Friday, May 30, 2014

SOA: Update Object Properties (TCComponent Type)

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

OUTPUT:








Tuesday, May 20, 2014

Unable to Login into Teamcenter after Setting Command Suppression

Symptom

Software Versions/Configuration:
                                                    TcUA 9.1.2.6

Description of Problem:
                                     After imported command suppression, the 4 Tier Rich Client cannot log in; 
it gets the error "com.teamcenter.soa.client.SoaRuntimeException.  Failure assigning server: CORBA failure during login:".

Solution :
             1. Clear cache.
             2. Re-run the genregxml.bat
You have to restart the TC environment in order for the 4 Tier Rich Client to log in / work again.

RAC : PSE Clone Structure

In ITK we have several APIs to clone an existing structure. If you are working on client-side, here is an example to clone a structure.

private void BOMClone
                 (TCComponentItem oldItem,
TCComponentItem newItem, 
                        TCSession session) throws TCException 
{
// TODO Auto-generated method stub
TCComponentBOMWindow oldBomWindow = null;
TCComponentBOMWindow newBomWindow = null;
try {
       TCComponentRevisionRuleType ruleType =                                                                                 (TCComponentRevisionRuleType) session
                                   .getTypeComponent("RevisionRule");
               TCComponentRevisionRule defRule = ruleType.getDefaultRule();
               TCComponentBOMWindowType bomType =                                                                                (TCComponentBOMWindowType) session
                                    .getTypeComponent("BOMWindow");
               oldBomWindow = bomType.create(defRule);
       oldBomWindow.setWindowTopLine(oldItem, null, null, null);
       TCComponentBOMLine oldBomTopLine =                                                                                             oldBomWindow.getTopBOMLine();
       AIFComponentContext[] oldBomContext =                                                                                              oldBomTopLine.getChildren();
       TCComponentItemRevision[] childItems  = new                                                                TCComponentItemRevision[oldBomContext.length];
               for ( int i=0; i < oldBomContext.length; i++ ) 
       {
 if ( oldBomContext[i].getComponent() instanceof                                                                           TCComponentBOMLine )
 {
 TCComponentBOMLine childBomLine = new                                                                                           TCComponentBOMLine();
 childBomLine =(TCComponentBOMLine)                                                                                           oldBomContext[i].getComponent();
                 childItems[i] = (TCComponentItemRevision)                                                                                     childBomLine.getItemRevision();
 }
       }
       newBomWindow = bomType.create(defRule);
       newBomWindow.setWindowTopLine(newItem, null, null, null);
       TCComponentBOMLine newBomTopLine =                                                                                        newBomWindow.getTopBOMLine();
         newBomTopLine.add(null, childItems);
       newBomWindow.save();
       newBomWindow.close();
       oldBomWindow.close();
        catch (TCException e) 
        {
       // TODO Auto-generated catch block
       e.printStackTrace();
}
}