| 1 | /** |
| 2 | * |
| 3 | */ |
| 4 | package de.uka.ipd.sdq.pcm.gmf.seff.helper; |
| 5 | |
| 6 | import org.eclipse.core.commands.ExecutionException; |
| 7 | import org.eclipse.core.runtime.IAdaptable; |
| 8 | import org.eclipse.core.runtime.IProgressMonitor; |
| 9 | import org.eclipse.gmf.runtime.common.core.command.CommandResult; |
| 10 | import org.eclipse.gmf.runtime.common.core.command.ICommand; |
| 11 | import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand; |
| 12 | import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; |
| 13 | import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; |
| 14 | import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; |
| 15 | |
| 16 | import de.uka.ipd.sdq.pcm.repository.OperationRequiredRole; |
| 17 | import de.uka.ipd.sdq.pcm.repository.OperationSignature; |
| 18 | import de.uka.ipd.sdq.pcm.seff.SeffPackage; |
| 19 | |
| 20 | /** |
| 21 | * @author Roman Andrej |
| 22 | */ |
| 23 | public class ExternalCallActionConfigureCommand extends ConfigureElementCommand { |
| 24 | |
| 25 | private ConfigureRequest request = null; |
| 26 | private OperationSignature signature = null; |
| 27 | private OperationRequiredRole requiredRole = null; |
| 28 | |
| 29 | public ExternalCallActionConfigureCommand(ConfigureRequest request, |
| 30 | OperationSignature signature, OperationRequiredRole requiredRole) { |
| 31 | super(request); |
| 32 | this.request = request; |
| 33 | this.signature = signature; |
| 34 | this.requiredRole = requiredRole; |
| 35 | } |
| 36 | |
| 37 | /* (non-Javadoc) |
| 38 | * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
| 39 | */ |
| 40 | @Override |
| 41 | protected CommandResult doExecuteWithResult(IProgressMonitor monitor, |
| 42 | IAdaptable info) throws ExecutionException { |
| 43 | CommandResult commandResult = setOperationSignatureExternalCallAction(monitor, |
| 44 | info); |
| 45 | if (!isOK(commandResult)) { |
| 46 | return CommandResult |
| 47 | .newErrorCommandResult("Set OperationSignature for the ExternalCallAction failed!"); |
| 48 | } |
| 49 | commandResult = setRequiredRoleEntryLevelSystemCall(monitor, info); |
| 50 | if (!isOK(commandResult)) { |
| 51 | return CommandResult |
| 52 | .newErrorCommandResult("Set OperationProvidedRole for the ExternalCallAction failed!"); |
| 53 | } |
| 54 | return CommandResult.newOKCommandResult(); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | private CommandResult setOperationSignatureExternalCallAction( |
| 59 | IProgressMonitor monitor, IAdaptable info) |
| 60 | throws ExecutionException { |
| 61 | |
| 62 | ICommand cmd = new SetValueCommand(new SetRequest(request |
| 63 | .getElementToConfigure(), SeffPackage.eINSTANCE |
| 64 | .getExternalCallAction_CalledService_ExternalService(), |
| 65 | signature)); |
| 66 | |
| 67 | cmd.execute(monitor, info); |
| 68 | |
| 69 | return cmd.getCommandResult(); |
| 70 | } |
| 71 | |
| 72 | private CommandResult setRequiredRoleEntryLevelSystemCall( |
| 73 | IProgressMonitor monitor, IAdaptable info) |
| 74 | throws ExecutionException { |
| 75 | |
| 76 | ICommand cmd = new SetValueCommand(new SetRequest(request |
| 77 | .getElementToConfigure(), SeffPackage.eINSTANCE |
| 78 | .getExternalCallAction_Role_ExternalService(), requiredRole)); |
| 79 | |
| 80 | cmd.execute(monitor, info); |
| 81 | |
| 82 | return cmd.getCommandResult(); |
| 83 | } |
| 84 | } |