Skip to content

Instantly share code, notes, and snippets.

@smileham
Last active July 31, 2023 14:13
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save smileham/a989e42e8db2d811f5f1427147b39e2e to your computer and use it in GitHub Desktop.
Save smileham/a989e42e8db2d811f5f1427147b39e2e to your computer and use it in GitHub Desktop.
#jarchi
/*
* Change Concept Type
*
* Requires jArchi - https://www.archimatetool.com/blog/2018/07/02/jarchi/
*
* Updated from original to prompt for types
*
* Version 1: First release
* Version 2: Error handling
*
*/
function convertType() {
console.show();
console.clear();
console.log("> Change Concepts");
try{
defaultType = $(selection).first().type;
var concept1 = window.prompt("Convert From Concept Type", defaultType );
if (!concept1) {console.log("> Change Concepts: Cancelled"); return;}
var concept2 = window.prompt("Convert To Concept Type", defaultType );
if (!concept2) {console.log("> Change Concepts: Cancelled"); return;}
var suffix = window.prompt("Include Suffix", "" );
if (suffix==null) {console.log("> Change Concepts: Cancelled"); return;}
if (concept1!=concept2 || suffix!="") {
$(selection).filter(concept1).each(function(e) {
e.concept.type = concept2;
e.fillColor = null;
if (suffix!="") {
e.concept.name = e.concept.name + suffix;
}
});
}
else {
console.error("> Change Concepts: Concepts not changed");
}
}
catch(e)
{
console.error("> Change Concepts:" + e);
}
console.log("> Change Concepts: Done");
}
convertType();
@alef1986
Copy link

alef1986 commented Mar 28, 2020

Thanks a lot for this script!
A question: I've just tried to use it to convert relationship types in a view. Didn't work :( It seems formally the script supports elements, not concepts? Or am I doing it wrong, using wrong naming of relationships? (i.e. "InfluenceRelationship", "RealizationRelationship" - clearly without bracets)

// Edit>
Yes, I did use wrong names! It's "influence-relationship", "realization-relationship". Thanks again, cool thing!

@smileham
Copy link
Author

Hey alef1986

To be honest, I never even thought about trying the script on relationships! Glad it worked though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment