Working with elements "diagram properties" in script - enterprise-architect

I have an my own MDG, consist of several elements. I need change view of those elements when its placed at different diagram. There is a mechanism called "user-selected settings" in MDG and I use its to change view of elements (e.g. via shape script function "HasProp" ). But for several reason I need to change diagram property for element via script. Are there any way to work with diagram property for element within script ?

It's possible but a bit tricky. First of all you need to get hold of the right diagram's table data stored in t_diagram. Issue a SQL like
SELECT StyleEx FROM t_diagram WHERE Diagram_ID = <theID>
Of course <theID> must be the diagram id of the diagram. Now you can use some string operations. Here's what my test diagram brought:
ExcludeRTF=0;DocAll=0;HideQuals=0;AttPkg=1;ShowTests=0;ShowMaint=0;SuppressFOC=1;MatrixActive=0;SwimlanesActive=1;KanbanActive=0;MatrixLineWidth=1;MatrixLineClr=0;MatrixLocked=0;TConnectorNotation=UML 2.1;TExplicitNavigability=0;AdvancedElementProps=1;AdvancedFeatureProps=1;AdvancedConnectorProps=1;m_bElementClassifier=1;ProfileData=;MDGDgm=VW VA Functional 3::Use case activity;STBLDgm=;ShowNotes=0;OPTIONS_9CEFE070=Structure=1:;VisibleAttributeDetail=0;ShowOpRetType=1;SuppressBrackets=0;SuppConnectorLabels=0;PrintPageHeadFoot=0;ShowAsList=0;SuppressedCompartments=;Theme=:119;SaveTag=79E21B13;;
which is a CSV at its best. See the
OPTIONS_9CEFE070=Structure=1:;
which actually encodes the diagram properties. Here it's just one with the name Structure and its value is set to 1. The 9CEFE070 refers to the GUID the diagram object. Of course not directly.
So find the diagram objects of the diagram itself with
SELECT Object_ID, ObjectStyle FROM t_diagramobjects
The Object_ID is for identifying the object behind (you might use a join to get needed information). And the ObjectStlye contains something like (from my test)
DUID=9CEFE070;HideIcon=0;
And there you have that hex string. Now you know that this one object has a diagram property set.
You should issue some queries manually to get familiar with that.
Now, to set a property, you "just" have to find the DUID from the diagram object of the diagram (just use the query above). Now you can add that OPTIONS_<duid> part or in case it already exists you need to modify it with according string operations. Finally you need to update the diagram table with
Repository.Execute("UPDATE t_diagram SET StyleEx = `<new string>` WHERE diagram_id = <theID>")
Note that this is an undocumented operation and you get
a) no support and
b) can easily clobber your whole model which is
c) the reason for a).
Have a backup!

Related

How to relate a column to the row rather than the other way in anylogic

I have created a database in anylogic. Previously, I have related the information in the row to the columnn, i.e. there is a component in the row, and its properties are in the columns, and have put this in a function. Now I want to make the component the column and the properties, but don't know how to make it all relate. Below is the code I've written for the former:
site = selectFrom(parameters) .where(parameters.box_number.eq(boxNumber)) .where(parameters.site.eq(site)) .firstResult(parameters.site);
So box_number is the component and site is one of the properties. With this method, site is a column, but I want it to be a row.
You should use the SELECT WHERE SQL syntax, see https://help.anylogic.com/index.jsp?topic=%2Fcom.anylogic.help%2Fhtml%2Fconnectivity%2Fquerying.html&resultof=%22%73%65%6c%65%63%74%22%20%22%77%68%65%72%65%22%20
You can filter and load data in any format. Also, best use the database query wizard to help:

ABAP Domain and Data Types Understanding

