Scenario:
1. I have an object say sourceObject called Engine which is created by DataMigration group user. i.e. owning_group = DataMigration
2. I have an object say targetObject called Tyre which is created by dba group user. i.e. owning_group = dba
So, I want the tyre object should belong to "DataMigration". So I need to change the owning_group.
Please find the below sample code.
//querying for source object 000017.....
ModelObject[] sourceObject = query.queryItems("000017");
//get the TC property of "owning_group"......
Property tc = sourceObject[0].getPropertyObject("owning_group");
//get the modelobject of that property "owning_group".....
ModelObject grp = tc.getModelObjectValue();
//Store that group in an array......
String[] properyNames = {grp.getUid()};
//querying for target object 000020.....
ModelObject[] targetObject = query.queryItems("000020");
VecStruct prop = new VecStruct();
prop.stringVec = properyNames;
HashMap<String, VecStruct> objectPropMap = new HashMap<String, VecStruct>();
//put that property into map.......
objectPropMap.put("owning_group", prop);
//Call dmservice and set the properties.....
DataManagementService dmService = DataManagementService.getService( Session.getConnection() );
dmService.setProperties(targetObject, objectPropMap );
After Execution.....
Log....
Anonymous.00001: Core-2008-06-Session.login
Anonymous.00001.01.infodba.00002: Core-2007-01-Session.getTCSessionInfo
Anonymous.00001.01.infodba.00002.01.infodba.00003: Core-2011-06-Session.getTypeDescriptions
Anonymous.00001.01.infodba.00004: Core-2011-06-Session.getTypeDescriptions
infodba.00005: Query-2006-03-SavedQuery.getSavedQueries
infodba.00005.01.infodba.00006: Core-2011-06-Session.getTypeDescriptions
.18060.01.infodba.00007: Query-2008-06-SavedQuery.executeSavedQueries
Found Items: 1
.18060.01.infodba.00008: Core-2007-09-DataManagement.loadObjects
.18060.01.infodba.00008.01.infodba.00009: Core-2011-06-Session.getTypeDescriptions
Item
.18060.01.infodba.00010: Query-2006-03-SavedQuery.getSavedQueries
.18060.01.infodba.00011: Query-2008-06-SavedQuery.executeSavedQueries
Found Items: 1
.18060.01.infodba.00012: Core-2007-09-DataManagement.loadObjects
.18060.01.infodba.00013: Core-2007-01-DataManagement.setProperties
18060.01.infodba.00013.01.infodba.00014: Core-2011-06-Session.getTypeDescriptions
.18060.01.infodba.00013.01.infodba.00015: Core-2011-06-Session.getTypeDescriptions
Modified Objects handled in com.teamcenter.clientx.AppXUpdateObjectListener.modelObjectChange
The following objects have been updated in the client data model:
xleNEK_4ICa4MD Item 000020-tyre
xpQNEK_4ICa4MD Item Master 000020
infodba.00016: Core-2006-03-Session.logout