From e2e7574e1be10b45c5e0265942d0d0966819ae37 Mon Sep 17 00:00:00 2001 From: tworrall Date: Tue, 1 Nov 2011 19:30:43 +0000 Subject: [PATCH] NIHVIVO-2288: freemarker conversion, templates and generators --- .../edit/forms/addEditorRoleToPerson.ftl | 26 +++ .../edit/forms/addReviewerRoleToPerson.ftl | 26 +++ .../AddEditorRoleToPersonGenerator.java | 131 +++++++++++++++ .../AddHeadOfRoleToPersonGenerator.java | 150 +++++++++++++++++ .../AddMemberRoleToPersonGenerator.java | 122 ++++++++++++++ .../AddOrganizerRoleToPersonGenerator.java | 137 ++++++++++++++++ ...OutreachProviderRoleToPersonGenerator.java | 149 +++++++++++++++++ .../AddPresenterRoleToPersonGenerator.java | 122 ++++++++++++++ .../AddResearcherRoleToPersonGenerator.java | 122 ++++++++++++++ .../AddReviewerRoleToPersonGenerator.java | 131 +++++++++++++++ ...dServiceProviderRoleToPersonGenerator.java | 151 ++++++++++++++++++ .../AddTeacherRoleToPersonGenerator.java | 124 ++++++++++++++ 12 files changed, 1391 insertions(+) create mode 100644 productMods/templates/freemarker/edit/forms/addEditorRoleToPerson.ftl create mode 100644 productMods/templates/freemarker/edit/forms/addReviewerRoleToPerson.ftl create mode 100644 src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddEditorRoleToPersonGenerator.java create mode 100644 src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddHeadOfRoleToPersonGenerator.java create mode 100644 src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddMemberRoleToPersonGenerator.java create mode 100644 src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddOrganizerRoleToPersonGenerator.java create mode 100644 src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddOutreachProviderRoleToPersonGenerator.java create mode 100644 src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddPresenterRoleToPersonGenerator.java create mode 100644 src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddResearcherRoleToPersonGenerator.java create mode 100644 src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddReviewerRoleToPersonGenerator.java create mode 100644 src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddServiceProviderRoleToPersonGenerator.java create mode 100644 src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddTeacherRoleToPersonGenerator.java diff --git a/productMods/templates/freemarker/edit/forms/addEditorRoleToPerson.ftl b/productMods/templates/freemarker/edit/forms/addEditorRoleToPerson.ftl new file mode 100644 index 00000000..c804d752 --- /dev/null +++ b/productMods/templates/freemarker/edit/forms/addEditorRoleToPerson.ftl @@ -0,0 +1,26 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> +<#--Two stage form for service provider role--> + +<#-- +Required Values to be set for each form that includes addRoleToPersonTwoStage.ftl are: +roleDescriptor. +The other required values (roleType, optionsType, objectClassUri, and literalOptions are +set in the JAVA class corresponding to the form, e.g. AddEditorRoleToPersonGenerator.java. + +Optional values can be set, but each of these has default values +set in addRoleToPersonTwoStage.ftl: + +buttonText +typeSelectorLabel +numDateFields +showRoleLAbelField +roleExamples--> + + +<#--Variable assignments for Add Clinical Role To Person--> +<#assign roleDescriptor = "collection or series editor role" /> +<#assign typeSelectorLabel = "editor role in" /> + + +<#--Each of the two stage forms will include the form below--> +<#include "addRoleToPersonTwoStage.ftl"> \ No newline at end of file diff --git a/productMods/templates/freemarker/edit/forms/addReviewerRoleToPerson.ftl b/productMods/templates/freemarker/edit/forms/addReviewerRoleToPerson.ftl new file mode 100644 index 00000000..093227b7 --- /dev/null +++ b/productMods/templates/freemarker/edit/forms/addReviewerRoleToPerson.ftl @@ -0,0 +1,26 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> +<#--Two stage form for service provider role--> + +<#-- +Required Values to be set for each form that includes addRoleToPersonTwoStage.ftl are: +roleDescriptor. +The other required values (roleType, optionsType, objectClassUri, and literalOptions are +set in the JAVA class corresponding to the form, e.g. AddReviewerRoleToPersonGenerator.java. + +Optional values can be set, but each of these has default values +set in addRoleToPersonTwoStage.ftl: + +buttonText +typeSelectorLabel +numDateFields +showRoleLAbelField +roleExamples--> + + +<#--Variable assignments for Add Clinical Role To Person--> +<#assign roleDescriptor = "reviewer of" /> +<#assign typeSelectorLabel = "reviewer of" /> + + +<#--Each of the two stage forms will include the form below--> +<#include "addRoleToPersonTwoStage.ftl"> \ No newline at end of file diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddEditorRoleToPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddEditorRoleToPersonGenerator.java new file mode 100644 index 00000000..59c2c149 --- /dev/null +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddEditorRoleToPersonGenerator.java @@ -0,0 +1,131 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +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.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.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 AddEditorRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator { + + private Log log = LogFactory.getLog(AddEditorRoleToPersonGenerator.class); + private static String template = "addEditorRoleToPerson.ftl"; + + //Should this be overridden + @Override + protected void setTemplate(EditConfigurationVTwo editConfiguration, + VitroRequest vreq) { + editConfiguration.setTemplate(template); + } + + + //The default activityToRolePredicate and roleToActivityPredicates are + //correct for this subclass so they don't need to be overwritten + public String getActivityToRolePredicate(VitroRequest vreq) { + return "http://vivoweb.org/ontology/core#linkedRole"; + } + + public String getRoleToActivityPredicate(VitroRequest vreq) { + return "http://vivoweb.org/ontology/core#forInformationResource"; + } + + //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#EditorRole"; + } + + //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 ? + public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) { + return RoleActivityOptionTypes.CHILD_VCLASSES; + } + + //This too will depend on the specific subclass of generator + public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { + return "http://purl.org/ontology/bibo/Collection"; + } + + + //Editor role involves hard-coded options for the "right side" of the role or activity + protected HashMap getRoleActivityTypeLiteralOptions(VitroRequest vreq) { + HashMap literalOptions = new HashMap(); + literalOptions.put("", "Select type"); + return literalOptions; + } + + //isShowRoleLabelField remains true for this so doesn't need to be overwritten + public boolean isShowRoleLabelField(VitroRequest vreq) { + return false; + } + + +} diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddHeadOfRoleToPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddHeadOfRoleToPersonGenerator.java new file mode 100644 index 00000000..afa6c933 --- /dev/null +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddHeadOfRoleToPersonGenerator.java @@ -0,0 +1,150 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +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.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.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 { + + private Log log = LogFactory.getLog(AddHeadOfRoleToPersonGenerator.class); + private static String template = "addHeadOfRoleToPerson.ftl"; + + //Should this be overridden + @Override + protected void setTemplate(EditConfigurationVTwo editConfiguration, + VitroRequest vreq) { + editConfiguration.setTemplate(template); + } + + + //The default activityToRolePredicate and roleToActivityPredicates are + //correct for this subclass so they don't need to be overwritten + + //role type will always be set based on particular form + public String getRoleType(VitroRequest vreq) { + //TODO: Get dynamic way of including vivoweb ontology + return "http://vivoweb.org/ontology/core#LeaderRole"; + } + + //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 ? + public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) { + return RoleActivityOptionTypes.HARDCODED_LITERALS; + } + + //This too will depend on the specific subclass of generator + public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { + return null; + } + + + //Head Of role involves hard-coded options for the "right side" of the role or activity + protected HashMap getRoleActivityTypeLiteralOptions(VitroRequest vreq) { + HashMapliteralOptions.put( literalOptions = new HashMap(); + literalOptions.put("", "Select type"); + literalOptions.put("http://vivoweb.org/ontology/core#Association", "Association"); + literalOptions.put("http://vivoweb.org/ontology/core#Center", "Center"); + literalOptions.put("http://vivoweb.org/ontology/core#ClinicalOrganization", "Clinical Organization"); + literalOptions.put("http://vivoweb.org/ontology/core#College", "College"); + literalOptions.put("http://vivoweb.org/ontology/core#Committee", "Committee"); + literalOptions.put("http://vivoweb.org/ontology/core#Consortium", "Consortium"); + literalOptions.put("http://vivoweb.org/ontology/core#Department", "Department"); + literalOptions.put("http://vivoweb.org/ontology/core#Division", "Division"); + literalOptions.put("http://purl.org/NET/c4dm/event.owl#Event", "Event"); + literalOptions.put("http://vivoweb.org/ontology/core#ExtensionUnit", "Extension Unit"); + literalOptions.put("http://vivoweb.org/ontology/core#Foundation", "Foundation"); + literalOptions.put("http://vivoweb.org/ontology/core#FundingOrganization", "Funding Organization"); + literalOptions.put("http://vivoweb.org/ontology/core#GovernmentAgency", "Government Agency"); + literalOptions.put("http://vivoweb.org/ontology/core#Hospital", "Hospital"); + literalOptions.put("http://vivoweb.org/ontology/core#Institute", "Institute"); + literalOptions.put("http://vivoweb.org/ontology/core#Laboratory", "Laboratory"); + literalOptions.put("http://vivoweb.org/ontology/core#Library", "Library"); + literalOptions.put("http://vivoweb.org/ontology/core#Museum", "Museum"); + literalOptions.put("http://xmlns.com/foaf/0.1/Organization", "Organization"); + literalOptions.put("http://vivoweb.org/ontology/core#PrivateCompany", "Private Company"); + literalOptions.put("http://vivoweb.org/ontology/core#Program", "Program"); + literalOptions.put("http://vivoweb.org/ontology/core#Project", "Project"); + literalOptions.put("http://vivoweb.org/ontology/core#Publisher", "Publisher"); + literalOptions.put("http://vivoweb.org/ontology/core#ResearchOrganization", "Research Organization"); + literalOptions.put("http://vivoweb.org/ontology/core#School", "School"); + literalOptions.put("http://vivoweb.org/ontology/core#Service","Service"); + literalOptions.put("http://vivoweb.org/ontology/core#Team", "Team"); + literalOptions.put("http://vivoweb.org/ontology/core#StudentOrganization", "Student Organization"); + literalOptions.put("http://vivoweb.org/ontology/core#University", "University"); + return literalOptions; + } + + //isShowRoleLabelField remains true for this so doesn't need to be overwritten + + +} diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddMemberRoleToPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddMemberRoleToPersonGenerator.java new file mode 100644 index 00000000..563530b7 --- /dev/null +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddMemberRoleToPersonGenerator.java @@ -0,0 +1,122 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +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.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.freemarker.responsevalues.ResponseValues; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; +import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;Member +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 { + + private Log log = LogFactory.getLog(AddMemberRoleToPersonGenerator.class); + private static String template = "addMemberRoleToPerson.ftl"; + + //Should this be overridden + @Override + protected void setTemplate(EditConfigurationVTwo editConfiguration, + VitroRequest vreq) { + editConfiguration.setTemplate(template); + } + + + //The default activityToRolePredicate and roleToActivityPredicates are + //correct for this subclass so they don't need to be overwritten + + + //role type will always be set based on particular form + public String getRoleType(VitroRequest vreq) { + //TODO: Get dynamic way of including vivoweb ontology + return "http://vivoweb.org/ontology/core#MemberRole"; + } + + //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 ? + public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) { + return RoleActivityOptionTypes.VCLASSGROUP; + } + + //This too will depend on the specific subclass of generator + public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { + return "http://vivoweb.org/ontology#vitroClassGrouporganizations"; + } + + + //Member role involves hard-coded options for the "right side" of the role or activity + protected HashMap getRoleActivityTypeLiteralOptions(VitroRequest vreq) { + HashMap literalOptions = new HashMap(); + literalOptions.put("", "Select type"); + return literalOptions; + } + + //isShowRoleLabelField remains true for this so doesn't need to be overwritten + + +} diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddOrganizerRoleToPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddOrganizerRoleToPersonGenerator.java new file mode 100644 index 00000000..bdbce378 --- /dev/null +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddOrganizerRoleToPersonGenerator.java @@ -0,0 +1,137 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +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.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.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 { + + private Log log = LogFactory.getLog(AddOrganizerRoleToPersonGenerator.class); + private static String template = "addOrganizerRoleToPerson.ftl"; + + //Should this be overridden + @Override + protected void setTemplate(EditConfigurationVTwo editConfiguration, + VitroRequest vreq) { + editConfiguration.setTemplate(template); + } + + + //The default activityToRolePredicate and roleToActivityPredicates are + //correct for this subclass so they don't need to be overwritten + + //role type will always be set based on particular form + public String getRoleType(VitroRequest vreq) { + //TODO: Get dynamic way of including vivoweb ontology + return "http://vivoweb.org/ontology/core#OrganizerRole"; + } + + //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 ? + public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) { + return RoleActivityOptionTypes.HARDCODED_LITERALS; + } + + //This too will depend on the specific subclass of generator + public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { + return null; + } + + + //Organizer role involves hard-coded options for the "right side" of the role or activity + protected HashMap getRoleActivityTypeLiteralOptions(VitroRequest vreq) { + HashMapliteralOptions.put( literalOptions = new HashMap(); + literalOptions.put("", "Select type"); + literalOptions.put("http://purl.org/NET/c4dm/event.owl#Event", "Event"); + literalOptions.put("http://vivoweb.org/ontology/core#Competition", "Competition"); + literalOptions.put("http://purl.org/ontology/bibo/Conference", "Conference"); + literalOptions.put("http://vivoweb.org/ontology/core#Course", "Course"); + literalOptions.put("http://vivoweb.org/ontology/core#Exhibit", "Exhibit"); + literalOptions.put("http://vivoweb.org/ontology/core#Meeting", "Meeting"); + literalOptions.put("http://vivoweb.org/ontology/core#Presentation", "Presentation"); + literalOptions.put("http://vivoweb.org/ontology/core#InvitedTalk", "Invited Talk"); + literalOptions.put("http://purl.org/ontology/bibo/Workshop", "Workshop"); + literalOptions.put("http://vivoweb.org/ontology/core#EventSeries", "Event 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#WorkshopSeries", "Workshop Series"); + return literalOptions; + } + + //isShowRoleLabelField remains true for this so doesn't need to be overwritten + public boolean isShowRoleLabelField(VitroRequest vreq) { + return false; + } + + +} diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddOutreachProviderRoleToPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddOutreachProviderRoleToPersonGenerator.java new file mode 100644 index 00000000..8055f025 --- /dev/null +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddOutreachProviderRoleToPersonGenerator.java @@ -0,0 +1,149 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +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.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.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 { + + private Log log = LogFactory.getLog(AddOutreachProviderRoleToPersonGenerator.class); + private static String template = "addOutreachProviderRoleToPerson.ftl"; + + //Should this be overridden + @Override + protected void setTemplate(EditConfigurationVTwo editConfiguration, + VitroRequest vreq) { + editConfiguration.setTemplate(template); + } + + + //The default activityToRolePredicate and roleToActivityPredicates are + //correct for this subclass so they don't need to be overwritten + + //role type will always be set based on particular form + public String getRoleType(VitroRequest vreq) { + //TODO: Get dynamic way of including vivoweb ontology + return "http://vivoweb.org/ontology/core#OutreachProviderRole"; + } + + //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 ? + public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) { + return RoleActivityOptionTypes.HARDCODED_LITERALS; + } + + //This too will depend on the specific subclass of generator + public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { + return null; + } + + + //Outreach Provider role involves hard-coded options for the "right side" of the role or activity + protected HashMap getRoleActivityTypeLiteralOptions(VitroRequest vreq) { + HashMapliteralOptions.put( literalOptions = new HashMap(); + literalOptions.put("", "Select type"); + literalOptions.put("http://vivoweb.org/ontology/core#Association", "Association"); + literalOptions.put("http://vivoweb.org/ontology/core#Center", "Center"); + literalOptions.put("http://vivoweb.org/ontology/core#ClinicalOrganization", "Clinical Organization"); + literalOptions.put("http://vivoweb.org/ontology/core#College", "College"); + literalOptions.put("http://vivoweb.org/ontology/core#Committee", "Committee"); + literalOptions.put("http://vivoweb.org/ontology/core#Consortium", "Consortium"); + literalOptions.put("http://vivoweb.org/ontology/core#Department", "Department"); + literalOptions.put("http://vivoweb.org/ontology/core#Division", "Division"); + literalOptions.put("http://purl.org/NET/c4dm/event.owl#Event", "Event"); + literalOptions.put("http://vivoweb.org/ontology/core#ExtensionUnit", "Extension Unit"); + literalOptions.put("http://vivoweb.org/ontology/core#Foundation", "Foundation"); + literalOptions.put("http://vivoweb.org/ontology/core#FundingOrganization", "Funding Organization"); + literalOptions.put("http://vivoweb.org/ontology/core#GovernmentAgency", "Government Agency"); + literalOptions.put("http://vivoweb.org/ontology/core#Hospital", "Hospital"); + literalOptions.put("http://vivoweb.org/ontology/core#Institute", "Institute"); + literalOptions.put("http://vivoweb.org/ontology/core#Laboratory", "Laboratory"); + literalOptions.put("http://vivoweb.org/ontology/core#Library", "Library"); + literalOptions.put("http://vivoweb.org/ontology/core#Museum", "Museum"); + literalOptions.put("http://xmlns.com/foaf/0.1/Organization", "Organization"); + literalOptions.put("http://vivoweb.org/ontology/core#PrivateCompany", "Private Company"); + literalOptions.put("http://vivoweb.org/ontology/core#Program", "Program"); + literalOptions.put("http://vivoweb.org/ontology/core#Project", "Project"); + literalOptions.put("http://vivoweb.org/ontology/core#Publisher", "Publisher"); + literalOptions.put("http://vivoweb.org/ontology/core#ResearchOrganization", "Research Organization"); + literalOptions.put("http://vivoweb.org/ontology/core#Team", "Team"); + literalOptions.put("http://vivoweb.org/ontology/core#School", "School"); + literalOptions.put("http://vivoweb.org/ontology/core#Service","Service"); + literalOptions.put("http://vivoweb.org/ontology/core#StudentOrganization", "Student Organization"); + literalOptions.put("http://vivoweb.org/ontology/core#University", "University"); + return literalOptions; + } + + //isShowRoleLabelField remains true for this so doesn't need to be overwritten + +} diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddPresenterRoleToPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddPresenterRoleToPersonGenerator.java new file mode 100644 index 00000000..71e47c24 --- /dev/null +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddPresenterRoleToPersonGenerator.java @@ -0,0 +1,122 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +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.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.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 { + + private Log log = LogFactory.getLog(AddPresenterRoleToPersonGenerator.class); + private static String template = "addPresenterRoleToPerson.ftl"; + + //Should this be overridden + @Override + protected void setTemplate(EditConfigurationVTwo editConfiguration, + VitroRequest vreq) { + editConfiguration.setTemplate(template); + } + + + //The default activityToRolePredicate and roleToActivityPredicates are + //correct for this subclass so they don't need to be overwritten + + //role type will always be set based on particular form + public String getRoleType(VitroRequest vreq) { + //TODO: Get dynamic way of including vivoweb ontology + return "http://vivoweb.org/ontology/core#PresenterRole"; + } + + //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 ? + public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) { + return RoleActivityOptionTypes.HARDCODED_LITERALS; + } + + //This too will depend on the specific subclass of generator + public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { + return null; + } + + + //Presenter role involves hard-coded options for the "right side" of the role or activity + protected HashMap getRoleActivityTypeLiteralOptions(VitroRequest vreq) { + HashMapliteralOptions.put( literalOptions = new HashMap(); + literalOptions.put("", "Select type"); + literalOptions.put("http://vivoweb.org/ontology/core#Presentation", "Presentation"); + literalOptions.put("http://vivoweb.org/ontology/core#InvitedTalk","Invited Talk"); + return literalOptions; + } + + //isShowRoleLabelField remains true for this so doesn't need to be overwritten + +} diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddResearcherRoleToPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddResearcherRoleToPersonGenerator.java new file mode 100644 index 00000000..e1565c99 --- /dev/null +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddResearcherRoleToPersonGenerator.java @@ -0,0 +1,122 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +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.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.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 { + + private Log log = LogFactory.getLog(AddResearcherRoleToPersonGenerator.class); + private static String template = "addResearcherRoleToPerson.ftl"; + + //Should this be overridden + @Override + protected void setTemplate(EditConfigurationVTwo editConfiguration, + VitroRequest vreq) { + editConfiguration.setTemplate(template); + } + + + //The default activityToRolePredicate and roleToActivityPredicates are + //correct for this subclass so they don't need to be overwritten + + //role type will always be set based on particular form + public String getRoleType(VitroRequest vreq) { + //TODO: Get dynamic way of including vivoweb ontology + return "http://vivoweb.org/ontology/core#ResearcherRole"; + } + + //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 ? + public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) { + return RoleActivityOptionTypes.HARDCODED_LITERALS; + } + + //This too will depend on the specific subclass of generator + public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { + return null; + } + + + //Researcher role involves hard-coded options for the "right side" of the role or activity + protected HashMap getRoleActivityTypeLiteralOptions(VitroRequest vreq) { + HashMapliteralOptions.put( literalOptions = new HashMap(); + literalOptions.put("", "Select one"); + literalOptions.put("http://vivoweb.org/ontology/core#Grant", "Grant"); + literalOptions.put("http://vivoweb.org/ontology/core#Project","Project"); + return literalOptions; + } + + //isShowRoleLabelField remains true for this so doesn't need to be overwritten + +} diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddReviewerRoleToPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddReviewerRoleToPersonGenerator.java new file mode 100644 index 00000000..17459c69 --- /dev/null +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddReviewerRoleToPersonGenerator.java @@ -0,0 +1,131 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +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.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.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 { + + private Log log = LogFactory.getLog(AddReviewerRoleToPersonGenerator.class); + private static String template = "addReviewerRoleToPerson.ftl"; + + //Should this be overridden + @Override + protected void setTemplate(EditConfigurationVTwo editConfiguration, + VitroRequest vreq) { + editConfiguration.setTemplate(template); + } + + + //The default activityToRolePredicate and roleToActivityPredicates are + //correct for this subclass so they don't need to be overwritten + public String getActivityToRolePredicate(VitroRequest vreq) { + return "http://vivoweb.org/ontology/core#linkedRole"; + } + + public String getRoleToActivityPredicate(VitroRequest vreq) { + return "http://vivoweb.org/ontology/core#forInformationResource"; + } + + //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#ReviewerRole"; + } + + //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 ? + public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) { + return RoleActivityOptionTypes.CHILD_VCLASSES; + } + + //This too will depend on the specific subclass of generator + public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { + return "http://vivoweb.org/ontology/core#InformationResource"; + } + + + //Reviewer role involves hard-coded options for the "right side" of the role or activity + protected HashMap getRoleActivityTypeLiteralOptions(VitroRequest vreq) { + HashMap literalOptions = new HashMap(); + literalOptions.put("", "Select type"); + return literalOptions; + } + + //isShowRoleLabelField remains true for this so doesn't need to be overwritten + public boolean isShowRoleLabelField(VitroRequest vreq) { + return false; + } + + +} diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddServiceProviderRoleToPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddServiceProviderRoleToPersonGenerator.java new file mode 100644 index 00000000..0f3abfa3 --- /dev/null +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddServiceProviderRoleToPersonGenerator.java @@ -0,0 +1,151 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +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.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.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 { + + private Log log = LogFactory.getLog(AddServiceProviderRoleToPersonGenerator.class); + private static String template = "addServiceProviderRoleToPerson.ftl"; + + //Should this be overridden + @Override + protected void setTemplate(EditConfigurationVTwo editConfiguration, + VitroRequest vreq) { + editConfiguration.setTemplate(template); + } + + + //The default activityToRolePredicate and roleToActivityPredicates are + //correct for this subclass so they don't need to be overwritten + + //role type will always be set based on particular form + public String getRoleType(VitroRequest vreq) { + //TODO: Get dynamic way of including vivoweb ontology + return "http://vivoweb.org/ontology/core#ServiceProviderRole"; + } + + //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 ? + public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) { + return RoleActivityOptionTypes.HARDCODED_LITERALS; + } + + //This too will depend on the specific subclass of generator + public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { + return null; + } + + + //Service Provider role involves hard-coded options for the "right side" of the role or activity + protected HashMap getRoleActivityTypeLiteralOptions(VitroRequest vreq) { + HashMap literalOptions = new HashMap(); + literalOptions.put("", "Select one"); + literalOptions.put("http://purl.org/ontology/bibo/Conference", "Conference"); + literalOptions.put("http://vivoweb.org/ontology/core#Association", "Association"); + literalOptions.put("http://vivoweb.org/ontology/core#Center", "Center"); + literalOptions.put("http://vivoweb.org/ontology/core#ClinicalOrganization", "Clinical Organization"); + literalOptions.put("http://vivoweb.org/ontology/core#College", "College"); + literalOptions.put("http://vivoweb.org/ontology/core#Committee", "Committee"); + literalOptions.put("http://vivoweb.org/ontology/core#Consortium", "Consortium"); + literalOptions.put("http://vivoweb.org/ontology/core#Department", "Department"); + literalOptions.put("http://vivoweb.org/ontology/core#Division", "Division"); + literalOptions.put("http://purl.org/NET/c4dm/event.owl#Event", "Event"); + literalOptions.put("http://vivoweb.org/ontology/core#ExtensionUnit", "Extension Unit"); + literalOptions.put("http://vivoweb.org/ontology/core#Foundation", "Foundation"); + literalOptions.put("http://vivoweb.org/ontology/core#FundingOrganization", "Funding Organization"); + literalOptions.put("http://vivoweb.org/ontology/core#GovernmentAgency", "Government Agency"); + literalOptions.put("http://vivoweb.org/ontology/core#Hospital", "Hospital"); + literalOptions.put("http://vivoweb.org/ontology/core#Institute", "Institute"); + literalOptions.put("http://vivoweb.org/ontology/core#Laboratory", "Laboratory"); + literalOptions.put("http://vivoweb.org/ontology/core#Library", "Library"); + literalOptions.put("http://vivoweb.org/ontology/core#Museum", "Museum"); + literalOptions.put("http://xmlns.com/foaf/0.1/Organization", "Organization"); + literalOptions.put("http://vivoweb.org/ontology/core#PrivateCompany", "Private Company"); + literalOptions.put("http://vivoweb.org/ontology/core#Program", "Program"); + literalOptions.put("http://vivoweb.org/ontology/core#Project", "Project"); + literalOptions.put("http://vivoweb.org/ontology/core#Publisher", "Publisher"); + literalOptions.put("http://vivoweb.org/ontology/core#ResearchOrganization", "Research Organization"); + literalOptions.put("http://vivoweb.org/ontology/core#Team", "Team"); + literalOptions.put("http://vivoweb.org/ontology/core#School", "School"); + literalOptions.put("http://vivoweb.org/ontology/core#Service","Service"); + literalOptions.put("http://vivoweb.org/ontology/core#StudentOrganization", "Student Organization"); + literalOptions.put("http://vivoweb.org/ontology/core#University", "University"); + return literalOptions; + } + + //isShowRoleLabelField remains true for this so doesn't need to be overwritten + + +} diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddTeacherRoleToPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddTeacherRoleToPersonGenerator.java new file mode 100644 index 00000000..1c17a72c --- /dev/null +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddTeacherRoleToPersonGenerator.java @@ -0,0 +1,124 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +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.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.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 { + + private Log log = LogFactory.getLog(AddTeacherRoleToPersonGenerator.class); + private static String template = "addTeacherRoleToPerson.ftl"; + + //Should this be overridden + @Override + protected void setTemplate(EditConfigurationVTwo editConfiguration, + VitroRequest vreq) { + editConfiguration.setTemplate(template); + } + + + //The default activityToRolePredicate and roleToActivityPredicates are + //correct for this subclass so they don't need to be overwritten + + //role type will always be set based on particular form + public String getRoleType(VitroRequest vreq) { + //TODO: Get dynamic way of including vivoweb ontology + return "http://vivoweb.org/ontology/core#TeacherRole"; + } + + //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 ? + public RoleActivityOptionTypes getRoleActivityTypeOptionsType(VitroRequest vreq) { + return RoleActivityOptionTypes.HARDCODED_LITERALS; + } + + //This too will depend on the specific subclass of generator + public String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { + return null; + } + + + //Teacher role involves hard-coded options for the "right side" of the role or activity + protected HashMap getRoleActivityTypeLiteralOptions(VitroRequest vreq) { + HashMap literalOptions = new HashMap(); + literalOptions.put("", "Select one"); + literalOptions.put("http://purl.org/ontology/bibo/Conference", "Conference"); + literalOptions.put("http://vivoweb.org/ontology/core#Course","Course"); + literalOptions.put("http://purl.org/ontology/bibo/Workshop","Workshop"); + return literalOptions; + } + + //isShowRoleLabelField remains true for this so doesn't need to be overwritten + + +}