Changes to AddRoleToPersonTwoStage and subclasses

This commit is contained in:
briancaruso 2011-11-11 21:47:51 +00:00
parent 5a2e1c76f0
commit a55bab3002
15 changed files with 438 additions and 1499 deletions

View file

@ -2,116 +2,38 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.XSD;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditN3GeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SelectListGeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils;
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation;
/**
* Generates the edit configuration for adding a Role to a Person.
Stage one is selecting the type of the non-person thing
associated with the Role with the intention of reducing the
number of Individuals that the user has to select from.
Stage two is selecting the non-person Individual to associate
with the Role.
This is intended to create a set of statements like:
?person core:hasResearchActivityRole ?newRole.
?newRole rdf:type core:ResearchActivityRole ;
roleToActivityPredicate ?someActivity .
?someActivity rdf:type core:ResearchActivity .
?someActivity rdfs:label "activity title" .
Each subclass of the abstract two stage Generator class will have the option of overriding certain
methods, and must always implement the following methods:
getRoleType
getRoleActivityTypeOptionsType
getRoleActivityTypeObjectClassUri
getRoleActivityTypeLiteralOptions
*
*/
public class AddAttendeeRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator { public class AddAttendeeRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
private Log log = LogFactory.getLog(AddAttendeeRoleToPersonGenerator.class); private static String TEMPLATE = "addAttendeeRoleToPerson.ftl";
private static String template = "addAttendeeRoleToPerson.ftl";
@Override
//Should this be overridden String getTemplate(){ return TEMPLATE; }
@Override
protected void setTemplate(EditConfigurationVTwo editConfiguration,
VitroRequest vreq) {
editConfiguration.setTemplate(template);
}
@Override
//The default activityToRolePredicate and roleToActivityPredicates are String getRoleType() {
//correct for this subclass so they don't need to be overwritten return "http://vivoweb.org/ontology/core#AttendeeRole";
}
//role type will always be set based on particular form
public String getRoleType(VitroRequest vreq) { @Override
//TODO: Get dynamic way of including vivoweb ontology public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) {
return "http://vivoweb.org/ontology/core#AttendeeRole"; //no ClassURI since it uses hard coded literals
} return null;
}
//Each subclass generator will return its own type of option here:
//whether literal hardcoded, based on class group, or subclasses of a specific class @Override
//The latter two will apparently lend some kind of uri to objectClassUri ? public RoleActivityOptionTypes getRoleActivityTypeOptionsType() {
public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) { return RoleActivityOptionTypes.HARDCODED_LITERALS;
return RoleActivityOptionTypes.HARDCODED_LITERALS; }
}
//Editor role involves hard-coded options for the "right side" of the role or activity
//This too will depend on the specific subclass of generator @Override
public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { protected HashMap<String, String> getRoleActivityTypeLiteralOptions() {
return null; HashMap<String, String> literalOptions = new HashMap<String, String>();
} literalOptions.put("", "Select type");
//Attendee role involves hard-coded options for the "right side" of the role or activity
protected HashMap<String, String> getRoleActivityTypeLiteralOptions(VitroRequest vreq) {
HashMap<String, String> literalOptions = new HashMap<String, String>();
literalOptions.put("", "Select type");
literalOptions.put("http://purl.org/NET/c4dm/event.owl#Event", "Event"); literalOptions.put("http://purl.org/NET/c4dm/event.owl#Event", "Event");
literalOptions.put("http://vivoweb.org/ontology/core#Competition", "Competition"); literalOptions.put("http://vivoweb.org/ontology/core#Competition", "Competition");
literalOptions.put("http://purl.org/ontology/bibo/Conference", "Conference"); literalOptions.put("http://purl.org/ontology/bibo/Conference", "Conference");
@ -125,10 +47,11 @@ public class AddAttendeeRoleToPersonGenerator extends AddRoleToPersonTwoStageGen
literalOptions.put("http://vivoweb.org/ontology/core#ConferenceSeries", "Conference Series"); literalOptions.put("http://vivoweb.org/ontology/core#ConferenceSeries", "Conference Series");
literalOptions.put("http://vivoweb.org/ontology/core#SeminarSeries", "Seminar Series"); literalOptions.put("http://vivoweb.org/ontology/core#SeminarSeries", "Seminar Series");
literalOptions.put("http://vivoweb.org/ontology/core#WorkshopSeries", "Workshop Series"); literalOptions.put("http://vivoweb.org/ontology/core#WorkshopSeries", "Workshop Series");
return literalOptions; return literalOptions;
} }
//isShowRoleLabelField remains true for this so doesn't need to be overwritten @Override
boolean isShowRoleLabelField() {
return true;
}
} }

View file

