/**
* LocationAuthorityClient.java
*
- * {Purpose of This Class}
- *
- * {Other Notes Relating to This Class (Optional)}
- *
- * $LastChangedBy: $ $LastChangedRevision: $ $LastChangedDate: $
- *
* This document is a part of the source code and related artifacts for
* CollectionSpace, an open source collections management system for museums and
* related institutions:
*
* http://www.collectionspace.org http://wiki.collectionspace.org
*
- * Copyright © 2009 {Contributing Institution}
+ * Copyright © 2009 The Regents of the University of California
*
* Licensed under the Educational Community License (ECL), Version 2.0. You may
* not use this file except in compliance with this License.
ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;\r
\r
String displayName = "";\r
- if (terms !=null && terms.size() > 0) {\r
+ if ((terms !=null) && (! terms.isEmpty())) {\r
displayName = terms.get(0).getTermDisplayName();\r
}\r
\r
*/
package org.collectionspace.services.location;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
import org.collectionspace.services.client.LocationAuthorityClient;
import org.collectionspace.services.common.vocabulary.AuthorityResource;
import org.collectionspace.services.location.nuxeo.LocationDocumentModelHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
+/**
+ * LocationAuthorityResource
+ *
+ * Handles, dispatches, and returns responses to RESTful requests related to
+ * Location authority-related resources.
+ */
@Path(LocationAuthorityClient.SERVICE_PATH)
@Consumes("application/xml")
@Produces("application/xml")
public class LocationAuthorityResource
extends AuthorityResource<LocationauthoritiesCommon, LocationDocumentModelHandler> {
- private final static String locationAuthorityServiceName = "locationauthorities";
- private final static String LOCATIONAUTHORITIES_COMMON = "locationauthorities_common";
- private final static String locationServiceName = "locations";
- private final static String LOCATIONS_COMMON = "locations_common";
final Logger logger = LoggerFactory.getLogger(LocationAuthorityResource.class);
public LocationAuthorityResource() {
super(LocationauthoritiesCommon.class, LocationAuthorityResource.class,
- LOCATIONAUTHORITIES_COMMON, LOCATIONS_COMMON);
+ LocationAuthorityClient.SERVICE_COMMON_PART_NAME, LocationAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
}
@Override
public String getServiceName() {
- return locationAuthorityServiceName;
- }
-
- public String getItemServiceName() {
- return locationServiceName;
+ return LocationAuthorityClient.SERVICE_NAME;
}
@Override
- public Class<LocationauthoritiesCommon> getCommonPartClass() {
- return LocationauthoritiesCommon.class;
+ public String getItemServiceName() {
+ return LocationAuthorityClient.SERVICE_ITEM_NAME;
}
@Override
ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;\r
\r
String displayName = "";\r
- if (terms !=null && terms.size() > 0) {\r
+ if ((terms !=null) && (! terms.isEmpty())) {\r
displayName = terms.get(0).getTermDisplayName();\r
}\r
\r
*/
package org.collectionspace.services.organization;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
import org.collectionspace.services.client.OrgAuthorityClient;
-import org.collectionspace.services.client.PersonAuthorityClient;
import org.collectionspace.services.contact.AuthorityResourceWithContacts;
import org.collectionspace.services.organization.nuxeo.OrganizationDocumentModelHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
+/**
+ * OrgAuthorityResource
+ *
+ * Handles, dispatches, and returns responses to RESTful requests
+ * related to Organization authority-related resources.
+ */
-@Path("/" + OrgAuthorityClient.SERVICE_PATH_COMPONENT)
+@Path(OrgAuthorityClient.SERVICE_PATH)
@Consumes("application/xml")
@Produces("application/xml")
public class OrgAuthorityResource extends
- AuthorityResourceWithContacts<OrgauthoritiesCommon, OrganizationDocumentModelHandler> {
+ AuthorityResourceWithContacts<OrgauthoritiesCommon, OrganizationDocumentModelHandler> {
- private final static String orgAuthorityServiceName = OrgAuthorityClient.SERVICE_NAME;
- private final static String ORGAUTHORITIES_COMMON = "orgauthorities_common";
-
- private final static String organizationServiceName = "organizations";
- private final static String ORGANIZATIONS_COMMON = "organizations_common";
-
final Logger logger = LoggerFactory.getLogger(OrgAuthorityResource.class);
public OrgAuthorityResource() {
- super(OrgauthoritiesCommon.class, OrgAuthorityResource.class,
- ORGAUTHORITIES_COMMON, ORGANIZATIONS_COMMON);
+ super(OrgauthoritiesCommon.class, OrgAuthorityResource.class,
+ OrgAuthorityClient.SERVICE_COMMON_PART_NAME, OrgAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
}
@Override
public String getServiceName() {
- return orgAuthorityServiceName;
- }
-
- public String getItemServiceName() {
- return organizationServiceName;
+ return OrgAuthorityClient.SERVICE_NAME;
}
@Override
- public Class<OrgauthoritiesCommon> getCommonPartClass() {
- return OrgauthoritiesCommon.class;
+ public String getItemServiceName() {
+ return OrgAuthorityClient.SERVICE_ITEM_NAME;
}
-
+
@Override
public String getItemTermInfoGroupXPathBase() {
return OrgAuthorityClient.TERM_INFO_GROUP_XPATH_BASE;
/**
- * This document is a part of the source code and related artifacts
- * for CollectionSpace, an open source collections management system
- * for museums and related institutions:
-
- * http://www.collectionspace.org
- * http://wiki.collectionspace.org
-
- * Copyright 2009 University of California at Berkeley
-
- * Licensed under the Educational Community License (ECL), Version 2.0.
- * You may not use this file except in compliance with this License.
-
- * You may obtain a copy of the ECL 2.0 License at
-
- * https://source.collectionspace.org/collection-space/LICENSE.txt
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * This document is a part of the source code and related artifacts for
+ * CollectionSpace, an open source collections management system for museums and
+ * related institutions:
+ *
+ * http://www.collectionspace.org http://wiki.collectionspace.org
+ *
+ * Copyright 2009 University of California at Berkeley
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0. You may
+ * not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ *
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.collectionspace.services.person;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
import org.collectionspace.services.client.PersonAuthorityClient;
import org.collectionspace.services.contact.AuthorityResourceWithContacts;
import org.collectionspace.services.person.nuxeo.PersonDocumentModelHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
+/**
+ * PersonAuthorityResource
+ *
+ * Handles, dispatches, and returns responses to RESTful requests related to
+ * Person authority-related resources.
+ */
@Path(PersonAuthorityClient.SERVICE_PATH)
@Consumes("application/xml")
@Produces("application/xml")
-public class PersonAuthorityResource extends
- AuthorityResourceWithContacts<PersonauthoritiesCommon, PersonDocumentModelHandler> {
+public class PersonAuthorityResource extends AuthorityResourceWithContacts<PersonauthoritiesCommon, PersonDocumentModelHandler> {
final Logger logger = LoggerFactory.getLogger(PersonAuthorityResource.class);
public PersonAuthorityResource() {
- super(PersonauthoritiesCommon.class, PersonAuthorityResource.class,
- PersonAuthorityClient.SERVICE_COMMON_PART_NAME, PersonAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
+ super(PersonauthoritiesCommon.class, PersonAuthorityResource.class,
+ PersonAuthorityClient.SERVICE_COMMON_PART_NAME, PersonAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
}
@Override
public String getItemServiceName() {
return PersonAuthorityClient.SERVICE_ITEM_NAME;
}
-
+
@Override
public String getItemTermInfoGroupXPathBase() {
return PersonAuthorityClient.TERM_INFO_GROUP_XPATH_BASE;
@Override
public Class<PersonauthoritiesCommon> getCommonPartClass() {
- return PersonauthoritiesCommon.class;
+ return PersonauthoritiesCommon.class;
}
-
}
-->
<xs:schema
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:ns="http://collectionspace.org/services/place"
- xmlns="http://collectionspace.org/services/place"
- targetNamespace="http://collectionspace.org/services/place"
- version="0.1"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:ns="http://collectionspace.org/services/place"
+ xmlns="http://collectionspace.org/services/place"
+ targetNamespace="http://collectionspace.org/services/place"
+ version="0.1"
>
<!-- See http://wiki.collectionspace.org/display/collectionspace/Place+Service+Home -->
<!-- Place Information Group -->
<xs:element name="inAuthority" type="xs:string" />
<xs:element name="shortIdentifier" type="xs:string"/>
<xs:element name="refName" type="xs:string"/>
- <xs:element name="termStatus" type="xs:string"/>
- <xs:element name="displayName" type="xs:string"/>
- <xs:element name="displayNameComputed" type="xs:boolean"/>
- <xs:element name="shortDisplayName" type="xs:string"/>
- <xs:element name="shortDisplayNameComputed" type="xs:boolean"/>
+
+ <!-- Term Information repeatable group -->
+ <xs:element name="placeTermGroupList" type="placeTermGroupList"/>
+
+ <!-- Does this pertain to the item or to individual terms? -->
<xs:element name="placeType" type="xs:string" />
+
<xs:element name="placeRecordAdminStatus" type="xs:string" />
+
+ <!-- Should this have been placeID? -->
<xs:element name="placeIdentifier" type="xs:string" />
- <xs:element name="placeNameGroupList" type="placeNameGroupList"/>
+
+ <!-- xs:element name="placeNameGroupList" type="placeNameGroupList"/ -->
+
<xs:element name="placeOwnerGroupList" type="placeOwnerGroupList"/>
<xs:element name="note" type="xs:string"/>
- <xs:element name="source" type="xs:string"/>
- <xs:element name="sourcePage" type="xs:string"/>
- <!-- Locality Information -->
+ <!-- Locality Information -->
<xs:element name="vCoordinates" type="xs:string"/>
<xs:element name="vLatitude" type="xs:string"/>
<xs:element name="vLongitude" type="xs:string"/>
<xs:element name="placeGeoRefGroupList" type="placeGeoRefGroupList"/>
-
+ <!--
<xs:complexType name="placeNameGroupList">
<xs:sequence>
<xs:element name="placeNameGroup" type="placeNameGroup" minOccurs="0" maxOccurs="unbounded"/>
<xs:complexType name="placeNameGroup">
<xs:sequence>
- <xs:element name="placeName" type="xs:string"/>
- <xs:element name="nameQualifiedName" type="xs:string"/>
- <xs:element name="nameLanguage" type="xs:string"/>
- <xs:element name="nameAbbrev" type="xs:string"/>
- <xs:element name="nameType" type="xs:string"/>
- <xs:element name="nameStatus" type="xs:string"/>
- <xs:element name="nameSource" type="xs:string"/>
- <xs:element name="nameSourceDetail" type="xs:string"/>
- <xs:element name="nameSourceRefId" type="xs:string"/>
- <xs:element name="nameNote" type="xs:string"/>
- <xs:element name="nameDateGroup" type="structuredDateGroup"/>
- <xs:element name="nameAdminStatus" type="xs:string"/>
+ <xs:element name="placeName" type="xs:string"/>
+ <xs:element name="nameQualifiedName" type="xs:string"/>
+ <xs:element name="nameLanguage" type="xs:string"/>
+ <xs:element name="nameAbbrev" type="xs:string"/>
+ <xs:element name="nameType" type="xs:string"/>
+ <xs:element name="nameStatus" type="xs:string"/>
+ <xs:element name="nameSource" type="xs:string"/>
+ <xs:element name="nameSourceDetail" type="xs:string"/>
+ <xs:element name="nameSourceRefId" type="xs:string"/>
+ <xs:element name="nameNote" type="xs:string"/>
+ <xs:element name="nameDateGroup" type="structuredDateGroup"/>
+ <xs:element name="nameAdminStatus" type="xs:string"/>
</xs:sequence>
</xs:complexType>
+ -->
<xs:complexType name="placeOwnerGroupList">
<xs:sequence>
<xs:complexType name="placeOwnerGroup">
<xs:sequence>
- <xs:element name="owner" type="xs:string"/>
- <xs:element name="ownershipDateGroup" type="structuredDateGroup"/>
- <xs:element name="ownershipNote" type="xs:string"/>
+ <xs:element name="owner" type="xs:string"/>
+ <xs:element name="ownershipDateGroup" type="structuredDateGroup"/>
+ <xs:element name="ownershipNote" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="geoRefVerificationStatus" type="xs:string"/>
<xs:element name="geoRefRemarks" type="xs:string"/>
<xs:element name="geoRefPlaceName" type="xs:string"/>
- </xs:sequence>
+ </xs:sequence>
</xs:complexType>
<!-- IMPORTANT: This structuredDateGroup MUST MATCH EXACTLY structuredDateGroups in other services, for example collectionobject.
<xs:element name="scalarValuesComputed" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
+
+ <xs:complexType name="placeTermGroupList">
+ <xs:sequence>
+ <xs:element name="placeTermGroup" type="placeTermGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="placeTermGroup">
+ <xs:sequence>
+ <!-- Common across all authority item terms -->
+ <xs:element name="termDisplayName" type="xs:string"/>
+ <xs:element name="termName" type="xs:string"/>
+ <xs:element name="termType" type="xs:string"/>
+ <xs:element name="termStatus" type="xs:string"/>
+ <xs:element name="termQualifier" type="xs:string"/>
+ <xs:element name="termLanguage" type="xs:string"/>
+ <xs:element name="termPrefForLang" type="xs:boolean"/>
+ <xs:element name="termSource" type="xs:string"/>
+ <xs:element name="termSourceDetail" type="xs:string"/>
+ <xs:element name="termSourceID" type="xs:string"/>
+ <xs:element name="termSourceNote" type="xs:string"/>
+ <!-- Specific to Place terms -->
+ <xs:element name="nameAbbrev" type="xs:string"/>
+ <xs:element name="nameType" type="xs:string"/>
+ <xs:element name="nameNote" type="xs:string"/>
+ <xs:element name="nameDateGroup" type="structuredDateGroup"/>
+ </xs:sequence>
+ </xs:complexType>
+
</xs:schema>
-/**
- * PlaceAuthorityClient.java
- *
- * {Purpose of This Class}
- *
- * {Other Notes Relating to This Class (Optional)}
- *
- * $LastChangedBy: $
- * $LastChangedRevision: $
- * $LastChangedDate: $
- *
- * This document is a part of the source code and related artifacts
- * for CollectionSpace, an open source collections management system
- * for museums and related institutions:
+/**
+ * This document is a part of the source code and related artifacts for
+ * CollectionSpace, an open source collections management system for museums and
+ * related institutions:
*
- * http://www.collectionspace.org
- * http://wiki.collectionspace.org
+ * http://www.collectionspace.org http://wiki.collectionspace.org
*
- * Copyright © 2009 {Contributing Institution}
+ * Copyright © 2009 The Regents of the University of California
*
- * Licensed under the Educational Community License (ECL), Version 2.0.
- * You may not use this file except in compliance with this License.
+ * Licensed under the Educational Community License (ECL), Version 2.0. You may
+ * not use this file except in compliance with this License.
*
* You may obtain a copy of the ECL 2.0 License at
* https://source.collectionspace.org/collection-space/LICENSE.txt
package org.collectionspace.services.client;
import org.collectionspace.services.place.PlacesCommon;
+
/**
* The Class PlaceAuthorityClient.
*/
public class PlaceAuthorityClient extends AuthorityClientImpl<PlacesCommon, PlaceAuthorityProxy> {
- public static final String SERVICE_NAME = "placeauthorities";
- public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
- public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
- public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public static final String TERM_INFO_GROUP_XPATH_BASE = "placeTermGroup";
- //
- // Subitem constants
- //
- public static final String SERVICE_ITEM_NAME = "places";
- public static final String SERVICE_ITEM_PAYLOAD_NAME = SERVICE_ITEM_NAME;
- //
- // Payload Part/Schema part names
- //
- public static final String SERVICE_COMMON_PART_NAME = SERVICE_NAME +
- PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
- public static final String SERVICE_ITEM_COMMON_PART_NAME = SERVICE_ITEM_NAME +
- PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
-
- @Override
- public String getServiceName() {
- return SERVICE_NAME;
- }
+
+ public static final String SERVICE_NAME = "placeauthorities";
+ public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
+ public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
+ public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
+ public static final String TERM_INFO_GROUP_XPATH_BASE = "placeTermGroupList";
+ //
+ // Subitem constants
+ //
+ public static final String SERVICE_ITEM_NAME = "places";
+ public static final String SERVICE_ITEM_PAYLOAD_NAME = SERVICE_ITEM_NAME;
+ //
+ // Payload Part/Schema part names
+ //
+ public static final String SERVICE_COMMON_PART_NAME = SERVICE_NAME
+ + PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
+ public static final String SERVICE_ITEM_COMMON_PART_NAME = SERVICE_ITEM_NAME
+ + PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
+
+ @Override
+ public String getServiceName() {
+ return SERVICE_NAME;
+ }
@Override
public String getServicePathComponent() {
@Override
public Class<PlaceAuthorityProxy> getProxyClass() {
- return PlaceAuthorityProxy.class;
+ return PlaceAuthorityProxy.class;
}
@Override
public String getInAuthority(PlacesCommon item) {
- return item.getInAuthority();
+ return item.getInAuthority();
}
@Override
public void setInAuthority(PlacesCommon item, String inAuthorityCsid) {
- item.setInAuthority(inAuthorityCsid);
+ item.setInAuthority(inAuthorityCsid);
}
}
import java.io.File;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Date;
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.PlaceJAXBSchema;
import org.collectionspace.services.client.test.ServiceRequestType;
+import org.collectionspace.services.common.api.Tools;
+import org.collectionspace.services.place.PlaceTermGroup;
+import org.collectionspace.services.place.PlaceTermGroupList;
import org.collectionspace.services.place.PlaceauthoritiesCommon;
-import org.collectionspace.services.place.PlaceNameGroup;
-import org.collectionspace.services.place.PlaceNameGroupList;
import org.collectionspace.services.place.PlacesCommon;
import org.dom4j.DocumentException;
import org.jboss.resteasy.client.ClientResponse;
*/
public static PoxPayloadOut createPlaceInstance(
String placeAuthRefName, Map<String, String> placeInfo,
- String headerLabel){
+ List<PlaceTermGroup> terms, String headerLabel){
PlacesCommon place = new PlacesCommon();
String shortId = placeInfo.get(PlaceJAXBSchema.SHORT_IDENTIFIER);
- String displayName = placeInfo.get(PlaceJAXBSchema.DISPLAY_NAME);
place.setShortIdentifier(shortId);
- String placeRefName = createPlaceRefName(placeAuthRefName, shortId, displayName);
- place.setRefName(placeRefName);
- String value = null;
- value = placeInfo.get(PlaceJAXBSchema.DISPLAY_NAME_COMPUTED);
- boolean displayNameComputed = (value==null) || value.equalsIgnoreCase("true");
- place.setDisplayNameComputed(displayNameComputed);
- if((value = (String)placeInfo.get(PlaceJAXBSchema.DISPLAY_NAME))!=null)
- place.setDisplayName(value);
- value = placeInfo.get(PlaceJAXBSchema.DISPLAY_NAME_COMPUTED);
- displayNameComputed = (value==null) || value.equalsIgnoreCase("true");
- place.setDisplayNameComputed(displayNameComputed);
- /* TODO - think about how much to support. This approach to the client
- * does not scale! We should really favor the document/payload approach. */
- if((value = (String)placeInfo.get(PlaceJAXBSchema.PLACE_NAME))!=null) {
- PlaceNameGroupList placeNameGroupList = new PlaceNameGroupList();
- List<PlaceNameGroup> placeNameGroups = placeNameGroupList.getPlaceNameGroup();
- PlaceNameGroup placeNameGroup = new PlaceNameGroup();
- placeNameGroup.setPlaceName(value);
- placeNameGroups.add(placeNameGroup);
- place.setPlaceNameGroupList(placeNameGroupList);
+
+ // Set values in the Term Information Group
+ PlaceTermGroupList termList = new PlaceTermGroupList();
+ if (terms == null || terms.isEmpty()) {
+ terms = getTermGroupInstance(getGeneratedIdentifier());
}
+ termList.getPlaceTermGroup().addAll(terms);
+ place.setPlaceTermGroupList(termList);
-
- if((value = (String)placeInfo.get(PlaceJAXBSchema.TERM_STATUS))!=null)
- place.setTermStatus(value);
-
PoxPayloadOut multipart = new PoxPayloadOut(PlaceAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
PayloadOutputPart commonPart = multipart.addPart(place,
MediaType.APPLICATION_XML_TYPE);
}
/**
- * @param vcsid CSID of the authority to create a new placplace
+ * @param vcsid CSID of the authority to create a new place
* @param placeAuthorityRefName The refName for the authority
* @param placeMap the properties for the new Place
* @param client the service client
*/
public static String createItemInAuthority(String vcsid,
String placeAuthorityRefName, Map<String,String> placeMap,
- PlaceAuthorityClient client ) {
+ List<PlaceTermGroup> terms, PlaceAuthorityClient client ) {
// Expected status code: 201 Created
int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
// Type of service request being tested
ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
- String displayName = placeMap.get(PlaceJAXBSchema.DISPLAY_NAME);
- String displayNameComputedStr = placeMap.get(PlaceJAXBSchema.DISPLAY_NAME_COMPUTED);
- boolean displayNameComputed = (displayNameComputedStr==null) || displayNameComputedStr.equalsIgnoreCase("true");
- if( displayName == null ) {
- if(!displayNameComputed) {
- throw new RuntimeException(
- "CreateItem: Must supply a displayName if displayNameComputed is set to false.");
- }
- /* Could try to pull name out of first placeNameGroup
- displayName =
- prepareDefaultDisplayName(
- placeMap.get(PlaceJAXBSchema.PLACE_NAME));
- */
- }
-
+ String displayName = "";
+ if ((terms !=null) && (! terms.isEmpty())) {
+ displayName = terms.get(0).getTermDisplayName();
+ }
if(logger.isDebugEnabled()){
- logger.debug("Import: Create Item: \""+displayName
- +"\" in placeAuthority: \"" + placeAuthorityRefName +"\"");
+ logger.debug("Creating item with display name: \"" + displayName
+ +"\" in locationAuthority: \"" + vcsid +"\"");
}
PoxPayloadOut multipart =
createPlaceInstance( placeAuthorityRefName,
- placeMap, client.getItemCommonPartName() );
+ placeMap, terms, client.getItemCommonPartName() );
String newID = null;
ClientResponse<Response> res = client.createItem(vcsid, multipart);
try {
return newStr.toString();
}
-
-
+ public static List<PlaceTermGroup> getTermGroupInstance(String identifier) {
+ if (Tools.isBlank(identifier)) {
+ identifier = getGeneratedIdentifier();
+ }
+ List<PlaceTermGroup> terms = new ArrayList<PlaceTermGroup>();
+ PlaceTermGroup term = new PlaceTermGroup();
+ term.setTermDisplayName(identifier);
+ term.setTermName(identifier);
+ terms.add(term);
+ return terms;
+ }
+
+ private static String getGeneratedIdentifier() {
+ return "id" + new Date().getTime();
+ }
+
}
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.collectionspace.services.PlaceJAXBSchema;
import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.AuthorityClient;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.place.PlaceauthoritiesCommon;
import org.collectionspace.services.place.PlacesCommon;
-import org.collectionspace.services.place.PlaceNameGroup;
-import org.collectionspace.services.place.PlaceNameGroupList;
-
import org.jboss.resteasy.client.ClientResponse;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
sanjoseMap.put(PlaceJAXBSchema.TERM_STATUS, TEST_STATUS);
String newID = PlaceAuthorityClientUtils.createItemInAuthority(vcsid,
- authRefName, sanjoseMap, client );
+ authRefName, sanjoseMap, terms client );
// Store the ID returned from the first item resource created
// for additional tests below.
return newID;
}
- /**
- * Verify item display name.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider="testName",
- dependsOnMethods = {"readItem", "updateItem"})
- public void verifyItemDisplayName(String testName) throws Exception {
- // Perform setup.
- setupRead();
- //
- // First, read our known item resource
- //
- PlaceAuthorityClient client = new PlaceAuthorityClient();
- ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
- PlacesCommon place = null;
- try {
- assertStatusCode(res, testName);
- // Check whether place has expected displayName.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- place = (PlacesCommon) extractPart(input,
- client.getItemCommonPartName(), PlacesCommon.class);
- Assert.assertNotNull(place);
- } finally {
- if (res != null) {
- res.releaseConnection();
- }
- }
- //
- // Now prepare an updated payload.
- //
- String displayName = place.getDisplayName();
- // Make sure displayName matches computed form
- String expectedDisplayName =
- PlaceAuthorityClientUtils.prepareDefaultDisplayName(TEST_NAME);
- Assert.assertNotNull(displayName, expectedDisplayName);
-
- // Update the shortName and verify the computed name is updated.
- place.setCsid(null);
- place.setDisplayNameComputed(true);
-
- // Verify the contents of this resource
- PlaceNameGroupList placeNameGroupList = place.getPlaceNameGroupList();
- Assert.assertNotNull(placeNameGroupList);
- List<PlaceNameGroup> placeNameGroups = placeNameGroupList.getPlaceNameGroup();
- Assert.assertNotNull(placeNameGroups);
- Assert.assertTrue(placeNameGroups.size() > 0);
- String placeName = placeNameGroups.get(0).getPlaceName();
- Assert.assertNotNull(placeName);
-
- // Update the contents of this resource.
- final String PLACE_NAME_ADDITION = "verify-item-place-name-updated";
- placeNameGroups.get(0).setPlaceName(PLACE_NAME_ADDITION + TEST_NAME);
- place.setPlaceNameGroupList(placeNameGroupList);
- if (logger.isDebugEnabled()) {
- logger.debug("to be updated Place");
- logger.debug(objectAsXmlString(place,
- PlacesCommon.class));
- }
- expectedDisplayName =
- PlaceAuthorityClientUtils.prepareDefaultDisplayName(PLACE_NAME_ADDITION + TEST_NAME);
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(PlaceAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), place);
-
- setupUpdate();
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- PlacesCommon updatedPlace = null;
- try {
- assertStatusCode(res, testName);
- // Retrieve the updated resource and verify that its contents exist.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- updatedPlace = (PlacesCommon) extractPart(input,
- client.getItemCommonPartName(), PlacesCommon.class);
- Assert.assertNotNull(updatedPlace);
- } finally {
- if (res != null) {
- res.releaseConnection();
- }
- }
-
- // Verify that the updated resource computes the right displayName.
- Assert.assertEquals(updatedPlace.getDisplayName(), expectedDisplayName,
- "Updated DisplayName in Place not reflected in computed DisplayName.");
- //
- // Now Update the displayName, not computed and verify the computed name is overriden.
- //
- place.setDisplayNameComputed(false);
- expectedDisplayName = "TestName";
- place.setDisplayName(expectedDisplayName);
-
- // Submit the updated resource to the service and store the response.
- output = new PoxPayloadOut(PlaceAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- commonPart = output.addPart(client.getItemCommonPartName(), place);
- setupUpdate();
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- try {
- assertStatusCode(res, testName);
- // Retrieve the updated resource and verify that its contents exist.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- updatedPlace = (PlacesCommon) extractPart(input,
- client.getItemCommonPartName(), PlacesCommon.class);
- Assert.assertNotNull(updatedPlace);
- } finally {
- if (res != null) {
- res.releaseConnection();
- }
- }
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedPlace.isDisplayNameComputed(), false,
- "Updated displayNameComputed in Place did not match submitted data.");
- // Verify that the updated resource computes the right displayName.
- Assert.assertEquals(updatedPlace.getDisplayName(),
- expectedDisplayName,
- "Updated DisplayName (not computed) in Place not stored.");
- }
-
/**
* Verify illegal item display name.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName",
- dependsOnMethods = {"verifyItemDisplayName"})
+ @Test(dataProvider="testName")
public void verifyIllegalItemDisplayName(String testName) throws Exception {
// Perform setup for read.
setupRead();
xmlns="http://collectionspace.org/services/place"
targetNamespace="http://collectionspace.org/services/place"
version="0.1"
- >
+>
<!-- avoid XmlRootElement nightnmare, see http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html-->
<xs:complexType>
<xs:sequence>
<!-- Common identifier -->
- <xs:element name="csid" type="xs:string" />
+ <xs:element name="csid" type="xs:string" />
<!-- Place Information Group -->
<!-- inAuthority is the csid of the owning PlaceAuthority -->
- <xs:element name="inAuthority" type="xs:string" />
- <xs:element name="shortIdentifier" type="xs:string"/>
- <xs:element name="refName" type="xs:string"/>
- <xs:element name="termStatus" type="xs:string"/>
- <xs:element name="displayName" type="xs:string"/>
- <xs:element name="displayNameComputed" type="xs:boolean"/>
- <xs:element name="shortDisplayName" type="xs:string"/>
- <xs:element name="shortDisplayNameComputed" type="xs:boolean"/>
- <xs:element name="placeType" type="xs:string" />
- <xs:element name="placeRecordAdminStatus" type="xs:string" />
- <xs:element name="placeIdentifier" type="xs:string" />
- <xs:element name="placeNameGroupList" type="placeNameGroupList"/>
- <xs:element name="placeOwnerGroupList" type="placeOwnerGroupList"/>
- <xs:element name="note" type="xs:string"/>
- <xs:element name="source" type="xs:string"/>
- <xs:element name="sourcePage" type="xs:string"/>
+ <xs:element name="inAuthority" type="xs:string" />
+ <xs:element name="shortIdentifier" type="xs:string"/>
+ <xs:element name="refName" type="xs:string"/>
+
+ <!-- Term Information repeatable group -->
+ <xs:element name="placeTermGroupList" type="placeTermGroupList"/>
+
+ <xs:element name="placeType" type="xs:string" />
+ <xs:element name="placeRecordAdminStatus" type="xs:string" />
+ <xs:element name="placeIdentifier" type="xs:string" />
+
+ <!-- xs:element name="placeNameGroupList" type="placeNameGroupList"/ -->
+
+ <xs:element name="placeOwnerGroupList" type="placeOwnerGroupList"/>
+ <xs:element name="note" type="xs:string"/>
<!-- Locality Information -->
- <xs:element name="vCoordinates" type="xs:string"/>
- <xs:element name="vLatitude" type="xs:string"/>
- <xs:element name="vLongitude" type="xs:string"/>
- <xs:element name="vCoordSys" type="xs:string"/>
- <xs:element name="vSpatialReferenceSystem" type="xs:string"/>
- <xs:element name="vCoordSource" type="xs:string"/>
- <xs:element name="vCoordSourceRefId" type="xs:string"/>
- <xs:element name="vUnitofMeasure" type="xs:string"/>
- <xs:element name="vElevation" type="xs:string"/>
- <xs:element name="minElevationInMeters" type="xs:decimal"/>
- <xs:element name="maxElevationInMeters" type="xs:decimal"/>
- <xs:element name="vDepth" type="xs:string"/>
- <xs:element name="minDepthInMeters" type="xs:decimal"/>
- <xs:element name="maxDepthInMeters" type="xs:decimal"/>
- <xs:element name="vDistanceAboveSurface" type="xs:string"/>
- <xs:element name="minDistanceAboveSurfaceInMeters" type="xs:decimal"/>
- <xs:element name="maxDistanceAboveSurfaceInMeters" type="xs:decimal"/>
+ <xs:element name="vCoordinates" type="xs:string"/>
+ <xs:element name="vLatitude" type="xs:string"/>
+ <xs:element name="vLongitude" type="xs:string"/>
+ <xs:element name="vCoordSys" type="xs:string"/>
+ <xs:element name="vSpatialReferenceSystem" type="xs:string"/>
+ <xs:element name="vCoordSource" type="xs:string"/>
+ <xs:element name="vCoordSourceRefId" type="xs:string"/>
+ <xs:element name="vUnitofMeasure" type="xs:string"/>
+ <xs:element name="vElevation" type="xs:string"/>
+ <xs:element name="minElevationInMeters" type="xs:decimal"/>
+ <xs:element name="maxElevationInMeters" type="xs:decimal"/>
+ <xs:element name="vDepth" type="xs:string"/>
+ <xs:element name="minDepthInMeters" type="xs:decimal"/>
+ <xs:element name="maxDepthInMeters" type="xs:decimal"/>
+ <xs:element name="vDistanceAboveSurface" type="xs:string"/>
+ <xs:element name="minDistanceAboveSurfaceInMeters" type="xs:decimal"/>
+ <xs:element name="maxDistanceAboveSurfaceInMeters" type="xs:decimal"/>
- <xs:element name="placeGeoRefGroupList" type="placeGeoRefGroupList"/>
+ <xs:element name="placeGeoRefGroupList" type="placeGeoRefGroupList"/>
</xs:sequence>
</xs:complexType>
</xs:element>
+ <!--
<xs:complexType name="placeNameGroupList">
<xs:sequence>
<xs:element name="placeNameGroup" type="placeNameGroup" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="nameAdminStatus" type="xs:string"/>
</xs:sequence>
</xs:complexType>
+ -->
<xs:complexType name="placeOwnerGroupList">
<xs:sequence>
<xs:element name="geoRefVerificationStatus" type="xs:string"/>
<xs:element name="geoRefRemarks" type="xs:string"/>
<xs:element name="geoRefPlaceName" type="xs:string"/>
- </xs:sequence>
+ </xs:sequence>
</xs:complexType>
<!-- IMPORTANT: This structuredDateGroup MUST MATCH EXACTLY structuredDateGroups in other services, for example collectionobject.
<xs:element name="scalarValuesComputed" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
+
+ <xs:complexType name="placeTermGroupList">
+ <xs:sequence>
+ <xs:element name="placeTermGroup" type="placeTermGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="placeTermGroup">
+ <xs:sequence>
+ <!-- Common across all authority item terms -->
+ <xs:element name="termDisplayName" type="xs:string"/>
+ <xs:element name="termName" type="xs:string"/>
+ <xs:element name="termType" type="xs:string"/>
+ <xs:element name="termStatus" type="xs:string"/>
+ <xs:element name="termQualifier" type="xs:string"/>
+ <xs:element name="termLanguage" type="xs:string"/>
+ <xs:element name="termPrefForLang" type="xs:boolean"/>
+ <xs:element name="termSource" type="xs:string"/>
+ <xs:element name="termSourceDetail" type="xs:string"/>
+ <xs:element name="termSourceID" type="xs:string"/>
+ <xs:element name="termSourceNote" type="xs:string"/>
+ <!-- Specific to Place terms -->
+ <xs:element name="nameAbbrev" type="xs:string"/>
+ <xs:element name="nameType" type="xs:string"/>
+ <xs:element name="nameNote" type="xs:string"/>
+ <xs:element name="nameDateGroup" type="structuredDateGroup"/>
+ </xs:sequence>
+ </xs:complexType>
</xs:schema>
/**
- * This document is a part of the source code and related artifacts
- * for CollectionSpace, an open source collections management system
- * for museums and related institutions:
-
- * http://www.collectionspace.org
- * http://wiki.collectionspace.org
-
- * Copyright 2009 University of California at Berkeley
-
- * Licensed under the Educational Community License (ECL), Version 2.0.
- * You may not use this file except in compliance with this License.
-
- * You may obtain a copy of the ECL 2.0 License at
-
- * https://source.collectionspace.org/collection-space/LICENSE.txt
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * This document is a part of the source code and related artifacts for
+ * CollectionSpace, an open source collections management system for museums and
+ * related institutions:
+ *
+ * http://www.collectionspace.org http://wiki.collectionspace.org
+ *
+ * Copyright 2009 University of California at Berkeley
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0. You may
+ * not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ *
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.collectionspace.services.place;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
import org.collectionspace.services.client.PlaceAuthorityClient;
import org.collectionspace.services.common.vocabulary.AuthorityResource;
import org.collectionspace.services.place.nuxeo.PlaceDocumentModelHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
+/**
+ * PlaceAuthorityResource
+ *
+ * Handles, dispatches, and returns responses to RESTful requests
+ * related to Place authority-related resources.
+ */
@Path(PlaceAuthorityClient.SERVICE_PATH)
@Consumes("application/xml")
@Produces("application/xml")
-public class PlaceAuthorityResource
- extends AuthorityResource<PlaceauthoritiesCommon,
- PlaceDocumentModelHandler> {
+public class PlaceAuthorityResource
+ extends AuthorityResource<PlaceauthoritiesCommon, PlaceDocumentModelHandler> {
- private final static String placeAuthorityServiceName = "placeauthorities";
- private final static String PLACEAUTHORITIES_COMMON = "placeauthorities_common";
-
- private final static String placeServiceName = "places";
- private final static String PLACES_COMMON = "places_common";
-
final Logger logger = LoggerFactory.getLogger(PlaceAuthorityResource.class);
public PlaceAuthorityResource() {
- super(PlaceauthoritiesCommon.class, PlaceAuthorityResource.class,
- PLACEAUTHORITIES_COMMON, PLACES_COMMON);
+ super(PlaceauthoritiesCommon.class, PlaceAuthorityResource.class,
+ PlaceAuthorityClient.SERVICE_COMMON_PART_NAME, PlaceAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
}
@Override
public String getServiceName() {
- return placeAuthorityServiceName;
+ return PlaceAuthorityClient.SERVICE_NAME;
}
+ @Override
public String getItemServiceName() {
- return placeServiceName;
+ return PlaceAuthorityClient.SERVICE_ITEM_NAME;
}
@Override
- public Class<PlaceauthoritiesCommon> getCommonPartClass() {
- return PlaceauthoritiesCommon.class;
+ public String getItemTermInfoGroupXPathBase() {
+ return PlaceAuthorityClient.TERM_INFO_GROUP_XPATH_BASE;
}
- @Override
- public String getItemTermInfoGroupXPathBase() {
- return PlaceAuthorityClient.TERM_INFO_GROUP_XPATH_BASE;
- }
}