Secure Tropos ProjectProject specific questions and answers from the project Secure Tropos.RE: Event "BeforeDeleteInstance"Wilfrid Utzhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=3930042015-10-27T11:59:18Z2015-10-27T11:59:18ZAs an update to the previous implementation proposal, please consider the following update. It is discouraged to use the "UpdateAction" event as this could result in unpredicted behaviour. The approach for preventing relation instances to be deleted, we can combine the "DeleteRelationInstance" with "DiscardRelationInstance". The approach is based on the sequence of events, as during the <strong>DeleteRelationInstance</strong> we can capture the deleted relation and all available attributes, serialize this information and run a re-create in the <strong>DiscardRelationInstance</strong>, as this event is triggered when the relation instance is discarded from the modelling core.<br /><br />The proposal below builds upon this assumption, serialization between the events is realized using a map object, e.g. serializing in memory.<br /><br /><div class="code"><span class="code-lines">1</span>ON_EVENT "AppInitialized"<br /><span class="code-lines">2</span>{<br /><span class="code-lines">3</span> # ...<br /><span class="code-lines">4</span> SETG mDeletedRelations: (map())<br /><span class="code-lines">5</span> # ....<br /><span class="code-lines">6</span>}<br /></div>During AppInitialized, the map for serializing is initialized.<br /><br /><div class="code"><span class="code-lines"> 1</span>ON_EVENT "DeleteRelationInstance" {<br /><span class="code-lines"> 2</span> IF (( #select the appropriate instance type#)) {<br /><span class="code-lines"> 3</span> # get the position of the relation <br /><span class="code-lines"> 4</span> CC "Core" GET_ATTR_VAL objid: (relationinstanceid) attrname:"Positions"<br /><span class="code-lines"> 5</span> SETL sPositionsVal: (val)<br /><span class="code-lines"> 6</span> # get all attributes of the relation<br /><span class="code-lines"> 7</span> CC "Core" GET_ALL_ATTRS classid: (relationclassid)<br /><span class="code-lines"> 8</span> SETL lAttributeIDs: (attrids)<br /><span class="code-lines"> 9</span> SETL lAttributeMap: ("")<br /><span class="code-lines">10</span> FOR sAttributeID in: (lAttributeIDs) {<br /><span class="code-lines">11</span> CC "Core" GET_ATTR_VAL objid: (relationinstanceid) attrid: (VAL sAttributeID) as-string<br /><span class="code-lines">12</span> SETL sAttributeValue: (val)<br /><span class="code-lines">13</span> SETL sIDValuePair: (sAttributeID + "#" + sAttributeValue)<br /><span class="code-lines">14</span> SETL lAttributeMap: (tokunion (lAttributeMap, sIDValuePair, "|"))<br /><span class="code-lines">15</span> }<br /><span class="code-lines">16</span> IF (type (mDeletedRelations[id_componentid]) = "undefined") {<br /><span class="code-lines">17</span> SET sTimeStampedDeletedActions: (STR relationclassid + "|" + STR toinstanceid + "|" + STR frominstanceid + "|" + base64encode(sPositionsVal) + "|" + base64encode(lAttributeMap)+ "|" + STR relationinstanceid)<br /><span class="code-lines">18</span> }<br /><span class="code-lines">19</span> ELSE {<br /><span class="code-lines">20</span> SET sTimeStampedDeletedActions: (tokunion (mDeletedRelations[id_componentid], STR relationclassid + "|" + STR toinstanceid + "|" + STR frominstanceid + "|" + base64encode(sPositionsVal)+ "|" + base64encode(lAttributeMap) + "|" + STR relationinstanceid))<br /><span class="code-lines">21</span> }<br /><span class="code-lines">22</span> SETG mDeletedRelations[id_componentid]: (sTimeStampedDeletedActions)<br /><span class="code-lines">23</span>}<br /></div>The "DeleteRelationInstance" retrieves the values from the deleted relation and stores them into the map element<br /><br /><div class="code"><span class="code-lines"> 1</span>ON_EVENT "DiscardRelationInstance" {<br /><span class="code-lines"> 2</span> CC "Modeling" GET_ACT_MODEL<br /><span class="code-lines"> 3</span> SETL nCreatedModelID: (modelid)<br /><span class="code-lines"> 4</span> IF (nCreatedModelID != -1 AND LEN (mDeletedRelations) > 0) {<br /><span class="code-lines"> 5</span> FOR sDeletedRelation in: (mDeletedRelations) {<br /><span class="code-lines"> 6</span> IF (LEN (sDeletedRelation) > 0) {<br /><span class="code-lines"> 7</span> EVENT_LOG msgType:"EVENT_LOG" message: (sDeletedRelation)<br /><span class="code-lines"> 8</span> CC "Core" CREATE_CONNECTOR modelid: (modelid) fromobjid: (VAL token (sDeletedRelation, 2, "|")) toobjid: (VAL token (sDeletedRelation, 1, "|")) classid: (VAL token (sDeletedRelation, 0, "|"))<br /><span class="code-lines"> 9</span> SETL nNewRelationID: (objid)<br /><span class="code-lines">10</span> CC "Core" SET_ATTR_VAL objid: (nNewRelationID) attrname:"Positions" val: (base64decode(token (sDeletedRelation, 3, "|")))<br /><span class="code-lines">11</span> SETL lAttributeValueMap: (base64decode(token (sDeletedRelation, 4, "|")))<br /><span class="code-lines">12</span> FOR sAttributeKeyValue in: (lAttributeValueMap) sep:"|" {<br /><span class="code-lines">13</span> SET sAttributeID: (token (sAttributeKeyValue, 0, "#"))<br /><span class="code-lines">14</span> SET sAttributeValue: (token (sAttributeKeyValue, 1, "#"))<br /><span class="code-lines">15</span> CC "Core" GET_ATTR_TYPE attrid: (VAL sAttributeID)<br /><span class="code-lines">16</span> IF (attrtype = "INTEGER" OR attrtype = "DOUBLE" OR attrtype = "TIME") {<br /><span class="code-lines">17</span> CC "Core" SET_ATTR_VAL objid: (nNewRelationID) attrid: (VAL sAttributeID) val: (VAL sAttributeValue)<br /><span class="code-lines">18</span> } ELSE {<br /><span class="code-lines">19</span> CC "Core" SET_ATTR_VAL objid: (nNewRelationID) attrid: (VAL sAttributeID) val: (sAttributeValue)<br /><span class="code-lines">20</span> }<br /><span class="code-lines">21</span> }<br /><span class="code-lines">22</span> }<br /><span class="code-lines">23</span> }<br /><span class="code-lines">24</span> # reset map<br /><span class="code-lines">25</span> SETG mDeletedRelations: (map())<br /><span class="code-lines">26</span> }<br /><span class="code-lines">27</span>}<br /></div>The event "DiscardRelationInstance" is used to re-create the missing connector.Wilfrid Utz2015-10-27T11:59:18ZRE: XML Export PluginDamiano Falcionihttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=3065242015-08-28T12:12:03Z2015-06-07T13:57:00ZI would like to share my transformation for the XML Export Plugin in order to export a BPMN diagram in BPMN2.0 standard format.<br />The code is attached,<br /><br />Enjoy <img alt="emoticon" src="https://www.adoxx.org/livehttps://www.adoxx.org/ADOxxORGv3-theme/images/emoticons/happy.gif" >Damiano Falcioni2015-06-07T13:57:00ZRE: Event "BeforeDeleteInstance"Wilfrid Utzhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=1759542014-09-30T11:39:32Z2014-09-30T11:39:32ZHi Domenik,<br /><br />to prevent the deletion of instances (NOT relation instances), you can just EXIT the event with -1 and you are good. See a small example below.<br /><br /><div class="code"><span class="code-lines">1</span>ON_EVENT "BeforeDeleteInstance" {<br /><span class="code-lines">2</span> # your custom logic, if not done, no deletion is possible at all<br /><span class="code-lines">3</span> EXIT -1<br /><span class="code-lines">4</span>}<br /></div>Wilfrid Utz2014-09-30T11:39:32ZRE: Event "BeforeDeleteInstance"Dominik Borkhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=1748432014-09-25T12:24:49Z2014-09-25T12:24:49ZDoes the same limitation hold for the object deletion or is there a way to prevent ADOxx from deleting modeling class instances?<br /><br />Thank you.<br />- DomenikDominik Bork2014-09-25T12:24:49ZExtending ADOXX with custom DLLs written in FreePascalWilfrid Utzhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=712622014-03-27T12:27:02Z2014-02-24T07:24:34ZOne part of the project is to provide a possibility to setup and maintain a pattern repository to support the user in the modelling task. In the course of the project an extension has been developed using a custom DLL to support that functionality. <br /><br />Please see attached the necessary files structured as a tutorial, including the example ABL file and a FreePascal DLL project. The tutorial is rather a development guide, so it is kept to the information only relative to the problems related to the ADOxx + DLL development. It is assumed that the intended audience will have some programming knowledge, so introduction to programming is beyond the scope of this tutorial.<br /><br />As a first step the DLL project must be built, then resulting DLL file (it will appear in the root directory of the project in the "bin" subfolder) copied to the installation directory of the ADOxx (most likely C:\Program Files\BOC\ADOxx13_EN_SA). After importing the application library and running the ADOxx modelling toolkit the main menu will have a couple of extra options - to show a message box from the DLL and invoke an object creation dialogue, which takes couple of parameters, then creates an object on the drawing area of the ADOxx. Such example demonstrates how to pass information forth and back between the DLL and ADOxx. Based on that any soft of functionality can be implemented in the DLL.<br /><br />Attribution: Prof. Haris Mouratidis, Viktoras Malinauskas<br /><br />In case of questions, please use this thread to communicate with Prof. Mouratidis and Viktoras.Wilfrid Utz2014-02-24T07:24:34ZXML Export PluginWilfrid Utzhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=616682014-03-27T12:27:27Z2014-01-27T09:31:54ZA requirement in the project was to provide means for a XML based interface where the actual XML structure is not yet clear. Therefore the project team developed a plugin framework of transformation implementation that can be dynamically modified, enhanced and extended.<br /><br />The basic idea is that each XML transformation plugin is an XSL file that provides the transformation logic. Please find attached the implemented resource for that.<br />In this case a default set of transformation plugins can be provided within the library and additionally, the user can develop and provide new plugins as required.<br /><br />Attached to this post is the framework implementation as an AdoScript that needs to be added/integrated in the library via the "External Coupling" Library attribute. 2 default plugins are provided in addition to have an initial configuration available.<br /><br />To include the framework, load and execute the AdoScript file in the event of "AppInitialized", the assumption is that all files are provided via the file management of the library.<br /><br /><div class="code"><span class="code-lines">1</span>ON_EVENT "AppInitialized" {<br /><span class="code-lines">2</span># ....<br /><span class="code-lines">3</span>EXECUTE file: ("db:\\XMLExportFramework.asc")<br /><span class="code-lines">4</span><br /><span class="code-lines">5</span>}<br /></div><br /><br /><br />.Wilfrid Utz2014-01-27T09:31:54ZRE: Modeltype-specific drawing area representationWilfrid Utzhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=216402013-07-26T11:26:59Z2013-07-10T13:30:25ZIt is possible to define a GraphRep which is used for drawing the background of the drawing area. Model attributes can be displayed on the drawing area Fields can be painted on the drawing area which may look like swimlanes but are not modeling objects. <br /><br />To define a GraphRep for a model type, please follow the steps below:<br /><br /><strong>Step 1: Prepare Class Hierarchy</strong><br />IMPORTANT: The class __ModelTypeMetaData__ does not exist in the default library/empty library, it needs to be created manuallyas a sub-class of the __LibraryMetaData__.<br /><br /><strong>Step 2: Define GraphRep Attribute</strong><br />Add a class attribute of type STRING or LONGSTRING to the class "__ModelTypeMetaData__" of the dynamic library. This attribute will be used as GraphRep definition for the treated model type. You may choose any attribute name, e.g. "ModelTypeA model GraphRep" for a model type "ModelType A".<br /><br /><strong>Step 3: Add a GraphRep Specification to ModelType</strong><br />Add a graphrep specification to the model type defnition. The model type definition is contained in the library attribute "Modi". There you have to specify the name of the attribute which contains the GraphRep definition, e.g. graphrep:"ModelTypeA model GraphRep".<br /><br /><div class="code"><span class="code-lines">1</span>MODELTYPE "ModelType A" ....graphrep:"ModelTypeA model GraphRep"</div><br /><br />The model types's GraphRep is painted as first object in its layer. The layer index is specified at the GRPAHREP element in the model type's GraphRep. If a high layer index is specified at the model type's GraphRep, it is more a foreground than a background graphics. To draw a graphics which lies behind all objects, you have to specify the lowest index used at a modeling object's GraphRep. In the model type's GraphRep, model attributes can be accessed via ATTR and AVAL. This applies also for custom model attributes. (see custom model attributes <a href="https://www.adoxx.org/live/live/en_GB/faq/-/message_boards/view_message/21615">http://www.adoxx.org/live/en_GB/faq/-/message_boards/view_message/21615</a>)<br /><br />At a model type's GraphRep, the following variables are preset:<br />w -- the current drawing area width<br />h -- the current drawing area height<br />So the GraphRep may depened on the current drawing area size. That makes it possible to draw lanes across the whole width or height, or to place a text at the bottom of the drawing area.<br /><br /><em>Examples:</em><br />Show the name, modeltype and count of objects and relations on the drawing area<br /><div class="code"><span class="code-lines"> 1</span>GRAPHREP layer:-1<br /><span class="code-lines"> 2</span>AVAL name:"Name" # model name<br /><span class="code-lines"> 3</span>AVAL type:"Type" # model type name<br /><span class="code-lines"> 4</span>AVAL count:"Number of objects and relations"<br /><span class="code-lines"> 5</span>SET y:0.5cm<br /><span class="code-lines"> 6</span>FONT "Verdana" h:24pt style:"outline" color:gray<br /><span class="code-lines"> 7</span>TEXT (name + " (" + type + ")") x:0.5cm y: (y) w:l h:t<br /><span class="code-lines"> 8</span>SET y: (y + 24pt + 0.3cm)<br /><span class="code-lines"> 9</span>FONT "Verdana" h:12pt color:gray<br /><span class="code-lines">10</span>TEXT ("Object count: " + count) x:0.5cm y: (y) w:l h:t <br /></div><br /><br />The following model type GraphRep displays the value of the attribute "Description" as headline and a copyright remark as footline. Also a vertical arrow is painted from the top to the bottom of the drawing area.<br /><div class="code"><span class="code-lines"> 1</span>GRAPHREP layer:-1<br /><span class="code-lines"> 2</span>SHADOW off<br /><span class="code-lines"> 3</span># horizontal lane which is the description's background<br /><span class="code-lines"> 4</span>PEN color:$c0dd80<br /><span class="code-lines"> 5</span>FILL color:$e0ffa0<br /><span class="code-lines"> 6</span>RECTANGLE w: (w) h:2.5cm<br /><span class="code-lines"> 7</span># description; width is drawing area width<br /><span class="code-lines"> 8</span>ATTR "Description" w: (w) h:2.5cm<br /><span class="code-lines"> 9</span># vertical arrow<br /><span class="code-lines">10</span>PEN w:0.3cm color:$c0dd80<br /><span class="code-lines">11</span>LINE x1: (w - 2cm) y1:0.5cm x2: (w - 2cm) y2: (h - 0.5cm)<br /><span class="code-lines">12</span>POLYLINE 3 x1: (w - 3cm) y1: (h - 2cm)<br /><span class="code-lines">13</span> x2: (w - 2cm) y2: (h - 0.5cm)<br /><span class="code-lines">14</span> x3: (w - 1cm) y3: (h - 2cm)<br /><span class="code-lines">15</span># copyright remark at the drawing area bottom<br /><span class="code-lines">16</span>FONT "Verdana" h:9pt color:$6060a0 italic<br /><span class="code-lines">17</span>TEXT "Creative Commons" x:0.2cm y: (h) h:b<br /></div>Wilfrid Utz2013-07-10T13:30:25ZModeltype-specific drawing area representationhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=216272014-03-27T12:27:50Z2013-07-10T13:21:30ZIs is possible to have different representations for the drawing area depending on the modeltype?2013-07-10T13:21:30ZRE: Custom model attributes for different modeltypesWilfrid Utzhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=216242013-07-10T13:18:00Z2013-07-10T13:17:00ZAll additional model attributes are stored in a class of the dynamic library in ADOxx called <strong>__ModelTypeMetaData__</strong>. This class must exist only in the dynamic library. Ensure that the ClassAbstract class attribute is set to 1 to make this properly work.<br /><br /><strong>Step 1: Prepare Class Hierarchy</strong><br />IMPORTANT: The class <strong>__ModelTypeMetaData__</strong> does not exist in the default library/empty library, it needs to be created manuallyas a sub-class of the <strong>__LibraryMetaData__</strong>.<br /><br /><strong>Step 2: Add Attributes to Class "__ModelTypeMetaData__"</strong><br />You can add attributes of any type, except INTERREF and ATTRPROFREF. When using RECORD attributes you have to take care that the referenced RECORD class does not contain any INTERREF attribute. Otherwise you will get an error message in ADOxx, since INTERREFs are not supported in model attributes<br /><br /><strong>Step 3: Define AttrRep Attribute for ModelType</strong><br />To adopt the AttrRep you have to add an <strong>attrrep </strong>attribute to a model type definition in the Modi attribute value of the concerned library. The attrrep value must be the name of a STRING or LONGSTRING attribute in the <strong>"__ModelTypeMetaData__"</strong> class.<br />The syntax of this attribute is the same as the AttrRep attribute for classes and relations, please be careful to test the implementation since no validation happens on save.<br /><br /><em>Example</em><br />ALL Representation of __ModelTypeMetaData__<br /><div class="code"><span class="code-lines">1</span>class "__ModelTypeMetaData__"<br /><span class="code-lines">2</span> attribute "Sample_Model_AttrRep"<br /><span class="code-lines">3</span> type STRING<br /><span class="code-lines">4</span> value "NOTEBOOK ... ATTR \"A new model attr\" ... "<br /><span class="code-lines">5</span><br /><span class="code-lines">6</span> attribute "A new model attr"<br /><span class="code-lines">7</span> type INTEGER<br /></div><br /><br />Library Attribute MODI<br /><div class="code"><span class="code-lines">1</span>MODELTYPE "Example ModelType A" .... attrrep:"Sample_Model_AttrRep"</div>Wilfrid Utz2013-07-10T13:17:00ZCustom model attributes for different modeltypeshttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=216152014-03-27T12:29:12Z2013-07-10T13:06:55ZIs it possible to define custom notebooks for models and modelattributes for modeltypes in ADOxx?2013-07-10T13:06:55ZRE: Dynamically get attributes of a classWilfrid Utzhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=216112013-07-10T13:04:03Z2013-07-10T13:02:38ZTwo AdoScript commands can be used to retrieve the attributes associated with a class in ADOxx:<br /><br /><strong>GET_ALL_NB_ATTRS</strong> returns a list of all attribute IDs contained in the notebook of a certain class or relation class.<br /><div class="code"><span class="code-lines">1</span>CC "Core" GET_ALL_NB_ATTRS classid:intValue<br /><span class="code-lines">2</span>#-->RESULT ecode:intValue attrids:strValue .<br /></div><br /><br /><br /><strong>GET_ALL_ATTRS </strong>returns a list of attribute ids (separated by spaces).<br /><div class="code"><span class="code-lines">1</span>CC "Core" GET_ALL_ATTRS [OfModelType | OfClass]<br /><span class="code-lines">2</span>Option: OfModelType: modeltype:strValue [ with-hidden-attrs ] .<br /><span class="code-lines">3</span>Option: OfClass: classid:intValue [ without-iattrs ] [ with-cattrs ]<br /><span class="code-lines">4</span>#-->RESULT ecode:intValue attrids:strValue<br /></div>Wilfrid Utz2013-07-10T13:02:38ZDynamically get attributes of a classhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=216042014-03-27T12:28:40Z2013-07-10T13:00:48ZIs there a way to get the attributes related to a class dynamically during operation with AdoScript?2013-07-10T13:00:48ZEvent "BeforeDeleteInstance"Wilfrid Utzhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=187212015-10-28T07:28:49Z2013-04-11T18:31:02Z<strong><span style="font-size: 18px"><span style="color: #b22222">NEW APPROACH DESCRIBED IN FOLLOWING POST - Use of EVENT UpdateAction is discouraged!</span></span></strong><br /><br />Currently, the "BeforeDeleteInstance" deletes related connectors, even if the event is cancelled, meaning the EXIT value is set to -1. This is due to the fact, that the deletion of events is happened beforehand. To overcome this limitation, the following implementation can be used. This is actually a restore mechanism of relation instances after the delete.<br /><br />- Implement a stack of deletedRelations as a map with the deleted relations and the related timestamp as a key, that is only updated in case the event triggering the delete is from the BeforeDeleteInstance event<br />- Implement the UpdateAction event inclduing a trigger flag (otherwise the event is triggered continously.<br />- Implement a timestamp capture mechanism to realize the events that should be restored.<br /><br /><br />Limitations:<br />- attribute values are currently not captured, this would to be implemented on a custom/method level<br /><br /><div class="code"><span class="code-lines"> 1</span>ON_EVENT "AppInitialized" {<br /><span class="code-lines"> 2</span> # init the holder for deleted relations as a map and the event time when these where triggered<br /><span class="code-lines"> 3</span> SETG mDeletedRelations: (map())<br /><span class="code-lines"> 4</span> SETG sEventTime:""<br /><span class="code-lines"> 5</span> ...<br /><span class="code-lines"> 6</span>}<br /><span class="code-lines"> 7</span><br /><span class="code-lines"> 8</span>ON_EVENT "BeforeDeleteInstance" {<br /><span class="code-lines"> 9</span> CC "Application" GET_DATE_TIME date-format:"dd/mm/yyyy" time-format:"hh:mm:ss"<br /><span class="code-lines">10</span> #... [other code to determine whether the EXIT is set to -1<br /><span class="code-lines">11</span> # set the flag only if the delete of the instance comes from a cancelled delete of objects<br /><span class="code-lines">12</span> IF (execResult = -1) {<br /><span class="code-lines">13</span> SETG bUpdate: (1)<br /><span class="code-lines">14</span> SETG sEventTime: (time)<br /><span class="code-lines">15</span> } <br /><span class="code-lines">16</span> ELSE {<br /><span class="code-lines">17</span> SETG bUpdate: (0)<br /><span class="code-lines">18</span> }<br /><span class="code-lines">19</span> EXIT (execResult) <br /><span class="code-lines">20</span>}<br /><span class="code-lines">21</span><br /><span class="code-lines">22</span>ON_EVENT "DeleteRelationInstance" {<br /><span class="code-lines">23</span> CC "Application" GET_DATE_TIME date-format:"dd/mm/yyyy" time-format:"hh:mm:ss"<br /><span class="code-lines">24</span> # store all parameters so that they are available in other action, for restore<br /><span class="code-lines">25</span> IF (type (mDeletedRelations[time]) = "undefined") {<br /><span class="code-lines">26</span> SET sTimeStampedDeletedActions: (STR relationclassid + "|" + STR toinstanceid + "|" + STR frominstanceid)<br /><span class="code-lines">27</span> }<br /><span class="code-lines">28</span> ELSE {<br /><span class="code-lines">29</span> SET sTimeStampedDeletedActions: (tokunion (mDeletedRelations[time], STR relationclassid + "|" + STR toinstanceid + "|" + STR frominstanceid))<br /><span class="code-lines">30</span> }<br /><span class="code-lines">31</span> SETG mDeletedRelations[time]: (sTimeStampedDeletedActions)<br /><span class="code-lines">32</span> # TODO: add attribute value collecting functionality<br /><span class="code-lines">33</span>}<br /><span class="code-lines">34</span><br /><span class="code-lines">35</span>ON_EVENT "UpdateActions" {<br /><span class="code-lines">36</span> # only if flag is there<br /><span class="code-lines">37</span> IF (bUpdate) {<br /><span class="code-lines">38</span> # reset flag<br /><span class="code-lines">39</span> SETG bUpdate: (0)<br /><span class="code-lines">40</span> IF (type (mDeletedRelations[sEventTime]) <> "undefined") {<br /><span class="code-lines">41</span> FOR sDeletedRelation in: (mDeletedRelations[sEventTime]) {<br /><span class="code-lines">42</span> # only do if the timestamp contains a value<br /><span class="code-lines">43</span> CC "Core" CREATE_CONNECTOR modelid: (modelid) fromobjid: (VAL token (sDeletedRelation, 2, "|")) toobjid: (VAL token (sDeletedRelation, 1, "|")) classid: (VAL token (sDeletedRelation, 0, "|"))<br /><span class="code-lines">44</span> }<br /><span class="code-lines">45</span> # reset the list of deletedRelations<br /><span class="code-lines">46</span> SETG mDeletedRelations: (map())<br /><span class="code-lines">47</span> # TODO: add functionality to restore attribute values.<br /><span class="code-lines">48</span> }<br /><span class="code-lines">49</span> }<br /><span class="code-lines">50</span>}<br /></div>Wilfrid Utz2013-04-11T18:31:02ZEvent "SetAttributeValue" - Special ConsiderationWilfrid Utzhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=186032013-04-09T07:29:13Z2013-04-09T06:48:42ZSpecific considerations are necessary when implementing an AdoScript that is triggered by the "SetAttributeValue" event. The event is triggered by any kind of update/modification on attribute values (by the user or platform) when modifying the model and instances. This is especially of interest in the case of move events, where the event is triggered for any kind of position update and also redraw functions (creation/build up of model).<br /><br />To implement an AdoScript for the event make sure that you:<br />- know exactly the cases the AdoScript is implemented for (validation against the attribute ID and its type) to prevent unncessary processing<br />- make sure that user interaction scripting is targeted to the specific cases (in case of a script during move of objects and relations, the event is continously triggered and the scope is lost)<br />- for performance considerations, make sure that the script loading is done in effective way, reading and executing AdoScripts on the event potentally results in an unstable and/or time-consuming implementation of your method. It is recommended to pre-load script using the PROCEDURE mechanism and just trigger the respective procedure for each case.<br />- run type checking (attributeID first and then all other checks) in the ON_EVENT definition, this makes sure that scripts that are not necessary are not loaded just for the checking purpose<br /><br />The event definition can be found below.<br />Event name: <strong>"SetAttributeValue"</strong><br /><strong>Parameters:</strong><br /><em>instid : integer</em> (ID of the changed instance)<br /><em>attrid : integer</em> (Attribute ID)<br /><em>modelid : integer</em> (ID of the model containing the changed instance.<br /><em>attrtypeid : integer</em> (Attribute type code)<br />0 INTEGER<br />1 DOUBLE<br />2 STRING<br />3 DISTRIBUTION<br />4 TIME<br />5 ENUMERATION<br />6 ENUMERATIONLIST<br />7 CORE_LONGSTRING<br />8 PROGRAMCALL<br />9 INTERREF<br />10 EXPRESSION<br />11 RECORD<br />12 ATTRPROFREF<br />13 DATE<br />14 DATETIME<br />15 CLOB<br /><em>oldval : string</em> (The original value (as string))<br />This is the Core internal value (not UI value).<br />For attributes of type RECORD this is always an empty string.<br />The new value can be determined via the "Core" MessagePort.<br /><strong>Exit value</strong><br /><em>N/A</em><br /><br /><strong>EXAMPLE Implementation:</strong><br /><br /><div class="code"><span class="code-lines"> 1</span>ON_EVENT "SetAttributeValue" {<br /><span class="code-lines"> 2</span> EVENT_LOG msgType:"EVENT_LOG" message: ("SetAttributeValue with parameters instid : " + STR instid + " attrid : " + STR attrid + " modelid : " + STR modelid + " attrtypeid : " + STR attrtypeid + " oldval : " + oldval)<br /><span class="code-lines"> 3</span> # CASE A: Validate against AttrID and ClassID - first validation against AttrID, the right-hand part is preloaded in "AppInitialized"<br /><span class="code-lines"> 4</span> IF (attrid = nPreLoadedAttrIDACase) {<br /><span class="code-lines"> 5</span> # ClassID is not part of the event, in case of this attribute ID, get it and only run for specific classes<br /><span class="code-lines"> 6</span> CC "Core" GET_CLASS_ID objid: (instid)<br /><span class="code-lines"> 7</span> SET nClassID: (classid)<br /><span class="code-lines"> 8</span> # Validation against PreloadedClassID, done "AppInitialized" event<br /><span class="code-lines"> 9</span> IF (nClassID = nPreloadedClassIDACase) {<br /><span class="code-lines">10</span> # perform action for Case A<br /><span class="code-lines">11</span> ...<br /><span class="code-lines">12</span> }<br /><span class="code-lines">13</span> }<br /><span class="code-lines">14</span> # CASE B: Validate against AttrID only<br /><span class="code-lines">15</span> IF (attrid = nPreloadedAttrIDBCase){<br /><span class="code-lines">16</span> # perform action for Case B<br /><span class="code-lines">17</span> ...<br /><span class="code-lines">18</span> }<br /><span class="code-lines">19</span>}<br /></div>Wilfrid Utz2013-04-09T06:48:42ZEvent LoggingWilfrid Utzhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=185972013-04-09T05:52:05Z2013-04-09T05:33:04ZAs a means for event logging the CREATE_OUTPUT_WIN command of the AdoScript message port can be used to a) open a new dockable window and b) continously log the event streams that are captured. This visualisation could potentially highlight performance issues in the event implementation.<br /><br />In the following the steps are explained to set up event logging, including code snipplets for the setup and the actual listening.<br /><br />1. Add the event log window and procedure to the "AppInitialized" event in the Library attribute "External coupling"<br /><div class="code"><span class="code-lines"> 1</span>#All configuration and implementations that need to be triggered during startup<br /><span class="code-lines"> 2</span>ON_EVENT "AppInitialized" {<br /><span class="code-lines"> 3</span> # create the dockable window for the output stream<br /><span class="code-lines"> 4</span> CC "AdoScript" CREATE_OUTPUT_WIN winid:"EVENTLOG" title:"Event Logging"<br /><span class="code-lines"> 5</span> <br /><span class="code-lines"> 6</span> # establish a global procedure as a helper implementation for timestamped logging<br /><span class="code-lines"> 7</span> PROCEDURE global EVENT_LOG msgType:string message:string {<br /><span class="code-lines"> 8</span> CC "Application" GET_DATE_TIME date-format:"dd/mm/yyyy" time-format:"hh:mm:ss"<br /><span class="code-lines"> 9</span> SET currentDateTime: ((date) + " " + (time))<br /><span class="code-lines">10</span> CC "AdoScript" OUT winid:"EVENTLOG" text: ("[" + (msgType) + "@" + currentDateTime + "]: " + (message) + "\n")<br /><span class="code-lines">11</span> }<br /><span class="code-lines">12</span> # Initial event log message for the "AppInitialized" event<br /><span class="code-lines">13</span> EVENT_LOG msgType:"EVENT_LOG" message: ("AppInitialized")<br /><span class="code-lines">14</span> # Perform other things for the event<br /><span class="code-lines">15</span>}<br /></div><br /><br />2. Add event logger messages to the events. This should be done before anything else is performed for the event, to limit the dependency on other implementations<br /><div class="code"><span class="code-lines"> 1</span>ON_EVENT "BeforeCreateRelationInstance" {<br /><span class="code-lines"> 2</span> # Log event plus all parameters set for the event<br /><span class="code-lines"> 3</span> EVENT_LOG msgType:"EVENT_LOG message: ("BeforeCreateRelationInstance with parameters frominstid : " + STR frominstid + " toinstid : " + STR toinstid + " relationclassid : " + STR relationclassid + " componentid " + STR componentid)<br /><span class="code-lines"> 4</span> # Perform other things for the event<br /><span class="code-lines"> 5</span>}<br /><span class="code-lines"> 6</span><br /><span class="code-lines"> 7</span>ON_EVENT "SetAttributeValue" {<br /><span class="code-lines"> 8</span> # Log event plus all parameters set for the event<br /><span class="code-lines"> 9</span> EVENT_LOG msgType:"EVENT_LOG" message: ("SetAttributeValue with parameters instid : " + STR instid + " attrid : " + STR attrid + " modelid : " + STR modelid + " attrtypeid : " + STR attrtypeid + " oldval : " + oldval)<br /><span class="code-lines">10</span> # Perform other things for the event<br /><span class="code-lines">11</span>}<br /></div><br /><br />This can be done for each event available in ADOxx. Details on the events available and their parameters are available in the online help. Please use "SetAttributeValue" carefully, since it is trigger in any kind of interaction that results in an update of an attribute on instance and model level (moving of objects, drawing, etc.). The attached screenshot shows the result of the above.Wilfrid Utz2013-04-09T05:33:04ZRE: Events: How can performance and stability of event implementation be teWilfrid Utzhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=185892013-04-08T12:24:31Z2013-04-08T12:21:39ZFor testing of performance and scalability, a automated testscript as the one below can be used to go through the view modes, analyse the classes available in each and create a predefined number of objects in the model currently open. For the test runs, the number of for instances per class and view have been defined in the header, additional code to be performed after each instance creation can be added accordingly. The script helps when test-driving the up-scale of the implementation to potentially analyze clitches in performance when it comes to event implementation.<br /><br /><em>Highlights:</em><br />- Configuration of model size<br />- Validation of "core" events and performance<br />- Additional custom code can be added<br />- Log file is written to a dockable window in the modelling tool, and provided at the end as an EDITBOX to save and further analyse<br /><em><br />Limitations:</em><br />- Relation classes are currently not considered and need to be tested separetly<br /><br />To run the code, integrate it in a menu item or run directly from the AdoScript Debug Shell:<br />EXECUTE file: ("PATH_TO_LOCAL_FILE\\NumberOfObjects.asc")<br /><br /><div class="code"><span class="code-lines"> 1</span># create a debug window to display result messages<br /><span class="code-lines"> 2</span>SETG sDebugWINID: ("debug")<br /><span class="code-lines"> 3</span>SETG nNumberOfObjects: (40)<br /><span class="code-lines"> 4</span>SETG lSkipClasses: ("Organisation")<br /><span class="code-lines"> 5</span>SETG xPos: (2)<br /><span class="code-lines"> 6</span>SETG yPos: (2)<br /><span class="code-lines"> 7</span>SETG nCounter: (1)<br /><span class="code-lines"> 8</span>SETG logMessages: ("")<br /><span class="code-lines"> 9</span>DEBUG_PRINTER debugmessage: ("START OF LOGGING for " + STR nNumberOfObjects + " each model contruct per view") <br /><span class="code-lines">10</span>CC "AdoScript" CREATE_OUTPUT_WIN winid: (sDebugWINID) title:"Performance Debug"<br /><span class="code-lines">11</span>DEBUG_PRINTER debugmessage: ("###############################################") <br /><span class="code-lines">12</span>DEBUG_PRINTER debugmessage: ("New performance test started") <br /><span class="code-lines">13</span># make sure that a model is loaded before starting<br /><span class="code-lines">14</span>CC "Modeling" GET_ACT_MODEL<br /><span class="code-lines">15</span>DEBUG_PRINTER debugmessage: ("modelid: " + STR modelid) <br /><span class="code-lines">16</span>IF (modelid = -1) {<br /><span class="code-lines">17</span> DEBUG_PRINTER debugmessage: ("No test model open .... EXITING")<br /><span class="code-lines">18</span> EXIT<br /><span class="code-lines">19</span>}<br /><span class="code-lines">20</span>SET nTestModelID: (modelid)<br /><span class="code-lines">21</span> # get model info<br /><span class="code-lines">22</span>CC "Core" GET_MODEL_INFO modelid: (nTestModelID)<br /><span class="code-lines">23</span>DEBUG_PRINTER debugmessage: ("modeltype: " + modeltype) <br /><span class="code-lines">24</span>SETL sTestModelType: (modeltype)<br /><span class="code-lines">25</span># get all view modes<br /><span class="code-lines">26</span>CC "Core" GET_ALL_MODES_OF_MODELTYPE modeltype: (sTestModelType) sep:"|"<br /><span class="code-lines">27</span>DEBUG_PRINTER debugmessage: ("available_view_modes: " + modenames) <br /><span class="code-lines">28</span>SETL lViewModes: (modenames)<br /><span class="code-lines">29</span># interate through modes<br /><span class="code-lines">30</span>FOR sModeName in: (lViewModes) sep:"|" {<br /><span class="code-lines">31</span> CC "Modeling" SET_VIEW_MODE mode-name: (sModeName)<br /><span class="code-lines">32</span> CC "Core" GET_ALL_CLASSES_OF_MODE modeltype: (sTestModelType) modename: (sModeName)<br /><span class="code-lines">33</span> DEBUG_PRINTER debugmessage: ("available_classes: " + classids) <br /><span class="code-lines">34</span> SETG lClassIDs: (classids)<br /><span class="code-lines">35</span> # iterate through all classids<br /><span class="code-lines">36</span> FOR sClassID in: (lClassIDs) {<br /><span class="code-lines">37</span> # get the class name and check whether a relation<br /><span class="code-lines">38</span> CC "Core" GET_CLASS_NAME classid: (VAL sClassID)<br /><span class="code-lines">39</span> # if relation, skip<br /><span class="code-lines">40</span> IF (isrel != 1) {<br /><span class="code-lines">41</span> FOR varName from:1 to: (nNumberOfObjects) {<br /><span class="code-lines">42</span> SETL sNewObjName: (classname + "-" +STR nCounter)<br /><span class="code-lines">43</span> CC "Core" CREATE_OBJ modelid: (nTestModelID) classid: (VAL sClassID) objname: (sNewObjName)<br /><span class="code-lines">44</span> DEBUG_PRINTER debugmessage: ("create object: " + sNewObjName) <br /><span class="code-lines">45</span> CC "Modeling" SET_OBJ_POS objid: (objid) x: (CM xPos) y: (CM yPos)<br /><span class="code-lines">46</span> DEBUG_PRINTER debugmessage: ("position object: " + sNewObjName) <br /><span class="code-lines">47</span> ################# SECURE TROPOS SPECIFIC CODE TO IMMIDATE THE EVENT CODE - START #################<br /><span class="code-lines">48</span> CC "Core" SET_ATTR_VAL objid: (objid) attrname: ("_View") val: (sModeName)<br /><span class="code-lines">49</span> DEBUG_PRINTER debugmessage: ("SECURETROPOS_SPECIFIC - set view mode in object: " + sNewObjName) <br /><span class="code-lines">50</span> ################# SECURE TROPOS SPECIFIC CODE TO IMMIDATE THE EVENT CODE - END #################<br /><span class="code-lines">51</span> SETG xPos: (xPos + 2)<br /><span class="code-lines">52</span> SETG nCounter: (nCounter + 1)<br /><span class="code-lines">53</span> }<br /><span class="code-lines">54</span> }<br /><span class="code-lines">55</span> SETG xPos: (2)<br /><span class="code-lines">56</span> SETG yPos: (yPos + 2)<br /><span class="code-lines">57</span> }<br /><span class="code-lines">58</span> SETG yPos: (2)<br /><span class="code-lines">59</span> DEBUG_PRINTER debugmessage: (".... SWITCHING VIEW MODE ....") <br /><span class="code-lines">60</span><br /><span class="code-lines">61</span>}<br /><span class="code-lines">62</span>CC "AdoScript" EDITBOX text: (logMessages) title:"Logged information" oktext:"Close" fileeditor<br /><span class="code-lines">63</span><br /><span class="code-lines">64</span>DEBUG_PRINTER debugmessage: ("###############################################") <br /><span class="code-lines">65</span><br /><span class="code-lines">66</span><br /><span class="code-lines">67</span><br /><span class="code-lines">68</span>#*************************************************************************************#<br /><span class="code-lines">69</span># #<br /><span class="code-lines">70</span> PROCEDURE DEBUG_PRINTER debugmessage:string<br /><span class="code-lines">71</span> #<br /><span class="code-lines">72</span>#*************************************************************************************#<br /><span class="code-lines">73</span><br /><span class="code-lines">74</span>{<br /><span class="code-lines">75</span> CC "Application" GET_DATE_TIME date-format:"DD.MM.YYYY" time-format:"HH:MM:SS"<br /><span class="code-lines">76</span> CC "AdoScript" OUT winid: (sDebugWINID) text: (time + ": " + debugmessage + "\n")<br /><span class="code-lines">77</span> SETG logMessages: (logMessages + time + ": " + debugmessage + "\n")<br /><span class="code-lines">78</span>}<br /><span class="code-lines">79</span>#*************************************************************************************#<br /></div>Wilfrid Utz2013-04-08T12:21:39ZEvents: How can performance and stability of event implementation be testedhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=185832014-03-27T12:30:31Z2013-04-08T12:02:49ZHow is it possibile to validate the scalability of event implementations in ADOxx? In the test-case at hand, a model with 100 objects in different view modes is established, the view switch takes time to be performed. The event used is "AfterUpdateGrObjects".2013-04-08T12:02:49ZRE: Documentation: Attribute ModiWilfrid Utzhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=184822013-04-02T09:51:55Z2013-04-02T09:51:55ZAs a configuration parameter, the attribute and class filter can be used to allow users to define which attributes to consider (per class) and take into the export for documentation. In addition, attributes can be defined in accordance with the class attribute that relates to the documentation setting (as in line 1 of the attached screen): the class-atttribute “Doku” is used when running documentation (same syntax as AttrRep) and is evaluated. If not existing, the AttrRep is used as a fall-back.<br />The “Documentation” MODE that is specified in the first line as corrsponding to “Doku” needs to be available as a mode in the modeltype definition ("Modi").Wilfrid Utz2013-04-02T09:51:55ZDocumentation: Attribute Modihttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=184772014-03-27T12:24:04Z2013-04-02T09:51:06ZThis question is similar to the previous one - how to customise which attributes of modelled objects to show on the exported document? When WORD document is exported it shows model's objects, their types and names. All of the included objects have custom attributes and none of them are shown on the document, except for one object. After searching for differences between different attributes I could not identify being anything special about the attribute which was included into the documentation (i.e. type - SystemActor, name - System, after it a table with single attribute and its value is displayed). There might be a relation to the attribute modes (thus ATTRIBUTEMODI), but it is not clear from the documentation how to use these attribute modes in other contexts than outlined in the sections "Defining the menu entries" and "Defining attribute modes" of the documentation.2013-04-02T09:51:06ZRE: Position of Endpoints (Start/Endobject)?Wilfrid Utzhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=179572013-03-19T12:34:47Z2013-03-19T12:34:47ZThe position of the endpoints of a connector relates to the center-position of the end-point class(es). The center position is used initially to start the connector and this can be modified afterwards by the modeller by dragging the connector. <br />A Solution for a "bottom-first" implementation is to shift the center of the modelling class to the bottom of the object by adjusting the Y coordinates accordingly.Wilfrid Utz2013-03-19T12:34:47Z