@ -2,114 +2,38 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.XSD;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditN3GeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SelectListGeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils;
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation;
/**
* Generates the edit configuration for adding a Role to a Person.
Stage one is selecting the type of the non-person thing
associated with the Role with the intention of reducing the
number of Individuals that the user has to select from.
Stage two is selecting the non-person Individual to associate
with the Role.
This is intended to create a set of statements like:
?person core:hasResearchActivityRole ?newRole.
?newRole rdf:type core:ResearchActivityRole ;
roleToActivityPredicate ?someActivity .
?someActivity rdf:type core:ResearchActivity .
?someActivity rdfs:label "activity title" .
Each subclass of the abstract two stage Generator class will have the option of overriding certain
methods, and must always implement the following methods:
getRoleType
getRoleActivityTypeOptionsType
getRoleActivityTypeObjectClassUri
getRoleActivityTypeLiteralOptions
*
*/
public class AddClinicalRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator { public class AddClinicalRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
private Log log = LogFactory.getLog(AddClinicalRoleToPersonGenerator.class);
private static String template = "addClinicalRoleToPerson.ftl"; private static String template = "addClinicalRoleToPerson.ftl";
//Should this be overridden //Should this be overridden
@Override @Override
protected void setTemplate(EditConfigurationVTwo editConfiguration, String getTemplate() {
VitroRequest vreq) { return template;
editConfiguration.setTemplate(template);
} }
@Override
//The default activityToRolePredicate and roleToActivityPredicates are String getRoleType() {
//correct for this subclass so they don't need to be overwritten
//role type will always be set based on particular form
public String getRoleType(VitroRequest vreq) {
//TODO: Get dynamic way of including vivoweb ontology
return "http://vivoweb.org/ontology/core#ClinicalRole"; return "http://vivoweb.org/ontology/core#ClinicalRole";
} }
//Each subclass generator will return its own type of option here: @Override
//whether literal hardcoded, based on class group, or subclasses of a specific class RoleActivityOptionTypes getRoleActivityTypeOptionsType() {
//The latter two will apparently lend some kind of uri to objectClassUri ?
public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) {
return RoleActivityOptionTypes.HARDCODED_LITERALS; return RoleActivityOptionTypes.HARDCODED_LITERALS;
} }
//This too will depend on the specific subclass of generator @Override
public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { String getRoleActivityTypeObjectClassUri(VitroRequest vreq) {
return null; return null; //not needed since the options are hard coded
} }
//Clinical role involves hard-coded options for the "right side" of the role or activity //Clinical role involves hard-coded options for the "right side" of the role or activity
protected HashMap<String, String> getRoleActivityTypeLiteralOptions(VitroRequest vreq) { @Override
HashMap<String, String> getRoleActivityTypeLiteralOptions() {
HashMap<String, String> literalOptions = new HashMap<String, String>(); HashMap<String, String> literalOptions = new HashMap<String, String>();
literalOptions.put("", "Select one"); literalOptions.put("", "Select one");
literalOptions.put("http://vivoweb.org/ontology/core#Project", "Project"); literalOptions.put("http://vivoweb.org/ontology/core#Project", "Project");
@ -118,6 +42,9 @@ public class AddClinicalRoleToPersonGenerator extends AddRoleToPersonTwoStageGen
} }
//isShowRoleLabelField remains true for this so doesn't need to be overwritten //isShowRoleLabelField remains true for this so doesn't need to be overwritten
@Override
boolean isShowRoleLabelField(){
return true;
}
} }

View file

@ -74,47 +74,35 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
* *
*/ */
public class AddEditorRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator { public class AddEditorRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
private static String TEMPLATE = "addEditorRoleToPerson.ftl";
private Log log = LogFactory.getLog(AddEditorRoleToPersonGenerator.class);
private static String template = "addEditorRoleToPerson.ftl";
//Should this be overridden
@Override @Override
protected void setTemplate(EditConfigurationVTwo editConfiguration, String getTemplate(){ return TEMPLATE; }
VitroRequest vreq) {
editConfiguration.setTemplate(template);
}
//role type will always be set based on particular form @Override
public String getRoleType(VitroRequest vreq) { String getRoleType() {
//TODO: Get dynamic way of including vivoweb ontology
return "http://vivoweb.org/ontology/core#EditorRole"; return "http://vivoweb.org/ontology/core#EditorRole";
} }
//Each subclass generator will return its own type of option here: @Override
//whether literal hardcoded, based on class group, or subclasses of a specific class public RoleActivityOptionTypes getRoleActivityTypeOptionsType() {
//The latter two will apparently lend some kind of uri to objectClassUri ?
public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) {
return RoleActivityOptionTypes.CHILD_VCLASSES; return RoleActivityOptionTypes.CHILD_VCLASSES;
} }
//This too will depend on the specific subclass of generator @Override
public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) {
return "http://purl.org/ontology/bibo/Collection"; return "http://purl.org/ontology/bibo/Collection";
} }
//Editor role involves hard-coded options for the "right side" of the role or activity //Editor role involves hard-coded options for the "right side" of the role or activity
protected HashMap<String, String> getRoleActivityTypeLiteralOptions(VitroRequest vreq) { @Override
protected HashMap<String, String> getRoleActivityTypeLiteralOptions() {
HashMap<String, String> literalOptions = new HashMap<String, String>(); HashMap<String, String> literalOptions = new HashMap<String, String>();
literalOptions.put("", "Select type"); literalOptions.put("", "Select type");
return literalOptions; return literalOptions;
} }
//isShowRoleLabelField remains true for this so doesn't need to be overwritten /** Do not show the role label field for the AddEditorRoleToPerson form */
public boolean isShowRoleLabelField(VitroRequest vreq) { @Override
return false; boolean isShowRoleLabelField() { return false; }
}
} }

View file

@ -144,17 +144,10 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
editConfiguration.setVarNameForPredicate("rolePredicate"); editConfiguration.setVarNameForPredicate("rolePredicate");
editConfiguration.setPredicateUri(predicateUri); editConfiguration.setPredicateUri(predicateUri);
//by definition, this is an object property //by definition, this is an object property
this.initObjectParameters(vreq);
this.processObjectPropForm(vreq, editConfiguration);
}
private void initObjectParameters(VitroRequest vreq) {
//in case of object property
objectUri = EditConfigurationUtils.getObjectUri(vreq); objectUri = EditConfigurationUtils.getObjectUri(vreq);
}
this.processObjectPropForm(vreq, editConfiguration);
}
private void processObjectPropForm(VitroRequest vreq, EditConfigurationVTwo editConfiguration) { private void processObjectPropForm(VitroRequest vreq, EditConfigurationVTwo editConfiguration) {
editConfiguration.setVarNameForObject("role"); editConfiguration.setVarNameForObject("role");

View file

@ -2,114 +2,38 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.XSD;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditN3GeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SelectListGeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils;
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation;
/**
* Generates the edit configuration for adding a Role to a Person.
Stage one is selecting the type of the non-person thing
associated with the Role with the intention of reducing the
number of Individuals that the user has to select from.
Stage two is selecting the non-person Individual to associate
with the Role.
This is intended to create a set of statements like:
?person core:hasResearchActivityRole ?newRole.
?newRole rdf:type core:ResearchActivityRole ;
roleToActivityPredicate ?someActivity .
?someActivity rdf:type core:ResearchActivity .
?someActivity rdfs:label "activity title" .
Each subclass of the abstract two stage Generator class will have the option of overriding certain
methods, and must always implement the following methods:
getRoleType
getRoleActivityTypeOptionsType
getRoleActivityTypeObjectClassUri
getRoleActivityTypeLiteralOptions
*
*/
public class AddHeadOfRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator { public class AddHeadOfRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
private Log log = LogFactory.getLog(AddHeadOfRoleToPersonGenerator.class);
private static String template = "addHeadOfRoleToPerson.ftl"; private static String template = "addHeadOfRoleToPerson.ftl";
//Should this be overridden //Should this be overridden
@Override @Override
protected void setTemplate(EditConfigurationVTwo editConfiguration, String getTemplate() {
VitroRequest vreq) { return template;
editConfiguration.setTemplate(template);
} }
//The default activityToRolePredicate and roleToActivityPredicates are
//correct for this subclass so they don't need to be overwritten
//role type will always be set based on particular form @Override
public String getRoleType(VitroRequest vreq) { String getRoleType() {
//TODO: Get dynamic way of including vivoweb ontology
return "http://vivoweb.org/ontology/core#LeaderRole"; return "http://vivoweb.org/ontology/core#LeaderRole";
} }
//Each subclass generator will return its own type of option here: @Override
//whether literal hardcoded, based on class group, or subclasses of a specific class RoleActivityOptionTypes getRoleActivityTypeOptionsType() {
//The latter two will apparently lend some kind of uri to objectClassUri ?
public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) {
return RoleActivityOptionTypes.HARDCODED_LITERALS; return RoleActivityOptionTypes.HARDCODED_LITERALS;
} }
//This too will depend on the specific subclass of generator @Override
public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { String getRoleActivityTypeObjectClassUri(VitroRequest vreq) {
return null; return null; //not needed since this is HARDCODED_LITERALS
} }
//Head Of role involves hard-coded options for the "right side" of the role or activity /** Head Of role involves hard-coded options for the "right side" of the role or activity */
protected HashMap<String, String> getRoleActivityTypeLiteralOptions(VitroRequest vreq) { @Override
HashMap<String, String> getRoleActivityTypeLiteralOptions() {
HashMap<String, String> literalOptions = new HashMap<String, String>(); HashMap<String, String> literalOptions = new HashMap<String, String>();
literalOptions.put("", "Select type"); literalOptions.put("", "Select type");
literalOptions.put("http://vivoweb.org/ontology/core#Association", "Association"); literalOptions.put("http://vivoweb.org/ontology/core#Association", "Association");
@ -144,7 +68,8 @@ public class AddHeadOfRoleToPersonGenerator extends AddRoleToPersonTwoStageGener
return literalOptions; return literalOptions;
} }
//isShowRoleLabelField remains true for this so doesn't need to be overwritten @Override
boolean isShowRoleLabelField(){return true;}
} }

View file

@ -2,121 +2,44 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.XSD;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditN3GeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SelectListGeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils;
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation;
/**
* Generates the edit configuration for adding a Role to a Person.
Stage one is selecting the type of the non-person thing
associated with the Role with the intention of reducing the
number of Individuals that the user has to select from.
Stage two is selecting the non-person Individual to associate
with the Role.
This is intended to create a set of statements like:
?person core:hasResearchActivityRole ?newRole.
?newRole rdf:type core:ResearchActivityRole ;
roleToActivityPredicate ?someActivity .
?someActivity rdf:type core:ResearchActivity .
?someActivity rdfs:label "activity title" .
Each subclass of the abstract two stage Generator class will have the option of overriding certain
methods, and must always implement the following methods:
getRoleType
getRoleActivityTypeOptionsType
getRoleActivityTypeObjectClassUri
getRoleActivityTypeLiteralOptions
*
*/
public class AddMemberRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator { public class AddMemberRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
private Log log = LogFactory.getLog(AddMemberRoleToPersonGenerator.class);
private static String template = "addMemberRoleToPerson.ftl"; private static String template = "addMemberRoleToPerson.ftl";
//Should this be overridden
@Override @Override
protected void setTemplate(EditConfigurationVTwo editConfiguration, String getTemplate() {
VitroRequest vreq) { return template;
editConfiguration.setTemplate(template); }
}
//The default activityToRolePredicate and roleToActivityPredicates are
//correct for this subclass so they don't need to be overwritten
//role type will always be set based on particular form @Override
public String getRoleType(VitroRequest vreq) { String getRoleType() {
//TODO: Get dynamic way of including vivoweb ontology
return "http://vivoweb.org/ontology/core#MemberRole"; return "http://vivoweb.org/ontology/core#MemberRole";
} }
//Each subclass generator will return its own type of option here: @Override
//whether literal hardcoded, based on class group, or subclasses of a specific class RoleActivityOptionTypes getRoleActivityTypeOptionsType() {
//The latter two will apparently lend some kind of uri to objectClassUri ?
public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) {
return RoleActivityOptionTypes.VCLASSGROUP; return RoleActivityOptionTypes.VCLASSGROUP;
} }
//This too will depend on the specific subclass of generator @Override
public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) {
//this is needed since the OptionTypes is VCLASSGROUP
return "http://vivoweb.org/ontology#vitroClassGrouporganizations"; return "http://vivoweb.org/ontology#vitroClassGrouporganizations";
} }
//Member role involves hard-coded options for the "right side" of the role or activity @Override
protected HashMap<String, String> getRoleActivityTypeLiteralOptions(VitroRequest vreq) { HashMap<String, String> getRoleActivityTypeLiteralOptions() {
HashMap<String, String> literalOptions = new HashMap<String, String>(); HashMap<String, String> literalOptions = new HashMap<String, String>();
literalOptions.put("", "Select type"); literalOptions.put("", "Select type");
return literalOptions; return literalOptions;
} }
//isShowRoleLabelField remains true for this so doesn't need to be overwritten @Override
boolean isShowRoleLabelField(){return true;}
} }

View file

@ -2,114 +2,38 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.XSD;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditN3GeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SelectListGeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils;
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation;
/**
* Generates the edit configuration for adding a Role to a Person.
Stage one is selecting the type of the non-person thing
associated with the Role with the intention of reducing the
number of Individuals that the user has to select from.
Stage two is selecting the non-person Individual to associate
with the Role.
This is intended to create a set of statements like:
?person core:hasResearchActivityRole ?newRole.
?newRole rdf:type core:ResearchActivityRole ;
roleToActivityPredicate ?someActivity .
?someActivity rdf:type core:ResearchActivity .
?someActivity rdfs:label "activity title" .
Each subclass of the abstract two stage Generator class will have the option of overriding certain
methods, and must always implement the following methods:
getRoleType
getRoleActivityTypeOptionsType
getRoleActivityTypeObjectClassUri
getRoleActivityTypeLiteralOptions
*
*/
public class AddOrganizerRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator { public class AddOrganizerRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
private Log log = LogFactory.getLog(AddOrganizerRoleToPersonGenerator.class);
private static String template = "addOrganizerRoleToPerson.ftl"; private static String template = "addOrganizerRoleToPerson.ftl";
//Should this be overridden
@Override @Override
protected void setTemplate(EditConfigurationVTwo editConfiguration, String getTemplate() {
VitroRequest vreq) { return template;
editConfiguration.setTemplate(template);
} }
@Override
//The default activityToRolePredicate and roleToActivityPredicates are String getRoleType() {
//correct for this subclass so they don't need to be overwritten
//role type will always be set based on particular form
public String getRoleType(VitroRequest vreq) {
//TODO: Get dynamic way of including vivoweb ontology
return "http://vivoweb.org/ontology/core#OrganizerRole"; return "http://vivoweb.org/ontology/core#OrganizerRole";
} }
//Each subclass generator will return its own type of option here: @Override
//whether literal hardcoded, based on class group, or subclasses of a specific class RoleActivityOptionTypes getRoleActivityTypeOptionsType() {
//The latter two will apparently lend some kind of uri to objectClassUri ?
public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) {
return RoleActivityOptionTypes.HARDCODED_LITERALS; return RoleActivityOptionTypes.HARDCODED_LITERALS;
} }
//This too will depend on the specific subclass of generator @Override
public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { String getRoleActivityTypeObjectClassUri(VitroRequest vreq) {
return null; return null;
} }
//Organizer role involves hard-coded options for the "right side" of the role or activity //Organizer role involves hard-coded options for the "right side" of the role or activity
protected HashMap<String, String> getRoleActivityTypeLiteralOptions(VitroRequest vreq) { @Override
HashMap<String, String> getRoleActivityTypeLiteralOptions() {
HashMap<String, String> literalOptions = new HashMap<String, String>(); HashMap<String, String> literalOptions = new HashMap<String, String>();
literalOptions.put("", "Select type"); literalOptions.put("", "Select type");
literalOptions.put("http://purl.org/NET/c4dm/event.owl#Event", "Event"); literalOptions.put("http://purl.org/NET/c4dm/event.owl#Event", "Event");
@ -128,10 +52,9 @@ public class AddOrganizerRoleToPersonGenerator extends AddRoleToPersonTwoStageGe
return literalOptions; return literalOptions;
} }
//isShowRoleLabelField remains true for this so doesn't need to be overwritten @Override
public boolean isShowRoleLabelField(VitroRequest vreq) { boolean isShowRoleLabelField() {
return false; return false;
} }
} }

View file

