Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Geert Bellekens on October 31, 2020, 12:44:51 am
-
I have this stereotype on a connector that has 5 boolean tagged values
Create, Update, Delete, Load, and Determine.
Now I want to show the ones that are true on the diagram as a sort of constraint.
So if Update = True, and Determine = True, I want to show {Update, Determine}
But I'm struggling a bit on how to implement such a thing in shapescript.
Below is the best I could come up with. It works, but if feels like it's written by an 8 year old who just learned about IF/THEN/ELSE (plus I'm and I'm very happy there aren't 8 or 10 tags)
Does anyone know a more intelligent way to get the same result (or can assure my that I'm not THAT thick :-[)
shape middleBottomLabel
{
if (HasTag("Create", "True"))
{
if (HasTag("Update", "True"))
{
if (HasTag("Delete", "True"))
{
if (HasTag("Load", "True"))
{
if (HasTag("Determine", "True"))
print("{Create, Update, Delete, Load, Determine}");
else
print("{Create, Update, Delete, Load}");
}
else if (HasTag("Determine", "True"))
print("{Create, Update, Delete, Determine}");
else
print("{Create, Update, Delete}");
}
}
else if (HasTag("Delete", "True"))
{
if (HasTag("Load", "True"))
{
if (HasTag("Determine", "True"))
print("{Create, Delete, Load, Determine}");
else
print("{Create, Delete, Load}");
}
else if (HasTag("Determine", "True"))
print("{Create, Delete, Determine}");
else
print("{Create, Delete}");
}
else if (HasTag("Load", "True"))
{
if (HasTag("Determine", "True"))
print("{Create, Load, Determine}");
else
print("{Create, Load}");
}
else if (HasTag("Determine", "True"))
print("{Create, Determine}");
else
print("{Create}");
}
else if (HasTag("Update", "True"))
{
if (HasTag("Delete", "True"))
{
if (HasTag("Load", "True"))
{
if (HasTag("Determine", "True"))
print("{Update, Delete, Load, Determine}");
else
print("{Update, Delete, Load}");
}
else if (HasTag("Determine", "True"))
print("{Update, Delete , Determine}");
else
print("{Update, Delete}");
}
else if(HasTag("Load", "True"))
{
if (HasTag("Determine", "True"))
print("{Update, Load, Determine}");
else
print("{Update, Load}");
}
else if (HasTag("Determine", "True"))
print("{Update, Determine}");
else
print("{Update}");
}
else if (HasTag("Delete", "True"))
{
if (HasTag("Load", "True"))
{
if (HasTag("Determine", "True"))
print("{ Delete, Load, Determine}");
else
print("{ Delete, Load}");
}
else if (HasTag("Determine", "True"))
print("{Delete, Determine}");
else
print("{Delete}");
}
else if (HasTag("Load", "True"))
{
if (HasTag("Determine", "True"))
print("{Load, Determine}");
else
print("{ Load}");
}
else if (HasTag("Determine", "True"))
print("{Determine}");
else
print("");
}
Geert
-
That's what I recently meant by "poor, poor" language. Not your fault.
q.
-
That's what I recently meant by "poor, poor" language. Not your fault.
q.
+1
Shapescript could be SO MUCH MORE!
Paolo
-
Agree re limitations of shapescript language. Has anyone tested to see if the newish model add-ins work in a shapescript ? Standard add-ins do - so i'd hope model add-ins do as well. If they do then calling a model addin that prepares your string should perform ok - given its just string manipulation, not looking up loads of data etc.
-
Has anyone tested to see if the newish model add-ins work in a shapescript ?
I have, and they do. It's not a practice I would recommend though.
For one thing it's probably pretty easy to crash EA this way -- mutual recursion and whatnot. Not to mention that the power of having stuff in-model is also a weakness: the model can be modified after deployment.
But more importantly, the whole Model Add-In feature feels very much like a dead end to me. I think it's more likely than not that a version or two down the line it will be quietly deprecated, EA style. Which means leaving it incomplete with a couple of glaring showstopper bugs in there, and when users complain tell them some other feature is now the flavour of the month preferred solution, while leaving the documentation in place, making it look like the feature is main stream and fully supported. (For reference, see Required/disabled Technologies.)
If they do then calling a model addin that prepares your string should perform ok - given its just string manipulation, not looking up loads of data etc.
I think not. EA launches a separate process (sscripter.exe) for a Model Add-In (one for each or one for all, haven't tested -- for that matter, is it even possible to run more than one Model Add-In at a time?). I don't see how you can get anything remotely approaching acceptable performance this way.
By contrast, a DLL Add-In's code executes within the EA process, and even then, more than a dozen instances of a shape script Add-In call in one diagram is unusable.
So I'd say yes on the Add-In option to solve this problem, but no to the Model Add-In as an alternative. If the thing has to work in the wild, anyway. For a concept demo, I guess it could be OK.
Shapescript could be SO MUCH MORE!
Yes indeed. Why not make it an extension of (a subset of) SVG, with a couple of macros to access the model data?
/Uffe
-
That SVG-path has been suggested before by others (can't recall who). The reason for Sparxians to have two ears is that the sound coming into one ear can leave through the other one.
q.