incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1375288 [2/2] - in /incubator/isis/trunk: examples/quickstart/dom/ examples/quickstart/dom/src/main/java/dom/todo/ examples/quickstart/webapp/ examples/quickstart/webapp/src/main/webapp/WEB-INF/ examples/quickstart/wicket/ examples/quickst...
Date Mon, 20 Aug 2012 22:41:04 GMT
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=1375288&r1=1375287&r2=1375288&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
Mon Aug 20 22:41:02 2012
@@ -1,7 +1,9 @@
 package org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence;
 
 import java.text.MessageFormat;
+import java.util.Arrays;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 import javax.jdo.JDOHelper;
@@ -16,10 +18,7 @@ import javax.jdo.listener.LoadLifecycleL
 import javax.jdo.listener.StoreLifecycleListener;
 import javax.jdo.spi.PersistenceCapable;
 
-import com.google.common.collect.Maps;
-
-import org.apache.log4j.Logger;
-
+import org.apache.isis.applib.filter.Filter;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.commons.exceptions.IsisException;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -33,13 +32,17 @@ import org.apache.isis.core.metamodel.fa
 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.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.runtimes.dflt.runtime.persistence.ConcurrencyException;
 import org.apache.isis.runtimes.dflt.runtime.persistence.PersistorUtil;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManagerSpi;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.OidGenerator;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
 import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransaction;
+import org.apache.log4j.Logger;
+import org.datanucleus.api.jdo.NucleusJDOHelper;
+
+import com.google.common.collect.Maps;
 
 public class IsisLifecycleListener implements AttachLifecycleListener, ClearLifecycleListener,
CreateLifecycleListener, DeleteLifecycleListener, DetachLifecycleListener, DirtyLifecycleListener,
LoadLifecycleListener, StoreLifecycleListener, SuspendableListener {
 
@@ -226,6 +229,12 @@ public class IsisLifecycleListener imple
             return;
         }
 
+        final PersistenceCapable pojo = persistenceCapableFor(event);
+        
+        final IsisTransaction transaction = getCurrentTransaction();
+        final ObjectAdapter adapter = getAdapterManager().getAdapterFor(pojo);
+        transaction.auditDirty(adapter);
+
         ensureRootObject(event);
         ensureFrameworksInAgreement(event);
     }
@@ -242,9 +251,14 @@ public class IsisLifecycleListener imple
             return;
         }
         
+
         ensureRootObject(event);
         ensureFrameworksInAgreement(event);
     }
