]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-1028
authorLaramie Crocker <laramie@berkeley.edu>
Fri, 12 Nov 2010 18:59:56 +0000 (18:59 +0000)
committerLaramie Crocker <laramie@berkeley.edu>
Fri, 12 Nov 2010 18:59:56 +0000 (18:59 +0000)
3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/schemas/collectionspace_core.xsd
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java

index c7f45ea67fc0710e811907bde4e168fe0db389b3..7ef65b122a9203047627434a1ac8fca78e33ea69 100644 (file)
     xmlns="http://collectionspace.org/collectionspace_core/"\r
     targetNamespace="http://collectionspace.org/collectionspace_core/"\r
     version="0.1">\r
+         \r
 \r
-    <xs:element name="tenantId" type="xs:string"/>    \r
+    <xs:element name="tenantId" type="xs:string"/>\r
+    <!--<xs:element name="createdAt" type="xs:string"/>-->\r
+    <xs:element name="createdAt" type="xs:dateTime"/>\r
+    <xs:element name="updatedAt" type="xs:dateTime"/>\r
 </xs:schema>\r
index e46e751c3a8958cc69462c6e6ba528870a486889..c6475100a80ba65437c1cab1a5f93422d45a516a 100644 (file)
@@ -57,7 +57,9 @@ public abstract class DocumentModelHandler<T, TL>
 
     public final static String COLLECTIONSPACE_CORE_SCHEMA = "collectionspace_core";
     public final static String COLLECTIONSPACE_CORE_TENANTID = "tenantId";
-    
+    public final static String COLLECTIONSPACE_CORE_CREATED_AT = "createdAt";
+    public final static String COLLECTIONSPACE_CORE_UPDATED_AT = "updatedAt";
+
     /**
      * getRepositorySession returns Nuxeo Repository Session
      * @return
index 6473591493c7f96fbedb9911ae113ebb249826a1..00f61d937c5748dacf1d73ae02ad84d08d7b5015 100644 (file)
@@ -25,6 +25,7 @@ import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
 import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
 import org.collectionspace.services.common.query.IQueryManager;
 import org.collectionspace.services.common.query.QueryContext;
 import org.collectionspace.services.common.repository.RepositoryClient;
@@ -100,12 +101,20 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
         documentModel.setProperty(DocumentModelHandler.COLLECTIONSPACE_CORE_SCHEMA,
                 DocumentModelHandler.COLLECTIONSPACE_CORE_TENANTID,
                 ctx.getTenantId());
+
+        String now = GregorianCalendarDateTimeUtils.timestampUTC();
+        
         switch (action) {
             case CREATE:
-                //add creation date value
+                documentModel.setProperty(DocumentModelHandler.COLLECTIONSPACE_CORE_SCHEMA,
+                                DocumentModelHandler.COLLECTIONSPACE_CORE_CREATED_AT,
+                                now);
                 break;
             case UPDATE:
-                //add update value
+                documentModel.setProperty(DocumentModelHandler.COLLECTIONSPACE_CORE_SCHEMA,
+                                DocumentModelHandler.COLLECTIONSPACE_CORE_UPDATED_AT,
+                                now);
+
                 break;
             default:
         }
@@ -115,8 +124,6 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
      * create document in the Nuxeo repository
      *
      * @param ctx service context under which this method is invoked
-     * @param docType
-     *            of the document created
      * @param handler
      *            should be used by the caller to provide and transform the
      *            document
@@ -331,7 +338,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
     /**
      * find wrapped documentModel from the Nuxeo repository
      * @param ctx service context under which this method is invoked
-     * @param where NXQL where clause to get the document
+     * @param whereClause where NXQL where clause to get the document
      * @throws DocumentException
      */
     @Override
@@ -381,7 +388,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
     /**
      * find doc and return CSID from the Nuxeo repository
      * @param ctx service context under which this method is invoked
-     * @param where NXQL where clause to get the document
+     * @param whereClause where NXQL where clause to get the document
      * @throws DocumentException
      */
     @Override
@@ -411,8 +418,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
     /**
      * Find a list of documentModels from the Nuxeo repository
      * @param docTypes a list of DocType names to match
-     * @param where the clause to qualify on
-     * @param domain the domain for the associated services
+     * @param  whereClause where the clause to qualify on
      * @return
      */
     @Override
@@ -637,7 +643,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
             ((DocumentModelHandler) handler).setRepositorySession(repoSession);
             DocumentWrapper<DocumentModel> wrapDoc = new DocumentWrapperImpl<DocumentModel>(doc);
             handler.handle(Action.UPDATE, wrapDoc);
-            setCollectionSpaceCoreValues(ctx, doc, Action.CREATE);
+            setCollectionSpaceCoreValues(ctx, doc, Action.UPDATE);
             repoSession.saveDocument(doc);
             repoSession.save();
             handler.complete(Action.UPDATE, wrapDoc);
@@ -841,7 +847,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
      * Append a WHERE clause to the NXQL query.
      *
      * @param query         The NXQL query to which the WHERE clause will be appended.
-     * @param querycontext  The query context, which provides the WHERE clause to append.
+     * @param queryContext  The query context, which provides the WHERE clause to append.
      */
     private final void appendNXQLWhere(StringBuilder query, QueryContext queryContext) {
         //
@@ -876,7 +882,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
      * Append an ORDER BY clause to the NXQL query.
      *
      * @param query         the NXQL query to which the ORDER BY clause will be appended.
-     * @param querycontext  the query context, which provides the ORDER BY clause to append.
+     * @param queryContext  the query context, which provides the ORDER BY clause to append.
      *
      * @throws DocumentException  if the supplied value of the orderBy clause is not valid.
      *