You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ke...@apache.org on 2013/02/08 18:55:52 UTC
[3/4] git commit: ISIS-220: Implemented optional extra parameters in
all locations
ISIS-220: Implemented optional extra parameters in all locations
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/c064a0e9
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/c064a0e9
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/c064a0e9
Branch: refs/heads/master
Commit: c064a0e91a46163338a720e80679938b8c83aa6b
Parents: 7ac25a6
Author: Kevin Meyer <ke...@apache.org>
Authored: Fri Feb 8 18:21:22 2013 +0100
Committer: Kevin Meyer <ke...@apache.org>
Committed: Fri Feb 8 18:21:22 2013 +0100
----------------------------------------------------------------------
.../isis/applib/AbstractContainedObject.java | 26 ++++++------
.../apache/isis/applib/DomainObjectContainer.java | 18 +++++---
.../java/org/apache/isis/applib/query/Query.java | 2 +-
.../container/DomainObjectContainerDefault.java | 30 +++++++-------
.../isis/core/objectstore/InMemoryObjectStore.java | 18 ++++----
.../system/transaction/IsisTransactionManager.java | 1 -
6 files changed, 49 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/c064a0e9/core/applib/src/main/java/org/apache/isis/applib/AbstractContainedObject.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/AbstractContainedObject.java b/core/applib/src/main/java/org/apache/isis/applib/AbstractContainedObject.java
index ec0978a..65bdc61 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/AbstractContainedObject.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/AbstractContainedObject.java
@@ -74,43 +74,43 @@ public abstract class AbstractContainedObject {
/**
* Convenience method that delegates to {@link DomainObjectContainer}.
*
- * @see DomainObjectContainer#allInstances(Class)
+ * @see DomainObjectContainer#allInstances(Class, long...)
*/
- protected <T> List<T> allInstances(final Class<T> ofType) {
- return getContainer().allInstances(ofType);
+ protected <T> List<T> allInstances(final Class<T> ofType, long... range) {
+ return getContainer().allInstances(ofType, range);
}
/**
* Convenience method that delegates to {@link DomainObjectContainer}.
*
- * @see DomainObjectContainer#allMatches(Class, Filter)
+ * @see DomainObjectContainer#allMatches(Class, Filter, long...)
*/
- protected <T> List<T> allMatches(final Class<T> ofType, final Filter<? super T> filter) {
- return getContainer().allMatches(ofType, filter);
+ protected <T> List<T> allMatches(final Class<T> ofType, final Filter<? super T> filter, long... range) {
+ return getContainer().allMatches(ofType, filter, range);
}
/**
* Convenience method that delegates to {@link DomainObjectContainer}.
*
- * @see DomainObjectContainer#allMatches(Class, Object)
+ * @see DomainObjectContainer#allMatches(Class, Object, long...)
*/
- protected <T> List<T> allMatches(final Class<T> ofType, final T pattern) {
- return getContainer().allMatches(ofType, pattern);
+ protected <T> List<T> allMatches(final Class<T> ofType, final T pattern, long... range) {
+ return getContainer().allMatches(ofType, pattern, range);
}
/**
* Convenience method that delegates to {@link DomainObjectContainer}.
*
- * @see DomainObjectContainer#allMatches(Class, String)
+ * @see DomainObjectContainer#allMatches(Class, String, long...)
*/
- protected <T> List<T> allMatches(final Class<T> ofType, final String title) {
- return getContainer().allMatches(ofType, title);
+ protected <T> List<T> allMatches(final Class<T> ofType, final String title, long... range) {
+ return getContainer().allMatches(ofType, title, range);
}
/**
* Convenience method that delegates to {@link DomainObjectContainer}.
*
- * @see DomainObjectContainer#allMatches(Query)
+ * @see DomainObjectContainer#allMatches(Query, long...)
*/
protected <T> List<T> allMatches(final Query<T> query) {
return getContainer().allMatches(query);
http://git-wip-us.apache.org/repos/asf/isis/blob/c064a0e9/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java b/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
index f7b379f..8d90121 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
@@ -276,8 +276,9 @@ public interface DomainObjectContainer {
* <p>
* This method should only be called where the number of instances is known
* to be relatively low.
+ * @param range TODO
*/
- public <T> List<T> allInstances(Class<T> ofType);
+ public <T> List<T> allInstances(Class<T> ofType, long... range);
/**
* Returns all the instances of the specified type (including subtypes) that
@@ -291,9 +292,10 @@ public interface DomainObjectContainer {
*
* <p>
* This method is useful during exploration/prototyping, but you may want to
- * use {@link #allMatches(Query)} for production code.
+ * use {@link #allMatches(Query, long...)} for production code.
+ * @param range TODO
*/
- public <T> List<T> allMatches(final Class<T> ofType, final Filter<? super T> filter);
+ public <T> List<T> allMatches(final Class<T> ofType, final Filter<? super T> filter, long... range);
/**
* Returns all the instances of the specified type (including subtypes) that
@@ -307,9 +309,10 @@ public interface DomainObjectContainer {
*
* <p>
* This method is useful during exploration/prototyping, but you may want to
- * use {@link #allMatches(Query)} for production code.
+ * use {@link #allMatches(Query, long...)} for production code.
+ * @param range TODO
*/
- public <T> List<T> allMatches(Class<T> ofType, String title);
+ public <T> List<T> allMatches(Class<T> ofType, String title, long... range);
/**
* Returns all the instances of the specified type (including subtypes) that
@@ -324,9 +327,10 @@ public interface DomainObjectContainer {
*
* <p>
* This method is useful during exploration/prototyping, but you may want to
- * use {@link #allMatches(Query)} for production code.
+ * use {@link #allMatches(Query, long...)} for production code.
+ * @param range TODO
*/
- <T> List<T> allMatches(Class<T> ofType, T pattern);
+ <T> List<T> allMatches(Class<T> ofType, T pattern, long... range);
/**
* Returns all the instances that match the given {@link Query}.
http://git-wip-us.apache.org/repos/asf/isis/blob/c064a0e9/core/applib/src/main/java/org/apache/isis/applib/query/Query.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/query/Query.java b/core/applib/src/main/java/org/apache/isis/applib/query/Query.java
index cc1819a..8dbafdb 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/query/Query.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/query/Query.java
@@ -35,7 +35,7 @@ import org.apache.isis.applib.filter.Filter;
* <b>Note:</b> that not every object store will necessarily support this
* interface. In particular, the in-memory object store does not. For this, you
* can use the {@link Filter} interface to similar effect, for example in
- * {@link DomainObjectContainer#allMatches(Class, Filter)}). Note that the
+ * {@link DomainObjectContainer#allMatches(Class, Filter, long...)}). Note that the
* filtering is done within the {@link DomainObjectContainer} rather than being
* pushed back to the object store.
*/
http://git-wip-us.apache.org/repos/asf/isis/blob/c064a0e9/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
index 4d0c9e5..87226a5 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
@@ -319,13 +319,13 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Quer
// //////////////////////////////////////////////////////////////////
@Override
- public <T> List<T> allInstances(final Class<T> type) {
- return allMatches(new QueryFindAllInstances<T>(type));
+ public <T> List<T> allInstances(final Class<T> type, long... range) {
+ return allMatches(new QueryFindAllInstances<T>(type, range));
}
@Override
- public <T> List<T> allMatches(final Class<T> cls, final Filter<? super T> filter) {
- final List<T> allInstances = allInstances(cls);
+ public <T> List<T> allMatches(final Class<T> cls, final Filter<? super T> filter, long... range) {
+ final List<T> allInstances = allInstances(cls, range);
final List<T> filtered = new ArrayList<T>();
for (final T instance : allInstances) {
if (filter.accept(instance)) {
@@ -336,14 +336,14 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Quer
}
@Override
- public <T> List<T> allMatches(final Class<T> type, final T pattern) {
+ public <T> List<T> allMatches(final Class<T> type, final T pattern, long... range) {
Assert.assertTrue("pattern not compatible with type", type.isAssignableFrom(pattern.getClass()));
- return allMatches(new QueryFindByPattern<T>(type, pattern));
+ return allMatches(new QueryFindByPattern<T>(type, pattern, range));
}
@Override
- public <T> List<T> allMatches(final Class<T> type, final String title) {
- return allMatches(new QueryFindByTitle<T>(type, title));
+ public <T> List<T> allMatches(final Class<T> type, final String title, long... range) {
+ return allMatches(new QueryFindByTitle<T>(type, title, range));
}
@Override
@@ -359,7 +359,7 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Quer
@Override
public <T> T firstMatch(final Class<T> cls, final Filter<T> filter) {
- final List<T> allInstances = allInstances(cls);
+ final List<T> allInstances = allInstances(cls); // Have to fetch all, as matching is done in next loop
for (final T instance : allInstances) {
if (filter.accept(instance)) {
return instance;
@@ -370,13 +370,13 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Quer
@Override
public <T> T firstMatch(final Class<T> type, final T pattern) {
- final List<T> instances = allMatches(type, pattern);
+ final List<T> instances = allMatches(type, pattern, 0, 1); // No need to fetch more than 1
return firstInstanceElseNull(instances);
}
@Override
public <T> T firstMatch(final Class<T> type, final String title) {
- final List<T> instances = allMatches(type, title);
+ final List<T> instances = allMatches(type, title, 0, 1); // No need to fetch more than 1
return firstInstanceElseNull(instances);
}
@@ -394,7 +394,7 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Quer
@Override
public <T> T uniqueMatch(final Class<T> type, final Filter<T> filter) {
- final List<T> instances = allMatches(type, filter);
+ final List<T> instances = allMatches(type, filter, 0, 2); // No need to fetch more than 2.
if (instances.size() > 1) {
throw new RepositoryException("Found more than one instance of " + type + " matching filter " + filter);
}
@@ -403,7 +403,7 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Quer
@Override
public <T> T uniqueMatch(final Class<T> type, final T pattern) {
- final List<T> instances = allMatches(type, pattern);
+ final List<T> instances = allMatches(type, pattern, 0, 2); // No need to fetch more than 2.
if (instances.size() > 1) {
throw new RepositoryException("Found more that one instance of " + type + " matching pattern " + pattern);
}
@@ -412,7 +412,7 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Quer
@Override
public <T> T uniqueMatch(final Class<T> type, final String title) {
- final List<T> instances = allMatches(type, title);
+ final List<T> instances = allMatches(type, title, 0, 2); // No need to fetch more than 2.
if (instances.size() > 1) {
throw new RepositoryException("Found more that one instance of " + type + " with title " + title);
}
@@ -421,7 +421,7 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Quer
@Override
public <T> T uniqueMatch(final Query<T> query) {
- final List<T> instances = allMatches(query);
+ final List<T> instances = allMatches(query); // No need to fetch more than 2.
if (instances.size() > 1) {
throw new RepositoryException("Found more that one instance for query:" + query.getDescription());
}
http://git-wip-us.apache.org/repos/asf/isis/blob/c064a0e9/core/objectstore-inmemory/src/main/java/org/apache/isis/core/objectstore/InMemoryObjectStore.java
----------------------------------------------------------------------
diff --git a/core/objectstore-inmemory/src/main/java/org/apache/isis/core/objectstore/InMemoryObjectStore.java b/core/objectstore-inmemory/src/main/java/org/apache/isis/core/objectstore/InMemoryObjectStore.java
index 9974bba..f3a5e19 100644
--- a/core/objectstore-inmemory/src/main/java/org/apache/isis/core/objectstore/InMemoryObjectStore.java
+++ b/core/objectstore-inmemory/src/main/java/org/apache/isis/core/objectstore/InMemoryObjectStore.java
@@ -24,6 +24,10 @@ import java.util.Iterator;
import java.util.List;
import java.util.Vector;
+import com.google.common.collect.Lists;
+
+import org.apache.log4j.Logger;
+
import org.apache.isis.core.commons.debug.DebugBuilder;
import org.apache.isis.core.commons.debug.DebugUtils;
import org.apache.isis.core.commons.exceptions.IsisException;
@@ -54,13 +58,9 @@ import org.apache.isis.core.runtime.persistence.objectstore.transaction.Persiste
import org.apache.isis.core.runtime.persistence.objectstore.transaction.SaveObjectCommand;
import org.apache.isis.core.runtime.persistence.query.PersistenceQueryBuiltIn;
import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.AdapterManagerSpi;
import org.apache.isis.core.runtime.system.persistence.PersistenceQuery;
import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
import org.apache.isis.core.runtime.system.persistence.PersistenceSessionFactory;
-import org.apache.log4j.Logger;
-
-import com.google.common.collect.Lists;
public class InMemoryObjectStore implements ObjectStoreSpi {
@@ -367,7 +367,7 @@ public class InMemoryObjectStore implements ObjectStoreSpi {
debug.appendln();
}
- private String debugCollectionGraph(final ObjectAdapter collection, final int level, final Vector recursiveElements) {
+ private String debugCollectionGraph(final ObjectAdapter collection, final int level, final Vector<ObjectAdapter> recursiveElements) {
final StringBuffer s = new StringBuffer();
if (recursiveElements.contains(collection)) {
@@ -397,14 +397,14 @@ public class InMemoryObjectStore implements ObjectStoreSpi {
return s.toString();
}
- private String debugGraph(final ObjectAdapter object, final int level, final Vector recursiveElements) {
+ private String debugGraph(final ObjectAdapter object, final int level, final Vector<ObjectAdapter> recursiveElements) {
if (level > 3) {
return "...\n"; // only go 3 levels?
}
- Vector elements;
+ Vector<ObjectAdapter> elements;
if (recursiveElements == null) {
- elements = new Vector(25, 10);
+ elements = new Vector<ObjectAdapter>(25, 10);
} else {
elements = recursiveElements;
}
@@ -416,7 +416,7 @@ public class InMemoryObjectStore implements ObjectStoreSpi {
}
}
- private String debugObjectGraph(final ObjectAdapter object, final int level, final Vector recursiveElements) {
+ private String debugObjectGraph(final ObjectAdapter object, final int level, final Vector<ObjectAdapter> recursiveElements) {
final StringBuffer s = new StringBuffer();
recursiveElements.addElement(object);
http://git-wip-us.apache.org/repos/asf/isis/blob/c064a0e9/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
index e5d10d8..efb34bb 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
@@ -33,7 +33,6 @@ import org.apache.log4j.Logger;
import org.apache.isis.core.commons.components.SessionScopedComponent;
import org.apache.isis.core.commons.debug.DebugBuilder;
import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.runtime.persistence.ObjectPersistenceException;
import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommand;
import org.apache.isis.core.runtime.persistence.objectstore.transaction.TransactionalResource;
import org.apache.isis.core.runtime.system.context.IsisContext;