]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-2628: Fixed issue where the Movemement service was returning empty values...
authorAron Roberts <aron@socrates.berkeley.edu>
Thu, 12 Aug 2010 00:18:21 +0000 (00:18 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Thu, 12 Aug 2010 00:18:21 +0000 (00:18 +0000)
services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java
services/movement/service/src/main/java/org/collectionspace/services/movement/nuxeo/MovementDocumentModelHandler.java

index 18e191b734c4f90ffd1c0e5809282fd20c70b405..e3e08fde638a578bf417e222e374c0c940c4401d 100644 (file)
@@ -69,6 +69,8 @@ public class MovementServiceTest extends AbstractServiceTestImpl {
     
     /** The known resource id. */
     private String knownResourceId = null;
+
+    private final static String TIMESTAMP_UTC = GregorianCalendarDateTimeUtils.timestampUTC();
     
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
@@ -305,6 +307,15 @@ public class MovementServiceTest extends AbstractServiceTestImpl {
         MovementsCommon movement = (MovementsCommon) extractPart(input,
                 client.getCommonPartName(), MovementsCommon.class);
         Assert.assertNotNull(movement);
+
+        // Check the values of one or more date/time fields
+        if (logger.isDebugEnabled()) {
+            logger.debug("locationDate=" + movement.getLocationDate());
+            logger.debug("TIMESTAMP_UTC=" + TIMESTAMP_UTC);
+        }
+        Assert.assertTrue(movement.getLocationDate().equals(TIMESTAMP_UTC));
+        Assert.assertTrue(movement.getPlannedRemovalDate().equals(TIMESTAMP_UTC));
+        Assert.assertTrue(movement.getRemovalDate().equals(TIMESTAMP_UTC));
     }
 
     // Failure outcomes
@@ -733,13 +744,12 @@ public class MovementServiceTest extends AbstractServiceTestImpl {
      */
     private MultipartOutput createInstance(String movementReferenceNumber) {
         MovementsCommon movement = new MovementsCommon();
-        String timestampUTC = GregorianCalendarDateTimeUtils.timestampUTC();
         // FIXME: Values of currentLocation, normalLocation,
         // and movementContact should be refNames.
         movement.setCurrentLocation("currentLocation value");
         movement.setCurrentLocationFitness("currentLocationFitness value");
         movement.setCurrentLocationNote("currentLocationNote value");
-        movement.setLocationDate(timestampUTC);
+        movement.setLocationDate(TIMESTAMP_UTC);
         movement.setNormalLocation("normalLocation value");
         movement.setMovementContact("movementContact value");
         MovementMethodsList movementMethodsList = new MovementMethodsList();
@@ -752,8 +762,8 @@ public class MovementServiceTest extends AbstractServiceTestImpl {
         movement.setMovementMethods(movementMethodsList);
         movement.setMovementNote("movementNote value");
         movement.setMovementReferenceNumber(movementReferenceNumber);
-        movement.setPlannedRemovalDate(timestampUTC);
-        movement.setRemovalDate(timestampUTC);
+        movement.setPlannedRemovalDate(TIMESTAMP_UTC);
+        movement.setRemovalDate(TIMESTAMP_UTC);
         movement.setReasonForMove("reasonForMove value");
         MultipartOutput multipart = new MultipartOutput();
         OutputPart commonPart =
index 994573380d989f605b74352d22f93622abaed475..f606909c1f9fabc46fa2085f6c075018829847b2 100644 (file)
@@ -61,7 +61,6 @@ public class MovementDocumentModelHandler
     /** The Movement list. */
     private MovementsCommonList MovementList;
 
-
     /**
      * Gets the common part.
      *
@@ -102,29 +101,6 @@ public class MovementDocumentModelHandler
         this.MovementList = MovementList;
     }
 
-    /* (non-Javadoc)
-     * @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#extractPart(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, org.collectionspace.services.common.service.ObjectPartType)
-     */
-    @Override
-    protected Map<String, Object> extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta)
-            throws Exception {
-       Map<String, Object> unQObjectProperties = super.extractPart(docModel, schema, partMeta);
-
-       // For each dateTime field in the common part, return an
-        // appropriately formatted representation of its value.
-       if (partMeta.getLabel().equalsIgnoreCase(COMMON_PART_LABEL)) {
-            for(Entry<String, Object> entry : unQObjectProperties.entrySet()){
-                if (isDateTimeType(entry)) {
-                    entry.setValue(
-                        GregorianCalendarDateTimeUtils.formatAsISO8601Timestamp(
-                            (GregorianCalendar) entry.getValue()));
-                }
-            }
-       }
-
-        return unQObjectProperties;
-    }
-
     /**
      * Extract common part.
      *
@@ -190,15 +166,15 @@ public class MovementDocumentModelHandler
         return MovementConstants.NUXEO_SCHEMA_NAME + ":" + prop;
     }
 
-    private boolean isDateTimeType(Entry<String, Object> entry) {
+    private boolean isDateTimeType(Object obj) {
         boolean isDateTimeType = false;
 
-        if (entry.getValue() instanceof Calendar) {
+        if (obj != null && obj instanceof Calendar) {
             isDateTimeType = true;
         }
 
         return isDateTimeType;
     }
+
 }