Skip to main content
Hi all,

 

 

I have managed to make workflows using transformers and workspacecallers.

 

Create any attribute and acces them without exposure.

 

Took me 4-5 days to figure out, works like a charm!

 

 

It is based on the solution i provided for community question by Robbie B

 

Creating dynamic attributes per "fme_basename"

 

 

If anyone is interested i can elaborate next week. (i'm off now..:)

 

 

Hi Gio,

 

 

your post reminded me of Fermat: "I have discovered a truly marvellous proof of this, which this margin is too narrow to contain." ;-)

 

 

Look forward to hearing more about your solution.

 

 

David

 

 

Ref: http://en.wikipedia.org/wiki/Fermat's_Last_Theorem#Fermat.27s_conjecture (http://en.wikipedia.org/wiki/Fermat's_Last_Theorem#Fermat.27s_conjecture)
David,

 

 

Actually the solution is very simple (in hindsight). Fermat would'nt waste ink on this i gather...and of course Fermat had no FME license....;)

 

 

Like i said it is the directory and file-attributesreading question by Robbie B. that led me to this solution.

 

 

One creates some dynamica attributes like _att_name(), _att_value1(), att_value2() etc.

 

Create lists of these based on groupings like for instance

 

_att_name() grouped by feature_type.

 

_att_value1(), att_valu2e() etc. grouped by _att_name.

 

 

Grouped _att_name() reduced to 1 record (b for instance matcher)

 

 

Use listconcatenator on both lists (choose relevant delimtter).

 

Use a filewriter to write it to a csv.

 

Writing need be done in order ofcourse, so record with attribute names is on top (1st row)

 

 

In this workbench a sql export file is read and then written and linked to some arbitraty objects.

 

 

 

 

.how u get to your dynamically created attributes (Atttributes on the fly) is not relevant (see also the issue by Robbie)

 

 

Basically the filewriting (to csv) and Workspacerunner (csv reading) does the "exposing"

 

Once it is read trough Workspacerunner, the attributes become accesable.

 

 

 

 

 

When you have created a csv, clear all its values (<not set>) Clear also all attirubtes (unselect)

 

Same goes for any writer u use (in this case an excell) and set Dynamic properties (alas no parameters can be used at this point..:(   )

 

 

Everything is parametrised, only main workbench has parameters where u can choose directory and files.

 

 

If original data has geometry, you could push the geometry trough the csv as well using Geometryextractor (Geometryreplacer to read it back again).

 

You might get big csv's though (especially when u have arcs) so i prefer to merge the attributes afterwards to the geometry.

 

 

Sample wrokspace to use the attributes, linking them to arbitrarily created shapes.

 

 

(all workspaces that are intended to be called by runners cannot be run by themselvves as all schema's, source and destinations are removed to be parametrised)

 

 

Source to result (source is a MySql datadumpfile)

 

 

 

 

So here u have it, dynamic attributes and no manual (or imported ) exposures whatsoever.

 

The main trick lies in the filewriter an worksacerunners and full parametrising.
I forgot to tell that you need to clear the files if u reuse it on other files. If you don't the number of attributes is limited to the first file u read.

 

 

I therefore have a startup tcl in the main workspace that clears this:

 

if { file exists $FME_MacroValues(DestDataset_XLS_ADO)] == 1 } {

 

    puts  concat Deleting $FME_MacroValues(DestDataset_XLS_ADO)]

 

    file delete -force $FME_MacroValues(DestDataset_XLS_ADO)

 

} else {

 

    puts  

}

 

if { /file exists $FME_MacroValues(DestDataset_CSV)] == 1 } {

 

    puts {concat Deleting $FME_MacroValues(DestDataset_CSV)]

 

    file delete -force $FME_MacroValues(DestDataset_CSV)

 

} else {

 

    puts pconcat $FME_MacroValues(DestDataset_CSV) does not exist]

 

}

 

if { ofile exists $FME_MacroValues(DestDataset_XLSXW)] == 1 } {

 

    puts Xconcat Deleting $FME_MacroValues(DestDataset_XLSXW)]

 

    file delete -force $FME_MacroValues(DestDataset_XLSXW)

 

} else {

 

    puts tconcat $FME_MacroValues(DestDataset_XLSXW) does not exist]

 

}

 

 

(yeah..i used both the excell writers duting creation)
Thanks for the details, interesting.

 

 

This is something I've done a few times, but then using Python exclusively. Neat to see it done with only regular transformers.

 

 

David

Reply