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";
//Should this be overridden @Override
@Override String getTemplate(){ return TEMPLATE; }
protected void setTemplate(EditConfigurationVTwo editConfiguration,
VitroRequest vreq) {
editConfiguration.setTemplate(template);
}
@Override
String getRoleType() {
return "http://vivoweb.org/ontology/core#AttendeeRole";
}
//The default activityToRolePredicate and roleToActivityPredicates are @Override
//correct for this subclass so they don't need to be overwritten public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) {
//no ClassURI since it uses hard coded literals
return null;
}
//role type will always be set based on particular form @Override
public String getRoleType(VitroRequest vreq) { public RoleActivityOptionTypes getRoleActivityTypeOptionsType() {
//TODO: Get dynamic way of including vivoweb ontology return RoleActivityOptionTypes.HARDCODED_LITERALS;
return "http://vivoweb.org/ontology/core#AttendeeRole"; }
}
//Each subclass generator will return its own type of option here: //Editor role involves hard-coded options for the "right side" of the role or activity
//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 ? protected HashMap<String, String> getRoleActivityTypeLiteralOptions() {
public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) { HashMap<String, String> literalOptions = new HashMap<String, String>();
return RoleActivityOptionTypes.HARDCODED_LITERALS; literalOptions.put("", "Select type");
}
//This too will depend on the specific subclass of generator
public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) {
return null;
}
//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);
} }
@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#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 @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");
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);
} }
@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#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 @Override
//correct for this subclass so they don't need to be overwritten String getRoleType() {
//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#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:
?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 { 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,52 +2,36 @@
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.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.vivoweb.webapp.util.ModelUtils; import org.vivoweb.webapp.util.ModelUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
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.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.vocabulary.RDF; import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.vocabulary.XSD; 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.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.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
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.edit.n3editing.VTwo.EditConfigurationVTwo; 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.configuration.preprocessors.RoleToActivityPredicatePreprocessor;
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.edit.n3editing.VTwo.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.RoleToActivityPredicatePreprocessor;
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.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.utils.generators.AddRoleUtils; import edu.cornell.mannlib.vitro.webapp.utils.generators.AddRoleUtils;
/** /**
@ -68,6 +52,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.generators.AddRoleUtils;
?someActivity rdfs:label "activity title" . ?someActivity rdfs:label "activity title" .
Important: This form cannot be directly used as a custom form. It has parameters that must be set. Important: This form cannot be directly used as a custom form. It has parameters that must be set.
See addClinicalRoleToPerson.jsp for an example. See addClinicalRoleToPerson.jsp for an example.
@ -75,73 +60,108 @@ import edu.cornell.mannlib.vitro.webapp.utils.generators.AddRoleUtils;
the activity itself. For a new statement, the predicate type is not known. the activity itself. For a new statement, the predicate type is not known.
For an existing statement, the predicate is known but may change based on the type of the activity newly selected. For an existing statement, the predicate is known but may change based on the type of the activity newly selected.
bdc34:
TODO: figure out what needs to be customized per role form, document it here in comments
TODO: rewrite class as an abstract class with simple, documented, required methods to override
AddRoleToPersonTwoStageGenerator is abstract, each subclass will need to configure:
From the old JSP version:
showRoleLabelField boolean
roleType URI
roleToActivityPredicate URI
activityToRolePredicate URI
roleActivityType_optionsType
roleActivityType_objectClassURI
roleActivityType_literalOptions
For the new generator version:
template
* *
*/ */
public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurationGenerator { public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator {
private Log log = LogFactory.getLog(AddRoleToPersonTwoStageGenerator.class); private Log log = LogFactory.getLog(AddRoleToPersonTwoStageGenerator.class);
private boolean isObjectPropForm = false;
private String subjectUri = null;
private String predicateUri = null;
private String objectUri = null;
private String datapropKeyStr= null;
private int dataHash = 0;
private DataPropertyStatement dps = null;
private String dataLiteral = null;
private String template = "addRoleToPersonTwoStage.ftl";
private static HashMap<String,String> defaultsForXSDtypes ;
//Types of options to populate drop-down for types for the "right side" of the role /* ***** Methods that are REQUIRED to be implemented in subclasses ***** */
public static enum RoleActivityOptionTypes {
VCLASSGROUP, /** Freemarker template to use */
CHILD_VCLASSES, abstract String getTemplate();
HARDCODED_LITERALS
}; /** URI of type for the role context node */
abstract String getRoleType();
/** In the case of literal options, subclass generator will set the options to be returned */
abstract HashMap<String, String> getRoleActivityTypeLiteralOptions();
/**
* Each subclass generator will return its own type of option here:
* 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 ? */
abstract RoleActivityOptionTypes getRoleActivityTypeOptionsType();
/** The URI of a Class to use with options if required. An option type like
* CHILD_VCLASSES would reqire a role activity object class URI. */
abstract String getRoleActivityTypeObjectClassUri(VitroRequest vreq);
/** If true an input should be shown on the form for a
* label for the role context node
* TODO: move this to the FTL and have label optional. */
abstract boolean isShowRoleLabelField();
/** URI of predicate between role context node and activity */
//Bdc34: not used anywhere? that's odd
// abstract String getActivityToRolePredicate();
@Override @Override
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) { public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo(); EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo();
initProcessParameters(vreq, session, editConfiguration);
//process subject, predicate, object parameters editConfiguration.setVarNameForSubject("person");
this.initProcessParameters(vreq, session, editConfiguration); editConfiguration.setVarNameForPredicate("rolePredicate");
editConfiguration.setVarNameForObject("role");
//Assumes this is a simple case of subject predicate var // Required N3
editConfiguration.setN3Required(this.generateN3Required(vreq)); editConfiguration.setN3Required(list(
N3_PREFIX + "\n" +
"?person ?rolePredicate ?role .\n" +
"?role a ?roleType .\n"+
"?role " + getRoleToActivityPlaceholder() + " ?roleActivity .\n"+
"?roleActivity " + getActivityToRolePlaceholder() + " ?role ."
));
//n3 optional // Optional N3
editConfiguration.setN3Optional(this.generateN3Optional()); editConfiguration.setN3Optional( list(
"?role ?inverseRolePredicate ?person .",
getN3ForActivityLabel(),
getN3ForActivityType(),
getN3RoleLabelAssertion(),
getN3ForStart(),
getN3ForEnd() ));
editConfiguration.setNewResources( newResources(vreq) );
//Todo: what do new resources depend on here?
//In original form, these variables start off empty
editConfiguration.setNewResources(generateNewResources(vreq));
//In scope //In scope
this.setUrisAndLiteralsInScope(editConfiguration, vreq); setUrisAndLiteralsInScope(editConfiguration, vreq);
//on Form //on Form
this.setUrisAndLiteralsOnForm(editConfiguration, vreq); setUrisAndLiteralsOnForm(editConfiguration, vreq);
editConfiguration.setFilesOnForm(new ArrayList<String>());
//Sparql queries //Sparql queries
this.setSparqlQueries(editConfiguration, vreq); setSparqlQueries(editConfiguration, vreq);
//set fields //set fields
setFields(editConfiguration, vreq, EditConfigurationUtils.getPredicateUri(vreq)); setFields(editConfiguration, vreq, EditConfigurationUtils.getPredicateUri(vreq));
// No need to put in session here b/c put in session within edit request dispatch controller instead
//placing in session depends on having edit key which is handled in edit request dispatch controller
// editConfiguration.putConfigInSession(editConfiguration, session);
prepareForUpdate(vreq, session, editConfiguration);
//Form title and submit label now moved to edit configuration template //Form title and submit label now moved to edit configuration template
//TODO: check if edit configuration template correct place to set those or whether //TODO: check if edit configuration template correct place to set those or whether
//additional methods here should be used and reference instead, e.g. edit configuration template could call //additional methods here should be used and reference instead, e.g. edit configuration template could call
//default obj property form.populateTemplate or some such method //default obj property form.populateTemplate or some such method
//Select from existing also set within template itself //Select from existing also set within template itself
setTemplate(editConfiguration, vreq); editConfiguration.setTemplate(getTemplate());
//Set edit key
setEditKey(editConfiguration, vreq);
//Add validator //Add validator
editConfiguration.addValidator(new DateTimeIntervalValidationVTwo("startField","endField") ); editConfiguration.addValidator(new DateTimeIntervalValidationVTwo("startField","endField") );
//Add preprocessors //Add preprocessors
@ -151,176 +171,74 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
return editConfiguration; return editConfiguration;
} }
private void setEditKey(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
String editKey = EditConfigurationUtils.getEditKey(vreq);
editConfiguration.setEditKey(editKey);
}
protected void setTemplate(EditConfigurationVTwo editConfiguration,
VitroRequest vreq) {
editConfiguration.setTemplate(template);
}
//Initialize setup: process parameters
//There will be specialized parameters as well, we may include them here or in a
//separate method
private void initProcessParameters(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) { private void initProcessParameters(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
String formUrl = EditConfigurationUtils.getFormUrl(vreq); editConfiguration.setFormUrl(EditConfigurationUtils.getFormUrl(vreq));
editConfiguration.setEntityToReturnTo(EditConfigurationUtils.getSubjectUri(vreq));
subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
editConfiguration.setFormUrl(formUrl);
editConfiguration.setUrlPatternToReturnTo("/individual");
editConfiguration.setVarNameForSubject("person");
editConfiguration.setSubjectUri(subjectUri);
editConfiguration.setEntityToReturnTo(subjectUri);
editConfiguration.setVarNameForPredicate("rolePredicate");
editConfiguration.setPredicateUri(predicateUri);
//by definition, this is an object property
this.initObjectParameters(vreq);
this.processObjectPropForm(vreq, editConfiguration);
} }
/* N3 Required and Optional Generators as well as supporting methods */
private String getN3ForActivityLabel() {
private void initObjectParameters(VitroRequest vreq) {
//in case of object property
objectUri = EditConfigurationUtils.getObjectUri(vreq);
}
private void processObjectPropForm(VitroRequest vreq, EditConfigurationVTwo editConfiguration) {
editConfiguration.setVarNameForObject("role");
editConfiguration.setObject(objectUri);
//this needs to be set for the editing to be triggered properly, otherwise the 'prepare' method
//pretends this is a data property editing statement and throws an error
//TODO: Check if null in case no object uri exists but this is still an object property
}
/*
* N3 Required and Optional Generators as well as supporting methods
*/
private String getPrefixesString() {
//TODO: Include dynamic way of including this
return "@prefix core: <http://vivoweb.org/ontology/core#> .";
}
//TODO: Check if single string or multiple strings - check rdfslabel form etc. for prefix
//processing
private List<String> generateN3Required(VitroRequest vreq) {
List<String> n3ForEdit = new ArrayList<String>();
String editString = getPrefixesString();
editString += "?person ?rolePredicate ?role .";
editString += "?role a <" + getRoleType(vreq) + "> .";
editString += "?role " + getRoleToActivityPredicate(vreq) + " ?roleActivity .";
editString += "?roleActivity " + getActivityToRolePredicate(vreq) + " ?role .";
n3ForEdit.add(editString);
return n3ForEdit;
}
private List<String> generateN3Optional() {
List<String> n3Optional = new ArrayList<String>();
//n3 for activity label
n3Optional.add(getN3ForActivityLabel());
//n3 for activity type
n3Optional.add(getN3ForActivityType());
//n3 for inverse
n3Optional.add("?role ?inverseRolePredicate ?person .");
//N3ForStart
n3Optional.addAll(getN3ForStart());
//N3 For End
n3Optional.addAll(getN3ForEnd());
//role label assertion
n3Optional.add(getN3RoleLabelAssertion());
return n3Optional;
}
public String getN3ForActivityLabel() {
return "?roleActivity <" + RDFS.label.getURI() + "> ?activityLabel ."; return "?roleActivity <" + RDFS.label.getURI() + "> ?activityLabel .";
} }
public String getN3ForActivityType() { private String getN3ForActivityType() {
return "?roleActivity a ?roleActivityType ."; return "?roleActivity a ?roleActivityType .";
} }
public String getN3RoleLabelAssertion() { private String getN3RoleLabelAssertion() {
return "?role <" + RDFS.label.getURI() + "> ?roleLabel ."; return "?role <" + RDFS.label.getURI() + "> ?roleLabel .";
} }
//Method b/c used in two locations, n3 optional and n3 assertions //Method b/c used in two locations, n3 optional and n3 assertions
private List<String> getN3ForStart() { private List<String> getN3ForStart() {
List<String> n3ForStart = new ArrayList<String>(); List<String> n3ForStart = new ArrayList<String>();
n3ForStart.add("?role <" + getRoleToIntervalURI() + "> ?intervalNode ." + n3ForStart.add("?role <" + RoleToIntervalURI + "> ?intervalNode ." +
"?intervalNode <" + RDF.type.getURI() + "> <" + getIntervalTypeURI() + "> ." + "?intervalNode <" + RDF.type.getURI() + "> <" + IntervalTypeURI + "> ." +
"?intervalNode <" + getIntervalToStartURI() + "> ?startNode ." + "?intervalNode <" + IntervalToStartURI + "> ?startNode ." +
"?startNode <" + RDF.type.getURI() + "> <" + getDateTimeValueTypeURI() + "> ." + "?startNode <" + RDF.type.getURI() + "> <" + DateTimeValueTypeURI + "> ." +
"?startNode <" + getDateTimeValueURI() + "> ?startField-value ." + "?startNode <" + DateTimeValueURI + "> ?startField-value ." +
"?startNode <" + getDateTimePrecisionURI() + "> ?startField-precision ."); "?startNode <" + DateTimePrecisionURI + "> ?startField-precision .");
return n3ForStart; return n3ForStart;
} }
private List<String> getN3ForEnd() { private List<String> getN3ForEnd() {
List<String> n3ForEnd = new ArrayList<String>(); List<String> n3ForEnd = new ArrayList<String>();
n3ForEnd.add("?role <" + getRoleToIntervalURI() + "> ?intervalNode . " + n3ForEnd.add("?role <" + RoleToIntervalURI + "> ?intervalNode . " +
"?intervalNode <" + RDF.type.getURI() + "> <" + getIntervalTypeURI() + "> ." + "?intervalNode <" + RDF.type.getURI() + "> <" + IntervalTypeURI + "> ." +
"?intervalNode <" + getIntervalToEndURI() + "> ?endNode ." + "?intervalNode <" + IntervalToEndURI + "> ?endNode ." +
"?endNode <" + RDF.type.getURI() + "> <" + getDateTimeValueTypeURI() + "> ." + "?endNode <" + RDF.type.getURI() + "> <" + DateTimeValueTypeURI + "> ." +
"?endNode <" + getDateTimeValueURI() + "> ?endField-value ." + "?endNode <" + DateTimeValueURI + "> ?endField-value ." +
"?endNode <" + getDateTimePrecisionURI() + "> ?endField-precision ."); "?endNode <" + DateTimePrecisionURI+ "> ?endField-precision .");
return n3ForEnd; return n3ForEnd;
} }
/** Get new resources */
private Map<String, String> newResources(VitroRequest vreq) {
String DEFAULT_NS_TOKEN=null; //null forces the default NS
/*
* Get new resources
*/
private Map<String, String> generateNewResources(VitroRequest vreq) {
HashMap<String, String> newResources = new HashMap<String, String>(); HashMap<String, String> newResources = new HashMap<String, String>();
//TODO: Get default namespace newResources.put("role", DEFAULT_NS_TOKEN);
String defaultNamespace = vreq.getWebappDaoFactory().getDefaultNamespace(); newResources.put("roleActivity", DEFAULT_NS_TOKEN);
newResources.put("role", defaultNamespace + "individual"); newResources.put("intervalNode", DEFAULT_NS_TOKEN);
newResources.put("roleActivity", defaultNamespace + "individual"); newResources.put("startNode", DEFAULT_NS_TOKEN);
newResources.put("intervalNode", defaultNamespace + "individual"); newResources.put("endNode", DEFAULT_NS_TOKEN);
newResources.put("startNode", defaultNamespace + "individual");
newResources.put("endNode", defaultNamespace + "individual");
return newResources; return newResources;
} }
/** Set URIS and Literals In Scope and on form and supporting methods */
/*
* Set URIS and Literals In Scope and on form and supporting methods
*/
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>(); HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
//note that at this point the subject, predicate, and object var parameters have already been processed
//these two were always set when instantiating an edit configuration object from json,
//although the json itself did not specify subject/predicate as part of uris in scope
urisInScope.put(editConfiguration.getVarNameForSubject(),
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
urisInScope.put(editConfiguration.getVarNameForPredicate(),
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
//Setting inverse role predicate //Setting inverse role predicate
urisInScope.put("inverseRolePredicate", getInversePredicate(vreq)); urisInScope.put("inverseRolePredicate", getInversePredicate(vreq));
urisInScope.put("roleType", list( getRoleType() ) );
editConfiguration.setUrisInScope(urisInScope);
//Uris in scope include subject, predicate, and object var //Uris in scope include subject, predicate, and object var
editConfiguration.setUrisInScope(urisInScope);
//literals in scope empty initially, usually populated by code in prepare for update //literals in scope empty initially, usually populated by code in prepare for update
//with existing values for variables //with existing values for variables
editConfiguration.setLiteralsInScope(new HashMap<String, List<Literal>>());
} }
private List<String> getInversePredicate(VitroRequest vreq) { private List<String> getInversePredicate(VitroRequest vreq) {
@ -332,12 +250,8 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
return inversePredicateArray; return inversePredicateArray;
} }
//n3 should look as follows
//?subject ?predicate ?objectVar
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
List<String> urisOnForm = new ArrayList<String>(); List<String> urisOnForm = new ArrayList<String>();
List<String> literalsOnForm = new ArrayList<String>();
//add role activity and roleActivityType to uris on form //add role activity and roleActivityType to uris on form
urisOnForm.add("roleActivity"); urisOnForm.add("roleActivity");
urisOnForm.add("roleActivityType"); urisOnForm.add("roleActivityType");
@ -346,119 +260,109 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
urisOnForm.add("roleToActivityPredicate"); urisOnForm.add("roleToActivityPredicate");
urisOnForm.add("activityToRolePredicate"); urisOnForm.add("activityToRolePredicate");
editConfiguration.setUrisOnform(urisOnForm); editConfiguration.setUrisOnform(urisOnForm);
//activity label and role label are literals on form //activity label and role label are literals on form
List<String> literalsOnForm = new ArrayList<String>();
literalsOnForm.add("activityLabel"); literalsOnForm.add("activityLabel");
literalsOnForm.add("roleLabel"); literalsOnForm.add("roleLabel");
editConfiguration.setLiteralsOnForm(literalsOnForm); editConfiguration.setLiteralsOnForm(literalsOnForm);
} }
/** Set SPARQL Queries and supporting methods. */
/**
* Set SPARQL Queries and supporting methods
*/
private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
//Sparql queries defining retrieval of literals etc. //Queries for activity label, role label, start Field value, end Field value
editConfiguration.setSparqlForAdditionalLiteralsInScope(new HashMap<String, String>()); HashMap<String, String> map = new HashMap<String, String>();
map.put("activityLabel", getActivityLabelQuery(vreq));
map.put("roleLabel", getRoleLabelQuery(vreq));
map.put("startField-value", getExistingStartDateQuery(vreq));
map.put("endField-value", getExistingEndDateQuery(vreq));
Map<String, String> urisInScope = new HashMap<String, String>(); editConfiguration.setSparqlForExistingLiterals(map);
editConfiguration.setSparqlForAdditionalUrisInScope(urisInScope);
editConfiguration.setSparqlForExistingLiterals(generateSparqlForExistingLiterals(vreq)); //Queries for role activity, activity type query, interval node,
editConfiguration.setSparqlForExistingUris(generateSparqlForExistingUris(vreq)); // start node, end node, start field precision, endfield precision
} map = new HashMap<String, String>();
map.put("roleActivity", getRoleActivityQuery(vreq));
map.put("roleActivityType", getActivityTypeQuery(vreq));
map.put("intervalNode", getIntervalNodeQuery(vreq));
map.put("startNode", getStartNodeQuery(vreq));
map.put("endNode", getEndNodeQuery(vreq));
map.put("startField-precision", getStartPrecisionQuery(vreq));
map.put("endField-precision", getEndPrecisionQuery(vreq));
//Also need sparql queries for roleToActivityPredicate and activityToRolePredicate
map.put("roleToActivityPredicate", getRoleToActivityPredicateQuery(vreq));
map.put("activityToRolePredicate", getActivityToRolePredicateQuery(vreq));
editConfiguration.setSparqlForExistingUris(map);
//Get page uri for object
private HashMap<String, String> generateSparqlForExistingUris(VitroRequest vreq) {
HashMap<String, String> map = new HashMap<String, String>();
//Queries for role activity, activity type query, interval node, start node, end node, start field precision, endfield precision
map.put("roleActivity", getRoleActivityQuery(vreq));
map.put("roleActivityType", getActivityTypeQuery(vreq));
map.put("intervalNode", getIntervalNodeQuery(vreq));
map.put("startNode", getStartNodeQuery(vreq));
map.put("endNode", getEndNodeQuery(vreq));
map.put("startField-precision", getStartPrecisionQuery(vreq));
map.put("endField-precision", getEndPrecisionQuery(vreq));
//Also need sparql queries for roleToActivityPredicate and activityToRolePredicate
map.put("roleToActivityPredicate", getRoleToActivityPredicateQuery(vreq));
map.put("activityToRolePredicate", getActivityToRolePredicateQuery(vreq));
return map;
} }
private String getActivityToRolePredicateQuery(VitroRequest vreq) { private String getActivityToRolePredicateQuery(VitroRequest vreq) {
String query = "SELECT ?existingActivityToRolePredicate \n " + String query = "SELECT ?existingActivityToRolePredicate \n " +
"WHERE { \n" + "WHERE { \n" +
"?roleActivity ?existingActivityToRolePredicate ?role ."; "?roleActivity ?existingActivityToRolePredicate ?role .\n";
//Get possible predicates //Get possible predicates
List<String> addToQuery = new ArrayList<String>(); List<String> addToQuery = new ArrayList<String>();
List<String> predicates = getPossibleActivityToRolePredicates(); List<String> predicates = getPossibleActivityToRolePredicates();
for(String p:predicates) { for(String p:predicates) {
addToQuery.add("(?existingActivityToRolePredicate=<" + p + ">)"); addToQuery.add("(?existingActivityToRolePredicate=<" + p + ">)");
} }
query += "FILTER (" + StringUtils.join(addToQuery, " || ") + ")"; query += "FILTER (" + StringUtils.join(addToQuery, " || ") + ")\n";
query += "}"; query += "}";
return query; return query;
} }
private String getRoleToActivityPredicateQuery(VitroRequest vreq) { private String getRoleToActivityPredicateQuery(VitroRequest vreq) {
String query = "SELECT ?existingRoleToActivityPredicate \n " + String query = "SELECT ?existingRoleToActivityPredicate \n " +
"WHERE { \n" + "WHERE { \n" +
"?role ?existingRoleToActivityPredicate ?roleActivity ."; "?role ?existingRoleToActivityPredicate ?roleActivity .\n";
//Get possible predicates //Get possible predicates
query += getFilterRoleToActivityPredicate("existingRoleToActivityPredicate"); query += getFilterRoleToActivityPredicate("existingRoleToActivityPredicate");
query += "}"; query += "\n}";
return query; return query;
} }
private String getEndPrecisionQuery(VitroRequest vreq) { private String getEndPrecisionQuery(VitroRequest vreq) {
String query = "SELECT ?existingEndPrecision WHERE {" + String query = "SELECT ?existingEndPrecision WHERE {\n" +
"?role <" + getRoleToIntervalURI() + "> ?intervalNode ." + "?role <" + RoleToIntervalURI + "> ?intervalNode .\n" +
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> ." + "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n" +
"?intervalNode <" + getIntervalToEndURI() + "> ?endNode ." + "?intervalNode <" + IntervalToEndURI + "> ?endNode .\n" +
"?endNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> . " + "?endNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> . \n" +
"?endNode <" + getDateTimePrecisionURI() + "> ?existingEndPrecision . }"; "?endNode <" + DateTimePrecisionURI + "> ?existingEndPrecision . }";
return query; return query;
} }
private String getStartPrecisionQuery(VitroRequest vreq) { private String getStartPrecisionQuery(VitroRequest vreq) {
String query = "SELECT ?existingStartPrecision WHERE {" + String query = "SELECT ?existingStartPrecision WHERE {\n" +
"?role <" + getRoleToIntervalURI() + "> ?intervalNode ." + "?role <" + RoleToIntervalURI + "> ?intervalNode .\n" +
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> ." + "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n" +
"?intervalNode <" + getIntervalToStartURI() + "> ?startNode ." + "?intervalNode <" + IntervalToStartURI + "> ?startNode .\n" +
"?startNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> . " + "?startNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> . \n" +
"?startNode <" + getDateTimePrecisionURI() + "> ?existingStartPrecision . }"; "?startNode <" + DateTimePrecisionURI + "> ?existingStartPrecision . }";
return query; return query;
} }
private String getEndNodeQuery(VitroRequest vreq) { private String getEndNodeQuery(VitroRequest vreq) {
String query = "SELECT ?existingEndNode WHERE {"+ String query = "SELECT ?existingEndNode WHERE {\n"+
"?role <" + getRoleToIntervalURI() + "> ?intervalNode ."+ "?role <" + RoleToIntervalURI + "> ?intervalNode .\n"+
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> ."+ "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n"+
" ?intervalNode <" + getIntervalToEndURI() + "> ?existingEndNode . "+ "?intervalNode <" + IntervalToEndURI + "> ?existingEndNode . \n"+
"?existingEndNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> .}"; "?existingEndNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> .}\n";
return query; return query;
} }
private String getStartNodeQuery(VitroRequest vreq) { private String getStartNodeQuery(VitroRequest vreq) {
String query = "SELECT ?existingStartNode WHERE {"+ String query = "SELECT ?existingStartNode WHERE {\n"+
"?role <" + getRoleToIntervalURI() + "> ?intervalNode ."+ "?role <" + RoleToIntervalURI + "> ?intervalNode .\n"+
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> ."+ "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n"+
"?intervalNode <" + getIntervalToStartURI() + "> ?existingStartNode . "+ "?intervalNode <" + IntervalToStartURI + "> ?existingStartNode . \n"+
"?existingStartNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> .}"; "?existingStartNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> .}";
return query; return query;
} }
private String getIntervalNodeQuery(VitroRequest vreq) { private String getIntervalNodeQuery(VitroRequest vreq) {
String query = "SELECT ?existingIntervalNode WHERE { " + String query = "SELECT ?existingIntervalNode WHERE { \n" +
"?role <" + getRoleToIntervalURI() + "> ?existingIntervalNode . " + "?role <" + RoleToIntervalURI + "> ?existingIntervalNode . \n" +
" ?existingIntervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> . }"; " ?existingIntervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> . }\n";
return query; return query;
} }
@ -479,7 +383,7 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
//roleActivityType_optionsType: This gets you whether this is a literal //roleActivityType_optionsType: This gets you whether this is a literal
// //
RoleActivityOptionTypes optionsType = getRoleActivityTypeOptionsType(vreq); RoleActivityOptionTypes optionsType = getRoleActivityTypeOptionsType();
// Note that this value is overloaded to specify either object class uri or classgroup uri // Note that this value is overloaded to specify either object class uri or classgroup uri
String objectClassUri = getRoleActivityTypeObjectClassUri(vreq); String objectClassUri = getRoleActivityTypeObjectClassUri(vreq);
@ -503,7 +407,7 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
} else if (RoleActivityOptionTypes.HARDCODED_LITERALS.equals(optionsType)) { } else if (RoleActivityOptionTypes.HARDCODED_LITERALS.equals(optionsType)) {
//literal options //literal options
HashMap<String, String> typeLiteralOptions = getRoleActivityTypeLiteralOptions(vreq); HashMap<String, String> typeLiteralOptions = getRoleActivityTypeLiteralOptions();
if (typeLiteralOptions.size() > 0) { if (typeLiteralOptions.size() > 0) {
try { try {
List<String> typeUris = new ArrayList<String>(); List<String> typeUris = new ArrayList<String>();
@ -542,7 +446,7 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
private String getDefaultActivityTypeQuery(VitroRequest vreq) { private String getDefaultActivityTypeQuery(VitroRequest vreq) {
String query = "PREFIX core: <" + getVivoCoreNamespace() + ">\n" + String query = "PREFIX core: <" + VIVO_NS + ">\n" +
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" + "PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
"SELECT ?existingActivityType WHERE { \n" + "SELECT ?existingActivityType WHERE { \n" +
" ?role ?predicate ?existingActivity . \n" + " ?role ?predicate ?existingActivity . \n" +
@ -553,7 +457,7 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
} }
private String getSubclassActivityTypeQuery(VitroRequest vreq) { private String getSubclassActivityTypeQuery(VitroRequest vreq) {
String query = "PREFIX core: <" + getVivoCoreNamespace() + ">\n" + String query = "PREFIX core: <" + VIVO_NS + ">\n" +
"PREFIX rdfs: <" + VitroVocabulary.RDFS + ">\n" + "PREFIX rdfs: <" + VitroVocabulary.RDFS + ">\n" +
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" + "PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
"SELECT ?existingActivityType WHERE {\n" + "SELECT ?existingActivityType WHERE {\n" +
@ -566,7 +470,7 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
} }
private String getClassgroupActivityTypeQuery(VitroRequest vreq) { private String getClassgroupActivityTypeQuery(VitroRequest vreq) {
String query = "PREFIX core: <" + getVivoCoreNamespace() + ">\n" + String query = "PREFIX core: <" + VIVO_NS + ">\n" +
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" + "PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
"SELECT ?existingActivityType WHERE { \n" + "SELECT ?existingActivityType WHERE { \n" +
" ?role ?predicate ?existingActivity . \n" + " ?role ?predicate ?existingActivity . \n" +
@ -581,9 +485,8 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
private String getRoleActivityQuery(VitroRequest vreq) { private String getRoleActivityQuery(VitroRequest vreq) {
//If role to activity predicate is the default query, then we need to replace with a union //If role to activity predicate is the default query, then we need to replace with a union
//of both realizedIn and the other //of both realizedIn and the other
String query = "PREFIX core: <" + getVivoCoreNamespace() + ">"; String query = "PREFIX core: <" + VIVO_NS + ">";
String roleToActivityPredicate = getRoleToActivityPredicate(vreq);
//Portion below for multiple possible predicates //Portion below for multiple possible predicates
List<String> predicates = getPossibleRoleToActivityPredicates(); List<String> predicates = getPossibleRoleToActivityPredicates();
List<String> addToQuery = new ArrayList<String>(); List<String> addToQuery = new ArrayList<String>();
@ -594,48 +497,37 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
return query; return query;
} }
private HashMap<String, String> generateSparqlForExistingLiterals(VitroRequest vreq) {
HashMap<String, String> map = new HashMap<String, String>();
//Queries for activity label, role label, start Field value, end Field value
map.put("activityLabel", getActivityLabelQuery(vreq));
map.put("roleLabel", getRoleLabelQuery(vreq));
map.put("startField-value", getExistingStartDateQuery(vreq));
map.put("endField-value", getExistingEndDateQuery(vreq));
return map;
}
private String getExistingEndDateQuery(VitroRequest vreq) { private String getExistingEndDateQuery(VitroRequest vreq) {
String query = " SELECT ?existingEndDate WHERE {\n" + String query = " SELECT ?existingEndDate WHERE {\n" +
"?role <" + getRoleToIntervalURI() + "> ?intervalNode .\n" + "?role <" + RoleToIntervalURI + "> ?intervalNode .\n" +
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> .\n" + "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n" +
"?intervalNode <" + getIntervalToEndURI() + "> ?endNode .\n" + "?intervalNode <" + IntervalToEndURI + "> ?endNode .\n" +
"?endNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> .\n" + "?endNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> .\n" +
"?endNode <" + getDateTimeValueURI() + "> ?existingEndDate . }"; "?endNode <" + DateTimeValueURI + "> ?existingEndDate . }";
return query; return query;
} }
private String getExistingStartDateQuery(VitroRequest vreq) { private String getExistingStartDateQuery(VitroRequest vreq) {
String query = "SELECT ?existingDateStart WHERE {\n" + String query = "SELECT ?existingDateStart WHERE {\n" +
"?role <" + getRoleToIntervalURI() + "> ?intervalNode .\n" + "?role <" + RoleToIntervalURI + "> ?intervalNode .\n" +
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> .\n" + "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n" +
"?intervalNode <" + getIntervalToStartURI() + "> ?startNode .\n" + "?intervalNode <" + IntervalToStartURI+ "> ?startNode .\n" +
"?startNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> .\n" + "?startNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> .\n" +
"?startNode <" + getDateTimeValueURI() + "> ?existingDateStart . }"; "?startNode <" + DateTimeValueURI + "> ?existingDateStart . }";
return query; return query;
} }
private String getRoleLabelQuery(VitroRequest vreq) { private String getRoleLabelQuery(VitroRequest vreq) {
String query = "SELECT ?existingRoleLabel WHERE { ?role <" + VitroVocabulary.LABEL + "> ?existingRoleLabel . }"; String query = "SELECT ?existingRoleLabel WHERE { \n" +
"?role <" + VitroVocabulary.LABEL + "> ?existingRoleLabel . }";
return query; return query;
} }
private String getActivityLabelQuery(VitroRequest vreq) { private String getActivityLabelQuery(VitroRequest vreq) {
String query = "PREFIX core: <" + getVivoCoreNamespace() + ">" + String query = "PREFIX core: <" + VIVO_NS + ">" +
"PREFIX rdfs: <" + RDFS.getURI() + "> \n"; "PREFIX rdfs: <" + RDFS.getURI() + "> \n";
String roleToActivityPredicate = getRoleToActivityPredicate(vreq);
query += "SELECT ?existingTitle WHERE { \n" + query += "SELECT ?existingTitle WHERE { \n" +
"?role ?predicate ?existingActivity . \n" + "?role ?predicate ?existingActivity . \n" +
"?existingActivity rdfs:label ?existingTitle . \n"; "?existingActivity rdfs:label ?existingTitle . \n";
@ -690,14 +582,9 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
field.setRangeDatatypeUri(null); field.setRangeDatatypeUri(null);
field.setLiteralOptions(new ArrayList<List<String>>()); field.setLiteralOptions(new ArrayList<List<String>>());
fields.put(field.getName(), field); fields.put(field.getName(), field);
} }
private void getRoleToActivityPredicateField( private void getRoleToActivityPredicateField(
EditConfigurationVTwo editConfiguration, VitroRequest vreq, EditConfigurationVTwo editConfiguration, VitroRequest vreq,
Map<String, FieldVTwo> fields) { Map<String, FieldVTwo> fields) {
@ -723,13 +610,9 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
field.setLiteralOptions(new ArrayList<List<String>>()); field.setLiteralOptions(new ArrayList<List<String>>());
fields.put(field.getName(), field); fields.put(field.getName(), field);
} }
//Label of "right side" of role, i.e. label for role roleIn Activity //Label of "right side" of role, i.e. label for role roleIn Activity
private void getActivityLabelField(EditConfigurationVTwo editConfiguration, private void getActivityLabelField(EditConfigurationVTwo editConfiguration,
VitroRequest vreq, Map<String, FieldVTwo> fields) { VitroRequest vreq, Map<String, FieldVTwo> fields) {
@ -757,10 +640,8 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
field.setObjectClassUri(null); field.setObjectClassUri(null);
field.setRangeDatatypeUri(stringDatatypeUri); field.setRangeDatatypeUri(stringDatatypeUri);
field.setLiteralOptions(new ArrayList<List<String>>()); field.setLiteralOptions(new ArrayList<List<String>>());
fields.put(field.getName(), field); fields.put(field.getName(), field);
} }
@ -782,14 +663,14 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
//subjectUri and subjectClassUri are not being used in Field //subjectUri and subjectClassUri are not being used in Field
//TODO: Check if this is correct //TODO: Check if this is correct
field.setOptionsType(getRoleActivityTypeOptionsType(vreq).toString()); field.setOptionsType(getRoleActivityTypeOptionsType().toString());
//why isn't predicate uri set for data properties? //why isn't predicate uri set for data properties?
field.setPredicateUri(null); field.setPredicateUri(null);
field.setObjectClassUri(getRoleActivityTypeObjectClassUri(vreq)); field.setObjectClassUri(getRoleActivityTypeObjectClassUri(vreq));
field.setRangeDatatypeUri(null); field.setRangeDatatypeUri(null);
HashMap<String, String> literalOptionsMap = getRoleActivityTypeLiteralOptions(vreq); HashMap<String, String> literalOptionsMap = getRoleActivityTypeLiteralOptions();
List<List<String>> fieldLiteralOptions = new ArrayList<List<String>>(); List<List<String>> fieldLiteralOptions = new ArrayList<List<String>>();
Set<String> optionUris = literalOptionsMap.keySet(); Set<String> optionUris = literalOptionsMap.keySet();
for(String optionUri: optionUris) { for(String optionUri: optionUris) {
@ -827,7 +708,6 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
field.setLiteralOptions(new ArrayList<List<String>>()); field.setLiteralOptions(new ArrayList<List<String>>());
fields.put(field.getName(), field); fields.put(field.getName(), field);
} }
private void getRoleLabelField(EditConfigurationVTwo editConfiguration, private void getRoleLabelField(EditConfigurationVTwo editConfiguration,
@ -840,7 +720,7 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
List<String> validators = new ArrayList<String>(); List<String> validators = new ArrayList<String>();
validators.add("datatype:" + stringDatatypeUri); validators.add("datatype:" + stringDatatypeUri);
if(isShowRoleLabelField(vreq)) { if(isShowRoleLabelField()) {
validators.add("nonempty"); validators.add("nonempty");
} }
field.setValidators(validators); field.setValidators(validators);
@ -856,11 +736,8 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
field.setLiteralOptions(new ArrayList<List<String>>()); field.setLiteralOptions(new ArrayList<List<String>>());
fields.put(field.getName(), field); fields.put(field.getName(), field);
} }
private void getStartField(EditConfigurationVTwo editConfiguration, private void getStartField(EditConfigurationVTwo editConfiguration,
VitroRequest vreq, Map<String, FieldVTwo> fields) { VitroRequest vreq, Map<String, FieldVTwo> fields) {
String fieldName = "startField"; String fieldName = "startField";
@ -888,7 +765,6 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
VitroVocabulary.Precision.NONE.uri())); VitroVocabulary.Precision.NONE.uri()));
fields.put(field.getName(), field); fields.put(field.getName(), field);
} }
private void getEndField(EditConfigurationVTwo editConfiguration, private void getEndField(EditConfigurationVTwo editConfiguration,
@ -918,33 +794,8 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
VitroVocabulary.Precision.NONE.uri())); VitroVocabulary.Precision.NONE.uri()));
fields.put(field.getName(), field); fields.put(field.getName(), field);
} }
/**
* Prepare edit configuration for update
* @param vreq
* @param session
* @param editConfiguration
*/
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
//Here, retrieve model from
Model model = (Model) session.getServletContext().getAttribute("jenaOntModel");
//Object property by definition
String objectUri = EditConfigurationUtils.getObjectUri(vreq);
if(objectUri != null) {
//update existing object
editConfiguration.prepareForObjPropUpdate(model);
} else {
//new object to be created
editConfiguration.prepareForNonUpdate( model );
}
}
//Add preprocessor
private void addPreprocessors(EditConfigurationVTwo editConfiguration, WebappDaoFactory wadf) { private void addPreprocessors(EditConfigurationVTwo editConfiguration, WebappDaoFactory wadf) {
//Add preprocessor that will replace the role to activity predicate and inverse //Add preprocessor that will replace the role to activity predicate and inverse
//with correct properties based on the activity type //with correct properties based on the activity type
@ -953,39 +804,13 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
} }
/**
* Methods that are REQUIRED to be implemented in subclasses
**/
//role type will always be set based on particular form
abstract public String getRoleType(VitroRequest vreq);
//In the case of literal options, subclass generator will set the options to be returned
abstract protected HashMap<String, String> getRoleActivityTypeLiteralOptions(VitroRequest vreq);
//Each subclass generator will return its own type of option here:
//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 ?
abstract public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq);
//This too will depend on the specific subclass of generator
abstract public String getRoleActivityTypeObjectClassUri(VitroRequest vreq);
/**
* Methods with default values that may be overwritten when required by a subclass
* Both Default value and method that can be overwritten are included below
**/
public boolean isShowRoleLabelField(VitroRequest vreq) {
return true;
}
public String getActivityToRolePredicate(VitroRequest vreq) {
return getActivityToRolePlaceholder();
}
//This has a default value, but note that even that will not be used //This has a default value, but note that even that will not be used
//in the update with realized in or contributes to //in the update with realized in or contributes to
//Overridden when need be in subclassed generator //Overridden when need be in subclassed generator
//Also note that for now we're going to actually going to return a //Also note that for now we're going to actually going to return a
//placeholder value by default //placeholder value by default
public String getRoleToActivityPredicate(VitroRequest vreq) { public String getRoleToActivityPredicate(VitroRequest vreq) {
//TODO: <uri> and ?placeholder are incompatible
return getRoleToActivityPlaceholder(); return getRoleToActivityPlaceholder();
} }
//Ensure when overwritten that this includes the <> b/c otherwise the query won't work //Ensure when overwritten that this includes the <> b/c otherwise the query won't work
@ -1000,14 +825,7 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
return ModelUtils.getPossibleInversePropertiesForRole(); return ModelUtils.getPossibleInversePropertiesForRole();
} }
/** /* Methods that check edit mode */
* Methods that check edit mode
*/
/**Methods for checking edit mode **
*
*/
public EditMode getEditMode(VitroRequest vreq) { public EditMode getEditMode(VitroRequest vreq) {
List<String> roleToGrantPredicates = getPossibleRoleToActivityPredicates(); List<String> roleToGrantPredicates = getPossibleRoleToActivityPredicates();
return AddRoleUtils.getEditMode(vreq, roleToGrantPredicates); return AddRoleUtils.getEditMode(vreq, roleToGrantPredicates);
@ -1025,48 +843,18 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
return AddRoleUtils.isRepairMode(getEditMode(vreq)); return AddRoleUtils.isRepairMode(getEditMode(vreq));
} }
/** /* URIS for various predicates */
* Methods to return URIS for various predicates private final String VIVO_NS="http://vivoweb.org/ontology/core#";
**/
public String getVivoCoreNamespace() {
return "http://vivoweb.org/ontology/core#";
}
public String getRoleToIntervalURI() { private final String RoleToIntervalURI = VIVO_NS + "dateTimeInterval";
return getVivoCoreNamespace() + "dateTimeInterval"; private final String IntervalTypeURI = VIVO_NS + "DateTimeInterval";
} private final String IntervalToStartURI = VIVO_NS + "start";
private final String IntervalToEndURI = VIVO_NS + "end";
public String getIntervalTypeURI() { private final String StartYearPredURI = VIVO_NS + "startYear";
return getVivoCoreNamespace() + "DateTimeInterval"; private final String EndYearPredURI = VIVO_NS + "endYear";
} private final String DateTimeValueTypeURI=VIVO_NS + "DateTimeValue";
private final String DateTimePrecisionURI=VIVO_NS + "dateTimePrecision";
public String getIntervalToStartURI() { private final String DateTimeValueURI = VIVO_NS + "dateTime";
return getVivoCoreNamespace() + "start";
}
public String getIntervalToEndURI() {
return getVivoCoreNamespace() + "end";
}
public String getStartYearPredURI() {
return getVivoCoreNamespace() + "startYear";
}
public String getEndYearPredURI() {
return getVivoCoreNamespace() + "endYear";
}
public String getDateTimeValueTypeURI() {
return getVivoCoreNamespace() + "DateTimeValue";
}
public String getDateTimePrecisionURI() {
return getVivoCoreNamespace() + "dateTimePrecision";
}
public String getDateTimeValueURI() {
return getVivoCoreNamespace() + "dateTime";
}
//Form specific data //Form specific data
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
@ -1079,12 +867,11 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
//TODO: Check if this is the proper way to do this? //TODO: Check if this is the proper way to do this?
formSpecificData.put("objectSelect", objectSelect); formSpecificData.put("objectSelect", objectSelect);
//Also put in show role label field //Also put in show role label field
formSpecificData.put("showRoleLabelField", isShowRoleLabelField(vreq)); formSpecificData.put("showRoleLabelField", isShowRoleLabelField());
//Put in the fact that we require field //Put in the fact that we require field
editConfiguration.setFormSpecificData(formSpecificData); editConfiguration.setFormSpecificData(formSpecificData);
} }
public String getFilterRoleToActivityPredicate(String predicateVar) { public String getFilterRoleToActivityPredicate(String predicateVar) {
String addFilter = "FILTER ("; String addFilter = "FILTER (";
List<String> predicates = getPossibleRoleToActivityPredicates(); List<String> predicates = getPossibleRoleToActivityPredicates();
@ -1098,12 +885,20 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
return addFilter; return addFilter;
} }
public String getRoleToActivityPlaceholder() { private String getRoleToActivityPlaceholder() {
return "?roleToActivityPredicate"; return "?roleToActivityPredicate";
} }
public String getActivityToRolePlaceholder() { private String getActivityToRolePlaceholder() {
return "?activityToRolePredicate"; return "?activityToRolePredicate";
} }
//Types of options to populate drop-down for types for the "right side" of the role
public static enum RoleActivityOptionTypes {
VCLASSGROUP,
CHILD_VCLASSES,
HARDCODED_LITERALS
};
private final String N3_PREFIX = "@prefix core: <http://vivoweb.org/ontology/core#> .";
} }

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);
} }
@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#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

@ -169,16 +169,11 @@ public class NewIndividualFormGenerator implements EditConfigurationGenerator {
//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);