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);
No comments:
Post a Comment