Skip to main content
Solved

Read dynamic (from sde) and write to dynamic (mapinfo)


francis_m
Contributor
Forum|alt.badge.img+7
Hi!!!

 

I read a SDE (SQL) database and write dynamic MapInfo table (dynamic is because I want my output to be like my SDE Database).  Eveything is fine except with the "date" type attribute.  MapInfo write the date as a "DateTime" attribute.

 

But I'd like to have a simple "Date" attirbute.  Any idea how to force "Date" and not "DateTime" on a dynamic transformation using Dynamic Properities of the  SDE Geodatabase ?

 

thank you!

Best answer by takashi

Hi,

 

 

The strategy is:

 

- Read schema features from the source dataset.

 

- Modify data type name in the schema feature.

 

- Merge the schema feature (list attribute) to the data features.

 

- Configure the Dynamic Properties with "Destination Schema is Derived from List Attributes" method. (https://knowledge.safe.com/articles/Samples_and_Demos/Dynamic-Workflow-Tutorial-Destination-Schema-is-Derived-from-List-Attributes)

 

 

(1) Add a Schema (Any Format) reader to the workspace, link its Dataset to the existing SDE reader's Dataset.

 

 

(2) The schema features have "attribute{}.fme_data_type" which contains FME generic data type names as its element. Here, replace every "fme_datetime" in the list with "fme_date". One possible way is to use a PythonCaller with this script, for example.

 

-----

 

def processFeature(feature):

 

    i = 0

 

    while True:

 

        attrName = 'attribute{%d}.fme_data_type' % i

 

        t = feature.getAttribute(attrName)

 

        if t == None:

 

            break

 

        if t == 'fme_datetime':

 

            feature.setAttribute(attrName, 'fme_date')

 

        i += 1

 

-----

 

If you are not familiar with Python, you can also use a NullAttributeMapper instead.

 

Map: All Attributes

 

If Attribute Value Is: <No Items Selected>

 

Or If Attribute Value Is: fme_datetime

 

Map To: New Value

 

New Value: fme_date

 

 

(3) Add a FeatureMerger; send the data features (from the existing SDE reader) to the Requestor port; send the modified schema features to the Supplier port.

 

Join On

 

Requestor: fme_feature_type (expose in the reader)

 

Supplier: fme_feature_type_name (note that it's not "fme_feature_type")

 

 

(4) Send the Merged features to the dynamic writer feature type, and configure the Dynamic Properties.

 

In FME 2015.1+:

 

Select "Schema from first feature" as the "Schema Sources".

 

In FME 2015.0 and earlier:

 

Add a NULL reader to the workspace as a Workspace Resource (Menu: Readers > Add Reader as Resource), and then select it as the "Schema Sources".

 

 

Hope this helps.

 

 

Takashi
View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • Best Answer
  • October 27, 2015
Hi,

 

 

The strategy is:

 

- Read schema features from the source dataset.

 

- Modify data type name in the schema feature.

 

- Merge the schema feature (list attribute) to the data features.

 

- Configure the Dynamic Properties with "Destination Schema is Derived from List Attributes" method. (https://knowledge.safe.com/articles/Samples_and_Demos/Dynamic-Workflow-Tutorial-Destination-Schema-is-Derived-from-List-Attributes)

 

 

(1) Add a Schema (Any Format) reader to the workspace, link its Dataset to the existing SDE reader's Dataset.

 

 

(2) The schema features have "attribute{}.fme_data_type" which contains FME generic data type names as its element. Here, replace every "fme_datetime" in the list with "fme_date". One possible way is to use a PythonCaller with this script, for example.

 

-----

 

def processFeature(feature):

 

    i = 0

 

    while True:

 

        attrName = 'attribute{%d}.fme_data_type' % i

 

        t = feature.getAttribute(attrName)

 

        if t == None:

 

            break

 

        if t == 'fme_datetime':

 

            feature.setAttribute(attrName, 'fme_date')

 

        i += 1

 

-----

 

If you are not familiar with Python, you can also use a NullAttributeMapper instead.

 

Map: All Attributes

 

If Attribute Value Is: <No Items Selected>

 

Or If Attribute Value Is: fme_datetime

 

Map To: New Value

 

New Value: fme_date

 

 

(3) Add a FeatureMerger; send the data features (from the existing SDE reader) to the Requestor port; send the modified schema features to the Supplier port.

 

Join On

 

Requestor: fme_feature_type (expose in the reader)

 

Supplier: fme_feature_type_name (note that it's not "fme_feature_type")

 

 

(4) Send the Merged features to the dynamic writer feature type, and configure the Dynamic Properties.

 

In FME 2015.1+:

 

Select "Schema from first feature" as the "Schema Sources".

 

In FME 2015.0 and earlier:

 

Add a NULL reader to the workspace as a Workspace Resource (Menu: Readers > Add Reader as Resource), and then select it as the "Schema Sources".

 

 

Hope this helps.

 

 

Takashi

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • October 27, 2015
P.S. You may have to specify the "Input Format" parameter of the Schema reader explicitly.

francis_m
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • October 27, 2015
This is perfect Takashi !

 

It works fine, I just used a FeatureReader (with Schema (Any Format)) instead of the reader directly.

 

Thank you Takashi!!!

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings