isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1098940 [3/5] - in /incubator/isis/trunk/runtimes: dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/ dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ dflt/ob...
Date Tue, 03 May 2011 06:42:09 GMT
Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlCreateObjectCommand.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlCreateObjectCommand.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlCreateObjectCommand.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlCreateObjectCommand.java Tue May  3 06:42:06 2011
@@ -17,37 +17,37 @@
  *  under the License.
  */
 
+package org.apache.isis.runtimes.dflt.objectstores.xml.internal.commands;
 
-package org.apache.isis.runtimes.dflt.objectstores.xml.internal.commands;
-
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.DataManager;
 import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.ObjectData;
 import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.CreateObjectCommand;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
 import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
 import org.apache.log4j.Logger;
-
-public final class XmlCreateObjectCommand extends AbstractXmlPersistenceCommand implements CreateObjectCommand {
-	private static final Logger LOG = Logger.getLogger(XmlCreateObjectCommand.class);
-	
-	public XmlCreateObjectCommand(final ObjectAdapter adapter, final DataManager dataManager) {
-		super(adapter, dataManager);
-	}
-
-	public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
-		if (LOG.isDebugEnabled()) {
-			LOG.debug("  create object " + onObject());
-		}
-	    final String user = getAuthenticationSession().getUserName();
-	    onObject().setOptimisticLock(new FileVersion(user));
-	    final ObjectData data = createObjectData(onObject(), true);
-	    getDataManager().insertObject(data);
-	}
-
-	@Override
-	public String toString() {
-	    return "CreateObjectCommand [object=" + onObject() + "]";
-	}
+
+public final class XmlCreateObjectCommand extends AbstractXmlPersistenceCommand implements CreateObjectCommand {
+    private static final Logger LOG = Logger.getLogger(XmlCreateObjectCommand.class);
+
+    public XmlCreateObjectCommand(final ObjectAdapter adapter, final DataManager dataManager) {
+        super(adapter, dataManager);
+    }
+
+    @Override
+    public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("  create object " + onObject());
+        }
+        final String user = getAuthenticationSession().getUserName();
+        onObject().setOptimisticLock(new FileVersion(user));
+        final ObjectData data = createObjectData(onObject(), true);
+        getDataManager().insertObject(data);
+    }
+
+    @Override
+    public String toString() {
+        return "CreateObjectCommand [object=" + onObject() + "]";
+    }
 }
\ No newline at end of file

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlDestroyObjectCommand.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlDestroyObjectCommand.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlDestroyObjectCommand.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlDestroyObjectCommand.java Tue May  3 06:42:06 2011
@@ -17,35 +17,35 @@
  *  under the License.
  */
 
+package org.apache.isis.runtimes.dflt.objectstores.xml.internal.commands;
 
-package org.apache.isis.runtimes.dflt.objectstores.xml.internal.commands;
-
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.DataManager;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.DataManager;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
 import org.apache.isis.runtimes.dflt.runtime.persistence.oidgenerator.simple.SerialOid;
 import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
 import org.apache.log4j.Logger;
-
-public final class XmlDestroyObjectCommand extends AbstractXmlPersistenceCommand implements DestroyObjectCommand {
-	private static final Logger LOG = Logger.getLogger(XmlDestroyObjectCommand.class);
-	
-	public XmlDestroyObjectCommand(final ObjectAdapter adapter, final DataManager dataManager) {
-		super(adapter, dataManager);
-	}
-
-	public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
-		if (LOG.isDebugEnabled()) {
-			LOG.debug("  destroy object " + onObject());
-		}
-	    final SerialOid oid = (SerialOid) onObject().getOid();
-	    getDataManager().remove(oid);
-	    onObject().setOptimisticLock(null);
-	}
-
-	@Override
-	public String toString() {
-	    return "DestroyObjectCommand [object=" + onObject() + "]";
-	}
+
+public final class XmlDestroyObjectCommand extends AbstractXmlPersistenceCommand implements DestroyObjectCommand {
+    private static final Logger LOG = Logger.getLogger(XmlDestroyObjectCommand.class);
+
+    public XmlDestroyObjectCommand(final ObjectAdapter adapter, final DataManager dataManager) {
+        super(adapter, dataManager);
+    }
+
+    @Override
+    public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("  destroy object " + onObject());
+        }
+        final SerialOid oid = (SerialOid) onObject().getOid();
+        getDataManager().remove(oid);
+        onObject().setOptimisticLock(null);
+    }
+
+    @Override
+    public String toString() {
+        return "DestroyObjectCommand [object=" + onObject() + "]";
+    }
 }
\ No newline at end of file

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlUpdateObjectCommand.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlUpdateObjectCommand.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlUpdateObjectCommand.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlUpdateObjectCommand.java Tue May  3 06:42:06 2011
@@ -17,44 +17,40 @@
  *  under the License.
  */
 
+package org.apache.isis.runtimes.dflt.objectstores.xml.internal.commands;
 
-package org.apache.isis.runtimes.dflt.objectstores.xml.internal.commands;
-
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.Data;
 import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.DataManager;
 import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.SaveObjectCommand;
 import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
 import org.apache.log4j.Logger;
-
-public final class XmlUpdateObjectCommand 
-		extends AbstractXmlPersistenceCommand 
-		implements SaveObjectCommand {
-	
-	private static final Logger LOG = Logger.getLogger(XmlUpdateObjectCommand.class);
-
-	public XmlUpdateObjectCommand(final ObjectAdapter adapter, final DataManager dataManager) {
-		super(adapter, dataManager);
-	}
-
-	public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
-		if (LOG.isDebugEnabled()) {
-			LOG.debug("  save object " + onObject());
-		}
-	    final String user = getAuthenticationSession().getUserName();
-	    onObject().setOptimisticLock(new FileVersion(user));
-
-	    final Data data = createObjectData(onObject(), true);
-	    getDataManager().save(data);
-	}
-
-	@Override
-	public String toString() {
-	    return "SaveObjectCommand [object=" + onObject() + "]";
-	}
-
-	
-
+
+public final class XmlUpdateObjectCommand extends AbstractXmlPersistenceCommand implements SaveObjectCommand {
+
+    private static final Logger LOG = Logger.getLogger(XmlUpdateObjectCommand.class);
+
+    public XmlUpdateObjectCommand(final ObjectAdapter adapter, final DataManager dataManager) {
+        super(adapter, dataManager);
+    }
+
+    @Override
+    public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("  save object " + onObject());
+        }
+        final String user = getAuthenticationSession().getUserName();
+        onObject().setOptimisticLock(new FileVersion(user));
+
+        final Data data = createObjectData(onObject(), true);
+        getDataManager().save(data);
+    }
+
+    @Override
+    public String toString() {
+        return "SaveObjectCommand [object=" + onObject() + "]";
+    }
+
 }
\ No newline at end of file

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/CollectionData.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/CollectionData.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/CollectionData.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/CollectionData.java Tue May  3 06:42:06 2011
@@ -17,14 +17,12 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.data;
 
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
 import org.apache.isis.runtimes.dflt.runtime.persistence.oidgenerator.simple.SerialOid;
 
-
 /**
  * A logical collection of elements of a specified type
  */

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/Data.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/Data.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/Data.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/Data.java Tue May  3 06:42:06 2011
@@ -17,21 +17,19 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.data;
 
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
 import org.apache.isis.runtimes.dflt.runtime.persistence.oidgenerator.simple.SerialOid;
 
-
 public abstract class Data {
-	private final ObjectSpecification noSpec;
+    private final ObjectSpecification noSpec;
     private final SerialOid oid;
     private final FileVersion version;
 
     Data(final ObjectSpecification noSpec, final SerialOid oid, final FileVersion version) {
-    	this.noSpec = noSpec;
+        this.noSpec = noSpec;
         this.oid = oid;
         this.version = version;
     }
@@ -45,9 +43,9 @@ public abstract class Data {
     }
 
     public ObjectSpecification getSpecification() {
-		return noSpec;
-	}
-    
+        return noSpec;
+    }
+
     public String getTypeName() {
         return noSpec.getFullIdentifier();
     }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/DataManager.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/DataManager.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/DataManager.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/DataManager.java Tue May  3 06:42:06 2011
@@ -17,25 +17,21 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.data;
 
 import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectNotFoundException;
 import org.apache.isis.runtimes.dflt.runtime.persistence.oidgenerator.simple.SerialOid;
 import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
 
-
 public interface DataManager {
 
     void shutdown();
 
-    
     /**
      * Return data for all instances that match the pattern.
      */
     public ObjectDataVector getInstances(final ObjectData pattern);
-    
-    
+
     /**
      * Return the number of instances that match the specified data
      */
@@ -43,8 +39,6 @@ public interface DataManager {
 
     public Data loadData(final SerialOid oid);
 
-    
-    
     /**
      * Save the data for an object and adds the reference to a list of instances
      */

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectData.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectData.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectData.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectData.java Tue May  3 06:42:06 2011
@@ -17,169 +17,148 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.data;
 
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
 import org.apache.isis.core.commons.exceptions.IsisException;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
 import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacetUtils;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
 import org.apache.isis.runtimes.dflt.runtime.persistence.oidgenerator.simple.SerialOid;
 
 /**
  * A logical collection of elements of a specified type
  */
 public class ObjectData extends Data {
-	private final Map<String, Object> fieldById;
-
-	public ObjectData(
-			final ObjectSpecification noSpec, 
-			final SerialOid oid,
-			final FileVersion version) {
-		super(noSpec, oid, version);
-		fieldById = new HashMap<String, Object>();
-	}
-
-	public Iterable<String> fields() {
-		return fieldById.keySet();
-	}
-
-	//////////////////////////////////////////////////////////
-	// id
-	//////////////////////////////////////////////////////////
-
-	public String id(final String fieldId) {
-		final Object field = get(fieldId);
-		return field == null ? null : "" + ((SerialOid) field).getSerialNo();
-	}
-
-	
-	//////////////////////////////////////////////////////////
-	// value
-	//////////////////////////////////////////////////////////
-
-	public void set(final String fieldId, final String value) {
-		fieldById.put(fieldId, value);
-	}
-
-	public void saveValue(final String fieldId, final boolean isEmpty,
-			final String encodedString) {
-		if (isEmpty) {
-			fieldById.remove(fieldId);
-		} else {
-			fieldById.put(fieldId, encodedString);
-		}
-	}
-
-	public String value(final String fieldId) {
-		return (String) get(fieldId);
-	}
-
-	
-	//////////////////////////////////////////////////////////
-	// reference
-	//////////////////////////////////////////////////////////
-
-	public Object get(final String fieldId) {
-		return fieldById.get(fieldId);
-	}
-
-	public void set(final String fieldId, final Object oid) {
-		if (oid == null) {
-			fieldById.remove(fieldId);
-		} else {
-			fieldById.put(fieldId, oid);
-		}
-	}
-
-	//////////////////////////////////////////////////////////
-	// collection
-	//////////////////////////////////////////////////////////
-
-	public void initCollection(final String fieldId) {
-		fieldById.put(fieldId, new ReferenceVector());
-	}
-
-	public void addElement(final String fieldId, final SerialOid elementOid) {
-		if (!fieldById.containsKey(fieldId)) {
-			throw new IsisException("Field " + fieldId
-					+ " not found  in hashtable");
-		}
-
-		final ReferenceVector v = (ReferenceVector) fieldById.get(fieldId);
-		v.add(elementOid);
-	}
-
-	public ReferenceVector elements(final String fieldId) {
-		return (ReferenceVector) fieldById.get(fieldId);
-	}
-
-	public void addAssociation(final ObjectAdapter fieldContent,
-			final String fieldId, final boolean ensurePersistent) {
-		final boolean notAlreadyPersistent = fieldContent != null
-				&& fieldContent.isTransient();
-		if (ensurePersistent && notAlreadyPersistent) {
-			throw new IllegalStateException(
-					"Cannot save an object that is not persistent: "
-							+ fieldContent);
-		}
-		// LOG.debug("adding reference field " + fieldId +" " + fieldContent);
-		set(fieldId, fieldContent == null ? null : fieldContent.getOid());
-	}
-
-	public void addInternalCollection(final ObjectAdapter collection,
-			final String fieldId, final boolean ensurePersistent) {
-		/*
-		 * if (ensurePersistent && collection != null && collection.getOid() ==
-		 * null) { throw new
-		 * IllegalStateException("Cannot save a collection that is not persistent: "
-		 * + collection); }
-		 */
-
-		initCollection(fieldId);
-
-		// int size = collection.size();
-
-		final CollectionFacet facet = CollectionFacetUtils
-				.getCollectionFacetFromSpec(collection);
-		for (ObjectAdapter element : facet.iterable(collection)) {
-			// LOG.debug("adding element to internal collection field " +
-			// fieldId +" " + element);
-			final Object elementOid = element.getOid();
-			if (elementOid == null) {
-				throw new IllegalStateException("Element is not persistent "
-						+ element);
-			}
-
-			addElement(fieldId, (SerialOid) elementOid);
-		}
-
-		/*
-		 * while (e.hasMoreElements()) { ObjectAdapter element = (ObjectAdapter)
-		 * e.nextElement(); //
-		 * LOG.debug("adding element to internal collection field " + fieldId
-		 * +" " + element); Object elementOid = element.getOid(); if (elementOid
-		 * == null) { throw new IllegalStateException("Element is not persistent
-		 * "+element); }
-		 * 
-		 * addElement(fieldId, (SimpleOid) elementOid); }
-		 */}
-
-
-	//////////////////////////////////////////////////////////
-	// toString
-	//////////////////////////////////////////////////////////
-
-	@Override
-	public String toString() {
-		return "ObjectData[type=" + getTypeName() + ",oid=" + getOid()
-				+ ",fields=" + fieldById + "]";
-	}
+    private final Map<String, Object> fieldById;
 
+    public ObjectData(final ObjectSpecification noSpec, final SerialOid oid, final FileVersion version) {
+        super(noSpec, oid, version);
+        fieldById = new HashMap<String, Object>();
+    }
+
+    public Iterable<String> fields() {
+        return fieldById.keySet();
+    }
+
+    // ////////////////////////////////////////////////////////
+    // id
+    // ////////////////////////////////////////////////////////
+
+    public String id(final String fieldId) {
+        final Object field = get(fieldId);
+        return field == null ? null : "" + ((SerialOid) field).getSerialNo();
+    }
+
+    // ////////////////////////////////////////////////////////
+    // value
+    // ////////////////////////////////////////////////////////
+
+    public void set(final String fieldId, final String value) {
+        fieldById.put(fieldId, value);
+    }
+
+    public void saveValue(final String fieldId, final boolean isEmpty, final String encodedString) {
+        if (isEmpty) {
+            fieldById.remove(fieldId);
+        } else {
+            fieldById.put(fieldId, encodedString);
+        }
+    }
+
+    public String value(final String fieldId) {
+        return (String) get(fieldId);
+    }
+
+    // ////////////////////////////////////////////////////////
+    // reference
+    // ////////////////////////////////////////////////////////
+
+    public Object get(final String fieldId) {
+        return fieldById.get(fieldId);
+    }
+
+    public void set(final String fieldId, final Object oid) {
+        if (oid == null) {
+            fieldById.remove(fieldId);
+        } else {
+            fieldById.put(fieldId, oid);
+        }
+    }
+
+    // ////////////////////////////////////////////////////////
+    // collection
+    // ////////////////////////////////////////////////////////
+
+    public void initCollection(final String fieldId) {
+        fieldById.put(fieldId, new ReferenceVector());
+    }
+
+    public void addElement(final String fieldId, final SerialOid elementOid) {
+        if (!fieldById.containsKey(fieldId)) {
+            throw new IsisException("Field " + fieldId + " not found  in hashtable");
+        }
+
+        final ReferenceVector v = (ReferenceVector) fieldById.get(fieldId);
+        v.add(elementOid);
+    }
+
+    public ReferenceVector elements(final String fieldId) {
+        return (ReferenceVector) fieldById.get(fieldId);
+    }
+
+    public void addAssociation(final ObjectAdapter fieldContent, final String fieldId, final boolean ensurePersistent) {
+        final boolean notAlreadyPersistent = fieldContent != null && fieldContent.isTransient();
+        if (ensurePersistent && notAlreadyPersistent) {
+            throw new IllegalStateException("Cannot save an object that is not persistent: " + fieldContent);
+        }
+        // LOG.debug("adding reference field " + fieldId +" " + fieldContent);
+        set(fieldId, fieldContent == null ? null : fieldContent.getOid());
+    }
+
+    public void addInternalCollection(final ObjectAdapter collection, final String fieldId,
+        final boolean ensurePersistent) {
+        /*
+         * if (ensurePersistent && collection != null && collection.getOid() == null) { throw new
+         * IllegalStateException("Cannot save a collection that is not persistent: " + collection); }
+         */
+
+        initCollection(fieldId);
+
+        // int size = collection.size();
+
+        final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
+        for (final ObjectAdapter element : facet.iterable(collection)) {
+            // LOG.debug("adding element to internal collection field " +
+            // fieldId +" " + element);
+            final Object elementOid = element.getOid();
+            if (elementOid == null) {
+                throw new IllegalStateException("Element is not persistent " + element);
+            }
+
+            addElement(fieldId, (SerialOid) elementOid);
+        }
+
+        /*
+         * while (e.hasMoreElements()) { ObjectAdapter element = (ObjectAdapter) e.nextElement(); //
+         * LOG.debug("adding element to internal collection field " + fieldId +" " + element); Object elementOid =
+         * element.getOid(); if (elementOid == null) { throw new IllegalStateException("Element is not persistent
+         * "+element); }
+         * 
+         * addElement(fieldId, (SimpleOid) elementOid); }
+         */}
+
+    // ////////////////////////////////////////////////////////
+    // toString
+    // ////////////////////////////////////////////////////////
+
+    @Override
+    public String toString() {
+        return "ObjectData[type=" + getTypeName() + ",oid=" + getOid() + ",fields=" + fieldById + "]";
+    }
 
 }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataVector.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataVector.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataVector.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataVector.java Tue May  3 06:42:06 2011
@@ -17,12 +17,10 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.data;
 
 import java.util.Vector;
 
-
 public class ObjectDataVector {
     Vector elements = new Vector();
 

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/PersistorException.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/PersistorException.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/PersistorException.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/PersistorException.java Tue May  3 06:42:06 2011
@@ -17,12 +17,10 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.data;
 
 import org.apache.isis.core.commons.exceptions.IsisException;
 
-
 public class PersistorException extends IsisException {
     private static final long serialVersionUID = 1L;
 

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ReferenceVector.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ReferenceVector.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ReferenceVector.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ReferenceVector.java Tue May  3 06:42:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.data;
 
 import java.util.Vector;
@@ -25,7 +24,6 @@ import java.util.Vector;
 import org.apache.isis.core.commons.lang.ToString;
 import org.apache.isis.runtimes.dflt.runtime.persistence.oidgenerator.simple.SerialOid;
 
-
 public class ReferenceVector {
     private final Vector elements = new Vector();
 

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/xml/XmlDataManager.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/xml/XmlDataManager.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/xml/XmlDataManager.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/xml/XmlDataManager.java Tue May  3 06:42:06 2011
@@ -17,13 +17,17 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.xml;
 
 import java.io.IOException;
 import java.io.Writer;
 import java.util.Vector;
 
+import org.apache.isis.core.commons.ensure.Assert;
+import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.core.commons.xml.ContentWriter;
+import org.apache.isis.core.commons.xml.XmlFile;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.CollectionData;
 import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.Data;
 import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.DataManager;
@@ -32,11 +36,6 @@ import org.apache.isis.runtimes.dflt.obj
 import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.PersistorException;
 import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.ReferenceVector;
 import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
-import org.apache.isis.core.commons.ensure.Assert;
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.commons.xml.ContentWriter;
-import org.apache.isis.core.commons.xml.XmlFile;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectNotFoundException;
 import org.apache.isis.runtimes.dflt.runtime.persistence.oidgenerator.simple.SerialOid;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
@@ -45,7 +44,6 @@ import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
-
 public class XmlDataManager implements DataManager {
     private final XmlFile xmlFile;
 
@@ -53,17 +51,17 @@ public class XmlDataManager implements D
         this.xmlFile = xmlFile;
     }
 
-    
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
     // shutdown
-    //////////////////////////////////////////////////////////
-    
-    public void shutdown() {}
+    // ////////////////////////////////////////////////////////
 
+    @Override
+    public void shutdown() {
+    }
 
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
     // SAX Handlers
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
 
     // TODO the following methods are being called repeatedly - is there no
     // caching? See the print statements
@@ -92,7 +90,7 @@ public class XmlDataManager implements D
 
         @Override
         public void startElement(final String ns, final String name, final String tagName, final Attributes attributes)
-                throws SAXException {
+            throws SAXException {
             if (object != null) {
                 if (tagName.equals("value")) {
                     fieldName = attributes.getValue("field");
@@ -142,11 +140,12 @@ public class XmlDataManager implements D
         Vector<SerialOid> instances = new Vector<SerialOid>();
 
         @Override
-        public void characters(final char[] arg0, final int arg1, final int arg2) throws SAXException {}
+        public void characters(final char[] arg0, final int arg1, final int arg2) throws SAXException {
+        }
 
         @Override
         public void startElement(final String ns, final String name, final String tagName, final Attributes attrs)
-                throws SAXException {
+            throws SAXException {
             if (tagName.equals("instance")) {
                 final long oid = Long.valueOf(attrs.getValue("id"), 16).longValue();
                 instances.addElement(SerialOid.createPersistent(oid));
@@ -167,25 +166,25 @@ public class XmlDataManager implements D
 
         @Override
         public void startElement(final String ns, final String name, final String tagName, final Attributes attrs)
-                throws SAXException {
+            throws SAXException {
             captureValue = tagName.equals("number");
         }
     }
 
-
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
     // fixtures
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
 
+    @Override
     public boolean isFixturesInstalled() {
         return xmlFile.isFixturesInstalled();
     }
 
-
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
     // loadData
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
 
+    @Override
     public Data loadData(final SerialOid oid) {
         final DataHandler handler = new DataHandler();
         xmlFile.parse(handler, filename(oid));
@@ -197,11 +196,11 @@ public class XmlDataManager implements D
         }
     }
 
-    
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
     // getInstances, numberOfInstances
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
 
+    @Override
     public ObjectDataVector getInstances(final ObjectData pattern) {
         final Vector<SerialOid> instances = loadInstances(pattern.getSpecification());
 
@@ -210,7 +209,7 @@ public class XmlDataManager implements D
         }
 
         final ObjectDataVector matches = new ObjectDataVector();
-        for (SerialOid oid: instances) {
+        for (final SerialOid oid : instances) {
             final ObjectData instanceData = (ObjectData) loadData(oid);
             // TODO check loader first
             if (instanceData == null) {
@@ -223,52 +222,46 @@ public class XmlDataManager implements D
         return matches;
     }
 
-
-	public int numberOfInstances(final ObjectData pattern) {
+    @Override
+    public int numberOfInstances(final ObjectData pattern) {
         return getInstances(pattern).size();
     }
 
-	private Vector<SerialOid> loadInstances(ObjectSpecification noSpec) {
-		final InstanceHandler handler = new InstanceHandler();
-		parseSpecAndSubclasses(handler, noSpec);
-		return handler.instances;
-	}
-
-
-	private void parseSpecAndSubclasses(final InstanceHandler handler,
-			ObjectSpecification noSpec) {
-		parseIfNotAbstract(noSpec, handler);
-		for(ObjectSpecification subSpec: noSpec.subclasses()) {
-			parseSpecAndSubclasses(handler, subSpec);
-		}
-	}
-
-
-	private void parseIfNotAbstract(ObjectSpecification noSpec,
-			final InstanceHandler handler) {
-		if (noSpec.isAbstract()) {
-			return;
-		}
-		xmlFile.parse(handler, noSpec.getFullIdentifier());
-	}
+    private Vector<SerialOid> loadInstances(final ObjectSpecification noSpec) {
+        final InstanceHandler handler = new InstanceHandler();
+        parseSpecAndSubclasses(handler, noSpec);
+        return handler.instances;
+    }
+
+    private void parseSpecAndSubclasses(final InstanceHandler handler, final ObjectSpecification noSpec) {
+        parseIfNotAbstract(noSpec, handler);
+        for (final ObjectSpecification subSpec : noSpec.subclasses()) {
+            parseSpecAndSubclasses(handler, subSpec);
+        }
+    }
 
+    private void parseIfNotAbstract(final ObjectSpecification noSpec, final InstanceHandler handler) {
+        if (noSpec.isAbstract()) {
+            return;
+        }
+        xmlFile.parse(handler, noSpec.getFullIdentifier());
+    }
 
-    
     /**
-     * A helper that determines if two sets of data match. A match occurs when the types are the same and any
-     * field in the pattern also occurs in the data set under test.
+     * A helper that determines if two sets of data match. A match occurs when the types are the same and any field in
+     * the pattern also occurs in the data set under test.
      */
     // TODO we need to be able to find collection instances as well
     protected boolean matchesPattern(final ObjectData patternData, final ObjectData candidateData) {
         if (patternData == null || candidateData == null) {
             throw new NullPointerException("Can't match on nulls " + patternData + " " + candidateData);
         }
-        
+
         if (!candidateData.getSpecification().isOfType(patternData.getSpecification())) {
-        	return false;
+            return false;
         }
 
-        for(final String field: patternData.fields()) {
+        for (final String field : patternData.fields()) {
             final Object patternFieldValue = patternData.get(field);
             final Object candidateFieldValue = candidateData.get(field);
 
@@ -310,7 +303,8 @@ public class XmlDataManager implements D
         xmlFile.parse(handler, "oid");
 
         xmlFile.writeXml("oid", new ContentWriter() {
-            public void write(Writer writer) throws IOException {
+            @Override
+            public void write(final Writer writer) throws IOException {
                 final StringBuffer data = new StringBuffer();
                 data.append("<number>");
                 data.append(handler.value + 1);
@@ -322,13 +316,14 @@ public class XmlDataManager implements D
         return handler.value + 1;
     }
 
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
     // insertObject, remove
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
 
     /**
      * Save the data for an object and adds the reference to a list of instances
      */
+    @Override
     public final void insertObject(final ObjectData data) {
         if (data.getOid() == null) {
             throw new IllegalArgumentException("Oid must be non-null");
@@ -338,19 +333,17 @@ public class XmlDataManager implements D
         addReferenceToInstancesFile(data.getOid(), data.getSpecification());
     }
 
-    
-
     private void addReferenceToInstancesFile(final SerialOid oid, final ObjectSpecification noSpec) {
-    	final Vector<SerialOid> instances = loadInstances(noSpec);
-		instances.addElement(oid);
-		writeInstanceFile(noSpec, instances);
+        final Vector<SerialOid> instances = loadInstances(noSpec);
+        instances.addElement(oid);
+        writeInstanceFile(noSpec, instances);
     }
 
-
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
     // remove
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
 
+    @Override
     public final void remove(final SerialOid oid) throws ObjectNotFoundException, ObjectPersistenceException {
         final Data data = loadData(oid);
         removeReferenceFromInstancesFile(oid, data.getSpecification());
@@ -364,29 +357,27 @@ public class XmlDataManager implements D
         xmlFile.delete(filename(oid));
     }
 
-
     private void removeReferenceFromInstancesFile(final SerialOid oid, final ObjectSpecification noSpec) {
-		final Vector<SerialOid> instances = loadInstances(noSpec);
-		instances.removeElement(oid);
-		writeInstanceFile(noSpec, instances);
+        final Vector<SerialOid> instances = loadInstances(noSpec);
+        instances.removeElement(oid);
+        writeInstanceFile(noSpec, instances);
     }
 
-
-    
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
     // helpers (used by both add & remove)
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
 
     private void writeInstanceFile(final ObjectSpecification noSpec, final Vector<SerialOid> instances) {
-    	writeInstanceFile(noSpec.getFullIdentifier(), instances);
+        writeInstanceFile(noSpec.getFullIdentifier(), instances);
     }
 
     private void writeInstanceFile(final String name, final Vector<SerialOid> instances) {
         xmlFile.writeXml(name, new ContentWriter() {
-            public void write(Writer writer) throws IOException {
+            @Override
+            public void write(final Writer writer) throws IOException {
                 final StringBuffer data = new StringBuffer();
                 data.append("<instances name=\"" + name + "\">\n");
-                for (SerialOid elementAt: instances) {
+                for (final SerialOid elementAt : instances) {
                     data.append("  <instance id=\"" + encodedOid(elementAt) + "\"/>\n");
                 }
                 data.append("</instances>");
@@ -395,141 +386,132 @@ public class XmlDataManager implements D
         });
     }
 
-
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
     // save
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
 
     /**
      * Save the data for latter retrieval.
      */
+    @Override
     public final void save(final Data data) {
         writeInstanceToItsDataFile(data);
     }
 
     private void writeInstanceToItsDataFile(final Data data) {
-		xmlFile.writeXml(filename(data.getOid()), new ContentWriter() {
-		    public void write(Writer writer) throws IOException {
-		        final StringBuffer xml = new StringBuffer();
-		        final boolean isObject = data instanceof ObjectData;
-		        final String tag = isObject ? "isis" : "collection";
-		        xml.append("<" + tag);
-		        xml.append(attribute("type", data.getTypeName()));
-		        xml.append(attribute("id", "" + encodedOid(data.getOid())));
-		        xml.append(attribute("user", "" + IsisContext.getAuthenticationSession().getUserName()));
-		        
-		        final long sequence = data.getVersion().getSequence();
-		        final String sequenceString = Long.toHexString(sequence).toUpperCase();
-		        xml.append(attribute("ver", "" + sequenceString));
-		        
-		        xml.append(">\n");
-		        
-		        if (isObject) {
-		            writeObject(data, xml);
-		        } else {
-		            writeCollection(data, xml);
-		        }
-		        
-		        xml.append("</" + tag + ">\n");
-		        writer.write(xml.toString());
-		    }
-		});
-    }
-
-
-	private void writeObject(final Data data, final StringBuffer xml) {
-		final ObjectData object = (ObjectData) data;
-		for(final String field: object.fields()) {
-		    writeField(xml, object, field);
-		}
-	}
-
-
-	private void writeField(final StringBuffer xml, final ObjectData object,
-			final String field) {
-		final Object entry = object.get(field);
-
-		if (entry instanceof SerialOid) {
-		    writeAssociationField(xml, field, entry);
-		} else if (entry instanceof ReferenceVector) {
-		    writeMultipleAssociationField(xml, field, entry);
-		} else {
-		    writeValueField(xml, field, entry);
-		}
-	}
-
-	private void writeAssociationField(final StringBuffer xml, final String field,
-			final Object entry) {
-		Assert.assertFalse(((SerialOid) entry).isTransient());
-		xml.append("  <association field=\"" + field + "\" ");
-		xml.append("ref=\"" + encodedOid((SerialOid) entry) + "\"/>\n");
-	}
-
-	private void writeMultipleAssociationField(final StringBuffer xml,
-			final String field, final Object entry) {
-		final ReferenceVector references = (ReferenceVector) entry;
-		final int size = references.size();
-
-		if (size > 0) {
-		    xml.append("  <multiple-association field=\"" + field + "\" ");
-		    xml.append(">\n");
-		    for (int i = 0; i < size; i++) {
-		        final Object oid = references.elementAt(i);
-		        if (((SerialOid) oid).isTransient()) {
-		            throw new ObjectPersistenceException("Can't add tranisent OID (" + oid + ") to " + field + " element.");
-		        }
-		        xml.append("    <element ");
-		        xml.append("ref=\"" + encodedOid((SerialOid) oid) + "\"/>\n");
-		    }
-		    xml.append("  </multiple-association>\n");
-		}
-	}
-
-	private void writeValueField(final StringBuffer xml, final String field,
-			final Object entry) {
-		xml.append("  <value field=\"" + field + "\">");
-		xml.append(XmlFile.getValueWithSpecialsEscaped(entry.toString()));
-		xml.append("</value>\n");
-	}
-
-
-	private void writeCollection(final Data data, final StringBuffer xml) {
-		final CollectionData collection = (CollectionData) data;
-		final ReferenceVector refs = collection.references();
-		for (int i = 0; i < refs.size(); i++) {
-		    final Object oid = refs.elementAt(i);
-		    xml.append("  <element ");
-		    xml.append("ref=\"" + encodedOid((SerialOid) oid) + "\"/>\n");
-		}
-	}
+        xmlFile.writeXml(filename(data.getOid()), new ContentWriter() {
+            @Override
+            public void write(final Writer writer) throws IOException {
+                final StringBuffer xml = new StringBuffer();
+                final boolean isObject = data instanceof ObjectData;
+                final String tag = isObject ? "isis" : "collection";
+                xml.append("<" + tag);
+                xml.append(attribute("type", data.getTypeName()));
+                xml.append(attribute("id", "" + encodedOid(data.getOid())));
+                xml.append(attribute("user", "" + IsisContext.getAuthenticationSession().getUserName()));
+
+                final long sequence = data.getVersion().getSequence();
+                final String sequenceString = Long.toHexString(sequence).toUpperCase();
+                xml.append(attribute("ver", "" + sequenceString));
 
+                xml.append(">\n");
+
+                if (isObject) {
+                    writeObject(data, xml);
+                } else {
+                    writeCollection(data, xml);
+                }
+
+                xml.append("</" + tag + ">\n");
+                writer.write(xml.toString());
+            }
+        });
+    }
+
+    private void writeObject(final Data data, final StringBuffer xml) {
+        final ObjectData object = (ObjectData) data;
+        for (final String field : object.fields()) {
+            writeField(xml, object, field);
+        }
+    }
+
+    private void writeField(final StringBuffer xml, final ObjectData object, final String field) {
+        final Object entry = object.get(field);
+
+        if (entry instanceof SerialOid) {
+            writeAssociationField(xml, field, entry);
+        } else if (entry instanceof ReferenceVector) {
+            writeMultipleAssociationField(xml, field, entry);
+        } else {
+            writeValueField(xml, field, entry);
+        }
+    }
+
+    private void writeAssociationField(final StringBuffer xml, final String field, final Object entry) {
+        Assert.assertFalse(((SerialOid) entry).isTransient());
+        xml.append("  <association field=\"" + field + "\" ");
+        xml.append("ref=\"" + encodedOid((SerialOid) entry) + "\"/>\n");
+    }
+
+    private void writeMultipleAssociationField(final StringBuffer xml, final String field, final Object entry) {
+        final ReferenceVector references = (ReferenceVector) entry;
+        final int size = references.size();
+
+        if (size > 0) {
+            xml.append("  <multiple-association field=\"" + field + "\" ");
+            xml.append(">\n");
+            for (int i = 0; i < size; i++) {
+                final Object oid = references.elementAt(i);
+                if (((SerialOid) oid).isTransient()) {
+                    throw new ObjectPersistenceException("Can't add tranisent OID (" + oid + ") to " + field
+                        + " element.");
+                }
+                xml.append("    <element ");
+                xml.append("ref=\"" + encodedOid((SerialOid) oid) + "\"/>\n");
+            }
+            xml.append("  </multiple-association>\n");
+        }
+    }
+
+    private void writeValueField(final StringBuffer xml, final String field, final Object entry) {
+        xml.append("  <value field=\"" + field + "\">");
+        xml.append(XmlFile.getValueWithSpecialsEscaped(entry.toString()));
+        xml.append("</value>\n");
+    }
+
+    private void writeCollection(final Data data, final StringBuffer xml) {
+        final CollectionData collection = (CollectionData) data;
+        final ReferenceVector refs = collection.references();
+        for (int i = 0; i < refs.size(); i++) {
+            final Object oid = refs.elementAt(i);
+            xml.append("  <element ");
+            xml.append("ref=\"" + encodedOid((SerialOid) oid) + "\"/>\n");
+        }
+    }
 
     private String attribute(final String name, final String value) {
         return " " + name + "=\"" + value + "\"";
     }
 
-
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
     // Helpers
-    //////////////////////////////////////////////////////////
-
+    // ////////////////////////////////////////////////////////
 
     private String filename(final SerialOid oid) {
         return encodedOid(oid);
     }
 
     private String encodedOid(final SerialOid oid) {
-    	return Long.toHexString(oid.getSerialNo()).toUpperCase();
+        return Long.toHexString(oid.getSerialNo()).toUpperCase();
     }
-    
 
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
     // Debugging
-    //////////////////////////////////////////////////////////
+    // ////////////////////////////////////////////////////////
 
+    @Override
     public String getDebugData() {
         return "Data directory " + xmlFile.getDirectory();
     }
 
-
 }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/services/ServiceManager.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/services/ServiceManager.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/services/ServiceManager.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/services/ServiceManager.java Tue May  3 06:42:06 2011
@@ -17,12 +17,10 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.services;
 
 import org.apache.isis.core.metamodel.adapter.oid.Oid;
 
-
 public interface ServiceManager {
 
     void loadServices();
@@ -32,4 +30,3 @@ public interface ServiceManager {
     Oid getOidForService(String name);
 
 }
-

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/services/xml/XmlServiceManager.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/services/xml/XmlServiceManager.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/services/xml/XmlServiceManager.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/services/xml/XmlServiceManager.java Tue May  3 06:42:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.services.xml;
 
 import java.io.IOException;
@@ -25,17 +24,16 @@ import java.io.Writer;
 import java.util.Enumeration;
 import java.util.Vector;
 
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.services.ServiceManager;
 import org.apache.isis.core.commons.ensure.Assert;
 import org.apache.isis.core.commons.xml.ContentWriter;
 import org.apache.isis.core.commons.xml.XmlFile;
 import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.runtimes.dflt.objectstores.xml.internal.services.ServiceManager;
 import org.apache.isis.runtimes.dflt.runtime.persistence.oidgenerator.simple.SerialOid;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
-
 class ServiceElement {
     final SerialOid oid;
     final String id;
@@ -53,7 +51,7 @@ class ServiceHandler extends DefaultHand
 
     @Override
     public void startElement(final String ns, final String name, final String tagName, final Attributes attrs)
-            throws SAXException {
+        throws SAXException {
         if (tagName.equals("service")) {
             final long oid = Long.valueOf(attrs.getValue("oid"), 16).longValue();
             final String id = attrs.getValue("id");
@@ -77,6 +75,7 @@ public class XmlServiceManager implement
         return Long.toHexString(oid.getSerialNo()).toUpperCase();
     }
 
+    @Override
     public Oid getOidForService(final String name) {
         for (final Enumeration e = services.elements(); e.hasMoreElements();) {
             final ServiceElement element = (ServiceElement) e.nextElement();
@@ -87,12 +86,14 @@ public class XmlServiceManager implement
         return null;
     }
 
+    @Override
     public void loadServices() {
         final ServiceHandler handler = new ServiceHandler();
         xmlFile.parse(handler, SERVICES_FILE_NAME);
         services = handler.services;
     }
 
+    @Override
     public void registerService(final String name, final Oid oid) {
         final SerialOid soid = (SerialOid) oid;
         final ServiceElement element = new ServiceElement(soid, name);
@@ -102,7 +103,8 @@ public class XmlServiceManager implement
 
     public final void saveServices() {
         xmlFile.writeXml(SERVICES_FILE_NAME, new ContentWriter() {
-            public void write(Writer writer) throws IOException {
+            @Override
+            public void write(final Writer writer) throws IOException {
                 final String tag = SERVICES_FILE_NAME;
                 writer.append("<" + tag + ">\n");
                 for (final Enumeration e = services.elements(); e.hasMoreElements();) {
@@ -118,4 +120,3 @@ public class XmlServiceManager implement
         });
     }
 }
-

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/utils/CopyXmlObjectStore.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/utils/CopyXmlObjectStore.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/utils/CopyXmlObjectStore.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/utils/CopyXmlObjectStore.java Tue May  3 06:42:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.utils;
 
 import java.io.BufferedInputStream;
@@ -29,7 +28,6 @@ import java.io.IOException;
 
 import org.apache.isis.core.commons.exceptions.IsisException;
 
-
 public class CopyXmlObjectStore {
     public static void main(final String[] args) {
         final String workingDirectory = args[0];
@@ -50,8 +48,8 @@ public class CopyXmlObjectStore {
         }
 
         final String list[] = from.list();
-        for (int i = 0; i < list.length; i++) {
-            copyFile(new File(from, list[i]), new File(to, list[i]));
+        for (final String element : list) {
+            copyFile(new File(from, element), new File(to, element));
         }
     }
 
@@ -69,18 +67,19 @@ public class CopyXmlObjectStore {
                 bos.write(buffer, 0, len);
             }
         } catch (final IOException e) {
-            throw new IsisException("Error copying file " + from.getAbsolutePath() + " to " + to.getAbsolutePath(),
-                    e);
+            throw new IsisException("Error copying file " + from.getAbsolutePath() + " to " + to.getAbsolutePath(), e);
         } finally {
             if (bis != null) {
                 try {
                     bis.close();
-                } catch (final IOException ignore) {}
+                } catch (final IOException ignore) {
+                }
             }
             if (bos != null) {
                 try {
                     bos.close();
-                } catch (final IOException ignore) {}
+                } catch (final IOException ignore) {
+                }
             }
         }
     }

Modified: incubator/isis/trunk/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/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/version/FileVersion.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/version/FileVersion.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/version/FileVersion.java Tue May  3 06:42:06 2011
@@ -17,21 +17,19 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.version;
 
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.Date;
 
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.clock.Clock;
 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;
 import org.apache.isis.core.metamodel.adapter.version.VersionUserAndTimeAbstract;
-
+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;
@@ -57,26 +55,27 @@ public class FileVersion extends Version
 
     @Override
     public void encode(final DataOutputExtended output) throws IOException {
-    	super.encode(output);
+        super.encode(output);
     }
 
-	private void initialized() {
-		// nothing to do
-	}
+    private void initialized() {
+        // nothing to do
+    }
 
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
     //
-    /////////////////////////////////////////////////////////
-    
+    // ///////////////////////////////////////////////////////
 
     public long getSequence() {
         return getTime().getTime();
     }
 
+    @Override
     public String sequence() {
         return Long.toString(getSequence(), 16);
     }
 
+    @Override
     public boolean different(final Version version) {
         if (version instanceof FileVersion) {
             final FileVersion other = (FileVersion) version;
@@ -91,11 +90,11 @@ public class FileVersion extends Version
     }
 
     // don't think is used...
-//    @Override
-//    protected VersionAbstract next() {
-//        // return new FileVersion(user);
-//        throw new NotYetImplementedException();
-//    }
+    // @Override
+    // protected VersionAbstract next() {
+    // // return new FileVersion(user);
+    // throw new NotYetImplementedException();
+    // }
 
     @Override
     public boolean equals(final Object obj) {

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/ObjectStorePersistenceHelper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/ObjectStorePersistenceHelper.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/ObjectStorePersistenceHelper.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/ObjectStorePersistenceHelper.java Tue May  3 06:42:06 2011
@@ -17,29 +17,31 @@
  *  under the License.
  */
 
+package org.apache.isis.runtimes.dflt.objectstores.xml;
 
-package org.apache.isis.runtimes.dflt.objectstores.xml;
-
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.testspec.TestProxySpecification;
 import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryBuiltIn;
-
-public class ObjectStorePersistenceHelper implements PersistenceQueryBuiltIn {
-	ObjectSpecification specification = null;
-
-	public ObjectStorePersistenceHelper(TestProxySpecification spec) {
-		specification = spec;
-	}
-
-	public boolean matches(ObjectAdapter object) {
-		if (object.getSpecification().getClass().getName().equals(specification.getClass().getName()))
-			return true;
-		return false;
-	}
-
-	public ObjectSpecification getSpecification() {
-		return specification;
-	}
-
-}
+
+public class ObjectStorePersistenceHelper implements PersistenceQueryBuiltIn {
+    ObjectSpecification specification = null;
+
+    public ObjectStorePersistenceHelper(final TestProxySpecification spec) {
+        specification = spec;
+    }
+
+    @Override
+    public boolean matches(final ObjectAdapter object) {
+        if (object.getSpecification().getClass().getName().equals(specification.getClass().getName())) {
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public ObjectSpecification getSpecification() {
+        return specification;
+    }
+
+}

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest.java Tue May  3 06:42:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml;
 
 import static org.junit.Assert.assertFalse;
@@ -25,19 +24,13 @@ import static org.junit.Assert.assertTru
 
 import java.util.Collections;
 
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.integration.junit4.JUnit4Mockery;
-import org.junit.Before;
-import org.junit.Test;
-
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.clock.DefaultClock;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.MockDataManager;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.services.DummyServiceManager;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.version.SerialNumberVersion;
 import org.apache.isis.core.metamodel.adapter.version.Version;
 import org.apache.isis.core.metamodel.testspec.TestProxySpecification;
+import org.apache.isis.runtimes.dflt.objectstores.xml.internal.clock.DefaultClock;
+import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.MockDataManager;
+import org.apache.isis.runtimes.dflt.objectstores.xml.internal.services.DummyServiceManager;
 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;
@@ -47,23 +40,28 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.runtimes.dflt.runtime.testsystem.ProxyJunit4TestCase;
 import org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyAdapter;
 import org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyConfiguration;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.integration.junit4.JUnit4Mockery;
+import org.junit.Before;
+import org.junit.Test;
 
 public class XmlObjectStoreTest extends ProxyJunit4TestCase {
 
-	private Mockery context = new JUnit4Mockery();
-	private XmlObjectStore objectStore;
+    private final Mockery context = new JUnit4Mockery();
+    private XmlObjectStore objectStore;
     private MockDataManager dataManager;
     private TestProxyAdapter adapter;
     private TestProxySpecification spec;
     private TestProxyConfiguration configuration;
     private ObjectStorePersistenceHelper persistenceHelper;
-	private PersistenceCommandContext transaction;
-	private ObjectAdapter mockAdapter;
+    private PersistenceCommandContext transaction;
+    private ObjectAdapter mockAdapter;
 
     @Before
     public void setUp() throws Exception {
 
-		mockAdapter = context.mock(ObjectAdapter.class);
+        mockAdapter = context.mock(ObjectAdapter.class);
         // system
         dataManager = new MockDataManager();
         objectStore = new XmlObjectStore(dataManager, new DummyServiceManager());
@@ -76,92 +74,93 @@ public class XmlObjectStoreTest extends 
         adapter = new TestProxyAdapter();
         adapter.setupSpecification(spec);
         adapter.setOptimisticLock(new SerialNumberVersion(23, null, null));
-    	adapter.setupOid(SerialOid.createPersistent(1));
+        adapter.setupOid(SerialOid.createPersistent(1));
         persistenceHelper = new ObjectStorePersistenceHelper(spec);
         transaction = null;
     }
 
-	@Test
-	public void validatesSaveObjectCommandWithOptimisticLock() throws Exception {
-		allowingGetOidAndGetObjectAndTitleStringFromAdapter();
-		context.checking(new Expectations() {
-			{
-				one(mockAdapter).setOptimisticLock(with(any(Version.class)));
-			}
-		});
-		objectStore.createSaveObjectCommand(mockAdapter);
-	}
+    @Test
+    public void validatesSaveObjectCommandWithOptimisticLock() throws Exception {
+        allowingGetOidAndGetObjectAndTitleStringFromAdapter();
+        context.checking(new Expectations() {
+            {
+                one(mockAdapter).setOptimisticLock(with(any(Version.class)));
+            }
+        });
+        objectStore.createSaveObjectCommand(mockAdapter);
+    }
 
     @Test
     public void ValidatesCreateObjectCommand() throws Exception {
-		CreateObjectCommand command = objectStore.createCreateObjectCommand(adapter);
-		command.execute(transaction);
-		assertFalse(objectStore.hasInstances(spec));
+        final CreateObjectCommand command = objectStore.createCreateObjectCommand(adapter);
+        command.execute(transaction);
+        assertFalse(objectStore.hasInstances(spec));
     }
 
     @Test
     public void validatesDestroyObjectCommand() throws Exception {
-		DestroyObjectCommand command = objectStore.createDestroyObjectCommand(adapter);
-		command.execute(transaction);
-		assertFalse(objectStore.hasInstances(spec));
+        final DestroyObjectCommand command = objectStore.createDestroyObjectCommand(adapter);
+        command.execute(transaction);
+        assertFalse(objectStore.hasInstances(spec));
     }
 
     @Test
     public void validatesSaveObjectCommand() throws Exception {
-		SaveObjectCommand command = objectStore.createSaveObjectCommand(adapter);
-		command.execute(transaction);
-		assertTrue(objectStore.hasInstances(spec));
+        final SaveObjectCommand command = objectStore.createSaveObjectCommand(adapter);
+        command.execute(transaction);
+        assertTrue(objectStore.hasInstances(spec));
     }
-    
+
     @Test
     public void validatesGettingObjectStoreInstances() throws Exception {
-        SaveObjectCommand command = objectStore.createSaveObjectCommand(adapter);
-        objectStore.execute(Collections.<PersistenceCommand>singletonList(command));
-    	ObjectAdapter[] array = objectStore.getInstances(persistenceHelper);
-    	assertTrue(array.length == 1);
-    }
-    
-	@Test 
-	public void validatesObjectStoreName()throws Exception {
-		assertTrue(objectStore.name().equals("XML"));
-	}
-	
-	@Test 
-	public void validatesObjectStoreHasInstances()throws Exception {
-        SaveObjectCommand command = objectStore.createSaveObjectCommand(adapter);
-        objectStore.execute(Collections.<PersistenceCommand>singletonList(command));
-		assertTrue(objectStore.hasInstances(spec));
-	}
-	
-	@Test 
-	public void validatesObjectStoreIfFixtureIsInstalled()throws Exception {
-        SaveObjectCommand command = objectStore.createSaveObjectCommand(adapter);
-        objectStore.execute(Collections.<PersistenceCommand>singletonList(command));
-        objectStore.open();        
-		assertTrue(objectStore.isFixturesInstalled());
-	}
-	
-	@Test 
-	public void validatesObjectStoreGetObject()throws Exception {
-        SaveObjectCommand command = objectStore.createSaveObjectCommand(adapter);
-        objectStore.execute(Collections.<PersistenceCommand>singletonList(command));
-		assertTrue(objectStore.getObject(adapter.getOid(), adapter.getSpecification()).getOid().equals(adapter.getOid()));
-	}
-	
-	@Test
-	public void validateObjectStoreCreationWithProxyConfiguration() throws Exception {
-		XmlObjectStore objectStore = new XmlObjectStore(configuration);
-		assertFalse(objectStore.isFixturesInstalled());
-	}
-	private void allowingGetOidAndGetObjectAndTitleStringFromAdapter() {
-		context.checking(new Expectations() {
-			{
-				allowing(mockAdapter).getOid();
-				allowing(mockAdapter).getObject();
-				allowing(mockAdapter).titleString();
-			}
-		});
-	}
-	
+        final SaveObjectCommand command = objectStore.createSaveObjectCommand(adapter);
+        objectStore.execute(Collections.<PersistenceCommand> singletonList(command));
+        final ObjectAdapter[] array = objectStore.getInstances(persistenceHelper);
+        assertTrue(array.length == 1);
+    }
+
+    @Test
+    public void validatesObjectStoreName() throws Exception {
+        assertTrue(objectStore.name().equals("XML"));
+    }
+
+    @Test
+    public void validatesObjectStoreHasInstances() throws Exception {
+        final SaveObjectCommand command = objectStore.createSaveObjectCommand(adapter);
+        objectStore.execute(Collections.<PersistenceCommand> singletonList(command));
+        assertTrue(objectStore.hasInstances(spec));
+    }
+
+    @Test
+    public void validatesObjectStoreIfFixtureIsInstalled() throws Exception {
+        final SaveObjectCommand command = objectStore.createSaveObjectCommand(adapter);
+        objectStore.execute(Collections.<PersistenceCommand> singletonList(command));
+        objectStore.open();
+        assertTrue(objectStore.isFixturesInstalled());
+    }
+
+    @Test
+    public void validatesObjectStoreGetObject() throws Exception {
+        final SaveObjectCommand command = objectStore.createSaveObjectCommand(adapter);
+        objectStore.execute(Collections.<PersistenceCommand> singletonList(command));
+        assertTrue(objectStore.getObject(adapter.getOid(), adapter.getSpecification()).getOid()
+            .equals(adapter.getOid()));
+    }
+
+    @Test
+    public void validateObjectStoreCreationWithProxyConfiguration() throws Exception {
+        final XmlObjectStore objectStore = new XmlObjectStore(configuration);
+        assertFalse(objectStore.isFixturesInstalled());
+    }
+
+    private void allowingGetOidAndGetObjectAndTitleStringFromAdapter() {
+        context.checking(new Expectations() {
+            {
+                allowing(mockAdapter).getOid();
+                allowing(mockAdapter).getObject();
+                allowing(mockAdapter).titleString();
+            }
+        });
+    }
 
 }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlPersistenceMechanismInstallerTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlPersistenceMechanismInstallerTest.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlPersistenceMechanismInstallerTest.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlPersistenceMechanismInstallerTest.java Tue May  3 06:42:06 2011
@@ -17,9 +17,8 @@
  *  under the License.
  */
 
+package org.apache.isis.runtimes.dflt.objectstores.xml;
 
-package org.apache.isis.runtimes.dflt.objectstores.xml;
-
 import static org.junit.Assert.assertTrue;
 
 import org.apache.isis.runtimes.dflt.runtime.system.ContextCategory;
@@ -33,23 +32,25 @@ import org.jmock.Mockery;
 import org.jmock.integration.junit4.JUnit4Mockery;
 import org.junit.Before;
 import org.junit.Test;
-
-public class XmlPersistenceMechanismInstallerTest  extends ProxyJunit4TestCase {
-	
-    private Mockery context = new JUnit4Mockery();
-    private DeploymentType mockDeploymentType;
-    XmlPersistenceMechanismInstaller mockInstaller;
-    
-    @Before
-    public void setUp() throws Exception {
-    	mockDeploymentType = new DeploymentType("SINGLE_USER", DeploymentCategory.PRODUCTION, ContextCategory.STATIC, SystemConstants.VIEWER_DEFAULT, Splash.NO_SHOW);
-    	mockInstaller = new XmlPersistenceMechanismInstaller();
-    }
-    
-    @Test
-	public void testCreatePersistenceSessionFactory() throws Exception {
-    	PersistenceSessionFactory factory = mockInstaller.createPersistenceSessionFactory(mockDeploymentType);
-		assertTrue(factory != null);
-	}
-    
-}
+
+public class XmlPersistenceMechanismInstallerTest extends ProxyJunit4TestCase {
+
+    private final Mockery context = new JUnit4Mockery();
+    private DeploymentType mockDeploymentType;
+    XmlPersistenceMechanismInstaller mockInstaller;
+
+    @Before
+    public void setUp() throws Exception {
+        mockDeploymentType =
+            new DeploymentType("SINGLE_USER", DeploymentCategory.PRODUCTION, ContextCategory.STATIC,
+                SystemConstants.VIEWER_DEFAULT, Splash.NO_SHOW);
+        mockInstaller = new XmlPersistenceMechanismInstaller();
+    }
+
+    @Test
+    public void testCreatePersistenceSessionFactory() throws Exception {
+        final PersistenceSessionFactory factory = mockInstaller.createPersistenceSessionFactory(mockDeploymentType);
+        assertTrue(factory != null);
+    }
+
+}

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/DefaultClockTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/DefaultClockTest.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/DefaultClockTest.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/DefaultClockTest.java Tue May  3 06:42:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.clock;
 
 import static org.junit.Assert.assertTrue;
@@ -25,17 +24,12 @@ import static org.junit.Assert.assertTru
 import org.apache.isis.runtimes.dflt.runtime.testsystem.ProxyJunit4TestCase;
 import org.junit.Test;
 
-
-
-
-
-
-public class DefaultClockTest extends ProxyJunit4TestCase{
+public class DefaultClockTest extends ProxyJunit4TestCase {
     DefaultClock clock;
 
     @Test
     public void testGetTime() {
-    	clock = new DefaultClock();
-       	assertTrue(clock.getTime()>0);        
+        clock = new DefaultClock();
+        assertTrue(clock.getTime() > 0);
     }
 }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/TestClock.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/TestClock.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/TestClock.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/TestClock.java Tue May  3 06:42:06 2011
@@ -17,18 +17,12 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.clock;
 
-
-
-
-
-
-
 public class TestClock implements Clock {
     long time = 0;
 
+    @Override
     public synchronized long getTime() {
         time += 1;
         return time;

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/MockDataManager.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/MockDataManager.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/MockDataManager.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/MockDataManager.java Tue May  3 06:42:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.data;
 
 import java.util.Iterator;
@@ -29,7 +28,6 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.runtimes.dflt.runtime.persistence.oidgenerator.simple.SerialOid;
 import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
 
-
 public class MockDataManager implements DataManager {
     private final Vector actions = new Vector();
 
@@ -48,55 +46,69 @@ public class MockDataManager implements 
         return null;
     }
 
-    public void insertObject(final ObjectData data) throws ObjectPersistenceException {}
+    @Override
+    public void insertObject(final ObjectData data) throws ObjectPersistenceException {
+    }
 
+    @Override
     public boolean isFixturesInstalled() {
         return true;
     }
 
+    @Override
     public void remove(final SerialOid oid) throws ObjectNotFoundException, ObjectPersistenceException {
-    	ObjectDataVector vector = new ObjectDataVector();
-        Iterator i = actions.iterator();
+        final ObjectDataVector vector = new ObjectDataVector();
+        final Iterator i = actions.iterator();
         while (i.hasNext()) {
-        	ObjectData data = (ObjectData)i.next();
-            if (data.getOid().equals(oid))
-             	actions.remove(data);        		  
+            final ObjectData data = (ObjectData) i.next();
+            if (data.getOid().equals(oid)) {
+                actions.remove(data);
+            }
         }
     }
 
+    @Override
     public void save(final Data data) throws ObjectPersistenceException {
         actions.addElement(data);
     }
 
-    public void shutdown() {}
+    @Override
+    public void shutdown() {
+    }
 
+    @Override
     public ObjectDataVector getInstances(final ObjectData pattern) {
-    	ObjectDataVector vector = new ObjectDataVector();
-        Iterator i = actions.iterator();
+        final ObjectDataVector vector = new ObjectDataVector();
+        final Iterator i = actions.iterator();
         while (i.hasNext()) {
-        	ObjectData data = (ObjectData)i.next();
-          if (pattern.getSpecification().equals(data.getSpecification()))
-        		  vector.addElement(data);
+            final ObjectData data = (ObjectData) i.next();
+            if (pattern.getSpecification().equals(data.getSpecification())) {
+                vector.addElement(data);
+            }
         }
-    	
+
         return vector;
     }
 
+    @Override
     public Data loadData(final SerialOid oid) {
-       	ObjectDataVector vector = new ObjectDataVector();
-        Iterator i = actions.iterator();
+        final ObjectDataVector vector = new ObjectDataVector();
+        final Iterator i = actions.iterator();
         while (i.hasNext()) {
-        	ObjectData data = (ObjectData)i.next();
-          if (data.getOid().equals(oid))
-        		  return data;
+            final ObjectData data = (ObjectData) i.next();
+            if (data.getOid().equals(oid)) {
+                return data;
+            }
         }
-         return null;
+        return null;
     }
 
+    @Override
     public int numberOfInstances(final ObjectData pattern) {
         return actions.size();
     }
 
+    @Override
     public String getDebugData() {
         return null;
     }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataTest.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataTest.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataTest.java Tue May  3 06:42:06 2011
@@ -17,19 +17,17 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.xml.internal.data;
 
 import java.util.Iterator;
 
 import junit.framework.TestCase;
 
+import org.apache.isis.core.metamodel.testspec.TestProxySpecification;
 import org.apache.isis.runtimes.dflt.objectstores.xml.internal.clock.DefaultClock;
 import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
-import org.apache.isis.core.metamodel.testspec.TestProxySpecification;
 import org.apache.isis.runtimes.dflt.runtime.persistence.oidgenerator.simple.SerialOid;
 
-
 public class ObjectDataTest extends TestCase {
 
     public void testValueField() {



Mime
View raw message