Return-Path: Delivered-To: apmail-incubator-isis-commits-archive@minotaur.apache.org Received: (qmail 56398 invoked from network); 17 Nov 2010 18:03:05 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 17 Nov 2010 18:03:05 -0000 Received: (qmail 83392 invoked by uid 500); 17 Nov 2010 18:03:37 -0000 Delivered-To: apmail-incubator-isis-commits-archive@incubator.apache.org Received: (qmail 83375 invoked by uid 500); 17 Nov 2010 18:03:36 -0000 Mailing-List: contact isis-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: isis-dev@incubator.apache.org Delivered-To: mailing list isis-commits@incubator.apache.org Received: (qmail 83078 invoked by uid 99); 17 Nov 2010 18:03:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Nov 2010 18:03:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Nov 2010 18:03:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 99F5023888E7; Wed, 17 Nov 2010 18:02:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1036148 - in /incubator/isis/trunk: alternatives/progmodel/groovy/ alternatives/progmodel/groovy/applib/ alternatives/progmodel/groovy/gapplib/ alternatives/progmodel/groovy/gmetamodel/ alternatives/progmodel/groovy/metamodel/ viewer/bdd/c... Date: Wed, 17 Nov 2010 18:02:18 -0000 To: isis-commits@incubator.apache.org From: danhaywood@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101117180218.99F5023888E7@eris.apache.org> Author: danhaywood Date: Wed Nov 17 18:02:17 2010 New Revision: 1036148 URL: http://svn.apache.org/viewvc?rev=1036148&view=rev Log: renaming groovy submodule directories to be consistent with artifactIds Added: incubator/isis/trunk/alternatives/progmodel/groovy/applib/ - copied from r1035987, incubator/isis/trunk/alternatives/progmodel/groovy/gapplib/ incubator/isis/trunk/alternatives/progmodel/groovy/metamodel/ - copied from r1035987, incubator/isis/trunk/alternatives/progmodel/groovy/gmetamodel/ Removed: incubator/isis/trunk/alternatives/progmodel/groovy/gapplib/ incubator/isis/trunk/alternatives/progmodel/groovy/gmetamodel/ Modified: incubator/isis/trunk/alternatives/progmodel/groovy/pom.xml incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/UsingIsisViewerPeer.java incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/perform/SaveObject.java incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/UsingIsisViewerForConcordion.java incubator/isis/trunk/viewer/bdd/fitnesse/src/main/java/net/sf/isiscontrib/bdd/fitnesse/internal/fixtures/UsingIsisViewerForFitNesse.java incubator/isis/trunk/viewer/bdd/src/docbkx/guide/isis-bdd-viewer.xml Modified: incubator/isis/trunk/alternatives/progmodel/groovy/pom.xml URL: http://svn.apache.org/viewvc/incubator/isis/trunk/alternatives/progmodel/groovy/pom.xml?rev=1036148&r1=1036147&r2=1036148&view=diff ============================================================================== --- incubator/isis/trunk/alternatives/progmodel/groovy/pom.xml (original) +++ incubator/isis/trunk/alternatives/progmodel/groovy/pom.xml Wed Nov 17 18:02:17 2010 @@ -31,8 +31,8 @@ http://incubator.apache.org/isis/${relativeUrl} - gapplib - gmetamodel + applib + metamodel Modified: incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/UsingIsisViewerPeer.java URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/UsingIsisViewerPeer.java?rev=1036148&r1=1036147&r2=1036148&view=diff ============================================================================== --- incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/UsingIsisViewerPeer.java (original) +++ incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/UsingIsisViewerPeer.java Wed Nov 17 18:02:17 2010 @@ -44,318 +44,308 @@ import org.apache.isis.viewer.bdd.common public class UsingIsisViewerPeer extends AbstractFixturePeer { - private static List performCommands(final Perform.Mode mode) { - ArrayList commands = new ArrayList(); + private static List performCommands(final Perform.Mode mode) { + ArrayList commands = new ArrayList(); - commands.add(new CheckProperty(mode)); - commands.add(new CheckSetProperty(mode)); - commands.add(new CheckClearProperty(mode)); - commands.add(new GetProperty(mode)); - commands.add(new SetProperty(mode)); - commands.add(new ClearProperty(mode)); - commands.add(new GetPropertyDefault(mode)); - commands.add(new GetPropertyChoices(mode)); - - commands.add(new CheckCollection(mode)); - commands.add(new CheckAddToCollection(mode)); - commands.add(new CheckRemoveFromCollection(mode)); - commands.add(new AddToCollection(mode)); - commands.add(new RemoveFromCollection(mode)); - commands.add(new GetCollection(mode)); - - commands.add(new CheckAction(mode)); - commands.add(new InvokeAction(mode)); - commands.add(new GetActionParameterDefault(mode)); - commands.add(new GetActionParameterChoices(mode)); - - commands.add(new CheckObject(mode)); - commands.add(new SaveObject(mode)); - - return commands; - } - - private final CellBinding onObjectBinding; - private final CellBinding aliasResultAsBinding; - private final CellBinding performBinding; - private final CellBinding onMemberBinding; - private final CellBinding thatItBinding; - private final CellBinding arg0Binding; - - private final Map commandByKey = new HashMap(); - - public UsingIsisViewerPeer(final AliasRegistry aliasesRegistry, - final Perform.Mode mode, final CellBinding onObjectBinding, - final CellBinding aliasResultAsBinding, - final CellBinding performBinding, - final CellBinding onMemberBinding, final CellBinding thatItBinding, - final CellBinding arg0Binding) { - super(aliasesRegistry, onObjectBinding, aliasResultAsBinding, - performBinding, onMemberBinding, thatItBinding, arg0Binding); - - this.onObjectBinding = onObjectBinding; - this.aliasResultAsBinding = aliasResultAsBinding; - this.performBinding = performBinding; - this.onMemberBinding = onMemberBinding; - this.thatItBinding = thatItBinding; - this.arg0Binding = arg0Binding; - - final List performCommands = performCommands(mode); - for (final Perform command : performCommands) { - commandByKey.put(command.getKey(), command); - } - } - - public CellBinding getOnObjectBinding() { - return onObjectBinding; - } - - public CellBinding getAliasResultAsBinding() { - return aliasResultAsBinding; - } - - public CellBinding getOnMemberBinding() { - return onMemberBinding; - } - - public CellBinding getPerformBinding() { - return performBinding; - } - - public CellBinding getThatItBinding() { - return thatItBinding; - } - - public CellBinding getArg0Binding() { - return arg0Binding; - } - - public boolean isArg0BindingLast() { - return !bindingAfterArg0(); - - } - - private boolean bindingAfterArg0() { - if (!getArg0Binding().isFound()) { - return false; - } - for (final CellBinding binding : getCellBindings()) { - if (binding.getColumn() > getArg0Binding().getColumn()) { - return true; - } - } - return false; - } - - // ////////////////////////////////////////////////////////////////// - // - // ////////////////////////////////////////////////////////////////// - - public void makePersistent(ObjectAdapter adapter) { - getPersistenceSession().makePersistent(adapter); - } - - public void provideDefault(StoryCell storySource, String resultStr) { - // TODO Auto-generated method stub - throw new NotYetImplementedException(); - } - - private String previousOnObject = null; - - public ObjectAdapter validateOnObject() throws StoryBoundValueException { - - StoryCell onObjectCell = onObjectBinding.getCurrentCell(); - String onObject = onObjectCell.getText(); - if (onObject == null) { - if (previousOnObject == null) { - throw StoryBoundValueException.current(onObjectBinding, "(required)"); - } - onObject = previousOnObject; - } else { - previousOnObject = onObject; - } - final ObjectAdapter onAdapter = getAliasRegistry().getAliased(onObject); - if (onAdapter == null) { - throw StoryBoundValueException.current(onMemberBinding, "(unknown object)"); - } - return onAdapter; - } - - public String validateAliasAs() throws StoryBoundValueException { - if (getAliasResultAsBinding() == null) { - return null; - } - final StoryCell aliasCell = aliasResultAsBinding - .getCurrentCell(); - if (aliasCell == null) { - return null; - } - - String aliasAs = aliasCell.getText(); - if (getAliasRegistry().getAliased(aliasAs) != null) { - throw StoryBoundValueException.current(aliasResultAsBinding, "(already used)"); - } - return aliasAs; - } - - public ObjectMember validateOnMember(ObjectAdapter onAdapter) - throws StoryBoundValueException { - - final StoryCell onMemberCell = onMemberBinding.getCurrentCell(); - final String onMember = onMemberCell.getText(); - - if (Strings.emptyString(onMember)) { - throw StoryBoundValueException.current(onMemberBinding, "(required)"); - } - - if (onAdapter == null) { - return null; - } - - // see if property, collection or action. - final String memberId = Strings.memberIdFor(onMember); - final ObjectSpecification spec = onAdapter.getSpecification(); - final List objectMembers = new ArrayList(); - - objectMembers.addAll(spec.getAssociationList()); - - // see if action (of any type) - objectMembers.addAll(spec - .getObjectActionList(ObjectActionType.USER)); - objectMembers.addAll(spec - .getObjectActionList(ObjectActionType.EXPLORATION)); - objectMembers.addAll(spec - .getObjectActionList(ObjectActionType.DEBUG)); - for (final ObjectMember member : objectMembers) { - if (matchesId(member, memberId)) { - return member; - } - // special handling for contributed actions. - if (member instanceof ObjectActionSet) { - final ObjectActionSet actionSet = (ObjectActionSet) member; - for (final ObjectAction contributedAction : actionSet - .getActions()) { - if (contributedAction.getId().equals(memberId)) { - return contributedAction; - } - } - } - } - throw StoryBoundValueException.current(onMemberBinding, "(unknown member)"); - } - - private boolean matchesId(final ObjectMember member, - final String memberId) { - return member.getId().equals(memberId); - } - - public Perform validatePerform() throws StoryBoundValueException { - final String perform = performBinding.getCurrentCell() - .getText(); - if (perform == null) { - throw StoryBoundValueException.current(performBinding, "(required)"); - } - final Perform performCommand = commandByKey.get(perform); - if (performCommand == null) { - throw StoryBoundValueException.current(performBinding, "(unknown interaction)"); - } - return performCommand; - } - - private void aliasResultFromPerformCommand(Perform performCommand, - String aliasAs) throws StoryBoundValueException { - if (Strings.emptyString(aliasAs)) { - return; - } - final ObjectAdapter resultAdapter = performCommand.getResult(); - if (resultAdapter == null) { - throw StoryBoundValueException.current(onMemberBinding, "(no result)"); - } - getAliasRegistry().aliasAs(aliasAs, resultAdapter); - } - - public StoryCell getMemberElseOnObjectCell() { - StoryCell storyCell = getOnMemberBinding().getCurrentCell(); - if (storyCell == null) { - storyCell = getOnObjectBinding().getCurrentCell(); - } - return storyCell; - } - - public void performCommand(Perform performCommand, ObjectAdapter onAdapter, - ObjectMember nakedObjectMember, - List argumentStoryCells, - String aliasAs) - throws StoryBoundValueException { - PerformContext performContext = new PerformContext(this, onAdapter, - nakedObjectMember, argumentStoryCells); - try { - performCommand.perform(performContext); - } catch (final RuntimeException ex) { - // handler should have colored in invalid cells. - } - aliasResultFromPerformCommand(performCommand, aliasAs); - } - - public ObjectAdapter getAdapter(final ObjectAdapter contextAdapter, - final ObjectSpecification noSpec, final CellBinding contextBinding, final StoryCell paramCell) - throws StoryBoundValueException { - - final String cellText = paramCell.getText(); - - // see if can handle as parseable value - final ParseableFacet parseableFacet = noSpec - .getFacet(ParseableFacet.class); - if (parseableFacet != null) { - try { - return parseableFacet.parseTextEntry(contextAdapter, cellText); - } catch (final IllegalArgumentException ex) { - throw StoryBoundValueException.arg(contextBinding, paramCell, "(cannot parse)"); - } - } - - // otherwise, handle as reference to known object - final ObjectAdapter adapter = getAliasRegistry().getAliased(cellText); - if (adapter == null) { - throw StoryBoundValueException.arg(contextBinding, paramCell, "(unknown reference)"); - } - - return adapter; - } - - /** - * Ensures that there are at least enough arguments for the number of parameters required. - */ - public ObjectAdapter[] getAdapters(final ObjectAdapter onAdapter, - final ObjectAction nakedObjectAction, - CellBinding onMemberBinding, final List argumentCells) throws StoryBoundValueException { - final ObjectActionParameter[] parameters = nakedObjectAction - .getParameters(); - - int parameterCount = parameters.length; - if (argumentCells.size() < parameterCount) { - throw StoryBoundValueException.current(onMemberBinding, - "(action requires " + parameterCount + " arguments)"); - } - final ObjectAdapter[] adapters = new ObjectAdapter[parameterCount]; - - - for (int i = 0; i < parameterCount; i++) { - final StoryCell paramCell = argumentCells.get(i); - final ObjectActionParameter parameter = parameters[i]; - adapters[i] = getAdapter(null, parameter.getSpecification(), - onMemberBinding, paramCell); - } - return adapters; - } - - public ObjectAdapter toAdaptedListOfPojos(final ObjectAdapter[] choiceAdapters) { - final List choiceList = new ArrayList(); - if (choiceAdapters != null) { - for (final ObjectAdapter adapter : choiceAdapters) { - choiceList.add(adapter.getObject()); - } - } - return getAdapterManager().adapterFor(choiceList); - } + commands.add(new CheckProperty(mode)); + commands.add(new CheckSetProperty(mode)); + commands.add(new CheckClearProperty(mode)); + commands.add(new GetProperty(mode)); + commands.add(new SetProperty(mode)); + commands.add(new ClearProperty(mode)); + commands.add(new GetPropertyDefault(mode)); + commands.add(new GetPropertyChoices(mode)); + + commands.add(new CheckCollection(mode)); + commands.add(new CheckAddToCollection(mode)); + commands.add(new CheckRemoveFromCollection(mode)); + commands.add(new AddToCollection(mode)); + commands.add(new RemoveFromCollection(mode)); + commands.add(new GetCollection(mode)); + + commands.add(new CheckAction(mode)); + commands.add(new InvokeAction(mode)); + commands.add(new GetActionParameterDefault(mode)); + commands.add(new GetActionParameterChoices(mode)); + + commands.add(new CheckObject(mode)); + commands.add(new SaveObject(mode)); + + return commands; + } + + // ////////////////////////////////////////////////////////////////// + // constructor + // ////////////////////////////////////////////////////////////////// + + private final CellBinding onObjectBinding; + private final CellBinding aliasResultAsBinding; + private final CellBinding performBinding; + private final CellBinding onMemberBinding; + private final CellBinding thatItBinding; + private final CellBinding arg0Binding; + + private final Map commandByKey = new HashMap(); + + public UsingIsisViewerPeer(final AliasRegistry aliasesRegistry, final Perform.Mode mode, + final CellBinding onObjectBinding, final CellBinding aliasResultAsBinding, final CellBinding performBinding, + final CellBinding onMemberBinding, final CellBinding thatItBinding, final CellBinding arg0Binding) { + super(aliasesRegistry, onObjectBinding, aliasResultAsBinding, performBinding, onMemberBinding, thatItBinding, + arg0Binding); + + this.onObjectBinding = onObjectBinding; + this.aliasResultAsBinding = aliasResultAsBinding; + this.performBinding = performBinding; + this.onMemberBinding = onMemberBinding; + this.thatItBinding = thatItBinding; + this.arg0Binding = arg0Binding; + + final List performCommands = performCommands(mode); + for (final Perform command : performCommands) { + commandByKey.put(command.getKey(), command); + } + } + + public CellBinding getOnObjectBinding() { + return onObjectBinding; + } + + public CellBinding getAliasResultAsBinding() { + return aliasResultAsBinding; + } + + public CellBinding getOnMemberBinding() { + return onMemberBinding; + } + + public CellBinding getPerformBinding() { + return performBinding; + } + + public CellBinding getThatItBinding() { + return thatItBinding; + } + + public CellBinding getArg0Binding() { + return arg0Binding; + } + + public boolean isArg0BindingLast() { + return !bindingAfterArg0(); + + } + + private boolean bindingAfterArg0() { + if (!getArg0Binding().isFound()) { + return false; + } + for (final CellBinding binding : getCellBindings()) { + if (binding.getColumn() > getArg0Binding().getColumn()) { + return true; + } + } + return false; + } + + // ////////////////////////////////////////////////////////////////// + // validate API + // ////////////////////////////////////////////////////////////////// + + public ObjectAdapter validateOnObject() throws StoryBoundValueException { + + StoryCell onObjectCell = onObjectBinding.getCurrentCell(); + String onObject = onObjectCell.getText(); + if (onObject == null) { + if (previousOnObject == null) { + throw StoryBoundValueException.current(onObjectBinding, "(required)"); + } + onObject = previousOnObject; + } else { + previousOnObject = onObject; + } + final ObjectAdapter onAdapter = getAliasRegistry().getAliased(onObject); + if (onAdapter == null) { + throw StoryBoundValueException.current(onMemberBinding, "(unknown object)"); + } + return onAdapter; + } + + public String validateAliasAs() throws StoryBoundValueException { + if (getAliasResultAsBinding() == null) { + return null; + } + final StoryCell aliasCell = aliasResultAsBinding.getCurrentCell(); + if (aliasCell == null) { + return null; + } + + String aliasAs = aliasCell.getText(); + if (getAliasRegistry().getAliased(aliasAs) != null) { + throw StoryBoundValueException.current(aliasResultAsBinding, "(already used)"); + } + return aliasAs; + } + + public ObjectMember validateOnMember(ObjectAdapter onAdapter) throws StoryBoundValueException { + + final StoryCell onMemberCell = onMemberBinding.getCurrentCell(); + final String onMember = onMemberCell.getText(); + + if (Strings.emptyString(onMember)) { + throw StoryBoundValueException.current(onMemberBinding, "(required)"); + } + + if (onAdapter == null) { + return null; + } + + // see if property, collection or action. + final String memberId = Strings.memberIdFor(onMember); + final ObjectSpecification spec = onAdapter.getSpecification(); + final List objectMembers = new ArrayList(); + + objectMembers.addAll(spec.getAssociationList()); + + // see if action (of any type) + objectMembers.addAll(spec.getObjectActionList(ObjectActionType.USER)); + objectMembers.addAll(spec.getObjectActionList(ObjectActionType.EXPLORATION)); + objectMembers.addAll(spec.getObjectActionList(ObjectActionType.DEBUG)); + for (final ObjectMember member : objectMembers) { + if (matchesId(member, memberId)) { + return member; + } + // special handling for contributed actions. + if (member instanceof ObjectActionSet) { + final ObjectActionSet actionSet = (ObjectActionSet) member; + for (final ObjectAction contributedAction : actionSet.getActions()) { + if (contributedAction.getId().equals(memberId)) { + return contributedAction; + } + } + } + } + throw StoryBoundValueException.current(onMemberBinding, "(unknown member)"); + } + + public Perform validatePerform() throws StoryBoundValueException { + final String perform = performBinding.getCurrentCell().getText(); + if (perform == null) { + throw StoryBoundValueException.current(performBinding, "(required)"); + } + final Perform performCommand = commandByKey.get(perform); + if (performCommand == null) { + throw StoryBoundValueException.current(performBinding, "(unknown interaction)"); + } + return performCommand; + } + + private boolean matchesId(final ObjectMember member, final String memberId) { + return member.getId().equals(memberId); + } + + // ////////////////////////////////////////////////////////////////// + // "perform" API + // ////////////////////////////////////////////////////////////////// + + public void performCommand(ObjectAdapter onAdapter, String aliasAs, ObjectMember objectMember, + Perform performCommand, List argumentStoryCells) throws StoryBoundValueException { + PerformContext performContext = new PerformContext(this, onAdapter, objectMember, argumentStoryCells); + try { + performCommand.perform(performContext); + } catch (final RuntimeException ex) { + // handler should have colored in invalid cells. + } + aliasResultFromPerformCommand(performCommand, aliasAs); + } + + private void aliasResultFromPerformCommand(Perform performCommand, String aliasAs) throws StoryBoundValueException { + if (Strings.emptyString(aliasAs)) { + return; + } + final ObjectAdapter resultAdapter = performCommand.getResult(); + if (resultAdapter == null) { + throw StoryBoundValueException.current(onMemberBinding, "(no result)"); + } + getAliasRegistry().aliasAs(aliasAs, resultAdapter); + } + + // ////////////////////////////////////////////////////////////////// + // + // ////////////////////////////////////////////////////////////////// + + private String previousOnObject = null; + + /** + * Not public API + */ + public void provideDefault(StoryCell storySource, String resultStr) { + // TODO Auto-generated method stub + throw new NotYetImplementedException(); + } + + /** + * Not public API + */ + public ObjectAdapter getAdapter(final ObjectAdapter contextAdapter, final ObjectSpecification noSpec, + final CellBinding contextBinding, final StoryCell paramCell) throws StoryBoundValueException { + + final String cellText = paramCell.getText(); + + // see if can handle as parseable value + final ParseableFacet parseableFacet = noSpec.getFacet(ParseableFacet.class); + if (parseableFacet != null) { + try { + return parseableFacet.parseTextEntry(contextAdapter, cellText); + } catch (final IllegalArgumentException ex) { + throw StoryBoundValueException.arg(contextBinding, paramCell, "(cannot parse)"); + } + } + + // otherwise, handle as reference to known object + final ObjectAdapter adapter = getAliasRegistry().getAliased(cellText); + if (adapter == null) { + throw StoryBoundValueException.arg(contextBinding, paramCell, "(unknown reference)"); + } + + return adapter; + } + + /** + * Not public API + * + *

