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 2010/11/16 15:26:00 UTC
svn commit: r1035641 - in /incubator/isis/trunk:
core/commons/src/main/java/org/apache/isis/commons/
core/commons/src/test/java/org/apache/isis/commons/
core/metamodel/src/main/java/org/apache/isis/metamodel/
core/metamodel/src/test/java/org/apache/isi...
Author: danhaywood
Date: Tue Nov 16 14:25:59 2010
New Revision: 1035641
URL: http://svn.apache.org/viewvc?rev=1035641&view=rev
Log:
aligning package names with maven groupId/artifactId for core/runtime
Removed:
incubator/isis/trunk/core/commons/src/main/java/org/apache/isis/commons/
incubator/isis/trunk/core/commons/src/test/java/org/apache/isis/commons/
incubator/isis/trunk/core/metamodel/src/main/java/org/apache/isis/metamodel/
incubator/isis/trunk/core/metamodel/src/test/java/org/apache/isis/metamodel/
incubator/isis/trunk/core/progmodel/src/main/java/org/apache/isis/metamodel/
incubator/isis/trunk/core/progmodel/src/test/java/org/apache/isis/metamodel/
incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/
incubator/isis/trunk/core/runtime/src/test/java/org/apache/isis/runtime/
incubator/isis/trunk/core/testsupport/src/main/java/org/apache/isis/common/
incubator/isis/trunk/core/webapp/src/main/java/org/apache/isis/webapp/
incubator/isis/trunk/core/webserver/src/main/java/org/apache/isis/webserver/
Modified:
incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/SetUpObjectsPeer.java
incubator/isis/trunk/viewer/bdd/src/docbkx/guide/isis-bdd-viewer.xml
Modified: incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/SetUpObjectsPeer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/SetUpObjectsPeer.java?rev=1035641&r1=1035640&r2=1035641&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/SetUpObjectsPeer.java (original)
+++ incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/SetUpObjectsPeer.java Tue Nov 16 14:25:59 2010
@@ -17,264 +17,260 @@ import org.apache.isis.viewer.bdd.common
import org.apache.isis.viewer.bdd.common.util.Strings;
public class SetUpObjectsPeer extends AbstractFixturePeer {
-
- public static enum Mode {
- PERSIST, DO_NOT_PERSIST;
-
- public boolean isPersist() {
- return this == PERSIST;
- }
- }
-
- public static enum PropertyResult {
- ALIAS, NO_SUCH_PROPERTY, NOT_A_PROPERTY, OK;
- public boolean isOk() {
- return this == OK;
- }
- }
+
+ public static enum Mode {
+ PERSIST, DO_NOT_PERSIST;
+
+ public boolean isPersist() {
+ return this == PERSIST;
+ }
+ }
+
+ public static enum PropertyResult {
+ ALIAS, NO_SUCH_PROPERTY, NOT_A_PROPERTY, OK;
+ public boolean isOk() {
+ return this == OK;
+ }
+ }
public static enum SetUpObjectResult {
- OK,
- NO_ASSOCIATION,
- CLEARED,
- CANNOT_CLEAR("(cannot clear)"),
- CANNOT_SET ("(cannot set"),
- CANNOT_PARSE("(cannot parse)"),
- UNKNOWN_REFERENCE("(unknown reference)");
- private String errorMessage;
- private SetUpObjectResult() {
- this(null);
- }
- private SetUpObjectResult(String errorMessage) {
- this.errorMessage = errorMessage;
- }
- public boolean isHandled() { return !isError(); }
- public boolean isError() { return errorMessage != null; }
- public String getErrorMessage() { return errorMessage; }
- }
-
- public interface AssociationVisitor {
- void visit(OneToOneAssociation association, int colNum);
- }
-
- private final ObjectSpecification spec;
-
- private final List<OneToOneAssociation> properties = new ArrayList<OneToOneAssociation>();
- private final CellBinding aliasBinding;
- private final SetUpObjectsPeer.Mode mode;
-
- private final List<String> cellTextList = new ArrayList<String>();
- private String alias;
-
- public SetUpObjectsPeer(AliasRegistry aliasesRegistry,
- final String className, final SetUpObjectsPeer.Mode mode,
- final CellBinding aliasBinding) {
- super(aliasesRegistry, aliasBinding);
-
- ObjectSpecification spec;
- try {
- spec = getSpecificationLoader().loadSpecification(className);
- } catch (final IsisException ex) {
- spec = null;
- }
- this.spec = spec;
-
- this.mode = mode;
- this.aliasBinding = aliasBinding;
- }
-
- public boolean isSpecOk() {
- return spec != null;
- }
-
- public List<OneToOneAssociation> getProperties() {
- return properties;
- }
-
- public CellBinding getAliasBinding() {
- return aliasBinding;
- }
-
- public PropertyResult definePropertyOrAlias(String heading, int colNum) {
-
- OneToOneAssociation otoa = null;
-
- try {
- final int aliasColumn = getAliasBinding().getColumn();
- if (colNum == aliasColumn) {
- return PropertyResult.ALIAS;
- }
-
- ObjectAssociation association = null;
- try {
- final String memberName = Strings.memberIdFor(heading);
- association = spec.getAssociation(memberName);
- } catch (final Exception ex) {
- return PropertyResult.NO_SUCH_PROPERTY;
- }
-
- if (!association.isOneToOneAssociation()) {
- return PropertyResult.NOT_A_PROPERTY;
- }
-
- otoa = (OneToOneAssociation) association;
-
- return PropertyResult.OK;
- } finally {
- // add an association if OK, add null otherwise
- getProperties().add(otoa);
- }
- }
-
- public void resetForNextObject() {
- cellTextList.clear();
- this.alias = null;
- }
-
- /**
- * Used by Concordion only.
- *
- * <p>
- * FitNesse, on the other hand, uses a more fine-grained approach, calling the underlying
- * methods.
- */
- public void createObject() throws StoryBoundValueException {
- ObjectAdapter adapter = createInstance();
-
- for (int colNum = 0; colNum < getProperties().size(); colNum++) {
- SetUpObjectResult result = setUpProperty(adapter, colNum);
-
- if (!result.isHandled()) {
- CellBinding cellBinding = getCellBindings().get(colNum);
- throw StoryBoundValueException.current(cellBinding, result.getErrorMessage());
- }
- }
-
- persistIfNecessary(adapter);
+ OK, NO_ASSOCIATION, CLEARED, CANNOT_CLEAR("(cannot clear)"), CANNOT_SET("(cannot set"),
+ CANNOT_PARSE("(cannot parse)"), UNKNOWN_REFERENCE("(unknown reference)");
+ private String errorMessage;
+
+ private SetUpObjectResult() {
+ this(null);
+ }
+
+ private SetUpObjectResult(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public boolean isHandled() {
+ return !isError();
+ }
+
+ public boolean isError() {
+ return errorMessage != null;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+ }
+
+ public interface AssociationVisitor {
+ void visit(OneToOneAssociation association, int colNum);
+ }
+
+ private final ObjectSpecification spec;
+
+ private final List<OneToOneAssociation> properties = new ArrayList<OneToOneAssociation>();
+ private final CellBinding aliasBinding;
+ private final SetUpObjectsPeer.Mode mode;
+
+ private final List<String> cellTextList = new ArrayList<String>();
+ private String alias;
+
+ public SetUpObjectsPeer(AliasRegistry aliasRegistry, final String className, final SetUpObjectsPeer.Mode mode,
+ final CellBinding aliasBinding) {
+ super(aliasRegistry, aliasBinding);
+
+ this.spec = loadSpecIfValid(className);
+
+ this.mode = mode;
+ this.aliasBinding = aliasBinding;
+ }
+
+ private ObjectSpecification loadSpecIfValid(final String className) {
+ try {
+ return getSpecificationLoader().loadSpecification(className);
+ } catch (final IsisException ex) {
+ return null;
+ }
+ }
+
+ public boolean isSpecOk() {
+ return spec != null;
+ }
+
+ public List<OneToOneAssociation> getProperties() {
+ return properties;
+ }
+
+ public CellBinding getAliasBinding() {
+ return aliasBinding;
+ }
+
+ public PropertyResult definePropertyOrAlias(String heading, int colNum) {
+
+ OneToOneAssociation otoa = null;
+
+ try {
+ final int aliasColumn = getAliasBinding().getColumn();
+ if (colNum == aliasColumn) {
+ return PropertyResult.ALIAS;
+ }
+
+ ObjectAssociation association = null;
+ try {
+ final String memberName = Strings.memberIdFor(heading);
+ association = spec.getAssociation(memberName);
+ } catch (final Exception ex) {
+ return PropertyResult.NO_SUCH_PROPERTY;
+ }
+
+ if (!association.isOneToOneAssociation()) {
+ return PropertyResult.NOT_A_PROPERTY;
+ }
+
+ otoa = (OneToOneAssociation) association;
+
+ return PropertyResult.OK;
+ } finally {
+ // add an association if OK, add null otherwise
+ getProperties().add(otoa);
+ }
+ }
+
+ public void resetForNextObject() {
+ cellTextList.clear();
+ this.alias = null;
+ }
+
+ /**
+ * Used by Concordion only.
+ *
+ * <p>
+ * FitNesse, on the other hand, uses a more fine-grained approach, calling the underlying methods.
+ */
+ public void createObject() throws StoryBoundValueException {
+ ObjectAdapter adapter = createInstance();
+
+ for (int colNum = 0; colNum < getProperties().size(); colNum++) {
+ SetUpObjectResult result = setUpProperty(adapter, colNum);
+
+ if (!result.isHandled()) {
+ CellBinding cellBinding = getCellBindings().get(colNum);
+ throw StoryBoundValueException.current(cellBinding, result.getErrorMessage());
+ }
+ }
+
+ persistIfNecessary(adapter);
alias(adapter);
resetForNextObject();
- }
+ }
+ public ObjectAdapter createInstance() {
+ if (spec == null) {
+ return null;
+ }
+ return getPersistenceSession().createInstance(spec);
+ }
- public ObjectAdapter createInstance() {
- if (spec == null) {
- return null;
- }
- return getPersistenceSession().createInstance(spec);
- }
-
- public SetUpObjectResult setUpProperty(ObjectAdapter adapter, int colNum) {
-
- final OneToOneAssociation association = getProperties().get(colNum);
- if (association == null) {
- return SetUpObjectResult.NO_ASSOCIATION;
- }
-
- final String cellText = cellTextList.get(colNum);
-
- // handle empty cell as null
- if (cellText == null || cellText.length() == 0) {
-
- // use clear facet if available
- final PropertyClearFacet clearFacet = association
- .getFacet(PropertyClearFacet.class);
-
- if (clearFacet != null) {
- clearFacet.clearProperty(adapter);
- return SetUpObjectResult.CLEARED;
- }
-
- // use setter facet otherwise
- final PropertySetterFacet setterFacet = association
- .getFacet(PropertySetterFacet.class);
-
- if (setterFacet != null) {
- setterFacet.setProperty(adapter, null);
- return SetUpObjectResult.CLEARED;
- }
-
- return SetUpObjectResult.CANNOT_CLEAR;
- }
-
- // non-empty, will need a setter
- final PropertySetterFacet setterFacet = association
- .getFacet(PropertySetterFacet.class);
- if (setterFacet == null) {
- return SetUpObjectResult.CANNOT_SET;
- }
-
- final ObjectSpecification fieldSpecification = association
- .getSpecification();
- final ParseableFacet parseableFacet = fieldSpecification
- .getFacet(ParseableFacet.class);
-
- ObjectAdapter referencedAdapter = null;
- if (parseableFacet != null) {
- // handle as parseable value
- try {
- referencedAdapter = parseableFacet.parseTextEntry(adapter,
- cellText);
- } catch (final IllegalArgumentException ex) {
- return SetUpObjectResult.CANNOT_PARSE;
- }
-
- } else {
- // handle as reference to known object
- referencedAdapter = getAliasRegistry().getAliased(cellText);
- if (referencedAdapter == null) {
- return SetUpObjectResult.UNKNOWN_REFERENCE;
- }
- }
-
- setterFacet.setProperty(adapter, referencedAdapter);
- return SetUpObjectResult.OK;
- }
-
- public void persistIfNecessary(ObjectAdapter adapter) {
- if (mode.isPersist()) {
- // xactn mgmt now done by PersistenceSession#makePersistent()
- // getTransactionManager().startTransaction();
- getPersistenceSession().makePersistent(adapter);
- // getTransactionManager().endTransaction();
- }
- }
+ public SetUpObjectResult setUpProperty(ObjectAdapter adapter, int colNum) {
- public void alias(ObjectAdapter adapter) {
+ final OneToOneAssociation association = getProperties().get(colNum);
+ if (association == null) {
+ return SetUpObjectResult.NO_ASSOCIATION;
+ }
+
+ final String cellText = cellTextList.get(colNum);
+
+ // handle empty cell as null
+ if (cellText == null || cellText.length() == 0) {
+
+ // use clear facet if available
+ final PropertyClearFacet clearFacet = association.getFacet(PropertyClearFacet.class);
+
+ if (clearFacet != null) {
+ clearFacet.clearProperty(adapter);
+ return SetUpObjectResult.CLEARED;
+ }
+
+ // use setter facet otherwise
+ final PropertySetterFacet setterFacet = association.getFacet(PropertySetterFacet.class);
+
+ if (setterFacet != null) {
+ setterFacet.setProperty(adapter, null);
+ return SetUpObjectResult.CLEARED;
+ }
+
+ return SetUpObjectResult.CANNOT_CLEAR;
+ }
+
+ // non-empty, will need a setter
+ final PropertySetterFacet setterFacet = association.getFacet(PropertySetterFacet.class);
+ if (setterFacet == null) {
+ return SetUpObjectResult.CANNOT_SET;
+ }
+
+ final ObjectSpecification fieldSpecification = association.getSpecification();
+ final ParseableFacet parseableFacet = fieldSpecification.getFacet(ParseableFacet.class);
+
+ ObjectAdapter referencedAdapter = null;
+ if (parseableFacet != null) {
+ // handle as parseable value
+ try {
+ referencedAdapter = parseableFacet.parseTextEntry(adapter, cellText);
+ } catch (final IllegalArgumentException ex) {
+ return SetUpObjectResult.CANNOT_PARSE;
+ }
+
+ } else {
+ // handle as reference to known object
+ referencedAdapter = getAliasRegistry().getAliased(cellText);
+ if (referencedAdapter == null) {
+ return SetUpObjectResult.UNKNOWN_REFERENCE;
+ }
+ }
+
+ setterFacet.setProperty(adapter, referencedAdapter);
+ return SetUpObjectResult.OK;
+ }
+
+ public void persistIfNecessary(ObjectAdapter adapter) {
+ if (mode.isPersist()) {
+ // xactn mgmt now done by PersistenceSession#makePersistent()
+ // getTransactionManager().startTransaction();
+ getPersistenceSession().makePersistent(adapter);
+ // getTransactionManager().endTransaction();
+ }
+ }
+
+ public void alias(ObjectAdapter adapter) {
final String alias = aliasFor(adapter);
getAliasRegistry().aliasAs(alias, adapter);
- }
+ }
- public String aliasFor(ObjectAdapter adapter) {
- if (alias != null) {
- return alias;
- } else {
- String specShortName = Strings.lowerLeading(spec.getShortName());
- return getAliasRegistry().aliasPrefixedAs(specShortName, adapter);
- }
- }
-
- public void forEachAssociation(AssociationVisitor visitor) {
- for (int colNum = 0; colNum < getProperties().size(); colNum++) {
- final OneToOneAssociation association = getProperties().get(
- colNum);
- if (association != null) {
- visitor.visit(association, colNum);
- }
- }
- }
-
- public boolean addPropertyValueOrAlias(String propertyValue) {
- cellTextList.add(propertyValue);
-
- // capture alias if just added
- int aliasColumn1based = getAliasBinding().getColumn() + 1;
- if (cellTextList.size() == aliasColumn1based) {
- alias = propertyValue;
- }
+ public String aliasFor(ObjectAdapter adapter) {
+ if (alias != null) {
+ return alias;
+ } else {
+ String specShortName = Strings.lowerLeading(spec.getShortName());
+ return getAliasRegistry().aliasPrefixedAs(specShortName, adapter);
+ }
+ }
- return true;
- }
+ public void forEachAssociation(AssociationVisitor visitor) {
+ for (int colNum = 0; colNum < getProperties().size(); colNum++) {
+ final OneToOneAssociation association = getProperties().get(colNum);
+ if (association != null) {
+ visitor.visit(association, colNum);
+ }
+ }
+ }
+ public boolean addPropertyValueOrAlias(String propertyValue) {
+ cellTextList.add(propertyValue);
+ // capture alias if just added
+ int aliasColumn1based = getAliasBinding().getColumn() + 1;
+ if (cellTextList.size() == aliasColumn1based) {
+ alias = propertyValue;
+ }
+
+ return true;
+ }
}
Modified: incubator/isis/trunk/viewer/bdd/src/docbkx/guide/isis-bdd-viewer.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/src/docbkx/guide/isis-bdd-viewer.xml?rev=1035641&r1=1035640&r2=1035641&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/src/docbkx/guide/isis-bdd-viewer.xml (original)
+++ incubator/isis/trunk/viewer/bdd/src/docbkx/guide/isis-bdd-viewer.xml Tue Nov 16 14:25:59 2010
@@ -1111,17 +1111,22 @@ Isis system <span concordion:assertTr
<sect2 id="sec.SetUpObjects">
<title>Setting Up Objects</title>
- <para>Initializes objects. Typically used for immutable
- reference/standing data objects). Can also be to setup used for
- transaction/operational data objects (though
- UsingNakedObjectsViewerForSetup, <xref
- linkend="sec.UsingNakedObjectsViewer" />, is preferable). The
- DebugObjectStore fixture (<xref linkend="sec.DebugObjectStore" />) can
- be used to check the state of objects created.</para>
+ <para>Creates objects, and persists them to the object store. .
+ Typically used for immutable reference/standing data objects). Can
+ also be to setup used for transaction/operational data objects (though
+ <classname>UsingIsisViewerForSetup</classname>, <xref
+ linkend="sec.UsingIsisViewer" />, is preferable). The DebugObjectStore
+ fixture (<xref linkend="sec.DebugObjectStore" />) can be used to check
+ the state of objects created.</para>
<sect3>
<title>Common</title>
+ <para>The common library support for setting up objects using the
+ SetUpObjectsPeer.</para>
+
+ <para></para>
+
<para></para>
</sect3>
@@ -1220,9 +1225,8 @@ Isis system <span concordion:assertTr
</sect3>
</sect2>
- <sect2 id="sec.UsingNakedObjectsViewer">
- <title>UsingNakedObjectsViewer /
- UsingNakedObjectsViewerForSetup</title>
+ <sect2 id="sec.UsingIsisViewer">
+ <title>Using Isis Viewer / Using Isis Viewer For Setup</title>
<para>Simulates interacting with domain objects as if through a
viewer. Interact with objects, check their state, alias referenced or