diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualResponseBuilder.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualResponseBuilder.java index 2ddca87c2..0fd8ae2f4 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualResponseBuilder.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualResponseBuilder.java @@ -7,6 +7,8 @@ import java.lang.Integer; import java.lang.String; import java.sql.SQLException; import java.util.HashMap; +import java.util.List; +import java.util.Locale; import java.util.Map; import org.apache.commons.logging.Log; @@ -31,6 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; +import edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale; import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ExecuteDataRetrieval; import edu.cornell.mannlib.vitro.webapp.web.beanswrappers.ReadOnlyBeansWrapper; import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel; @@ -108,6 +111,8 @@ class IndividualResponseBuilder { */ // body.put("individual", wrap(itm, BeansWrapper.EXPOSE_SAFE)); body.put("labelCount", getLabelCount(itm.getUri(), vreq)); + //We also need to know the number of available locales + body.put("localesCount", SelectedLocale.getSelectableLocales(vreq).size()); body.put("profileType", getProfileType(itm.getUri(), vreq)); body.put("individual", wrap(itm, new ReadOnlyBeansWrapper())); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManageLabelsForIndividualGenerator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManageLabelsForIndividualGenerator.java index a9cb131d7..d34c1c5da 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManageLabelsForIndividualGenerator.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManageLabelsForIndividualGenerator.java @@ -258,6 +258,7 @@ public class ManageLabelsForIndividualGenerator extends BaseEditConfigurationGen HashMap localeCodeToNameMap = this.getFullCodeToLanguageNameMap(locales); //the labels already added by the user ArrayList existingLabels = this.getExistingLabels(config.getSubjectUri(), vreq); + int numberExistingLabels = existingLabels.size(); //existing labels keyed by language name and each of the list of labels is sorted by language name HashMap> existingLabelsByLanguageName = this.getLabelsSortedByLanguageName(existingLabels, localeCodeToNameMap, config, vreq); //Get available locales for the drop down for adding a new label, also sorted by language name @@ -270,6 +271,7 @@ public class ManageLabelsForIndividualGenerator extends BaseEditConfigurationGen //Save labels sorted by language name, untyped have "untyped" as the language name value config.addFormSpecificData("labelsSortedByLanguageName", existingLabelsByLanguageName); config.addFormSpecificData("selectLocale",availableLocalesForAdd); + config.addFormSpecificData("displayRemoveLink", (numberExistingLabels > 1)); //How do we edit? Will need to see diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/ConceptSemanticTypesPreprocessor.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/ConceptSemanticTypesPreprocessor.java deleted file mode 100644 index b95733b4f..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/ConceptSemanticTypesPreprocessor.java +++ /dev/null @@ -1,125 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors; - -import javax.servlet.http.HttpServletRequest; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.hp.hpl.jena.ontology.OntModel; -import com.hp.hpl.jena.query.Dataset; -import com.hp.hpl.jena.query.Query; -import com.hp.hpl.jena.query.QueryExecution; -import com.hp.hpl.jena.query.QueryExecutionFactory; -import com.hp.hpl.jena.query.QueryFactory; -import com.hp.hpl.jena.query.QuerySolutionMap; -import com.hp.hpl.jena.query.Syntax; -import com.hp.hpl.jena.rdf.model.Literal; -import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.rdf.model.ModelFactory; -import com.hp.hpl.jena.rdf.model.Property; -import com.hp.hpl.jena.rdf.model.ResIterator; -import com.hp.hpl.jena.rdf.model.Resource; -import com.hp.hpl.jena.rdf.model.ResourceFactory; -import com.hp.hpl.jena.rdf.model.Statement; -import com.hp.hpl.jena.shared.Lock; -import com.hp.hpl.jena.vocabulary.RDF; -import com.hp.hpl.jena.vocabulary.RDFS; - -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; -import edu.cornell.mannlib.vitro.webapp.dao.jena.DatasetWrapper; -import edu.cornell.mannlib.vitro.webapp.dao.jena.DatasetWrapperFactory; - -//We are representing semantic types from the UMLS Semantic Network as OWL Classes -//and this preprocessor will add the appropriate class information to the TBox - -public class ConceptSemanticTypesPreprocessor implements ModelChangePreprocessor { - - private static String VIVOCore = "http://vivoweb.org/ontology/core#"; - private static String SKOSConceptType = "http://www.w3.org/2004/02/skos/core#Concept"; - private Log log = LogFactory.getLog(ConceptSemanticTypesPreprocessor.class); - - private OntModel toUpdateModel = null; - - //Custom constructor - public ConceptSemanticTypesPreprocessor(OntModel updateModel) { - this.toUpdateModel = updateModel; - } - - @Override - public void preprocess(Model retractionsModel, Model additionsModel, - HttpServletRequest request) { - //Run a construct query against the additions model - String prefixes = "PREFIX rdfs:<" + RDFS.getURI() + "> " + - "PREFIX owl: " + - "PREFIX rdf:<" + RDF.getURI() + ">" + - "PREFIX skos:"; - String constructQuery = prefixes + " CONSTRUCT { " + - "?semanticType rdf:type owl:Class. " + - "?semanticType rdfs:subClassOf skos:Concept . " + - "?semanticType rdfs:label ?label. " + - "} WHERE { " + - "?concept rdf:type ?semanticType. " + - "?semanticType rdfs:label ?label . " + - "?semanticType rdfs:subClassOf skos:Concept . " + - "}"; - - //Execute construct query - Model constructedModel = ModelFactory.createDefaultModel(); - - - log.debug("CONSTRUCT query string " + constructQuery); - - Query query = null; - try { - query = QueryFactory.create(constructQuery, Syntax.syntaxARQ); - } catch(Throwable th){ - log.error("Could not create CONSTRUCT SPARQL query for query " + - "string. " + th.getMessage()); - log.error(constructQuery); - return; - } - - - - additionsModel.getLock().enterCriticalSection(Lock.READ); - QueryExecution qe = null; - try { - qe = QueryExecutionFactory.create( - query, additionsModel); - qe.execConstruct(constructedModel); - } catch (Exception e) { - log.error("Error getting constructed model for query string " + constructQuery); - } finally { - if (qe != null) { - qe.close(); - } - additionsModel.getLock().leaveCriticalSection(); - } - - //Add constructed model to the designated update model - toUpdateModel.enterCriticalSection(Lock.WRITE); - try { - toUpdateModel.add(constructedModel); - } catch (Exception e) { - log.error("Error adding statements to update model for " + constructQuery); - } finally { - toUpdateModel.leaveCriticalSection(); - } - - //Take this constructed model and remove from the additions model - additionsModel.enterCriticalSection(Lock.WRITE); - try { - additionsModel.remove(constructedModel.listStatements().toList()); - } catch (Exception e) { - log.error("Error removing statements from additions model for " + constructQuery); - } finally { - additionsModel.leaveCriticalSection(); - } - - } - - - -} diff --git a/webapp/web/i18n/all.properties b/webapp/web/i18n/all.properties index b235c903c..a2ff550d5 100644 --- a/webapp/web/i18n/all.properties +++ b/webapp/web/i18n/all.properties @@ -676,6 +676,8 @@ no_image = no image placeholder_image = placeholder image manage_labels = manage labels manage_list_of_labels = manage list of labels +view_list_of_labels = view list of labels +view = view add_label = Add Label add_label_for_language = Language unsupported_ie_version = This form is not supported in versions of Internet Explorer below version 8. Please upgrade your browser, or switch to another browser, such as FireFox. @@ -705,9 +707,10 @@ delete_entry_capitalized = Delete this entry? add_new_of_type = Add a new item of this type create_new_entry = Please create a new entry. no_appropriate_entry = If you don't find the appropriate entry on the selection list above - +return_to_individual = Return to Individual Page remove_menu_item = Remove menu item confirm_menu_item_delete = Are you sure you want to remove +remove_capitalized = Remove pretty_url = Pretty URL start_with_leading_slash = Must begin with a leading forward slash: / (e.g., /people) diff --git a/webapp/web/images/individual/manage-icon.png b/webapp/web/images/individual/manage-icon.png new file mode 100644 index 000000000..18ab57568 Binary files /dev/null and b/webapp/web/images/individual/manage-icon.png differ diff --git a/webapp/web/js/individual/manageLabelsForIndividual.js b/webapp/web/js/individual/manageLabelsForIndividual.js index 7e1c8128c..f80513fa9 100644 --- a/webapp/web/js/individual/manageLabelsForIndividual.js +++ b/webapp/web/js/individual/manageLabelsForIndividual.js @@ -182,14 +182,22 @@ var manageLabels = { //See if there are any other remove link if(languageName != "untyped") { //find if there are any other remove links for the same language + var allRemoveLinks = manageLabels.existingLabelsList.find("a.remove"); var removeLinks = manageLabels.existingLabelsList.find("a.remove[languageName='" + languageName + "']"); if(removeLinks.length == 0) { //if there aren't any other labels for this language, also remove the heading manageLabels.existingLabelsList.find("h3[languageName='" + languageName + "']").remove(); } + //Check to see if there is only one label left on the page, if so remove or hide the remove link + if(allRemoveLinks.length == 1) { + allRemoveLinks.remove(); + //These will be removed instead of hidden because currently add will reload the page + //whereas remove executes an ajax query and the page isn't reloaded + } } + }, //Determine if there are new locales that can be added to the options once a delete has occurred updateLocaleSelection:function() { diff --git a/webapp/web/templates/freemarker/body/individual/individual-vitro.ftl b/webapp/web/templates/freemarker/body/individual/individual-vitro.ftl index db57984b6..742d8470d 100644 --- a/webapp/web/templates/freemarker/body/individual/individual-vitro.ftl +++ b/webapp/web/templates/freemarker/body/individual/individual-vitro.ftl @@ -2,6 +2,9 @@ <#if !labelCount??> <#assign labelCount = 0 > +<#if !localesCount??> + <#assign localesCount = 1> + <#-- Default individual profile page template --> <#--@dumpAll /--> @@ -32,7 +35,7 @@ <#else>

<#-- Label --> - <@p.label individual editable labelCount /> + <@p.label individual editable labelCount localesCount/> <#-- Most-specific types --> <@p.mostSpecificTypes individual /> diff --git a/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividual.ftl b/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividual.ftl index dea117f5c..63f520a79 100644 --- a/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividual.ftl +++ b/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividual.ftl @@ -1,5 +1,5 @@ <#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> - +<#include "manageLabelsForIndividualTerms.ftl" > <#-- Custom form for managing labels for individuals --> <#import "manageLabelsForIndividualMacros.ftl" as m > <#assign requiredHint = " *" /> @@ -13,6 +13,10 @@ <#if editConfiguration.pageData.editable?has_content> <#assign editable = editConfiguration.pageData.editable /> +<#assign displayRemoveLink = true/> +<#if editConfiguration.pageData.displayRemoveLink?has_content> + <#assign displayRemoveLink = editConfiguration.pageData.displayRemoveLink/> + <#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content> <#assign submissionErrors = editSubmission.validationErrors/> <#assign submissionErrorsExist = "true" /> @@ -60,7 +64,7 @@ <#include "manageLabelsForIndividualSubmissionErrors.ftl"> <#include "manageLabelsForIndividualAddForm.ftl" > diff --git a/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividualMacros.ftl b/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividualMacros.ftl index 35839dada..b8258891d 100644 --- a/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividualMacros.ftl +++ b/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividualMacros.ftl @@ -1,10 +1,11 @@ <#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> <#--LabelsSorted is a hash keyed by language name where the value is a list of LabelInformation class objects--> -<#macro displayExistingLabelsForLanguage lang labelsSorted editable editGenerator> +<#macro displayExistingLabelsForLanguage lang labelsSorted editable editGenerator displayRemoveLink=true> <#--get label information for this language--> <#assign labelList = labelsSorted[lang] /> <#--Reset for every language--> <#assign labelSeq = []/> + <#list labelList as labelObject> <#assign labelLiteral = labelObject.labelLiteral /> <#assign labelStringValue = labelObject.labelStringValue /> @@ -25,19 +26,16 @@ <#assign labelStr = label > <#assign tagOrTypeStr = "" > -
  • ${labelStr} <#if labelSeq?seq_contains(labelStr)> (duplicate value) - <#if editable && labelEditLink?has_content> Edit - ${i18n().remove_capitalized} - + <@displayLabel labelSeq labelStr languageCode labelEditLink tagOrTypeStr editGenerator editable displayRemoveLink/> -
  • - <#assign labelSeq = labelSeq + [labelStr]> + <#assign labelSeq = labelSeq + [labelStr]> <#--ignore 'untyped' and display everything--> -<#macro displayExistingTypedLabels langList labelsSorted editable editGenerator> +<#macro displayExistingTypedLabels langList labelsSorted editable editGenerator displayRemoveLink=true> + + <#list langList as lang> <#if lang != "untyped">

    ${lang}

    @@ -65,15 +63,21 @@ <#assign labelStr = label > <#assign tagOrTypeStr = "" > -
  • ${labelStr} <#if labelSeq?seq_contains(labelStr)> (duplicate value) - <#if editable && labelEditLink?has_content> Edit - ${i18n().remove_capitalized} - - -
  • + <@displayLabel labelSeq labelStr languageCode labelEditLink tagOrTypeStr editGenerator editable displayRemoveLink/> <#assign labelSeq = labelSeq + [labelStr]> + + +<#macro displayLabel labelSeq labelStr languageCode labelEditLink tagOrTypeStr editGenerator editable displayRemoveLink> +
  • ${labelStr} <#if labelSeq?seq_contains(labelStr)> (duplicate value) + <#if editable> <#if labelEditLink?has_content> Edit + <#if displayRemoveLink = true> + ${i18n().remove_capitalized} + + + +
  • \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividualTerms.ftl b/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividualTerms.ftl new file mode 100644 index 000000000..913826af4 --- /dev/null +++ b/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividualTerms.ftl @@ -0,0 +1,4 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> + +<#--Some values for labels etc. may be different between vitro and other systems --> +<#assign returnText = "${i18n().return_to_individual}" /> \ No newline at end of file diff --git a/webapp/web/templates/freemarker/lib/lib-properties.ftl b/webapp/web/templates/freemarker/lib/lib-properties.ftl index 3393f9686..ee72732c0 100644 --- a/webapp/web/templates/freemarker/lib/lib-properties.ftl +++ b/webapp/web/templates/freemarker/lib/lib-properties.ftl @@ -208,22 +208,34 @@ name will be used as the label. --> <#-- Label --> -<#macro label individual editable labelCount> +<#macro label individual editable labelCount localesCount=1> <#assign labelPropertyUri = ("http://www.w3.org/2000/01/rdf-schema#label"?url) /> - <#-- Will need to deal with multiple languages as well--> + <#assign useEditLink = false /> + <#--edit link used if in edit mode and only one label and one language--> + <#if labelCount = 1 && editable && localeCount = 1 > + <#assign useEditLink = true/> + <#local label = individual.nameStatement> ${label.value} - <#if (labelCount > 1) && editable > + <#if useEditLink> + <@editingLinks "label" label editable /> + <#elseif editable || (labelCount > 1)> + <#--We display the link even when the user is not logged in case of multiple labels--> + <#if editable> + <#assign imageAlt = "${i18n().manage}" /> + <#assign linkTitle = "${i18n().manage_list_of_labels}"> + <#else> + <#assign linkTitle = "${i18n().view_list_of_labels}"> + <#assign imageAlt = "${i18n().view}" /> + <#-- Manage labels now goes to generator --> <#assign individualUri = individual.uri!""/> <#assign individualUri = (individualUri?url)/> - ${i18n().manage} + title="${linkTitle}"> + ${imageAlt} - <#else> - <@editingLinks "label" label editable />