Delete referenced file

This example pipeline demonstrates how to delete a file referenced by a dataset, and optionally the dataset itself once it is empty.


Pipeline consisting of sixteen snaps to demonstrate usage of upload and delete file snaps.

The Snaps 1 till 6 (marked with frame in picture) are copied from pipeline Create a part, upload and download a file and will not be explained again. They are a placeholder to create an object - file example in Teamcenter.

Steps

Pipeline has parameters to give contral to calling service. TeamcenterObjectID is the id of the existing object in Teamcenter which shall be cleaned up. The parameter “wholeCleanup” shall control if dataset shall be deleted if it is empty.


Pipeline parameters TeamcenterObjectID with empty default value and wholeCleanup with default value 'false'.

7: The Mapper Snap “TeamcenterObjectID” copies id of created object to variable “TeamcenterObjectID” to show that example pipeline only need this ID. On validation, the Snap displays the ID.

Snap configuration

Snap output


Mapper Snap settings with one row in Mapping table.


JSON output document including one property.

8: The Tc Get Downloadable Files Snap expands all datasets for configured relations including Files. On validation, the Snap displays Datasets list with one Dataset and its Files in “NamedReferences” list object. The influence of Modeinlinehas the effect that incomming document is extended with Datasets list.

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: The Router Snap read parameter of pipeline to route document to path where only files of dataset will be deleted.

Snap configuration


Router Snap settings with first expression checking parameter wholeCleanup is true and routing to branch 'delete empty dataset'. Otherwise branch to only delete files is routed.

10: The Tc File Delete Referenced Snap is configured to delete all files (File ID field is empty) for first dataset. On validation, the Snap displays result including one object (since there was only one File referenced). This object has a message and UID of deleted file.

Snap configuration

Snap output


Tc File Delete Referenced Snap settings where 'Object ID' value is filled with _id of first Dataset object. 'Delete if empty' checkbox is OFF.


JSON output document including result list object with one message object about outcome of deletion.

11: The Join Snap merges the pathes opened by Router Snap. On validation, the Snap displays the same document as the one from Tc File Delete Referenced.

Snap configuration

Snap output


Join Snap settings with Join type defined as 'Merge'.


JSON output document of Join Snap.

12: The Tc Get Downloadable Files Snap is configured to show Downloadables of original Teamcenter object to validate result of deletion. The influence of Modeinlinehas the effect that incomming document is extended with Datasets list. So on validation, the Snap shows incomming document enhanced with Datasets list. This list still includes the dataset but it has no referenced files anymore in “NamedReferences”.

Snap configuration

Snap output


Tc Get Downloadable Files Snap settings using TeamcenterObjectID property of original 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. Dataset object contains now empty NamedReferences list object.

13: The Join Snap at the end merges the outcome of succes result and the outcome of possibly happend errors. On validation, the Snap displays same document as the one from the Tc Get Downloadable Files Snap.

Snap configuration

Snap output


Join Snap settings with Join type defined as 'Merge'.


JSON output document of Join Snap.

Alternative way for deleting empty dataset

Given the pipeline is called with _wholeCleanup parameter set to true. Numbering of steps has prefix “a” now as in “alternative” and starts with 10 to be in sync with pipeline steps above.


Pipeline parameters TeamcenterObjectID with empty default value and wholeCleanup with default value 'true'.


Pipeline steps to demonstrate usage of delete file snaps.

a10: The Tc File Delete Referenced Snap in this path is configured to Delete if empty. On validation, the Snap displays the actions done in Teamcenter. First the ImanFile was deleted as ist was done in Step 10 described before. But additionally the Snap checks if dataset has other file relation. This is not the case in our example so relation to ItemRevision was deleted (JSON object two in result list). At the end the dataset itself was deleted (JSON object three in result list).

Snap configuration

Snap output


Tc File Delete Referenced Snap settings where 'Object ID' value is filled with _id of first Dataset object. 'Delete if empty' checkbox is ON.


JSON output document of Tc File Delete Referenced Snap including result list object with three message objects. Message object about deleted file, relation object and dataset object.

a11: The Mapper Snap copies id of created object to varaible “TeamcenterObjectID” to show that example pipeline only need this ID. On validation, the Snap displays

Snap configuration

Snap output


Join Snap settings with Join type 'Merge'.


pipeline_fileDeleteReferenced_joinResultSnapAlternative-output.jpg

a12: The Tc Get Downloadable Files Snap is configured to show Downloadables of original Teamcenter object to validate result of deletion. The influence of Modeinlinehas the effect that incomming document is extended with Datasets list. So on validation, the Snap shows incomming document enhanced with Datasets list. This list is now empty since dataset was deleted.

Snap configuration

Snap output


Tc Get Downloadable Files Snap settings using TeamcenterObjectID property of original 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 empty 'Datasets' list.

Snap description for error pathes

Both Tc Delete Referenced Files Snap are configured to send error data to error view. This information has to be handled then. Numbering of steps has prefix “e” now as in “error”

e1: The Join Snap merges both branches opened by Router Snap.

Snap configuration


Join Snap settings with Join type 'Merge'.

e2: The Mapper Snap transforms error infomation to an error object.

Snap configuration


pipeline_fileDeleteReferenced_mapperSnapError.jpg