SOA Service Client : Delete Children from BOM

不想你离开。 提交于 2020-02-25 19:27:00

How to delete all the lines/children for give itemrevision ?

public void deleteAllBOMLines(Connection connection,ItemRevision parentItemRev) throws Exception
{
    ArrayList bomWindowAndLine = 
    openBOMWindow(connection, parentItemRev);//open BOM WINDOW
    BOMWindow bomWindow = (BOMWindow) bomWindowAndLine.get(0);//BOMWINDOW
    BOMLine parentBOMLine = 
   (BOMLine) bomWindowAndLine.get(1);//TOPLine ->you get topline after opening BOMwindow with object
    com.teamcenter.services.strong.core.DataManagementService dmService = 
    com.teamcenter.services.strong.core.DataManagementService.getService(connection);

    dmService.getProperties(new ModelObject[] { parentBOMLine },
    new String[] { "bl_bomview_rev", "bl_child_lines",
    "bl_bomview" });//Load the properties on Item revision
    ModelObject childBOMLines[];
    childBOMLines = parentBOMLine.get_bl_child_lines();//Get children objects
    //System.out.println("No of BOMLines found == "+childBOMLines.length);
    if(childBOMLines.length <= 0)
 return ;
    BOMLine bomlines[] = new BOMLine[childBOMLines.length];
    for (int i = 0; i < childBOMLines.length; i++){
     //Collect all children as BOMMLine Object
     bomlines[i] = (BOMLine) childBOMLines[i];

    }
   if (childBOMLines != null && childBOMLines.length > 0){
  com.teamcenter.services.strong.bom.StructureManagementService bomStrucMgmtService = 
  com.teamcenter.services.strong.bom.StructureManagementService
 .getService(connection);
  RemoveChildrenFromParentLineResponse response = bomStrucMgmtService
 .removeChildrenFromParentLine(bomlines);//Remove all children
  boolean isErrorOccured = false;
   String sErrors = "";
  if (response.serviceData.sizeOfPartialErrors() > 0) 
 {
 isErrorOccured = true;
 for(int i=0 ; i < response.serviceData.sizeOfPartialErrors();i++)
       {
 ErrorStack errorStack = response.serviceData.getPartialError(i);
        String arrMessages[] = errorStack.getMessages();
        for(int j=0 ; j<arrMessages.length ; j++)
        {
  sErrors +=arrMessages[j]+"\n";
 }     
 }
 //System.out.println("Partial Error Occured while DeleteAllBOMLines : "+sErrors);
}
if(isErrorOccured && (response.serviceData.sizeOfDeletedObjects() < bomlines.length)){
 throw new eQMIException("Deleting the BOM-Lines: 002","Deleting the BOM-Lines - "+sErrors);
}
saveBOMWindow(connection, bomWindow);//Save BOM WINDOW
closeBOMWindow(connection, bomWindow);//Close BOM WINDOW
System.out.println("************************************** BOM-Lines deleted**************************************");
}

}

Explanation : Important API
childBOMLines = parentBOMLine.get_bl_child_lines();
RemoveChildrenFromParentLineResponse  response = bomStrucMgmtService.removeChildrenFromParentLine(bomlines);

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!