From 74545944e44a0e07b21e0f36e2b8e2479b7b7077 Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Tue, 23 Feb 2021 22:31:14 +0100 Subject: [PATCH] Save query and rules at compilation creation --- .../generators/CompilationGenerator.java | 46 +++++++++++----- .../rdf/tbox/filegraph/text_structures.owl | 18 +++++++ .../templates/freemarker/compilationForm.ftl | 53 +++++++++++-------- 3 files changed, 80 insertions(+), 37 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/CompilationGenerator.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/CompilationGenerator.java index f98d0366..d11c7213 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/CompilationGenerator.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/CompilationGenerator.java @@ -53,13 +53,23 @@ public class CompilationGenerator extends BaseEditConfigurationGenerator impleme config.setTemplate( "compilationForm.ftl" ); config.setN3Required( generateN3Required(vreq)); + //Optional because user may have selected either person or individual of another kind //Person uses first name and last name whereas individual of other class would use label //middle name is also optional - config.setN3Optional(generateN3Optional()); + //config.setN3Optional(generateN3Optional()); config.addNewResource("newCompilation", vreq.getWebappDaoFactory().getDefaultNamespace()); config.addNewResource("newCompilationTOC", vreq.getWebappDaoFactory().getDefaultNamespace()); + config.addField(new FieldVTwo(). + setName("rawQueryString"). + setRangeDatatypeUri(XSD.xstring.getURI()). + setValidators(getCompilationNameValidators(vreq))); + config.addField(new FieldVTwo(). + setName("queryBuilderRules"). + setRangeDatatypeUri(XSD.xstring.getURI()). + setValidators(getCompilationNameValidators(vreq))); + for (int itemN = 1; itemN <= excerptsCounter; itemN++) { String tocItem = "tocItem" + itemN; config.addNewResource(tocItem, vreq.getWebappDaoFactory().getDefaultNamespace()); @@ -131,6 +141,8 @@ public class CompilationGenerator extends BaseEditConfigurationGenerator impleme String tocLevelName = "tocLevel" + itemN + "Name"; literals.add(tocItemName); literals.add(tocLevelName); + literals.add("rawQueryString"); + literals.add("queryBuilderRules"); } return literals; } @@ -153,10 +165,13 @@ public class CompilationGenerator extends BaseEditConfigurationGenerator impleme n3Req.append("@prefix ts: .\n"); n3Req.append("?newCompilation <" + VitroVocabulary.RDF_TYPE + "> <" + getTypeOfNew(vreq) + "> .\n"); n3Req.append("?newCompilation " + getModificationTime() + " .\n"); + n3Req.append("?newCompilation ts:rawQueryString ?rawQueryString .\n"); + n3Req.append("?newCompilation ts:queryBuilderRules ?queryBuilderRules .\n"); n3Req.append("?newCompilation <" + RDFS.label.getURI() + "> ?newCompilationLabel .\n"); n3Req.append("?newCompilation ts:hasTOC ?newCompilationTOC .\n"); n3Req.append("?newCompilationTOC <" + VitroVocabulary.RDF_TYPE + "> ts:TOC .\n"); n3Req.append("?newCompilationTOC <" + RDFS.label.getURI() + "> ?newCompilationLabel .\n"); + if (!associatedProfile.isEmpty()) { n3Req.append("<" + associatedProfile + "> ts:compilatorOf ?newCompilation .\n"); @@ -180,6 +195,16 @@ public class CompilationGenerator extends BaseEditConfigurationGenerator impleme } return list(n3Req.toString()); } + + private List generateN3Optional() { + List n3OptList = list(); + StringBuilder n3Opt = new StringBuilder(); + n3Opt.append("@prefix ts: .\n"); + n3Opt.append("?newCompilation ts:rawQueryString ?rawQueryString .\n"); + n3Opt.append("?newCompilation ts:queryBuilderRules ?queryBuilderRules .\n"); + n3OptList.add(n3Opt.toString()); + return n3OptList; + } private String getModificationTime() { SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); @@ -201,21 +226,14 @@ public class CompilationGenerator extends BaseEditConfigurationGenerator impleme } } - private List generateN3Optional() { - return getUrisOnForm(); - } - - //first and last name have validators if is person is true private List getCompilationNameValidators(VitroRequest vreq) { - List validators = new ArrayList(); - if(isCompilationType(vreq)) { - validators.add("nonempty"); - } - return validators; - } - - + List validators = new ArrayList(); + if (isCompilationType(vreq)) { + validators.add("nonempty"); + } + return validators; + } //Get parameter from HTTP request for type of new individual private String getTypeOfNew(VitroRequest vreq) { diff --git a/home/src/main/resources/rdf/tbox/filegraph/text_structures.owl b/home/src/main/resources/rdf/tbox/filegraph/text_structures.owl index 56294bb3..ef5adf7e 100644 --- a/home/src/main/resources/rdf/tbox/filegraph/text_structures.owl +++ b/home/src/main/resources/rdf/tbox/filegraph/text_structures.owl @@ -287,6 +287,24 @@ true + + Query Builder Rules + + + + + + + + + Raw Query String + + + + + + + diff --git a/webapp/src/main/webapp/templates/freemarker/compilationForm.ftl b/webapp/src/main/webapp/templates/freemarker/compilationForm.ftl index 366cb0ca..349fc0ba 100644 --- a/webapp/src/main/webapp/templates/freemarker/compilationForm.ftl +++ b/webapp/src/main/webapp/templates/freemarker/compilationForm.ftl @@ -48,32 +48,39 @@
<#if isCompilationType = "true"> -

- - -

+

+ + +

<#if excerptsCounter > 0 > - <#list 1..excerptsCounter as i> -

- - -

-

- - -

-

- - -

- - + <#list 1..excerptsCounter as i> +

+ + +

+

+ + +

+

+ + +

+ +

+ + +

+

+ + +

<#else> -

- - -

+

+ + +