Removing debut statements and adding support for validation of annotation properties on forms.
This commit is contained in:
parent
c4062267bd
commit
5d4f3d8601
8 changed files with 32 additions and 31 deletions
|
@ -120,7 +120,6 @@ public class BasicValidation {
|
|||
return errors;
|
||||
}
|
||||
|
||||
|
||||
private String validate(String validationType, List<FileItem> fileItems) {
|
||||
if( "nonempty".equalsIgnoreCase(validationType)){
|
||||
if( fileItems == null || fileItems.size() == 0 ){
|
||||
|
@ -245,6 +244,8 @@ public class BasicValidation {
|
|||
public final static String SUCCESS = null;
|
||||
public final static String REQUIRED_FIELD_EMPTY_MSG = "This field must not be empty.";
|
||||
public final static String DATE_NOT_PAST_MSG = "Please enter a future target date for publication (past dates are invalid).";
|
||||
//public final static String MIN_FIELDS_NOT_POPULATED = "Please enter values for at least ";
|
||||
//public final static String FORM_ERROR_FIELD_ID = "formannotationerrors";
|
||||
/** regex for strings like "12/31/2004" */
|
||||
private final String dateRegex = "((1[012])|([1-9]))/((3[10])|([12][0-9])|([1-9]))/[\\d]{4}";
|
||||
private final Pattern datePattern = Pattern.compile(dateRegex);
|
||||
|
|
|
@ -297,15 +297,26 @@ public class EditConfiguration {
|
|||
* and return it.
|
||||
*/
|
||||
public void prepareForObjPropUpdate( Model model ){
|
||||
if( model == null ) throw new Error("EditConfiguration.prepareForObjPropUpdate() needs a Model");
|
||||
if( model == null ) {
|
||||
//Added parens and output
|
||||
System.out.println("Model is null and will be throwing an error");
|
||||
throw new Error("EditConfiguration.prepareForObjPropUpdate() needs a Model");}
|
||||
if( !isObjectResource )
|
||||
{
|
||||
//Added parens and output
|
||||
System.out.println("This is not an object resource? lacks dataprop ");
|
||||
throw new Error("This request does not appear to be for an update since it lacks a dataprop object or a dataProp hash key ");
|
||||
//find the variable for object, this anchors the paths to the existing values
|
||||
}
|
||||
//find the variable for object, this anchors the paths to the existing values
|
||||
if( object == null || object.trim().length() == 0)
|
||||
throw new Error("This request does not appear to be for an update since it lacks an object");
|
||||
{
|
||||
//Added parens and output
|
||||
System.out.println("Object is null or object length is null");
|
||||
throw new Error("This request does not appear to be for an update since it lacks an object");
|
||||
}
|
||||
|
||||
getUrisInScope().put( varNameForObject, object);
|
||||
|
||||
System.out.println("Putting uris in scope - var name for ojbect " + varNameForObject + " and object is " + object);
|
||||
// run SPARQL, sub in values
|
||||
SparqlEvaluate sparqlEval = new SparqlEvaluate( model );
|
||||
runSparqlForAdditional( sparqlEval );
|
||||
|
|
|
@ -323,24 +323,6 @@ public class EditSubmission {
|
|||
try{
|
||||
dt = dateFormater.parseDateTime(year.get(0) +'-'+ month.get(0) +'-'+ day.get(0));
|
||||
String dateStr = dateFormater.print(dt);
|
||||
|
||||
/*if(compareCurrentDate) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
//Set to last year
|
||||
int currentYear = c.get(Calendar.YEAR);
|
||||
//?Set to time starting at 00 this morning?
|
||||
Calendar inputC = Calendar.getInstance();
|
||||
inputC.set(Integer.parseInt(yearParamStr), Integer.parseInt(monthParamStr) - 1, Integer.parseInt(dayParamStr));
|
||||
//if input time is more than a year ago
|
||||
if(inputC.before(c)) {
|
||||
errors += "Please enter a future target date for publication (past dates are invalid).";
|
||||
validationErrors.put( fieldName, errors);
|
||||
//Returning null makes the error message "field is empty" display instead
|
||||
//return null;
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
return new EditLiteral(dateStr,DATE_URI, null );
|
||||
}catch(IllegalFieldValueException ifve){
|
||||
validationErrors.put( fieldName, ifve.getLocalizedMessage() );
|
||||
|
|
|
@ -121,7 +121,10 @@ public class SparqlEvaluate {
|
|||
queryStrings = editConfig.getN3Generator().subInLiterals(literalScope,queryStrings);
|
||||
String uriFromQuery = queryToUri( queryStrings.get(0) );
|
||||
if( uriFromQuery != null )
|
||||
varToUris.put(var, uriFromQuery);
|
||||
{
|
||||
//Added parens and output
|
||||
varToUris.put(var, uriFromQuery);
|
||||
}
|
||||
else
|
||||
log.debug("sparqlEvaluateForUris(): for var " + var
|
||||
+ " the following query evaluated to null:\n"+queryStrings.get(0)+"\n(end of query)\n");
|
||||
|
|
|
@ -340,6 +340,7 @@ public class InputElementFormattingTag extends TagSupport {
|
|||
log.error("Error in doStartTag: input element id is blank or not specified.");
|
||||
}
|
||||
|
||||
|
||||
HttpSession session = pageContext.getSession();
|
||||
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,(HttpServletRequest) pageContext.getRequest());
|
||||
EditSubmission editSub = EditSubmission.getEditSubmissionFromSession(session,editConfig);
|
||||
|
@ -519,7 +520,12 @@ public class InputElementFormattingTag extends TagSupport {
|
|||
|
||||
} else if( getType().equalsIgnoreCase("editKey")) {
|
||||
log.warn("Input element of type editKey was ignored, editKey fields are created by InputElementFormat submit and cancel.");
|
||||
} else { // among other things, not supporting input type "reset"
|
||||
}
|
||||
//added this for general form validation errors
|
||||
else if(getType().equalsIgnoreCase("formerror")) {
|
||||
//print nothing since error string still printed below
|
||||
}
|
||||
else { // among other things, not supporting input type "reset"
|
||||
log.error("Error in InputElementFormattingTag.doStartTag(): unknown input element type "+getType());
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,6 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.
|
|||
} else {
|
||||
formParam = null;
|
||||
}
|
||||
|
||||
String objectUri = request.getParameter("objectUri");
|
||||
if (objectUri != null) {
|
||||
request.setAttribute("objectUri", objectUri);
|
||||
|
|
|
@ -320,13 +320,13 @@ are well formed.
|
|||
try{
|
||||
lock = writeModel.getLock();
|
||||
lock.enterCriticalSection(Lock.WRITE);
|
||||
writeModel.getBaseModel().notifyEvent(new EditEvent(editorUri,true));
|
||||
writeModel.add( actualAssertions );
|
||||
writeModel.remove( actualRetractions );
|
||||
// writeModel.getBaseModel().notifyEvent(new EditEvent(editorUri,true));
|
||||
// writeModel.add( actualAssertions );
|
||||
// writeModel.remove( actualRetractions );
|
||||
}catch(Throwable t){
|
||||
errorMessages.add("error adding edit change n3required model to in memory model \n"+ t.getMessage() );
|
||||
}finally{
|
||||
writeModel.getBaseModel().notifyEvent(new EditEvent(editorUri,false));
|
||||
// writeModel.getBaseModel().notifyEvent(new EditEvent(editorUri,false));
|
||||
lock.leaveCriticalSection();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.
|
|||
try {
|
||||
VitroRequest vreq = new VitroRequest(request);
|
||||
entity = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI((String)request.getAttribute("myEntityURI"));
|
||||
System.out.println("entityBasic rendering "+entity.getURI());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue