NIHVIVO-143 Front end editing of moniker

This commit is contained in:
rjy7 2010-03-16 19:17:53 +00:00
parent 1af92dc350
commit 1de471536a
9 changed files with 87 additions and 54 deletions

View file

@ -87,6 +87,7 @@ public class EditConfiguration {
String entityToReturnTo;
String formUrl;
String editKey;
boolean isVitroNsProp;
EditN3Generator n3generator;
private String originalJson;
@ -169,6 +170,9 @@ public class EditConfiguration {
urlPatternToReturnTo = obj.getString("urlPatternToReturnTo");
String vitroNsPropParam = obj.getString("isVitroNsProp");
isVitroNsProp = vitroNsPropParam != null && vitroNsPropParam.equalsIgnoreCase("true");
JSONArray predicate = obj.getJSONArray("predicate");
if( predicate.length() != 2 )
throw new Error("EditConfiguration predicate field must be an array with two items: [varnameForPredicate, predicateUri]");
@ -510,6 +514,14 @@ public class EditConfiguration {
public void setUrlPatternToReturnTo(String s) {
urlPatternToReturnTo = s;
}
public boolean isVitroNsProp() {
return isVitroNsProp;
}
public void setIsVitroNsProp(boolean b) {
isVitroNsProp = b;
}
/** return a copy of the value so that the configuration is not modified by external code.
* @return

View file

@ -56,7 +56,6 @@ public class RdfLiteralHash {
}
/**
*
* @param stmt
* @param hash
* @return
@ -75,15 +74,30 @@ public class RdfLiteralHash {
return stmtHash == hash;
}
/**
*
* @param ind, may be null and getDataPropertyStatements() may return null.
* Forward to either getDataPropertyStmtByHash or getVitroNsPropByHash, depending on the type of 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, int hash, Model model, boolean isVitroNsProp) {
if (ind == null) return null;
DataPropertyStatement dps = isVitroNsProp ? RdfLiteralHash.getVitroNsPropertyStmtByHash(ind, model, hash) :
RdfLiteralHash.getDataPropertyStmtByHash(ind, hash);
return dps;
}
public static DataPropertyStatement getDataPropertyStmtByHash( Individual ind, int hash){
if( ind == null ) return null;
List<DataPropertyStatement> statements = ind.getDataPropertyStatements();
if( statements == null ) return null;
for( DataPropertyStatement dps : statements){
@ -92,11 +106,15 @@ public class RdfLiteralHash {
}
return null;
}
/**
*
* @param ind, may be null and getDataPropertyStatements() may return null.
* @param hash
* @return a DataPropertyStatement if found or null if not found
*/
public static DataPropertyStatement getVitroNsPropertyStmtByHash(Individual ind, Model model, int hash) {
if (ind == null || model == null || hash == 0) {
return null;
}
DataPropertyStatement dps = null;
StmtIterator stmts = model.listStatements(model.createResource(ind.getURI()), null, (RDFNode)null);
try {
@ -113,6 +131,7 @@ public class RdfLiteralHash {
dps.setLanguage(lang);
dps.setData(value);
dps.setDatapropURI(stmt.getPredicate().toString());
dps.setIndividualURI(ind.getURI());
if (doesStmtMatchHash(dps, hash)) {
break;

View file

@ -235,13 +235,6 @@ public class InputElementFormattingTag extends TagSupport {
log.debug("doValue():", ex);
}
//here we are looking for defaults since everything else failed
// Field field = editConfig.getField( getId() );
// if( field == null )
// log.debug("doValue(): when looking for default value, could not find Field object in EditConfig");
// else
// return field.getDefault();
log.debug("doValue(): No existing or default value for key '"+getId()+"' found from in editConfig or"
+" or editSub");
return "";