Author Topic: Transform an Instance to Class  (Read 5008 times)

Viking

  • EA User
  • **
  • Posts: 453
  • Karma: +2/-2
    • View Profile
Transform an Instance to Class
« on: January 16, 2017, 09:49:34 pm »
We currently think about using Classifier-Instances for out AsIs-ToBe-Modelling.

Our concept prescribes that an instance, which represents a ToBe artefact, will become the class one day. The class represents the AsIs.

Question: is there a way to transform an Instance to a Class? I cannot imagine that this is possible for several reasons (e.g. because the classifier and its instances are different entities, the instance would replace its own class, what happens to the other instances?, etc.). But my colleague says, "you never known with SparxEA".

V

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Transform an Instance to Class
« Reply #1 on: January 17, 2017, 12:13:56 am »
Not out of the box (only vice versa). But a little script or add-in can do that easily.

q.

Viking

  • EA User
  • **
  • Posts: 453
  • Karma: +2/-2
    • View Profile
Re: Transform an Instance to Class
« Reply #2 on: January 17, 2017, 08:15:29 pm »
Not out of the box (only vice versa). But a little script or add-in can do that easily.
q.

Many thanks, q.

Can this really work? If I delete a class manually, Sparx also deletes the corresponding instances. Is there no referential integrity in the database (soory for asking, I do not know the datamodel)?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Transform an Instance to Class
« Reply #3 on: January 17, 2017, 08:31:18 pm »
An instance has a ClassifierID which is the internal ID of the classifying element. If you delete a class (manually or via API), EA will also remove those references. So these objects are left unclassified. If you want to create a class from an instance, you create a new class (with whatever you invent from the instance, which usually only has a scaffold from its meant classifier) and the classify the instance with your new class.

q.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: Transform an Instance to Class
« Reply #4 on: January 18, 2017, 09:40:18 am »
If I delete a class manually, Sparx also deletes the corresponding instances.

If that's the case, then what you are calling an instance isn't what I would call an instance. Create an object diagram, create an "Object" element, select it, Ctrl+L, select a classifier, and your object is an instance of the selected classifier. This object will not be deleted when you delete the classifier.
The Sparx Team
[email protected]