blob: 8f7af37006ba8f07178363cfe8e3aa102f3f7c8e [file] [log] [blame]
/*Copyright (c) 2018, MDH */
// All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v2.0
// which accompanies this distribution, and is available at
// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
// EPF - Process -> OpenCert - ARG
pre {
'Running ETL'.println();
//var arg:= new ARG!Case;
var processComponent : LIB!ProcessComponent;
processComponent = LIB!ProcessComponent.allInstances().first();
var id = processComponent.id;
id.println();
}
rule ProcessComponent2Case
transform l : LIB!ProcessComponent
to arg : ARG!Case{
guard : l.process.isTypeOf(LIB!DeliveryProcess)
var str = "Process = " + l.name;
str.println();
for (cp in LIB!CapabilityPattern.allInstances()){
var contClaims : Integer = 0;
var contArgRea : Integer = 0;
var contEvid : Integer = 0;
var contJusti : Integer = 0;
var u = "Capability Pattern: "+cp;
u.println();
arg.argument.add(cp.equivalent());
}
}
/*Transform Capability Pattern to Claim*/
rule CapabilityPattern2Claim
transform cp : LIB!CapabilityPattern
to cpcl : ARG!Claim{
contClaims=contClaims+1;
//Cap. pattern -> Claim
cpcl.name = cp.name;
cpcl.id = "G"+contClaims+".CP"+cp.id;
cpcl.description="Capability Pattern: "+cp.briefDescription;
arg.argument.add(cpcl);
if(cp.breakdownElements.select(ph|ph.isTypeOf(LIB!Phase))<>null){
contArgRea=contArgRea+1;
var arr = new ARG!ArgumentReasoning;
var cpar = new ARG!AssertedInference;
//Argument reasoning over Phases
arr.id="S"+contArgRea+".Ph"+cp.id;
arr.name="Argument over phases P";
arr.description="Argument over phases P";
arg.argument.add(arr);
//Asserted inference links Claim to Argument
cpar.name = 'CP_Arph';
cpar.source.add(cpcl);
cpar.target.add(arr);
arg.argument.add(cpar);
/*Phases -> linked to Capability Pattern*/
for (ph in cp.breakdownElements.select(ph|ph.isTypeOf(LIB!Phase))){
contClaims=contClaims+1;
var phcl = new ARG!Claim;
var arph = new ARG!AssertedInference;
//Phase -> Claim
phcl.name = ph.name;
phcl.id = "G"+contClaims+".Ph"+ph.id;
phcl.description="Phase: "+ph.name;
arg.argument.add(phcl);
//Asserted inference links Argument to Claim
arph.name = 'Arph_Phcl';
arph.source.add(arr);
arph.target.add(phcl);
arg.argument.add(arph);
var ctx = new ARG!InformationElementCitation;
var c = new ARG!AssertedContext;
//Purpose -> Context
var context : String = LIB2!DeliveryProcessDescription.allInstances().first().purpose;
var context2 = context.replaceAll("\\<[^>]*>","");
var context3 = context2.replaceAll("&#xD;","");
var context4 = context3.replaceAll("&#xA;","");
var context5 = context4.replaceAll("&lt;","");
var context6 = context5.trim();
ctx.name= ph.name+"'s context";
ctx.id="C.Ph"+ph.id;
ctx.description=context6;
ctx.type = ARG!InformationElementType#Context;
arg.argument.add(ctx);
//Asserted inference links Claim to Context
c.name = 'Ph_Con';
c.source.add(phcl);
c.target.add(ctx);
arg.argument.add(c);
if(ph.getActivities(ph.breakdownElements)<>null){
contArgRea=contArgRea+1;
var arr = new ARG!ArgumentReasoning;
var phar = new ARG!AssertedInference;
//Argument reasoning over Activities
arr.id="S"+contArgRea+".A"+ph.id;
arr.name="Argument over activities A";
arr.description="Argument over activities A";
arg.argument.add(arr);
//Asserted inference links Claim to Argument
phar.name = 'Ph_Aract';
phar.source.add(phcl);
phar.target.add(arr);
arg.argument.add(phar);
/*Activities -> linked to Phases*/
for(act in ph.getActivities(ph.breakdownElements)){
contClaims=contClaims+1;
var acl = new ARG!Claim;
var aa = new ARG!AssertedInference;
//Activity -> Claim
acl.id="G"+contClaims+".A"+act.id; //act.guid;
acl.name="Activity: "+ act.name; //act.presentationName;
acl.description="Activity: "+ act.name;
arg.argument.add(acl);
//Asserted inference links Claim to Claim
aa.name = 'Aph_Act';
aa.source.add(arr);
aa.target.add(acl);
arg.argument.add(aa);
/*Task Descriptors -> linked to Activity*/
if(act.getTaskDescriptors(act.breakdownElements) <> null){
contArgRea=contArgRea+1;
var arr = new ARG!ArgumentReasoning;
var actar = new ARG!AssertedInference;
//Argument reasoning over Task
arr.id="S"+contArgRea+".T"+act.id;
arr.name="Argument over tasks Td";
arr.description="Argument over tasks Td";
arg.argument.add(arr);
//Asserted inference links Claim to Argument
actar.name = 'Act_Artask';
actar.source.add(acl);
actar.target.add(arr);
arg.argument.add(actar);
for(td in act.getTaskDescriptors(act.breakdownElements)){
contClaims=contClaims+1;
var cltd = new ARG!Claim;
var cxa = new ARG!AssertedInference;
//Task descriptor -> Claim
cltd.id="G"+contClaims+".T"+td.id;
cltd.name="Task: "+td.name;
cltd.description="Task: "+td.briefDescription;
//Asserted inference links Claim to Claim
cxa.name = 'Act_Td';
cxa.source.add(arr);
cxa.target.add(cltd);
arg.argument.add(acl);
arg.argument.add(cxa);
arg.argument.add(cltd);
/*Role Descriptors -> attached to Task Descriptor*/
if(td.getTaskParticipants() <>null){
contArgRea=contArgRea+1;
var ar = new ARG!ArgumentReasoning;
//Argument reasoning over role descriptors
ar.id="S"+contArgRea+".R"+td.id;
ar.name="Argument over role descriptors Rd";
ar.description="Argument over role descriptors Rd";
arg.argument.add(ar);
for(rd in td.getTaskParticipants()){
contClaims=contClaims+1;
var ca = new ARG!Claim;
var x = new ARG!AssertedInference;
//Role descriptor -> Claim
ca.name="Role: "+rd.name;
ca.id="G"+contClaims+".R"+rd.id;
ca.description="Role: "+rd.name + " is certified";
arg.argument.add(ca);
//Asserted Inference links Argument to Claim
x.name = 'Ard_Crd';
x.source.add(ar);
x.target.add(ca);
arg.argument.add(x);
("Role: "+rd.name).println(); // can be removed
//Skills -> Solution/Justification
var skillsOk = rd.getSkills(rd.name);
("skillsOk: "+skillsOk).println();
var sk : String;
for (ski in skillsOk) {
sk = ski.trim();
var justification : Boolean = false;
// already
if (sk.contains("because") or sk.contains("due to") or sk.contains("since") or sk.contains("already")){
contJusti=contJusti+1;
var iec = new ARG!InformationElementCitation;
var y = new ARG!AssertedContext;
//Rationale -> Justification
iec.name= rd.name+"'s justification";
iec.id="J"+contJusti+".R"+rd.id;
iec.description=rd.presentationName + "'s justification: "+sk;
iec.type = ARG!InformationElementType#Justification;
//Asserted Context links Claim to Justification
y.name = 'Crd_Jrd';
y.source.add(ca);
y.target.add(iec);
arg.argument.add(y);
arg.argument.add(iec);
justification = true;
}
if (justification <> true) {
contEvid=contEvid+1;
var iec = new ARG!InformationElementCitation;
var y = new ARG!AssertedEvidence;
var skill : String = sk.firstToLowerCase();
skill.println();
rd.presentationName.println();
//Skill -> Solution
iec.name= rd.name+"'s certification";
iec.id="E"+contEvid+".R"+rd.id;
iec.description=rd.presentationName + "'s certification against "+sk.firstToLowerCase();
iec.type = ARG!InformationElementType#Solution;
//Asserted Evidence links Claim to Solution
y.name = 'Crd_Erd';
y.source.add(ca);
y.target.add(iec);
arg.argument.add(y);
arg.argument.add(iec);
}
}
}
//Asserted Inference links Claim to Argument
var z = new ARG!AssertedInference;
z.name = "Cltd_Ard";
z.source.add(cltd);
z.target.add(ar);
arg.argument.add(z);
}
/* WorkProduct Descriptors -> attached to Task Descriptor */
if(td.getWorkProducts().isEmpty()=false){
contArgRea=contArgRea+1;
var arw = new ARG!ArgumentReasoning;
//Argument Reasoning over work products
arw.name="Argument over work product descriptors Wp";
arw.description="Argument over work product descriptors Wp";
arw.id="S"+contArgRea+".Wp"+td.id;
arg.argument.add(arw);
for(wp in td.getWorkProducts()){
contClaims=contClaims+1;
var clw = new ARG!Claim;
var xw = new ARG!AssertedInference;
//Work product -> Claim
clw.name="Work Product: "+wp.name;
clw.id="G"+contClaims+".Wp"+wp.id;
clw.description="Work Product: "+wp.name + " is planned";
//Asserted Inference links Argument to Claim
xw.name = 'Awp_Cwp';
xw.source.add(arw);
xw.target.add(clw);
//Undeveloped goal
if (ph.superActivities.name.toLowercase.contains("planning")){
clw.toBeSupported = true;
}else{
contEvid=contEvid+1;
var iew = new ARG!InformationElementCitation;
var yw = new ARG!AssertedEvidence;
//Work product -> Solution
iew.name= wp.name+" should be filled-in template";
iew.id="E"+contEvid+".Wp"+wp.id;
iew.description= "Evidence: "+wp.name + " should be filled-in template"; //"E_"+wp.name +
iew.type = ARG!InformationElementType#Solution;
//Asserted Evidence links Claim to Solution
yw.name = 'Cwp_Ewp';
yw.source.add(clw);
yw.target.add(iew);
arg.argument.add(yw);
arg.argument.add(iew);
}
arg.argument.add(xw);
arg.argument.add(clw);
}
//Asserted Inference links Claim to Argument Reasoning
var zw = new ARG!AssertedInference;
zw.name = "Cltd_Awp";
zw.source.add(cltd);
zw.target.add(arw);
arg.argument.add(zw);
}
if(td.Task<>null){
var task = REQ!Task.allInstances.selectOne(task|task.name=td.name);
/*Guideline -> attached to Task Descriptor*/
//if(task.guidelines <> null){
if(task.guidelines.isEmpty()=false){
contArgRea=contArgRea+1;
var aguk = new ARG!ArgumentReasoning;
//Argument Reasoning over guidelines
aguk.name="Argument over guidelines Gu";
aguk.description="Argument over guidelines Gu";
aguk.id="S"+contArgRea+".Gu"+td.id;
//arg.argument.add(aguk);
for(gu in task.guidelines){
contClaims=contClaims+1;
var clgk = new ARG!Claim;
var xgk = new ARG!AssertedInference;
//Asserted inference links Argument to Claim
xgk.name = 'Agu_Cgu';
xgk.source.add(aguk);
xgk.target.add(clgk);
//Guideline -> Claim
clgk.id="G"+contClaims+".Gu"+gu.id;
clgk.name="Guideline: "+gu.name;
//clgk.description="Guideline: "+gu.name + " is planned";
//Undeveloped goal
if (ph.superActivities.name.toLowercase.contains("planning")){
clgk.description="Guideline: "+gu.name + " should be followed according to the template";
clgk.toBeSupported = true;
}else{
clgk.description=gu.name + " is planned";
contEvid=contEvid+1;
var iegk = new ARG!InformationElementCitation;
var ygk = new ARG!AssertedEvidence;
//Guideline -> Solution
iegk.id="E"+contEvid+".Gu"+gu.id;
iegk.name=gu.name+" should be followed according to the template";
iegk.description= gu.name+" should be followed according to the template";
iegk.type = ARG!InformationElementType#Solution;
//Asserted Evidence links Sub-claim to Solution
ygk.name = 'Cgu_Egu';
ygk.source.add(clgk);
ygk.target.add(iegk);
arg.argument.add(ygk);
arg.argument.add(iegk);
}
arg.argument.add(xgk);
arg.argument.add(clgk);
}
//Asserted Inference links Claim to Argument Reasoning
var zgk = new ARG!AssertedInference;
zgk.name = "Cltd_Agu";
zgk.source.add(cltd);
zgk.target.add(aguk);
arg.argument.add(zgk);
arg.argument.add(aguk);
}
/* Checklist -> attached to Task Descriptor */
//if(task.checklists <> null){
if(task.checklists.isEmpty()=false){
//Argument reasoning over checklists
contArgRea=contArgRea+1;
var arc = new ARG!ArgumentReasoning;
arc.id="S"+contArgRea+".Ch"+td.id;
arc.name="Argument over checklists Ch";
arc.description="Argument over checklists Ch";
for(che in task.checklists){
contClaims=contClaims+1;
var cc = new ARG!Claim;
var xc = new ARG!AssertedInference;
//Checklist -> Sub-claim
cc.id="G"+contClaims+".Ch"+che.id;
cc.name="Checklist: "+che.name;
//Asserted inference links Argument to Sub-Claim
xc.name = 'Ach_Cch';
xc.source.add(arc);
xc.target.add(cc);
if (ph.superActivities.name.toLowercase.contains("planning")){
cc.description="Checklist: "+che.name + "should be completed or verified";
cc.toBeSupported = true;
}else{
var icc = new ARG!InformationElementCitation;
var yc = new ARG!AssertedEvidence;
contEvid=contEvid+1;
cc.description=che.briefDescription + "is planned";
//Checklist -> Solution
icc.id="E"+contEvid+".Ch"+che.id;
icc.name= che.name+" should be completed or verified";
icc.description= che.briefDescription;
icc.type = ARG!InformationElementType#Solution;
//Asserted Evidence links Sub-claim to Solution
yc.name = 'Cch_Ech';
yc.source.add(cc);
yc.target.add(icc);
arg.argument.add(yc);
arg.argument.add(icc);
}
arg.argument.add(xc);
arg.argument.add(cc);
}
//Asserted Inference Links Claim to Argument
var zc = new ARG!AssertedInference;
zc.name = "Cltd_Ach";
zc.source.add(cltd);
zc.target.add(arc);
arg.argument.add(zc);
arg.argument.add(arc);
}
/* Example -> attached to Task Descriptor */
//if(task.examples <> null){
if(task.examples.isEmpty()=false){
contArgRea=contArgRea+1;
var are = new ARG!ArgumentReasoning;
//Argument Reasoning over examples
are.id="S"+contArgRea+".Ex"+td.id;
are.name="Argument over examples Ex";
are.description="Argument over examples Ex";
for(exp in task.examples){
contClaims=contClaims+1;
var ce = new ARG!Claim;
var xe = new ARG!AssertedInference;
//Example -> Sub-claim
ce.id="G"+contClaims+".Ex"+exp.id;
ce.name="Example: "+exp.name;
//Asserted Inference links Argument to Sub-Claim
xe.name = 'Aex_Cex';
xe.source.add(are);
xe.target.add(ce);
if (ph.superActivities.name.toLowercase.contains("planning")){
ce.description= "Example: "+exp.name + " example will be used";
ce.toBeSupported = true;
}else{
var iee = new ARG!InformationElementCitation;
var ye = new ARG!AssertedEvidence;
contEvid=contEvid+1;
ce.description=exp.name + " is planned";
//Example -> Solution
iee.id="E"+contEvid+".Ex"+exp.id;
iee.name= exp.name; //+" should be completed or verified";
iee.description= exp.briefDescription + exp.name;
iee.type = ARG!InformationElementType#Solution;
//Asserted Evidence links Sub-claim to Solution
ye.name = 'Cex_Eex';
ye.source.add(ce);
ye.target.add(iee);
arg.argument.add(ye);
arg.argument.add(iee);
}
arg.argument.add(xe);
arg.argument.add(ce);
//arg.argument.add(are);
}
//Asserted Inference links Claim to Argument
var ze = new ARG!AssertedInference;
ze.name = "Cltd_Aex";
ze.source.add(cltd);
ze.target.add(are);
arg.argument.add(ze);
arg.argument.add(are);
}
/* ToolMentor -> attached to Task Descriptor */
if(task.toolMentors.isEmpty()=false){
contArgRea=contArgRea+1;
var art = new ARG!ArgumentReasoning;
//Argument over tool mentors
art.name="Argument over tool mentors Tm";
art.id="S"+contArgRea+".Tm"+td.id;
art.description="Argument over tool mentors Tm";
arg.argument.add(art);
//Asserted Inference links Claim to Argument
var ztm = new ARG!AssertedInference;
ztm.name = "Cltd_Atm";
ztm.source.add(cltd);
ztm.target.add(art);
arg.argument.add(ztm);
for(tm in task.toolMentors){
contClaims=contClaims+1;
var clt = new ARG!Claim;
var iet = new ARG!InformationElementCitation;
var xt = new ARG!AssertedInference;
//Tool mentor -> Claim
clt.id="G"+contClaims+".Tm"+tm.id;
clt.name="Tool Mentor: "+tm.name;
clt.description=tm.name + " is qualified";
//Asserted Inference links Argument to Claim
xt.name = 'Atm_Ctm';
xt.source.add(art);
xt.target.add(clt);
//Tool Qualifications -> Solution/Justification
var q = tm.getToolQual();
if (q.contains("because") or q.contains("due to") or q.contains("since")or q.contains("already")){
contJusti=contJusti+1;
//Rationale -> Justification
iet.id="J"+contJusti+".T"+tm.id;
iet.name= tm.name+"Â’s qualifications";
iet.description=q;
iet.type = ARG!InformationElementType#Justification;
//Asserted Context links Claim to Justification
var yt = new ARG!AssertedContext;
yt.name = 'Ctm_Etm';
yt.source.add(clt);
yt.target.add(iet);
arg.argument.add(iet);
arg.argument.add(yt);
}else{
contEvid=contEvid+1;
//Qualification -> Solution
iet.id="E"+contEvid+".T"+tm.id;
iet.name= tm.name+"Â’s qualifications";
iet.description=q;
iet.type = ARG!InformationElementType#Solution;
//Asserted Evidence links Claim to Solution
var yt = new ARG!AssertedEvidence;
yt.name = 'Ctm_Etm';
yt.source.add(clt);
yt.target.add(iet);
arg.argument.add(iet);
arg.argument.add(yt);
}
arg.argument.add(xt);
arg.argument.add(clt);
}
}
}
}
}
}
}
}
}
}
operation Any getActivities(source : Set(LIB!BreadkDownElement)):Set(LIB!Activity){
return source.select(act|act.isTypeOf(LIB!Activity));
//act.id.println();
}
operation Any getTaskDescriptors(source : Set(LIB!BreadkDownElement)):Set(LIB!TaskDescriptor){
return source.select(td|td.isTypeOf(LIB!TaskDescriptor));
//td.id.println();
}
operation LIB!TaskDescriptor getTaskParticipants():Set(LIB!RoleDescriptor){
var res=new Set(LIB!RoleDescriptor);
// performedPrimarilyBy; additionallyPerformedBy; assistedBy
for(p in self.performedPrimarilyBy){
res.add(LIB!RoleDescriptor.allInstances.selectOne(role|role.id=p.id));
}
for(a in self.additionallyPerformedBy){
res.add(LIB!RoleDescriptor.allInstances.selectOne(role|role.id=a.id));
//var strr3 = "a = " + a;
//strr3.println();
}
for(asi in self.assistedBy){
res.add(LIB!RoleDescriptor.allInstances.selectOne(role|role.id=asi.id));
//var strr4 = "asi = " + asi;
//strr4.println();
}
return res;
}
operation LIB!RoleDescriptor getSkills(name:String):Sequence{
var rolesDescriptions : Sequence = ROL!RoleDescription.allInstances();
var skOk5 : String;
for(r in rolesDescriptions){
var nameRole : String;
nameRole = r.name.substring(0,r.name.indexOf(","));
if (nameRole = name) {
("name: "+name).println();
"ENTRO EN IF".println();
var skOk0 = r.skills.replaceAll("\\<[^>]*>","");
var skOk1 = skOk0.replaceAll("&nbsp;"," ");
var skOk2 = skOk1.replaceAll("&amp;","&");
var skOk3 = skOk2.replaceAll(" ","");
var skOk4 = skOk3.replaceAll("&#xA;","");
skOk5 = skOk4.replaceAll("&#xD;","");
}
}
var splitSkills = skOk5.split(";");
var firstSkill = splitSkills.first();
var skill0 : String;
var skillsOk : Sequence;
if (firstSkill.contains(":")){
skill0 = firstSkill.substring((firstSkill.indexOf(":"))+2);
skillsOk.add(skill0);
splitSkills.remove(firstSkill);
for(x in splitSkills){
skillsOk.add(x);
}
} else {
if(firstSkill.contains("against")){
var skagainst: Sequence = firstSkill.split("against");
skill0 = skagainst.at(1);
skillsOk.add(skill0);
splitSkills.remove(firstSkill);
for(x in splitSkills){
skillsOk.add(x);
}
}
if(firstSkill.contains("over")){
var skover: Sequence = firstSkill.split("over");
skill0 = skover.at(1);
skillsOk.add(skill0);
splitSkills.remove(firstSkill);
for(x in splitSkills){
skillsOk.add(x);
}
}
}
return skillsOk;
}
operation LIB!TaskDescriptor getWorkProducts():Set(LIB!WorkProductDescriptor){
var res=new Set(LIB!WorkProductDescriptor);
// externalInput; optionalInput; mandatoryInput; output
for(ei in self.externalInput){
res.add(LIB!WorkProductDescriptor.allInstances.selectOne(workProduct|workProduct.id=ei));
//var strr6 = "ei = " + ei;
//strr6.println();
}
for(oi in self.optionalInput){
res.add(LIB!WorkProductDescriptor.allInstances.selectOne(workProduct|workProduct.id=oi));
//var strr3 = "oi = " + oi;
//strr3.println();
}
for(mi in self.mandatoryInput){
res.add(LIB!WorkProductDescriptor.allInstances.selectOne(workProduct|workProduct.id=mi));
//var strr4 = "mi = " + mi;
//strr4.println();
}
for(o in self.output){
res.add(LIB!WorkProductDescriptor.allInstances.selectOne(workProduct|workProduct.id=o.id));
//var strr5 = "o = " + o;
//strr5.println();
}
return res;
}
operation REQ!ToolMentor getToolQual():String{
var tools : Sequence(REQ!Tool) = REQ!Tool.allInstances();
var tool : REQ!Tool;
for (t in tools){
var toolMentors = t.toolMentors;
for (tm in toolMentors){
if(tm.id = self.id){
tool = t;
}
}
}
var toolsDescriptions : Sequence = TOOL!ContentDescription.allInstances();
var keyConsiderations : String;
var qualification : String;
for(t in toolsDescriptions){
var nameTool : String;
var idTool : String;
nameTool = t.name.substring(0,t.name.indexOf(","));
idTool = t.name.substring(t.name.indexOf(","));
if ((nameTool = tool.name)or(idTool = tool.id)) {
var q1 = t.keyConsiderations.replaceAll("\\<[^>]*>","");
var q2 = q1.replaceAll("&nbsp;"," ");
var q3 = q2.replaceAll("&amp;","&");
qualification = q3.replaceAll("&#xD;","");
}
}
return qualification;
}
post{
"End of transformation".println();
}