NIHVIVO 2599 and 2702 updates to addAuthorToPub to allow selection of organizations
This commit is contained in:
parent
39cb99321f
commit
805ddb1d1e
4 changed files with 268 additions and 46 deletions
|
@ -2,10 +2,14 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
|
||||
|
||||
import java.lang.String;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3ValidatorVTwo;
|
||||
|
@ -27,12 +31,22 @@ public class PublicationHasAuthorValidator implements N3ValidatorVTwo {
|
|||
Map<String,String> errors = new HashMap<String,String>();
|
||||
|
||||
List<String> personUri = urisFromForm.get("personUri");
|
||||
List<String> orgUri = urisFromForm.get("orgUri");
|
||||
List<Literal> orgNameList = literalsFromForm.get("orgName");
|
||||
|
||||
if (allListElementsEmpty(personUri)) {
|
||||
personUri = null;
|
||||
}
|
||||
// If there's a personUri, then we're done. The firstName and lastName fields are
|
||||
if (allListElementsEmpty(orgUri)) {
|
||||
orgUri = null;
|
||||
}
|
||||
Literal orgName = null;
|
||||
if(orgNameList != null && orgNameList.size() > 0) {
|
||||
orgName = orgNameList.get(0);
|
||||
}
|
||||
// If there's a personUri, orgUri or orgName, then we're done. The firstName and lastName fields are
|
||||
// disabled and so don't get submitted.
|
||||
if (personUri != null) {
|
||||
if (personUri != null || orgUri != null || orgName != null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
|||
|
||||
editConfiguration.addNewResource("authorshipUri", DEFAULT_NS_TOKEN);
|
||||
editConfiguration.addNewResource("newPerson", DEFAULT_NS_TOKEN);
|
||||
editConfiguration.addNewResource("newOrg", DEFAULT_NS_TOKEN);
|
||||
|
||||
//In scope
|
||||
setUrisAndLiteralsInScope(editConfiguration, vreq);
|
||||
|
@ -118,7 +119,9 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
|||
getN3NewPersonLastName(),
|
||||
getN3NewPerson(),
|
||||
getN3AuthorshipRank(),
|
||||
getN3ForExistingPerson());
|
||||
getN3ForExistingPerson(),
|
||||
getN3NewOrg(),
|
||||
getN3ForExistingOrg());
|
||||
|
||||
}
|
||||
|
||||
|
@ -152,6 +155,19 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
|||
"?personUri core:authorInAuthorship ?authorshipUri .";
|
||||
}
|
||||
|
||||
private String getN3NewOrg() {
|
||||
return getN3PrefixString() +
|
||||
"?newOrg a foaf:Organization ;\n" +
|
||||
"<" + RDFS.label.getURI() + "> ?orgName .\n" +
|
||||
"?authorshipUri core:linkedAuthor ?newOrg .\n" +
|
||||
"?newOrg core:authorInAuthorship ?authorshipUri . ";
|
||||
}
|
||||
|
||||
private String getN3ForExistingOrg() {
|
||||
return getN3PrefixString() +
|
||||
"?authorshipUri core:linkedAuthor ?orgUri .\n" +
|
||||
"?orgUri core:authorInAuthorship ?authorshipUri .";
|
||||
}
|
||||
/** Get new resources */
|
||||
//A new authorship uri will always be created when an author is added
|
||||
//A new person may be added if a person not in the system will be added as author
|
||||
|
@ -161,6 +177,7 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
|||
HashMap<String, String> newResources = new HashMap<String, String>();
|
||||
newResources.put("authorshipUri", DEFAULT_NS_TOKEN);
|
||||
newResources.put("newPerson", DEFAULT_NS_TOKEN);
|
||||
newResources.put("newOrg", DEFAULT_NS_TOKEN);
|
||||
return newResources;
|
||||
}
|
||||
|
||||
|
@ -180,6 +197,7 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
|||
List<String> urisOnForm = new ArrayList<String>();
|
||||
//If an existing person is being used as an author, need to get the person uri
|
||||
urisOnForm.add("personUri");
|
||||
urisOnForm.add("orgUri");
|
||||
editConfiguration.setUrisOnform(urisOnForm);
|
||||
|
||||
//for person who is not in system, need to add first name, last name and middle name
|
||||
|
@ -188,6 +206,7 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
|||
"middleName",
|
||||
"lastName",
|
||||
"rank",
|
||||
"orgName",
|
||||
"label");
|
||||
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
||||
}
|
||||
|
@ -216,6 +235,8 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
|||
setLastNameField(editConfiguration);
|
||||
setRankField(editConfiguration);
|
||||
setPersonUriField(editConfiguration);
|
||||
setOrgUriField(editConfiguration);
|
||||
setOrgNameField(editConfiguration);
|
||||
}
|
||||
|
||||
private void setLabelField(EditConfigurationVTwo editConfiguration) {
|
||||
|
@ -278,6 +299,21 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
|||
|
||||
}
|
||||
|
||||
private void setOrgUriField(EditConfigurationVTwo editConfiguration) {
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
setName("orgUri")
|
||||
//.setObjectClassUri(personClass)
|
||||
);
|
||||
|
||||
}
|
||||
private void setOrgNameField(EditConfigurationVTwo editConfiguration) {
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
setName("orgName").
|
||||
setValidators(list("datatype:" + XSD.xstring.toString())).
|
||||
setRangeDatatypeUri(XSD.xstring.toString())
|
||||
);
|
||||
|
||||
}
|
||||
//Form specific data
|
||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue