From 03750cd669feae8bd37a31b91abcef98faa667bb Mon Sep 17 00:00:00 2001 From: j2blake Date: Tue, 10 Dec 2013 11:37:47 -0500 Subject: [PATCH 1/6] VIVO-581 Add a diagnostic page --- .../controller/admin/ShowConfiguration.java | 50 +++++++++++++++++++ webapp/web/WEB-INF/web.xml | 9 ++++ .../body/admin/admin-showConfiguration.ftl | 28 +++++++++++ .../page/partials/developerPanel.ftl | 2 + 4 files changed, 89 insertions(+) create mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java create mode 100644 webapp/web/templates/freemarker/body/admin/admin-showConfiguration.ftl diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java new file mode 100644 index 000000000..7a8a2322c --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java @@ -0,0 +1,50 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.controller.admin; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.SortedMap; +import java.util.TreeMap; + +import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; + +/** + * Show the current ConfigurationProperties and the Java system properties. + */ +public class ShowConfiguration extends FreemarkerHttpServlet { + @Override + protected Actions requiredActions(VitroRequest vreq) { + return Actions.AUTHORIZED; + } + + @Override + protected ResponseValues processRequest(VitroRequest vreq) { + Map body = new HashMap(); + body.put("configurationProperties", getConfigurationProperties(vreq)); + body.put("javaSystemProperties", getSystemProperties()); + return new TemplateResponseValues("admin-showConfiguration.ftl", body); + } + + private SortedMap getConfigurationProperties( + VitroRequest vreq) { + return new TreeMap<>(ConfigurationProperties.getBean(vreq) + .getPropertyMap()); + } + + private SortedMap getSystemProperties() { + Properties props = System.getProperties(); + SortedMap map = new TreeMap<>(); + for (String key : props.stringPropertyNames()) { + map.put(key, props.getProperty(key)); + } + return map; + } + +} diff --git a/webapp/web/WEB-INF/web.xml b/webapp/web/WEB-INF/web.xml index 1d393a7b9..08612be19 100644 --- a/webapp/web/WEB-INF/web.xml +++ b/webapp/web/WEB-INF/web.xml @@ -660,6 +660,15 @@ /admin/showAuth + + ShowConfiguration + edu.cornell.mannlib.vitro.webapp.controller.admin.ShowConfiguration + + + ShowConfiguration + /admin/showConfiguration + + StartupStatus edu.cornell.mannlib.vitro.webapp.controller.admin.StartupStatusController diff --git a/webapp/web/templates/freemarker/body/admin/admin-showConfiguration.ftl b/webapp/web/templates/freemarker/body/admin/admin-showConfiguration.ftl new file mode 100644 index 000000000..f77e0d518 --- /dev/null +++ b/webapp/web/templates/freemarker/body/admin/admin-showConfiguration.ftl @@ -0,0 +1,28 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> + +<#-- Template viewing the authorization mechanisms: current identifiers, factories, policies, etc. --> + +${stylesheets.add('')} + +

Configuration settings

+ +
+

Build and runtime properties:

+ + <#list configurationProperties?keys as key> + + + + + +
${key}${configurationProperties[key]}
+

Java system properties:

+ + <#list javaSystemProperties?keys as key> + + + + + +
${key}${javaSystemProperties[key]}
+
diff --git a/webapp/web/templates/freemarker/page/partials/developerPanel.ftl b/webapp/web/templates/freemarker/page/partials/developerPanel.ftl index 82b2a0c80..a9437a3d8 100644 --- a/webapp/web/templates/freemarker/page/partials/developerPanel.ftl +++ b/webapp/web/templates/freemarker/page/partials/developerPanel.ftl @@ -56,6 +56,8 @@ Links
Set log levels + Show Configuration +
Show authorization info Show background threads From 0a00aee68488d43bf89cd36f65c30d696b91ede4 Mon Sep 17 00:00:00 2001 From: j2blake Date: Tue, 10 Dec 2013 12:07:28 -0500 Subject: [PATCH 2/6] VIVO-581 Add a smoke test for Java version --- .../webapp/servlet/setup/JvmSmokeTests.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JvmSmokeTests.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JvmSmokeTests.java index c9241320f..4a5630801 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JvmSmokeTests.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JvmSmokeTests.java @@ -22,9 +22,26 @@ public class JvmSmokeTests implements ServletContextListener { ServletContext ctx = sce.getServletContext(); StartupStatus ss = StartupStatus.getBean(ctx); + checkJvmLevel(ss); checkTempDirectory(ss); } + /** + * We need to run at 1.7 or later. + */ + private void checkJvmLevel(StartupStatus ss) { + String specLevel = System.getProperty("java.specification.version", ""); + if (specLevel.isEmpty()) { + ss.warning(this, "Can't determine the current level of Java. " + + "VIVO requires at least Java 1.7."); + } else if (specLevel.compareTo("1.7") < 0) { + ss.warning(this, "VIVO requires at least Java 1.7 - " + + "currently running on Java " + specLevel); + } else { + ss.info(this, "Java version is " + specLevel); + } + } + /** * Check the Java temp directory. Make sure that it exists, it is a * directory, we can read it, we can write to it. From 0c791852541f7bcf2089e2d668f8edf1d0b973f9 Mon Sep 17 00:00:00 2001 From: tworrall Date: Tue, 10 Dec 2013 12:44:04 -0500 Subject: [PATCH 3/6] VIVO-637 date time generator changes for various date time properties --- .../generators/DateTimePropertyGenerator.java | 54 +++++++++++++++++++ .../edit/forms/dateTimeValueForm.ftl | 3 +- 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimePropertyGenerator.java diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimePropertyGenerator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimePropertyGenerator.java new file mode 100644 index 000000000..24ed50d68 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimePropertyGenerator.java @@ -0,0 +1,54 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; + + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import javax.servlet.http.HttpSession; + +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.vocabulary.XSD; + +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo; +import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils; +import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode; +import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils; + +/** + * + * @author hjk54 + * + * There are multiple date time properties in VIVO, all of which have a DateTimeValue individual as an object. + * I am extending DateTimeValueFormGenerator to enable the predicate to be utilized as the "toDateTimeValue" property, i.e. + * the property associating the subject with the date time value individual. The dateTimeValueForm template has been + * used as the basis for the general form for this generator that can be applied to multiple properties. + */ + +public class DateTimePropertyGenerator extends DateTimeValueFormGenerator { + + String predicate = null; + @Override + public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, + HttpSession session) { + predicate = EditConfigurationUtils.getPredicateUri(vreq); + EditConfigurationVTwo conf = super.getEditConfiguration(vreq, session); + return conf; + } + + //isolating the predicate in this fashion allows this class to be subclassed for other date time value + //properties + @Override + protected String getToDateTimeValuePredicate() { + return predicate; + } + +} \ No newline at end of file diff --git a/webapp/web/templates/freemarker/edit/forms/dateTimeValueForm.ftl b/webapp/web/templates/freemarker/edit/forms/dateTimeValueForm.ftl index 8596e3497..b77192f64 100644 --- a/webapp/web/templates/freemarker/edit/forms/dateTimeValueForm.ftl +++ b/webapp/web/templates/freemarker/edit/forms/dateTimeValueForm.ftl @@ -33,8 +33,7 @@ ${i18n().cancel_link}

