Closed Phillipus closed 5 months ago
Good.
Maybe a better name for the function should be: model.merge(otherModelObject, update, updateAll)
This would be aligned with current element.merge()
and relation.merge()
.
Note that this uses a model object and not a path, so the user has to first load the model with $.model.load(path)
(of course we could provide an alternative function which takes a path as input and load it under the hood).
Note that this uses a model object and not a path...
The implementation does use a path pathToModelFile
so perhaps we need both?
The implementation does use a path
pathToModelFile
so perhaps we need both?
Would make sense. For example, my CSV synchronization script would create a new model in memory and would merge it into current model, so in my case I will never have a path (unless I create a temporary one somewhere).
Related question: what does this merge
function return? I guess returning a JS object which contains a global status and list of infos, warnings and errors make sense:
{
status: true|false,
informations: [
"INFO001",
"INFO002",
...
],
warnings: [
"WARN001",
"WARN002",
...
],
errors: [
"ERR001",
"ERR002",
...
]
}
what does this merge function return
Right now it returns the owning model proxy.
I guess returning a JS object which contains a global status and list of infos, warnings and errors make sense
Will investigate...
Will investigate...
Wait a minute. One of the good thing on jArchi is that we do method chaining. And returning the model proxy is aligned with that.
Maybe we could stick with that but raise an exception if we have some errors ?
Maybe we could stick with that but raise an exception if we have some errors ?
Will investigate... ;-)
Btw, if you haven't tried chatGPT yet, do it. It provided me this idea of using exception to keep the method chaining available... If only we had an opensource equivalent of it and train it on an ArchiMate model (ArchiBot...)
What did you ask it?
What did you ask it?
I asked: Can you tell me how (in java) we can create code that uses method chaining and still provides useful information to know if a method failed?
It then provided me a code example to illustrate method chaning, then two proposals (the first off, but the second was about exceptions)
Should have asked chatPhillipus
var messages = [];
model.merge("model.archimate", true, true, messages);
messages.forEach(function(message) {
console.log(message);
});
Added in 1.5.0
@jbsarrodie I figured out how to expose the model importer's undo/redo Command to jArchi so it's possible to do this now. It will have to be for a version of jArchi that depends on Archi 5.
Suggested basic API:
model.importModel(pathToModelFile, update, updateAll)
update
- update existing objects and foldersupdateAll
- update model information and top-level foldersCould probably get a better name for the boolean parameters