+ * Ensures that there are at least enough arguments for the number of parameters required. + */ + public ObjectAdapter[] getAdapters(final ObjectAdapter onAdapter, final ObjectAction nakedObjectAction, + CellBinding onMemberBinding, final List argumentCells) throws StoryBoundValueException { + final ObjectActionParameter[] parameters = nakedObjectAction.getParameters(); + + int parameterCount = parameters.length; + if (argumentCells.size() < parameterCount) { + throw StoryBoundValueException.current(onMemberBinding, "(action requires " + parameterCount + + " arguments)"); + } + final ObjectAdapter[] adapters = new ObjectAdapter[parameterCount]; + + for (int i = 0; i < parameterCount; i++) { + final StoryCell paramCell = argumentCells.get(i); + final ObjectActionParameter parameter = parameters[i]; + adapters[i] = getAdapter(null, parameter.getSpecification(), onMemberBinding, paramCell); + } + return adapters; + } + + /** + * Not public API + */ + public ObjectAdapter toAdaptedListOfPojos(final ObjectAdapter[] choiceAdapters) { + final List choiceList = new ArrayList(); + if (choiceAdapters != null) { + for (final ObjectAdapter adapter : choiceAdapters) { + choiceList.add(adapter.getObject()); + } + } + return getAdapterManager().adapterFor(choiceList); + } } Modified: incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/perform/SaveObject.java URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/perform/SaveObject.java?rev=1036148&r1=1036147&r2=1036148&view=diff ============================================================================== --- incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/perform/SaveObject.java (original) +++ incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/perform/SaveObject.java Wed Nov 17 18:02:17 2010 @@ -2,49 +2,52 @@ package org.apache.isis.viewer.bdd.commo import org.apache.isis.core.metamodel.adapter.ObjectAdapter; import org.apache.isis.core.metamodel.consent.Consent; +import org.apache.isis.core.runtime.context.IsisContext; +import org.apache.isis.core.runtime.persistence.PersistenceSession; import org.apache.isis.viewer.bdd.common.CellBinding; import org.apache.isis.viewer.bdd.common.StoryBoundValueException; public class SaveObject extends PerformAbstractTypeParams { - private ObjectAdapter result; + private ObjectAdapter result; - public SaveObject(final Perform.Mode mode) { - super("save", Type.OBJECT, NumParameters.ZERO, mode); - } + public SaveObject(final Perform.Mode mode) { + super("save", Type.OBJECT, NumParameters.ZERO, mode); + } - @Override - public void doHandle(final PerformContext performContext) - throws StoryBoundValueException { + @Override + public void doHandle(final PerformContext performContext) throws StoryBoundValueException { - final ObjectAdapter onAdapter = performContext.getOnAdapter(); + final ObjectAdapter onAdapter = performContext.getOnAdapter(); - final Consent valid = onAdapter.getSpecification().isValid(onAdapter); + final Consent valid = onAdapter.getSpecification().isValid(onAdapter); - CellBinding performBinding = performContext.getPeer() - .getPerformBinding(); - if (valid.isVetoed()) { - throw StoryBoundValueException.current(performBinding, - valid.getReason()); - } + CellBinding performBinding = performContext.getPeer().getPerformBinding(); + if (valid.isVetoed()) { + throw StoryBoundValueException.current(performBinding, valid.getReason()); + } - if (onAdapter.isPersistent()) { - throw StoryBoundValueException.current(performBinding, - "(already persistent)"); - } + if (onAdapter.isPersistent()) { + throw StoryBoundValueException.current(performBinding, "(already persistent)"); + } - // persist + // persist - // xactn mgmt now performed by PersistenceSession#makePersistent - // getOwner().getTransactionManager().startTransaction(); - performContext.getPeer().makePersistent(onAdapter); - // getOwner().getTransactionManager().endTransaction(); + // xactn mgmt now performed by PersistenceSession#makePersistent + // getOwner().getTransactionManager().startTransaction(); + getPersistenceSession().makePersistent(onAdapter); + // getOwner().getTransactionManager().endTransaction(); - // all OK. - } + // all OK. + } - public ObjectAdapter getResult() { - return result; - } + protected PersistenceSession getPersistenceSession() { + return IsisContext.getPersistenceSession(); + } + + @Override + public ObjectAdapter getResult() { + return result; + } } Modified: incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/UsingIsisViewerForConcordion.java URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/UsingIsisViewerForConcordion.java?rev=1036148&r1=1036147&r2=1036148&view=diff ============================================================================== --- incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/UsingIsisViewerForConcordion.java (original) +++ incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/UsingIsisViewerForConcordion.java Wed Nov 17 18:02:17 2010 @@ -121,12 +121,12 @@ public class UsingIsisViewerForConcordio String aliasAs = getPeer().validateAliasAs(); Perform performCommand = getPeer().validatePerform(); - ObjectMember nakedObjectMember = null; + ObjectMember objectMember = null; if (performCommand.requiresMember()) { - nakedObjectMember = getPeer().validateOnMember(onAdapter); + objectMember = getPeer().validateOnMember(onAdapter); } - getPeer().performCommand(performCommand, onAdapter, nakedObjectMember, asValues(argumentCells), aliasAs); + getPeer().performCommand(onAdapter, aliasAs, objectMember, performCommand, asValues(argumentCells)); } private static List asValues(List argumentCells) { Modified: incubator/isis/trunk/viewer/bdd/fitnesse/src/main/java/net/sf/isiscontrib/bdd/fitnesse/internal/fixtures/UsingIsisViewerForFitNesse.java URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/fitnesse/src/main/java/net/sf/isiscontrib/bdd/fitnesse/internal/fixtures/UsingIsisViewerForFitNesse.java?rev=1036148&r1=1036147&r2=1036148&view=diff ============================================================================== --- incubator/isis/trunk/viewer/bdd/fitnesse/src/main/java/net/sf/isiscontrib/bdd/fitnesse/internal/fixtures/UsingIsisViewerForFitNesse.java (original) +++ incubator/isis/trunk/viewer/bdd/fitnesse/src/main/java/net/sf/isiscontrib/bdd/fitnesse/internal/fixtures/UsingIsisViewerForFitNesse.java Wed Nov 17 18:02:17 2010 @@ -109,10 +109,10 @@ public class UsingIsisViewerForFitNesse return; } - ObjectMember nakedObjectMember = null; + ObjectMember objectMember = null; if (performCommand.requiresMember()) { try { - nakedObjectMember = getPeer().validateOnMember(onAdapter); + objectMember = getPeer().validateOnMember(onAdapter); } catch (StoryBoundValueException ex) { FitnesseUtil.exception(this, ex); return; @@ -121,7 +121,7 @@ public class UsingIsisViewerForFitNesse try { List argumentStoryCells = asValues(argumentCells); - getPeer().performCommand(performCommand, onAdapter, nakedObjectMember, argumentStoryCells, aliasAs); + getPeer().performCommand(onAdapter, aliasAs, objectMember, performCommand, argumentStoryCells); } catch (StoryBoundValueException ex) { FitnesseUtil.exception(this, ex); return; @@ -139,7 +139,19 @@ public class UsingIsisViewerForFitNesse } private void rightMemberElseOnObjectCell() { - right(getPeer().getMemberElseOnObjectCell()); + UsingIsisViewerPeer peer = getPeer(); + StoryCell storyCell = + coalesce(peer.getOnMemberBinding().getCurrentCell(), peer.getOnObjectBinding().getCurrentCell()); + right(storyCell); + } + + private static T coalesce(T... objects) { + for (T object : objects) { + if (object != null) { + return object; + } + } + return null; } } 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=1036148&r1=1036147&r2=1036148&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 Wed Nov 17 18:02:17 2010 @@ -154,8 +154,17 @@ methods so the matching is done simply by parameter position to these method). - The library provides a default implementation, though - subclasses can override if required. + *** + + + + + + + + The library provides a default implementation of + CellBinding, though subclasses can override + if required. @@ -1575,7 +1584,7 @@ and running in <span concordion:set=" - sobject alias + object alias alias for list of choices @@ -2001,11 +2010,61 @@ and running in <span concordion:set=" here. While it is tempting to refactor the common library to use type safe enums, this would move the need to translate story text into each and every BDD framework - integration. The API is probably correct as it is, even though - it is reliant on the exact string phrases that appear in the - tables above. + integration. The API is probably correct as + it is, even though it is reliant on the exact string phrases + that appear in the tables above. + + + + To actually perform, these interaction, the set + + + + *** discuss captureCurrent() + + + + the UsingIsisViewerPeer provides the + following methods: + + + + #validateOnObject(): + ObjectAdapter + + + + + + #validateAliasAs(): String + + + + + + #validateOnMember(): + ObjectMember + + + + + + #validatePerform(): + Perform + + + + + + #performCommand(ObjectAdapter onObject, String + aliasAs, ObjectMember onMember, Perform perform, + List<StoryCell> args) + + + + @@ -2049,7 +2108,7 @@ and running in <span concordion:set=" - usingIsisViewerThatArgs(String onObject, + #usingIsisViewerThatArgs(String onObject, String aliasResultAs, String perform, String usingMember, String arg0, String arg1, ...) @@ -2060,13 +2119,16 @@ and running in <span concordion:set=" There are multiple overloaded versions of this method taking from 1 to 5 arguments. - - - - - + If there is a requirement for more than 5 arguments, then you + can write your own method and delegate to the (protected visibility) + #usingIsisViewerThatArgsVarargs(...) + method. + + In all cases these methods return the string "ok", or return + the text of an exception otherwise. This makes them easy to + embed Returns ok @@ -2210,10 +2272,20 @@ and running in <span concordion:set=" - + Check List - + Check items in list, either precisely or just for presence, + using their title. Lists are either aliased results of actions, or + aliased collections within objects. + + Typically used in the "Then", though can be helpful as a way of + confirming/documenting a "Given". + + See also AliasItemsInList (), which also performs an implicit + check (will fail if the objects are not in the list) and aliases them + for further use. @@ -2242,9 +2314,18 @@ and running in <span concordion:set=" - + Alias Items In List + Allows an alias to be associated with items in a list. The list + items are located by their title, and are presumed to exist. This + fixture can therefore also be used as a way of checking for presence + of items in a list (similar to CheckList, ). + + Typically used both in the "Given" (to simplify writing the rest + of a test). + @@ -2273,145 +2354,6 @@ and running in <span concordion:set=" - - - Using Isis Viewer / Using Isis Viewer For Setup - - Simulates interacting with domain objects as if through a - viewer. Interact with objects, check their state, alias referenced or - returned objects. - - The "ForSetup" version disables checks for visibility and - usability, making it easier to reuse functionality for setting up - objects prior to a test scenario (the "given"). The DebugObjectStore - fixture () can be used to check - the state of objects created. - - - UsingNakedObjectsViewer - - - - - - - - - Example usage: - - - ExampleUsage - - - - - - - - - On properties: - - - On Properties - - - - - - - - - On collections: - - - On Collections - - - - - - - - - On actions: - - - On Actions - - - - - - - - - On objects: - - - On Objects - - - - - - - - - - - CheckList - - Check items in list, either precisely or just for presence, - using their title. Lists are either aliased results of actions, or - aliased collections within objects. - - Typically used in the "Then", though can be helpful as a way of - confirming/documenting a "Given". - - See also AliasItemsInList (), which also performs an implicit - check (will fail if the objects are not in the list) and aliases them - for further use. - - - CheckList - - - - - - - - - - - AliasItemsInList - - Allows an alias to be associated with items in a list. The list - items are located by their title, and are presumed to exist. This - fixture can therefore also be used as a way of checking for presence - of items in a list (similar to CheckList, ). - - Typically used both in the "Given" (to simplify writing the rest - of a test). - - - AliasItemsInList - - - - - - - -