Teamcenter SOA Service : Manufacturing Process Planner : Operation and Activity Creation and Attachm

本文详细介绍了在Teamcenter中如何将表单对象附加到活动,以及如何将活动附加到操作的根活动。通过创建表单对象和活动对象,并使用特定API将它们与相应的活动或根活动连接,实现工作流程的定制化。文章提供了具体的代码示例,展示了从顶级生产线获取操作线,进而获取活动或根活动的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Problem Statement : 1) Attach Form Object To Activity OR Activity To RootActivity
//APIs are same only Object provided to APIs are different

How to do this task in Teamcenter ? refer link
1) Attach Form Object to Activity
  Left Object - Activity
  Right Object - Form Object

Assumption here is we have top line of Process under which we have operation ,beneath operation we have activity attached.Add form to that activity.
From top Line we will get Operation Line and from that operation line we will get root activity and from root activity we will get activity to which we want form to be attached.

//Create Form Object
CreateIn[] createIn = new CreateIn[1];
createIn[0] = new CreateIn();
createIn[0].data.stringProps.put( "object_name", "TestRRActivity12302016123" );
createIn[0].data.stringProps.put( "object_desc", "jTestRRActivity12302016 desc123" );
createIn[0].data.boName = "Activity Form";
CreateResponse createObjectsForm = null;

try {

createObjectsForm = dataManagementService1.createObjects( createIn );

} catch (ServiceException e) {

e.printStackTrace();

} // create form object end
//Attach Form Object To Activity

BOMLine operationline3=getchildlines("TCK71000006461/A-TestMeOp1VOption (Engineering)",topLineObject,dataManagementService1);//get Operation line

getAttachmentLines(operationline3, connection);//get Activity to which form is to be attached

MEActivityFolderInfo[] Activityfolderinfo=new MEActivityFolderInfo[1];
Activityfolderinfo[0]=new MEActivityFolderInfo();
Activityfolderinfo[0].activity=activityLineObject;//MEActivity to which we want to attach form
Activityfolderinfo[0].contents=new WorkspaceObject[]{(WorkspaceObject) createObjectsForm.output[0].objects[0]};//Form object<-createObjectsForm.output[0].objects[0]

dataManagementService.createOrUpdateMEActivityFolders(Activityfolderinfo);

2) Attach Activity To Root Activity Of Operation(i.e What we say in Teamcenter is attach activity to operation but it is actually attached to root activity of operation)
Left Object - RootActivity  of Operation
Right Object - Activity

Assumption here is we have top line of Process under which we have operation under which there is default root activity to which we want to attach activity.
From top Line we will get Operation Line and from that operation line we will get root activity to that root activity we will attach activity.

//Create Activity Object
CreateIn[] createIn2 = new CreateIn[1];
createIn2[0] = new CreateIn();
createIn2[0].data.stringProps.put( "object_name", "Test10" );
createIn2[0].data.stringProps.put( "object_desc", "Test10 desc" );
createIn2[0].data.boName = "MEActivity";
CreateResponse createObjectsActivity= null;

try {

  createObjectsActivity = dataManagementService1.createObjects( createIn2 );

} catch (ServiceException e) {

e.printStackTrace();

} // create Activity object end
//Attach Activity Object To Root Activity
BOMLine operationline3=getchildlines("TCK71000006461/A-TestMeOp1VOption (Engineering)",topLineObject,dataManagementService1);//Get OPeration line
getAttachmentLines(operationline3, connection);//provide root line

MEActivityFolderInfo[] Activityfolderinfo=new MEActivityFolderInfo[1];
Activityfolderinfo[0]=new MEActivityFolderInfo();
Activityfolderinfo[0].activity=rootactivityLineObject;//Root Activity
Activityfolderinfo[0].contents=new WorkspaceObject[]{(WorkspaceObject)createObjectsActivity.output[0].objects[0]}; //MEActivity object

dataManagementService.createOrUpdateMEActivityFolders(Activityfolderinfo);
//Return the child line based on filter

 private BOMLine getchildlines(String filter_formattedtitletext,BOMLine topLineObject,com.teamcenter.services.strong.core.DataManagementService dataManagementService)
 {

  ModelObject[] allChildLines;

  try {

    dataManagementService.getProperties( new ModelObject[] { topLineObject }, new String[]{ "bl_child_lines" } );

   allChildLines = topLineObject.get_bl_child_lines();

  for ( int i = 0; i < allChildLines.length; i++ )
   {

    BOMLine bomLine = (BOMLine) allChildLines[i];
    dataManagementService.getProperties( new ModelObject[] { bomLine }, new String[]{ "bl_formatted_title" } );

    String formated_title = bomLine.get_bl_formatted_title();

    if ( formated_title.equalsIgnoreCase(filter_formattedtitletext))
    {
     return bomLine;
    }
    System.out.println( bomLine.get_bl_formatted_title() );
   }

  } catch (NotLoadedException e) {

   e.printStackTrace();
  }
  return null;
}
//provide Root activity and ActivityLine object
 
MEActivity activityLineObject;
MEActivity rootactivityLineObject;

private void getAttachmentLines( BOMLine bopLine, Connection connection ) throws NotLoadedException
 {
  Mfg0BvrOperation mfg0BVROperation = (Mfg0BvrOperation)bopLine;

  DataManagementService dataManagementService = DataManagementService.getService( connection );
  dataManagementService.getProperties( new ModelObject[] { bopLine }, new String[]{ "bl_me_activity_lines" } );

  CfgActivityLine activityLine = (CfgActivityLine) mfg0BVROperation.get_bl_me_activity_lines();

  dataManagementService.getProperties( new ModelObject[] { activityLine }, new String[]{ "me_cl_object_name","me_cl_object_desc","me_cl_source" } );
  rootactivityLineObject=(MEActivity) activityLine.get_me_cl_source();
  dataManagementService.getProperties( new ModelObject[] { activityLine }, new String[]{ "me_cl_child_lines" } );
  ModelObject[] activityContents = activityLine.get_me_cl_child_lines();

  for ( int i = 0; i < activityContents.length; i++ )
  {
    CfgActivityLine cfgActivityLine =  (CfgActivityLine) activityContents[0];
    dataManagementService.getProperties( new ModelObject[] { cfgActivityLine }, new String[]{ "me_cl_object_name","me_cl_object_desc","me_cl_source" } );
    activityLineObject = (MEActivity) cfgActivityLine.get_me_cl_source();
    System.out.println("Activity Object Name ="+cfgActivityLine.get_me_cl_object_name());
    System.out.println("Activity Object Desc ="+cfgActivityLine.get_me_cl_object_desc());
  }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值