[VIVO-1245] Cleanup of NewIndividualFormGenerator, simplify configuration of generators and improve means of configuring in Freemarker
This commit is contained in:
parent
5cbcab5bcc
commit
fbeed01a94
10 changed files with 34 additions and 40 deletions
|
@ -30,7 +30,7 @@ public class JspToGeneratorMapping {
|
|||
map.put("dateTimeValueForm.jsp",
|
||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.DateTimeValueFormGenerator.class.getName());
|
||||
map.put("defaultAddMissingIndividualForm.jsp",
|
||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.DefaultAddMissingIndividualFormGenerator.getImplementationName());
|
||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.DefaultAddMissingIndividualFormGenerator.class.getName());
|
||||
map.put("defaultDatapropForm.jsp",
|
||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.DefaultDataPropertyFormGenerator.class.getName());
|
||||
map.put("defaultObjPropForm.jsp",
|
||||
|
@ -56,4 +56,18 @@ public class JspToGeneratorMapping {
|
|||
log.error( "could not load VIVO jsp mappings",th );
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T createFor(String jsp, Class<T> clazz) {
|
||||
try {
|
||||
if (jspsToGenerators.containsKey(jsp)) {
|
||||
Class classDefinition = Class.forName(jspsToGenerators.get(jsp));
|
||||
if (clazz.isAssignableFrom(classDefinition)) {
|
||||
return (T) classDefinition.newInstance();
|
||||
}
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,30 +46,12 @@ public class DefaultAddMissingIndividualFormGenerator implements EditConfigurati
|
|||
protected static String objectVarName = "newIndividual";
|
||||
private static HashMap<String,String> defaultsForXSDtypes ;
|
||||
|
||||
private static Class defaultGeneratorClass = DefaultAddMissingIndividualFormGenerator.class;
|
||||
|
||||
static {
|
||||
defaultsForXSDtypes = new HashMap<String,String>();
|
||||
//defaultsForXSDtypes.put("http://www.w3.org/2001/XMLSchema#dateTime","2001-01-01T12:00:00");
|
||||
defaultsForXSDtypes.put("http://www.w3.org/2001/XMLSchema#dateTime","#Unparseable datetime defaults to now");
|
||||
}
|
||||
|
||||
protected DefaultAddMissingIndividualFormGenerator() { }
|
||||
|
||||
public static final DefaultAddMissingIndividualFormGenerator create() {
|
||||
try {
|
||||
return (DefaultAddMissingIndividualFormGenerator) defaultGeneratorClass.newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
throw new IllegalStateException("Unable to create DefaultAddMissingIndividualFormGenerator", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new IllegalStateException("Unable to create DefaultAddMissingIndividualFormGenerator", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String getImplementationName() {
|
||||
return defaultGeneratorClass.getName();
|
||||
}
|
||||
|
||||
//Method which checks whether this particular generator should be employed
|
||||
public static final boolean isCreateNewIndividual(VitroRequest vreq, HttpSession session) {
|
||||
String command = vreq.getParameter("cmd");
|
||||
|
@ -480,11 +462,4 @@ public class DefaultAddMissingIndividualFormGenerator implements EditConfigurati
|
|||
|
||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
}
|
||||
|
||||
|
||||
protected static void registerGeneratorClass(Class clazz) {
|
||||
if (DefaultAddMissingIndividualFormGenerator.class.isAssignableFrom(clazz)) {
|
||||
defaultGeneratorClass = clazz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Map;
|
|||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.JspToGeneratorMapping;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -98,7 +99,7 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
|||
|
||||
//Check if create new and return specific edit configuration from that generator.
|
||||
if(DefaultAddMissingIndividualFormGenerator.isCreateNewIndividual(vreq, session)) {
|
||||
DefaultAddMissingIndividualFormGenerator generator = DefaultAddMissingIndividualFormGenerator.create();
|
||||
EditConfigurationGenerator generator = JspToGeneratorMapping.createFor("defaultAddMissingIndividualForm.jsp", DefaultAddMissingIndividualFormGenerator.class);
|
||||
return generator.getEditConfiguration(vreq, session);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#import "lib-generator-classes.ftl" as generators />
|
||||
|
||||
<div>
|
||||
|
||||
<#if pages?has_content >
|
||||
|
@ -25,7 +27,7 @@
|
|||
<form id="addIndividualClass" action="${urls.base}/editRequestDispatch" method="get">
|
||||
<input type="hidden" name="typeOfNew" value="http://vitro.mannlib.cornell.edu/ontologies/display/1.1#Page">
|
||||
<input type="hidden" name="switchToDisplayModel" value="1">
|
||||
<input type="hidden" name="editForm" value="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.NewIndividualFormGenerator" role="input">
|
||||
<input type="hidden" name="editForm" value="${generators.NewIndividualFormGenerator}" role="input">
|
||||
<input type="submit" id="submit" value="${i18n().add_page}" role="button">
|
||||
</form>
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#import "lib-generator-classes.ftl" as generators />
|
||||
|
||||
<div>
|
||||
|
||||
<#if pages?has_content >
|
||||
|
@ -25,7 +27,7 @@
|
|||
<form id="addIndividualClass" action="${urls.base}/editRequestDispatch" method="get">
|
||||
<input type="hidden" name="typeOfNew" value="http://vitro.mannlib.cornell.edu/ontologies/display/1.1#Page">
|
||||
<input type="hidden" name="switchToDisplayModel" value="1">
|
||||
<input type="hidden" name="editForm" value="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.NewIndividualFormGenerator" role="input">
|
||||
<input type="hidden" name="editForm" value="${generators.NewIndividualFormGenerator}" role="input">
|
||||
<input type="submit" id="submit" value="${i18n().Add_page}" role="button">
|
||||
</form>
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<#-- Template for Site Administration data input panel -->
|
||||
|
||||
<#import "lib-form.ftl" as form>
|
||||
<#import "lib-generator-classes.ftl" as generators />
|
||||
|
||||
<#if dataInput?has_content>
|
||||
<section class="pageBodyGroup" role="region">
|
||||
|
@ -12,7 +13,7 @@
|
|||
<select id="VClassURI" name="typeOfNew" class="form-item long-options" role="select">
|
||||
<@form.optionGroups groups=dataInput.groupedClassOptions />
|
||||
</select>
|
||||
<input type="hidden" name="editForm" value="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.NewIndividualFormGenerator" role="input" />
|
||||
<input type="hidden" name="editForm" value="${generators.NewIndividualFormGenerator}" role="input" />
|
||||
<input type="submit" id="submit" value="${i18n().add_individual_of_class}" role="button" />
|
||||
</form>
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#assign ManageLabelsGenerator = "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageLabelsGenerator" />
|
||||
<#assign NewIndividualFormGenerator = "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.NewIndividualFormGenerator" />
|
|
@ -1,5 +0,0 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#function class_ManageLabelsGenerator>
|
||||
<#return "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.VIVOManageLabelsGenerator" />
|
||||
</#function>
|
|
@ -4,7 +4,7 @@
|
|||
Macros and functions for working with properties and property lists
|
||||
------------------------------------------------------------------------------>
|
||||
|
||||
<#include "lib-properties-classes.ftl" />
|
||||
<#import "lib-generator-classes.ftl" as generators />
|
||||
|
||||
<#-- Return true iff there are statements for this property -->
|
||||
<#function hasStatements propertyGroups propertyName>
|
||||
|
@ -304,7 +304,7 @@ name will be used as the label. -->
|
|||
<#if editable>
|
||||
<#assign imageAlt = "${i18n().manage}" />
|
||||
<#assign linkTitle = "${i18n().manage_list_of_labels}">
|
||||
<#assign labelLink= "${urls.base}/editRequestDispatch?subjectUri=${individualUri}&editForm=${class_ManageLabelsGenerator}&predicateUri=${labelPropertyUri}${extraParameters}">
|
||||
<#assign labelLink= "${urls.base}/editRequestDispatch?subjectUri=${individualUri}&editForm=${generators.ManageLabelsGenerator}&predicateUri=${labelPropertyUri}${extraParameters}">
|
||||
<#else>
|
||||
<#assign linkTitle = "${i18n().view_list_of_labels}">
|
||||
<#assign imageAlt = "${i18n().view}" />
|
||||
|
|
Loading…
Add table
Reference in a new issue