From 8be60063e05f6d0048819782d4f15ea100bb4115 Mon Sep 17 00:00:00 2001 From: j2blake Date: Wed, 16 Oct 2013 15:35:06 -0400 Subject: [PATCH 1/2] VIVO-364 Test for various language-setup problems. --- .../ConfigurationPropertiesSmokeTests.java | 56 +++++++++++++++++++ .../selection/LocaleSelectionDataGetter.java | 1 + 2 files changed, 57 insertions(+) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/config/ConfigurationPropertiesSmokeTests.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/config/ConfigurationPropertiesSmokeTests.java index 7d7a6211b..3f0419cfa 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/config/ConfigurationPropertiesSmokeTests.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/config/ConfigurationPropertiesSmokeTests.java @@ -18,6 +18,7 @@ import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -39,6 +40,10 @@ public class ConfigurationPropertiesSmokeTests implements private static final String PROPERTY_DB_DRIVER_CLASS_NAME = "VitroConnection.DataSource.driver"; private static final String PROPERTY_DB_TYPE = "VitroConnection.DataSource.dbtype"; private static final String PROPERTY_DEFAULT_NAMESPACE = "Vitro.defaultNamespace"; + private static final String PROPERTY_LANGUAGE_BUILD = "languages.addToBuild"; + private static final String PROPERTY_LANGUAGE_SELECTABLE = "languages.selectableLocales"; + private static final String PROPERTY_LANGUAGE_FORCE = "languages.forceLocale"; + private static final String PROPERTY_LANGUAGE_FILTER = "RDFService.languageFilter"; private static final String DEFAULT_DB_DRIVER_CLASS = "com.mysql.jdbc.Driver"; @@ -51,6 +56,7 @@ public class ConfigurationPropertiesSmokeTests implements checkHomeDirectory(ctx, props, ss); checkDatabaseConnection(ctx, props, ss); checkDefaultNamespace(ctx, props, ss); + checkLanguages(props, ss); } /** @@ -283,6 +289,56 @@ public class ConfigurationPropertiesSmokeTests implements } } + /** + * Warn if we set up the languages incorrectly: + * + * Must build with a language in order to select languages. Can't select + * languages and force language. Shouldn't build with language unless + * language filtering is enabled. + */ + private void checkLanguages(ConfigurationProperties props, StartupStatus ss) { + String buildString = props.getProperty(PROPERTY_LANGUAGE_BUILD); + boolean buildWithLanguages = StringUtils.isNotEmpty(buildString); + + String selectString = props.getProperty(PROPERTY_LANGUAGE_SELECTABLE); + boolean selectableLanguages = StringUtils.isNotEmpty(selectString); + + String forceString = props.getProperty(PROPERTY_LANGUAGE_FORCE); + boolean forceLanguage = StringUtils.isNotEmpty(forceString); + + String filterString = props.getProperty(PROPERTY_LANGUAGE_FILTER, + "true"); + boolean languageFilter = Boolean.valueOf(filterString); + + if (selectableLanguages && !buildWithLanguages) { + ss.warning(this, String.format("Problem with Language setup - " + + "runtime.properties specifies a " + + "list of selectable languages (%s = %s), but " + + "build.properties did not include any languages with %s", + PROPERTY_LANGUAGE_SELECTABLE, selectString, + PROPERTY_LANGUAGE_BUILD)); + } + + if (selectableLanguages && forceLanguage) { + ss.warning(this, String.format("Problem with Language setup - " + + "runtime.properties specifies a " + + "forced locale (%s = %s), and also a list of selectable " + + "languages (%s = %s). These options are incompatible.", + PROPERTY_LANGUAGE_FORCE, forceString, + PROPERTY_LANGUAGE_SELECTABLE, selectString)); + } + + if (buildWithLanguages && !languageFilter) { + ss.warning(this, String.format("Problem with Language setup - " + + "build.properties includes one or more additional " + + "languages (%s = %s), but runtime.properties has " + + "disabled language filtering (%s = %s). This will " + + "likely result in a mix of languages in the " + + "application.", PROPERTY_LANGUAGE_BUILD, buildString, + PROPERTY_LANGUAGE_FILTER, filterString)); + } + } + @Override public void contextDestroyed(ServletContextEvent sce) { // nothing to do at shutdown diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectionDataGetter.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectionDataGetter.java index 9bd5107f2..f1086edab 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectionDataGetter.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectionDataGetter.java @@ -37,6 +37,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.DataGetter; * code = [the code for the Locale, e.g. "en_US"] * label = [the alt text for the Locale, e.g. "Spanish (Spain)"] * imageUrl = [the URL of the image that represents the Locale] + * selected = [true, if this locale is currently selected] * } * } * } From 4e851d0c357a653b2eb17d4454e4da5cf2c17ebc Mon Sep 17 00:00:00 2001 From: tworrall Date: Wed, 16 Oct 2013 15:53:44 -0400 Subject: [PATCH 2/2] VIVO-372: check the domainUri to correctly display the manage icon --- .../individual/PropertyTemplateModel.java | 4 ++++ .../partials/individual/individual-properties.ftl | 2 +- .../web/templates/freemarker/lib/lib-properties.ftl | 11 ++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/PropertyTemplateModel.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/PropertyTemplateModel.java index 43240e66f..f7d5c603b 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/PropertyTemplateModel.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/PropertyTemplateModel.java @@ -129,6 +129,10 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel { return rangeUri; } + public String getDomainUri() { + return domainUri; + } + public String getAddUrl() { //log.info("addUrl=" + addUrl); return (addUrl != null) ? addUrl : ""; diff --git a/webapp/web/templates/freemarker/body/partials/individual/individual-properties.ftl b/webapp/web/templates/freemarker/body/partials/individual/individual-properties.ftl index 610d4b409..7d3dd7b6b 100644 --- a/webapp/web/templates/freemarker/body/partials/individual/individual-properties.ftl +++ b/webapp/web/templates/freemarker/body/partials/individual/individual-properties.ftl @@ -12,7 +12,7 @@
<#-- Property display name --> - <#if rangeClass == "Authorship" && editable > + <#if rangeClass == "Authorship" && editable && property.domainUri?contains("Person")>

${property.name} <@p.addLink property editable /> <@p.verboseDisplay property /> style="padding-top:10px" > ${i18n().manage_publications_link} diff --git a/webapp/web/templates/freemarker/lib/lib-properties.ftl b/webapp/web/templates/freemarker/lib/lib-properties.ftl index fb69a6a8a..d5b5ec9c2 100644 --- a/webapp/web/templates/freemarker/lib/lib-properties.ftl +++ b/webapp/web/templates/freemarker/lib/lib-properties.ftl @@ -128,16 +128,21 @@ name will be used as the label. --> <#else> <#local rangeUri = "" /> + <#if property.domainUri?? > + <#local domainUri = property.domainUri /> + <#else> + <#local domainUri = "" /> + <#if editable> <#local url = property.addUrl> <#if url?has_content> - <@showAddLink property.localName label url rangeUri/> + <@showAddLink property.localName label url rangeUri domainUri/> -<#macro showAddLink propertyLocalName label url rangeUri> - <#if rangeUri?contains("Authorship") || rangeUri?contains("URL") || rangeUri?contains("Editorship") || label == "hasResearchArea"> +<#macro showAddLink propertyLocalName label url rangeUri domainUri=""> + <#if (rangeUri?contains("Authorship") && domainUri?contains("IAO_0000030")) || (rangeUri?contains("Editorship") && domainUri?contains("IAO_0000030"))|| rangeUri?contains("URL") || label == "hasResearchArea"> ${i18n().manage} <#else>