@ -2,114 +2,37 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.XSD;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditN3GeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SelectListGeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils;
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation;
/**
* Generates the edit configuration for adding a Role to a Person.
Stage one is selecting the type of the non-person thing
associated with the Role with the intention of reducing the
number of Individuals that the user has to select from.
Stage two is selecting the non-person Individual to associate
with the Role.
This is intended to create a set of statements like:
?person core:hasResearchActivityRole ?newRole.
?newRole rdf:type core:ResearchActivityRole ;
roleToActivityPredicate ?someActivity .
?someActivity rdf:type core:ResearchActivity .
?someActivity rdfs:label "activity title" .
Each subclass of the abstract two stage Generator class will have the option of overriding certain
methods, and must always implement the following methods:
getRoleType
getRoleActivityTypeOptionsType
getRoleActivityTypeObjectClassUri
getRoleActivityTypeLiteralOptions
*
*/
public class AddOutreachProviderRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator { public class AddOutreachProviderRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
private Log log = LogFactory.getLog(AddOutreachProviderRoleToPersonGenerator.class);
private static String template = "addOutreachProviderRoleToPerson.ftl"; private static String template = "addOutreachProviderRoleToPerson.ftl";
//Should this be overridden
@Override @Override
protected void setTemplate(EditConfigurationVTwo editConfiguration, String getTemplate() {
VitroRequest vreq) { return template;
editConfiguration.setTemplate(template);
} }
@Override
//The default activityToRolePredicate and roleToActivityPredicates are String getRoleType() {
//correct for this subclass so they don't need to be overwritten
//role type will always be set based on particular form
public String getRoleType(VitroRequest vreq) {
//TODO: Get dynamic way of including vivoweb ontology
return "http://vivoweb.org/ontology/core#OutreachProviderRole"; return "http://vivoweb.org/ontology/core#OutreachProviderRole";
} }
//Each subclass generator will return its own type of option here: @Override
//whether literal hardcoded, based on class group, or subclasses of a specific class RoleActivityOptionTypes getRoleActivityTypeOptionsType() {
//The latter two will apparently lend some kind of uri to objectClassUri ?
public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) {
return RoleActivityOptionTypes.HARDCODED_LITERALS; return RoleActivityOptionTypes.HARDCODED_LITERALS;
} }
//This too will depend on the specific subclass of generator @Override
public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { String getRoleActivityTypeObjectClassUri(VitroRequest vreq) {
return null; return null;
} }
//Outreach Provider role involves hard-coded options for the "right side" of the role or activity //Outreach Provider role involves hard-coded options for the "right side" of the role or activity
protected HashMap<String, String> getRoleActivityTypeLiteralOptions(VitroRequest vreq) { @Override
HashMap<String, String> getRoleActivityTypeLiteralOptions() {
HashMap<String, String> literalOptions = new HashMap<String, String>(); HashMap<String, String> literalOptions = new HashMap<String, String>();
literalOptions.put("", "Select type"); literalOptions.put("", "Select type");
literalOptions.put("http://vivoweb.org/ontology/core#Association", "Association"); literalOptions.put("http://vivoweb.org/ontology/core#Association", "Association");
@ -144,6 +67,6 @@ public class AddOutreachProviderRoleToPersonGenerator extends AddRoleToPersonTwo
return literalOptions; return literalOptions;
} }
//isShowRoleLabelField remains true for this so doesn't need to be overwritten @Override
boolean isShowRoleLabelField(){return true;}
} }

View file

@ -2,114 +2,40 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.XSD;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditN3GeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SelectListGeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils;
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation;
/**
* Generates the edit configuration for adding a Role to a Person.
Stage one is selecting the type of the non-person thing
associated with the Role with the intention of reducing the
number of Individuals that the user has to select from.
Stage two is selecting the non-person Individual to associate
with the Role.
This is intended to create a set of statements like:
?person core:hasResearchActivityRole ?newRole.
?newRole rdf:type core:ResearchActivityRole ;
roleToActivityPredicate ?someActivity .
?someActivity rdf:type core:ResearchActivity .
?someActivity rdfs:label "activity title" .
Each subclass of the abstract two stage Generator class will have the option of overriding certain
methods, and must always implement the following methods:
getRoleType
getRoleActivityTypeOptionsType
getRoleActivityTypeObjectClassUri
getRoleActivityTypeLiteralOptions
*
*/
public class AddPresenterRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator { public class AddPresenterRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
private Log log = LogFactory.getLog(AddPresenterRoleToPersonGenerator.class);
private static String template = "addPresenterRoleToPerson.ftl"; private static String template = "addPresenterRoleToPerson.ftl";
//Should this be overridden
@Override @Override
protected void setTemplate(EditConfigurationVTwo editConfiguration, String getTemplate() {
VitroRequest vreq) { return template;
editConfiguration.setTemplate(template);
} }
//The default activityToRolePredicate and roleToActivityPredicates are
//correct for this subclass so they don't need to be overwritten
//role type will always be set based on particular form @Override
public String getRoleType(VitroRequest vreq) { String getRoleType() {
//TODO: Get dynamic way of including vivoweb ontology
return "http://vivoweb.org/ontology/core#PresenterRole"; return "http://vivoweb.org/ontology/core#PresenterRole";
} }
//Each subclass generator will return its own type of option here: @Override
//whether literal hardcoded, based on class group, or subclasses of a specific class RoleActivityOptionTypes getRoleActivityTypeOptionsType() {
//The latter two will apparently lend some kind of uri to objectClassUri ?
public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) {
return RoleActivityOptionTypes.HARDCODED_LITERALS; return RoleActivityOptionTypes.HARDCODED_LITERALS;
} }
//This too will depend on the specific subclass of generator
public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { @Override
String getRoleActivityTypeObjectClassUri(VitroRequest vreq) {
return null; return null;
} }
//Presenter role involves hard-coded options for the "right side" of the role or activity //Presenter role involves hard-coded options for the "right side" of the role or activity
protected HashMap<String, String> getRoleActivityTypeLiteralOptions(VitroRequest vreq) { @Override
protected HashMap<String, String> getRoleActivityTypeLiteralOptions() {
HashMap<String, String> literalOptions = new HashMap<String, String>(); HashMap<String, String> literalOptions = new HashMap<String, String>();
literalOptions.put("", "Select type"); literalOptions.put("", "Select type");
literalOptions.put("http://vivoweb.org/ontology/core#Presentation", "Presentation"); literalOptions.put("http://vivoweb.org/ontology/core#Presentation", "Presentation");
@ -117,6 +43,6 @@ public class AddPresenterRoleToPersonGenerator extends AddRoleToPersonTwoStageGe
return literalOptions; return literalOptions;
} }
//isShowRoleLabelField remains true for this so doesn't need to be overwritten @Override
boolean isShowRoleLabelField(){return true;}
} }

