cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Copy and Paste into Folders (SOA)

Hello everybody,

 

I cannot find any examples using basic FOLDER manipulation from SOA JAVA/NET. HelloTeamcenter contains sample code for Items and Revisions. But I am trying hard to create a reference from a folder to an existing Item Revision without any luck. Folders seem to use a different approach to Items regarding content, instead of using 'references' they seem to be using the 'contents' property. 

 

 

Could someone guide me in the right direction? all I want is to 'copy' and 'paste' an item revision from a source folder to a destination one. I have not found any example for that simple operation so far.

 

Thank you.

9 REPLIES

Re: Copy and Paste into Folders (SOA)

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor
You need to use DMS.CreateRelations() API with relation name = contents

Re: Copy and Paste into Folders (SOA)

Hello Amol,

 

I wish that was the case, but it is not working at all (at least for me):

 

tcRelInfo.relationType="contents";
tcRelInfo.primaryObject=folderMo;
tcRelInfo.secondaryData=new SecondaryData[1];
tcRelInfo.secondaryData[0]= secondaryMo;

 

Does not create the relationship and throws:
Error Msg.: Invalid relation type
Error Val.: Invalid relation type

 

If the type is set to "IMAN_reference", the relation is created, but not shown as content of the folder.

 

I also tried through CAD API, same result: Invalid relation type.

 

Any idea about what could I be doing wrong?

 

Thank you.

Re: Copy and Paste into Folders (SOA)

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor
Hi Ramon,

This has worked for me. Your input "SecondaryData" (MO array) seems to be different. In my case it is "SecondaryObject" (MO, not array).

Try using 'Teamcenter.Services.Strong.Core.DataManagementService.CreateRelations()'.

Here the input is an object of class 'Teamcenter.Services.Strong.Core._2006_03.DataManagement.Relationship'.

Follow exact namespaces given above. Hope this helps you.

Re: Copy and Paste into Folders (SOA)

Hello Amol,

 

It should be that easy, but it is not. I have to faithfully stick to the loose API. Teamcenter is not refusing the structure, it is rejecting the "contents" relation.

 

Adjusting the code (it was not putting an array in secondary data, but it seemed that way, maybe it is not a good idea to post code afterall).

 

CreateOrUpdateRelationsInfo tcRelInfos[]=
new CreateOrUpdateRelationsInfo[1];
tcRelInfos[0]=new CreateOrUpdateRelationsInfo();
CreateOrUpdateRelationsInfo tcRelInfo=tcRelInfos[0];
tcRelInfo.relationType="contents";
tcRelInfo.primaryObject=folderMo;
tcRelInfo.secondaryData=new SecondaryData[1];
tcRelInfo.secondaryData[0]=new SecondaryData();
SecondaryData secondaryData=tcRelInfo.secondaryData[0];
secondaryData.secondary= secondaryMos;


Same results... the structure is accepted but the "contents" relation is rejected. 

 

Thank you.

Re: Copy and Paste into Folders (SOA)

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor
Okay, there's one more difference: You are trying to paste "ItemRevision" and what I have pasted is "Item". So apparantly Item is supported for contents relation, but not ItemRevision.

Re: Copy and Paste into Folders (SOA)

Does not make any sense to me. Providing the UID of an Item does not change the situation, the "Invalid relation type" is still thrown. Your code most probably works fine with revisions when it does work with items. I am unable to make it paste the content when using the loose API. 

 

Somehow the "contents" relation is not accepted and I have no idea of how to make it work. A simple code with an unexpected behaviour. 

 

 

 

Re: Copy and Paste into Folders (SOA)

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor
You are right, I just tried it in RAC and found that ItemRevision can also be pasted in folder.
I have no further idea why it fails for you.

Re: Copy and Paste into Folders (SOA)

I have found it Smiley Happy

 

The 'contents' of a folder is a Property whose name is 'contents' and its value is the UID of the contained element (Item, Revision, a Unicorn or a Candy) and voilá, there you have it in RAC shown as being part of the folder. 

 

Thank you Amol.

 

Enjoy!

Re: Copy and Paste into Folders (SOA)

Experimenter
Experimenter

did you try to create an  new item- from orhet revision  with save as button? ( and whilce creation if you try to creta under your newstuff or your special folder alltime you can see under your folder)