diff --git a/productMods/edit/forms/js/addConcept.js b/productMods/edit/forms/js/addConcept.js index fe3466df..57e830ae 100644 --- a/productMods/edit/forms/js/addConcept.js +++ b/productMods/edit/forms/js/addConcept.js @@ -206,7 +206,7 @@ var addConceptForm = { var htmlAdd = "
  • " + "
    " + "" + - addConceptForm.generateIndividualCUIInput(cuiURI, label, definition, type, definedBy) + + addConceptForm.generateIndividualCUIInput(cuiURI, label, type, definedBy) + label + addConceptForm.generateIndividualTypeDisplay(type) + "" + addConceptForm.generateIndividualDefinitionDisplay(definition) + "
    " + diff --git a/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl b/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl index 8b2ae2e7..569da54a 100644 --- a/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl +++ b/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl @@ -3,6 +3,7 @@ <#assign existingConcepts = editConfiguration.pageData.existingConcepts/> <#assign userDefinedConceptUrl = editConfiguration.pageData.userDefinedConceptUrl/> +<#assign sources = editConfiguration.pageData.searchServices/> <#--If edit submission exists, then retrieve validation errors if they exist--> <#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content> @@ -10,10 +11,6 @@ -<#--This is set for testing purposes - will be retrieved dynamically from the generator later--> -<#assign sources = [{"uri":"http://link.informatics.stonybrook.edu/umls/", "label":"UMLS"}, {"uri":"http://www.fao.org/webservices/Agrovoc", "label":"Agrovoc"}]/> -<#assign selectedSource = "UMLS" /> -

    Manage Concepts

    @@ -81,9 +78,9 @@
    - <#list sources as source> - checked /> - + <#list sources?keys as sourceUri> + +
    diff --git a/src/edu/cornell/mannlib/semservices/service/impl/AgrovocService.java b/src/edu/cornell/mannlib/semservices/service/impl/AgrovocService.java index d7498f6b..0999f2df 100644 --- a/src/edu/cornell/mannlib/semservices/service/impl/AgrovocService.java +++ b/src/edu/cornell/mannlib/semservices/service/impl/AgrovocService.java @@ -66,7 +66,7 @@ public class AgrovocService implements ExternalConceptService { //XMLUtils.serializeNode(node); System.out.println(); Concept concept = new Concept(); - concept.setDefinedBy("Agrovoc"); + concept.setDefinedBy("http://aims.fao.org/aos/agrovoc/agrovocScheme"); concept.setConceptId(termcode); NamedNodeMap attrs = node.getAttributes(); diff --git a/src/edu/cornell/mannlib/semservices/service/impl/UMLSService.java b/src/edu/cornell/mannlib/semservices/service/impl/UMLSService.java index ed116c06..59a8fbe3 100644 --- a/src/edu/cornell/mannlib/semservices/service/impl/UMLSService.java +++ b/src/edu/cornell/mannlib/semservices/service/impl/UMLSService.java @@ -82,7 +82,7 @@ public class UMLSService implements ExternalConceptService { JSONObject o = bestMatchArray.getJSONObject(i); //System.out.println(o.toString()); Concept concept = new Concept(); - concept.setDefinedBy("UMLS"); + concept.setDefinedBy("http://link.informatics.stonybrook.edu/umls"); concept.setBestMatch("true"); String cui = getJsonValue(o, "CUI"); bestMatchIdList.add(cui); diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddAssociatedConceptGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddAssociatedConceptGenerator.java index a989281e..7c76ee05 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddAssociatedConceptGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddAssociatedConceptGenerator.java @@ -54,6 +54,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo; import edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils; import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch; import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils; +import edu.cornell.mannlib.vitro.webapp.utils.ConceptSearchService.ConceptSearchServiceUtils; import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode; import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils; /** @@ -306,19 +307,12 @@ public class AddAssociatedConceptGenerator extends VivoBaseGenerator implements //Form specific data public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { HashMap formSpecificData = new HashMap(); - //Existing concepts should probably be a hash map or a hash map of classes - //with URI of concept node to label and information about existing URI - //This would be a sparql query and would need to be run here? - //-------------------->For test purposes - List testInfo = new ArrayList(); - testInfo.add(new AssociatedConceptInfo("testLabel", "testURI", "testVocabURI", "testVocabLabel", null)); - testInfo.add(new AssociatedConceptInfo("user defined label", "testUserURI", null, null, "http://www.w3.org/2004/02/skos/core#Concept")); - - //Adding concepts - testInfo.addAll(getExistingConcepts(vreq)); - formSpecificData.put("existingConcepts", testInfo); + //These are the concepts that already exist currently + formSpecificData.put("existingConcepts", getExistingConcepts(vreq)); //Return url for adding user defined concept formSpecificData.put("userDefinedConceptUrl", getUserDefinedConceptUrl(vreq)); + //Add URIs and labels for different services + formSpecificData.put("searchServices", ConceptSearchServiceUtils.getVocabSources()); editConfiguration.setFormSpecificData(formSpecificData); } @@ -342,17 +336,17 @@ public class AddAssociatedConceptGenerator extends VivoBaseGenerator implements //TODO: Check if sorted correctly sortConceptIndividuals(concepts); - return getAssociatedConceptInfo(concepts); + return getAssociatedConceptInfo(concepts, vreq); } - private void sortConceptIndividuals(List authorships) { + private void sortConceptIndividuals(List concepts) { DataPropertyComparator comp = new DataPropertyComparator(RDFS.label.getURI()); - Collections.sort(authorships, comp); + Collections.sort(concepts, comp); } private List getAssociatedConceptInfo( - List concepts) { + List concepts, VitroRequest vreq) { List info = new ArrayList(); for ( Individual conceptIndividual : concepts ) { boolean isSKOSConcept = false; @@ -376,8 +370,9 @@ public class AddAssociatedConceptGenerator extends VivoBaseGenerator implements String vocabLabel = null; if(vocabList != null && vocabList.size() > 0) { vocabSource = vocabList.get(0).getObjectURI(); - //vocab label? Right now set as same to vocab source until we get the correct input - vocabLabel = vocabSource; + Individual sourceIndividual = EditConfigurationUtils.getIndividual(vreq, vocabSource); + //Assuming name will get label + vocabLabel = sourceIndividual.getName(); } info.add(new AssociatedConceptInfo(conceptLabel, conceptUri, vocabSource, vocabLabel, null)); diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasEducationalTraining.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasEducationalTraining.java index 39aa78cb..804f743a 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasEducationalTraining.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasEducationalTraining.java @@ -89,7 +89,7 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements conf.setN3Optional(Arrays.asList( n3ForEdTrainingToOrg, majorFieldAssertion, degreeAssertion, deptAssertion, infoAssertion, - n3ForStart, n3ForEnd )); + n3ForStart, n3ForEnd, n3ForOrgToEdTraining )); conf.addNewResource("edTraining", DEFAULT_NS_FOR_NEW_RESOURCE); conf.addNewResource("org",DEFAULT_NS_FOR_NEW_RESOURCE); @@ -119,6 +119,8 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements conf.addSparqlForExistingUris("endNode", existingEndNodeQuery); conf.addSparqlForExistingUris("startField-precision", existingStartPrecisionQuery); conf.addSparqlForExistingUris("endField-precision", existingEndPrecisionQuery); + //Add sparql to include inverse property as well + conf.addSparqlForAdditionalUrisInScope("inverseTrainingAtOrg", inverseTrainingAtOrgQuery); conf.addField( new FieldVTwo(). setName("degree"). @@ -228,7 +230,9 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements final static String n3ForEdTrainingToOrg = "?edTraining <"+ trainingAtOrg +"> ?org ."; - + //The inverse of the above + final static String n3ForOrgToEdTraining = + "?org ?inverseTrainingAtOrg ?edTraining ."; /* Queries for editing an existing educational training entry */ final static String orgQuery = @@ -318,6 +322,13 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements "?endNode <"+ type +"> <"+ dateTimeValueType +"> .\n"+ "?endNode <"+ dateTimePrecision +"> ?existingEndPrecision . }"; + //Query for inverse property + final static String inverseTrainingAtOrgQuery = + "PREFIX owl: " + + " SELECT ?inverseTrainingAtOrg " + + " WHERE { ?inverseTrainingAtOrg owl:inverseOf <"+ trainingAtOrg +"> . } "; + + //Adding form specific data such as edit mode public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { HashMap formSpecificData = new HashMap(); @@ -331,4 +342,6 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements return EditModeUtils.getEditMode(vreq, predicates); } + + } diff --git a/src/edu/cornell/mannlib/vitro/webapp/utils/ConceptSearchService/ConceptSearchServiceUtils.java b/src/edu/cornell/mannlib/vitro/webapp/utils/ConceptSearchService/ConceptSearchServiceUtils.java index c016fccd..0289654a 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/utils/ConceptSearchService/ConceptSearchServiceUtils.java +++ b/src/edu/cornell/mannlib/vitro/webapp/utils/ConceptSearchService/ConceptSearchServiceUtils.java @@ -19,8 +19,9 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; public class ConceptSearchServiceUtils { private static final Log log = LogFactory.getLog(ConceptSearchServiceUtils.class); //Get the appropriate search service class - private static final String UMLSVocabSource = "http://link.informatics.stonybrook.edu/umls/"; - private static final String AgrovocVocabSource = "http://www.fao.org/webservices/Agrovoc"; + //TODO: Change this so retrieved from the system instead using a query + private static final String UMLSVocabSource = "http://link.informatics.stonybrook.edu/umls"; + private static final String AgrovocVocabSource = "http://aims.fao.org/aos/agrovoc/agrovocScheme"; //Get the class that corresponds to the appropriate search public static String getConceptSearchServiceClassName(String searchServiceName) { HashMap map = getMapping(); @@ -44,8 +45,8 @@ public class ConceptSearchServiceUtils { //Get the hashmap mapping service name to Service class private static HashMap getMapping() { HashMap map = new HashMap(); - map.put("http://link.informatics.stonybrook.edu/umls/", "edu.cornell.mannlib.semservices.service.impl.UMLSService"); - map.put("http://www.fao.org/webservices/Agrovoc", "edu.cornell.mannlib.semservices.service.impl.AgrovocService"); + map.put(UMLSVocabSource, "edu.cornell.mannlib.semservices.service.impl.UMLSService"); + map.put(AgrovocVocabSource, "edu.cornell.mannlib.semservices.service.impl.AgrovocService"); return map; }