View file

@ -2,114 +2,37 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.XSD;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditN3GeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SelectListGeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils;
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation;
/**
* Generates the edit configuration for adding a Role to a Person.
Stage one is selecting the type of the non-person thing
associated with the Role with the intention of reducing the
number of Individuals that the user has to select from.
Stage two is selecting the non-person Individual to associate
with the Role.
This is intended to create a set of statements like:
?person core:hasResearchActivityRole ?newRole.
?newRole rdf:type core:ResearchActivityRole ;
roleToActivityPredicate ?someActivity .
?someActivity rdf:type core:ResearchActivity .
?someActivity rdfs:label "activity title" .
Each subclass of the abstract two stage Generator class will have the option of overriding certain
methods, and must always implement the following methods:
getRoleType
getRoleActivityTypeOptionsType
getRoleActivityTypeObjectClassUri
getRoleActivityTypeLiteralOptions
*
*/
public class AddResearcherRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator { public class AddResearcherRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
private Log log = LogFactory.getLog(AddResearcherRoleToPersonGenerator.class);
private static String template = "addResearcherRoleToPerson.ftl"; private static String template = "addResearcherRoleToPerson.ftl";
//Should this be overridden
@Override @Override
protected void setTemplate(EditConfigurationVTwo editConfiguration, String getTemplate() {
VitroRequest vreq) { return template;
editConfiguration.setTemplate(template);
} }
@Override
//The default activityToRolePredicate and roleToActivityPredicates are public String getRoleType() {
//correct for this subclass so they don't need to be overwritten
//role type will always be set based on particular form
public String getRoleType(VitroRequest vreq) {
//TODO: Get dynamic way of including vivoweb ontology
return "http://vivoweb.org/ontology/core#ResearcherRole"; return "http://vivoweb.org/ontology/core#ResearcherRole";
} }
//Each subclass generator will return its own type of option here: @Override
//whether literal hardcoded, based on class group, or subclasses of a specific class RoleActivityOptionTypes getRoleActivityTypeOptionsType() {
//The latter two will apparently lend some kind of uri to objectClassUri ?
public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) {
return RoleActivityOptionTypes.HARDCODED_LITERALS; return RoleActivityOptionTypes.HARDCODED_LITERALS;
} }
//This too will depend on the specific subclass of generator @Override
public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { String getRoleActivityTypeObjectClassUri(VitroRequest vreq) {
return null; return null;
} }
//Researcher role involves hard-coded options for the "right side" of the role or activity //Researcher role involves hard-coded options for the "right side" of the role or activity
protected HashMap<String, String> getRoleActivityTypeLiteralOptions(VitroRequest vreq) { @Override
HashMap<String, String> getRoleActivityTypeLiteralOptions() {
HashMap<String, String> literalOptions = new HashMap<String, String>(); HashMap<String, String> literalOptions = new HashMap<String, String>();
literalOptions.put("", "Select one"); literalOptions.put("", "Select one");
literalOptions.put("http://vivoweb.org/ontology/core#Grant", "Grant"); literalOptions.put("http://vivoweb.org/ontology/core#Grant", "Grant");
@ -117,6 +40,6 @@ public class AddResearcherRoleToPersonGenerator extends AddRoleToPersonTwoStageG
return literalOptions; return literalOptions;
} }
//isShowRoleLabelField remains true for this so doesn't need to be overwritten @Override
boolean isShowRoleLabelField() { return true; }
} }

View file

