Changing the order of context variables

One Star

Changing the order of context variables

Is there a way to change the order of context variables after you created them? The only way how I could do it - is to export data and import again. But it is a lot of hassle. Is there an easy way to do it?
The other question - is there a way to create context variables on the project level? I have the same variables for each job (like $_context{DATA_DIR} or $_context{BIN_DIR}) and have to drop the context in each job separately. Is there an easier way to handle this?
Community Manager

Re: Changing the order of context variables

Hello
Is there a way to change the order of context variables after you created them? The only way how I could do it - is to export data and import again. But it is a lot of hassle. Is there an easy way to do it?

There is a sort function for the context variables.(see the screenshot).
The other question - is there a way to create context variables on the project level? I have the same variables for each job (like $_context{DATA_DIR} or $_context{BIN_DIR}) and have to drop the context in each job separately. Is there an easier way to handle this?

Yes, you can create context variable on project level. Click on Contexts on Repository viewer to create global variables for all jobs, then you can import the global variables in each job.(see screenshot2)
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Changing the order of context variables

Thank you for the quick reply!
1) sort is not enough for me, because the order of the variables is important. I have:
PROJECT_NAME='test'
ROOT_DIR='/projects/'
PROJECT_ROOT="$_context{ROOT_DIR}/$_context{PROJECT_NAME}"
BIN="$_context{PROJECT_ROOT}/bin"
as you can see - PROJECT_NAME should always come first, then ROOT_DIR etc.
The big problem is - if I forget to put some variable in the list and I want to add it in between - then the only way to do it is to re-create the whole tree again
2) It's a great feature, that you can create the context variables in the repository and then add it to the jobs. Although what I wanted - was different - I wanted to create a set of variables on the project level once and "forget" about them (I don't want to copy these context variables to each individual jobs again and again). The good example is above - these variables will be the same for all jobs in the project.
Thank you again for the great product and quick replies Smiley Happy
Employee

Re: Changing the order of context variables

I could have proposed you to use the tContextLoad (so that you can manage the context variables order in a dedicated external file) but the values are not evaluated, ie you wouldn't be able to set BIN variable based on previously set PROJECT_ROOT variable.
Another solution is to "simulate" a true context file, but a context file that you would create manually.
Here is the content of /home/pierrick/dev/tos/topics/topic2795/context.pl :
$_context{PROJECT_NAME} = 'myProject';
$_context{PROJECT_DIR} = '/tmp';
$_context{PROJECT_FILEPATH} = $_context{PROJECT_DIR}.'/'.$_context{PROJECT_NAME};
1;

One Star

Re: Changing the order of context variables

Excellent, thank you for your advice, I will definitely use this solution.
The only thing is - I will have to abandon the whole "context" system and use my own script, which is sad, because context looks pretty handy and user-friendly, it just missing this small features that I want.
Employee

Re: Changing the order of context variables

I will have to abandon the whole "context" system and use my own script, which is sad, because context looks pretty handy and user-friendly

You will indeed loose the auto-completion CTRL+Space if you don't declare context variables in the context view.
it just missing this small features that I want.

Only one advice : submit a feature request "order context variables". I'm sure it's a very simple dev.
One Star

Re: Changing the order of context variables

Sure, will do!