Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2021-05-05 14:57:49 +0000
committerptessier2021-05-05 14:57:49 +0000
commitcd906b5a18619dd4697d6673d62c8f0af05c37e1 (patch)
tree2148f4ec1e043702a77d7aadf1a96c2fc4e68d71
parent76d045be19fdb74e4b69e406fd26b7c56fc10c63 (diff)
downloadorg.eclipse.papyrus-privacydesigner-cd906b5a18619dd4697d6673d62c8f0af05c37e1.tar.gz
org.eclipse.papyrus-privacydesigner-cd906b5a18619dd4697d6673d62c8f0af05c37e1.tar.xz
org.eclipse.papyrus-privacydesigner-cd906b5a18619dd4697d6673d62c8f0af05c37e1.zip
Bug 573384 - [privacydesigner] refactor creation of the requirement
6.1.a Change-Id: Id85d26f5b12b31de972ffabd9d6fdba8e95f4efa Signed-off-by: ptessier <Patrick.Tessier@cea.fr>
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/papyrus/pdp4eng/req/gdprananalysis/api/IRequirementGenerator.java11
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/papyrus/pdp4eng/req/gdprananalysis/api/RequirementGenerator.java35
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementByConsentCreateCommand.java173
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementByContractCreateCommand.java168
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementCreateCommand.java27
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/RequirementTestGeneratorImpl.java124
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.metareq/src/org/eclipse/papyrus/pdp4eng/req/metareq/GDPRRequirements.xtend20
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.metareq/xtend-gen/org/eclipse/papyrus/pdp4eng/req/metareq/GDPRRequirements.java66
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.ui/src/org/eclipse/papyrus/pdp4eng/req/ui/GenerateGDPRRequirementHandler.java2
9 files changed, 557 insertions, 69 deletions
diff --git a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/papyrus/pdp4eng/req/gdprananalysis/api/IRequirementGenerator.java b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/papyrus/pdp4eng/req/gdprananalysis/api/IRequirementGenerator.java
index 3f6bb7f..0318ca6 100644
--- a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/papyrus/pdp4eng/req/gdprananalysis/api/IRequirementGenerator.java
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/papyrus/pdp4eng/req/gdprananalysis/api/IRequirementGenerator.java
@@ -29,10 +29,21 @@ public interface IRequirementGenerator {
* @param owner
* @return
*/
+ //article 5
public Command generateArticle51a(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Package owner);
public Command generateArticle51b(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Package owner);
public Command generateArticle51c(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Package owner);
public Command generateArticle51d(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Package owner);
public Command generateArticle51e(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Package owner);
public Command generateArticle51f(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Package owner);
+
+ //article 6
+ public Command generateArticle61a(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Package owner);
+ public Command generateArticle61b(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Package owner);
+ public Command generateArticle61c(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Package owner);
+ public Command generateArticle61d(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Package owner);
+ public Command generateArticle61e(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Package owner);
+ public Command generateArticle61f(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Package owner);
+ public Command generateArticle64(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Package owner);
+
}
diff --git a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/papyrus/pdp4eng/req/gdprananalysis/api/RequirementGenerator.java b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/papyrus/pdp4eng/req/gdprananalysis/api/RequirementGenerator.java
index 759d08d..a5caa63 100644
--- a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/papyrus/pdp4eng/req/gdprananalysis/api/RequirementGenerator.java
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/papyrus/pdp4eng/req/gdprananalysis/api/RequirementGenerator.java
@@ -54,6 +54,41 @@ public class RequirementGenerator implements IRequirementGenerator {
return generatorImpl.generateArticle51e(domain, owner);
}
+ @Override
+ public Command generateArticle61a(TransactionalEditingDomain domain, Package owner) {
+ return generatorImpl.generateArticle61a(domain, owner);
+ }
+
+ @Override
+ public Command generateArticle61b(TransactionalEditingDomain domain, Package owner) {
+ return generatorImpl.generateArticle61b(domain, owner);
+ }
+
+ @Override
+ public Command generateArticle61c(TransactionalEditingDomain domain, Package owner) {
+ return generatorImpl.generateArticle61c(domain, owner);
+ }
+
+ @Override
+ public Command generateArticle61d(TransactionalEditingDomain domain, Package owner) {
+ return generatorImpl.generateArticle61d(domain, owner);
+ }
+
+ @Override
+ public Command generateArticle61e(TransactionalEditingDomain domain, Package owner) {
+ return generatorImpl.generateArticle61e(domain, owner);
+ }
+
+ @Override
+ public Command generateArticle61f(TransactionalEditingDomain domain, Package owner) {
+ return generatorImpl.generateArticle61f(domain, owner);
+ }
+
+ @Override
+ public Command generateArticle64(TransactionalEditingDomain domain, Package owner) {
+ return generatorImpl.generateArticle64(domain, owner);
+ }
+
}
diff --git a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementByConsentCreateCommand.java b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementByConsentCreateCommand.java
new file mode 100644
index 0000000..44b7246
--- /dev/null
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementByConsentCreateCommand.java
@@ -0,0 +1,173 @@
+/*****************************************************************************
+ * 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 java.util.Iterator;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+/**
+ * Copyright (c) 2019 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are the property of the CEA.
+ * Any use is subject to specific agreement with the CEA.
+ * Contributors:
+ *
+ * Patrick Tessier (CEA LIST) - Initial API and implementation
+ *
+ */
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.sysml14.requirements.Requirement;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.util.UMLUtil;
+import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper;
+
+import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.Consent;
+import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.DataSubject;
+import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.PersonalData;
+import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.Purpose;
+import org.eclipse.papyrus.pdp4eng.req.metareq.GDPRRequirements;
+import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.pdp4engReqGDPRPackage;
+import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.PersonalDataRequirement;
+import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.ProcessRequirement;
+
+public class LawfulRequirementByConsentCreateCommand extends BasicGDPRRequirementCreateCommand {
+
+ private DataSubject dataSubject;
+ public LawfulRequirementByConsentCreateCommand(TransactionalEditingDomain domain, Element owner, String id, String text,ProcessRequirement processRequirement, DataSubject dataSubject) {
+ super(domain, owner, id, text,processRequirement);
+ this.dataSubject= dataSubject;
+ }
+
+ @Override
+ protected void createRequirement(Package owner, String id, String text) {
+ StereotypeApplicationHelper stereotypeApplicationHelper = StereotypeApplicationHelper.getInstance(null);
+ GDPRRequirements gdprRrequiement= new GDPRRequirements();
+
+ Class lawfullReq =null;
+ //1. look for LawfulRequirement
+ lawfullReq = lookForLawFullRequirement(owner, lawfullReq);
+
+
+ //2. create the sub requirement
+ for (Iterator<Consent> iteratorConsent = dataSubject.getGivenConsent().iterator(); iteratorConsent.hasNext();) {
+ Consent aConsent = (Consent) iteratorConsent.next();
+ for (Iterator<Purpose> purposeIterator = aConsent.getPurpose().iterator(); purposeIterator.hasNext();) {
+ Purpose aPurpose = (Purpose) purposeIterator.next();
+ if( aPurpose.getProcesses().contains(this.processRequirement)) {
+ //1.1 create the class
+ Class requirementClass =UMLFactory.eINSTANCE.createClass();
+
+ //2.1 set the owner
+ setTheOwner(owner, lawfullReq, requirementClass);
+ //3. apply the seterotype
+ stereotypeApplicationHelper.applyStereotype(requirementClass,org.eclipse.papyrus.sysml14.requirements.RequirementsPackage.eINSTANCE.getRequirement(),null );
+ Requirement reqStereotype= (Requirement)UMLUtil.getStereotypeApplication(requirementClass, Requirement.class);
+ stereotypeApplicationHelper.applyStereotype(requirementClass,pdp4engReqGDPRPackage.eINSTANCE.getLawfulByConsent(),null );
+ org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByConsent lawfulRbyConsent= (org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByConsent)UMLUtil.getStereotypeApplication(requirementClass, org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByConsent.class);
+ //4. set attribute of the applied stereotype
+ setAttributeAppliedStereotype(gdprRrequiement, aConsent, reqStereotype, lawfulRbyConsent);
+ //5.set the ID
+ setTheID(id, lawfullReq, requirementClass, reqStereotype);
+
+ }
+
+ }
+
+ }
+
+
+ }
+
+ private void setAttributeAppliedStereotype(GDPRRequirements gdprRrequiement, Consent aConsent, Requirement reqStereotype, org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByConsent lawfulRbyConsent) {
+ lawfulRbyConsent.setConsent(aConsent);
+ lawfulRbyConsent.setDataSubject(dataSubject);
+ for (PersonalData personalData : processRequirement.getPersonaldata()) {
+ lawfulRbyConsent.getPersonalData().add((PersonalDataRequirement) personalData);
+ }
+ lawfulRbyConsent.setProcess(this.processRequirement);
+ reqStereotype.setText(""+gdprRrequiement.getDescriptionForLawfulByConsent(lawfulRbyConsent));
+ }
+
+ /**
+ * set the id of the requirement
+ * @param id
+ * @param lawfullReq
+ * @param requirementClass
+ * @param reqStereotype
+ */
+ private void setTheID(String id, Class lawfullReq, Class requirementClass, Requirement reqStereotype) {
+ if(lawfullReq==null) {
+ reqStereotype.setId(id);
+ requirementClass.setName(id);
+ }
+ else {
+ reqStereotype.setId(lawfullReq.getName()+"."+lawfullReq.getNestedClassifiers().size());
+ requirementClass.setName(lawfullReq.getName()+"."+lawfullReq.getNestedClassifiers().size());
+ }
+ }
+
+ /** tSet the owner the of the requirement
+ *
+ * @param owner
+ * @param lawfullReq
+ * @param requirementClass
+ */
+ private void setTheOwner(Package owner, Class lawfullReq, Class requirementClass) {
+ if(lawfullReq==null) {
+ owner.getPackagedElements().add(requirementClass);
+ }
+ else {
+ lawfullReq.getNestedClassifiers().add(requirementClass);
+
+ }
+ }
+
+ /**
+ * look for lawfull requirement that could be the owner
+ * @param owner
+ * @param lawfullReq
+ * @return
+ */
+ private Class lookForLawFullRequirement(Package owner, Class lawfullReq) {
+ TreeIterator<EObject> iterator= owner.eAllContents();
+ while (iterator.hasNext()) {
+ EObject eObject = (EObject) iterator.next();
+ //test if is is a class
+ if (eObject instanceof Class) {
+ Class aclass=(Class)eObject;
+ org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.Lawful lawful= (org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.Lawful)UMLUtil.getStereotypeApplication(aclass, org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.Lawful.class);
+ // test if this is a lawfull req.
+ if( lawful!=null) {
+ //test attributes
+ if(lawful.getProcess().equals(this.processRequirement) && lawful.getDataSubject().equals(this.dataSubject)) {
+ lawfullReq=(Class)lawful.getBase_NamedElement();
+ return lawfullReq;
+ }
+ }
+ }
+
+ }
+ return lawfullReq;
+ }
+
+}
diff --git a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementByContractCreateCommand.java b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementByContractCreateCommand.java
new file mode 100644
index 0000000..337965b
--- /dev/null
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementByContractCreateCommand.java
@@ -0,0 +1,168 @@
+/*****************************************************************************
+ * 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 java.util.Iterator;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+/**
+ * Copyright (c) 2019 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are the property of the CEA.
+ * Any use is subject to specific agreement with the CEA.
+ * Contributors:
+ *
+ * Patrick Tessier (CEA LIST) - Initial API and implementation
+ *
+ */
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.sysml14.requirements.Requirement;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.util.UMLUtil;
+import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper;
+
+import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.Consent;
+import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.Contract;
+import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.DataSubject;
+import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.PersonalData;
+import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.Purpose;
+import org.eclipse.papyrus.pdp4eng.req.metareq.GDPRRequirements;
+import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.pdp4engReqGDPRPackage;
+import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.PersonalDataRequirement;
+import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.ProcessRequirement;
+
+public class LawfulRequirementByContractCreateCommand extends BasicGDPRRequirementCreateCommand {
+
+ private DataSubject dataSubject;
+ public LawfulRequirementByContractCreateCommand(TransactionalEditingDomain domain, Element owner, String id, String text,ProcessRequirement processRequirement, DataSubject dataSubject) {
+ super(domain, owner, id, text,processRequirement);
+ this.dataSubject= dataSubject;
+ }
+
+ @Override
+ protected void createRequirement(Package owner, String id, String text) {
+ StereotypeApplicationHelper stereotypeApplicationHelper = StereotypeApplicationHelper.getInstance(null);
+ GDPRRequirements gdprRrequiement= new GDPRRequirements();
+
+ Class lawfullReq =null;
+ //1. look for LawfulRequirement
+ lawfullReq = lookForLawFullRequirement(owner, lawfullReq);
+
+
+ //2. create the sub requirement
+ for (Iterator<Consent> iteratorConsent = dataSubject.getGivenConsent().iterator(); iteratorConsent.hasNext();) {
+ Contract aContract =this.processRequirement.getPerformAContract();
+ if( aContract!=null) {
+
+ //1.1 create the class
+ Class requirementClass =UMLFactory.eINSTANCE.createClass();
+
+ //2.1 set the owner
+ setTheOwner(owner, lawfullReq, requirementClass);
+ //3. apply the stereotype
+ stereotypeApplicationHelper.applyStereotype(requirementClass,org.eclipse.papyrus.sysml14.requirements.RequirementsPackage.eINSTANCE.getRequirement(),null );
+ Requirement reqStereotype= (Requirement)UMLUtil.getStereotypeApplication(requirementClass, Requirement.class);
+ stereotypeApplicationHelper.applyStereotype(requirementClass,pdp4engReqGDPRPackage.eINSTANCE.getLawfulByConsent(),null );
+ org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByContract lawfulRbyContract= (org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByContract)UMLUtil.getStereotypeApplication(requirementClass, org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByContract.class);
+ //4. set attribute of the applied stereotype
+ setAttributeAppliedStereotype(gdprRrequiement, aContract, reqStereotype, lawfulRbyContract);
+ //5.set the ID
+ setTheID(id, lawfullReq, requirementClass, reqStereotype);
+ }
+ }
+
+ }
+
+ private void setAttributeAppliedStereotype(GDPRRequirements gdprRrequiement, Contract aContract, Requirement reqStereotype, org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByContract lawfulByContract) {
+ lawfulByContract.setContract(aContract);
+ lawfulByContract.setDataSubject(dataSubject);
+ for (PersonalData personalData : processRequirement.getPersonaldata()) {
+ lawfulByContract.getPersonalData().add((PersonalDataRequirement) personalData);
+ }
+ lawfulByContract.setProcess(this.processRequirement);
+ reqStereotype.setText(""+gdprRrequiement.getDescriptionForLawfulByConsent(lawfulByContract));
+ }
+
+ /**
+ * set the id of the requirement
+ * @param id
+ * @param lawfullReq
+ * @param requirementClass
+ * @param reqStereotype
+ */
+ private void setTheID(String id, Class lawfullReq, Class requirementClass, Requirement reqStereotype) {
+ if(lawfullReq==null) {
+ reqStereotype.setId(id);
+ requirementClass.setName(id);
+ }
+ else {
+ reqStereotype.setId(lawfullReq.getName()+"."+lawfullReq.getNestedClassifiers().size());
+ requirementClass.setName(lawfullReq.getName()+"."+lawfullReq.getNestedClassifiers().size());
+ }
+ }
+
+ /** tSet the owner the of the requirement
+ *
+ * @param owner
+ * @param lawfullReq
+ * @param requirementClass
+ */
+ private void setTheOwner(Package owner, Class lawfullReq, Class requirementClass) {
+ if(lawfullReq==null) {
+ owner.getPackagedElements().add(requirementClass);
+ }
+ else {
+ lawfullReq.getNestedClassifiers().add(requirementClass);
+
+ }
+ }
+
+ /**
+ * look for lawfull requirement that could be the owner
+ * @param owner
+ * @param lawfullReq
+ * @return
+ */
+ private Class lookForLawFullRequirement(Package owner, Class lawfullReq) {
+ TreeIterator<EObject> iterator= owner.eAllContents();
+ while (iterator.hasNext()) {
+ EObject eObject = (EObject) iterator.next();
+ //test if is is a class
+ if (eObject instanceof Class) {
+ Class aclass=(Class)eObject;
+ org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.Lawful lawful= (org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.Lawful)UMLUtil.getStereotypeApplication(aclass, org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.Lawful.class);
+ // test if this is a lawfull req.
+ if( lawful!=null) {
+ //test attributes
+ if(lawful.getProcess().equals(this.processRequirement) && lawful.getDataSubject().equals(this.dataSubject)) {
+ lawfullReq=(Class)lawful.getBase_NamedElement();
+ return lawfullReq;
+ }
+ }
+ }
+
+ }
+ return lawfullReq;
+ }
+
+}
diff --git a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementCreateCommand.java b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementCreateCommand.java
index 46b0aec..d075ffa 100644
--- a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementCreateCommand.java
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementCreateCommand.java
@@ -73,33 +73,6 @@ public class LawfulRequirementCreateCommand extends BasicGDPRRequirementCreateCo
Command traceCommand=PDP4EngTraceabilityFactory.addTraceabilityToLFR(domain, processRequirement, reqStereotypeAppli);
traceCommand.execute();
-
- for (Iterator<Consent> iterator = dataSubject.getGivenConsent().iterator(); iterator.hasNext();) {
- Consent aConsent = (Consent) iterator.next();
- for (Iterator<Purpose> purposeIterator = aConsent.getPurpose().iterator(); purposeIterator.hasNext();) {
- Purpose aPurpose = (Purpose) purposeIterator.next();
- if( aPurpose.getProcesses().contains(this.processRequirement)) {
- System.out.println("Create Lawfull BY CONSENT");
- Class requirementClass=(Class)requirement.createNestedClassifier(reqStereotypeAppli.getId()+".1", UMLPackage.eINSTANCE.getClass_());
- stereotypeApplicationHelper.applyStereotype(requirementClass,org.eclipse.papyrus.sysml14.requirements.RequirementsPackage.eINSTANCE.getRequirement(),null );
- Requirement reqStereotype= (Requirement)UMLUtil.getStereotypeApplication(requirementClass, Requirement.class);
- stereotypeApplicationHelper.applyStereotype(requirementClass,pdp4engReqGDPRPackage.eINSTANCE.getLawfulByConsent(),null );
- org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByConsent lawfulRbyConsent= (org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByConsent)UMLUtil.getStereotypeApplication(requirementClass, org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByConsent.class);
- lawfulRbyConsent.setConsent(aConsent);
- lawfulRbyConsent.setDataSubject(dataSubject);
- lawfulRbyConsent.getPersonalData().addAll(lawfulReq.getPersonalData());
- lawfulRbyConsent.setProcess(this.processRequirement);
- reqStereotype.setText(""+gdprRrequiement.getDescriptionForLawfulByConsent(lawfulRbyConsent));
- reqStereotype.setId(reqStereotypeAppli.getId()+".1");
-
-
- }
-
- }
-
- }
-
-
}
diff --git a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/RequirementTestGeneratorImpl.java b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/RequirementTestGeneratorImpl.java
index 0d805ad..4b9cb8c 100644
--- a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/RequirementTestGeneratorImpl.java
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/RequirementTestGeneratorImpl.java
@@ -1,18 +1,18 @@
/*****************************************************************************
-* 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
-*****************************************************************************/
+ * 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 java.util.HashSet;
@@ -45,7 +45,7 @@ public class RequirementTestGeneratorImpl implements IRequirementGenerator {
protected String prefix="GDPRReq-";
protected Package generatedRequirementPackage=null;
-
+
@Override
public Command generateArticle51a(TransactionalEditingDomain domain, Package owner) {
@@ -201,7 +201,7 @@ public class RequirementTestGeneratorImpl implements IRequirementGenerator {
String id = prefix+index;
Command cmd=new SecuritySafetyRequirementCreateCommand(domain, lookForGeneratedrequirementPackage(owner), id, "",processRequirement, dataSubject);
compoundCommand.append(cmd);
-
+
}
@@ -216,7 +216,7 @@ public class RequirementTestGeneratorImpl implements IRequirementGenerator {
public Command generateArticle51c(TransactionalEditingDomain domain, Package owner) {
// data minimisation
// Create 1 requirement DataMinimization per PR-PD *PersonalData.size()
-
+
CompoundCommand compoundCommand= new CompoundCommand();
Iterator<EObject> iterator=owner.eAllContents();
@@ -238,4 +238,94 @@ public class RequirementTestGeneratorImpl implements IRequirementGenerator {
}
return compoundCommand;
}
+
+ @Override
+ public Command generateArticle61a(TransactionalEditingDomain domain, Package owner) {
+ CompoundCommand compoundCommand= new CompoundCommand();
+ Iterator<EObject> iterator=owner.eAllContents();
+
+ while (iterator.hasNext()) {
+ EObject eObject = (EObject) iterator.next();
+ if( eObject instanceof NamedElement) {
+ NamedElement namedElement= (NamedElement)eObject;
+ ProcessRequirement processRequirement= (ProcessRequirement)UMLUtil.getStereotypeApplication(namedElement, ProcessRequirement.class);
+ if (processRequirement!=null) {
+ HashSet<DataSubject> dataSubjectList=new HashSet<>();
+ for (PersonalData personalData : processRequirement.getPersonaldata()) {
+ dataSubjectList.addAll(personalData.getRelatedTo());
+ }
+ for (DataSubject dataSubject : dataSubjectList) {
+ index++;
+ String id = prefix+index;
+ Command cmd=new LawfulRequirementByConsentCreateCommand(domain, lookForGeneratedrequirementPackage(owner), id, "",processRequirement, dataSubject);
+ compoundCommand.append(cmd);
+ }
+
+
+ }
+ }
+
+ }
+ return compoundCommand;
+ }
+
+ @Override
+ public Command generateArticle61b(TransactionalEditingDomain domain, Package owner) {
+ CompoundCommand compoundCommand= new CompoundCommand();
+ Iterator<EObject> iterator=owner.eAllContents();
+
+ while (iterator.hasNext()) {
+ EObject eObject = (EObject) iterator.next();
+ if( eObject instanceof NamedElement) {
+ NamedElement namedElement= (NamedElement)eObject;
+ ProcessRequirement processRequirement= (ProcessRequirement)UMLUtil.getStereotypeApplication(namedElement, ProcessRequirement.class);
+ if (processRequirement!=null) {
+ HashSet<DataSubject> dataSubjectList=new HashSet<>();
+ for (PersonalData personalData : processRequirement.getPersonaldata()) {
+ dataSubjectList.addAll(personalData.getRelatedTo());
+ }
+ for (DataSubject dataSubject : dataSubjectList) {
+ index++;
+ String id = prefix+index;
+ Command cmd=new LawfulRequirementByContractCreateCommand(domain, lookForGeneratedrequirementPackage(owner), id, "",processRequirement, dataSubject);
+ compoundCommand.append(cmd);
+ }
+
+
+ }
+ }
+
+ }
+ return compoundCommand;
+ }
+
+ @Override
+ public Command generateArticle61c(TransactionalEditingDomain domain, Package owner) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Command generateArticle61d(TransactionalEditingDomain domain, Package owner) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Command generateArticle61e(TransactionalEditingDomain domain, Package owner) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Command generateArticle61f(TransactionalEditingDomain domain, Package owner) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Command generateArticle64(TransactionalEditingDomain domain, Package owner) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git a/plugins/req/org.eclipse.papyrus.pdp4eng.req.metareq/src/org/eclipse/papyrus/pdp4eng/req/metareq/GDPRRequirements.xtend b/plugins/req/org.eclipse.papyrus.pdp4eng.req.metareq/src/org/eclipse/papyrus/pdp4eng/req/metareq/GDPRRequirements.xtend
index 518866a..31b6453 100644
--- a/plugins/req/org.eclipse.papyrus.pdp4eng.req.metareq/src/org/eclipse/papyrus/pdp4eng/req/metareq/GDPRRequirements.xtend
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.metareq/src/org/eclipse/papyrus/pdp4eng/req/metareq/GDPRRequirements.xtend
@@ -25,6 +25,7 @@ import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.StorageLimitation
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.SecuritySafety
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.DataMinimisation
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByConsent
+import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByContract
class GDPRRequirements {
/**
@@ -35,11 +36,6 @@ class GDPRRequirements {
}
- def getDescriptionForLawfulByConsent(LawfulByConsent lawfulByConsent){
- '''Processing "«lawfulByConsent.process.base_NamedElement.name»" shall be lawful if the data subject "«lawfulByConsent.dataSubject.base_NamedElement.name»" has given consent "«lawfulByConsent.consent.base_NamedElement.name»" to the processing of his or her personal data "«getPersonalDataFromProcess(lawfulByConsent)»" for one or more specific purposes «lawfulByConsent.process.contributedTo.base_NamedElement.name»'''
- }
-
-
/**
* get Description for fairly requirements from article5.1
*/
@@ -90,6 +86,20 @@ class GDPRRequirements {
'''Personal Data «getPersonalDataFromProcess(securitySafety)» shall be processed in a manner that ensures appropriate security. '''
}
+ /**
+ * get Description for lawfullByConsent requirements from article6.1.a
+ */
+ def getDescriptionForLawfulByConsent(LawfulByConsent lawfulByConsent){
+ '''Processing "«lawfulByConsent.process.base_NamedElement.name»" shall be lawful if the data subject "«lawfulByConsent.dataSubject.base_NamedElement.name»" has given consent "«lawfulByConsent.consent.base_NamedElement.name»" to the processing of his or her personal data :"«getPersonalDataFromProcess(lawfulByConsent)»" for one or more specific purposes «lawfulByConsent.process.contributedTo.base_NamedElement.name»'''
+ }
+
+ /**
+ * get Description for lawfullByContract requirements from article6.1.b
+ */
+ def getDescriptionForLawfulByConsent(LawfulByContract lawfulByContract){
+ '''Processing "«lawfulByContract.process.base_NamedElement.name»" shall be lawful if processing "«lawfulByContract.process.base_NamedElement.name»" is necessary for the performance of the contract:"«lawfulByContract.contract.base_NamedElement»" to which the data subject:"«lawfulByContract.dataSubject.base_NamedElement.name»" is party or in order to take steps at the request of the data subject prior to entering into a contract'''
+ }
+
def getPersonalDataFromProcess(ProcessPrinciple ProcessPrinciple){
var result = ""
diff --git a/plugins/req/org.eclipse.papyrus.pdp4eng.req.metareq/xtend-gen/org/eclipse/papyrus/pdp4eng/req/metareq/GDPRRequirements.java b/plugins/req/org.eclipse.papyrus.pdp4eng.req.metareq/xtend-gen/org/eclipse/papyrus/pdp4eng/req/metareq/GDPRRequirements.java
index 407d548..f1857f5 100644
--- a/plugins/req/org.eclipse.papyrus.pdp4eng.req.metareq/xtend-gen/org/eclipse/papyrus/pdp4eng/req/metareq/GDPRRequirements.java
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.metareq/xtend-gen/org/eclipse/papyrus/pdp4eng/req/metareq/GDPRRequirements.java
@@ -21,12 +21,14 @@ import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.DataMinimisation;
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.Fairly;
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.Lawful;
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByConsent;
+import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByContract;
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.PersonalDataRequirement;
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.ProcessPrinciple;
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.PurposeLimitation;
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.SecuritySafety;
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.StorageLimitation;
import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.Transparency;
+import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.xtend2.lib.StringConcatenation;
@SuppressWarnings("all")
@@ -52,26 +54,6 @@ public class GDPRRequirements {
return _builder;
}
- public CharSequence getDescriptionForLawfulByConsent(final LawfulByConsent lawfulByConsent) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("Processing \"");
- String _name = lawfulByConsent.getProcess().getBase_NamedElement().getName();
- _builder.append(_name);
- _builder.append("\" shall be lawful if the data subject \"");
- String _name_1 = lawfulByConsent.getDataSubject().getBase_NamedElement().getName();
- _builder.append(_name_1);
- _builder.append("\" has given consent \"");
- String _name_2 = lawfulByConsent.getConsent().getBase_NamedElement().getName();
- _builder.append(_name_2);
- _builder.append("\" to the processing of his or her personal data \"");
- String _personalDataFromProcess = this.getPersonalDataFromProcess(lawfulByConsent);
- _builder.append(_personalDataFromProcess);
- _builder.append("\" for one or more specific purposes ");
- String _name_3 = lawfulByConsent.getProcess().getContributedTo().getBase_NamedElement().getName();
- _builder.append(_name_3);
- return _builder;
- }
-
/**
* get Description for fairly requirements from article5.1
*/
@@ -192,6 +174,50 @@ public class GDPRRequirements {
return _builder;
}
+ /**
+ * get Description for lawfullByConsent requirements from article6.1.a
+ */
+ public CharSequence getDescriptionForLawfulByConsent(final LawfulByConsent lawfulByConsent) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("Processing \"");
+ String _name = lawfulByConsent.getProcess().getBase_NamedElement().getName();
+ _builder.append(_name);
+ _builder.append("\" shall be lawful if the data subject \"");
+ String _name_1 = lawfulByConsent.getDataSubject().getBase_NamedElement().getName();
+ _builder.append(_name_1);
+ _builder.append("\" has given consent \"");
+ String _name_2 = lawfulByConsent.getConsent().getBase_NamedElement().getName();
+ _builder.append(_name_2);
+ _builder.append("\" to the processing of his or her personal data :\"");
+ String _personalDataFromProcess = this.getPersonalDataFromProcess(lawfulByConsent);
+ _builder.append(_personalDataFromProcess);
+ _builder.append("\" for one or more specific purposes ");
+ String _name_3 = lawfulByConsent.getProcess().getContributedTo().getBase_NamedElement().getName();
+ _builder.append(_name_3);
+ return _builder;
+ }
+
+ /**
+ * get Description for lawfullByContract requirements from article6.1.b
+ */
+ public CharSequence getDescriptionForLawfulByConsent(final LawfulByContract lawfulByContract) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("Processing \"");
+ String _name = lawfulByContract.getProcess().getBase_NamedElement().getName();
+ _builder.append(_name);
+ _builder.append("\" shall be lawful if processing \"");
+ String _name_1 = lawfulByContract.getProcess().getBase_NamedElement().getName();
+ _builder.append(_name_1);
+ _builder.append("\" is necessary for the performance of the contract:\"");
+ NamedElement _base_NamedElement = lawfulByContract.getContract().getBase_NamedElement();
+ _builder.append(_base_NamedElement);
+ _builder.append("\" to which the data subject:\"");
+ String _name_2 = lawfulByContract.getDataSubject().getBase_NamedElement().getName();
+ _builder.append(_name_2);
+ _builder.append("\" is party or in order to take steps at the request of the data subject prior to entering into a contract");
+ return _builder;
+ }
+
public String getPersonalDataFromProcess(final ProcessPrinciple ProcessPrinciple) {
String result = "";
EList<PersonalDataRequirement> _personalData = ProcessPrinciple.getPersonalData();
diff --git a/plugins/req/org.eclipse.papyrus.pdp4eng.req.ui/src/org/eclipse/papyrus/pdp4eng/req/ui/GenerateGDPRRequirementHandler.java b/plugins/req/org.eclipse.papyrus.pdp4eng.req.ui/src/org/eclipse/papyrus/pdp4eng/req/ui/GenerateGDPRRequirementHandler.java
index 68d6d2f..1d1bcca 100644
--- a/plugins/req/org.eclipse.papyrus.pdp4eng.req.ui/src/org/eclipse/papyrus/pdp4eng/req/ui/GenerateGDPRRequirementHandler.java
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.ui/src/org/eclipse/papyrus/pdp4eng/req/ui/GenerateGDPRRequirementHandler.java
@@ -42,6 +42,8 @@ public class GenerateGDPRRequirementHandler extends PapyrusAbstractHandler {
transactionalEditingDomain.getCommandStack().execute(generator.generateArticle51d(transactionalEditingDomain, (Package)selectedElement));
transactionalEditingDomain.getCommandStack().execute(generator.generateArticle51e(transactionalEditingDomain, (Package)selectedElement));
transactionalEditingDomain.getCommandStack().execute(generator.generateArticle51f(transactionalEditingDomain, (Package)selectedElement));
+ transactionalEditingDomain.getCommandStack().execute(generator.generateArticle61a(transactionalEditingDomain, (Package)selectedElement));
+ transactionalEditingDomain.getCommandStack().execute(generator.generateArticle61b(transactionalEditingDomain, (Package)selectedElement));
}
return null;

Back to the top