From b8c70867e078f8dd022164ceeecaef0a6f6fded8 Mon Sep 17 00:00:00 2001 From: hjkhjk54 Date: Tue, 29 Nov 2011 16:36:00 +0000 Subject: [PATCH] updates for adding concepts and removing redirectToPublication.jsp --- .../edit/forms/redirectToPublication.jsp | 70 ------------------- .../edit/forms/addAssociatedConcept.ftl | 2 +- .../AddAssociatedConceptGenerator.java | 3 +- .../generators/VivoBaseGenerator.java | 3 - .../AddAssociatedConceptsPreprocessor.java | 38 ++++++---- 5 files changed, 29 insertions(+), 87 deletions(-) delete mode 100644 productMods/edit/forms/redirectToPublication.jsp diff --git a/productMods/edit/forms/redirectToPublication.jsp b/productMods/edit/forms/redirectToPublication.jsp deleted file mode 100644 index ccf5545b..00000000 --- a/productMods/edit/forms/redirectToPublication.jsp +++ /dev/null @@ -1,70 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%-- -This form will not allow an edit but will redirect to the publication. -This can be used to skip over an authorship context node. - -What does this do on an add? -It shouldn't encounter an add, it will redirect to the subject. Hide the add with in a policy. - -What about the delete link? -The delete link will not go to this form. You should hide the delete link with the policy. ---%> -<%@ page import="java.util.List" %> -<%@ page import="java.util.ArrayList" %> -<%@ page import="java.util.Arrays" %> - -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils" %> - -<%@ page import="org.apache.commons.logging.Log" %> -<%@ page import="org.apache.commons.logging.LogFactory" %> - -<%! - public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.redirectToObject.jsp"); - public static String nodeToPubProp = "http://vivoweb.org/ontology/core#linkedInformationResource"; -%> -<% - VitroRequest vreq = new VitroRequest(request); - WebappDaoFactory wdf = vreq.getWebappDaoFactory(); - - Individual subject = (Individual) request.getAttribute("subject"); - Individual obj = (Individual) request.getAttribute("object"); - - if( obj == null ){ - log.warn("this custom form is intended to redirect to the object but none was found."); - %> - - - - <% - }else{ - List stmts = obj.getObjectPropertyStatements( nodeToPubProp ); - if( stmts == null || stmts.size() == 0 ){ - %> - - - - <% - } else { - ObjectPropertyStatement ops = stmts.get(0); - String pubUri = ops.getObjectURI(); - if( pubUri != null ){ - %> - - - - <% - } else{ - %> - - - - <% } - } - } -%> - \ No newline at end of file diff --git a/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl b/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl index b6c374b3..dab3fe09 100644 --- a/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl +++ b/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl @@ -11,7 +11,7 @@ <#--This is set for testing purposes - will be retrieved dynamically from the generator later--> -<#assign sources = [{"uri":"UMLS", "label":"UMLS"}, {"uri":"Agrovoc", "label":"Agrovoc"}]/> +<#assign sources = [{"uri":"http://link.informatics.stonybrook.edu/umls/", "label":"UMLS"}, {"uri":"http://www.agrovoc.com", "label":"Agrovoc"}]/> <#assign selectedSource = "UMLS" />

