import java.io.File;
import java.util.ArrayList;
import java.util.Date;
+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.commons.io.FileUtils;
-
+import org.collectionspace.services.ConceptJAXBSchema;
import org.collectionspace.services.client.test.ServiceRequestType;
import org.collectionspace.services.common.api.Tools;
+
import org.collectionspace.services.concept.ConceptTermGroup;
+import org.collectionspace.services.concept.ConceptTermGroupList;
import org.collectionspace.services.concept.ConceptauthoritiesCommon;
+import org.collectionspace.services.concept.ConceptsCommon;
+import org.apache.commons.io.FileUtils;
import org.dom4j.DocumentException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return multipart;
}
+
+ /**
+ * Creates a concept instance.
+ *
+ */
+ public static PoxPayloadOut createConceptInstance(
+ Map<String, String> conceptInfo,
+ List<ConceptTermGroup> terms,
+ String headerLabel) {
+
+ ConceptsCommon concept = new ConceptsCommon();
+ String shortId = conceptInfo.get(ConceptJAXBSchema.SHORT_IDENTIFIER);
+ if (shortId == null || shortId.isEmpty()) {
+ throw new IllegalArgumentException("shortIdentifier cannot be null or empty");
+ }
+ concept.setShortIdentifier(shortId);
+
+ // Set values in the Term Information Group
+ ConceptTermGroupList termList = new ConceptTermGroupList();
+ if (terms == null || terms.isEmpty()) {
+ terms = getTermGroupInstance(getGeneratedIdentifier());
+ }
+ termList.getConceptTermGroup().addAll(terms);
+ concept.setConceptTermGroupList(termList);
+
+ PoxPayloadOut multipart = new PoxPayloadOut(ConceptAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = multipart.addPart(concept, MediaType.APPLICATION_XML_TYPE);
+ commonPart.setLabel(headerLabel);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("to be created, concept common ", concept, ConceptsCommon.class);
+ }
+
+ return multipart;
+ }
/**
* @param commonPartXML the XML payload for the common part.
return multipart;
}
+
+ public static List<ConceptTermGroup> getTermGroupInstance(String shortIdentifier, String displayName) {
+ if (Tools.isBlank(shortIdentifier)) {
+ shortIdentifier = getGeneratedIdentifier();
+ }
+ if (Tools.isBlank(shortIdentifier)) {
+ displayName = shortIdentifier;
+ }
+
+ List<ConceptTermGroup> terms = new ArrayList<ConceptTermGroup>();
+ ConceptTermGroup term = new ConceptTermGroup();
+ term.setTermDisplayName(displayName);
+ term.setTermName(shortIdentifier);
+ terms.add(term);
+ return terms;
+ }
+
+ /*
+ * Create a very simple Concept term -just a short ID and display name.
+ */
+ public static PoxPayloadOut createConceptInstance(String shortIdentifier, String displayName,
+ String headerLabel) {
+ List<ConceptTermGroup> terms = getTermGroupInstance(shortIdentifier, displayName);
+
+ Map<String, String> conceptInfo = new HashMap<String, String>();
+ conceptInfo.put(ConceptJAXBSchema.SHORT_IDENTIFIER, shortIdentifier);
+
+ return createConceptInstance(conceptInfo, terms, headerLabel);
+ }
public static String createItemInAuthority(String vcsid,
String commonPartXML,
import org.collectionspace.services.OrganizationJAXBSchema;
import org.collectionspace.services.client.test.ServiceRequestType;
import org.collectionspace.services.common.api.Tools;
+
+import org.collectionspace.services.organization.StructuredDateGroup;
import org.collectionspace.services.organization.ContactNameList;
import org.collectionspace.services.organization.FunctionList;
import org.collectionspace.services.organization.GroupList;
import org.collectionspace.services.organization.OrgauthoritiesCommon;
import org.collectionspace.services.organization.OrgTermGroup;
import org.collectionspace.services.organization.OrgTermGroupList;
+
import org.jboss.resteasy.client.ClientResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.collectionspace.services.organization.StructuredDateGroup;
/**
* OrgAuthorityClientUtils.
return result;
}
+
+ public static List<OrgTermGroup> getTermGroupInstance(String shortIdentifier, String displayName) {
+ if (Tools.isBlank(shortIdentifier)) {
+ shortIdentifier = getGeneratedIdentifier();
+ }
+ if (Tools.isBlank(shortIdentifier)) {
+ displayName = shortIdentifier;
+ }
+
+ List<OrgTermGroup> terms = new ArrayList<OrgTermGroup>();
+ OrgTermGroup term = new OrgTermGroup();
+ term.setTermDisplayName(displayName);
+ term.setTermName(shortIdentifier);
+ terms.add(term);
+ return terms;
+ }
+
+ /*
+ * Create a very simple Organization term -just a short ID and display name.
+ */
+ public static PoxPayloadOut createOrganizationInstance(String shortIdentifier, String displayName,
+ String headerLabel) {
+ List<OrgTermGroup> terms = getTermGroupInstance(shortIdentifier, displayName);
+
+ Map<String, String> orgInfo = new HashMap<String, String>();
+ orgInfo.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortIdentifier);
+
+ final Map<String, List<String>> EMPTY_ORG_REPEATABLES_INFO = new HashMap<String, List<String>>();
+
+ return createOrganizationInstance(null, orgInfo, terms, EMPTY_ORG_REPEATABLES_INFO, headerLabel);
+ }
/**
* Creates the organization instance.
* @return the multipart output
*/
public static PoxPayloadOut createOrganizationInstance(
- String orgAuthRefName, Map<String, String> orgInfo, List<OrgTermGroup> terms,
- Map<String, List<String>> orgRepeatablesInfo, String headerLabel){
+ String orgAuthRefName,
+ Map<String, String> orgInfo,
+ List<OrgTermGroup> terms,
+ Map<String, List<String>> orgRepeatablesInfo,
+ String headerLabel) {
+
OrganizationsCommon organization = new OrganizationsCommon();
- String shortId = orgInfo.get(OrganizationJAXBSchema.SHORT_IDENTIFIER);
- if (shortId == null || shortId.isEmpty()) {
- throw new IllegalArgumentException("shortIdentifier cannot be null or empty");
- }
- organization.setShortIdentifier(shortId);
+ String shortId = orgInfo.get(OrganizationJAXBSchema.SHORT_IDENTIFIER);
+ if (shortId == null || shortId.isEmpty()) {
+ throw new IllegalArgumentException("shortIdentifier cannot be null or empty");
+ }
+ organization.setShortIdentifier(shortId);
String value = null;
List<String> values = null;
termList.getOrgTermGroup().addAll(terms);
organization.setOrgTermGroupList(termList);
- if((values = (List<String>)orgRepeatablesInfo.get(OrganizationJAXBSchema.CONTACT_NAMES))!=null) {
+ if ((values = (List<String>)orgRepeatablesInfo.get(OrganizationJAXBSchema.CONTACT_NAMES))!=null) {
ContactNameList contactsList = new ContactNameList();
List<String> contactNames = contactsList.getContactName();
contactNames.addAll(values);
organization.setContactNames(contactsList);
}
- if((value = (String)orgInfo.get(OrganizationJAXBSchema.FOUNDING_DATE))!=null) {
+ if ((value = (String)orgInfo.get(OrganizationJAXBSchema.FOUNDING_DATE))!=null) {
StructuredDateGroup foundingDate = new StructuredDateGroup();
foundingDate.setDateDisplayDate(value);
organization.setFoundingDateGroup(foundingDate);
}
- if((value = (String)orgInfo.get(OrganizationJAXBSchema.DISSOLUTION_DATE))!=null) {
+ if ((value = (String)orgInfo.get(OrganizationJAXBSchema.DISSOLUTION_DATE))!=null) {
StructuredDateGroup dissolutionDate = new StructuredDateGroup();
dissolutionDate.setDateDisplayDate(value);
organization.setDissolutionDateGroup(dissolutionDate);
}
- if((value = (String)orgInfo.get(OrganizationJAXBSchema.FOUNDING_PLACE))!=null)
+ if ((value = (String)orgInfo.get(OrganizationJAXBSchema.FOUNDING_PLACE))!=null)
organization.setFoundingPlace(value);
if((values = (List<String>)orgRepeatablesInfo.get(OrganizationJAXBSchema.GROUPS))!=null) {
GroupList groupsList = new GroupList();
groups.addAll(values);
organization.setGroups(groupsList);
}
- if((values = (List<String>)orgRepeatablesInfo.get(OrganizationJAXBSchema.FUNCTIONS))!=null) {
+ if ((values = (List<String>)orgRepeatablesInfo.get(OrganizationJAXBSchema.FUNCTIONS))!=null) {
FunctionList functionsList = new FunctionList();
List<String> functions = functionsList.getFunction();
functions.addAll(values);
organization.setFunctions(functionsList);
}
- if((values = (List<String>)orgRepeatablesInfo.get(OrganizationJAXBSchema.HISTORY_NOTES))!=null) {
+ if ((values = (List<String>)orgRepeatablesInfo.get(OrganizationJAXBSchema.HISTORY_NOTES))!=null) {
HistoryNoteList historyNotesList = new HistoryNoteList();
List<String> historyNotes = historyNotesList.getHistoryNote();
historyNotes.addAll(values);
commonPart.setLabel(headerLabel);
if(logger.isDebugEnabled()){
- logger.debug("to be created, organization common ", organization, OrganizationsCommon.class);
+ logger.debug("to be created, organization common ", organization, OrganizationsCommon.class);
}
return multipart;