--- /dev/null
+package org.collectionspace.services.client;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import javax.ws.rs.core.MediaType;\r
+\r
+import org.collectionspace.services.OrganizationJAXBSchema;\r
+import org.collectionspace.services.organization.OrganizationsCommon;\r
+import org.collectionspace.services.organization.OrgauthoritiesCommon;\r
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;\r
+import org.jboss.resteasy.plugins.providers.multipart.OutputPart;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+public class OrgAuthorityClientUtils {\r
+ private static final Logger logger =\r
+ LoggerFactory.getLogger(OrgAuthorityClientUtils.class);\r
+\r
+ public static MultipartOutput createOrgAuthorityInstance(\r
+ String displayName, String refName, String headerLabel ) {\r
+ OrgauthoritiesCommon orgAuthority = new OrgauthoritiesCommon();\r
+ orgAuthority.setDisplayName(displayName);\r
+ orgAuthority.setRefName(refName);\r
+ orgAuthority.setVocabType("OrgAuthority");\r
+ MultipartOutput multipart = new MultipartOutput();\r
+ OutputPart commonPart = multipart.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);\r
+ commonPart.getHeaders().add("label", headerLabel);\r
+\r
+ if(logger.isDebugEnabled()){\r
+ logger.debug("to be created, orgAuthority common ", \r
+ orgAuthority, OrgauthoritiesCommon.class);\r
+ }\r
+\r
+ return multipart;\r
+ }\r
+\r
+ public static MultipartOutput createOrganizationInstance(String inAuthority, \r
+ String orgRefName, Map<String, String> orgInfo, String headerLabel){\r
+ OrganizationsCommon organization = new OrganizationsCommon();\r
+ organization.setInAuthority(inAuthority);\r
+ organization.setRefName(orgRefName);\r
+ String value = null;\r
+ if((value = (String)orgInfo.get(OrganizationJAXBSchema.SHORT_NAME))!=null)\r
+ organization.setShortName(value);\r
+ if((value = (String)orgInfo.get(OrganizationJAXBSchema.LONG_NAME))!=null)\r
+ organization.setLongName(value);\r
+ if((value = (String)orgInfo.get(OrganizationJAXBSchema.NAME_ADDITIONS))!=null)\r
+ organization.setNameAdditions(value);\r
+ if((value = (String)orgInfo.get(OrganizationJAXBSchema.CONTACT_NAME))!=null)\r
+ organization.setContactName(value);\r
+ if((value = (String)orgInfo.get(OrganizationJAXBSchema.FOUNDING_DATE))!=null)\r
+ organization.setFoundingDate(value);\r
+ if((value = (String)orgInfo.get(OrganizationJAXBSchema.DISSOLUTION_DATE))!=null)\r
+ organization.setDissolutionDate(value);\r
+ if((value = (String)orgInfo.get(OrganizationJAXBSchema.FOUNDING_PLACE))!=null)\r
+ organization.setFoundingPlace(value);\r
+ if((value = (String)orgInfo.get(OrganizationJAXBSchema.FUNCTION))!=null)\r
+ organization.setFunction(value);\r
+ if((value = (String)orgInfo.get(OrganizationJAXBSchema.DESCRIPTION))!=null)\r
+ organization.setDescription(value);\r
+ MultipartOutput multipart = new MultipartOutput();\r
+ OutputPart commonPart = multipart.addPart(organization,\r
+ MediaType.APPLICATION_XML_TYPE);\r
+ commonPart.getHeaders().add("label", headerLabel);\r
+\r
+ if(logger.isDebugEnabled()){\r
+ logger.debug("to be created, organization common ", organization, OrganizationsCommon.class);\r
+ }\r
+\r
+ return multipart;\r
+ }\r
+\r
+}\r
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.collectionspace.services.OrganizationJAXBSchema;
import org.collectionspace.services.client.OrgAuthorityClient;
+import org.collectionspace.services.client.OrgAuthorityClientUtils;
import org.collectionspace.services.organization.OrgauthoritiesCommon;
import org.collectionspace.services.organization.OrgauthoritiesCommonList;
import org.collectionspace.services.organization.OrganizationsCommon;
String identifier = createIdentifier();
String displayName = "displayName-" + identifier;
String refName = createRefName(displayName);
- String typeName = "vocabType-" + identifier;
MultipartOutput multipart =
- createOrgAuthorityInstance(displayName, refName, typeName);
+ OrgAuthorityClientUtils.createOrgAuthorityInstance(
+ displayName, refName,
+ client.getCommonPartName());
ClientResponse<Response> res = client.create(multipart);
int statusCode = res.getStatus();
// Submit the request to the service and store the response.
String identifier = createIdentifier();
String refName = createRefName(identifier);
- MultipartOutput multipart = createOrganizationInstance(vcsid,
- identifier, refName, "Longer Name for "+identifier,
- null, "joe@org.org", "1910", null, "Anytown, USA", "testing",
- "This is a fake organization that was created by a test method." );
+ Map<String, String> testOrgMap = new HashMap<String,String>();
+ testOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "Test Org");
+ testOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "The real official test organization");
+ testOrgMap.put(OrganizationJAXBSchema.CONTACT_NAME, "joe@test.org");
+ testOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "May 26, 1907");
+ testOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, "Anytown, USA");
+ testOrgMap.put(OrganizationJAXBSchema.FUNCTION, "For testing");
+ MultipartOutput multipart =
+ OrgAuthorityClientUtils.createOrganizationInstance(vcsid,
+ refName, testOrgMap, client.getItemCommonPartName() );
ClientResponse<Response> res = client.createItem(vcsid, multipart);
int statusCode = res.getStatus();
// The only relevant ID may be the one used in update(), below.
// The only relevant ID may be the one used in update(), below.
- MultipartOutput multipart = createOrganizationInstance(
- knownResourceId, NON_EXISTENT_ID, createRefName(NON_EXISTENT_ID),
- null, null, null, null, null, null, null, null);
+ Map<String, String> nonexOrgMap = new HashMap<String,String>();
+ nonexOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "Non-existent");
+ MultipartOutput multipart =
+ OrgAuthorityClientUtils.createOrganizationInstance(
+ knownResourceId, createRefName(NON_EXISTENT_ID),
+ nonexOrgMap, client.getCommonPartName() );
ClientResponse<MultipartInput> res =
client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
int statusCode = res.getStatus();
private MultipartOutput createOrgAuthorityInstance(String identifier) {
String displayName = "displayName-" + identifier;
String refName = createRefName(displayName);
- String typeName = "vocabType-" + identifier;
- return createOrgAuthorityInstance(
- displayName, refName,typeName );
- }
-
- private MultipartOutput createOrgAuthorityInstance(
- String displayName, String refName, String vocabType) {
- OrgauthoritiesCommon orgAuthority = new OrgauthoritiesCommon();
- orgAuthority.setDisplayName(displayName);
- if(refName!=null)
- orgAuthority.setRefName(refName);
- orgAuthority.setVocabType(vocabType);
- MultipartOutput multipart = new MultipartOutput();
- OutputPart commonPart = multipart.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getCommonPartName());
-
- if(logger.isDebugEnabled()) {
- logger.debug("to be created, orgAuthority common");
- logger.debug(objectAsXmlString(orgAuthority, OrgauthoritiesCommon.class));
- }
- 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 ) {
- OrganizationsCommon organization = new OrganizationsCommon();
- organization.setInAuthority(inAuthority);
- organization.setShortName(shortName);
- if(refName!=null)
- organization.setRefName(refName);
- if(longName!=null)
- organization.setLongName(longName);
- if(nameAdditions!=null)
- organization.setNameAdditions(nameAdditions);
- if(contactName!=null)
- organization.setContactName(contactName);
- if(foundingDate!=null)
- organization.setFoundingDate(foundingDate);
- if(dissolutionDate!=null)
- organization.setDissolutionDate(dissolutionDate);
- if(foundingPlace!=null)
- organization.setFoundingPlace(foundingPlace);
- if(function!=null)
- organization.setFunction(function);
- if(description!=null)
- organization.setDescription(description);
- MultipartOutput multipart = new MultipartOutput();
- OutputPart commonPart = multipart.addPart(organization,
- MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getItemCommonPartName());
-
- if(logger.isDebugEnabled()){
- logger.debug("to be created, organization common");
- logger.debug(objectAsXmlString(organization,
- OrganizationsCommon.class));
- }
-
- return multipart;
+ return OrgAuthorityClientUtils.createOrgAuthorityInstance(
+ displayName, refName,
+ client.getCommonPartName());
}
}
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
-import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import org.apache.log4j.BasicConfigurator;
+import org.collectionspace.services.OrganizationJAXBSchema;
import org.collectionspace.services.client.OrgAuthorityClient;
+import org.collectionspace.services.client.OrgAuthorityClientUtils;
import org.collectionspace.services.client.test.ServiceRequestType;
-import org.collectionspace.services.organization.OrgauthoritiesCommon;
-import org.collectionspace.services.organization.OrganizationsCommon;
import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final String ITEM_SERVICE_PATH_COMPONENT = "items";
public void createOrgAuthority(String orgAuthorityName,
- List<List<String>> orgInfo ) {
+ List<Map<String,String>> orgInfos ) {
// Expected status code: 201 Created
int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
}
String baseOrgAuthRefName = createOrgAuthRefName(orgAuthorityName);
String fullOrgAuthRefName = baseOrgAuthRefName+"'"+orgAuthorityName+"'";
- MultipartOutput multipart = createOrgAuthorityInstance(orgAuthorityName,
- fullOrgAuthRefName);
+ MultipartOutput multipart =
+ OrgAuthorityClientUtils.createOrgAuthorityInstance(
+ orgAuthorityName, fullOrgAuthRefName,
+ client.getCommonPartName());
ClientResponse<Response> res = client.create(multipart);
int statusCode = res.getStatus();
logger.debug("Import: Created orgAuthorityulary: \"" + orgAuthorityName +"\" ID:"
+newOrgAuthorityId );
}
- for(List<String> orgStrings : orgInfo){
- createItemInAuthority(newOrgAuthorityId, baseOrgAuthRefName, orgStrings);
+ for(Map<String,String> orgInfo : orgInfos){
+ createItemInAuthority(newOrgAuthorityId,
+ baseOrgAuthRefName, orgInfo );
}
}
private String createItemInAuthority(String vcsid,
- String orgAuthorityRefName, List<String> orgStrings) {
+ String orgAuthorityRefName, Map<String, String> orgInfo) {
// 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)+"'"+shortName+"'";
+ String shortName = orgInfo.get(OrganizationJAXBSchema.SHORT_NAME);
+ String refName = createOrganizationRefName(
+ orgAuthorityRefName, shortName)+"'"+shortName+"'";
if(logger.isDebugEnabled()){
logger.debug("Import: Create Item: \""+shortName
+"\" in orgAuthorityulary: \"" + orgAuthorityRefName +"\"");
}
- MultipartOutput multipart = createOrganizationInstance( vcsid, refName,
- orgStrings );
+ MultipartOutput multipart =
+ OrgAuthorityClientUtils.createOrganizationInstance( vcsid,
+ refName, orgInfo, client.getCommonPartName() );
ClientResponse<Response> res = client.createItem(vcsid, multipart);
int statusCode = res.getStatus();
// Utility methods used by methods above
// ---------------------------------------------------------------
- private MultipartOutput createOrgAuthorityInstance(
- String displayName, String refName ) {
- OrgauthoritiesCommon orgAuthority = new OrgauthoritiesCommon();
- orgAuthority.setDisplayName(displayName);
- orgAuthority.setRefName(refName);
- orgAuthority.setVocabType("OrgAuthority");
- MultipartOutput multipart = new MultipartOutput();
- OutputPart commonPart = multipart.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getCommonPartName());
-
- if(logger.isDebugEnabled()){
- logger.debug("to be created, orgAuthority common ",
- orgAuthority, OrgauthoritiesCommon.class);
- }
-
- return multipart;
- }
-
- private MultipartOutput createOrganizationInstance(String inAuthority,
- String orgRefName, List<String> orgStrings){
- OrganizationsCommon organization = new OrganizationsCommon();
- 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();
- OutputPart commonPart = multipart.addPart(organization,
- MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getItemCommonPartName());
-
- if(logger.isDebugEnabled()){
- logger.debug("to be created, organization common ", organization, OrganizationsCommon.class);
- }
-
- return multipart;
- }
-
-
/**
* Returns an error message indicating that the status code returned by a
* specific call to a service does not fall within a set of valid status
OrgAuthorityBaseImport oabi = new OrgAuthorityBaseImport();
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);
+ Map<String, String> mmiOrgMap = new HashMap<String,String>();
+ mmiOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "MMI");
+ mmiOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "Museum of the Moving Image");
+ mmiOrgMap.put(OrganizationJAXBSchema.CONTACT_NAME, "Megan Forbes");
+ mmiOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "1984");
+ mmiOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, "Astoria, NY");
+ Map<String, String> pahmaOrgMap = new HashMap<String,String>();
+ pahmaOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "PAHMA");
+ pahmaOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "Phoebe A. Hearst Museum of Anthropology");
+ pahmaOrgMap.put(OrganizationJAXBSchema.NAME_ADDITIONS, "University of California, Berkeley");
+ pahmaOrgMap.put(OrganizationJAXBSchema.CONTACT_NAME, "Michael Black");
+ pahmaOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "1901");
+ pahmaOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, "Berkeley, CA");
+ Map<String, String> savoyOrgMap = new HashMap<String,String>();
+ savoyOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "Savoy Theatre");
+ savoyOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "1900");
+ savoyOrgMap.put(OrganizationJAXBSchema.DISSOLUTION_DATE, "1952");
+ savoyOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, "New York, NY");
+ List<Map<String, String>> orgMaps =
+ Arrays.asList(mmiOrgMap, pahmaOrgMap, savoyOrgMap );
+
+ oabi.createOrgAuthority(demoOrgAuthorityName, orgMaps);
logger.info("OrgAuthorityBaseImport complete.");
}
\r
import java.util.ArrayList;\r
import java.util.Arrays;\r
+import java.util.HashMap;\r
import java.util.List;\r
+import java.util.Map;\r
\r
import javax.ws.rs.core.MediaType;\r
import javax.ws.rs.core.MultivaluedMap;\r
import javax.ws.rs.core.Response;\r
\r
import org.apache.log4j.BasicConfigurator;\r
+import org.collectionspace.services.OrganizationJAXBSchema;\r
import org.collectionspace.services.client.OrgAuthorityClient;\r
+import org.collectionspace.services.client.OrgAuthorityClientUtils;\r
import org.collectionspace.services.client.test.ServiceRequestType;\r
import org.collectionspace.services.organization.OrgauthoritiesCommon;\r
import org.collectionspace.services.organization.OrgauthoritiesCommonList;\r
// ---------------------------------------------------------------\r
// Create\r
// ---------------------------------------------------------------\r
+ protected String createOrgAuthRefName(String orgAuthorityName) {\r
+ return "urn:cspace:org.collectionspace.demo:orgauthority:name("\r
+ +orgAuthorityName+")";\r
+ }\r
+\r
+ protected String createOrganizationRefName(\r
+ String orgAuthRefName, String orgName) {\r
+ return orgAuthRefName+":organization:name("+orgName+")";\r
+ }\r
+\r
+ \r
\r
- public void createEnumeration(String orgAuthName, List<String> enumValues ) {\r
+ public void createOrgAuthority(String orgAuthName, List<Map<String,String>> orgInfos ) {\r
\r
// Expected status code: 201 Created\r
int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();\r
ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;\r
\r
logger.info("Import: Create orgAuthority: \"" + orgAuthName +"\"");\r
- MultipartOutput multipart = createOrgAuthorityInstance(orgAuthName, \r
- createRefName(orgAuthName), "enum");\r
+ String baseOrgAuthRefName = createOrgAuthRefName(orgAuthName);\r
+ String fullOrgAuthRefName = baseOrgAuthRefName+"'"+orgAuthName+"'";\r
+ MultipartOutput multipart = \r
+ OrgAuthorityClientUtils.createOrgAuthorityInstance(\r
+ orgAuthName, fullOrgAuthRefName, \r
+ client.getCommonPartName());\r
ClientResponse<Response> res = client.create(multipart);\r
\r
int statusCode = res.getStatus();\r
+newOrgAuthId );\r
\r
// Add items to the orgAuthority\r
- for(String itemName : enumValues){\r
- createItemInOrgAuth(newOrgAuthId, orgAuthName, itemName, createRefName(itemName));\r
+ for(Map<String,String> orgInfo : orgInfos){\r
+ createItemInOrgAuth(newOrgAuthId, baseOrgAuthRefName, orgInfo);\r
}\r
\r
}\r
\r
- private String createItemInOrgAuth(String vcsid, String orgAuthName, String itemName, String refName) {\r
+ private String createItemInOrgAuth(String vcsid, \r
+ String orgAuthorityRefName, Map<String,String> orgInfo) {\r
// Expected status code: 201 Created\r
int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();\r
// Type of service request being tested\r
ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;\r
+ String shortName = orgInfo.get(OrganizationJAXBSchema.SHORT_NAME);\r
+ String refName = createOrganizationRefName(\r
+ orgAuthorityRefName, shortName)+"'"+shortName+"'";\r
+\r
+\r
+ logger.info("Import: Create Item: \""+shortName+\r
+ "\" in orgAuthority: \"" + orgAuthorityRefName +"\"");\r
+ MultipartOutput multipart = \r
+ OrgAuthorityClientUtils.createOrganizationInstance( vcsid, \r
+ refName, orgInfo, client.getCommonPartName() );\r
\r
- logger.info("Import: Create Item: \""+itemName+"\" in orgAuthority: \"" + orgAuthName +"\"");\r
- MultipartOutput multipart = createOrganizationInstance(vcsid, itemName, refName);\r
ClientResponse<Response> res = client.createItem(vcsid, multipart);\r
\r
int statusCode = res.getStatus();\r
\r
if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
- throw new RuntimeException("Could not create Item: \""+itemName\r
- +"\" in orgAuthority: \"" + orgAuthName\r
+ throw new RuntimeException("Could not create Item: \""+shortName\r
+ +"\" in orgAuthority: \"" + orgAuthorityRefName\r
+"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
}\r
if(statusCode != EXPECTED_STATUS_CODE) {\r
- throw new RuntimeException("Unexpected Status when creating Item: \""+itemName\r
- +"\" in orgAuthority: \"" + orgAuthName +"\", Status:"+ statusCode);\r
+ throw new RuntimeException("Unexpected Status when creating Item: \""+shortName\r
+ +"\" in orgAuthority: \"" + orgAuthorityRefName +\r
+ "\", Status:"+ statusCode);\r
}\r
\r
return extractId(res);\r
// Utility methods used by tests above\r
// ---------------------------------------------------------------\r
\r
- private MultipartOutput createOrgAuthorityInstance(\r
- String displayName, String refName, String vocabType) {\r
- OrgauthoritiesCommon orgAuthority = new OrgauthoritiesCommon();\r
- orgAuthority.setDisplayName(displayName);\r
- orgAuthority.setRefName(refName);\r
- orgAuthority.setVocabType(vocabType);\r
- MultipartOutput multipart = new MultipartOutput();\r
- OutputPart commonPart = multipart.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);\r
- commonPart.getHeaders().add("label", client.getCommonPartName());\r
-\r
- if(logger.isDebugEnabled()){\r
- logger.debug("to be created, orgAuthority common ",\r
- orgAuthority, OrgauthoritiesCommon.class);\r
- }\r
-\r
- return multipart;\r
- }\r
-\r
- private MultipartOutput createOrganizationInstance(\r
- String inAuthority, String displayName, String refName) {\r
- OrganizationsCommon organization = new OrganizationsCommon();\r
- organization.setInAuthority(inAuthority);\r
- organization.setShortName(displayName);\r
- organization.setRefName(refName);\r
- MultipartOutput multipart = new MultipartOutput();\r
- OutputPart commonPart = multipart.addPart(organization, MediaType.APPLICATION_XML_TYPE);\r
- commonPart.getHeaders().add("label", client.getItemCommonPartName());\r
-\r
- if(logger.isDebugEnabled()){\r
- logger.debug("to be created, organization common ", organization, OrganizationsCommon.class);\r
- }\r
-\r
- return multipart;\r
- }\r
\r
// Retrieve individual fields of orgAuthority records.\r
\r
\r
logger.info("OrgAuthority Sample starting...");\r
\r
- Sample vbi = new Sample();\r
+ Sample sample = new Sample();\r
OrgauthoritiesCommonList orgAuthorities;\r
List<String> orgAuthIds;\r
String details = "";\r
logger.info("Deleting all organizations and orgAuthorities ...");\r
\r
// For each orgAuthority ...\r
- orgAuthorities = vbi.readOrgAuthorities();\r
- orgAuthIds = vbi.readOrgAuthorityIds(orgAuthorities);\r
+ orgAuthorities = sample.readOrgAuthorities();\r
+ orgAuthIds = sample.readOrgAuthorityIds(orgAuthorities);\r
for (String orgAuthId : orgAuthIds) {\r
logger.info("Deleting all organizations for orgAuthority ...");\r
- vbi.deleteAllItemsForOrgAuth(orgAuthId);\r
+ sample.deleteAllItemsForOrgAuth(orgAuthId);\r
logger.info("Deleting orgAuthority ...");\r
- vbi.deleteOrgAuthority(orgAuthId);\r
+ sample.deleteOrgAuthority(orgAuthId);\r
}\r
\r
logger.info("Reading orgAuthorities after deletion ...");\r
- orgAuthorities = vbi.readOrgAuthorities();\r
- details = vbi.displayAllOrgAuthorities(orgAuthorities);\r
+ orgAuthorities = sample.readOrgAuthorities();\r
+ details = sample.displayAllOrgAuthorities(orgAuthorities);\r
logger.info(details);\r
\r
logger.info("Reading items in each orgAuthority after deletion ...");\r
- orgAuthIds = vbi.readOrgAuthorityIds(orgAuthorities);\r
+ orgAuthIds = sample.readOrgAuthorityIds(orgAuthorities);\r
for (String orgAuthId : orgAuthIds) {\r
- OrganizationsCommonList items = vbi.readItemsInOrgAuth(orgAuthId);\r
- details = vbi.displayAllOrganizations(items);\r
+ OrganizationsCommonList items = sample.readItemsInOrgAuth(orgAuthId);\r
+ details = sample.displayAllOrganizations(items);\r
logger.info(details);\r
}\r
\r
}\r
\r
// Create new authorities, each populated with organizations.\r
-\r
- /*\r
- final String acquisitionMethodsVocabName = "Acquisition Methods";\r
- final String entryMethodsVocabName = "Entry Methods";\r
- final String entryReasonsVocabName = "Entry Reasons";\r
- final String responsibleDeptsVocabName = "Responsible Departments";\r
-\r
- List<String> acquisitionMethodsEnumValues = \r
- Arrays.asList("Gift","Purchase","Exchange","Transfer","Treasure");\r
- List<String> entryMethodsEnumValues = \r
- Arrays.asList("In person","Post","Found on doorstep");\r
- List<String> entryReasonsEnumValues = \r
- Arrays.asList("Enquiry","Commission","Loan");\r
- List<String> respDeptNamesEnumValues = \r
- Arrays.asList("Antiquities","Architecture and Design","Decorative Arts",\r
- "Ethnography","Herpetology","Media and Performance Art",\r
- "Paintings and Sculpture","Paleobotany","Photographs",\r
- "Prints and Drawings");\r
+ Map<String, String> mmiOrgMap = new HashMap<String,String>();\r
+ mmiOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "MMI");\r
+ mmiOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "Museum of the Moving Image");\r
+ mmiOrgMap.put(OrganizationJAXBSchema.CONTACT_NAME, "Megan Forbes");\r
+ mmiOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "1984");\r
+ mmiOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, "Astoria, NY");\r
+ Map<String, String> pahmaOrgMap = new HashMap<String,String>();\r
+ pahmaOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "PAHMA");\r
+ pahmaOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "Phoebe A. Hearst Museum of Anthropology");\r
+ pahmaOrgMap.put(OrganizationJAXBSchema.NAME_ADDITIONS, "University of California, Berkeley");\r
+ pahmaOrgMap.put(OrganizationJAXBSchema.CONTACT_NAME, "Michael Black");\r
+ pahmaOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "1901");\r
+ pahmaOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, "Berkeley, CA");\r
+ Map<String, String> savoyOrgMap = new HashMap<String,String>();\r
+ savoyOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "Savoy Theatre");\r
+ savoyOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "1900");\r
+ savoyOrgMap.put(OrganizationJAXBSchema.DISSOLUTION_DATE, "1952");\r
+ savoyOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, "New York, NY");\r
+ List<Map<String, String>> orgMaps = \r
+ Arrays.asList(mmiOrgMap, pahmaOrgMap, savoyOrgMap );\r
\r
- vbi.createEnumeration(acquisitionMethodsVocabName, acquisitionMethodsEnumValues);\r
- vbi.createEnumeration(entryMethodsVocabName, entryMethodsEnumValues);\r
- vbi.createEnumeration(entryReasonsVocabName, entryReasonsEnumValues);\r
- vbi.createEnumeration(responsibleDeptsVocabName, respDeptNamesEnumValues);\r
- */\r
+ sample.createOrgAuthority("Sample Org Authority", orgMaps);\r
\r
logger.info("OrgAuthority Sample complete.");\r
\r
logger.info("Reading orgAuthorities and items ...");\r
// Get a list of orgAuthorities.\r
- orgAuthorities = vbi.readOrgAuthorities();\r
+ orgAuthorities = sample.readOrgAuthorities();\r
// For each orgAuthority ...\r
for (OrgauthoritiesCommonList.OrgauthorityListItem\r
orgAuthority : orgAuthorities.getOrgauthorityListItem()) {\r
logger.info(orgAuthority.getDisplayName());\r
// Get a list of the organizations in this orgAuthority.\r
OrganizationsCommonList items =\r
- vbi.readItemsInOrgAuth(orgAuthority.getCsid());\r
+ sample.readItemsInOrgAuth(orgAuthority.getCsid());\r
// For each organization ...\r
for (OrganizationsCommonList.OrganizationListItem\r
item : items.getOrganizationListItem()) {\r
if (RUN_ADDITIONAL_SAMPLES) {\r
\r
logger.info("Reading all orgAuthorities ...");\r
- details = vbi.displayAllOrgAuthorities(orgAuthorities);\r
+ details = sample.displayAllOrgAuthorities(orgAuthorities);\r
logger.info(details);\r
\r
logger.info("Reading all organizations ...");\r
- orgAuthIds = vbi.readOrgAuthorityIds(orgAuthorities);\r
+ orgAuthIds = sample.readOrgAuthorityIds(orgAuthorities);\r
for (String orgAuthId : orgAuthIds) {\r
- OrganizationsCommonList items = vbi.readItemsInOrgAuth(orgAuthId);\r
- details = vbi.displayAllOrganizations(items);\r
+ OrganizationsCommonList items = sample.readItemsInOrgAuth(orgAuthId);\r
+ details = sample.displayAllOrganizations(items);\r
logger.info(details);\r
}\r
\r