Page 1 of 1

put xml in template job file and zip that file

Posted: Wed Feb 20, 2013 10:42 am
by ppmg


Hi there,



As i am quite the newbie here, i have no starting point in how to tackle the following question:



I have a static template folder that contains files/folders (like this:)



TEMPLATE

FOLDER_A

file_a.xml

file_b.xml

FOLDER_B

image_a.eps





What i would like to do in Switch, is this:



a xml file 'file_a.xml' is submitted by a customer.



In this case i want the file 'file_a.xml' in my template folder to be replaced by the customer's 'file_a.xml'



then the whole folder should be zipped and the zip submitted to a ftp.



Looks as quite the challenge for me, tried some things with Assemble job, but can't make it look at my static template folder...



Any ideas?



thanks in advance,



Leon Dona













put xml in template job file and zip that file

Posted: Wed Feb 20, 2013 12:15 pm
by freddyp
If you want to pick up a static job (file or folder) you have to use "Inject job".



First of all you start with an input folder with two connections, one that goes to "Inject job", another one going to a folder (include all jobs on both connections). Name the injected job after itself, not after the incoming job or the folder will be renamed to the name of the XML file including the extension.



In "Inject job" you have to inject a specific job, namely your static template folder. Note that the settings for "Inject job" are on the outgoing connection, not on the element itself. After the inject job you use an "Archive hierarchy". Make sure to set the "Folder level" high enough. Now you have a copy of your template in a specific location.



On the other branch you direct the incoming XML to the same location by using "Set

hierarchy path" and a connection from there into the same hierarchy as the injected job.



Take care: you want your template to be copied into the hierarchy before the XML that arrived in the flow, and as the template folder is a lot bigger than the XML that is not going to happen. To counter that you let the incoming XML wait a little bit by putting a "Hold job" before the "Set hierarchy path". The setting to use for that is "Space jobs apart" and can be found on the outgoing connection of "Hold job".



There is one more thing: you cannot have outgoing connections on "Archive hierarchy" and you still have to continue to zip everything. This feature will be added to the next update of Switch that we are working on, but for the time being you will have to make a second flow that continues with the zipping and the ftp'ing. This second flow has a "Submit hierarchy" at the beginning pointing to the same path as the hierarchy at the end of the first flow. Tip: do not strip the unique name at the end of the first flow, so all your metadata is still available in the second flow.



Freddy

put xml in template job file and zip that file

Posted: Thu Feb 21, 2013 10:26 am
by ppmg
Thanks Freddy, i'm making great progress!



Just one little problem left, i think i'm not using 'set hierarchy path' the right way. I want the file_a.xml to replace the file in my template, what it does now is that it adds the file at top level.



What i want:



TEMPLATE

FOLDER_A

file_a.xml <-- replaced by costumer's version

file_b.xml

FOLDER_B

image_a.eps



What i get now:



TEMPLATE

file_a.xml <-- Costumer's file

FOLDER_A

file_a.xml

file_b.xml

FOLDER_B

image_a.eps



Thanks again for your help sofar.



Leon

put xml in template job file and zip that file

Posted: Thu Feb 21, 2013 4:45 pm
by ppmg
Got it!



I had to strip the unique name at the end of the first flow, then the file will be punt into place.



thanks,



Leon

put xml in template job file and zip that file

Posted: Fri Feb 22, 2013 5:00 pm
by freddyp
Ah yes of course, not stripping the unique name as I suggested means that the XML file has a different name than the one it is supposed to replace. I did not try out the whole flow, but I am glad you figured it out by yourself, just like you did with the fact that FOLDER_A had to be added to the hierarchy path as well.



Freddy