so my company wants me to learn ABAP for SAP and I have started on the road to learn this. My background is mainly VB.net and sqlserver with T-SQL but also have experience in c#.
With ABAP though I am needing some clarification or confirmation on the understanding of Data Types and Domain. If anyone can help.
My understanding currently is we have a table, in the table we have fields and the fields have data types and lengths if needed. Example: We have a table Customer, I could have a customerNumber field with the data type of char(10). To me this mean in the table customer we have a field called CustomerNumber that will have 10 characters.
However with ABAP we have Domains, Data elements then the field, does this mean we have a field named whatever we want. As the field could mean anything we assign a data element which has the descriptions of the sort of data stored within the field. However to store the format and data type we need to assign the Domain to the Data element.
For example I call a field ZCUSNO, currently this means nothing however if I assign the ZCTNMR (with description of customer number) Data element this tells us that the field ZCUSNO is ZCTNMR so ZCUSNO is a customer number field.
Now within the data elements we would have a domain and for our example ZCTNMR data element (the customer number) we could assign ZCTDOM as the domain which would be what I recognise as the data types so Char 20, Char 100 or integer field etc.
Is my understanding correct on this? and could someone give me a clear indication of what the difference between a Domain > Data Element is against what I would know as data types in sqlserver.
Thanks
I don't know if it's 100% correct, but that's is the way I use, like you say.
You can reuse the Domain, If you don't plan to reuse you can use direct the Data Element and refer this to a built-in-type.
Data Element is to define semantic of the field, like label, translation, etc
Domain is to define techinical info of the field, like Type, conversions, predefined Values,e tc
E.G.
Domain:
DOM_VALUE you define it's 10 position and 2 Decimals
Data Element:
UNIT_VAL you refer it to DOM_VALUE and define label as "Unit Value"
TOTAL_VAL you refer it to DOM_VALUE and define label as "Total Value"
Your understanding is pretty correct and not much can be added here.
You should clearly get the main thing.
Domains store technical data (decimal points, length, type, predefined values and so on)
Data elements store semantic data (labels, texts, search help binding, etc.)
Not every table field has data element (they can possess builtin type) but every field has type (either primitive or wrapped in data element).
If you wanna use your field in screens (Dynpros), ALV grids or other reports, then create data elements that will bear business meaning of your field.
If you use this field just for calculations or other utility internal tasks, then don't bother yourself.
As usual table date field (type of variable) uses data element which uses domain.
When you create fields in table and use predefined types instead of data elements you will have some problems in future, when you'll need to see the data on alv_grid.
Actually, you will see that you have some problems even before this (when you will try to make a maintenance view the header will have something like "+" symbol).
And of course we usually try to create 1 domain for 2 and more Data Elements.
In domain you talk about main logic.
In Data Element I always talk about Field label settings (how it'll show in future and some other things)
Final: Actually, the good practice, as I think to create a domain for data element, it may help you in future.
I hope that it helps you. Good luck!

How to document only attributes displayed on a class diagram?

I have a class diagram showing tables and the relations. The tables have been restricted on the diagram to show only the attributes I'm interested in, using the "custom" button in the Feature Compartment Visibility dialog. I now want to use the document generator to document the classes and attributes displayed on the diagram in the document text.
While I can use a virtual document with the appropriate query to select the classes in the diagram, passing that into a template which shows the attributes shows all of them. I can't find a way of reducing the list of attributes.
I could use a template to show the class header, and a custom fragment to query the attributes, but it would not be possible to determine within the custom script/sql which diagram was the relevant one, so that doesn't work.
Has anyone managed to do this without a third party tool?
You can get that info in the field StyleEx of the t_diagram
The following example query returns the attributes that are shown on a particular diagram
select a.ea_guid,d.StyleEx from t_diagramobjects do
inner join t_object o on do.Object_ID = o.Object_ID
inner join t_diagram d on d.Diagram_ID = do.Diagram_ID
inner join t_attribute a on o.Object_ID = a.Object_ID
where o.ea_guid = '{0285FC6A-A2CE-479e-B374-5135BD74DACF}'
and d.StyleEx like '%SPL=S_%' + substring(a.ea_guid,2,6) + '%'
This works for SQL-Server, but needs to be adapted to suit your DBMS as substring and wildcards are database specific.
You can set a Scope on the attribute so they will be shown dependent of the scope, for example, your diagram can show only all public attributes.
You can then go into the Diagram Properties, on the features tab, and select which scopes you want to show
Or
You can set a stereotype, for example NotVisible, on an attribute you want to hide.
You then need to go in the feature visibility of each element, and enter the stereotypes you want to hide in the box in the bottom
There are other ways, but this is the gist of it
After that you can use fragments and query on attributes with the defined scope or stereotype

Document Generation Order

I would like to report an UI diagram to a Word file.
I therefore create a template to extract the controls and their notes to a table.
The table, by default, is sorted by the aleph beta order of their names.
Is there a way to order the tabe by the order of the controls on the diagram?
The default options are to order by Tree order, Name, Modified date or Created date, so no diagram position.
What I would do is probably create an SQL fragment and order them in the query. It's a tad complicated, but doable if you know your way around the EA database structure.

knockout - update UI (filter data) based on select/dropdown choice?

How can I update this UI based on the selection made in the select/dropdowns?
For example, if I select a member name from the select/dropdown, I want the table to update/filter to only show those member rows (member names are in far right column) AND their corresponding date header (the gray background).
If I select a provider name from the select/dropdown), I want the table to update/filter to only show those provider rows (provider names in left column) AND their corresponding date header (the gray background).
I'm using the KO mapping plugin. The dummy data is hard coded and would eventually be returned via ajax.
Here's a fiddle of all the code (it's all just inlined in the HTML pane). You could copy/paste this and run it locally if you wanted, as well.
http://jsfiddle.net/qBGTh/
Any help/direction is greatly appreciated!
My suggestion is to use a computed value at eob level returning the filtered array. To add this computed value during the mapping process, you must customize the eob object creation using a create callback in the mapping options parameter (see mapping doc)
Here is the updated fiddle to see it in action.
Also don't forget to add 2 more observables to capture current values for the 2 select elements. The computed value will depend on those 2 observables.
Note: the provided fiddle will not run on IE as github where is located the
mapping javascript does not return the content-type header required by IE.