Last active
October 8, 2022 14:41
-
-
Save nfigay/6896ff5da8a6f7555854d7d87959bf4d to your computer and use it in GitHub Desktop.
This #jArchi script aims at create the table of allowed relationships in ArchiMate, as implemented by Archi, as a excel table.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Archi Relationship Array Builder script | |
*/ | |
console.log("Archi Relationship Array Builder"); | |
var ArchiMateObjects=["Resource","Capability", "Value_Stream","Course_Of_Action","Business_Actor","Business_Role", "Business_Collaboration", "Business_Interface", "Business_Process", "Business_Function", "Business_Interaction", "Business_Event", "Business_Service", "Business_Object", "Contract", "Representation", "Product", "Application_Component", "Application_Collaboration", "Application_Interface", "Application_Function", "Application_Interaction", "Application_Process", "Application_Event","Application_Service", "Data_Object", "Node", "Device", "System_Software","Technology_Collaboration", "Technology_Interface", "Path","Communication_Network", "Technology_Function", "Technology_Process", "Technology_Interaction", "Technology_Event", "Technology_Service", "Artifact", "Equipment", "Facility", "Distribution_Network", "Material", "Stakeholder", "Driver", "Assessment", "Goal", "Outcome", "Principle", "Requirement", "Constraint", "Meaning", "Value", "Work_Package", "Deliverable", "Implementation_Event", "Plateau", "Gap", "Location", "Grouping", "Junction"]; | |
var ArchiMateRelationNames =[ "Access", "Composition", "Flow", "Aggregation", "Assignment", "Influence", "Association", "Realization", "Specialization", "Triggering", "Serving"]; | |
var ArchiMateRelationIDs= [ "a","c","f","g","i","n","o","r","s","t","v"]; | |
var ArchiMateRelations=[ | |
["Resource","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Capability","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Value_Stream","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Course_Of_Action","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Business_Actor","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Business_Role","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Business_Collaboration","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Business_Interface","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Business_Process","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Business_Function","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Business_Interaction","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Business_Event","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Business_Service","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Business_Object","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Contract","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Representation","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Product","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Application_Component","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Application_Collaboration","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Application_Interface","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Application_Function","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Application_Interaction","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Application_Process","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Application_Event","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Application_Service","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Data_Object","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Node","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Device","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["System_Software","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Technology_Collaboration","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Technology_Interface","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Path","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Communication_Network","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Technology_Function","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Technology_Process","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Technology_Interaction","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Technology_Event","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Technology_Service","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Artifact","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Equipment","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Facility","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Distribution_Network","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Material","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Stakeholder","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Driver","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Assessment","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Goal","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Outcome","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Principle","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Requirement","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Constraint","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Meaning","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Value","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["WorkPackage","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Deliverable","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Implementation_Event","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Plateau","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Gap","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Location","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""] , | |
["Grouping","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""], | |
["Junction","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""] | |
]; | |
const RelationStr=JSON.stringify(ArchiMateRelations); | |
var ArchiMateAccessRelation= JSON.parse(RelationStr); | |
var ArchiMateCompositionRelation= JSON.parse(RelationStr); | |
var ArchiMateFlowRelation= JSON.parse(RelationStr); | |
var ArchiMateAggregationRelation= JSON.parse(RelationStr); | |
var ArchiMateAssignmentRelation= JSON.parse(RelationStr); | |
var ArchiMateInfluenceRelation= JSON.parse(RelationStr); | |
var ArchiMateAssociationRelation= JSON.parse(RelationStr); | |
var ArchiMateRealizationRelation= JSON.parse(RelationStr); | |
var ArchiMateSpecializationRelation= JSON.parse(RelationStr); | |
var ArchiMateTriggeringRelation= JSON.parse(RelationStr); | |
var ArchiMateServiceRelation= JSON.parse(RelationStr); | |
$.model.create("myModel").setAsCurrent(); | |
var myElement; | |
var myN=["001", "002"]; | |
var myRelation; | |
ArchiMateObjects.forEach((item,index) => { | |
myN.forEach(n =>{ | |
myElement = item+"_"+ n; | |
var rep = /_/gi; | |
var element = model.createElement(item.toLowerCase().replace(rep, "-"), myElement.toLowerCase()); | |
}) | |
}) | |
ArchiMateRelationNames.forEach((relation,relationIndex) => { | |
myRelation=relation.toLowerCase()+"-relationship"; | |
ArchiMateObjects.forEach((source, sourceIndex) =>{ | |
ArchiMateRelations[sourceIndex][0]=source; | |
ArchiMateAccessRelation[sourceIndex][0]=source; | |
ArchiMateCompositionRelation[sourceIndex][0]=source; | |
ArchiMateFlowRelation[sourceIndex][0]=source; | |
ArchiMateAggregationRelation[sourceIndex][0]=source; | |
ArchiMateAssignmentRelation[sourceIndex][0]=source; | |
ArchiMateInfluenceRelation[sourceIndex][0]=source; | |
ArchiMateAssociationRelation[sourceIndex][0]=source; | |
ArchiMateRealizationRelation[sourceIndex][0]=source; | |
ArchiMateSpecializationRelation[sourceIndex][0]=source; | |
ArchiMateTriggeringRelation[sourceIndex][0]=source; | |
ArchiMateServiceRelation[sourceIndex][0]=source; | |
myElementLineName = source+"_001"; myElementLine="."+myElementLineName.toLowerCase(); | |
var elementSource = $(myElementLine); | |
ArchiMateObjects.forEach((target, targetIndex) =>{ | |
columnIndex=targetIndex +1; | |
myElementColumnName = target+"_002"; myElementColumn="."+myElementColumnName.toLowerCase(); | |
var elementTarget = $(myElementColumn); | |
var allowed = $.model.isAllowedRelationship(myRelation,elementSource[0].type ,elementTarget[0].type); | |
switch(ArchiMateRelationIDs[relationIndex]) { | |
case "a": ArchiMateAccessRelation[sourceIndex][columnIndex]=Number(Boolean(allowed));break; | |
case "c": ArchiMateCompositionRelation[sourceIndex][columnIndex]=Number(Boolean(allowed));break; | |
case "f": ArchiMateFlowRelation[sourceIndex][columnIndex]=Number(Boolean(allowed));break; | |
case "g": ArchiMateAggregationRelation[sourceIndex][columnIndex]=Number(Boolean(allowed));break; | |
case "i": ArchiMateAssignmentRelation[sourceIndex][columnIndex]=Number(Boolean(allowed));break; | |
case "n": ArchiMateInfluenceRelation[sourceIndex][columnIndex]=Number(Boolean(allowed));break; | |
case "o": ArchiMateAssociationRelation[sourceIndex][columnIndex]=Number(Boolean(allowed));break; | |
case "r": ArchiMateRealizationRelation[sourceIndex][columnIndex]=Number(Boolean(allowed));break; | |
case "s": ArchiMateSpecializationRelation[sourceIndex][columnIndex]=Number(Boolean(allowed));break; | |
case "t": ArchiMateTriggeringRelation[sourceIndex][columnIndex]=Number(Boolean(allowed));break; | |
case "v": ArchiMateServiceRelation[sourceIndex][columnIndex]=Number(Boolean(allowed));break; | |
} | |
if (allowed){ArchiMateRelations[sourceIndex][columnIndex]+=ArchiMateRelationIDs[relationIndex]; | |
} | |
}) | |
}) | |
}) | |
var rep1 = /,/gi; | |
var rep2 = /\[/gi; | |
var rep3 = /\]\]/gi; | |
var rep4 = /\]\;/gi; | |
var rep5 = /\]/gi; | |
var rep6 = /\"/gi; | |
var FileWriter=Java.type("java.io.FileWriter"); | |
function ArrayToCSV(Tableau, Relation){ | |
var fileName = window.promptSaveFile( { title: "Export CSV File with allowed"+Relation , filterExtensions: [ "*.csv" ], fileName: "Archi Allowed "+Relation+" Table.csv" } ); | |
if(fileName) { | |
var fw = new FileWriter(fileName); | |
fw.write("From/To;"); | |
fw.write (JSON.stringify(ArchiMateObjects).replace(rep1, ";").replace(rep2,"").replace(rep4,"\n").replace(rep5,"").replace(rep6,"")); | |
fw.write("\n"); | |
fw.write (JSON.stringify(Tableau).replace(rep1, ";").replace(rep2,"").replace(rep3,"]").replace(rep4,"\n").replace(rep5,"").replace(rep6,"")); | |
fw.close(); | |
} | |
} | |
ArrayToCSV(ArchiMateRelations, "Relations"); | |
ArrayToCSV(ArchiMateAccessRelation, "Access"); | |
ArrayToCSV(ArchiMateCompositionRelation, "Composition"); | |
ArrayToCSV(ArchiMateFlowRelation, "Flow"); | |
ArrayToCSV(ArchiMateAggregationRelation, "Aggregation"); | |
ArrayToCSV(ArchiMateAssignmentRelation, "Assignment"); | |
ArrayToCSV(ArchiMateInfluenceRelation, "Influence"); | |
ArrayToCSV(ArchiMateAssociationRelation, "Association"); | |
ArrayToCSV(ArchiMateRealizationRelation, "Realization"); | |
ArrayToCSV(ArchiMateSpecializationRelation, "Specialization"); | |
ArrayToCSV(ArchiMateTriggeringRelation, "Triggering"); | |
ArrayToCSV(ArchiMateServiceRelation, "Service"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment