NIHVIVO-238 - Updating custom reports and site configuration sections of vitro site admin to remove datastar-specific changes. Preventing past expected publication date (datastar-215), Autopopulating dataset originator with person info (datastar-304), Updates to Model preprocess related to dataset-304
This commit is contained in:
parent
5b6ee59e77
commit
61a64faf40
12 changed files with 116 additions and 36 deletions
|
@ -151,6 +151,8 @@ public class FedoraDatastreamController extends VitroHttpServlet implements Cons
|
|||
IndividualDao iwDao = vreq.getWebappDaoFactory().getIndividualDao();
|
||||
Individual entity = iwDao.getIndividualByURI(fileUri);
|
||||
|
||||
|
||||
|
||||
if( entity == null )
|
||||
throw new FdcException( "No entity found in system for file uri " + fileUri);
|
||||
//System.out.println("Entity == null:" + (entity == null));
|
||||
|
|
|
@ -74,11 +74,15 @@ public class BasicValidation {
|
|||
if( validations != null ){
|
||||
// NB this is case-sensitive
|
||||
boolean isRequiredField = validations.contains("nonempty");
|
||||
|
||||
for( String validationType : validations){
|
||||
String value = null;
|
||||
try{
|
||||
if( literal != null )
|
||||
if( literal != null ){
|
||||
value = literal.getString();
|
||||
System.out.println("get data type uri " + literal.asNode().getLiteralDatatype().getURI());
|
||||
|
||||
}
|
||||
}catch(Throwable th){
|
||||
log.debug("could not convert literal to string" , th);
|
||||
}
|
||||
|
@ -92,6 +96,7 @@ public class BasicValidation {
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
String validateMsg = validate(validationType, value);
|
||||
if( validateMsg != null) {
|
||||
errors.put(name,validateMsg);
|
||||
|
@ -149,7 +154,8 @@ public class BasicValidation {
|
|||
return SUCCESS;
|
||||
else
|
||||
return "must be in valid date format mm/dd/yyyy.";
|
||||
}else if( validationType.indexOf("datatype:") == 0 ) {
|
||||
}
|
||||
else if( validationType.indexOf("datatype:") == 0 ) {
|
||||
String datatypeURI = validationType.substring(9);
|
||||
String errorMsg = validateAgainstDatatype( value, datatypeURI );
|
||||
if ( errorMsg == null ) {
|
||||
|
@ -158,6 +164,34 @@ public class BasicValidation {
|
|||
return errorMsg;
|
||||
}
|
||||
}
|
||||
|
||||
//Date not past validation
|
||||
if( "dateNotPast".equalsIgnoreCase(validationType)){
|
||||
System.out.println("date not past - Value " + value);
|
||||
//if( ! past (value) )
|
||||
// return "date must not be in the past";
|
||||
//Current date
|
||||
Calendar c = Calendar.getInstance();
|
||||
//Input
|
||||
Calendar inputC = Calendar.getInstance();
|
||||
String yearParamStr, monthParamStr, dayParamStr;
|
||||
int yearDash = value.indexOf("-");
|
||||
int monthDash = value.lastIndexOf("-");
|
||||
if(yearDash != -1 && yearDash != monthDash) {
|
||||
yearParamStr = value.substring(0, yearDash);
|
||||
monthParamStr = value.substring(yearDash + 1, monthDash);
|
||||
dayParamStr = value.substring(monthDash + 1, value.length());
|
||||
System.out.println("Year param str " + yearParamStr + " - MonthPAram:" + monthParamStr + " - day:" + dayParamStr);
|
||||
inputC.set(Integer.parseInt(yearParamStr), Integer.parseInt(monthParamStr) - 1, Integer.parseInt(dayParamStr));
|
||||
if(inputC.before(c)) {
|
||||
return this.DATE_NOT_PAST_MSG;
|
||||
//Returning null makes the error message "field is empty" display instead
|
||||
//return null;
|
||||
} else {
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null; //
|
||||
}
|
||||
|
||||
|
@ -214,7 +248,7 @@ public class BasicValidation {
|
|||
/** we use null to indicate success */
|
||||
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).";
|
||||
/** 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);
|
||||
|
@ -222,7 +256,7 @@ public class BasicValidation {
|
|||
static final List<String> basicValidations;
|
||||
static{
|
||||
basicValidations = Arrays.asList(
|
||||
"nonempty","isDate" );
|
||||
"nonempty","isDate","dateNotPast" );
|
||||
}
|
||||
|
||||
private Log log = LogFactory.getLog(BasicValidation.class);
|
||||
|
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
|
|||
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* This will remove old relation triple for an edit.
|
||||
|
@ -22,7 +23,7 @@ public class DefaultAddMissingIndividualFormModelPreprocessor implements
|
|||
this.objectUri = objectUri;
|
||||
}
|
||||
|
||||
public void preprocess( Model retractionsModel, Model additionsModel) {
|
||||
public void preprocess( Model retractionsModel, Model additionsModel, HttpServletRequest r) {
|
||||
if( retractionsModel == null || additionsModel == null)
|
||||
return;
|
||||
|
||||
|
|
|
@ -251,12 +251,15 @@ public class EditConfiguration {
|
|||
UserToIndIdentifierFactory.getIndividualsForUser(ids);
|
||||
|
||||
if( userUris == null || userUris.size() == 0 ){
|
||||
System.out.println("Cound not find user ur for edit request");
|
||||
log.error("Could not find a userUri for edit request, make " +
|
||||
"sure that there is an IdentifierBundleFactory that " +
|
||||
"produces userUri identifiers in the context.");
|
||||
} else if( userUris.size() > 1 ){
|
||||
log.error("Found multiple userUris, using the first in list.");
|
||||
System.out.println("Found multiple user uris");
|
||||
}else {
|
||||
System.out.println("EditConfiguration.java - checking system value for User URI " + userUris.get(0));
|
||||
getUrisInScope().put("editingUser",userUris.get(0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Calendar;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
|
@ -46,7 +47,6 @@ public class EditSubmission {
|
|||
}
|
||||
|
||||
public EditSubmission(Map<String,String[]> queryParameters, EditConfiguration editConfig){
|
||||
|
||||
if( editConfig == null )
|
||||
throw new Error("EditSubmission needs an EditConfiguration");
|
||||
this.editKey = editConfig.getEditKey();
|
||||
|
@ -70,7 +70,6 @@ public class EditSubmission {
|
|||
log.debug("No value found for query parameter " + var);
|
||||
}
|
||||
}
|
||||
|
||||
this.literalsFromForm =new HashMap<String,Literal>();
|
||||
for(String var: editConfig.getLiteralsOnForm() ){
|
||||
Field field = editConfig.getField(var);
|
||||
|
@ -126,6 +125,8 @@ public class EditSubmission {
|
|||
if( errors != null ) {
|
||||
validationErrors.putAll( errors);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public EditSubmission(Map<String, String[]> queryParameters, EditConfiguration editConfig,
|
||||
|
@ -301,9 +302,36 @@ public class EditSubmission {
|
|||
return null;
|
||||
}
|
||||
|
||||
//Removing this
|
||||
/*
|
||||
boolean compareCurrentDate = false;
|
||||
String[] dateNotPastArgs = queryParameters.get("validDateParam");
|
||||
if(dateNotPastArgs != null && dateNotPastArgs.length > 0) {
|
||||
|
||||
compareCurrentDate = (dateNotPastArgs[0].equals("dateNotPast"));
|
||||
}*/
|
||||
|
||||
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() );
|
||||
|
|
|
@ -4,8 +4,10 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
|
|||
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public interface ModelChangePreprocessor {
|
||||
|
||||
public abstract void preprocess ( Model retractionsModel, Model additionsModel );
|
||||
public abstract void preprocess ( Model retractionsModel, Model additionsModel, HttpServletRequest request );
|
||||
|
||||
}
|
||||
|
|
|
@ -305,6 +305,7 @@ public class InputElementFormattingTag extends TagSupport {
|
|||
Map<String,String> errors = editSub.getValidationErrors();
|
||||
if( errors == null || errors.isEmpty())
|
||||
return "";
|
||||
|
||||
String val = errors.get(getId());
|
||||
if( val != null){
|
||||
return val;
|
||||
|
@ -340,7 +341,6 @@ public class InputElementFormattingTag extends TagSupport {
|
|||
/* populate the pieces */
|
||||
String classStr = doClass();
|
||||
String errorStr = getValidationErrors(editSub);
|
||||
|
||||
JspWriter out = pageContext.getOut();
|
||||
|
||||
boolean definitionTags = false; // current default
|
||||
|
@ -355,12 +355,15 @@ public class InputElementFormattingTag extends TagSupport {
|
|||
}
|
||||
|
||||
Field field = editConfig == null ? null : editConfig.getField(getId());
|
||||
|
||||
if( getType().equalsIgnoreCase("date") ||
|
||||
(field != null && field.getRangeDatatypeUri() != null && field.getRangeDatatypeUri().equals(XSD.date.getURI())) ){
|
||||
//if its a dataprop that should be a string override type and use date picker
|
||||
if (definitionTags) { out.print("<dg>"); }
|
||||
out.print( generateHtmlForDate(getId(),editConfig,editSub) );
|
||||
if (definitionTags) { out.print("</dg>"); }
|
||||
|
||||
|
||||
} else if ( getType().equalsIgnoreCase("time") ||
|
||||
(field != null && field.getRangeDatatypeUri() != null && field.getRangeDatatypeUri().equals(XSD.time.getURI())) ) {
|
||||
if (definitionTags) { out.print("<dd>"); }
|
||||
|
@ -636,14 +639,14 @@ public class InputElementFormattingTag extends TagSupport {
|
|||
}
|
||||
}else{
|
||||
//try to get default value
|
||||
System.out.println("Trying to get the default value");
|
||||
|
||||
Field field = editConfig.getField(fieldName);
|
||||
List<List<String>> options = field.getLiteralOptions();
|
||||
if( options.size() >=1 && options.get(0) != null &&
|
||||
options.get(0).size() >= 1 && options.get(0).get(0) != null){
|
||||
dateStrFromLit = options.get(0).get(0);
|
||||
}else{
|
||||
System.out.println("No default value found for field " + fieldName);
|
||||
|
||||
log.debug("no default found for field " + fieldName);
|
||||
}
|
||||
}
|
||||
|
@ -737,6 +740,10 @@ public class InputElementFormattingTag extends TagSupport {
|
|||
sb += " <option value=\"31\" "+(day == 31?SELECTED:"")+">31</option> \n";
|
||||
sb += " </select> \n";
|
||||
sb += "</div> \n";
|
||||
if(fieldName.equals("expectedPublicationDateEdited")) {
|
||||
|
||||
sb += "<input type='hidden' id='validDateParam' name='validDateParam' value='dateNotPast'/>";
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
|
||||
|
|
|
@ -233,6 +233,7 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.
|
|||
}
|
||||
|
||||
request.setAttribute("form", form);
|
||||
System.out.println("EditRequestDispatch - Forwarding TO: " + form);
|
||||
%>
|
||||
<jsp:forward page="/edit/forms/${form}" />
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("edu.cornell.mannlib.vitro.jsp.edit.forms.defaultDatapropForm.jsp");
|
||||
log.debug("Starting defaultDatapropForm.jsp");
|
||||
VitroRequest vreq = new VitroRequest(request);
|
||||
|
||||
System.out.println("Default data prop form is being called");
|
||||
String subjectUri = vreq.getParameter("subjectUri");
|
||||
String predicateUri = vreq.getParameter("predicateUri");
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.Field" %>
|
||||
<%@ page import="java.io.StringReader" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.Iterator" %>
|
||||
<%@page import="org.apache.commons.logging.LogFactory"%>
|
||||
<%@page import="org.apache.commons.logging.Log"%>
|
||||
<%@page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
|
||||
|
@ -66,7 +68,18 @@ are well formed.
|
|||
* we have to make a copy. */
|
||||
Map <String,String[]> queryParameters = null;
|
||||
queryParameters = vreq.getParameterMap();
|
||||
|
||||
Iterator it = queryParameters.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry pairs = (Map.Entry)it.next();
|
||||
String[] value= (String[]) pairs.getValue();
|
||||
System.out.println(pairs.getKey() + " = ");
|
||||
if(value != null && value.length > 0 ) {
|
||||
int i;
|
||||
for(i = 0; i < value.length; i++) {
|
||||
System.out.println(" " + value[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<String> errorMessages = new ArrayList<String>();
|
||||
|
||||
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,vreq,queryParameters);
|
||||
|
@ -296,7 +309,7 @@ are well formed.
|
|||
List<ModelChangePreprocessor> modelChangePreprocessors = editConfig.getModelChangePreprocessors();
|
||||
if ( modelChangePreprocessors != null ) {
|
||||
for ( ModelChangePreprocessor pp : modelChangePreprocessors ) {
|
||||
pp.preprocess( actualRetractions, actualAssertions );
|
||||
pp.preprocess( actualRetractions, actualAssertions, request );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,3 @@
|
|||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
||||
|
||||
<% if (securityLevel >= loginHandler.DBA) { %>
|
||||
<div class="pageBodyGroup">
|
||||
|
||||
<h3>Reports</h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="customsparql?queryType=fileupload">Custom Report: File Publication Date > 1 YEAR AGO</a></li>
|
||||
<li><a href="customsparql?queryType=filedelete">Custom Report: File Deleted > 1 YEAR AGO</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<% } %>
|
||||
<!--If your product contains custom reports, then overwrite this page-->
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
<% if (securityLevel >= loginHandler.DBA) { %>
|
||||
<li><a href="listUsers?home=<%=portal.getPortalId()%>">User accounts</a></li>
|
||||
<li><a href="usermail?home=<%=portal.getPortalId()%>">Email All Users</a></li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue