cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Difference between decorator vs translator

Former Member
0 Likes
4,667

Hello,

We can write decorators and translators in the impex. What the difference between decorator and translator. I am always writing translators and I didn't get in what situations need to write the decorator and what situations need to write translators. Could you any one explain when to write translators and when to write decorators?

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

andyfletcher
Active Contributor
0 Likes

A decorator is meant for changing the text of impex value to another text value before an Item has even been created.

A translator takes the text value (that may or may not have been decorated) and adds it to an Item.

Certainly you can do anything that a decorator is doing in your translator but the purpose of keeping them separate is so that you can chain them in different combinations.

E.g. in my (total contrived) example

You might have a decorator than appends the word TEST to all data in a column and that then gets passed to a translator. You can then decide to only specify the decorator when importing to your test environment but still use the same translator.

Former Member
0 Likes

Thanks for the clarification. I am good with your explanation.

Answers (3)

Answers (3)

Former Member
0 Likes

Thanks for your response. I can do the same thing with translator also right? Using translator also I can decorate the format ( from 23-45-67-89 to 23456789).

0 Likes

Hi ,

Just for the understanding purpose and mentioned in wiki, both are different decorators and translator. Decorator comes between parsing and translating.

Decorators are created to modify the value for a specific attribute. For example We get group ID in some format and want to search using group ID in database where we need to pass the string, so first we parse Input attribute to string and in case we get a string like 23-45-67-89, we use the decorator to format it to 23456789.

This is where we can use Decorators , to modify attributes. Refer ContentUnitCellDecorator, ClassificationGroupIDCellDecorator for better understanding

Former Member
0 Likes

Thanks for your response. I can do the same thing with translator also right? Using translator also I can decorate the format ( from 23-45-67-89 to 23456789).

Former Member
0 Likes
Former Member
0 Likes

Thansk for your quick response. I read that document already. I didn't get what cases we need to write decorators. Could you provide one example where I need to write decorator but not the translator?

Former Member
0 Likes

Two examples where I used a decorator were: 1) To create a unique identifier by concatenating other values of the impex row with an undescore separator(Business requirement). 2) To derive the value of an attribute based on some business logic using other values of the impex row. Example where translator were used: 1) One of the most common is to use the OOTB password encoding translator specifying the desired encoding.

Former Member
0 Likes

Thanks for the examples. The examples that you mentioned here I can do with translator also right? Why need to write decorator instead of translator?