When importing a system model from any external sources (EA, Excel, Rhapsody, ...) as baseline file is created and added to the imported system model. Main intention is to use it on the next occasion when the modle is updated o do a 3-way comparison in order to understand which local modifications have been made. That baseline (model) is typically stored as a separate XMI file and hiddenly attached to the system model as a separate resource. It is not part of the project "resource set", so not loaded into memory by default, its just loaded and used whenever the system modle is updated from the same external resource.
Now there are sometimes strange situations in which the baseline is somewhat "broken" or has issues and it is not that easy as with other models to access or fix it with a script. I had this issue on the table and started to play a bit with a script that at least finds the baseline file and opens it in a notepad. This is easy for local projects, but obviously not for remote / shared one. So for those I simply offered the ability to remove the baseline. And "remove" baseline means, to remove the hidden entry in the model that points to the file. The file is still in the shared collaboration server of course and in principle could be re-added at any time.
Here is the result as a start for your own scripting or simply to get rid of any baseline that does not do its job.
var eaImport = selection && selection[0];
if (!eaImport) throw "Please select an imported system model";
// we need the proxy
var opposites = eaImport.mediniGetOpposites("originalModel");
if (!opposites || opposites.size() != 1) throw "Can't access model proxy";
var proxy = opposites.get(0);
// console.log("Proxy {0}", proxy);
// baselines are contained in the proxy
var contained = proxy.containedElements.toArray();
for (var i=0; i<contained.length; i++) {
var elem = contained[i];
if (elem instanceof Metamodel.projectmodel.PJResource) {
// might be a baseline
var uri = elem.resourceURI;
console.log("{0} {1} => {2}", i, elem.type, uri);
if (uri.indexOf("filestorage:") == 0) {
console.log("Seems to be a remote file");
var remove = confirm("Seems to be a remote baseline, do you want to remove it?");
if (remove) {
proxy.containedElements.remove(elem);
}
} else {
var file = new java.io.File(__filedir + "../../../" + elem.resourceURI);
console.log("Opening {0}...", file.getCanonicalPath());
var rt = java.lang.Runtime.getRuntime();
rt.exec(["notepad", file.getCanonicalPath()]);
}
}
}
undefined
Happy Scripting and Happy Christmas
Jan