incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1363549 - in /incubator/isis/trunk: examples/quickstart/dom/src/main/java/dom/todo/ examples/quickstart/exploration/config/ examples/quickstart/webapp/src/main/webapp/WEB-INF/ examples/quickstart/wicket/src/main/webapp/WEB-INF/ framework/c...
Date Thu, 19 Jul 2012 21:16:41 GMT
Author: danhaywood
Date: Thu Jul 19 21:16:40 2012
New Revision: 1363549

URL: http://svn.apache.org/viewvc?rev=1363549&view=rev
Log:
ISIS-14: working on the optimistic locking stuff

Modified:
    incubator/isis/trunk/examples/quickstart/dom/src/main/java/dom/todo/ToDoItem.java
    incubator/isis/trunk/examples/quickstart/exploration/config/isis.properties
    incubator/isis/trunk/examples/quickstart/webapp/src/main/webapp/WEB-INF/isis.properties
    incubator/isis/trunk/examples/quickstart/webapp/src/main/webapp/WEB-INF/persistor_datanucleus.properties
    incubator/isis/trunk/examples/quickstart/wicket/src/main/webapp/WEB-INF/isis.properties
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/FeatureType.java
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/facetprocessor/FacetProcessor.java
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/FacetedMethodsBuilder.java
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectSpecificationAbstract.java
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/IsisLifecycleListener.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/JdoVersionAnnotationFacetFactory.java

Modified: incubator/isis/trunk/examples/quickstart/dom/src/main/java/dom/todo/ToDoItem.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/examples/quickstart/dom/src/main/java/dom/todo/ToDoItem.java?rev=1363549&r1=1363548&r2=1363549&view=diff
==============================================================================
--- incubator/isis/trunk/examples/quickstart/dom/src/main/java/dom/todo/ToDoItem.java (original)
+++ incubator/isis/trunk/examples/quickstart/dom/src/main/java/dom/todo/ToDoItem.java Thu
Jul 19 21:16:40 2012
@@ -23,12 +23,16 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
+import javax.jdo.annotations.Extension;
 import javax.jdo.annotations.IdentityType;
+import javax.jdo.annotations.Version;
+import javax.jdo.annotations.VersionStrategy;
 
 import org.apache.isis.applib.AbstractDomainObject;
 import org.apache.isis.applib.annotation.Disabled;
 import org.apache.isis.applib.annotation.Hidden;
 import org.apache.isis.applib.annotation.MemberOrder;
+import org.apache.isis.applib.annotation.Title;
 
 @javax.jdo.annotations.PersistenceCapable(identityType=IdentityType.DATASTORE)
 @javax.jdo.annotations.Discriminator("TODO")
@@ -41,20 +45,16 @@ import org.apache.isis.applib.annotation
         name="todo_similarTo", language="JDOQL",  
         value="SELECT FROM dom.todo.ToDoItem WHERE ownedBy == :ownedBy && category
== :category")
 })
+@Version(strategy=VersionStrategy.VERSION_NUMBER, column="VERSION",
+extensions={@Extension(vendorName="datanucleus", key="field-name", value="version")})
 public class ToDoItem extends AbstractDomainObject {
 
     public static final List<String> CATEGORIES = Collections.unmodifiableList(Arrays.asList("Professional",
"Domestic", "Other"));
 
-    // {{ Title
-    public String title() {
-        return getDescription();
-    }
-
-    // }}
-
     // {{ Description
     private String description;
 
+    @Title
     @MemberOrder(sequence = "1")
     public String getDescription() {
         return description;
@@ -134,6 +134,39 @@ public class ToDoItem extends AbstractDo
     }
     // }}
 
+
+    // {{ Version (property)
+    private long version;
+
+    @Disabled
+    @MemberOrder(sequence = "3")
+    public long getVersion() {
+        return version;
+    }
+
+    public void setVersion(final long version) {
+        this.version = version;
+    }
+    // }}
+
+
+//    // {{ LastUpdatedAt (property)
+//    private java.util.Date lastUpdatedAt;
+//
+//    @Disabled
+//    @MemberOrder(sequence = "3")
+//    public java.util.Date getLastUpdatedAt() {
+//        return lastUpdatedAt;
+//    }
+//
+//    public void setLastUpdatedAt(final java.util.Date lastUpdatedAt) {
+//        this.lastUpdatedAt = lastUpdatedAt;
+//    }
+//    // }}
+
+
+
+
     // {{ injected: ToDoItems
     @SuppressWarnings("unused")
     private ToDoItems toDoItems;

Modified: incubator/isis/trunk/examples/quickstart/exploration/config/isis.properties
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/examples/quickstart/exploration/config/isis.properties?rev=1363549&r1=1363548&r2=1363549&view=diff
==============================================================================
--- incubator/isis/trunk/examples/quickstart/exploration/config/isis.properties (original)
+++ incubator/isis/trunk/examples/quickstart/exploration/config/isis.properties Thu Jul 19
21:16:40 2012
@@ -58,8 +58,8 @@
 #
 # NOTE:
 # * edit isis.services (below) and pom.xml to reference appropriate objstore-xxx module
-# * for jdo objectstore, also edit isis.reflector.facets and isis.reflector.class-substitutor
(below)
-# * for sql and jdo objectstores, also edit pom.xml to reference appropriate JDBC driver
+# * for datanucleus objectstore, also edit isis.reflector.facets and isis.reflector.class-substitutor
(below)
+# * for sql and datanucleus objectstores, also edit pom.xml to reference appropriate JDBC
driver
 # 
 
 isis.persistor=in-memory

Modified: incubator/isis/trunk/examples/quickstart/webapp/src/main/webapp/WEB-INF/isis.properties
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/examples/quickstart/webapp/src/main/webapp/WEB-INF/isis.properties?rev=1363549&r1=1363548&r2=1363549&view=diff
==============================================================================
--- incubator/isis/trunk/examples/quickstart/webapp/src/main/webapp/WEB-INF/isis.properties
(original)
+++ incubator/isis/trunk/examples/quickstart/webapp/src/main/webapp/WEB-INF/isis.properties
Thu Jul 19 21:16:40 2012
@@ -58,8 +58,8 @@
 #
 # NOTE:
 # * edit isis.services (below) and pom.xml to reference appropriate objstore-xxx module
-# * for jdo objectstore, also edit isis.reflector.facets and isis.reflector.class-substitutor
(below)
-# * for sql and jdo objectstores, also edit pom.xml to reference appropriate JDBC driver
+# * for datanucleus objectstore, also edit isis.reflector.facets and isis.reflector.class-substitutor
(below)
+# * for sql and datanucleus objectstores, also edit pom.xml to reference appropriate JDBC
driver
 # 
 
 #isis.persistor=in-memory

Modified: incubator/isis/trunk/examples/quickstart/webapp/src/main/webapp/WEB-INF/persistor_datanucleus.properties
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/examples/quickstart/webapp/src/main/webapp/WEB-INF/persistor_datanucleus.properties?rev=1363549&r1=1363548&r2=1363549&view=diff
==============================================================================
--- incubator/isis/trunk/examples/quickstart/webapp/src/main/webapp/WEB-INF/persistor_datanucleus.properties
(original)
+++ incubator/isis/trunk/examples/quickstart/webapp/src/main/webapp/WEB-INF/persistor_datanucleus.properties
Thu Jul 19 21:16:40 2012
@@ -29,7 +29,7 @@ isis.persistor.datanucleus.impl.datanucl
 
 
 # L2 cache (on by default)
-#isis.persistor.datanucleus.impl.datanucleus.cache.level2.type=none
+isis.persistor.datanucleus.impl.datanucleus.cache.level2.type=none
 
 
 

Modified: incubator/isis/trunk/examples/quickstart/wicket/src/main/webapp/WEB-INF/isis.properties
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/examples/quickstart/wicket/src/main/webapp/WEB-INF/isis.properties?rev=1363549&r1=1363548&r2=1363549&view=diff
==============================================================================
--- incubator/isis/trunk/examples/quickstart/wicket/src/main/webapp/WEB-INF/isis.properties
(original)
+++ incubator/isis/trunk/examples/quickstart/wicket/src/main/webapp/WEB-INF/isis.properties
Thu Jul 19 21:16:40 2012
@@ -58,8 +58,8 @@
 #
 # NOTE:
 # * edit isis.services (below) and pom.xml to reference appropriate objstore-xxx module
-# * for jdo objectstore, also edit isis.reflector.facets and isis.reflector.class-substitutor
(below)
-# * for sql and jdo objectstores, also edit pom.xml to reference appropriate JDBC driver
+# * for datanucleus objectstore, also edit isis.reflector.facets and isis.reflector.class-substitutor
(below)
+# * for sql and datanucleus objectstores, also edit pom.xml to reference appropriate JDBC
driver
 # 
 
 #isis.persistor=in-memory

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/FeatureType.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/FeatureType.java?rev=1363549&r1=1363548&r2=1363549&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/FeatureType.java
(original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/FeatureType.java
Thu Jul 19 21:16:40 2012
@@ -32,7 +32,14 @@ import org.apache.isis.core.metamodel.sp
 
 /**
  * Enumerates the features that a particular Facet can be applied to.
- * 
+ *
+ * <p>
+ * The class-level feature processing is typically performed by {@link FacetFactory}s 
+ * pertaining to {@link #OBJECT}, performed before the processing of class members.  
+ * However, {@link FacetFactory}s can also be associated with {@link #OBJECT_POST_PROCESSING},
+ * which is run after all members have been introspected. This is useful for facets
+ * (eg the JDO <tt>Version</tt> annotation) that references class members.
+ *  
  * <p>
  * TODO: should rationalize this and {@link ObjectSpecification#getResultType()}
  * . Note though that we don't distinguish value properties and reference
@@ -78,6 +85,15 @@ public enum FeatureType {
         public Identifier identifierFor(final Class<?> type, final Method method) {
             return null;
         }
+    },
+    OBJECT_POST_PROCESSING("Object post processing") {
+        /**
+         * The supplied method can be null; at any rate it will be ignored.
+         */
+        @Override
+        public Identifier identifierFor(final Class<?> type, final Method method) {
+            return Identifier.classIdentifier(type);
+        }
     };
 
     public final static List<FeatureType> COLLECTIONS_ONLY = ImmutableList.of(COLLECTION);
@@ -87,6 +103,7 @@ public enum FeatureType {
     public final static List<FeatureType> OBJECTS_ONLY = ImmutableList.of(OBJECT);
     public final static List<FeatureType> MEMBERS = ImmutableList.of(PROPERTY, COLLECTION,
ACTION);
     public final static List<FeatureType> OBJECTS_PROPERTIES_AND_COLLECTIONS = ImmutableList.of(OBJECT,
PROPERTY, COLLECTION);
+    public final static List<FeatureType> OBJECTS_POST_PROCESSING_ONLY = ImmutableList.of(OBJECT_POST_PROCESSING);
 
     /**
      * Use of this is discouraged; instead use multiple {@link FacetFactory}s

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/facetprocessor/FacetProcessor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/facetprocessor/FacetProcessor.java?rev=1363549&r1=1363548&r2=1363549&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/facetprocessor/FacetProcessor.java
(original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/facetprocessor/FacetProcessor.java
Thu Jul 19 21:16:40 2012
@@ -283,6 +283,13 @@ public class FacetProcessor implements R
         }
     }
 
+    public void processPost(final Class<?> cls, final MethodRemover methodRemover,
final FacetHolder facetHolder) {
+        final List<FacetFactory> factoryList = getFactoryListByFeatureType(FeatureType.OBJECT_POST_PROCESSING);
+        for (final FacetFactory facetFactory : factoryList) {
+            facetFactory.process(new ProcessClassContext(cls, removerElseNullRemover(methodRemover),
facetHolder));
+        }
+    }
+
     /**
      * Attaches all facets applicable to the provided {@link FeatureType type of
      * feature} to the supplied {@link FacetHolder}.

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/FacetedMethodsBuilder.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/FacetedMethodsBuilder.java?rev=1363549&r1=1363548&r2=1363549&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/FacetedMethodsBuilder.java
(original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/FacetedMethodsBuilder.java
Thu Jul 19 21:16:40 2012
@@ -452,6 +452,21 @@ public class FacetedMethodsBuilder {
         return true;
     }
 
+
+    // ////////////////////////////////////////////////////////////////////////////
+    // introspect class post processing
+    // ////////////////////////////////////////////////////////////////////////////
+
+    public void introspectClassPostProcessing() {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("introspecting " + getClassName() + ": class-level post-processing");
+        }
+
+        // process facets at object level
+        // this will also remove some methods, such as the superclass methods.
+        getFacetProcessor().processPost(introspectedClass, methodRemover, spec);
+    }
+
     // ////////////////////////////////////////////////////////////////////////////
     // Helpers for finding and removing methods.
     // ////////////////////////////////////////////////////////////////////////////

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectSpecificationAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectSpecificationAbstract.java?rev=1363549&r1=1363548&r2=1363549&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectSpecificationAbstract.java
(original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectSpecificationAbstract.java
Thu Jul 19 21:16:40 2012
@@ -429,7 +429,7 @@ public abstract class ObjectSpecificatio
     @Override
     public String getSingularName() {
         final NamedFacet namedFacet = getFacet(NamedFacet.class);
-        return namedFacet.value();
+        return namedFacet != null? namedFacet.value() : this.getFullIdentifier();
     }
 
     /**

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java?rev=1363549&r1=1363548&r2=1363549&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
(original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
Thu Jul 19 21:16:40 2012
@@ -180,6 +180,8 @@ public class ObjectSpecificationDefault 
         final OrderSet actionOrderSet = getMemberLayoutArranger().createActionOrderSetFor(this,
actionFacetedMethods);
         addObjectActions(asObjectActions(actionOrderSet));
 
+        facetedMethodsBuilder.introspectClassPostProcessing();
+
         updateFromFacetValues();
 
         facetedMethodsBuilder = null;

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/IsisLifecycleListener.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/IsisLifecycleListener.java?rev=1363549&r1=1363548&r2=1363549&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/IsisLifecycleListener.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/IsisLifecycleListener.java
Thu Jul 19 21:16:40 2012
@@ -1,6 +1,7 @@
 package org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence;
 
 import java.text.MessageFormat;
+import java.util.Date;
 import java.util.Map;
 
 import javax.jdo.JDOHelper;
@@ -19,17 +20,19 @@ import com.google.common.collect.Maps;
 
 import org.apache.log4j.Logger;
 
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.commons.exceptions.IsisException;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.ResolveState;
 import org.apache.isis.core.metamodel.adapter.oid.Oid;
 import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.version.SerialNumberVersion;
+import org.apache.isis.core.metamodel.adapter.version.Version;
 import org.apache.isis.core.metamodel.facets.object.callbacks.CallbackFacet;
 import org.apache.isis.core.metamodel.facets.object.callbacks.CallbackUtils;
 import org.apache.isis.core.metamodel.facets.object.callbacks.PersistedCallbackFacet;
 import org.apache.isis.core.metamodel.facets.object.callbacks.UpdatedCallbackFacet;
 import org.apache.isis.runtimes.dflt.runtime.persistence.PersistorUtil;
-import org.apache.isis.runtimes.dflt.runtime.persistence.adaptermanager.AdapterManagerDefault;
 import org.apache.isis.runtimes.dflt.runtime.persistence.adaptermanager.AdapterManagerExtended;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.OidGenerator;
@@ -90,27 +93,28 @@ public class IsisLifecycleListener imple
         final PersistenceCapable pojo = persistenceCapableFor(event);
         
         final RootOid oid ;
-        ObjectAdapter existingAdapterIfAny = getAdapterManager().getAdapterFor(pojo);
-        if(existingAdapterIfAny != null) {
+        ObjectAdapter adapter = getAdapterManager().getAdapterFor(pojo);
+        if(adapter != null) {
             ensureRootObject(event);
-            oid = (RootOid) existingAdapterIfAny.getOid();
+            oid = (RootOid) adapter.getOid();
         } else {
             final OidGenerator oidGenerator = getOidGenerator();
             oid = oidGenerator.createPersistent(pojo, null);
             
             // it's possible that there is already an adapter for this Oid, ie from ObjectStore#resolveImmediately()
-            existingAdapterIfAny = getAdapterManager().getAdapterFor(oid);
-            if(existingAdapterIfAny != null) {
-                getAdapterManager().removeAdapter(existingAdapterIfAny);
-                existingAdapterIfAny.replacePojo(pojo);
-                getAdapterManager().addExistingAdapter(existingAdapterIfAny);
+            adapter = getAdapterManager().getAdapterFor(oid);
+            if(adapter != null) {
+                getAdapterManager().removeAdapter(adapter);
+                adapter.replacePojo(pojo);
+                getAdapterManager().addExistingAdapter(adapter);
             } else {
                 PersistenceSessionHydrator hydrator = getPersistenceSession();
-                ObjectAdapter adapter = hydrator.recreateAdapter(oid, pojo);
+                adapter = hydrator.recreateAdapter(oid, pojo);
                 PersistorUtil.startResolving(adapter);
                 PersistorUtil.endResolving(adapter);
             }
         }
+        adapter.setVersion(getVersionIfAny(pojo));
 
         ensureFrameworksInAgreement(event);
     }
@@ -165,6 +169,8 @@ public class IsisLifecycleListener imple
         }
         
         clearDirtyFor(adapter);
+        
+        adapter.setVersion(getVersionIfAny(pojo));
         CallbackUtils.callCallback(adapter, callbackFacetClass);
 
         ensureFrameworksInAgreement(event);
@@ -386,6 +392,15 @@ public class IsisLifecycleListener imple
         return jdoObjectId;
     }
 
+    private Version getVersionIfAny(final PersistenceCapable pojo) {
+        Object jdoVersion = pojo.jdoGetVersion();
+        if(jdoVersion instanceof Long) {
+            return new SerialNumberVersion((Long) jdoVersion, getAuthenticationSession().getUserName(),
new Date()); 
+        } 
+        return null;
+    }
+
+
     // /////////////////////////////////////////////////////////
     // Dependencies (from context)
     // /////////////////////////////////////////////////////////
@@ -402,4 +417,9 @@ public class IsisLifecycleListener imple
         return IsisContext.getPersistenceSession();
     }
 
+    protected AuthenticationSession getAuthenticationSession() {
+        return IsisContext.getAuthenticationSession();
+    }
+
+
 }

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/JdoVersionAnnotationFacetFactory.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/JdoVersionAnnotationFacetFactory.java?rev=1363549&r1=1363548&r2=1363549&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/JdoVersionAnnotationFacetFactory.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/JdoVersionAnnotationFacetFactory.java
Thu Jul 19 21:16:40 2012
@@ -18,6 +18,7 @@
  */
 package org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.version;
 
+import javax.jdo.annotations.Extension;
 import javax.jdo.annotations.Version;
 
 import org.apache.isis.core.metamodel.facetapi.FacetUtil;
@@ -29,7 +30,7 @@ import org.apache.isis.core.metamodel.sp
 public class JdoVersionAnnotationFacetFactory extends AnnotationBasedFacetFactoryAbstract
{
 
     public JdoVersionAnnotationFacetFactory() {
-        super(FeatureType.OBJECTS_ONLY);
+        super(FeatureType.OBJECTS_POST_PROCESSING_ONLY);
     }
 
     @Override
@@ -39,7 +40,7 @@ public class JdoVersionAnnotationFacetFa
             return;
         }
         final ObjectSpecification objSpec = (ObjectSpecification) processClassContext.getFacetHolder();
-        String propertyId = annotation.column();
+        String propertyId = getPropertyId(annotation);
         ObjectAssociation otoa = objSpec.getAssociation(propertyId);
         if (otoa == null) {
             throw new RuntimeException("No such property '" + propertyId + "'");
@@ -50,4 +51,14 @@ public class JdoVersionAnnotationFacetFa
         FacetUtil.addFacet(new OptionalFacetDerivedFromJdoVersionAnnotation(otoa));
     }
 
+    private static String getPropertyId(final Version annotation) {
+        final Extension[] extensions = annotation.extensions();
+        for(Extension extension: extensions) {
+            if("datanucleus".equals(extension.vendorName()) && "field-name".equals(extension.key()))
{
+                return  extension.value();
+            }
+        }
+        return annotation.column();
+    }
+
 }



Mime
View raw message