@ -2,88 +2,14 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.XSD;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditN3GeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SelectListGeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils;
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation;
/**
* Generates the edit configuration for adding a Role to a Person.
Stage one is selecting the type of the non-person thing
associated with the Role with the intention of reducing the
number of Individuals that the user has to select from.
Stage two is selecting the non-person Individual to associate
with the Role.
This is intended to create a set of statements like: public class AddReviewerRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
?person core:hasResearchActivityRole ?newRole.
?newRole rdf:type core:ResearchActivityRole ;
roleToActivityPredicate ?someActivity .
?someActivity rdf:type core:ResearchActivity .
?someActivity rdfs:label "activity title" .
Each subclass of the abstract two stage Generator class will have the option of overriding certain
methods, and must always implement the following methods:
getRoleType
getRoleActivityTypeOptionsType
getRoleActivityTypeObjectClassUri
getRoleActivityTypeLiteralOptions
*
*/
public class AddReviewerRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
private Log log = LogFactory.getLog(AddReviewerRoleToPersonGenerator.class);
private static String template = "addReviewerRoleToPerson.ftl";
//Should this be overridden
@Override @Override
protected void setTemplate(EditConfigurationVTwo editConfiguration, String getTemplate() { return "addReviewerRoleToPerson.ftl"; }
VitroRequest vreq) {
editConfiguration.setTemplate(template);
}
//The default activityToRolePredicate and roleToActivityPredicates are //The default activityToRolePredicate and roleToActivityPredicates are
@ -93,11 +19,11 @@ public class AddReviewerRoleToPersonGenerator extends AddRoleToPersonTwoStageGen
} }
public String getRoleToActivityPredicate(VitroRequest vreq) { public String getRoleToActivityPredicate(VitroRequest vreq) {
return "http://vivoweb.org/ontology/core#forInformationResource"; return "<http://vivoweb.org/ontology/core#forInformationResource>";
} }
//role type will always be set based on particular form //role type will always be set based on particular form
public String getRoleType(VitroRequest vreq) { public String getRoleType() {
//TODO: Get dynamic way of including vivoweb ontology //TODO: Get dynamic way of including vivoweb ontology
return "http://vivoweb.org/ontology/core#ReviewerRole"; return "http://vivoweb.org/ontology/core#ReviewerRole";
} }
@ -105,7 +31,7 @@ public class AddReviewerRoleToPersonGenerator extends AddRoleToPersonTwoStageGen
//Each subclass generator will return its own type of option here: //Each subclass generator will return its own type of option here:
//whether literal hardcoded, based on class group, or subclasses of a specific class //whether literal hardcoded, based on class group, or subclasses of a specific class
//The latter two will apparently lend some kind of uri to objectClassUri ? //The latter two will apparently lend some kind of uri to objectClassUri ?
public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) { public RoleActivityOptionTypes getRoleActivityTypeOptionsType() {
return RoleActivityOptionTypes.CHILD_VCLASSES; return RoleActivityOptionTypes.CHILD_VCLASSES;
} }
@ -116,14 +42,14 @@ public class AddReviewerRoleToPersonGenerator extends AddRoleToPersonTwoStageGen
//Reviewer role involves hard-coded options for the "right side" of the role or activity //Reviewer role involves hard-coded options for the "right side" of the role or activity
protected HashMap<String, String> getRoleActivityTypeLiteralOptions(VitroRequest vreq) { protected HashMap<String, String> getRoleActivityTypeLiteralOptions() {
HashMap<String, String> literalOptions = new HashMap<String, String>(); HashMap<String, String> literalOptions = new HashMap<String, String>();
literalOptions.put("", "Select type"); literalOptions.put("", "Select type");
return literalOptions; return literalOptions;
} }
//isShowRoleLabelField remains true for this so doesn't need to be overwritten //isShowRoleLabelField remains true for this so doesn't need to be overwritten
public boolean isShowRoleLabelField(VitroRequest vreq) { public boolean isShowRoleLabelField() {
return false; return false;
} }

View file

@ -2,114 +2,38 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.XSD;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditN3GeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SelectListGeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils;
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation;
/**
* Generates the edit configuration for adding a Role to a Person.
Stage one is selecting the type of the non-person thing
associated with the Role with the intention of reducing the
number of Individuals that the user has to select from.
Stage two is selecting the non-person Individual to associate
with the Role.
This is intended to create a set of statements like:
?person core:hasResearchActivityRole ?newRole.
?newRole rdf:type core:ResearchActivityRole ;
roleToActivityPredicate ?someActivity .
?someActivity rdf:type core:ResearchActivity .
?someActivity rdfs:label "activity title" .
Each subclass of the abstract two stage Generator class will have the option of overriding certain
methods, and must always implement the following methods:
getRoleType
getRoleActivityTypeOptionsType
getRoleActivityTypeObjectClassUri
getRoleActivityTypeLiteralOptions
*
*/
public class AddServiceProviderRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator { public class AddServiceProviderRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
private Log log = LogFactory.getLog(AddServiceProviderRoleToPersonGenerator.class);
private static String template = "addServiceProviderRoleToPerson.ftl"; private static String template = "addServiceProviderRoleToPerson.ftl";
//Should this be overridden
@Override @Override
protected void setTemplate(EditConfigurationVTwo editConfiguration, String getTemplate() {
VitroRequest vreq) { return template;
editConfiguration.setTemplate(template);
} }
@Override
//The default activityToRolePredicate and roleToActivityPredicates are String getRoleType() {
//correct for this subclass so they don't need to be overwritten
//role type will always be set based on particular form
public String getRoleType(VitroRequest vreq) {
//TODO: Get dynamic way of including vivoweb ontology
return "http://vivoweb.org/ontology/core#ServiceProviderRole"; return "http://vivoweb.org/ontology/core#ServiceProviderRole";
} }
//Each subclass generator will return its own type of option here: @Override
//whether literal hardcoded, based on class group, or subclasses of a specific class RoleActivityOptionTypes getRoleActivityTypeOptionsType() {
//The latter two will apparently lend some kind of uri to objectClassUri ?
public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) {
return RoleActivityOptionTypes.HARDCODED_LITERALS; return RoleActivityOptionTypes.HARDCODED_LITERALS;
} }
//This too will depend on the specific subclass of generator @Override
public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { String getRoleActivityTypeObjectClassUri(VitroRequest vreq) {
return null; return null;
} }
//Service Provider role involves hard-coded options for the "right side" of the role or activity //Service Provider role involves hard-coded options for the "right side" of the role or activity
protected HashMap<String, String> getRoleActivityTypeLiteralOptions(VitroRequest vreq) { @Override
HashMap<String, String> getRoleActivityTypeLiteralOptions() {
HashMap<String, String> literalOptions = new HashMap<String, String>(); HashMap<String, String> literalOptions = new HashMap<String, String>();
literalOptions.put("", "Select one"); literalOptions.put("", "Select one");
literalOptions.put("http://purl.org/ontology/bibo/Conference", "Conference"); literalOptions.put("http://purl.org/ontology/bibo/Conference", "Conference");
@ -145,7 +69,8 @@ public class AddServiceProviderRoleToPersonGenerator extends AddRoleToPersonTwoS
return literalOptions; return literalOptions;
} }
//isShowRoleLabelField remains true for this so doesn't need to be overwritten @Override
boolean isShowRoleLabelField() { return false; }
} }

