diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/RdfLiteralHash.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/RdfLiteralHash.java
index b2829cb50..5109d39ba 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/RdfLiteralHash.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/RdfLiteralHash.java
@@ -4,10 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
import java.util.List;
-import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
-import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
-import edu.cornell.mannlib.vitro.webapp.beans.Individual;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -17,6 +13,11 @@ import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator;
+import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
+import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
+import edu.cornell.mannlib.vitro.webapp.beans.Individual;
+import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
+
public class RdfLiteralHash {
private static final Log log = LogFactory.getLog(RdfLiteralHash.class.getName());
@@ -27,7 +28,7 @@ public class RdfLiteralHash {
* @param stmt
* @return a value between MIN_INTEGER and MAX_INTEGER
*/
- public static int makeRdfLiteralHash( DataPropertyStatement stmt ){
+ public static int makeRdfLiteralHash( DataPropertyStatement stmt ){
if( (stmt.getLanguage() != null && stmt.getLanguage().trim().length() > 0)
&&
(stmt.getDatatypeURI() != null && stmt.getDatatypeURI().trim().length() > 0 ) )
@@ -76,23 +77,23 @@ public class RdfLiteralHash {
}
/**
- * Forward to either getDataPropertyStmtByHash or getVitroNsPropByHash, depending on the type of property.
+ * Forward to either getDataPropertyStmtByHash or getRdfsLabelStatementByHash, depending on the property.
* @param ind
* @param hash
* @param model
- * @param isVitroNsProp
* @return a DataPropertyStatement if found or null if not found
*/
- // RY Instead of a code fork here, we should have a method of Individual getAllDataPropertyStatements() which
- // doesn't filter out the vitro ns property statements. This would also simplify the front end editing of the vitro ns
- // properties, because they wouldn't have to be a special case.
- public static DataPropertyStatement getPropertyStmtByHash(Individual ind, String predicateUri, int hash, Model model, boolean isVitroNsProp) {
+
+ public static DataPropertyStatement getPropertyStmtByHash(Individual ind, String predicateUri, int hash, Model model) {
if (ind == null) return null;
-
- DataPropertyStatement dps = isVitroNsProp ? RdfLiteralHash.getVitroNsPropertyStmtByHash(ind, predicateUri, model, hash) :
- RdfLiteralHash.getDataPropertyStmtByHash(ind, hash);
+ // RY Instead of a code fork here, we should have a method of Individual getAllDataPropertyStatements() which
+ // doesn't filter out rdfs:label.
+ DataPropertyStatement dps = predicateUri.equals(VitroVocabulary.LABEL)
+ ? getRdfsLabelStatementByHash(ind, model, hash)
+ : getDataPropertyStmtByHash(ind, hash);
+
return dps;
}
@@ -110,12 +111,14 @@ public class RdfLiteralHash {
/**
*
- * @param ind, may be null and getDataPropertyStatements() may return null.
+ * @param ind, may be null
* @param hash
* @return a DataPropertyStatement if found or null if not found
*/
- public static DataPropertyStatement getVitroNsPropertyStmtByHash(Individual ind, String predicateUri, Model model, int hash) {
+ public static DataPropertyStatement getRdfsLabelStatementByHash(Individual ind, Model model, int hash) {
+ String predicateUri = VitroVocabulary.LABEL;
+
DataPropertyStatement dps = null;
StmtIterator stmts = model.listStatements(model.createResource(ind.getURI()),
model.getProperty(predicateUri),
@@ -139,9 +142,10 @@ public class RdfLiteralHash {
return null;
}
- public static int makeVitroNsLiteralHash( Individual subject, String predicateUri, String value, Model model) {
+ public static int makeRdfsLabelLiteralHash( Individual subject, String value, Model model) {
String subjectUri = subject.getURI();
+ String predicateUri = VitroVocabulary.LABEL;
StmtIterator stmts = model.listStatements(model.createResource(subjectUri),
model.getProperty(predicateUri),
diff --git a/webapp/test/edu/cornell/mannlib/vitro/webapp/edit/n3editing/RdfLiteralHashTest.java b/webapp/test/edu/cornell/mannlib/vitro/webapp/edit/n3editing/RdfLiteralHashTest.java
index 2be1dd331..862a277be 100644
--- a/webapp/test/edu/cornell/mannlib/vitro/webapp/edit/n3editing/RdfLiteralHashTest.java
+++ b/webapp/test/edu/cornell/mannlib/vitro/webapp/edit/n3editing/RdfLiteralHashTest.java
@@ -188,33 +188,30 @@ public class RdfLiteralHashTest {
}
@Test
- public void testGetVitroNsPropertyStatement(){
+ public void testGetRdfsLabelStatementByHash(){
String n3 =
- "@prefix vitro: <" + VitroVocabulary.vitroURI + "> . \n" +
"@prefix ex: . \n" +
"@prefix rdf: . \n"+
"@prefix rdfs: .\n"+
- " ex:bob vitro:moniker \"great\"^^<"+XSD.xstring.getURI()+"> ." ;
+ " ex:bob rdfs:label \"Smith, Bob\"^^<"+XSD.xstring.getURI()+"> ." ;
Model model = (ModelFactory.createDefaultModel()).read(new StringReader(n3), "", "N3");
Individual bob = new IndividualImpl();
bob.setURI("http://example.com/bob");
-
- String propertyUri = VitroVocabulary.MONIKER;
- int hash = RdfLiteralHash.makeVitroNsLiteralHash(bob, propertyUri, "great", model);
- DataPropertyStatement stmt = RdfLiteralHash.getVitroNsPropertyStmtByHash(bob, propertyUri, model, hash);
+ int hash = RdfLiteralHash.makeRdfsLabelLiteralHash(bob, "Smith, Bob", model);
+ DataPropertyStatement stmt = RdfLiteralHash.getRdfsLabelStatementByHash(bob, model, hash);
String data = stmt.getData();
String datatypeUri = stmt.getDatatypeURI();
String predicateUri = stmt.getDatapropURI();
String subjectUri = stmt.getIndividualURI();
- Assert.assertEquals("great", data);
+ Assert.assertEquals("Smith, Bob", data);
Assert.assertEquals(XSD.xstring.getURI(), datatypeUri);
- Assert.assertEquals(VitroVocabulary.MONIKER, predicateUri);
+ Assert.assertEquals(VitroVocabulary.LABEL, predicateUri);
Assert.assertEquals("http://example.com/bob", subjectUri);
}
diff --git a/webapp/web/edit/editDatapropStmtRequestDispatch.jsp b/webapp/web/edit/editDatapropStmtRequestDispatch.jsp
index 55c9d695c..1d40010d5 100644
--- a/webapp/web/edit/editDatapropStmtRequestDispatch.jsp
+++ b/webapp/web/edit/editDatapropStmtRequestDispatch.jsp
@@ -40,7 +40,6 @@
************************************** */
final String DEFAULT_DATA_FORM = "defaultDatapropForm.jsp";
- final String DEFAULT_VITRO_NS_FORM = "defaultVitroNsDataPropForm.jsp";
final String DEFAULT_ERROR_FORM = "error.jsp";
VitroRequest vreq = new VitroRequest(request);
@@ -58,14 +57,6 @@
String formParam = vreq.getParameter("editForm");
String command = vreq.getParameter("cmd");
- String vitroNsProp = (String) vreq.getParameter("vitroNsProp");
-
- boolean isVitroNsProp = false;
- // On new Freemarker individual page, the editing link for rdfs:label doesn't get this url param attached
- if ( "true".equals(vitroNsProp) || predicateUri.equals(VitroVocabulary.LABEL) ) {
- isVitroNsProp = true;
- }
-
if( subjectUri == null || subjectUri.trim().length() == 0 ) {
log.error("required subjectUri parameter missing");
throw new Error("subjectUri was empty, it is required by editDatapropStmtRequestDispatch");
@@ -92,8 +83,9 @@
DataProperty dataproperty = wdf.getDataPropertyDao().getDataPropertyByURI( predicateUri );
if( dataproperty == null) {
- // No dataproperty will be returned for a vitro ns prop, but we shouldn't throw an error.
- if (!isVitroNsProp) {
+ // No dataproperty will be returned for rdfs:label, but we shouldn't throw an error.
+ // RY ** Consider instead getting rdfs:label included in what's returned
+ if (! predicateUri.equals(VitroVocabulary.LABEL)) {
log.error("Could not find data property '"+predicateUri+"' in model");
throw new Error("editDatapropStmtRequest.jsp: Could not find DataProperty in model: " + predicateUri);
}
@@ -120,7 +112,7 @@
DataPropertyStatement dps = null;
if( dataHash != 0) {
Model model = (Model)application.getAttribute("jenaOntModel");
- dps = RdfLiteralHash.getPropertyStmtByHash(subject, predicateUri, dataHash, model, isVitroNsProp);
+ dps = RdfLiteralHash.getPropertyStmtByHash(subject, predicateUri, dataHash, model);
if (dps==null) {
log.error("No match to existing data property \""+predicateUri+"\" statement for subject \""+subjectUri+"\" via key "+datapropKeyStr);
@@ -160,8 +152,8 @@
if (formParam != null) {
form = formParam;
}
- else if (isVitroNsProp) { // dataproperty is null here
- form = DEFAULT_VITRO_NS_FORM;
+ else if (predicateUri.equals(VitroVocabulary.LABEL)) { // dataproperty is null here
+ form = "rdfsLabelForm.jsp";
}
else {
form = dataproperty.getCustomEntryForm();
diff --git a/webapp/web/edit/forms/defaultVitroNsDataPropForm.jsp b/webapp/web/edit/forms/rdfsLabelForm.jsp
similarity index 99%
rename from webapp/web/edit/forms/defaultVitroNsDataPropForm.jsp
rename to webapp/web/edit/forms/rdfsLabelForm.jsp
index 7b68cd90b..df987c0bb 100644
--- a/webapp/web/edit/forms/defaultVitroNsDataPropForm.jsp
+++ b/webapp/web/edit/forms/rdfsLabelForm.jsp
@@ -30,8 +30,7 @@
%>
<%
org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("edu.cornell.mannlib.vitro.jsp.edit.forms.defaultVitroNsPropForm.jsp");
- log.debug("Starting defaultVitroNsPropForm.jsp");
-
+
VitroRequest vreq = new VitroRequest(request);
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
vreq.setAttribute("defaultNamespace", wdf.getDefaultNamespace());
@@ -40,7 +39,9 @@
String predicateUri = vreq.getParameter("predicateUri");
String propertyName = predicateUri.substring(predicateUri.lastIndexOf("#")+1);
vreq.setAttribute("propertyName", propertyName);
-
+
+ log.debug("Starting defaultVitroNsPropForm.jsp for property " + predicateUri);
+
DataPropertyStatement dps = (DataPropertyStatement)vreq.getAttribute("dataprop");
String datapropKeyStr = vreq.getParameter("datapropKey");
diff --git a/webapp/web/edit/processDatapropRdfForm.jsp b/webapp/web/edit/processDatapropRdfForm.jsp
index f76e9d098..a7da77c27 100644
--- a/webapp/web/edit/processDatapropRdfForm.jsp
+++ b/webapp/web/edit/processDatapropRdfForm.jsp
@@ -374,9 +374,7 @@ and set a flag in the request to indicate "back button confusion"
Model model = (Model)application.getAttribute("jenaOntModel");
int dpropHash = Integer.parseInt(editConfig.getDatapropKey());
- String vitroNsProp = vreq.getParameter("vitroNsProp");
- boolean isVitroNsProp = vitroNsProp != null && vitroNsProp.equals("true");
- DataPropertyStatement dps = RdfLiteralHash.getPropertyStmtByHash(subject, editConfig.getPredicateUri(), dpropHash, model, isVitroNsProp);
+ DataPropertyStatement dps = RdfLiteralHash.getPropertyStmtByHash(subject, editConfig.getPredicateUri(), dpropHash, model);
if (dps != null)
return false;