Create a part, upload and download a file

This example pipeline demonstrates how to create a part, upload a file to it, and download that file again.


Pipeline consisting of twelve snaps to demonstrate usage of upload and download file snaps.

Steps

1: Create a xml document. The XML Generator (and XML Formatter) Snaps are a placeholder for external system which could send a file to Snaplogic.

Snap configuration

Content of XML


XML Generator Snap where xml is stored behind 'Edit XML'.

<?xml version="1.0"?>
<welcome>
   <message id="4711">
      <title>Hello</title>
      <!--                           -->
      <!--     __  __     ____       -->
      <!--    / / / /__  / / /___    -->
      <!--   / /_/ / _ \/ / / __ \   -->
      <!--  / __  /  __/ / / /_/ /   -->
      <!-- /_/ /_/\___/_/_/\____/    -->
      <!--                           -->
   </message>
</welcome>​

2: Configure the XML Formatter Snap to format data to binary.

Snap configuration

Snap output


XML Formatter Snap settings with 'Output character set' to UTF-8.

3: Configure the File Writer Snap to store file on filesystem.

Snap configuration

Snap output


File Writer Snap settings including configured filename.

4: Configure the Tc Create Snap with minimal mandatory data to create an object of type Item in Teamcenter. On validation, the Snap displays the part revision created for the input.

Snap configuration

Snap output


Tc Create Item Snap setting with hard written Type 'Item' and attribute 'object_name'.


JSON output with metadata of newly created item revision.

5: Configure the Tc Info Snap to refresh the data. On validation, the Snap displays the part revision.

Snap configuration

Snap output


Tc Info Snap settings using _id property of input document as 'Object ID' and hard written expand attributes.


JSON output with metadata of item revision.

6: Configure the Pipeline execute Snap to start child pipeline for uploading of stored file to object in Teamcenter identified by id. ID is parameter for child pipeline. On validation, the Snap displays the result of the child pipeline execution. The child pipeline is described in Delete referenced file .

Snap configuration

Snap output


Pipeline Execute Snap settings with pipeline to be called 'z_TC_UploadFile' and parameter name value pair id and property _id.


JSON ouput document including result of child pipeline execution.

7: Configure the Tc Info Snap to get configured data for Item Revision. On validation, the Snap displays the part revision information.

Snap configuration

Snap output


Tc Info Snap settings using original _id property of input document as 'Object ID' and hard written expand attributes.


JSON output with metadata of item revision.

8: Configure the Tc Get Downloadable Files Snap to get information about files related to Item Revision. On validation, the Snap displays the related datasets.

Snap configuration

Snap output


Tc Get Downloadable Files Snap settings using _id property from input document as 'Object ID' and defining two primary relation files are related with object. 'Mode' is defined as inline.


JSON output document being copy of input document including 'Datasets' list object with one dataset object.

9: Configure a Splitter Snap to extract all Datasets objects. On validation, the Snap displays the related object.

Snap configuration

Snap output


Splitter Snap settings with path to split leading to list object Datasets in input document.


JSON output document of Splitter Snap including one object.

10: Configure again a Splitter Snap to extract all NamedReferences of dataset. On validation, the Snap displays the object from NamedReferences list.

Snap configuration

Snap output


Splitter Snap settings with path to split leading to list object NamedReferences in input document.


JSON output document of Splitter Snap including one object including metadata of ImanFile.

11: Configure a Tc File Download Snap to download file data to pipeline. 1Therefore id of ImanFile which was found in NamedReferences is used. On validation, the Snap displays the ImanFile metadata information.

Snap configuration

Snap output


Settings of Tc File Download Snap with _id property value of input document used for field 'Object ID'.


JSON output document including metadata of file.

12: Configure a File Writer Snap to store file.

Snap configuration


Fiel Writer Snap settings with configured file name where binary data shall be written to.

Child pipeline to upload a file

This example pipeline demonstrates how to upload a file Teamcenter.


Child pipeline consisting of two snaps to read file and upload it to Teamcenter.

1: Configure the File Reader Snap to read file which was stored by prior pipeline.

Snap configuration


File Reader settings with configured File to be read from directory.

2: Configure a Tc File Upload Snap to upload file to Teamcenter object. On validation, the Snap displays the dataset and file information.

Snap configuration

Snap output


Tc File Upload Snap settings using parameter _id in field 'Parent ID'. Mandatory fields for dataset and relation configuration are defined.


JSON output document including metadata of created ImanFile object.