View file

@ -2,114 +2,38 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.XSD;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditN3GeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SelectListGeneratorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils;
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation;
/**
* Generates the edit configuration for adding a Role to a Person.
Stage one is selecting the type of the non-person thing
associated with the Role with the intention of reducing the
number of Individuals that the user has to select from.
Stage two is selecting the non-person Individual to associate
with the Role.
This is intended to create a set of statements like:
?person core:hasResearchActivityRole ?newRole.
?newRole rdf:type core:ResearchActivityRole ;
roleToActivityPredicate ?someActivity .
?someActivity rdf:type core:ResearchActivity .
?someActivity rdfs:label "activity title" .
Each subclass of the abstract two stage Generator class will have the option of overriding certain
methods, and must always implement the following methods:
getRoleType
getRoleActivityTypeOptionsType
getRoleActivityTypeObjectClassUri
getRoleActivityTypeLiteralOptions
*
*/
public class AddTeacherRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator { public class AddTeacherRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
private Log log = LogFactory.getLog(AddTeacherRoleToPersonGenerator.class);
private static String template = "addTeacherRoleToPerson.ftl"; private static String template = "addTeacherRoleToPerson.ftl";
//Should this be overridden
@Override @Override
protected void setTemplate(EditConfigurationVTwo editConfiguration, String getTemplate() {
VitroRequest vreq) { return template;
editConfiguration.setTemplate(template);
} }
//The default activityToRolePredicate and roleToActivityPredicates are
//correct for this subclass so they don't need to be overwritten
//role type will always be set based on particular form @Override
public String getRoleType(VitroRequest vreq) { String getRoleType() {
//TODO: Get dynamic way of including vivoweb ontology
return "http://vivoweb.org/ontology/core#TeacherRole"; return "http://vivoweb.org/ontology/core#TeacherRole";
} }
//Each subclass generator will return its own type of option here: @Override
//whether literal hardcoded, based on class group, or subclasses of a specific class RoleActivityOptionTypes getRoleActivityTypeOptionsType() {
//The latter two will apparently lend some kind of uri to objectClassUri ?
public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) {
return RoleActivityOptionTypes.HARDCODED_LITERALS; return RoleActivityOptionTypes.HARDCODED_LITERALS;
} }
//This too will depend on the specific subclass of generator @Override
public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { String getRoleActivityTypeObjectClassUri(VitroRequest vreq) {
return null; return null;
} }
//Teacher role involves hard-coded options for the "right side" of the role or activity //Teacher role involves hard-coded options for the "right side" of the role or activity
protected HashMap<String, String> getRoleActivityTypeLiteralOptions(VitroRequest vreq) { @Override
HashMap<String, String> getRoleActivityTypeLiteralOptions() {
HashMap<String, String> literalOptions = new HashMap<String, String>(); HashMap<String, String> literalOptions = new HashMap<String, String>();
literalOptions.put("", "Select one"); literalOptions.put("", "Select one");
literalOptions.put("http://purl.org/ontology/bibo/Conference", "Conference"); literalOptions.put("http://purl.org/ontology/bibo/Conference", "Conference");
@ -118,7 +42,7 @@ public class AddTeacherRoleToPersonGenerator extends AddRoleToPersonTwoStageGene
return literalOptions; return literalOptions;
} }
//isShowRoleLabelField remains true for this so doesn't need to be overwritten @Override
boolean isShowRoleLabelField() { return false; }
} }

View file

@ -168,17 +168,12 @@ public class NewIndividualFormGenerator implements EditConfigurationGenerator {
editConfiguration.setPredicateUri(predicateUri); editConfiguration.setPredicateUri(predicateUri);
//not concerned about remainder, can move into default obj prop form if required //not concerned about remainder, can move into default obj prop form if required
this.isObjectPropForm = true; this.isObjectPropForm = true;
this.initObjectParameters(vreq); objectUri = EditConfigurationUtils.getObjectUri(vreq);
this.processObjectPropForm(vreq, editConfiguration); this.processObjectPropForm(vreq, editConfiguration);
} }
private void initObjectParameters(VitroRequest vreq) {
//in case of object property
objectUri = EditConfigurationUtils.getObjectUri(vreq);
}
private void processObjectPropForm(VitroRequest vreq, EditConfigurationVTwo editConfiguration) { private void processObjectPropForm(VitroRequest vreq, EditConfigurationVTwo editConfiguration) {
editConfiguration.setVarNameForObject("objectNotUsed"); editConfiguration.setVarNameForObject("objectNotUsed");
editConfiguration.setObject(objectUri); editConfiguration.setObject(objectUri);