So the scenario is: I have an SDE featureclass with attributes A,B,C. User has shapefile with attributes A,bob,C,D. I want to create a workspace to be run on FME server that will allow the user to map one, many, or none of the fields. I'm not sure how to go about this. I also want to map the matched ones so the users will only have to match the remaining, but still give them the option to change the mapped one if they so choose. Thanks.
Hi @tnarladni,
I believe that use the publish parameter option. Link Publish Parameter
Once configurated your Publish Parameter in FME Workbench and publish it to FME Server.
On FME Server the user can to choose to map field to run your workspace.
Thanks,
Danilo
Â
Â
Â
From your example I would say: if the attributes do not match but the writer is set to automatic, it is not a problem that some attributes might be missing?
Â
For example, a user can create a table consisting of "RoadName", "SurveyCo", and "SurfveyDate" columns; another user can create a table consisting of "RoadName" and "SurfaceMat" columns; and so on.Â
Â
From your example I would say: if the attributes do not match but the writer is set to automatic, it is not a problem that some attributes might be missing?
Â
Â
Â
For example, a user can create a table consisting of "RoadName", "SurveyCo", and "SurfveyDate" columns; another user can create a table consisting of "RoadName" and "SurfaceMat" columns; and so on.Â
Â
Â
Â
Â
Â
Assume the destination feature type has the attributes A, B, and C.Â
- When a source data has attributes A, B, C, A, B, C will be mapped to the destination attributes and D will be just ignored.
- When a source data has attributes A, C: A, C will be mapped and B will be missing.
Â
Â
Â
Â
Assume the destination feature type has the attributes A, B, and C.Â
- When a source data has attributes A, B, C, A, B, C will be mapped to the destination attributes and D will be just ignored.
- When a source data has attributes A, C: A, C will be mapped and B will be missing.
Â
Â
Â
@tnarladni visited live chat, and gave some clarification on the scenario. Let me see if I can explain:Â
Say the destination SDE Schema is A, B, C, D, EÂ
User shapefile schema could be different from destination, and it also varies from time to time. e.g. it could be A, bob, C, D, or A, B, cat, dog.Â
We need the matching attribute names to be automatically mapped, meanwhile allow user to manually map from bob -> B, cat ->C, dog->D, at run time.Â
When source schema doesn't have any attribute to map to a particular attribute on the destination, it's ok to write missing value to that attribute. (E could be missing)Â
I'm also try to brainstorm some ideas with colleagues, but any suggestions from anyone on the community would be much appreciated.Â
Hi @tnarladni,
If your user is able to edit a local CSV file at each run in order to match whichever attribute names vary between the source and destination schemas, you may be able to set up a SchemaMapper in your translation. Take a look at this article for some ideas on how to set this up. In its simplest form the CSV is two columns, one for the Source attribute name, and one for the Destination attribute name.
Here's an example:
SourceDestinationAAbobBCCDogDThe SchemaMapper reads this file at each run, so it would need to be edited and saved before running, and will likely need to be edited each time as long as the schema varies each time.
Hope this helps spark a solution!
Thanks,
Â
NathanÂ
Hi @tnarladni,
If your user is able to edit a local CSV file at each run in order to match whichever attribute names vary between the source and destination schemas, you may be able to set up a SchemaMapper in your translation. Take a look at this article for some ideas on how to set this up. In its simplest form the CSV is two columns, one for the Source attribute name, and one for the Destination attribute name.
Here's an example:
SourceDestinationAAbobBCCDogDThe SchemaMapper reads this file at each run, so it would need to be edited and saved before running, and will likely need to be edited each time as long as the schema varies each time.
Hope this helps spark a solution!
Thanks,
Â
NathanÂ
Hi @tnarladni,
One of the suggestions I got from the team is along the same lines of @NathanAtSafe's thought, but using a separate workspace to scan for the input file's schema, and present it in a web form (that you'll need to create) for users to select desired mapping. and this generates a csv file that will be used in a SchemaMapper in a second workspace.
Our Easy Geocoder example uses a very similar idea. And we have detailed information, including some sample workspace and source code for the web form in this link: https://knowledge.safe.com/articles/1116/easygeocoder-data-driven-self-serve-data-transform.html
Hopefully this gives you a good starting point.
If the number of destination attributes was not so large, I would create published parameters corresponding to each destination attribute, so that the user can specify source attribute names to be mapped to the destination attributes for each, like this.
Then, in the workspace, rename the source attribute names based on the parameter values immediately after reading from the source dataset. Maybe writing a Python script would be an easy way to perform renaming.
# PythonCaller Script Example
import fme
class AttributeMapper(object):
    def __init__(self):
        # Destination attribute names = published parameter names
        destAttributes = Â
            'AccessRdId',
            'NewExist',
            'PermTemp',
            'PublicPriv',
            'RoadName',
        ]
        self.map = {}
        for dest in destAttributes:
            src = fme.macroValuesidest]
            if src and src != dest:
                self.map src] = dest
       Â
    def input(self, feature):
        for src, dest in self.map.items():
            null, missing, type = feature.getAttributeNullMissingAndType(src)
            if null:
                feature.setAttributeNullWithType(dest, type)
            elif not missing:
                feature.setAttribute(dest, feature.getAttribute(src))
            feature.removeAttribute(src)
        self.pyoutput(feature)
Hi @tnarladni,
One of the suggestions I got from the team is along the same lines of @NathanAtSafe's thought, but using a separate workspace to scan for the input file's schema, and present it in a web form (that you'll need to create) for users to select desired mapping. and this generates a csv file that will be used in a SchemaMapper in a second workspace.
Our Easy Geocoder example uses a very similar idea. And we have detailed information, including some sample workspace and source code for the web form in this link: https://knowledge.safe.com/articles/1116/easygeocoder-data-driven-self-serve-data-transform.html
Hopefully this gives you a good starting point.
Â
Â