<template mode="any">/layouts/layout_default_template.xhtml</template>
</templates>
<rows>
- <row><widget>displayName</widget></row>
+ <row><widget>shortName</widget></row>
<row><widget>refName</widget></row>
<row><widget>inAuthority</widget></row>
+ <row><widget>longName</widget></row>
+ <row><widget>nameAdditions</widget></row>
+ <row><widget>contactName</widget></row>
+ <row><widget>foundingDate</widget></row>
+ <row><widget>dissolutionDate</widget></row>
+ <row><widget>foundingPlace</widget></row>
+ <row><widget>function</widget></row>
+ <row><widget>description</widget></row>
</rows>
- <widget name="displayName" type="text">
+ <widget name="shortName" type="text">
<labels>
<label mode="any">Name</label>
</labels>
<translated>true</translated>
<fields>
- <field schema="organizations_common">displayName</field>
+ <field schema="organizations_common">shortName</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
<property name="styleClass">dataInputText</property>
</properties>
</widget>
+
+ <widget name="longName" type="text">
+ <labels>
+ <label mode="any">longName</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="organizations_common">longName</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="nameAdditions" type="text">
+ <labels>
+ <label mode="any">nameAdditions</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="organizations_common">nameAdditions</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="contactName" type="text">
+ <labels>
+ <label mode="any">contactName</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="organizations_common">contactName</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="foundingDate" type="text">
+ <labels>
+ <label mode="any">foundingDate</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="organizations_common">foundingDate</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="dissolutionDate" type="text">
+ <labels>
+ <label mode="any">dissolutionDate</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="organizations_common">dissolutionDate</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="foundingPlace" type="text">
+ <labels>
+ <label mode="any">foundingPlace</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="organizations_common">foundingPlace</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="function" type="text">
+ <labels>
+ <label mode="any">function</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="organizations_common">function</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="description" type="text">
+ <labels>
+ <label mode="any">description</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="organizations_common">description</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
</layout>
</extension>
</component>
final String SERVICE_PATH_COMPONENT = "orgauthorities";
final String ITEM_SERVICE_PATH_COMPONENT = "items";
private String knownResourceId = null;
+ private String lastOrgAuthId = null;
private String knownResourceRefName = null;
private String knownItemResourceId = null;
+ private int nItemsToCreateInList = 3;
private List<String> allResourceIdsCreated = new ArrayList<String>();
private Map<String, String> allResourceItemIdsCreated =
new HashMap<String, String>();
// for additional tests below.
knownResourceRefName = refName;
+ lastOrgAuthId = extractId(res);
// Store the ID returned from the first resource created
// for additional tests below.
if (knownResourceId == null){
- knownResourceId = extractId(res);
+ knownResourceId = lastOrgAuthId;
if (logger.isDebugEnabled()) {
logger.debug(testName + ": knownResourceId=" + knownResourceId);
}
public void createItem(String testName) {
setupCreate(testName);
- knownItemResourceId = createItemInAuthority(knownResourceId);
+ knownItemResourceId = createItemInAuthority(lastOrgAuthId);
if(logger.isDebugEnabled()){
logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
}
public void createList(String testName) throws Exception {
for (int i = 0; i < 3; i++) {
create(testName);
- // Add 3 items to each orgauthority
- for (int j = 0; j < 3; j++) {
+ knownResourceId = lastOrgAuthId;
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": Resetting knownResourceId to" + knownResourceId);
+ }
+ // Add nItemsToCreateInList items to each orgauthority
+ for (int j = 0; j < nItemsToCreateInList; j++) {
createItem(testName);
}
}
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ List<OrganizationsCommonList.OrganizationListItem> items =
+ list.getOrganizationListItem();
+ int nItemsReturned = items.size();
+ if(logger.isDebugEnabled()){
+ logger.debug(" " + testName + ": Expected "
+ + nItemsToCreateInList+" items; got: "+nItemsReturned);
+ }
+ Assert.assertEquals( nItemsReturned, nItemsToCreateInList);
+
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = false;
if (iterateThroughList && logger.isDebugEnabled()) {
- List<OrganizationsCommonList.OrganizationListItem> items =
- list.getOrganizationListItem();
int i = 0;
for (OrganizationsCommonList.OrganizationListItem item : items) {
logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
item.getCsid());
- logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
- item.getDisplayName());
+ logger.debug(" " + testName + ": list-item[" + i + "] shortName=" +
+ item.getShortName());
logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
item.getUri());
i++;
String foundingDate, String dissolutionDate, String foundingPlace,
String function, String description ) {
OrganizationsCommon organization = new OrganizationsCommon();
+ organization.setInAuthority(inAuthority);
organization.setShortName(shortName);
if(refName!=null)
organization.setRefName(refName);
final String SERVICE_PATH_COMPONENT = "orgauthorities";
final String ITEM_SERVICE_PATH_COMPONENT = "items";
- public void createOrgAuthority(String orgAuthorityName, List<String> enumValues ) {
+ public void createOrgAuthority(String orgAuthorityName,
+ List<List<String>> orgInfo ) {
// Expected status code: 201 Created
int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
if(logger.isDebugEnabled()){
logger.debug("Import: Create orgAuthority: \"" + orgAuthorityName +"\"");
}
+ String baseOrgRefName = createOrgAuthRefName(orgAuthorityName);
+ String fullOrgRefName = baseOrgRefName+"'"+orgAuthorityName+"'";
MultipartOutput multipart = createOrgAuthorityInstance(orgAuthorityName,
- createRefName(orgAuthorityName), "enum");
+ fullOrgRefName);
ClientResponse<Response> res = client.create(multipart);
int statusCode = res.getStatus();
logger.debug("Import: Created orgAuthorityulary: \"" + orgAuthorityName +"\" ID:"
+newOrgAuthorityId );
}
- for(String itemName : enumValues){
- createItemInAuthority(newOrgAuthorityId, orgAuthorityName, itemName, createRefName(itemName));
+ for(List<String> orgStrings : orgInfo){
+ createItemInAuthority(newOrgAuthorityId, baseOrgRefName, orgStrings);
}
}
- private String createItemInAuthority(String vcsid, String orgAuthorityName, String itemName, String refName) {
+ private String createItemInAuthority(String vcsid,
+ String orgAuthorityRefName, List<String> orgStrings) {
// Expected status code: 201 Created
int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
// Type of service request being tested
ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
+ /* Strings are:
+ shortName, longName, nameAdditions, contactName,
+ foundingDate, dissolutionDate, foundingPlace, function, description
+ */
+ String shortName = orgStrings.get(0);
+ String refName = createOrganizationRefName(orgAuthorityRefName, shortName);
if(logger.isDebugEnabled()){
- logger.debug("Import: Create Item: \""+itemName+"\" in orgAuthorityulary: \"" + orgAuthorityName +"\"");
+ logger.debug("Import: Create Item: \""+shortName
+ +"\" in orgAuthorityulary: \"" + orgAuthorityRefName +"\"");
}
- MultipartOutput multipart = createOrganizationInstance(itemName, refName,
- null, null, null, null, null, null, null, null, null );
+ MultipartOutput multipart = createOrganizationInstance( vcsid, refName,
+ orgStrings );
ClientResponse<Response> res = client.createItem(vcsid, multipart);
int statusCode = res.getStatus();
if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not create Item: \""+itemName
- +"\" in orgAuthority: \"" + orgAuthorityName
+ throw new RuntimeException("Could not create Item: \""+shortName
+ +"\" in orgAuthority: \"" + orgAuthorityRefName
+"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
}
if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when creating Item: \""+itemName
- +"\" in orgAuthority: \"" + orgAuthorityName +"\", Status:"+ statusCode);
+ throw new RuntimeException("Unexpected Status when creating Item: \""+shortName
+ +"\" in orgAuthority: \"" + orgAuthorityRefName +"\", Status:"+ statusCode);
}
return extractId(res);
}
// ---------------------------------------------------------------
- // Utility methods used by tests above
+ // Utility methods used by methods above
// ---------------------------------------------------------------
private MultipartOutput createOrgAuthorityInstance(
- String displayName, String refName, String vocabType) {
+ String displayName, String refName ) {
OrgauthoritiesCommon orgAuthority = new OrgauthoritiesCommon();
orgAuthority.setDisplayName(displayName);
orgAuthority.setRefName(refName);
- orgAuthority.setVocabType(vocabType);
+ orgAuthority.setVocabType("OrgAuthority");
MultipartOutput multipart = new MultipartOutput();
OutputPart commonPart = multipart.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);
commonPart.getHeaders().add("label", client.getCommonPartName());
return multipart;
}
- private MultipartOutput createOrganizationInstance(String inAuthority,
- String shortName, String refName, String longName,
- String nameAdditions, String contactName,
- String foundingDate, String dissolutionDate, String foundingPlace,
- String function, String description ) {
+ private MultipartOutput createOrganizationInstance(String inAuthority,
+ String orgRefName, List<String> orgStrings){
OrganizationsCommon organization = new OrganizationsCommon();
- organization.setShortName(shortName);
- if(refName!=null)
- organization.setRefName(refName);
+ organization.setInAuthority(inAuthority);
+ organization.setShortName(orgStrings.get(0));
+ organization.setRefName(orgRefName);
+ String longName = orgStrings.get(1);
if(longName!=null)
organization.setLongName(longName);
+ String nameAdditions = orgStrings.get(2);
if(nameAdditions!=null)
organization.setNameAdditions(nameAdditions);
+ String contactName = orgStrings.get(3);
if(contactName!=null)
organization.setContactName(contactName);
+ String foundingDate = orgStrings.get(4);
if(foundingDate!=null)
organization.setFoundingDate(foundingDate);
+ String dissolutionDate = orgStrings.get(5);
if(dissolutionDate!=null)
organization.setDissolutionDate(dissolutionDate);
+ String foundingPlace = orgStrings.get(6);
if(foundingPlace!=null)
organization.setFoundingPlace(foundingPlace);
+ String function = orgStrings.get(7);
if(function!=null)
organization.setFunction(function);
+ String description = orgStrings.get(8);
if(description!=null)
organization.setDescription(description);
MultipartOutput multipart = new MultipartOutput();
return id;
}
- protected String createRefName(String displayName) {
- return displayName.replaceAll("\\W", "");
+ protected String createOrgAuthRefName(String orgAuthorityName) {
+ return "urn:cspace:org.collectionspace.demo:personauthority:name("
+ +orgAuthorityName+")";
+ }
+
+ protected String createOrganizationRefName(
+ String orgAuthRefName, String orgName) {
+ return orgAuthRefName+":organization:name("+orgName+")";
}
public static void main(String[] args) {
logger.info("OrgAuthorityBaseImport starting...");
OrgAuthorityBaseImport oabi = new OrgAuthorityBaseImport();
- final String acquisitionMethodsOrgAuthorityName = "Acquisition Methods";
- final String entryMethodsOrgAuthorityName = "Entry Methods";
- final String entryReasonsOrgAuthorityName = "Entry Reasons";
- final String responsibleDeptsOrgAuthorityName = "Responsible Departments";
-
- List<String> acquisitionMethodsEnumValues =
- Arrays.asList("Gift","Purchase","Exchange","Transfer","Treasure");
- List<String> entryMethodsEnumValues =
- Arrays.asList("In person","Post","Found on doorstep");
- List<String> entryReasonsEnumValues =
- Arrays.asList("Enquiry","Commission","Loan");
- List<String> respDeptNamesEnumValues =
- Arrays.asList("Antiquities","Architecture and Design","Decorative Arts",
- "Ethnography","Herpetology","Media and Performance Art",
- "Paintings and Sculpture","Paleobotany","Photographs",
- "Prints and Drawings");
-
- oabi.createOrgAuthority(acquisitionMethodsOrgAuthorityName, acquisitionMethodsEnumValues);
- oabi.createOrgAuthority(entryMethodsOrgAuthorityName, entryMethodsEnumValues);
- oabi.createOrgAuthority(entryReasonsOrgAuthorityName, entryReasonsEnumValues);
- oabi.createOrgAuthority(responsibleDeptsOrgAuthorityName, respDeptNamesEnumValues);
+ final String demoOrgAuthorityName = "Demo Org Authority";
+
+ /* Strings are:
+ shortName, longName, nameAdditions, contactName,
+ foundingDate, dissolutionDate, foundingPlace, function, description
+ */
+ List<String> mmiOrgStrings =
+ Arrays.asList("MMI","Museum of the Moving Image",null,"Megan Forbes",
+ "1984", null, "Astoria, NY", null, null);
+ List<String> pahmaOrgStrings =
+ Arrays.asList("PAHMA","Phoebe A. Hearst Museum of Anthropology",
+ "University of California, Berkeley","Michael Black",
+ "1901", null, "Berkeley, CA", null, null);
+ List<String> savoyOrgStrings =
+ Arrays.asList("Savoy Theatre",null,null,null,
+ "1900", "1952", "New York, NY", null, null);
+ List<List<String>> orgsStrings =
+ Arrays.asList(mmiOrgStrings, pahmaOrgStrings, savoyOrgStrings );
+
+ oabi.createOrgAuthority(demoOrgAuthorityName, orgsStrings);
logger.info("OrgAuthorityBaseImport complete.");
}