Book a Demo

Author Topic: Embed existing event in existing Activity  (Read 6138 times)

Mr Stuff

  • EA User
  • **
  • Posts: 64
  • Karma: +0/-0
    • View Profile
Embed existing event in existing Activity
« on: June 30, 2017, 11:36:19 pm »
Try as I might I cannot change the parent of an event element to change it from a free-standing element to an embedded element - I know the diagrammatic aspect is separate, I mean I can't "move" the event element in the first place. (of course if I drag and drop digram elements parenthood is updated and in the project browser, but the element is not "embedded", mounted on the target activity) NB both elements are in the same package, but in general they might not be.

I have tried:

Code: [Select]
updateActivityWithEventToBeEmbeddedSQL = "update t_object set ParentID = " & actEl.ElementID & " where Object_ID = " & eventEl.ElementID
and

Code: [Select]
updateActivityWithEventToBeEmbeddedSQL = "update t_object set ParentID = " & actEl.ElementID & " where ea_guid = " & "'" & eventEl.ElementGUID & "'"
(with
Code: [Select]
Repository.Execute updateActivityWithEventToBeEmbeddedSQL, of course)

and in desperation, even though Geert said it didn't work in a code note I tried poking the parentID directly, then updating, refreshing and advising of repository changes ad nauseam also to no effect.

Any suggestions?

Thanks, Julian

PS parentID no "_" !?&$ is that the only exception???

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Embed existing event in existing Activity
« Reply #1 on: July 01, 2017, 01:58:32 am »
Rather than fiddling with SQL you should use the API in this case. What drives you to bypass it??

q.

Mr Stuff

  • EA User
  • **
  • Posts: 64
  • Karma: +0/-0
    • View Profile
Re: Embed existing event in existing Activity
« Reply #2 on: July 03, 2017, 04:06:51 pm »
Hi q.

I do avoid SQL when I can but in this case I was adapting Geert's synchronize code, and where it copies embedded elements from one activity to another the code is this

Code: [Select]
for each embeddedElement in element.EmbeddedElements 'copy embedded elements
'check if the embedded element is shown on this diagram
set embeddedDiagramObject = getDiagramObjectFromArray(embeddedElement.elementID, diagramObjects, count) ' get the diagramObject for the embedded element

if not embeddedDiagramObject is nothing then
'if yes then make a new embedded elementin the callingActivity
dim newEmbeddedElement as EA.Element
set newEmbeddedElement = callingActivity.EmbeddedElements.AddNew("","ObjectNode")
newEmbeddedElement.Name = embeddedElement.Name
newEmbeddedElement.Stereotype = "IntermediateEvent"
newEmbeddedElement.Update()
newEmbeddedElement.SynchTaggedValues "BPMN2.0","IntermediateEvent"
newEmbeddedElement.TaggedValues.Refresh
'Copy tagged values
copyTaggedValuesValues embeddedElement, newEmbeddedElement
' set the element id of the diagramobject to the new embedded element
'embeddedDiagramObject.ElementID = newEmbeddedElement.ElementID
'embeddedDiagramObject.Update
'for some reason the update doesn't want to work. so we do it the hard way
dim updateEmbeddedDiagramObjectSQL
updateEmbeddedDiagramObjectSQL = "update t_diagramobjects set object_id = "& newEmbeddedElement.ElementID &" where Diagram_ID = " & diagramObject.DiagramID & " and Object_ID = " & embeddedElement.ElementID
'Session.Output updateEmbeddedDiagramObjectSQL
Repository.Execute updateEmbeddedDiagramObjectSQL
end if
next

Where just before the SQL Geert says: "for some reason the update doesn't want to work. so we do it the hard way".

I think I also tried it with the API without success (after SQL issues) and also found it didn't work... but I could be wrong - if you have a working API snippet that would be proof it does in fact work. (NB EA 12.1 on W7 64-but)

Thanks,

Julian

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Embed existing event in existing Activity
« Reply #3 on: July 03, 2017, 04:29:35 pm »
You will need to change t_object.Object_Type from 'Event' to 'ObjectNode'. (Probably not the whole story, but one step closer...)
The Sparx Team
[email protected]

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Embed existing event in existing Activity
« Reply #4 on: July 03, 2017, 05:37:55 pm »
Without knowing Geert's framework it's almost impossible to follow your code. Also, in your original question you're trying to change the parent id for "something".  But you're talking about embedded elements. Now, those are two different pairs of shoes. Only a few elements are embeddable, like e.g. ports.  While (almost?) all elements can be made simple children (having the appropriate ParentID). So: what are you really trying to do?

q.

Mr Stuff

  • EA User
  • **
  • Posts: 64
  • Karma: +0/-0
    • View Profile
Re: Embed existing event in existing Activity
« Reply #5 on: July 05, 2017, 04:00:24 pm »
@KP @qwerty - thanks for the input; I got it working.

I do find it irksome that the Element Type displayed in the Properties pane ~e.g. the event/object node obfuscation is not the element type returned by the API, but, that's life ;)

Thanks again

Julian