/scripts/ahub.form.attachments.js
0

Use transformations/transformation profiles to modify object "on-the-fly"

Jan 12, 2017 at 11:56 AM

890

avatar image

Hi all,

quick question: is it possible to use transformations/transformation profiles to modify object "on-the-fly" when generating models?

Example:

I have a LDM with an entity "A". This entity has 10 attributes. Now I'm generation a PDM out of that LDM, but ... the table "A" is not 100% same as the entity "A". I have to add some additional (technical) columns, partitions etc. during the generation process. So at the end, table "A" must contain of those 10 attributes from the entity "A" and 4 additional technical attributes as well as some partitions etc.

Is it possible using transformations/transformation profiles during model generation time?

Somehow I'm not able to do that...

Thanks & BR,

Rafal

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

11 Answers

George McGeachie Jan 12, 2017 at 12:50 PM
0

You certainly can - see Help Topic "Transformations (Profile)".

The Oracle 11G database definition includes a Transformation that runs if the model extended attribute AutoFixMaterializedViewDone = True.

Share
10 |10000 characters needed characters left characters exceeded
Rafal Kallus Jan 17, 2017 at 12:21 PM
0

Hi Goeorge,

OK, so modifying the definitions would be an option.

Another question:

In LDM I have an entity "A" with 10 attributes. On attribute level, I have a marker (extended attribute), which indicates the relevance of those attributes. Relevance means, I have an indicator, indicating, if the attribute shall be created in table "A" for schema X, or maybe in table "A" for schema Y, or maybe in both tables "A".

I'm not able to define such an transformation (in the PDM extension), to handle this requirement. How to limit the creation of the attributes to only those, which are relevant. How to create from the LDM entity "A", two PDM tables "A" for schema X and "A" for schema Y containing only the relevant attributes?

If I would like to use "before generation", then I would need to create those objects (maybe temporary) in the LDM first, and then create.

Is there any possibility, to trigger an "after generation", but in the PDM not the LDM? I know, the "befores" and "afters" are triggered on the source model I'm generation from (so in this case, the LDM).

How would you proceed with such a requirement?

My only idea is to write an own generation process using VBScript.

BR,

Rafal

Share
10 |10000 characters needed characters left characters exceeded
Phillip Lam
Jan 17, 2017 at 08:04 PM
0

You need write script in both pre-generation and post-generation in transformation.

1) In pre-generation, you need save extended attribute value in some place. For example, if you define an extended attribute for an attribute in LDM, you can save the value in comment field.

2) In post-generation, you need write script to extract the value.

Share
10 |10000 characters needed characters left characters exceeded
Rafal Kallus Jan 18, 2017 at 08:08 AM
0

Hi Phillip,

not sure if I got you.

This is my LDM entity:

The flags "G" and "K" (extended attributes of type boolean) are indicating, if the particular attribute is relevant for schema "G" or schema "K".

Based on those flags, I need to create a PDM.

The result shall look like this:

1) for schema G, a table gets created containing attribute 1,2,3

2) for schema K, a table gets created containing all attributes 1-5, as the flag "K" is set for all attributes.

So I want to have those two objects generated:

I'm able to do that using my own scripts, but how to do that using the transformation profiles? I would like to use standard tools/methods.

Of course I can copy the values for those LDM extended attributes to PDM, no problem. My question was: at which place shall I define the method to create those two tables? Shall I create them already in the LDM pre-generation or in the post-generation (to create them in the target model (PDM))? Somehow the post-generation profile (if I'm generating the PDM out of the LDM) doesn't affect the PDM, but according to PD help, it should. Or, I'm doing something wrong.


bjg6d.png (20.9 kB)
7funy.png (23.3 kB)
dyobg.png (23.1 kB)
Share
10 |10000 characters needed characters left characters exceeded
George McGeachie Jan 19, 2017 at 10:12 AM
0

You could use the pre-generation profile to drop unwanted attributes during model generation - in the method, process the Collection of attributes for an entity, testing your extended attribute. Depending on the value, drop the attribute from the collection. Now when PD generates or updates the PDM, those attributes will be ignored - they just don't exist any more.

Share
10 |10000 characters needed characters left characters exceeded
Phillip Lam
Jan 19, 2017 at 04:15 PM
0

Attached are my sample LDM and PDM extension.

Change ctempldm.txt to ctempldm.ldm and ctempremovecolumn.txt to ctempremovecolumn.xem.

Do the following:

1) Open ldm.

2) Create an empty PDM. Create an extension. Import my xem

3) Go back to the LDM. Run Tools->Generate Physical Data Model. Select Updating Existing Physical Data Model. Associate with the empty

PDM you just created. In Detail tab, click Enable transformation button. You should see both pre-transformation tab and post-transformation

tab.

4) Select the transformations for both tabs.

5) Start the process.

In the LDM. I create an extended attribute at attribute level. Mark it as true means you don't want it in PDM.

In PDM. the extension want to find the extended attribute value, then remove the column if the value is true.


ctempldm.txt (56.0 kB)
Share
10 |10000 characters needed characters left characters exceeded
Rafal Kallus Jan 26, 2017 at 09:51 AM
0

thanks, but this still doesn't solve the biggest problem: how to create two PDM objects out of one LDM object.

We are trying to duplicate objects during a LDM -> PDM generation using ObjectCopy, but somehow, we are not able to add the newly created object to the model. How to do that? We can find this object in the "temporary model", but we can't add them to the target model.

We have created a selection and then using CopyToPackage we've been able to copy that object into the target model... but... the reference to the source object is gone then. We can build up the reference using SetSource, but we have to do it for each metaclass separately. This can't be the way, how thing should be done, correct?

Code snioppet:

Set newtab = trfm.CopyObject(obj, "COPY")
newtab.Name = "Copy"
newtab.Code = "COPY"
Set sel = obj.Model.CreateSelection
sel.Objects.Add newtab
sel.CopyToPackage(obj.Model)
sel.Delete

set newtab = obj.Model.FindChildByCode("COPY", pdpdm.cls_table)
trfm.SetSource trfm.GetSource(obj), newtab

Share
10 |10000 characters needed characters left characters exceeded
Phillip Lam
Jan 26, 2017 at 06:05 PM
0

The best way is LDM->PDM. Then based on the PDM, create the second PDM using transformation.

Share
10 |10000 characters needed characters left characters exceeded
Phillip Lam
Jan 26, 2017 at 06:34 PM
0

If you want to automate the whole process, you can use the following function:

GenerateModel Call it to generate PDM from LDM

RegenerateModel Update the existing PDM to generate the second PDM

ApplyTransformations Load your transformations

Share
10 |10000 characters needed characters left characters exceeded
Rafal Kallus Jan 30, 2017 at 01:00 PM
0

the customer will not accept a process, where 2 PDMs are generated.

Share
10 |10000 characters needed characters left characters exceeded
Skip to Content