updates for label addition as well as beginning changes for concepts search service

This commit is contained in:
hudajkhan 2013-09-03 15:32:51 -04:00
parent 8ed2523a7d
commit 419af234c4
4 changed files with 74 additions and 6 deletions

View file

@ -0,0 +1,40 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-- Custom form for managing labels for individuals - specific to VIVO which handles people as well -->
<#assign isPersonType = editConfiguration.pageData.isPersonType />
<form id="addLabelForm" name="addLabelForm" class="customForm" action="${submitUrl}">
<h2>${i18n().add_label}</h2>
<#if isPersonType = "true">
<p>
<label for="firstName">${i18n().first_name} ${requiredHint}</label>
<input size="30" type="text" id="firstName" name="firstName" value="${firstNameValue}" />
</p>
<p>
<label for="lastName">${i18n().last_name} ${requiredHint}</label>
<input size="30" type="text" id="lastName" name="lastName" value="${lastNameValue}" />
</p>
<#else>
<p>
<label for="name">${i18n().name_capitalized} ${requiredHint}</label>
<input size="30" type="text" id="label" name="label" value="${labelValue}" />
</p>
</#if>
<label for="newLabelLanguage">${i18n().add_label_for_language}</label>
<select name="newLabelLanguage" id="newLabelLanguage" >
<option value=""<#if !newLabelLanguageValue?has_content> selected="selected"</#if>>${i18n().select_locale}</option>
<#if editConfiguration.pageData.selectLocale?has_content>
<#assign selectLocale = editConfiguration.pageData.selectLocale />
<#list selectLocale as locale>
<option value="${locale.code}"<#if newLabelLanguageValue?has_content && locale.code == newLabelLanguageValue> selected="selected"</#if>>${locale.label}</option>
</#list>
</#if>
</select>
<input type="hidden" name="editKey" id="editKey" value="${editKey}"/>
<input type="submit" class="submit" id="submit" value="${i18n().save_button}" role="button" role="input" />
${i18n().or}
<a href="${urls.referringPage}" class="cancel" title="${i18n().cancel_title}" >${i18n().cancel_link}</a>
<p id="requiredLegend" class="requiredHint">* ${i18n().required_fields}</p>
</form>

View file

@ -0,0 +1,27 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#--VIVO specific errors for person-->
<#import "lib-vivo-form.ftl" as lvf>
<#--Get existing value for specific data literals and uris, in case the form is returned because of an error-->
<#assign firstNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "firstName")/>
<#assign lastNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "lastName")/>
<#assign labelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "label")/>
<#assign newLabelLanguageValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "newLabelLanguage")/>
<#if submissionErrors?has_content >
<section id="error-alert" role="alert">
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="${i18n().error_alert_icon}" />
<p>
<#list submissionErrors?keys as errorFieldName>
<#if errorFieldName == "firstName">
${i18n().enter_first_name}
<#elseif errorFieldName == "lastName">
${i18n().enter_last_name}
<#elseif errorFieldName == "label">
${i18n().enter_a_name}
</#if>
<br />
</#list>
</p>
</section>
</#if>

View file

@ -425,6 +425,7 @@ public class AgrovocService implements ExternalConceptService {
} }
protected String getDbpediaDescription(String uri) throws Exception{ protected String getDbpediaDescription(String uri) throws Exception{
String descriptionSource = " (Source: DBpedia)";
String description = new String(); String description = new String();
String qs = "" String qs = ""
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
@ -476,7 +477,8 @@ public class AgrovocService implements ExternalConceptService {
} catch (Exception ex) { } catch (Exception ex) {
throw ex; throw ex;
} }
return description; //Adding source so it is clear that this description comes from DBPedia
return description + descriptionSource;
} }
/** /**

View file

@ -47,10 +47,9 @@ public class AddAssociatedConceptGenerator extends VivoBaseGenerator implements
private Log log = LogFactory.getLog(AddAssociatedConceptGenerator.class); private Log log = LogFactory.getLog(AddAssociatedConceptGenerator.class);
private String template = "addAssociatedConcept.ftl"; private String template = "addAssociatedConcept.ftl";
private static String SKOSConceptType = "http://www.w3.org/2004/02/skos/core#Concept";
//TODO: Set this to a dynamic mechanism //TODO: Set this to a dynamic mechanism
private static String VIVOCore = "http://vivoweb.org/ontology/core#"; private static String VIVOCore = "http://vivoweb.org/ontology/core#";
private static String SKOSConceptType = "http://www.w3.org/2004/02/skos/core#Concept";
@Override @Override
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) { public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo(); EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo();
@ -173,13 +172,13 @@ public class AddAssociatedConceptGenerator extends VivoBaseGenerator implements
//Optional N3, includes possibility of semantic type which may or may not be included //Optional N3, includes possibility of semantic type which may or may not be included
//label and source are independent of semantic type //label and source are independent of semantic type
//concept semantic type uri is a placeholder which is actually processed in the sparql update preprocessor
private List<String> generateN3Optional() { private List<String> generateN3Optional() {
return list("?conceptNode <" + RDFS.label.getURI() + "> ?conceptLabel .\n" + return list("?conceptNode <" + RDFS.label.getURI() + "> ?conceptLabel .\n" +
"?conceptNode <" + RDFS.isDefinedBy.getURI() + "> ?conceptSource .", "?conceptNode <" + RDFS.isDefinedBy.getURI() + "> ?conceptSource .",
"?conceptNode <" + VIVOCore + "hasConceptSemanticType> ?conceptSemanticTypeURI ." + "?conceptNode <" + RDF.type + "> ?conceptSemanticTypeURI ." +
"?conceptSemanticTypeURI <" + VIVOCore + "isConceptSemanticTypeOf> ?conceptNode ." +
"?conceptSemanticTypeURI <" + RDFS.label.getURI() + "> ?conceptSemanticTypeLabel ." + "?conceptSemanticTypeURI <" + RDFS.label.getURI() + "> ?conceptSemanticTypeLabel ." +
"?conceptSemanticTypeURI <" + RDF.type.getURI() + "> <" + VIVOCore + "ConceptSemanticType> ." "?conceptSemanticTypeURI <" + RDFS.subClassOf + "> <" + SKOSConceptType + "> ."
); );
} }