Adding reference models autonomously (two sided)Adding reference models autonomously (two sided)RE: Adding reference models autonomously (two sided)Fadi Al Machothttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=3558162015-08-10T09:16:47Z2015-08-10T09:10:44ZThank you Wilfrid,<br />what is the event to know if the user did click the "+" to add a reference model, or if he did click "*" to delete a reference model?<br />Currently, I am using the event "AfterEditAttributeValue" which works for both without knowing what is the clicked choice.Fadi Al Machot2015-08-10T09:10:44ZRE: Adding reference models autonomously (two sided)Wilfrid Utzhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=3552072015-08-06T09:30:22Z2015-08-06T09:30:22ZTo create such an reference as an inverse of the actual one created can be achieved using events and AdoScript. Please be aware that the system is already aware of the backlink itself, not explicitly as an attribute but within script and querying functionalities of ADOxx. To give you examples how to see this examples, please consider the following approaches already provided by the platform.<br /><br /><strong>+ UI - see pointing-at relations through the Object reference context menu entry:</strong> For any objects you can right-clcik and select the "Object reference" entry. This will return a clickable list of all other instances referencing the object. These objects can also be moved to others (all, single one) or used as a report<br /><strong><br />+ AQL: </strong>it is possible to query all pointers using AQL using "<--". An example would look like <br /><br /><div class="code"><span class="code-lines">1</span>{"Document-4711"} <--</div><br />This would return all pointing instance IDs to the object named "Document-4711".<br /><br /><strong>+ AdoScript: </strong>you can execute the AQL of above using AdoScript using the<br /><br /><div class="code"><span class="code-lines">1</span>CC "AQL" EVAL_AQL_EXPRESSION expr:strValue ( modelid:intValue | modelscope )<br /><span class="code-lines">2</span>#RESULT ecode:intValue objids:strValue<br /></div><br />or use the direct command <div class="code"><span class="code-lines">1</span><br /><span class="code-lines">2</span>CC "Core" GET_INCOMING_INTERREFS Target [ sourcemodelids:strValue ] .<br /><span class="code-lines">3</span>Target : objid:intValue | modelid:intValue .<br /><span class="code-lines">4</span># RESULT ecode:intValue reftext:references<br /></div><br /><strong>Automatically create INTERREFs based on INTERREFs<br /></strong>Using events, you can also perform the behaviour to create a (redundant) INTERREF. Please be aware that this script needs heavy testing and validation as there are assumption with respect to the metamodel and availability of attributes, but it should give you a hint how things are done. In addition, redundancies are not checked and corrected. Please let us know if you need further details here.<br /><br /><div class="code"><span class="code-lines"> 1</span>ON_EVENT "AfterEditAttributeValue" {<br /><span class="code-lines"> 2</span> # instid : integer ID of the changed instance.<br /><span class="code-lines"> 3</span> # attrid : integer Attribute ID.<br /><span class="code-lines"> 4</span> # modelid : integer ID of the model containing the changed instance.<br /><span class="code-lines"> 5</span> SET nCurrentObjID: (objid)<br /><span class="code-lines"> 6</span> SET nCurrentModelID: (modelid)<br /><span class="code-lines"> 7</span> SET nCurrentAttrID: (attrid)<br /><span class="code-lines"> 8</span> CC "Core" GET_CLASS_ID objid: (nCurrentObjID)<br /><span class="code-lines"> 9</span> SET nCurrentClassID: (classid)<br /><span class="code-lines">10</span> CC "Core" GET_ATTR_ID classid: (nCurrentClassID) attrname: "Participating"<br /><span class="code-lines">11</span> SET nParticipatingAttrID: (attrid)<br /><span class="code-lines">12</span> # only continue if the correct ID<br /><span class="code-lines">13</span> IF (nCurrentAttrID = nParticipatingAttrID) {<br /><span class="code-lines">14</span> # get the created INTERREF count<br /><span class="code-lines">15</span> CC "Core" GET_INTERREF_COUNT objid: (nCurrentObjID) attrid:(nParticipatingAttrID)<br /><span class="code-lines">16</span> # get value of latest<br /><span class="code-lines">17</span> CC "Core" GET_INTERREF objid: (nCurrentObjID) attrname:"Participating" index: (count)<br /><span class="code-lines">18</span> SET nTargetObjectID: (tobjid)<br /><span class="code-lines">19</span> SET nTargtClassID: (tclassid)<br /><span class="code-lines">20</span> # TODO: Potentially LOAD model to be able to modify<br /><span class="code-lines">21</span> # get the attribute ID of the target class attribute, assumption the INTERREF DOMAIN is correct<br /><span class="code-lines">22</span> CC "Core" GET_ATTR_ID classid: (nTargetClassID) attrname:"Participating"<br /><span class="code-lines">23</span> SET nTargetParticipatingID: (attrid)<br /><span class="code-lines">24</span> CC "Core" ADD_INTERREF objid: (nTargetObjectID) attrid: (nTargetParticipatingID) tobjid: (nCurrentObjID)<br /><span class="code-lines">25</span> }<br /><span class="code-lines">26</span>}<br /></div>Wilfrid Utz2015-08-06T09:30:22ZAdding reference models autonomously (two sided)Fadi Al Machothttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=3543832015-08-03T18:42:41Z2015-08-03T18:02:59ZWe have the following problem:<br />suppose we have an attribute of type "INTERREF" named "Participating" of class "XX", now, when we choose an instance "harold" of class "person" (which is created in an other model) as reference model to be set into "participating" of class "XX", <br /> then,<br />the attribute "participating" in the intance class "harold" should be set autonomously to the model "XX" as a reference.<br />Would you please post an example!<br />Thank you in advance.Fadi Al Machot2015-08-03T18:02:59Z