-${stylesheets.add('', - '')} +${stylesheets.add('')} ${scripts.add('', '')} \ No newline at end of file From d4443fe60135ffe72737a40b14e1fee6efebe6ae Mon Sep 17 00:00:00 2001 From: j2blake Date: Tue, 10 Dec 2013 14:59:30 -0500 Subject: [PATCH 4/6] =?UTF-8?q?VIVO-581=20Restrict=20access,=20and=20don?= =?UTF-8?q?=E2=80=99t=20give=20out=20the=20DB=20password.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/rdf/auth/everytime/permission_config.n3 | 1 + .../webapp/auth/permissions/SimplePermission.java | 2 ++ .../webapp/controller/admin/ShowConfiguration.java | 13 ++++++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/webapp/rdf/auth/everytime/permission_config.n3 b/webapp/rdf/auth/everytime/permission_config.n3 index e0b1c1960..3af62fb71 100644 --- a/webapp/rdf/auth/everytime/permission_config.n3 +++ b/webapp/rdf/auth/everytime/permission_config.n3 @@ -20,6 +20,7 @@ auth:ADMIN auth:hasPermission simplePermission:ManageUserAccounts ; auth:hasPermission simplePermission:RebuildVClassGroupCache ; auth:hasPermission simplePermission:RefreshVisualizationCache ; + auth:hasPermission simplePermission:SeeConfiguration ; auth:hasPermission simplePermission:SeeStartupStatus ; auth:hasPermission simplePermission:UseAdvancedDataToolsPages ; auth:hasPermission simplePermission:UseMiscellaneousAdminPages ; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/permissions/SimplePermission.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/permissions/SimplePermission.java index 0484638bd..539356e17 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/permissions/SimplePermission.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/permissions/SimplePermission.java @@ -64,6 +64,8 @@ public class SimplePermission extends Permission { NAMESPACE + "RebuildVClassGroupCache"); public static final SimplePermission REFRESH_VISUALIZATION_CACHE = new SimplePermission( NAMESPACE + "RefreshVisualizationCache"); + public static final SimplePermission SEE_CONFIGURATION = new SimplePermission( + NAMESPACE + "SeeConfiguration"); public static final SimplePermission SEE_INDVIDUAL_EDITING_PANEL = new SimplePermission( NAMESPACE + "SeeIndividualEditingPanel"); public static final SimplePermission SEE_REVISION_INFO = new SimplePermission( diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java index 7a8a2322c..c25d845eb 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java @@ -8,6 +8,7 @@ import java.util.Properties; import java.util.SortedMap; import java.util.TreeMap; +import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; @@ -21,7 +22,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem public class ShowConfiguration extends FreemarkerHttpServlet { @Override protected Actions requiredActions(VitroRequest vreq) { - return Actions.AUTHORIZED; + return SimplePermission.SEE_CONFIGURATION.ACTIONS; } @Override @@ -34,8 +35,14 @@ public class ShowConfiguration extends FreemarkerHttpServlet { private SortedMap getConfigurationProperties( VitroRequest vreq) { - return new TreeMap<>(ConfigurationProperties.getBean(vreq) - .getPropertyMap()); + ConfigurationProperties props = ConfigurationProperties.getBean(vreq); + TreeMap map = new TreeMap<>(props.getPropertyMap()); + for (String key : map.keySet()) { + if (key.toLowerCase().endsWith("password")) { + map.put(key, "********"); + } + } + return map; } private SortedMap getSystemProperties() { From 46b93406556559abae8c438f55531a8151d4f33f Mon Sep 17 00:00:00 2001 From: j2blake Date: Tue, 10 Dec 2013 15:09:56 -0500 Subject: [PATCH 5/6] =?UTF-8?q?VIVO-581=20Avoid=20Files.isReadable()=20?= =?UTF-8?q?=E2=80=94=20it=20runs=20slowly=20on=20some=20Windows=20machines?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../webapp/freemarker/loader/FreemarkerTemplateLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/freemarker/loader/FreemarkerTemplateLoader.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/freemarker/loader/FreemarkerTemplateLoader.java index 0bef38b30..1dd73816a 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/freemarker/loader/FreemarkerTemplateLoader.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/freemarker/loader/FreemarkerTemplateLoader.java @@ -285,7 +285,7 @@ public class FreemarkerTemplateLoader implements TemplateLoader { } public boolean fileQualifies(Path path) { - return Files.isReadable(path) && !Files.isDirectory(path); + return !Files.isDirectory(path); } public SortedSet getMatches() { From 8a490c6125e998a6e8c637fb502104577de81ec7 Mon Sep 17 00:00:00 2001 From: hudajkhan Date: Tue, 10 Dec 2013 15:41:45 -0500 Subject: [PATCH 6/6] vivo 638 fixing query for existing interval value to utilize variable for object so editing works correctly --- .../VTwo/DateTimeWithPrecisionVTwo.java | 76 +++++++++++-------- .../DateTimeIntervalFormGenerator.java | 19 ++--- .../DateTimeValueFormGenerator.java | 22 ++---- 3 files changed, 58 insertions(+), 59 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/DateTimeWithPrecisionVTwo.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/DateTimeWithPrecisionVTwo.java index 2c3fa5587..d4dbc8669 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/DateTimeWithPrecisionVTwo.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/DateTimeWithPrecisionVTwo.java @@ -167,40 +167,50 @@ public class DateTimeWithPrecisionVTwo extends BaseEditElementVTwo { DateTime value = getTimeValue(editConfig,editSub); /* This is the case where there is a precision so there should be a datetime */ - if( value == null ) - log.debug("Field " + getFieldName() + " has precision " + precisionUri - + " but the date time is " + value); - - /* only put the values in the map for ones which are significant based on the precision */ - if( existingPrec.ordinal() >= VitroVocabulary.Precision.SECOND.ordinal() ) - map.put("second", Integer.toString(value.getSecondOfMinute() )) ; - else - map.put("second", ""); - - if( existingPrec.ordinal() >= VitroVocabulary.Precision.MINUTE.ordinal() ) - map.put("minute", Integer.toString(value.getMinuteOfHour()) ); - else - map.put("minute", ""); - - if( existingPrec.ordinal() >= VitroVocabulary.Precision.HOUR.ordinal() ) - map.put("hour", Integer.toString(value.getHourOfDay()) ); - else - map.put("hour", ""); - - if( existingPrec.ordinal() >= VitroVocabulary.Precision.DAY.ordinal() ) - map.put("day", Integer.toString(value.getDayOfMonth()) ); - else - map.put("day", ""); - - if( existingPrec.ordinal() >= VitroVocabulary.Precision.MONTH.ordinal() ) - map.put("month", Integer.toString(value.getMonthOfYear())); - else - map.put("month", ""); - - if( existingPrec.ordinal() >= VitroVocabulary.Precision.YEAR.ordinal() ) - map.put("year", Integer.toString(value.getYear())); - else + if( value == null ) { + //If there is no value, then this is an error condition + log.error("Field " + getFieldName() + " has precision " + precisionUri + + " but the date time value is null "); map.put("year", ""); + map.put("month", ""); + map.put("day", ""); + map.put("hour", ""); + map.put("minute", ""); + map.put("second", "") ; + + } else { + + /* only put the values in the map for ones which are significant based on the precision */ + if( existingPrec.ordinal() >= VitroVocabulary.Precision.SECOND.ordinal() ) + map.put("second", Integer.toString(value.getSecondOfMinute() )) ; + else + map.put("second", ""); + + if( existingPrec.ordinal() >= VitroVocabulary.Precision.MINUTE.ordinal() ) + map.put("minute", Integer.toString(value.getMinuteOfHour()) ); + else + map.put("minute", ""); + + if( existingPrec.ordinal() >= VitroVocabulary.Precision.HOUR.ordinal() ) + map.put("hour", Integer.toString(value.getHourOfDay()) ); + else + map.put("hour", ""); + + if( existingPrec.ordinal() >= VitroVocabulary.Precision.DAY.ordinal() ) + map.put("day", Integer.toString(value.getDayOfMonth()) ); + else + map.put("day", ""); + + if( existingPrec.ordinal() >= VitroVocabulary.Precision.MONTH.ordinal() ) + map.put("month", Integer.toString(value.getMonthOfYear())); + else + map.put("month", ""); + + if( existingPrec.ordinal() >= VitroVocabulary.Precision.YEAR.ordinal() ) + map.put("year", Integer.toString(value.getYear())); + else + map.put("year", ""); + } } return map; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimeIntervalFormGenerator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimeIntervalFormGenerator.java index 7daa9743c..9cb4033f9 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimeIntervalFormGenerator.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimeIntervalFormGenerator.java @@ -70,8 +70,7 @@ public class DateTimeIntervalFormGenerator extends "startField-value", existingStartDateQuery); conf.addSparqlForExistingLiteral( "endField-value", existingEndDateQuery); - conf.addSparqlForExistingUris( - getNodeVar(), existingIntervalNodeQuery); + conf.addSparqlForExistingUris("startNode", existingStartNodeQuery); conf.addSparqlForExistingUris("endNode", existingEndNodeQuery); conf.addSparqlForExistingUris( @@ -115,7 +114,7 @@ public class DateTimeIntervalFormGenerator extends final String existingStartDateQuery = "SELECT ?existingDateStart WHERE { \n" + - "?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" + + "?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" + getNodeN3Var() + " a <" + intervalType + "> . \n" + getNodeN3Var() + " <" + intervalToStart + "> ?startNode . \n" + "?startNode a <" + dateTimeValueType + "> . \n" + @@ -123,34 +122,30 @@ public class DateTimeIntervalFormGenerator extends final String existingEndDateQuery = "SELECT ?existingEndDate WHERE { \n" + - "?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" + + "?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" + getNodeN3Var() + " a <" + intervalType + "> . \n" + getNodeN3Var() + " <" + intervalToEnd + "> ?endNode . \n" + "?endNode a <" + dateTimeValueType + "> . \n " + "?endNode <" + dateTimeValue + "> ?existingEndDate . }"; - final String existingIntervalNodeQuery = - "SELECT ?existingIntervalNode WHERE { \n" + - "?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" + - "?existingIntervalNode a <" + intervalType + "> . }"; final String existingStartNodeQuery = "SELECT ?existingStartNode WHERE { \n" + - "?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" + + "?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" + getNodeN3Var() + " a <" + intervalType + "> . \n" + getNodeN3Var() + " <" + intervalToStart + "> ?existingStartNode . \n" + "?existingStartNode a <" + dateTimeValueType + "> .} "; final String existingEndNodeQuery = "SELECT ?existingEndNode WHERE { \n" + - "?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" + + "?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" + getNodeN3Var() + " a <" + intervalType + "> . \n" + getNodeN3Var() + " <" + intervalToEnd + "> ?existingEndNode . \n" + "?existingEndNode a <" + dateTimeValueType + "> .} "; final String existingStartPrecisionQuery = "SELECT ?existingStartPrecision WHERE { \n" + - "?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" + + "?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" + getNodeN3Var() + " a <" + intervalType + "> . \n" + getNodeN3Var() + " <" + intervalToStart + "> ?startNode . \n" + "?startNode a <" + dateTimeValueType + "> . \n" + @@ -158,7 +153,7 @@ public class DateTimeIntervalFormGenerator extends final String existingEndPrecisionQuery = "SELECT ?existingEndPrecision WHERE { \n" + - "?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" + + "?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" + getNodeN3Var() + " a <" + intervalType + "> . \n" + getNodeN3Var() + " <" + intervalToEnd + "> ?endNode . \n" + "?endNode a <" + dateTimeValueType + "> . \n" + diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimeValueFormGenerator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimeValueFormGenerator.java index 7ecf1695e..360d47cb6 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimeValueFormGenerator.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimeValueFormGenerator.java @@ -46,7 +46,7 @@ public class DateTimeValueFormGenerator extends BaseEditConfigurationGenerator conf.setVarNameForSubject("subject"); conf.setVarNameForPredicate("toDateTimeValue"); conf.setVarNameForObject("valueNode"); - + //Value node value will be in scope if we have an object uri that exists for editing conf.setN3Optional(Arrays.asList(getN3ForValue())); conf.addNewResource("valueNode", DEFAULT_NS_FOR_NEW_RESOURCE); @@ -55,7 +55,6 @@ public class DateTimeValueFormGenerator extends BaseEditConfigurationGenerator "dateTimeField-value", getExistingDateTimeValueQuery()); conf.addSparqlForExistingUris( "dateTimeField-precision", getExistingPrecisionQuery()); - conf.addSparqlForExistingUris("valueNode", getExistingNodeQuery()); FieldVTwo dateTimeField = new FieldVTwo().setName(this.getDateTimeFieldName()); dateTimeField.setEditElement(new DateTimeWithPrecisionVTwo(dateTimeField, @@ -84,23 +83,18 @@ public class DateTimeValueFormGenerator extends BaseEditConfigurationGenerator protected String getExistingDateTimeValueQuery () { return "SELECT ?existingDateTimeValue WHERE { \n" + - "?subject <" + this.getToDateTimeValuePredicate() + "> ?existingValueNode . \n" + - "?existingValueNode a <" + valueType + "> . \n" + - "?existingValueNode <" + dateTimeValue + "> ?existingDateTimeValue }"; + "?subject <" + this.getToDateTimeValuePredicate() + "> ?valueNode . \n" + + "?valueNode a <" + valueType + "> . \n" + + "?valueNode <" + dateTimeValue + "> ?existingDateTimeValue }"; } protected String getExistingPrecisionQuery() { return "SELECT ?existingPrecision WHERE { \n" + - "?subject <" + this.getToDateTimeValuePredicate() + "> ?existingValueNode . \n" + - "?existingValueNode a <" + valueType + "> . \n" + - "?existingValueNode <" + dateTimePrecision + "> ?existingPrecision }"; - } - protected String getExistingNodeQuery() { - return "SELECT ?existingNode WHERE { \n" + - "?subject <" + this.getToDateTimeValuePredicate() + "> ?existingNode . \n" + - "?existingNode a <" + valueType + "> }"; - + "?subject <" + this.getToDateTimeValuePredicate() + "> ?valueNode . \n" + + "?valueNode a <" + valueType + "> . \n" + + "?valueNode <" + dateTimePrecision + "> ?existingPrecision }"; } + public static String getNodeVar() { return "valueNode"; }