+    
+    
+
+
 
     @Override
     public void preDelete(InstanceLifecycleEvent event) {
@@ -414,16 +428,6 @@ public class IsisLifecycleListener imple
 
 
 
-    private void ensureObjectNotLoaded(InstanceLifecycleEvent event) {
-        final PersistenceCapable pojo = persistenceCapableFor(event);
-        final ObjectAdapter adapter = getAdapterManager().getAdapterFor(pojo);
-        if(adapter != null) {
-            final Oid oid = adapter.getOid();
-            throw new IsisException(MessageFormat.format("Object is already mapped in Isis:
oid={0}, for {1}", oid, pojo));
-        }
-    }
-
-    
     private enum Phase {
         PRE, POST
     }
@@ -470,6 +474,32 @@ public class IsisLifecycleListener imple
     }
 
 
+    
+    @SuppressWarnings("unused")
+    private Filter<ObjectAssociation> dirtyFieldFilterFor(final PersistenceCapable
pojo) {
+        String[] dirtyFields = NucleusJDOHelper.getDirtyFields(pojo, JDOHelper.getPersistenceManager(pojo));
+        final List<String> dirtyFieldList = Arrays.asList(dirtyFields);
+        Filter<ObjectAssociation> dirtyFieldsFilter = new Filter<ObjectAssociation>()
{
+            @Override
+            public boolean accept(final ObjectAssociation t) {
+                String id = t.getId();
+                return dirtyFieldList.contains(id);
+            }};
+        return dirtyFieldsFilter;
+    }
+
+    @SuppressWarnings("unused")
+    private void ensureObjectNotLoaded(InstanceLifecycleEvent event) {
+        final PersistenceCapable pojo = persistenceCapableFor(event);
+        final ObjectAdapter adapter = getAdapterManager().getAdapterFor(pojo);
+        if(adapter != null) {
+            final Oid oid = adapter.getOid();
+            throw new IsisException(MessageFormat.format("Object is already mapped in Isis:
oid={0}, for {1}", oid, pojo));
+        }
+    }
+
+
+    
     // /////////////////////////////////////////////////////////
     // Dependencies (from context)
     // /////////////////////////////////////////////////////////
@@ -493,5 +523,6 @@ public class IsisLifecycleListener imple
     protected IsisTransaction getCurrentTransaction() {
         return IsisContext.getCurrentTransaction();
     }
-    
+
+
 }

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransaction.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/spi/DataNucleusTransaction.java?rev=1375288&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransaction.java
(added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransaction.java
Mon Aug 20 22:41:02 2012
@@ -0,0 +1,76 @@
+package org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.spi;
+
+import java.util.Map.Entry;
+import java.util.Date;
+import java.util.Set;
+
+import org.apache.isis.applib.clock.Clock;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.applib.AuditService;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.applib.Auditable;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.TransactionalResource;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransaction;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.MessageBroker;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.UpdateNotifier;
+
+public class DataNucleusTransaction extends IsisTransaction {
+
+    private AuditService auditService;
+    
+    public DataNucleusTransaction(IsisTransactionManager transactionManager, MessageBroker
messageBroker, UpdateNotifier updateNotifier, TransactionalResource objectStore) {
+        super(transactionManager, messageBroker, updateNotifier, objectStore);
+    }
+
+    
+    @Override
+    protected void doAudit(Set<Entry<AdapterAndProperty, PreAndPostValues>> auditEntries)
{
+        if(auditService == null) {
+            super.doAudit(auditEntries);
+            return;
+        }
+        final String currentUser = getAuthenticationSession().getUserName();
+        final long currentTimestampEpoch = currentTimestampEpoch();
+        for (Entry<AdapterAndProperty, PreAndPostValues> auditEntry : auditEntries)
{
+            audit(currentUser, currentTimestampEpoch, auditEntry);
+        }
+    }
+
+    private long currentTimestampEpoch() {
+        return Clock.getTime();
+    }
+
+    private void audit(final String currentUser, final long currentTimestampEpoch, final
Entry<AdapterAndProperty, PreAndPostValues> auditEntry) {
+        final AdapterAndProperty aap = auditEntry.getKey();
+        final ObjectAdapter adapter = aap.getAdapter();
+        final Object pojo = adapter.getObject();
+        if(!(pojo instanceof Auditable)) {
+            return;
+        }
+        final RootOid oid = (RootOid) adapter.getOid();
+        final String objectType = oid.getObjectSpecId().asString();
+        final String identifier = oid.getIdentifier();
+        final PreAndPostValues papv = auditEntry.getValue();
+        final String preValue = asString(papv.getPre());
+        final String postValue = asString(papv.getPost());
+        auditService.audit(currentUser, currentTimestampEpoch, objectType, identifier, preValue,
postValue);
+    }
+
+    private static String asString(Object object) {
+        return object != null? object.toString(): null;
+    }
+
+
+    protected AuthenticationSession getAuthenticationSession() {
+        return IsisContext.getAuthenticationSession();
+    }
+
+
+    public void usingAuditService(AuditService auditService) {
+        this.auditService = auditService;
+    }
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransactionManager.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/spi/DataNucleusTransactionManager.java?rev=1375288&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransactionManager.java
(added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransactionManager.java
Mon Aug 20 22:41:02 2012
@@ -0,0 +1,44 @@
+package org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.spi;
+
+import java.util.List;
+
+import org.apache.isis.runtimes.dflt.objectstores.jdo.applib.AuditService;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.TransactionalResource;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.EnlistedObjectDirtying;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransaction;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.MessageBroker;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.UpdateNotifier;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+public class DataNucleusTransactionManager extends IsisTransactionManager {
+
+    private static final Predicate<Object> AUDIT_SERVICE = new Predicate<Object>()
{
+
+        @Override
+        public boolean apply(Object input) {
+            return input instanceof AuditService;
+        }
+    };
+
+    public DataNucleusTransactionManager(EnlistedObjectDirtying objectPersistor, TransactionalResource
objectStore) {
+        super(objectPersistor, objectStore);
+    }
+    
+    @Override
+    protected IsisTransaction createTransaction(MessageBroker messageBroker, UpdateNotifier
updateNotifier) {
+        DataNucleusTransaction transaction = new DataNucleusTransaction(this, messageBroker,
updateNotifier, getTransactionalResource());
+        List<Object> services = IsisContext.getServices();
+        Optional<Object> optionalService = Iterables.tryFind(services, AUDIT_SERVICE);
+        if(optionalService.isPresent()) {
+            AuditService service = (AuditService) optionalService.get();
+            transaction.usingAuditService(service);
+        }
+        return transaction;
+    }
+
+}

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/applibtypes/IsisDateConverterTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/applibtypes/IsisDateConverterTest.java?rev=1375288&r1=1375287&r2=1375288&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/applibtypes/IsisDateConverterTest.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/applibtypes/IsisDateConverterTest.java
Mon Aug 20 22:41:02 2012
@@ -20,8 +20,8 @@ public class IsisDateConverterTest {
     @Test
     public void roundTrip() {
         Date date = new Date();
-        final Long value = converter.toLong(date);
-        Date date2 = (Date) converter.toObject(value);
+        final Long value = converter.toDatastoreType(date);
+        Date date2 = (Date) converter.toMemberType(value);
         
         // necessary to use dateValue() because the Isis date (rather poorly) does not
         // override equals() / hashCode()
@@ -30,12 +30,12 @@ public class IsisDateConverterTest {
 
     @Test
     public void toLong_whenNull() {
-        assertNull(converter.toLong(null));
+        assertNull(converter.toDatastoreType(null));
     }
 
     @Test
     public void toObject_whenNull() {
-        assertNull(converter.toObject(null));
+        assertNull(converter.toMemberType(null));
     }
 
 }

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/specloader/progmodelfacets/JdoProgrammingModelFacets.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/specloader/progmodelfacets/JdoProgrammingModelFacets.java?rev=1375288&r1=1375287&r2=1375288&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/specloader/progmodelfacets/JdoProgrammingModelFacets.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/specloader/progmodelfacets/JdoProgrammingModelFacets.java
Mon Aug 20 22:41:02 2012
@@ -25,7 +25,6 @@ import org.apache.isis.runtimes.dflt.obj
 import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.embeddedonly.JdoEmbeddedOnlyAnnotationFacetFactory;
 import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableAnnotationFacetFactory;
 import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.query.JdoQueryAnnotationFacetFactory;
-import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.version.JdoVersionAnnotationFacetFactory;
 import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.prop.primarykey.JdoPrimaryKeyAnnotationFacetFactory;
 
 /**
@@ -46,7 +45,7 @@ public class JdoProgrammingModelFacets e
         addFactory(JdoPrimaryKeyAnnotationFacetFactory.class);
         addFactory(JdoDiscriminatorAnnotationFacetFactory.class);
 
-        addFactory(JdoVersionAnnotationFacetFactory.class);
+        //addFactory(JdoVersionAnnotationFacetFactory.class);
         addFactory(JdoQueryAnnotationFacetFactory.class);
     }
 

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/pom.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/pom.xml?rev=1375288&r1=1375287&r2=1375288&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/pom.xml (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/pom.xml Mon Aug 20 22:41:02
2012
@@ -154,28 +154,30 @@
 	        <dependency>
 	            <groupId>org.datanucleus</groupId>
 	            <artifactId>datanucleus-core</artifactId>
-	            <version>3.0.11</version>
+	            <version>3.1.0-release</version>
 	        </dependency>
 	        <dependency>
 	            <groupId>org.datanucleus</groupId>
 	            <artifactId>datanucleus-enhancer</artifactId>
-	            <version>3.0.1</version>
+	            <version>3.1.0-release</version>
 	        </dependency>
 	        <dependency>
 	            <groupId>org.datanucleus</groupId>
 	            <artifactId>datanucleus-api-jdo</artifactId>
-	            <version>3.0.8</version>
+	            <version>3.1.0-release</version>
 	        </dependency>
 	        <dependency>
 	            <groupId>org.datanucleus</groupId>
-	            <artifactId>datanucleus-jdo-query</artifactId>
-	            <version>3.0.2</version>
+	            <artifactId>datanucleus-rdbms</artifactId>
+	            <version>3.1.0-release</version>
 	        </dependency>
+	        <!-- 
 	        <dependency>
 	            <groupId>org.datanucleus</groupId>
-	            <artifactId>datanucleus-rdbms</artifactId>
-	            <version>3.0.10</version>
+	            <artifactId>datanucleus-jdo-query</artifactId>
+	            <version>3.0.2</version>
 	        </dependency>
+	         -->
 	    
 	        <dependency>
 	            <groupId>org.hsqldb</groupId>

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/version/FileVersion.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/version/FileVersion.java?rev=1375288&r1=1375287&r2=1375288&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/version/FileVersion.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/version/FileVersion.java
Mon Aug 20 22:41:02 2012
@@ -24,7 +24,6 @@ import java.io.Serializable;
 import java.util.Date;
 
 import org.apache.isis.core.commons.encoding.DataInputExtended;
-import org.apache.isis.core.commons.encoding.DataOutputExtended;
 import org.apache.isis.core.commons.encoding.Encodable;
 import org.apache.isis.core.commons.lang.ToString;
 import org.apache.isis.core.metamodel.adapter.version.Version;
@@ -32,6 +31,7 @@ import org.apache.isis.core.metamodel.ad
 import org.apache.isis.runtimes.dflt.objectstores.xml.internal.clock.Clock;
 
 public class FileVersion extends VersionUserAndTimeAbstract implements Encodable, Serializable
{
+    
     private static final long serialVersionUID = 1L;
     private static Clock clock;
 
@@ -39,28 +39,23 @@ public class FileVersion extends Version
         FileVersion.clock = clock;
     }
 
+    
+    // ///////////////////////////////////////////////////////
+    // constructor
+    // ///////////////////////////////////////////////////////
+
     public FileVersion(final String user) {
         this(user, clock.getTime());
     }
 
     public FileVersion(final String user, final long sequence) {
         super(user, new Date(sequence));
-        initialized();
     }
 
     public FileVersion(final DataInputExtended input) throws IOException {
         super(input);
-        initialized();
-    }
-
-    @Override
-    public void encode(final DataOutputExtended output) throws IOException {
-        super.encode(output);
     }
 
-    private void initialized() {
-        // nothing to do
-    }
 
     // ///////////////////////////////////////////////////////
     //
@@ -77,25 +72,17 @@ public class FileVersion extends Version
 
     @Override
     public boolean different(final Version version) {
-        if (version instanceof FileVersion) {
-            final FileVersion other = (FileVersion) version;
-            return !sameTime(other);
-        } else {
+        if (!(version instanceof FileVersion)) {
             return false;
-        }
+        } 
+        final FileVersion other = (FileVersion) version;
+        return !sameTime(other);
     }
 
     private boolean sameTime(final FileVersion other) {
         return getTime().getTime() == other.getTime().getTime();
     }
 
-    // don't think is used...
-    // @Override
-    // protected VersionAbstract next() {
-    // // return new FileVersion(user);
-    // throw new NotYetImplementedException();
-    // }
-
     @Override
     public boolean equals(final Object obj) {
         if (obj == this) {

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/installerregistry/installerapi/PersistenceMechanismInstallerAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/installerregistry/installerapi/PersistenceMechanismInstallerAbstract.java?rev=1375288&r1=1375287&r2=1375288&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/installerregistry/installerapi/PersistenceMechanismInstallerAbstract.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/installerregistry/installerapi/PersistenceMechanismInstallerAbstract.java
Mon Aug 20 22:41:02 2012
@@ -157,7 +157,7 @@ public abstract class PersistenceMechani
      * Hook method to return an {@link IsisTransactionManager}.
      * 
      * <p>
-     * By default returns a {@link ObjectStoreTransactionManager}.
+     * By default returns a {@link IsisTransactionManager}.
      */
     protected IsisTransactionManager createTransactionManager(final EnlistedObjectDirtying
persistor, final TransactionalResource objectStore) {
         return new IsisTransactionManager(persistor, objectStore);

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransaction.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransaction.java?rev=1375288&r1=1375287&r2=1375288&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransaction.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransaction.java
Mon Aug 20 22:41:02 2012
@@ -27,22 +27,33 @@ import static org.hamcrest.Matchers.not;
 
 import java.util.Collections;
 import java.util.List;
-
-import com.google.common.collect.Lists;
-
-import org.apache.log4j.Logger;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
 
 import org.apache.isis.core.commons.components.TransactionScopedComponent;
 import org.apache.isis.core.commons.ensure.Ensure;
 import org.apache.isis.core.commons.lang.ToString;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.ResolveState;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
 import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectPersistenceException;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.CreateObjectCommand;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.SaveObjectCommand;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.TransactionalResource;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.log4j.Logger;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
 
 /**
  * Used by the {@link IsisTransactionManager} to captures a set of changes to be
@@ -329,6 +340,8 @@ public class IsisTransaction implements 
      */
     private void doFlush() {
 
+        doAudit(getAuditEntries());
+        
         if (commands.size() > 0) {
             objectStore.execute(Collections.unmodifiableList(commands));
 
@@ -343,6 +356,16 @@ public class IsisTransaction implements 
         }
     }
 
+    
+    /**
+     * Hook method for subtypes to audit as required.
+     */
+    protected void doAudit(Set<Entry<AdapterAndProperty, PreAndPostValues>> auditEntries)
{
+        for (Entry<AdapterAndProperty, PreAndPostValues> auditEntry : auditEntries)
{
+            LOG.info(auditEntry.getKey() + ": " + auditEntry.getValue());
+        }
+    }
+
 
     
     // ////////////////////////////////////////////////////////////////
@@ -500,5 +523,160 @@ public class IsisTransaction implements 
         return updateNotifier;
     }
 
+    public static class AdapterAndProperty {
+        private final ObjectAdapter objectAdapter;
+        private final ObjectAssociation property;
+        
+        public static AdapterAndProperty of(ObjectAdapter adapter, ObjectAssociation property)
{
+            return new AdapterAndProperty(adapter, property);
+        }
+
+        private AdapterAndProperty(ObjectAdapter adapter, ObjectAssociation property) {
+            this.objectAdapter = adapter;
+            this.property = property;
+        }
+        
+        public ObjectAdapter getAdapter() {
+            return objectAdapter;
+        }
+        public ObjectAssociation getProperty() {
+            return property;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((objectAdapter == null) ? 0 : objectAdapter.hashCode());
+            result = prime * result + ((property == null) ? 0 : property.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj)
+                return true;
+            if (obj == null)
+                return false;
+            if (getClass() != obj.getClass())
+                return false;
+            AdapterAndProperty other = (AdapterAndProperty) obj;
+            if (objectAdapter == null) {
+                if (other.objectAdapter != null)
+                    return false;
+            } else if (!objectAdapter.equals(other.objectAdapter))
+                return false;
+            if (property == null) {
+                if (other.property != null)
+                    return false;
+            } else if (!property.equals(other.property))
+                return false;
+            return true;
+        }
+        
+        @Override
+        public String toString() {
+            return getAdapter().getOid().enStringNoVersion(getMarshaller()) + " , " + getProperty().getId();
+        }
+
+        protected OidMarshaller getMarshaller() {
+            return new OidMarshaller();
+        }
+
+        private Object getPropertyValue() {
+            ObjectAdapter referencedAdapter = property.get(objectAdapter);
+            return referencedAdapter == null ? null : referencedAdapter.getObject();
+        }
+    }
+   
+    
+    ////////////////////////////////////////////////////////////////////////
+    // Auditing
+    ////////////////////////////////////////////////////////////////////////
+
+    public static class PreAndPostValues {
+        
+        private final static Predicate<Entry<?, PreAndPostValues>> CHANGED =
new Predicate<Entry<?, PreAndPostValues>>(){
+            @Override
+            public boolean apply(Entry<?, PreAndPostValues> input) {
+                final PreAndPostValues papv = input.getValue();
+                return papv.differ();
+            }};
+            
+        private final Object pre;
+        private Object post;
+        
+        public static PreAndPostValues pre(Object preValue) {
+            return new PreAndPostValues(preValue, null);
+        }
+
+        private PreAndPostValues(Object pre, Object post) {
+            this.pre = pre;
+            this.post = post;
+        }
+        public Object getPre() {
+            return pre;
+        }
+        
+        public Object getPost() {
+            return post;
+        }
+        
+        public void setPost(Object post) {
+            this.post = post;
+        }
+        
+        @Override
+        public String toString() {
+            return getPre() + " -> " + getPost();
+        }
+
+        public boolean differ() {
+            return !Objects.equal(getPre(), getPost());
+        }
+    }
+    
+   
+    private final Map<AdapterAndProperty, PreAndPostValues> auditLog = Maps.newLinkedHashMap();
+    
+
+    public void auditDirty(ObjectAdapter adapter) {
+        for (ObjectAssociation property : adapter.getSpecification().getAssociations(ObjectAssociationFilters.PROPERTIES))
{
+            audit(adapter, property);
+        }
+    }
+    
+    private void audit(ObjectAdapter adapter, ObjectAssociation property) {
+        final AdapterAndProperty aap = AdapterAndProperty.of(adapter, property);
+        PreAndPostValues papv = PreAndPostValues.pre(aap.getPropertyValue());
+        auditLog.put(aap, papv);
+    }
+
+
+    public Set<Entry<AdapterAndProperty, PreAndPostValues>> getAuditEntries()
{
+        updatePostValues(auditLog.entrySet());
+
+        return Collections.unmodifiableSet(Sets.filter(auditLog.entrySet(), PreAndPostValues.CHANGED));
+    }
+
+    private void updatePostValues(Set<Entry<AdapterAndProperty, PreAndPostValues>>
entrySet) {
+        for (Entry<AdapterAndProperty, PreAndPostValues> entry : entrySet) {
+            final AdapterAndProperty aap = entry.getKey();
+            final PreAndPostValues papv = entry.getValue();
+            
+            papv.setPost(aap.getPropertyValue());
+        }
+    }
+
+
+    
+    ////////////////////////////////////////////////////////////////////////
+    // Dependencies (from context)
+    ////////////////////////////////////////////////////////////////////////
+
+    
+    protected AdapterManager getAdapterManager() {
+        return IsisContext.getPersistenceSession().getAdapterManager();
+    }
     
 }

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransactionManager.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransactionManager.java?rev=1375288&r1=1375287&r2=1375288&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransactionManager.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransactionManager.java
Mon Aug 20 22:41:02 2012
@@ -44,7 +44,7 @@ public class IsisTransactionManager impl
     private static final Logger LOG = Logger.getLogger(IsisTransactionManager.class);
 
     private final EnlistedObjectDirtying objectPersistor;
-    private final TransactionalResource objectStore;
+    private final TransactionalResource transactionalResource;
 
     private int transactionLevel;
     
@@ -56,17 +56,20 @@ public class IsisTransactionManager impl
     private IsisTransaction transaction;
 
 
-
     // ////////////////////////////////////////////////////////////////
     // constructor
     // ////////////////////////////////////////////////////////////////
 
     public IsisTransactionManager(final EnlistedObjectDirtying objectPersistor, final TransactionalResource
objectStore) {
         this.objectPersistor = objectPersistor;
-        this.objectStore = objectStore;
+        this.transactionalResource = objectStore;
     }
     
     
+    public TransactionalResource getTransactionalResource() {
+        return transactionalResource;
+    }
+    
     // ////////////////////////////////////////////////////////////////
     // open, close
     // ////////////////////////////////////////////////////////////////
@@ -230,7 +233,7 @@ public class IsisTransactionManager impl
         ensureThatArg(messageBroker, is(not(nullValue())));
         ensureThatArg(updateNotifier, is(not(nullValue())));
 
-        return new IsisTransaction(this, messageBroker, updateNotifier, objectStore);
+        return new IsisTransaction(this, messageBroker, updateNotifier, getTransactionalResource());
     }
     
 
@@ -246,7 +249,7 @@ public class IsisTransactionManager impl
 
             createTransaction();
             transactionLevel = 0;
-            objectStore.startTransaction();
+            transactionalResource.startTransaction();
         }
 
         transactionLevel++;
@@ -307,7 +310,7 @@ public class IsisTransactionManager impl
             }
             
             if(exceptions.isEmpty()) {
-                objectStore.endTransaction();
+                transactionalResource.endTransaction();
                 
                 // just in case any additional exceptions were raised...
                 exceptions = this.getTransaction().getExceptionsIfAny();
@@ -350,7 +353,7 @@ public class IsisTransactionManager impl
         if (getTransaction() != null) {
             getTransaction().abort();
             transactionLevel = 0;
-            objectStore.abortTransaction();
+            transactionalResource.abortTransaction();
         }
     }
 

Modified: incubator/isis/trunk/framework/tck/tck-dom/pom.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/tck/tck-dom/pom.xml?rev=1375288&r1=1375287&r2=1375288&view=diff
==============================================================================
--- incubator/isis/trunk/framework/tck/tck-dom/pom.xml (original)
+++ incubator/isis/trunk/framework/tck/tck-dom/pom.xml Mon Aug 20 22:41:02 2012
@@ -34,11 +34,11 @@
             <plugin>
                 <groupId>org.datanucleus</groupId>
                 <artifactId>maven-datanucleus-plugin</artifactId>
-                <version>3.0.2</version>
+                <version>3.1.0-release</version>
                 <configuration>
                 	<fork>false</fork>
-                    <log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
                     <verbose>true</verbose>
+                    <log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
                 </configuration>
                 <executions>
                     <execution>

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/valuechoices/ValueChoicesPanel.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/valuechoices/ValueChoicesPanel.java?rev=1375288&r1=1375287&r2=1375288&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/valuechoices/ValueChoicesPanel.java
(original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/valuechoices/ValueChoicesPanel.java
Mon Aug 20 22:41:02 2012
@@ -110,7 +110,9 @@ public class ValueChoicesPanel extends S
                     pending = adapterMemento;
                 }
                 if (scalarModel != null && pending != null) {
-                    LOG.info("TextField: setting to pending: " + pending.toString());
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("TextField: setting to pending: " + pending.toString());
+                    }
                     scalarModel.setObject(pending.getObjectAdapter());
                 }
 



Mime
View raw message