Manage Concepts

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 3166d4d6..a989281e 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 @@ -161,7 +161,8 @@ public class AddAssociatedConceptGenerator extends VivoBaseGenerator implements private List generateN3Required(VitroRequest vreq) { return list( getPrefixesString() + "\n" + - "?subject ?predicate ?conceptNode .\n" + "?subject ?predicate ?conceptNode .\n" + + "?conceptNode <" + RDF.type.getURI() + "> ." ); } diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/VivoBaseGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/VivoBaseGenerator.java index 6e095621..52f6f0fd 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/VivoBaseGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/VivoBaseGenerator.java @@ -39,7 +39,4 @@ public abstract class VivoBaseGenerator extends BaseEditConfigurationGenerator i final static String orgClass ="http://xmlns.com/foaf/0.1/Organization" ; final static String personClass = foaf + "Person"; - //TODO: Define these elsewhere - final static String UMLSClass = vivoCore + "UMLS"; - final static String AgrovocClass = vivoCore + "Agrovoc"; } diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/AddAssociatedConceptsPreprocessor.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/AddAssociatedConceptsPreprocessor.java index 6b7d983d..446ce325 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/AddAssociatedConceptsPreprocessor.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/AddAssociatedConceptsPreprocessor.java @@ -30,7 +30,10 @@ public class AddAssociatedConceptsPreprocessor extends private static String conceptNodeBase = "conceptNode"; private static String sourceBase = "conceptSource"; private static String labelBase = "conceptLabel"; - //Also storing submission + //Also storing submission values + private static String conceptNodeValues = null; + private static String conceptLabelValues = null; + private static String conceptSourceValues = null; private static MultiValueEditSubmission submission = null; // String datatype @@ -46,7 +49,7 @@ public class AddAssociatedConceptsPreprocessor extends // Get the input elements for concept node and concept label as well // as vocab uri (which is based on thge // For query parameters, check whether CUI - String conceptNodeValues = getConceptNodeValues(); + copySubmissionValues(); if (conceptNodeValues != null) { String[] conceptNodes = convertDelimitedStringToArray(conceptNodeValues); @@ -60,11 +63,22 @@ public class AddAssociatedConceptsPreprocessor extends } } + + //Since we will change the uris and literals from form, we should make copies + //of the original values and store them, this will also make iterations + //and updates to the submission independent from accessing the values + private void copySubmissionValues() { + conceptLabelValues = getConceptLabelValues(); + conceptNodeValues = getConceptNodeValues(); + conceptSourceValues = getConceptSourceValues(); + } private void processConceptNodes(int numberConcepts) { //There are no "new" resources b/c the concept nodes are URIs from external vocabularies // Add N3Required addN3Required(numberConcepts); + //Add N3 Optional as well + addN3Optional(numberConcepts); // Add URIs on Form and Add Literals On Form addLiteralsAndUrisOnForm(numberConcepts); // Add fields @@ -88,13 +102,13 @@ public class AddAssociatedConceptsPreprocessor extends } private void addConceptNodeInputs(int numberConcepts) { - //Get the current value - String conceptNodeValues = getConceptNodeValues(); + String[] conceptNodes = convertDelimitedStringToArray(conceptNodeValues); if(conceptNodes != null && conceptNodes.length == numberConcepts) { int i; - for(i = 1; i <= numberConcepts; i++) { - int suffix = i; + //iterate through the concept nodes converted string array + for(i = 0; i < numberConcepts; i++) { + int suffix = i + 1; String conceptInputName = conceptNodeBase + suffix; String[] nodeValues = new String[1]; nodeValues[0] = conceptNodes[i]; @@ -110,12 +124,11 @@ public class AddAssociatedConceptsPreprocessor extends } private void addConceptSourceInputs(int numberConcepts) { - String conceptSourceValues = getConceptSourceValues(); String[] conceptSources = convertDelimitedStringToArray(conceptSourceValues); if(conceptSources != null && conceptSources.length == numberConcepts) { int i; - for(i = 1; i <= numberConcepts; i++) { - int suffix = i; + for(i = 0; i < numberConcepts; i++) { + int suffix = i + 1; String conceptInputName = sourceBase + suffix; String[] sourceValues = new String[1]; sourceValues[0] = conceptSources[i]; @@ -130,12 +143,11 @@ public class AddAssociatedConceptsPreprocessor extends } private void addConceptLabelInputs(int numberConcepts) { - String conceptLabelValues = getConceptLabelValues(); String[] labels = convertDelimitedStringToArray(conceptLabelValues); if(labels != null && labels.length == numberConcepts) { int i; - for(i = 1; i <= numberConcepts; i++) { - int suffix = i; + for(i = 0; i < numberConcepts; i++) { + int suffix = i + 1; String labelInputName = labelBase + suffix; String[] labelValues = new String[1]; labelValues[0] = labels[i]; @@ -301,5 +313,7 @@ public class AddAssociatedConceptsPreprocessor extends return null; return inputList.get(0); } + + }