Is there a way to change sources in an aggregate without deleting and re-adding them

Is there a way to change sources in an aggregate without deleting and re-adding them

  

Hi there,

When I edit an aggregate and I change the datasource name from E.g. TableToBeDeleted to NewTable, the source now displays as NewTable(TableToBeDeleted). 
Furthermore even if the filter and join conditions appear to change, viewing them in the editor shows otherwise when the mouse-over tooltip displays. It appears that it is only a name change and not an actual data type change.

Why do I need to do this?

I have cloned an application so that I can use it as a template for a new application and am in the process of deleting some functionality and keeping other functionality.

Some of the entities will be kept, but with different attributes and types.

I renamed all the entities that I am interested in from [Entity] to [Entity]ToBeDeleted, which then updates all usages throughout the application. I am creating my own entities which are the same or almost the same as the entities of the original application.

I am currently going through aggregates that I want to keep and renaming them from [Entity]ToBeDeleted to [MyNewEnitityName].

Apparently this only works if I delete the [Entity]ToBeDeleted source, and actually add my own source. This becomes a bit of a headache with filters and joins.

Granted, just because i rename an entity i cannot expect the IDE to know that [Enitity]ToBeDeleted.CarType should now be changed to [NewEntity].BicycleType. 

Am I missing something, or is this just the way it is?

Thanks.

Solution

Hi,

To replace an old entity with a new one, what you can do is Find Usages of the entity you want to replace.

Then click the replace usages and select the new entity.


By doing this, you will replace the old entity with the new, even in aggregates.

Cheers,

João

Solution

Hi Albert,

There are a few misconceptions in your post, I hope I clear these up.

  1. "When I edit an aggregate and I change the datasource name (...) It appears that it is only a name change and not an actual data type change." - This is true, you cannot change the Entity in an Aggregate, you'll need to add the new Entity, add or fix the joins, etc. When you are changing the name of the Entity, you are giving it an alias, which is particulary useful when you join an Entity twice or more, or join some generic Entity like User, but you want to make clear it's signifying a customer, or the like.
  2. "Apparently this only works if I delete the [Entity]ToBeDeleted source, and actually add my own source. This becomes a bit of a headache with filters and joins." - There's a thing called "TrueChange", which is foremost the technology that checks whether everything in your code is in a sane state, and if not complains. However, TrueChange can also fix stuff that is broken e.g. after a rename or reference of things. In your case, if you delete your EntityToBeDeleted Entity, TrueChange will give you a gazillion errors, but if you then rename your new Entity to EntityToBeDeleted, it will fix everything as far as it can, replacing internally all occurences of the now deleted EntityToBeDeleted with that of the new EntityToBeDeleted. After that, you can rename the Entity back, and it should be in a state you want.
  3. "Granted, just because i rename an entity i cannot expect the IDE to know that [Enitity]ToBeDeleted.CarType should now be changed to [NewEntity].BicycleType." - Now that is true, if you have also changed Attribute names, you'll need to mostly manually fix it, but the trick I detailed above could work in this case as well (i.e. rename BicycleType to CarType, and back again).

Thank you João

Find-All-Usages and then using Replace-All-Usages does indeed achieve what i was looking for. And as pointed out, I'd still have to go fix some of the joins etc.

Killian, thank you for the information. Now I inadvertently know how to perform self joins as well. ;-)

Cheers

Albert