diff --git a/productMods/templates/freemarker/body/individual/manageLabelsForIndividualSubmissionErrors.ftl b/productMods/templates/freemarker/body/individual/manageLabelsForIndividualSubmissionErrors.ftl
index 833f5e99..cd22dfed 100644
--- a/productMods/templates/freemarker/body/individual/manageLabelsForIndividualSubmissionErrors.ftl
+++ b/productMods/templates/freemarker/body/individual/manageLabelsForIndividualSubmissionErrors.ftl
@@ -5,8 +5,7 @@
<#--Get existing value for specific data literals and uris, in case the form is returned because of an error-->
<#assign firstNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "firstName")/>
<#assign lastNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "lastName")/>
-<#--With ISF changes, we also have a niddle name value, also add error field below-->
-<#--assign middleNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "middleName") /-->
+<#assign middleNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "middleName") />
<#assign labelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "label")/>
<#assign newLabelLanguageValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "newLabelLanguage")/>
diff --git a/productMods/templates/freemarker/edit/forms/newIndividualForm.ftl b/productMods/templates/freemarker/edit/forms/newIndividualForm.ftl
index 286b4b8b..ad452e4d 100644
--- a/productMods/templates/freemarker/edit/forms/newIndividualForm.ftl
+++ b/productMods/templates/freemarker/edit/forms/newIndividualForm.ftl
@@ -11,6 +11,8 @@
<#--Get existing value for specific data literals and uris-->
<#assign firstNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "firstName")/>
<#assign lastNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "lastName")/>
+<#assign middleNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "middleName")/>
+
<#assign labelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "label")/>
<#--If edit submission exists, then retrieve validation errors if they exist-->
@@ -51,6 +53,11 @@
+
+
+
+
+
diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManageLabelsForPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManageLabelsForPersonGenerator.java
index 0f2dc9a6..f524f555 100644
--- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManageLabelsForPersonGenerator.java
+++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManageLabelsForPersonGenerator.java
@@ -54,6 +54,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTw
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.FoafNameToRdfsLabelPreprocessor;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.ManageLabelsForIndividualPreprocessor;
+import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.ManageLabelsForPersonPreprocessor;
import edu.cornell.mannlib.vitro.webapp.i18n.selection.LocaleSelectionDataGetter;
import edu.cornell.mannlib.vitro.webapp.i18n.selection.LocaleSelectorUtilities;
import edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale;
@@ -69,12 +70,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
private static String template = "manageLabelsForPerson.ftl";
private HashMap> labelsSortedByLanguage = null;
private List existingLabelLiterals = null;
- //list of language names sorted alphabetically
- private List existingSortedLanguageNameList = null;
- //This would be for the full list and can be used for the existing labels list as well
-
- private HashMap fullLanguageNameToCodeMap = null;
- private static String predicateUri = RDFS.label.getURI();
+
@Override
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
@@ -115,7 +111,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
addFormSpecificData(config, vreq);
//This preprocessor handles getting the correct label language and putting the attribute on the label
config.addEditSubmissionPreprocessor(
- new ManageLabelsForIndividualPreprocessor(config));
+ new ManageLabelsForPersonPreprocessor(config));
//This will handle generating the label from the first name, middle, and last names and also make sure to associate
//a language with that label
config.addModelChangePreprocessor(new FoafNameToRdfsLabelPreprocessor());
@@ -150,22 +146,20 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
private List generateN3Optional(VitroRequest vreq) {
List n3Optional = new ArrayList();
- String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
- String n3 = "?subject <" + predicateUri + "> ?label ";
- //n3 used if the subject is a person
- //String personN3 = this.N3_PREFIX + "?subject foaf:firstName ?firstName ; foaf:lastName ?lastName .";
- //This n3 will be different with the ISF changes
- String personN3 = this.N3_PREFIX +
+
+ String personFullNameN3 = this.N3_PREFIX +
"?subject ?individualVcard . \n" +
"?individualVcard a . \n" +
"?individualVcard ?subject . \n" +
"?individualVcard ?fullName . \n" +
- "?fullName a . \n" +
- "?fullName ?firstName . \n" +
+ "?fullName a .";
+ String personFirstNameN3 =
+ "?fullName ?firstName . ";
+ String personLastNameN3 =
"?fullName ?lastName .";
-
- n3Optional.add(n3);
- n3Optional.add(personN3);
+ String personMiddleNameN3 = "?fullName ?middleName .";
+ n3Optional.add(personFullNameN3 + "\n " + personFirstNameN3 + "\n " + personLastNameN3);
+ n3Optional.add(personMiddleNameN3);
return n3Optional;
}
@@ -174,9 +168,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
Map fields = new HashMap();
editConfiguration.setFields(fields);
- editConfiguration.addField(new FieldVTwo().
- setName("label").
- setValidators(getLabelValidators(vreq, editConfiguration)));
+
editConfiguration.addField(new FieldVTwo(
).setName("newLabelLanguage"));
//no validators since all of this is optional
@@ -186,7 +178,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
setValidators(getFirstNameValidators(vreq, editConfiguration)));
editConfiguration.addField(new FieldVTwo().
setName("middleName").
- setValidators(getLastNameValidators(vreq, editConfiguration)));
+ setValidators(getMiddleNameValidators(vreq, editConfiguration)));
editConfiguration.addField(new FieldVTwo().
setName("lastName").
@@ -199,39 +191,36 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
//first and last name have validators if is person is true
private List getFirstNameValidators(VitroRequest vreq, EditConfigurationVTwo config) {
List validators = new ArrayList();
- if(isPersonType(vreq, config)) {
validators.add("nonempty");
- }
+
+ return validators;
+ }
+
+ private List getMiddleNameValidators(VitroRequest vreq, EditConfigurationVTwo config) {
+ List validators = new ArrayList();
+
return validators;
}
private List getLastNameValidators(VitroRequest vreq, EditConfigurationVTwo config) {
List validators = new ArrayList();
- if(isPersonType(vreq, config)) {
validators.add("nonempty");
- }
+
return validators;
}
- //validate label if person is not true
- private List getLabelValidators(VitroRequest vreq, EditConfigurationVTwo config) {
- List validators = new ArrayList();
- if(!isPersonType(vreq, config)) {
- validators.add("nonempty");
- }
- return validators;
- }
+
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo config,
VitroRequest vreq) {
List literalsOnForm = new ArrayList();
- literalsOnForm.add("label");
literalsOnForm.add("newLabelLanguage");
//optional for person
literalsOnForm.add("firstName");
literalsOnForm.add("lastName");
+ literalsOnForm.add("middleName");
config.setLiteralsOnForm(literalsOnForm);
}
@@ -253,17 +242,6 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
private void initExistingLabels(EditConfigurationVTwo config,
VitroRequest vreq) {
this.existingLabelLiterals = this.getExistingLabels(config.getSubjectUri(), vreq);
- // this.labelsSortedByLanguage = this.getLabelsSortedByLanguage(config,vreq);
- //language names sorted for the existing languages
- // this.existingSortedLanguageNameList = getExistingSortedLanguageNamesList();
-
- //Generate a label to language code hash map
- //TODO:
-
- //HashMap labelToLanguageCode = new HashMap();
-
- //this.labels = getExistingLabels(config.getSubjectUri(), vreq);
- //this.labelsSortedByLanguage = getLabelsSortedByLanguage(config.getSubjectUri(), vreq);
}
@@ -318,15 +296,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
config.addFormSpecificData("subjectName", null);
}
- //Put in whether or not person type
- if(isPersonType(vreq, config)) {
- //Doing this b/c unsure how freemarker will handle boolean value from JAVA
- config.addFormSpecificData("isPersonType", "true");
- } else {
- config.addFormSpecificData("isPersonType", "false");
-
- }
-
+ config.addFormSpecificData("isPersonType", "true");
//Include whether or not editable to enable edit/remove links and add to show up
config.addFormSpecificData("editable", isEditable(vreq, config));
}
@@ -376,7 +346,6 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
//Copied from NewIndividualFormGenerator
- //TODO: Refactor so common code can be used by both generators
public String getFOAFPersonClassURI() {
return "http://xmlns.com/foaf/0.1/Person";
}
diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/NewIndividualFormGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/NewIndividualFormGenerator.java
index 0fd76116..51b929a8 100644
--- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/NewIndividualFormGenerator.java
+++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/NewIndividualFormGenerator.java
@@ -41,6 +41,7 @@ public class NewIndividualFormGenerator extends BaseEditConfigurationGenerator i
));
//Optional because user may have selected either person or individual of another kind
//Person uses first name and last name whereas individual of other class would use label
+ //middle name is also optional
config.setN3Optional(list(
N3_PREFIX + "@prefix vcard: .\n"
+ " ?newInd ?newVcardInd . \n"
@@ -50,6 +51,7 @@ public class NewIndividualFormGenerator extends BaseEditConfigurationGenerator i
+ " ?newVcardName a . \n"
+ " ?newVcardName vcard:givenName ?firstName . \n"
+ " ?newVcardName vcard:familyName ?lastName .",
+ "?newVcardName ?middleName .",
N3_PREFIX + " ?newInd <" + RDFS.label.getURI() + "> ?label ."
));
@@ -58,7 +60,7 @@ public class NewIndividualFormGenerator extends BaseEditConfigurationGenerator i
config.addNewResource("newVcardName", vreq.getWebappDaoFactory().getDefaultNamespace());
config.setUrisOnform(list ());
- config.setLiteralsOnForm( list( "label", "firstName", "lastName" ));
+ config.setLiteralsOnForm( list( "label", "firstName", "lastName", "middleName" ));
setUrisAndLiteralsInScope(config);
//No SPARQL queries for existing since this is only used to create new, never for edit
@@ -67,6 +69,11 @@ public class NewIndividualFormGenerator extends BaseEditConfigurationGenerator i
setRangeDatatypeUri(XSD.xstring.getURI()).
setValidators(getFirstNameValidators(vreq)));
+ config.addField(new FieldVTwo().
+ setName("middleName").
+ setRangeDatatypeUri(XSD.xstring.getURI()).
+ setValidators(getMiddleNameValidators(vreq)));
+
config.addField(new FieldVTwo().
setName("lastName").
setRangeDatatypeUri(XSD.xstring.getURI()).
@@ -96,7 +103,12 @@ public class NewIndividualFormGenerator extends BaseEditConfigurationGenerator i
return config;
}
- //first and last name have validators if is person is true
+ private List getMiddleNameValidators(VitroRequest vreq) {
+ List validators = new ArrayList();
+ return validators;
+ }
+
+ //first and last name have validators if is person is true
private List getFirstNameValidators(VitroRequest vreq) {
List validators = new ArrayList();
if(isPersonType(vreq)) {
diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/ManageLabelsForPersonPreprocessor.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/ManageLabelsForPersonPreprocessor.java
new file mode 100644
index 00000000..e6fe5830
--- /dev/null
+++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/ManageLabelsForPersonPreprocessor.java
@@ -0,0 +1,105 @@
+/* $This file is distributed under the terms of the license in /doc/license.txt$ */
+
+package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.hp.hpl.jena.ontology.OntModel;
+import com.hp.hpl.jena.rdf.model.Literal;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.ResIterator;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.Statement;
+
+import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
+import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
+/*
+ * This preprocessor is used to set the language attribute on the label based on the user selection
+ * on the manage labels page when adding a new label.
+ */
+import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.BaseEditSubmissionPreprocessorVTwo;
+import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
+import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
+
+public class ManageLabelsForPersonPreprocessor extends ManageLabelsForIndividualPreprocessor {
+
+
+
+
+ public ManageLabelsForPersonPreprocessor(EditConfigurationVTwo editConfig) {
+ super(editConfig);
+
+ }
+
+ @Override
+ public void preprocess(MultiValueEditSubmission inputSubmission, VitroRequest vreq) {
+ //Use the ManageLabelsForIndividualPreprocessor in addition to this code specific for person
+ super.preprocess(inputSubmission, vreq);
+ //First name and last name would also have a language selected so make sure those literals are also
+ //correctly typed
+ //Middle name is optional
+ if(inputSubmission.hasLiteralValue("firstName") && inputSubmission.hasLiteralValue("lastName") && inputSubmission.hasLiteralValue("newLabelLanguage")) {
+ Map> literalsFromForm = inputSubmission.getLiteralsFromForm();
+ List newLabelLanguages = literalsFromForm.get("newLabelLanguage");
+ List firstNames = literalsFromForm.get("firstName");
+ List lastNames = literalsFromForm.get("lastName");
+ List middleNames = new ArrayList();
+ if(inputSubmission.hasLiteralValue("middleName")) {
+ middleNames = literalsFromForm.get("middleName");
+ }
+
+
+ //Expecting only one language
+ if(firstNames.size() > 0 && lastNames.size() > 0 && newLabelLanguages.size() > 0) {
+ Literal newLabelLanguage = newLabelLanguages.get(0);
+ Literal firstNameLiteral = firstNames.get(0);
+ Literal lastNameLiteral = lastNames.get(0);
+
+ //Get the string
+ String lang = this.getLanguage(newLabelLanguage.getString());
+ String firstNameValue = firstNameLiteral.getString();
+ String lastNameValue = lastNameLiteral.getString();
+
+ //Now add the language category to the literal
+ Literal firstNameWithLanguage = inputSubmission.createLiteral(firstNameValue,
+ null,
+ lang);
+ Literal lastNameWithLanguage = inputSubmission.createLiteral(lastNameValue,
+ null,
+ lang);
+
+ firstNames = new ArrayList();
+ lastNames = new ArrayList();
+ firstNames.add(firstNameWithLanguage);
+ lastNames.add(lastNameWithLanguage);
+ //replace the label with one with language, again assuming only one label being returned
+ literalsFromForm.put("firstName", firstNames);
+ literalsFromForm.put("lastName", lastNames);
+
+ //Middle name handling
+ if(middleNames.size() > 0) {
+ Literal middleNameLiteral = middleNames.get(0);
+ String middleNameValue = middleNameLiteral.getString();
+ Literal middleNameWithLanguage = inputSubmission.createLiteral(middleNameValue,
+ null,
+ lang);
+ middleNames = new ArrayList();
+ middleNames.add(middleNameWithLanguage);
+ literalsFromForm.put("middleName", middleNames);
+ }
+
+ //Set literals
+ inputSubmission.setLiteralsFromForm(literalsFromForm);
+ }
+ }
+
+ }
+
+
+}