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 2016/05/02 17:49:35 UTC
[11/14] isis git commit: ISIS-1397: renaming CommandMementoDto to
CommandDto (similarly). Also ...
http://git-wip-us.apache.org/repos/asf/isis/blob/a9d706be/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
index cfb4a82..30dcf67 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
@@ -46,10 +46,13 @@ import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
import org.apache.isis.schema.cmd.v1.ActionDto;
-import org.apache.isis.schema.cmd.v1.CommandMementoDto;
+import org.apache.isis.schema.cmd.v1.CommandDto;
+import org.apache.isis.schema.cmd.v1.InteractionTypeDto;
+import org.apache.isis.schema.cmd.v1.MemberDto;
import org.apache.isis.schema.cmd.v1.ParamDto;
+import org.apache.isis.schema.cmd.v1.PropertyDto;
import org.apache.isis.schema.common.v1.OidDto;
-import org.apache.isis.schema.utils.CommandMementoDtoUtils;
+import org.apache.isis.schema.utils.CommandDtoUtils;
/**
* Intended to be used as a base class for executing queued up {@link Command background action}s.
@@ -156,42 +159,53 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
} else {
- final CommandMementoDto dto = jaxbService.fromXml(CommandMementoDto.class, memento);
- final ActionDto actionDto = dto.getAction();
- final String actionId = actionDto.getMemberIdentifier();
+ final CommandDto dto = jaxbService.fromXml(CommandDto.class, memento);
- final List<OidDto> targetOidDtos = dto.getTargets();
- for (OidDto targetOidDto : targetOidDtos) {
+ final MemberDto memberDto = dto.getMember();
+ final String memberId = memberDto.getMemberIdentifier();
- final Bookmark bookmark = Bookmark.from(targetOidDto);
- final Object targetObject = bookmarkService.lookup(bookmark);
+ final InteractionTypeDto interactionType = dto.getInteractionType();
+ if(interactionType == InteractionTypeDto.ACTION_INVOCATION) {
- final ObjectAdapter targetAdapter = adapterFor(targetObject);
+ final ActionDto actionDto = (ActionDto) memberDto;
- final ObjectAction objectAction =
- findObjectAction(targetAdapter, actionId);
+ final List<OidDto> targetOidDtos = dto.getTargets();
+ for (OidDto targetOidDto : targetOidDtos) {
- // TODO: background commands won't work for mixin actions...
- // ... we obtain the target from the bookmark service (above), which will
- // simply fail for a mixin. Instead we would need to serialize out the mixedInAdapter
- // and also capture the mixinType within the aim memento.
- final ObjectAdapter mixedInAdapter = null;
+ final Bookmark bookmark = Bookmark.from(targetOidDto);
+ final Object targetObject = bookmarkService.lookup(bookmark);
- final ObjectAdapter[] argAdapters = argAdaptersFor(dto);
- final ObjectAdapter resultAdapter = objectAction.execute(
- targetAdapter, mixedInAdapter, argAdapters, InteractionInitiatedBy.FRAMEWORK);
+ final ObjectAdapter targetAdapter = adapterFor(targetObject);
- // alternatively, could use...
- Object unused = backgroundInteraction.getPriorExecution().getReturned();
+ final ObjectAction objectAction = findObjectAction(targetAdapter, memberId);
- // this doesn't really make sense if >1 action
- // in any case, the capturing of the action interaction should be the
- // responsibility of auditing/profiling
- if(resultAdapter != null) {
- Bookmark resultBookmark = CommandUtil.bookmarkFor(resultAdapter);
- backgroundCommand.setResult(resultBookmark);
+ // we pass 'null' for the mixedInAdapter; if this action _is_ a mixin then
+ // it will switch the targetAdapter to be the mixedInAdapter transparently
+ final ObjectAdapter[] argAdapters = argAdaptersFor(actionDto);
+ final ObjectAdapter resultAdapter = objectAction.execute(
+ targetAdapter, null, argAdapters, InteractionInitiatedBy.FRAMEWORK);
+
+ // for the result adapter, we could alternatively have used...
+ Object unused = backgroundInteraction.getPriorExecution().getReturned();
+
+ // this doesn't really make sense if >1 action
+ // in any case, the capturing of the action interaction should be the
+ // responsibility of auditing/profiling
+ if(resultAdapter != null) {
+ Bookmark resultBookmark = CommandUtil.bookmarkFor(resultAdapter);
+ backgroundCommand.setResult(resultBookmark);
+ }
}
+ } else {
+
+ final PropertyDto propertyDto = (PropertyDto) memberDto;
+
+ //
+ // TODO: need equivalent logic if this is a property modification
+ //
+ throw new RuntimeException("Not yet implemented");
}
+
}
} catch (RuntimeException e) {
@@ -266,13 +280,13 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
}
}
- private ObjectAdapter[] argAdaptersFor(final CommandMementoDto dto) {
- final List<ParamDto> params = dto.getAction().getParameters();
+ private ObjectAdapter[] argAdaptersFor(final ActionDto actionDto) {
+ final List<ParamDto> params = actionDto.getParameters();
final List<ObjectAdapter> args = Lists.newArrayList(
Iterables.transform(params, new Function<ParamDto, ObjectAdapter>() {
@Override
public ObjectAdapter apply(final ParamDto paramDto) {
- final Object arg = CommandMementoDtoUtils.paramArgOf(paramDto);
+ final Object arg = CommandDtoUtils.paramArgOf(paramDto);
return adapterFor(arg);
}
})
@@ -280,8 +294,6 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
return args.toArray(new ObjectAdapter[]{});
}
-
-
// //////////////////////////////////////
@javax.inject.Inject
http://git-wip-us.apache.org/repos/asf/isis/blob/a9d706be/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
index 74ee8e6..7007d71 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
@@ -41,7 +41,7 @@ import org.apache.isis.core.commons.lang.ArrayExtensions;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
import org.apache.isis.core.metamodel.facets.actions.action.invocation.CommandUtil;
-import org.apache.isis.core.metamodel.services.command.CommandMementoService;
+import org.apache.isis.core.metamodel.services.command.CommandDtoService;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
import org.apache.isis.core.metamodel.spec.feature.Contributed;
@@ -51,7 +51,7 @@ import org.apache.isis.core.metamodel.specloader.classsubstitutor.JavassistEnhan
import org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionMixedIn;
import org.apache.isis.core.metamodel.specloader.specimpl.dflt.ObjectSpecificationDefault;
import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.schema.cmd.v1.CommandMementoDto;
+import org.apache.isis.schema.cmd.v1.CommandDto;
import javassist.util.proxy.MethodFilter;
import javassist.util.proxy.MethodHandler;
@@ -216,7 +216,7 @@ public class BackgroundServiceDefault implements BackgroundService2 {
final ObjectAdapter domainObjectAdapter = getAdapterManager().adapterFor(domainObject);
final String domainObjectClassName = CommandUtil.targetClassNameFor(domainObjectAdapter);
- final String targetActionName = CommandUtil.targetActionNameFor(action);
+ final String targetActionName = CommandUtil.targetMemberNameFor(action);
final ObjectAdapter[] argAdapters = adaptersFor(args);
final String targetArgs = CommandUtil.argDescriptionFor(action, argAdapters);
@@ -227,14 +227,14 @@ public class BackgroundServiceDefault implements BackgroundService2 {
final BackgroundCommandService2 bcs2 = (BackgroundCommandService2) backgroundCommandService;
final List<ObjectAdapter> targetList = Collections.singletonList(domainObjectAdapter);
- final CommandMementoDto dto =
- commandMementoService.asCommandMemento(targetList, action, argAdapters);
+ final CommandDto dto =
+ commandDtoService.asCommandDto(targetList, action, argAdapters);
bcs2.schedule(dto, command, domainObjectClassName, targetActionName, targetArgs);
} else {
// fallback
final ActionInvocationMemento aim =
- commandMementoService.asActionInvocationMemento(proxyMethod, target, args);
+ commandDtoService.asActionInvocationMemento(proxyMethod, target, args);
backgroundCommandService.schedule(aim, command, domainObjectClassName, targetActionName, targetArgs);
}
@@ -282,7 +282,7 @@ public class BackgroundServiceDefault implements BackgroundService2 {
private BackgroundCommandService backgroundCommandService;
@javax.inject.Inject
- private CommandMementoService commandMementoService;
+ private CommandDtoService commandDtoService;
@javax.inject.Inject
private CommandContext commandContext;
http://git-wip-us.apache.org/repos/asf/isis/blob/a9d706be/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandDtoServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandDtoServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandDtoServiceDefault.java
new file mode 100644
index 0000000..6741ae3
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandDtoServiceDefault.java
@@ -0,0 +1,255 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.isis.core.runtime.services.command;
+
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.annotation.PostConstruct;
+
+import com.google.common.collect.Lists;
+
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.annotation.NatureOfService;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.services.background.ActionInvocationMemento;
+import org.apache.isis.applib.services.background.BackgroundCommandService;
+import org.apache.isis.applib.services.bookmark.Bookmark;
+import org.apache.isis.applib.services.bookmark.BookmarkService;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.facets.actions.action.invocation.CommandUtil;
+import org.apache.isis.core.metamodel.services.command.CommandDtoService;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.core.metamodel.specloader.specimpl.dflt.ObjectSpecificationDefault;
+import org.apache.isis.core.runtime.services.memento.MementoServiceDefault;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.schema.cmd.v1.ActionDto;
+import org.apache.isis.schema.cmd.v1.CommandDto;
+import org.apache.isis.schema.cmd.v1.InteractionTypeDto;
+import org.apache.isis.schema.cmd.v1.ParamDto;
+import org.apache.isis.schema.cmd.v1.PropertyDto;
+import org.apache.isis.schema.common.v1.ValueDto;
+import org.apache.isis.schema.utils.CommandDtoUtils;
+import org.apache.isis.schema.utils.CommonDtoUtils;
+
+/**
+ * Depends on an implementation of {@link BackgroundCommandService} to
+ * be configured.
+ */
+@DomainService(
+ nature = NatureOfService.DOMAIN
+)
+public class CommandDtoServiceDefault implements CommandDtoService {
+
+ private final MementoServiceDefault mementoService;
+
+ public CommandDtoServiceDefault() {
+ this(new MementoServiceDefault());
+ }
+
+ CommandDtoServiceDefault(MementoServiceDefault mementoService) {
+ this.mementoService = mementoService.withNoEncoding();
+ }
+
+ // //////////////////////////////////////
+
+
+ @Programmatic
+ @PostConstruct
+ public void init(Map<String,String> props) {
+ }
+
+ // //////////////////////////////////////
+
+
+ private ObjectSpecificationDefault getJavaSpecificationOfOwningClass(final Method method) {
+ return getJavaSpecification(method.getDeclaringClass());
+ }
+
+ private ObjectSpecificationDefault getJavaSpecification(final Class<?> cls) {
+ final ObjectSpecification objectSpec = getSpecification(cls);
+ if (!(objectSpec instanceof ObjectSpecificationDefault)) {
+ throw new UnsupportedOperationException(
+ "Only Java is supported "
+ + "(specification is '" + objectSpec.getClass().getCanonicalName() + "')");
+ }
+ return (ObjectSpecificationDefault) objectSpec;
+ }
+
+ private ObjectSpecification getSpecification(final Class<?> type) {
+ return getSpecificationLoader().loadSpecification(type);
+ }
+
+
+ // //////////////////////////////////////
+
+ @Deprecated
+ @Programmatic
+ @Override
+ public ActionInvocationMemento asActionInvocationMemento(
+ final Method method,
+ final Object domainObject,
+ final Object[] args) {
+
+ final ObjectSpecificationDefault targetObjSpec = getJavaSpecificationOfOwningClass(method);
+ final ObjectMember member = targetObjSpec.getMember(method);
+ if(member == null) {
+ return null;
+ }
+
+ if(!(member instanceof ObjectAction)) {
+ throw new UnsupportedOperationException(String.format(
+ "Method %s does not correspond to an action.", method.getName()));
+ }
+
+ final ObjectAction action = (ObjectAction) member;
+ final String actionIdentifier = CommandUtil.memberIdentifierFor(action);
+
+ final Bookmark domainObjectBookmark = bookmarkService.bookmarkFor(domainObject);
+
+ final List<Class<?>> argTypes = Lists.newArrayList();
+ final List<Object> argObjs = Lists.newArrayList();
+ CommandUtil.buildMementoArgLists(mementoService, bookmarkService, method, args, argTypes, argObjs);
+
+ final ActionInvocationMemento aim =
+ new ActionInvocationMemento(mementoService,
+ actionIdentifier,
+ domainObjectBookmark,
+ argTypes,
+ argObjs);
+
+ return aim;
+ }
+
+ @Override
+ public CommandDto asCommandDto(
+ final List<ObjectAdapter> targetAdapters,
+ final ObjectAction objectAction,
+ final ObjectAdapter[] argAdapters) {
+
+ final CommandDto dto = asCommandDto(targetAdapters);
+
+ dto.setInteractionType(InteractionTypeDto.ACTION_INVOCATION);
+ final ActionDto actionDto = new ActionDto();
+ dto.setMember(actionDto);
+
+ addActionArgs(objectAction, actionDto, argAdapters);
+
+ return dto;
+ }
+
+ @Override
+ public CommandDto asCommandDto(
+ final List<ObjectAdapter> targetAdapters,
+ final OneToOneAssociation property,
+ final ObjectAdapter valueAdapterOrNull) {
+
+ final CommandDto dto = asCommandDto(targetAdapters);
+
+ dto.setInteractionType(InteractionTypeDto.PROPERTY_MODIFICATION);
+ final PropertyDto propertyDto = new PropertyDto();
+ dto.setMember(propertyDto);
+
+ addPropertyValue(property, propertyDto, valueAdapterOrNull);
+
+ return dto;
+ }
+
+ private CommandDto asCommandDto(final List<ObjectAdapter> targetAdapters) {
+ final CommandDto dto = new CommandDto();
+ dto.setMajorVersion("1");
+ dto.setMinorVersion("0");
+
+ dto.setTransactionId(UUID.randomUUID().toString());
+
+ for (ObjectAdapter targetAdapter : targetAdapters) {
+ final RootOid rootOid = (RootOid) targetAdapter.getOid();
+ final Bookmark bookmark = rootOid.asBookmark();
+ dto.getTargets().add(bookmark.toOidDto());
+ }
+ return dto;
+ }
+
+
+ @Override
+ public void addActionArgs(
+ final ObjectAction objectAction,
+ final ActionDto actionDto,
+ final ObjectAdapter[] argAdapters) {
+ final String actionIdentifier = CommandUtil.memberIdentifierFor(objectAction);
+ actionDto.setMemberIdentifier(actionIdentifier);
+
+ List<ObjectActionParameter> actionParameters = objectAction.getParameters();
+ for (int paramNum = 0; paramNum < actionParameters.size(); paramNum++) {
+ final ObjectActionParameter actionParameter = actionParameters.get(paramNum);
+ final String parameterName = actionParameter.getName();
+ final Class<?> paramType = actionParameter.getSpecification().getCorrespondingClass();
+ final ObjectAdapter argAdapter = argAdapters[paramNum];
+ final Object arg = argAdapter != null? argAdapter.getObject(): null;
+ final List<ParamDto> parameters = actionDto.getParameters();
+ CommandDtoUtils.addParamArg(
+ parameters, parameterName, paramType, arg, bookmarkService);
+ }
+ }
+
+ @Override
+ public void addPropertyValue(
+ final OneToOneAssociation property,
+ final PropertyDto propertyDto,
+ final ObjectAdapter valueAdapter) {
+
+ final String actionIdentifier = CommandUtil.memberIdentifierFor(property);
+ propertyDto.setMemberIdentifier(actionIdentifier);
+
+ final ObjectSpecification valueSpec = property.getSpecification();
+
+ final ValueDto valueDto = new ValueDto();
+ CommonDtoUtils.setValue(
+ valueDto, valueSpec.getCorrespondingClass(), ObjectAdapter.Util.unwrap(valueAdapter));
+
+ propertyDto.setNewValue(valueDto);
+ }
+
+ // //////////////////////////////////////
+
+
+ @javax.inject.Inject
+ private BookmarkService bookmarkService;
+
+
+ // //////////////////////////////////////
+
+ protected SpecificationLoaderSpi getSpecificationLoader() {
+ return IsisContext.getSpecificationLoader();
+ }
+
+ protected AdapterManager getAdapterManager() {
+ return IsisContext.getPersistenceSession();
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/a9d706be/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
deleted file mode 100644
index 7d869c3..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.core.runtime.services.command;
-
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.annotation.PostConstruct;
-
-import com.google.common.collect.Lists;
-
-import org.apache.isis.applib.annotation.DomainService;
-import org.apache.isis.applib.annotation.NatureOfService;
-import org.apache.isis.applib.annotation.Programmatic;
-import org.apache.isis.applib.services.background.ActionInvocationMemento;
-import org.apache.isis.applib.services.background.BackgroundCommandService;
-import org.apache.isis.applib.services.bookmark.Bookmark;
-import org.apache.isis.applib.services.bookmark.BookmarkService;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.core.metamodel.facets.actions.action.invocation.CommandUtil;
-import org.apache.isis.core.metamodel.services.command.CommandMementoService;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
-import org.apache.isis.core.metamodel.specloader.specimpl.dflt.ObjectSpecificationDefault;
-import org.apache.isis.core.runtime.services.memento.MementoServiceDefault;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.schema.cmd.v1.ActionDto;
-import org.apache.isis.schema.cmd.v1.CommandMementoDto;
-import org.apache.isis.schema.cmd.v1.ParamDto;
-import org.apache.isis.schema.utils.CommandMementoDtoUtils;
-
-/**
- * Depends on an implementation of {@link BackgroundCommandService} to
- * be configured.
- */
-@DomainService(
- nature = NatureOfService.DOMAIN
-)
-public class CommandMementoServiceDefault implements CommandMementoService {
-
- private final MementoServiceDefault mementoService;
-
- public CommandMementoServiceDefault() {
- this(new MementoServiceDefault());
- }
-
- CommandMementoServiceDefault(MementoServiceDefault mementoService) {
- this.mementoService = mementoService.withNoEncoding();
- }
-
- // //////////////////////////////////////
-
-
- @Programmatic
- @PostConstruct
- public void init(Map<String,String> props) {
- }
-
- // //////////////////////////////////////
-
-
- private ObjectSpecificationDefault getJavaSpecificationOfOwningClass(final Method method) {
- return getJavaSpecification(method.getDeclaringClass());
- }
-
- private ObjectSpecificationDefault getJavaSpecification(final Class<?> cls) {
- final ObjectSpecification objectSpec = getSpecification(cls);
- if (!(objectSpec instanceof ObjectSpecificationDefault)) {
- throw new UnsupportedOperationException(
- "Only Java is supported "
- + "(specification is '" + objectSpec.getClass().getCanonicalName() + "')");
- }
- return (ObjectSpecificationDefault) objectSpec;
- }
-
- private ObjectSpecification getSpecification(final Class<?> type) {
- return getSpecificationLoader().loadSpecification(type);
- }
-
-
- // //////////////////////////////////////
-
- @Deprecated
- @Programmatic
- @Override
- public ActionInvocationMemento asActionInvocationMemento(
- final Method method,
- final Object domainObject,
- final Object[] args) {
-
- final ObjectSpecificationDefault targetObjSpec = getJavaSpecificationOfOwningClass(method);
- final ObjectMember member = targetObjSpec.getMember(method);
- if(member == null) {
- return null;
- }
-
- if(!(member instanceof ObjectAction)) {
- throw new UnsupportedOperationException(String.format(
- "Method %s does not correspond to an action.", method.getName()));
- }
-
- final ObjectAction action = (ObjectAction) member;
- final String actionIdentifier = CommandUtil.actionIdentifierFor(action);
-
- final Bookmark domainObjectBookmark = bookmarkService.bookmarkFor(domainObject);
-
- final List<Class<?>> argTypes = Lists.newArrayList();
- final List<Object> argObjs = Lists.newArrayList();
- CommandUtil.buildMementoArgLists(mementoService, bookmarkService, method, args, argTypes, argObjs);
-
- final ActionInvocationMemento aim =
- new ActionInvocationMemento(mementoService,
- actionIdentifier,
- domainObjectBookmark,
- argTypes,
- argObjs);
-
- return aim;
- }
-
- @Override
- public CommandMementoDto asCommandMemento(
- final List<ObjectAdapter> targetAdapters,
- final ObjectAction objectAction,
- final ObjectAdapter[] argAdapters) {
-
- final CommandMementoDto dto = new CommandMementoDto();
- dto.setMajorVersion("1");
- dto.setMinorVersion("0");
-
- for (ObjectAdapter targetAdapter : targetAdapters) {
- final RootOid rootOid = (RootOid) targetAdapter.getOid();
- final Bookmark bookmark = rootOid.asBookmark();
- dto.getTargets().add(bookmark.toOidDto());
- }
-
- final ActionDto actionDto = new ActionDto();
- dto.setAction(actionDto);
-
- addActionArgs(objectAction, actionDto, argAdapters);
-
- dto.setTransactionId(UUID.randomUUID().toString());
- return dto;
- }
-
- @Override
- public CommandMementoDto asCommandMemento(
- final ObjectAdapter targetAdapter,
- final OneToOneAssociation association,
- final ObjectAdapter valueAdapterOrNull) {
-
- // TODO. introduce a choice for aim vs pmm, in the cmd.xsd
-
- throw new RuntimeException("not yet implemented");
- }
-
- @Override
- public void addActionArgs(
- final ObjectAction objectAction,
- final ActionDto actionDto,
- final ObjectAdapter[] argAdapters) {
- final String actionIdentifier = CommandUtil.actionIdentifierFor(objectAction);
- actionDto.setMemberIdentifier(actionIdentifier);
-
- List<ObjectActionParameter> actionParameters = objectAction.getParameters();
- for (int paramNum = 0; paramNum < actionParameters.size(); paramNum++) {
- final ObjectActionParameter actionParameter = actionParameters.get(paramNum);
- final String parameterName = actionParameter.getName();
- final Class<?> paramType = actionParameter.getSpecification().getCorrespondingClass();
- final ObjectAdapter argAdapter = argAdapters[paramNum];
- final Object arg = argAdapter != null? argAdapter.getObject(): null;
- final List<ParamDto> parameters = actionDto.getParameters();
- CommandMementoDtoUtils.addParamArg(
- parameters, parameterName, paramType, arg, bookmarkService);
- }
- }
-
- // //////////////////////////////////////
-
-
- @javax.inject.Inject
- private BookmarkService bookmarkService;
-
-
- // //////////////////////////////////////
-
- protected SpecificationLoaderSpi getSpecificationLoader() {
- return IsisContext.getSpecificationLoader();
- }
-
- protected AdapterManager getAdapterManager() {
- return IsisContext.getPersistenceSession();
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a9d706be/core/runtime/src/main/java/org/apache/isis/core/runtime/services/publishing/PublishingServiceInternalDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/publishing/PublishingServiceInternalDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/publishing/PublishingServiceInternalDefault.java
index 9064bb8..4e0a3fc 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/publishing/PublishingServiceInternalDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/publishing/PublishingServiceInternalDefault.java
@@ -63,7 +63,7 @@ import org.apache.isis.core.metamodel.facets.actions.action.invocation.CommandUt
import org.apache.isis.core.metamodel.facets.actions.publish.PublishedActionFacet;
import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
import org.apache.isis.core.metamodel.facets.object.publishedobject.PublishedObjectFacet;
-import org.apache.isis.core.metamodel.services.command.CommandMementoService;
+import org.apache.isis.core.metamodel.services.command.CommandDtoService;
import org.apache.isis.core.metamodel.services.publishing.PublishingServiceInternal;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
@@ -215,9 +215,9 @@ public class PublishingServiceInternalDefault implements PublishingServiceIntern
final String title = oidStr + ": " + actionIdentifier.toNameParmsIdentityString();
final String actionTargetClass = CommandUtil.targetClassNameFor(targetAdapter);
- final String actionTargetAction = CommandUtil.targetActionNameFor(objectAction);
+ final String actionTargetAction = CommandUtil.targetMemberNameFor(objectAction);
final Bookmark actionTarget = CommandUtil.bookmarkFor(targetAdapter);
- final String actionMemberIdentifier = CommandUtil.actionIdentifierFor(objectAction);
+ final String actionMemberIdentifier = CommandUtil.memberIdentifierFor(objectAction);
final List<String> parameterNames;
final List<Class<?>> parameterTypes;
@@ -353,7 +353,7 @@ public class PublishingServiceInternalDefault implements PublishingServiceIntern
final Timestamp completedAt = execution.getCompletedAt();
final ActionDto actionDto = new ActionDto();
- commandMementoService.addActionArgs(
+ commandDtoService.addActionArgs(
objectAction, actionDto, parameterAdapters.toArray(new ObjectAdapter[]{}));
final ObjectSpecification returnSpec = objectAction.getReturnType();
@@ -398,7 +398,7 @@ public class PublishingServiceInternalDefault implements PublishingServiceIntern
private PublishingService publishingServiceIfAny;
@Inject
- CommandMementoService commandMementoService;
+ CommandDtoService commandDtoService;
@Inject
private BookmarkService bookmarkService;
http://git-wip-us.apache.org/repos/asf/isis/blob/a9d706be/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.0.xsd
----------------------------------------------------------------------
diff --git a/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.0.xsd b/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.0.xsd
index 893a408..66185dd 100644
--- a/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.0.xsd
+++ b/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.0.xsd
@@ -25,7 +25,7 @@
<xs:import namespace="http://isis.apache.org/schema/common" schemaLocation="../common/common-1.0.xsd"/>
- <xs:element name="commandMementoDto">
+ <xs:element name="commandDto">
<xs:annotation>
<xs:documentation>Represents v1.0 of this schema.
</xs:documentation>
@@ -56,9 +56,10 @@
</xs:documentation>
</xs:annotation>
</xs:element>
- <xs:element name="action" type="actionDto">
+ <xs:element name="interactionType" type="interactionTypeDto"/>
+ <xs:element name="member" type="memberDto">
<xs:annotation>
- <xs:documentation>The action and arguments to be invoked on the target object(s).</xs:documentation>
+ <xs:documentation>The action or property (identifier and parameter arguments) to be invoked on the target object(s).</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="user" type="xs:string">
@@ -69,9 +70,18 @@
</xs:element>
</xs:sequence>
</xs:complexType>
-
</xs:element>
+ <xs:simpleType name="interactionTypeDto" final="restriction" >
+ <xs:annotation>
+ <xs:documentation>Whether this interaction with a member is invoking an action, or modifying a property.</xs:documentation>
+ </xs:annotation>
+ <xs:restriction base="xs:NMTOKEN">
+ <xs:enumeration value="ACTION_INVOCATION" />
+ <xs:enumeration value="PROPERTY_MODIFICATION" />
+ </xs:restriction>
+ </xs:simpleType>
+
<xs:complexType name="memberDto" abstract="true">
<xs:annotation>
<xs:documentation>Represents the information required to be able to invoke an action or modify a property on the target(s). Specifically, is the identifier of the action/property, along with the parameter arguments. Is subclassed by 'actionDto' and 'propertyDto'.
@@ -111,7 +121,7 @@
<xs:complexContent>
<xs:extension base="memberDto">
<xs:sequence>
- <xs:element name="newValue" type="paramDto"/>
+ <xs:element name="newValue" type="common:valueDto"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>