blob: 4bcbb326337ea4ccd6dc7ad9897d969d3c2556b1 [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
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr
* Gabriel Pedroza (CEA LIST) gabriel.pedroza@cea.fr
*****************************************************************************/
package org.eclipse.pdp4eng.req.gdprananalysis.internal;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.Contract;
import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.DataSubject;
import org.eclipse.papyrus.pdp4eng.req.metareq.GDPRRequirements;
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.Lawful;
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByContract;
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.ProcessRequirement;
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.pdp4engReqGDPRPackage;
import org.eclipse.papyrus.sysml14.requirements.Requirement;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.util.UMLUtil;
import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper;
/**
* command for 6.1.b
*
*/
public class LawfulRequirementByContractCreateCommand extends AbstractLawfulRequirementByCreateCommand{
public LawfulRequirementByContractCreateCommand(TransactionalEditingDomain domain, Element owner, String id, String text,ProcessRequirement processRequirement, DataSubject dataSubject) {
super(domain, owner, id, text,processRequirement, dataSubject);
}
@Override
protected Object getLawfulObject(ProcessRequirement process) {
return process.getPerformAContract();
}
@Override
protected void setTextOnRequirement(GDPRRequirements gdprRrequiement,Requirement reqStereotype, EObject lawfulBy) {
if( lawfulBy instanceof LawfulByContract) {
LawfulByContract lawfulByContract = (LawfulByContract) lawfulBy;
reqStereotype.setText(""+gdprRrequiement.getDescriptionForLawfulByContract(lawfulByContract));
}
}
@Override
protected void associateLawfulObjectToAppliedStereotype(EObject lawfulBy, Object lawfulObject) {
if( lawfulBy instanceof LawfulByContract) {
LawfulByContract lawfulByContract = (LawfulByContract) lawfulBy;
lawfulByContract.setContract((Contract)lawfulObject);
}
}
@Override
protected Lawful applyStereotype(StereotypeApplicationHelper stereotypeApplicationHelper, Class requirementClass) {
stereotypeApplicationHelper.applyStereotype(requirementClass, pdp4engReqGDPRPackage.eINSTANCE.getLawfulByContract(),null);
return UMLUtil.getStereotypeApplication(requirementClass, org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByContract.class);
}
}