Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2021-05-19 13:45:02 +0000
committerptessier2021-05-19 13:45:02 +0000
commit3e6143d585d1828b19bbc8da9fc3689b7a7c3d85 (patch)
treef82d46a6cfc55979e0b5e74d59f1cfad2382a85d
parent70902137a256c0e118a045e5812a32e0a13fb307 (diff)
downloadorg.eclipse.papyrus-privacydesigner-3e6143d585d1828b19bbc8da9fc3689b7a7c3d85.tar.gz
org.eclipse.papyrus-privacydesigner-3e6143d585d1828b19bbc8da9fc3689b7a7c3d85.tar.xz
org.eclipse.papyrus-privacydesigner-3e6143d585d1828b19bbc8da9fc3689b7a7c3d85.zip
Bug 573641 - [PrivacyDesigner] choose article to generate when a process
has consent , contract etc... Change-Id: Iabcf2b3ab865ee58379e68d397bd1f59c2eb0bca Signed-off-by: ptessier <Patrick.Tessier@cea.fr>
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/.settings/org.eclipse.jdt.core.prefs1
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/META-INF/MANIFEST.MF7
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/build.properties3
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/papyrus/pdp4eng/req/gdprananalysis/api/IRequirementGenerator.java1
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/papyrus/pdp4eng/req/gdprananalysis/api/RequirementGenerator.java5
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementByVitalInterestCreateCommand.java2
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/RequirementTestGeneratorImpl.java30
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/WarnLawfulRequirementCommand.java187
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/ui/ChooseArticleToGenerate.java109
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.ui/src/org/eclipse/papyrus/pdp4eng/req/ui/GenerateGDPRRequirementHandler.java23
-rw-r--r--plugins/req/org.eclipse.papyrus.pdp4eng.req.ui/src/org/eclipse/papyrus/pdp4eng/req/ui/view/RequirementView.java9
11 files changed, 372 insertions, 5 deletions
diff --git a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/.settings/org.eclipse.jdt.core.prefs b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/.settings/org.eclipse.jdt.core.prefs
index 0c68a61..9f6ece8 100644
--- a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/.settings/org.eclipse.jdt.core.prefs
@@ -4,4 +4,5 @@ org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
diff --git a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/META-INF/MANIFEST.MF b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/META-INF/MANIFEST.MF
index e66ba32..35a1b36 100644
--- a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/META-INF/MANIFEST.MF
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/META-INF/MANIFEST.MF
@@ -6,14 +6,17 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: %providerName
Automatic-Module-Name: org.eclipse.papyrus.pdp4eng.req.gdprananalysis
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Require-Bundle: org.eclipse.papyrus.requirements.sysml14.assistant.commands;bundle-version="[0.8.0,1.0.0)",
+Require-Bundle: org.eclipse.ui;bundle-version="3.117.0",
+ org.eclipse.papyrus.requirements.sysml14.assistant.commands;bundle-version="[0.8.0,1.0.0)",
org.eclipse.papyrus.requirements.sysml14.common;bundle-version="[0.7.0,1.0.0)",
org.eclipse.emf.transaction;bundle-version="[1.9.1,2.0.0)",
org.eclipse.uml2.uml;bundle-version="[5.4.0,6.0.0)",
org.eclipse.papyrus.pdp4eng.req.profile;bundle-version="[1.0.0,2.0.0)",
org.eclipse.papyrus.sysml14;bundle-version="[1.3.0,2.0.0)",
org.eclipse.papyrus.pdp4eng.req.metareq;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.papyrus.requirements.sysml14.traceability.commands
+ org.eclipse.papyrus.requirements.sysml14.traceability.commands,
+ org.eclipse.ui.ide;bundle-version="3.17.100",
+ org.eclipse.swt;bundle-version="3.114.100"
Export-Package: org.eclipse.papyrus.pdp4eng.req.gdprananalysis.api
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
diff --git a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/build.properties b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/build.properties
index 597a1cc..f7a99d3 100644
--- a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/build.properties
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/build.properties
@@ -2,4 +2,5 @@ source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
- build.properties
+ build.properties,\
+ plugin.properties
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 0318ca6..86f0023 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
@@ -38,6 +38,7 @@ public interface IRequirementGenerator {
public Command generateArticle51f(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Package owner);
//article 6
+ public Command warnAboutArticle6(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Package owner);
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);
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 a5caa63..c5296da 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
@@ -89,6 +89,11 @@ public class RequirementGenerator implements IRequirementGenerator {
return generatorImpl.generateArticle64(domain, owner);
}
+ @Override
+ public Command warnAboutArticle6(TransactionalEditingDomain domain, Package owner) {
+ return generatorImpl.warnAboutArticle6(domain, owner);
+ }
+
}
diff --git a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementByVitalInterestCreateCommand.java b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementByVitalInterestCreateCommand.java
index d61d91c..2e1fa4b 100644
--- a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementByVitalInterestCreateCommand.java
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/LawfulRequirementByVitalInterestCreateCommand.java
@@ -64,7 +64,7 @@ public class LawfulRequirementByVitalInterestCreateCommand extends AbstractLawfu
@Override
protected Lawful applyStereotype(StereotypeApplicationHelper stereotypeApplicationHelper, Class requirementClass) {
- stereotypeApplicationHelper.applyStereotype(requirementClass, pdp4engReqGDPRPackage.eINSTANCE.getLawfulByLegitimateInterest(),null);
+ stereotypeApplicationHelper.applyStereotype(requirementClass, pdp4engReqGDPRPackage.eINSTANCE.getLawfulByVitalInterest(),null);
return UMLUtil.getStereotypeApplication(requirementClass, org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.LawfulByVitalInterest.class);
}
} \ No newline at end of file
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 acb4a30..78d9f7e 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
@@ -448,4 +448,34 @@ public class RequirementTestGeneratorImpl implements IRequirementGenerator {
}
return compoundCommand;
}
+
+ @Override
+ public Command warnAboutArticle6(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 WarnLawfulRequirementCommand(domain, lookForGeneratedrequirementPackage(owner), id, "",processRequirement, dataSubject);
+ compoundCommand.append(cmd);
+ }
+
+
+ }
+ }
+
+ }
+ return compoundCommand;
+ }
}
diff --git a/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/WarnLawfulRequirementCommand.java b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/WarnLawfulRequirementCommand.java
new file mode 100644
index 0000000..75d0dd7
--- /dev/null
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/WarnLawfulRequirementCommand.java
@@ -0,0 +1,187 @@
+/*****************************************************************************
+ * 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
+ *****************************************************************************/
+package org.eclipse.pdp4eng.req.gdprananalysis.internal;
+
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.LegalObligation;
+import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.LegitimateInterest;
+import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.Pdp4engCommonGDPRPackage;
+import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.PublicInterest;
+import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.VitalInterest;
+import org.eclipse.papyrus.pdp4eng.req.metareq.GDPRRequirements;
+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.pdp4eng.req.gdprananalysis.internal.ui.ChooseArticleToGenerate;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.util.UMLUtil;
+import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper;
+
+/**
+ * Command for the article 6.4
+ *
+ */
+public class WarnLawfulRequirementCommand extends BasicGDPRRequirementCreateCommand {
+
+ private DataSubject dataSubject;
+ public WarnLawfulRequirementCommand(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);
+ if(processRequirement.getContributedTo().getConsent()!=null) {
+ return;
+ }
+ if( processRequirement.getPerformAContract()!=null) {
+ return;
+ }
+ if( processRequirement.getNeededForLegalObligation()!=null) {
+ return;
+ }
+ if( processRequirement.getNeededForLegimateInterest()!=null) {
+ return;
+ }
+ if( processRequirement.getNeededForPublicInterest()!=null) {
+ return;
+ }
+ if( processRequirement.getNeededForVitalInterest()!=null) {
+ return;
+ }
+ //propose a popup
+ ChooseArticleToGenerate chooseArticleToGenerate = new ChooseArticleToGenerate();
+ String requirementType=chooseArticleToGenerate.launchWindow(processRequirement.getBase_NamedElement().getName());
+ System.err.println(requirementType);
+ if( requirementType.equals(ChooseArticleToGenerate.CONSENT)) {
+ //create a consent
+ Class createdClass=owner.createOwnedClass(ChooseArticleToGenerate.CONSENT, false);
+ stereotypeApplicationHelper.applyStereotype(createdClass,Pdp4engCommonGDPRPackage.eINSTANCE.getConsent(),null );
+ Consent apliedStereotype= (Consent)UMLUtil.getStereotypeApplication(createdClass, Consent.class);
+ apliedStereotype.getPurpose().add(processRequirement.getContributedTo());
+ apliedStereotype.setDatasubject(this.dataSubject);
+
+ }
+ if( requirementType.equals(ChooseArticleToGenerate.CONTRACT)) {
+ //create a contract
+ Class createdClass=owner.createOwnedClass(ChooseArticleToGenerate.CONTRACT, false);
+ stereotypeApplicationHelper.applyStereotype(createdClass,Pdp4engCommonGDPRPackage.eINSTANCE.getContract(),null );
+ Contract apliedStereotype= (Contract)UMLUtil.getStereotypeApplication(createdClass, Contract.class);
+ processRequirement.setPerformAContract(apliedStereotype);
+ apliedStereotype.setDatasubject(this.dataSubject);
+ }
+ if( requirementType.equals(ChooseArticleToGenerate.LEGAL_OBLIGATION)) {
+
+ Class createdClass=owner.createOwnedClass(ChooseArticleToGenerate.LEGAL_OBLIGATION, false);
+ stereotypeApplicationHelper.applyStereotype(createdClass,Pdp4engCommonGDPRPackage.eINSTANCE.getLegalObligation(),null );
+ LegalObligation apliedStereotype= (LegalObligation)UMLUtil.getStereotypeApplication(createdClass, LegalObligation.class);
+ processRequirement.setNeededForLegalObligation(apliedStereotype);
+ }
+ if( requirementType.equals(ChooseArticleToGenerate.LEGITIMATE_INTEREST)) {
+ Class createdClass=owner.createOwnedClass(ChooseArticleToGenerate.LEGITIMATE_INTEREST, false);
+ stereotypeApplicationHelper.applyStereotype(createdClass,Pdp4engCommonGDPRPackage.eINSTANCE.getLegitimateInterest(),null );
+ LegitimateInterest apliedStereotype= (LegitimateInterest)UMLUtil.getStereotypeApplication(createdClass, LegitimateInterest.class);
+ processRequirement.setNeededForLegimateInterest(apliedStereotype);
+ }
+ if( requirementType.equals(ChooseArticleToGenerate.PUBLIC_INTEREST)) {
+ Class createdClass=owner.createOwnedClass(ChooseArticleToGenerate.PUBLIC_INTEREST, false);
+ stereotypeApplicationHelper.applyStereotype(createdClass,Pdp4engCommonGDPRPackage.eINSTANCE.getPublicInterest(),null );
+ PublicInterest apliedStereotype= (PublicInterest)UMLUtil.getStereotypeApplication(createdClass, PublicInterest.class);
+ processRequirement.setNeededForPublicInterest(apliedStereotype);
+ }
+ if( requirementType.equals(ChooseArticleToGenerate.VITAL_INTEREST)) {
+ Class createdClass=owner.createOwnedClass(ChooseArticleToGenerate.VITAL_INTEREST, false);
+ stereotypeApplicationHelper.applyStereotype(createdClass,Pdp4engCommonGDPRPackage.eINSTANCE.getVitalInterest(),null );
+ VitalInterest apliedStereotype= (VitalInterest)UMLUtil.getStereotypeApplication(createdClass, VitalInterest.class);
+ processRequirement.setNeededForVitalInterest(apliedStereotype);
+ }
+ }
+
+ /**
+ * 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/ui/ChooseArticleToGenerate.java b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/ui/ChooseArticleToGenerate.java
new file mode 100644
index 0000000..8c73aa3
--- /dev/null
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.gdprananalysis/src/org/eclipse/pdp4eng/req/gdprananalysis/internal/ui/ChooseArticleToGenerate.java
@@ -0,0 +1,109 @@
+/**
+ * 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
+ *
+ */
+package org.eclipse.pdp4eng.req.gdprananalysis.internal.ui;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+public class ChooseArticleToGenerate {
+
+ private String question= "The process has no consent, contract, no legal obligation no legitmate interest," //$NON-NLS-1$
+ + " no vital interest and no public interest.\n Which requirement would you like to generate?"; //$NON-NLS-1$
+ public String[] requirementTypeText= {
+ "Consent (Article 6.1.a)", //$NON-NLS-1$
+ "Contract (Arcticle 6.1.b)", //$NON-NLS-1$
+ "Legal Obligation (Article 6.1.c)", //$NON-NLS-1$
+ "Vital Interest (Article 6.1.d)", //$NON-NLS-1$
+ "Public Interest (Article 6.1.e)", //$NON-NLS-1$
+ "Legitimate Interest (Article 6.1.f)", //$NON-NLS-1$
+ "Nothing, Safeguard (Article 6.4)"}; //$NON-NLS-1$
+
+
+ public static String CONSENT="CONSENT"; //$NON-NLS-1$
+ public static String CONTRACT="CONTRACT"; //$NON-NLS-1$
+ public static String LEGAL_OBLIGATION="LEGAL_OBLIGATION"; //$NON-NLS-1$
+ public static String VITAL_INTEREST="VITAL_INTEREST"; //$NON-NLS-1$
+ public static String PUBLIC_INTEREST="PUBLIC_INTEREST"; //$NON-NLS-1$
+ public static String LEGITIMATE_INTEREST="LEGITIMATE_INTEREST"; //$NON-NLS-1$
+ public static String SAFEGUARD="SAFEGUARD"; //$NON-NLS-1$
+ public static String[] requirementType= {
+ CONSENT,
+ CONTRACT,
+ LEGAL_OBLIGATION,
+ VITAL_INTEREST,
+ PUBLIC_INTEREST,
+ LEGITIMATE_INTEREST,
+ SAFEGUARD};
+ public int selection=6;
+ public String launchWindow(String processName) {
+ final Display display = Display.getDefault();
+ Shell shell = new Shell(display);
+ shell.setText("Choose Article to Generate"); //$NON-NLS-1$
+ shell.pack();
+ Label label= new Label(shell, SWT.NONE);
+ label.setText(processName +": "+question); //$NON-NLS-1$
+ label.setBounds(10,5,700,30);
+ Button[] radios = new Button[7];
+
+ for(int i=0; i<7; i++) {
+ radios[i] = new Button(shell, SWT.RADIO);
+ radios[i].setSelection(false);
+ radios[i].setText(requirementTypeText[i]);
+ radios[i].setBounds(10, 40+(i*25), 200, 30);
+ }
+ radios[6].setSelection(true);
+ Button ok = new Button(shell, SWT.PUSH);
+ ok.setText("OK"); //$NON-NLS-1$
+ ok.setBounds(150, 240, 300,30);
+ ok.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ switch (e.type) {
+ case SWT.Selection:
+ //look for selection
+ System.out.println("Button pressed"); //$NON-NLS-1$
+ for(int i=0; i<7; i++) {
+ if( radios[i].getSelection()==true) {
+ selection=i;
+ }
+ }
+ shell.dispose();
+ break;
+ }
+ }
+ });
+
+ Label phantomlabel= new Label(shell, SWT.NONE);
+ phantomlabel.setBounds(150,270,200,30);
+ shell.open();
+ shell.pack();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ return requirementType[selection];
+ }
+
+ public static void main(String[] args) {
+ ChooseArticleToGenerate articleToGenerate= new ChooseArticleToGenerate();
+ articleToGenerate.launchWindow( "test"); //$NON-NLS-1$
+ }
+} \ No newline at end of file
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 3798d9a..4c291f5 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
@@ -16,14 +16,21 @@
*/
package org.eclipse.papyrus.pdp4eng.req.ui;
+import java.util.Iterator;
+
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
import org.eclipse.papyrus.pdp4eng.req.gdprananalysis.api.IRequirementGenerator;
import org.eclipse.papyrus.pdp4eng.req.gdprananalysis.api.RequirementGenerator;
import org.eclipse.papyrus.pdp4eng.req.profile.constraints.TraceabilityIndexer;
+import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.GeneratedRequirements;
import org.eclipse.papyrus.requirements.sysml14.common.PapyrusAbstractHandler;
import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.util.UMLUtil;
/**
* Executes the creation of a new SysML requirement based on the Papyrus Req
* preferences page.
@@ -36,6 +43,8 @@ public class GenerateGDPRRequirementHandler extends PapyrusAbstractHandler {
if (selectedElement != null) {
IRequirementGenerator generator= new RequirementGenerator();
TraceabilityIndexer.getInstance().loadTraceability((Package)selectedElement);
+ transactionalEditingDomain.getCommandStack().execute(org.eclipse.emf.edit.command.DeleteCommand.create(transactionalEditingDomain, (lookForGeneratedrequirementPackage((Package)selectedElement)).getPackagedElements()));
+ transactionalEditingDomain.getCommandStack().execute(generator.warnAboutArticle6(transactionalEditingDomain, (Package)selectedElement));
transactionalEditingDomain.getCommandStack().execute(generator.generateArticle51a(transactionalEditingDomain, (Package)selectedElement));
transactionalEditingDomain.getCommandStack().execute(generator.generateArticle51b(transactionalEditingDomain, (Package)selectedElement));
transactionalEditingDomain.getCommandStack().execute(generator.generateArticle51c(transactionalEditingDomain, (Package)selectedElement));
@@ -54,6 +63,20 @@ public class GenerateGDPRRequirementHandler extends PapyrusAbstractHandler {
return null;
}
+ protected Package lookForGeneratedrequirementPackage(Package owner) {
+ Iterator<EObject> iterator=owner.eAllContents();
+ while (iterator.hasNext()) {
+ EObject eObject = (EObject) iterator.next();
+ if( eObject instanceof Package) {
+ NamedElement namedElement= (NamedElement)eObject;
+ GeneratedRequirements generatedRequirements= (GeneratedRequirements)UMLUtil.getStereotypeApplication(namedElement, GeneratedRequirements.class);
+ if (generatedRequirements!=null) {
+ return (Package) namedElement;
+ }
+ }
+ }
+ return null;
+ }
/**
*
* @see org.eclipse.core.commands.AbstractHandler#isEnabled()
diff --git a/plugins/req/org.eclipse.papyrus.pdp4eng.req.ui/src/org/eclipse/papyrus/pdp4eng/req/ui/view/RequirementView.java b/plugins/req/org.eclipse.papyrus.pdp4eng.req.ui/src/org/eclipse/papyrus/pdp4eng/req/ui/view/RequirementView.java
index 291e447..b85f61a 100644
--- a/plugins/req/org.eclipse.papyrus.pdp4eng.req.ui/src/org/eclipse/papyrus/pdp4eng/req/ui/view/RequirementView.java
+++ b/plugins/req/org.eclipse.papyrus.pdp4eng.req.ui/src/org/eclipse/papyrus/pdp4eng/req/ui/view/RequirementView.java
@@ -65,6 +65,7 @@ public class RequirementView extends ViewPart implements ITabbedPropertySheetPag
// list of stereotype to filter
private ArrayList<Class<?>> steretotypeFilter = new ArrayList<>();
private List<IPropertySheetPage> propertySheetPages = new ArrayList<>();
+ private ISelectionListener mylistener;
private static FontData[] getModifiedFontData(FontData[] originalData, int additionalStyle) {
FontData[] styleData = new FontData[originalData.length];
@@ -128,7 +129,7 @@ public class RequirementView extends ViewPart implements ITabbedPropertySheetPag
// used to synchronize the selection on this view
getSite().setSelectionProvider(viewer);
- ISelectionListener mylistener = new ISelectionListener() {
+ mylistener = new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection) {
if (sourcepart != RequirementView.this && selection instanceof IStructuredSelection) {
@@ -140,6 +141,12 @@ public class RequirementView extends ViewPart implements ITabbedPropertySheetPag
}
+
+ @Override
+ public void dispose() {
+ getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(mylistener);
+ super.dispose();
+ }
private Listener makeTreeItemMultiline() {
// this code comes from eclipse in oder to display multi line in a tree
Listener paintListener = new Listener() {

Back to the top