blob: 0fb1a69abc73d83f5067f6d958f2bb8a3bc25973 [file] [log] [blame]
/**
* Copyright (c)2020 CEA LIST, Committer Name, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* CEA LIST - Initial API and implementation
* Gabriel Pedroza (CEA LIST) gabriel.pedroza@cea.fr
*
*/
package org.eclipse.papyrus.pdp4eng.designer.controller.internal;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.IdentityCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.pdp4eng.designer.controller.api.IModelTransfo;
import org.eclipse.papyrus.pdp4eng.designer.controller.api.ModelTransfoFactory;
import org.eclipse.papyrus.pdp4eng.designer.controller.internal.processcreation.ProcessDFDCreateCommand;
import org.eclipse.papyrus.pdp4eng.designer.profile.pdp4engDesign.Data;
import org.eclipse.uml2.uml.Action;
import org.eclipse.uml2.uml.Activity;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.OpaqueAction;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.util.UMLUtil;
/**
* This factory is an implementation of a factory that gives command to execute model transformation
* to used it see {@link ModelTransfoFactory}
*/
public class ModelTransfoFactoryImpl implements IModelTransfo{
/**
* return a command to create an abstraction from a given Data
* @param domain
* @param data
* @return a command, it is never null
*/
public Command getAbstractionDataCommand(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Element data) {
if( data instanceof NamedElement) {
Data appliedStereotypedata= (Data)UMLUtil.getStereotypeApplication(data, Data.class);
if( appliedStereotypedata!=null) {
return new AbstractDataCreateCommand(domain, (NamedElement)data);
}
}
return IdentityCommand.INSTANCE;
}
@Override
public Command getCreateProcessModelFromReq(TransactionalEditingDomain domain, Package owner,Activity ReqDFDSource) {
return new ProcessDFDCreateCommand(domain, owner,ReqDFDSource);
}
@Override
public Command getCallProcessToProcessCommand(TransactionalEditingDomain domain, OpaqueAction process) {
return new CallProcessToProcessCommand(domain, process);
}
@Override
public Command getActionCallProcessToProcessCommand(TransactionalEditingDomain domain, Action actionCallProcess) {
return new ActionCallProcessToProcessCommand(domain, actionCallProcess);
}
public Command getAllCallProcessToProcessCommand(TransactionalEditingDomain domain, Activity activityDFD) {
return new AllCallProcessToProcessCommand(domain, activityDFD);
}
@Override
public Command getApplyPDPbDProfileToActivityDFDCommand(TransactionalEditingDomain domain, Activity activityDFD) {
return new ApplyPDPbDProfileToActivityDFDCommand(domain, activityDFD);
}
@Override
public Command getInstantiateGDPRConsentPatternCommand(TransactionalEditingDomain domain, Activity process) {
return new InstantiateGDPRConsentPatternCommand(domain, process);
}
@Override
public Command getInstantiateGDPRNotificationsPatternCommand(TransactionalEditingDomain domain, Activity process) {
return new InstantiateGDPRNotificationsPatternCommand(domain, process);
}
}