From 1518919a7d22d021cf483a05191421bb13c45c58 Mon Sep 17 00:00:00 2001 From: ryounes Date: Mon, 11 Jul 2011 19:28:44 +0000 Subject: [PATCH] NIHVIVO-707 Fix required values on webpage form. Fix cancel url on webpage form in add mode. --- productMods/edit/forms/addEditWebpageForm.jsp | 96 ++++++++++--------- 1 file changed, 53 insertions(+), 43 deletions(-) diff --git a/productMods/edit/forms/addEditWebpageForm.jsp b/productMods/edit/forms/addEditWebpageForm.jsp index c84aba0e..8d38c54e 100644 --- a/productMods/edit/forms/addEditWebpageForm.jsp +++ b/productMods/edit/forms/addEditWebpageForm.jsp @@ -46,8 +46,9 @@ core:rank <%! public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.addEditWebpageForm.jsp"); - /* Note on ordering by rank in sparql: if there is a non-integer value on a link, that will be returned. - * Preventing that would require getting all the ranks and ordering in Java, throwing out non-int values. + /* Note on ordering by rank in sparql: if there is a non-integer value on a link, that will be returned, + * since it's ranked highest. Preventing that would require getting all the ranks and sorting in Java, + * throwing out non-int values. */ public static String RANK_QUERY = "" + "PREFIX core: \n" @@ -129,8 +130,7 @@ core:rank ?link <${inverseProperty}> ?subject . ?link a <${linkClass}> ; - <${linkUrl}> ?url ; - <${linkAnchor}> ?anchor ; + <${linkUrl}> ?url . @@ -141,13 +141,14 @@ core:rank "formUrl" : "${formUrl}", "editKey" : "${editKey}", "urlPatternToReturnTo" : "${returnPathAfterSubmit}", + "urlPatternToCancelTo" : "${returnPathAfterCancel}", "subject" : ["subject", "${subjectUriJson}" ], "predicate" : ["predicate", "${predicateUriJson}" ], "object" : ["link", "${objectUriJson}", "URI" ], "n3required" : [ "${n3ForEdit}" ], - "n3optional" : [ "${rankAssertion}"], + "n3optional" : [ "${rankAssertion}", "${anchorAssertion}" ], "newResources" : { "link" : "${defaultNamespace}" }, "urisInScope" : { }, "literalsInScope" : { }, @@ -159,7 +160,7 @@ core:rank "sparqlForExistingLiterals" : { "url" : "${urlQuery}", "anchor" : "${anchorQuery}", - "rank" : "${rankQuery}" + "rank" : "${rankQuery}" }, "sparqlForExistingUris" : { }, "fields" : { @@ -176,7 +177,7 @@ core:rank }, "anchor" : { "newResource" : "false", - "validators" : [ "nonempty", "datatype:${stringDatatypeUriJson}" ], + "validators" : [ "datatype:${stringDatatypeUriJson}" ], "optionsType" : "UNDEFINED", "literalOptions" : [ ], "predicateUri" : "", @@ -222,7 +223,49 @@ core:rank String subjectName = ((Individual)request.getAttribute("subject")).getName(); - // Get largest existing rank value + // Get largest existing rank value to compute hidden rank field value + int newRank = getMaxRank(objectUri, subjectUri, vreq) + 1; + +%> + + + + + + + + + + + + + + + + + + + + +

${title} <%= subjectName %>

+ +
" > + + +

If left blank, the URL will be used when displaying a link to this webpage.

+ + + +

+ +

+ + + + +<%! +private int getMaxRank(String objectUri, String subjectUri, VitroRequest vreq) { + int maxRank = 0; // default value if (objectUri == null) { // adding new webpage String queryStr = QueryUtils.subUriForQueryVar(RANK_QUERY, "subject", subjectUri); @@ -248,40 +291,7 @@ core:rank log.error(e, e); } } + return maxRank; +} %> - - - - - - - <%-- May need to do this in Java above --%> - - - - - - - - - - - - - -

${title} <%= subjectName %>

- -
" > - - -

If left blank, the URL will be used when displaying a link to this webpage.

- - - -

- - - - -