jArchi Script not working

Started by wnad, February 24, 2022, 11:56:42 AM

Previous topic - Next topic

wnad

after updating my version

one of  script doesn't work anymore

console.show();
console.clear();
 
var el_selection = selection.filter("element");
 
if(el_selection.size() < 2) {
  window.alert("You have to select at least two elements to run this script. Note: merging relationships is not supported for the moment.");
  exit();
}
 
var list = "Which element do you want to keep (enter its index)?";
var index = 1;
 
el_selection.each(function(o) {
  list += "\n  ("+index+") "+o.name;
  index++
})
var answer = window.prompt(list, "1");
if(answer) {
  var relaxed = window.confirm('By default, only documentation and properties of the target element are saved (those of merged elements are cleared). Click Ok for this behavior or Cancel if you want a "strict" mode where they are copied into target element.');
 
  var merge_target = el_selection.get(answer-1);
  var to_be_deleted = $("#null");
  el_selection.not($(merge_target)).each(function(o) {
    console.log('Merging "', o.name, '" into "', merge_target.name, '"');
    // We don't want to delete while iterating on the collection, so create
    // another collection containing the element (not object) to delete
    to_be_deleted.add(concept(o));
    if (relaxed) {
      removeDocAndProps(concept(o));
    }
    concept(merge_target).merge(concept(o));
  });
 
  // Deletion loop
  to_be_deleted.each(function(e) {
    e.delete();
  });
} else {
  console.log("Merge cancelled");
}
function concept(o) {
  if(o.concept)
    return o.concept;
  else
    return o;
}
 
function removeDocAndProps(c) {
  c.documentation = "";
  c.prop().forEach(function(p) {
    c.removeProp(p);
  });
}

what is the problem
thanks

Jean-Baptiste Sarrodie

Hi,

Can you try to norrow it down a little bit? Can you share the error message you have on the script console and/or on the Archi error log?

Which versions (old and new) of both Archi and jArchi do/did you use?

There should not be any differences, as there have been no breaking changes in the jArchi API for a while.

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

#2
(Topic moved to jArchi forum and title changed from "archi 4.9" to something more descriptive)

Please make sure you are using Archi 4.9.2 and jArchi 1.2.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

wnad

I use archi 4.9.2 but I don't find how to see my jarchi version

Phil Beauvoir

Quote from: wnad on February 28, 2022, 10:53:41 AMI use archi 4.9.2 but I don't find how to see my jarchi version

Go to Help -> Manage Plug-ins... menu item.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

wnad