Remove entity with generalization and keep data

1
Hi all! Currently i have a customer challenge for which I don't have found a solution yet. Maybe somebody here has a great idea or can put me in the right direction. I will use a fictional example, to describe the problem as clear as possible. Let's say I have an entity called 'Employee'. This entity has 'Account' set as it's generalization and account on it's turn is a generalization of 'System.User'. The 'employee' entity is a big one, with a lot of attributes and associations due to the nature of this object. Now let's say I also created 'SuperEmployee' in the past, which has 'Employee' set as it's generalization. The 'SuperEmployee' only has 1 attribute of itself, the rest is via the generalization. Now I come to the conclusion that the entity 'SuperEmployee' is obsolete and I want it to be removed. However, I do not want to loose the data that is already there in the generalization table(s), such as employee. So basically, I want to "downgrade" my SuperEmployee to a normal employee, without loosing data, associations and the CreatedBy and OwnedBy in al the >100 other entities in my model.... Hacking the submetaobject name in the database will not work, because the GUID still references to the 'SuperEmployee' object. Cloning the object will take a lot of effort (and probably some issues with double usernames) and will still loose CreatedBy and OwnerBy data... Any help or smart idea's will be appreciated very much!
asked
4 answers
1

Hi Rene, here's an idea for a solution

  • Add custom CreatedBy and OwnerBy attributes to you employee entity
  • Copy all the original CreatedBy and OwnerBy to the custom attributes via a conversion script
  • Replace all the usages of CreatedBy and OwnerBy with the custom attributes
  • Make sure the custom CreatedBy and OwnerBy are populated via an on-change microflow
  • Export SuperEmployees to Excel
  • Remove the SuperEmployees (because the username is unique...)
  • Import the SuperEmployees into the Employees entity via an Excel import

 

Hope that helps.

answered
0

I would solve it differently. Retrieve the SuperEmployees, iterate over them. In the iteration create a new employee object and copy all the data including all the references etc over to the new object. Also retrieve all the objects the SuperEmployee has a reference with because these also needs to be update to the new employee object. It is indeed probably quite some work depending on how many references the object has. You could try the community commons deepclone but I am not 100 procent sure it works wit generalizations. Normally you need two objects of the same type but in this case it might work.

Regards,

Ronald

 

answered
0

I agree with Ronald. Do all of this in a microflow that you run one time to transform your data. This way you can create a new employee object for every super employee, and write all of the super employee associations to the new employee object.

You also talked about preserving the createdBy and OwnerBy system attributes. I dont think you can write to these attributes so what Thijs mentioned about creating your own attributes to store this data would be best.

In your microflow you can retrieve all employees and write the system createdby/owner attributes to the newly created attributes. Then retrieve all super employees and create employee objects for each super employee.  

answered
0

Hi Ronald and Austin, thanks for your responses! Unfortunatly, my story\question still seems to be unclear (or I misunderstand the responses). I know\understant I can re-create the employees in the correct entity by making a conversion and iterate over all the SuperEmployees. I consider that as basic mendix knowledge. I also thought already about several ways to save the CreatedBy and ChangedBy information for the user object itself, that is also clear.

But, apart from the fact that iterate and convert all SuperEmployees (+20 references, +60attributes) is a long work\proces, the true question how to prevent the loss of CreatedBy and ChangedBy on all the other identities in the application is unanswered.

Let's say the application also has an entity called "Order". On that entity the 'Store owner' and 'Store changeby' options are activated. (Technically, it means that the platform will write the GUID of the creating or changing user in the table of "Order"). When I delete the SuperEmployee enitity after re-creating the users like suggested, the CreatedBy and the Changed by of all the Order object will be set to null. Now imagine that this will be done for all the +100 entity's in a application that track CreatedBy and ChangedBy....

So that is the real question and why I am looking in a way of "Downgrading" a generalization object.

answered