You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2013/09/03 09:23:51 UTC
[5/7] git commit: ISIS-503: more minor refactoring...
ISIS-503: more minor refactoring...
... splitting out the responsibility of converting FacetedMethods to OTOA, OTMA or ObjectActions vs traversing the DeweyOrderSet collection.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/c2c30052
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/c2c30052
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/c2c30052
Branch: refs/heads/master
Commit: c2c30052de0443342123bc2d4da92d9e37e14a82
Parents: c8cd533
Author: Dan Haywood <da...@apache.org>
Authored: Tue Sep 3 07:24:14 2013 +0100
Committer: Dan Haywood <da...@apache.org>
Committed: Tue Sep 3 07:24:14 2013 +0100
----------------------------------------------------------------------
.../dflt/ObjectSpecificationDefault.java | 51 +++++++++++++-------
1 file changed, 34 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/c2c30052/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
index 37b264c..a4fe7a0 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
@@ -72,6 +72,8 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
import org.apache.isis.core.metamodel.spec.feature.ObjectMemberContext;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
import org.apache.isis.core.metamodel.specloader.classsubstitutor.ClassSubstitutor;
import org.apache.isis.core.metamodel.specloader.specimpl.CreateObjectContext;
import org.apache.isis.core.metamodel.specloader.specimpl.FacetedMethodsBuilder;
@@ -236,11 +238,17 @@ public class ObjectSpecificationDefault extends ObjectSpecificationAbstract impl
for (final Object element : orderSet) {
if (element instanceof FacetedMethod) {
final FacetedMethod facetMethod = (FacetedMethod) element;
- if (facetMethod.getFeatureType().isCollection()) {
- associationsToAppendTo.add(createCollection(facetMethod));
- } else if (facetMethod.getFeatureType().isProperty()) {
- associationsToAppendTo.add(createProperty(facetMethod));
+ final ObjectAssociation objectAssociation = createAssociation(facetMethod);
+ if(objectAssociation != null) {
+ associationsToAppendTo.add(objectAssociation);
}
+
+ } else if (element instanceof OneToManyAssociation) {
+ // positioning for DeweyOrderSet acting on OTOA, OTMA rather than FacetedMethods
+ associationsToAppendTo.add((ObjectAssociation) element);
+ } else if (element instanceof OneToOneAssociation) {
+ // positioning for DeweyOrderSet acting on OTOA, OTMA rather than FacetedMethods
+ associationsToAppendTo.add((ObjectAssociation) element);
} else if (element instanceof DeweyOrderSet) {
// just flatten.
DeweyOrderSet childOrderSet = (DeweyOrderSet) element;
@@ -255,10 +263,16 @@ public class ObjectSpecificationDefault extends ObjectSpecificationAbstract impl
for (final Object element : orderSet) {
if (element instanceof FacetedMethod) {
final FacetedMethod facetedMethod = (FacetedMethod) element;
- if (facetedMethod.getFeatureType().isAction()) {
- actionsToAppendTo.add(createAction(facetedMethod));
+ final ObjectAction objectAction = createAction(facetedMethod);
+ if(objectAction != null) {
+ actionsToAppendTo.add(objectAction);
}
- } else if (element instanceof DeweyOrderSet) {
+ } else if(element instanceof ObjectAction) {
+ // positioning for DeweyOrderSet acting on ObjectActions rather than FacetedMethods
+ final ObjectAction objectAction = (ObjectAction) element;
+ actionsToAppendTo.add(objectAction);
+ }
+ else if (element instanceof DeweyOrderSet) {
final DeweyOrderSet set = ((DeweyOrderSet) element);
final List<ObjectAction> actions = Lists.newArrayList();
convertToObjectActions(set, actions);
@@ -269,22 +283,25 @@ public class ObjectSpecificationDefault extends ObjectSpecificationAbstract impl
}
}
- private OneToOneAssociationImpl createProperty(final FacetedMethod facetedMethod) {
- return new OneToOneAssociationImpl(facetedMethod, objectMemberContext);
- }
-
- private OneToManyAssociationImpl createCollection(final FacetedMethod facetedMethod) {
- return new OneToManyAssociationImpl(facetedMethod, objectMemberContext);
+ private ObjectAssociation createAssociation(final FacetedMethod facetMethod) {
+ if (facetMethod.getFeatureType().isCollection()) {
+ return new OneToManyAssociationImpl(facetMethod, objectMemberContext);
+ } else if (facetMethod.getFeatureType().isProperty()) {
+ return new OneToOneAssociationImpl(facetMethod, objectMemberContext);
+ } else {
+ return null;
+ }
}
private ObjectAction createAction(final FacetedMethod facetedMethod) {
- return new ObjectActionImpl(facetedMethod, objectMemberContext);
+ if (facetedMethod.getFeatureType().isAction()) {
+ return new ObjectActionImpl(facetedMethod, objectMemberContext);
+ } else {
+ return null;
+ }
}
-
-
-
// //////////////////////////////////////////////////////////////////////
// Whether a service or not
// //////////////////////////////////////////////////////////////////////