Ejemplo n.º 1
0
 private static WTPart getLatestObject(WTPartMaster master)
     throws PersistenceException, WTException {
   WTPart part = null;
   QueryResult qr = VersionControlHelper.service.allVersionsOf(master);
   while (qr.hasMoreElements()) {
     part = (WTPart) qr.nextElement();
   }
   return part;
 }
Ejemplo n.º 2
0
 private static EPMDocument getLatestObject(EPMDocumentMaster master)
     throws PersistenceException, WTException {
   EPMDocument epm = null;
   QueryResult qr = VersionControlHelper.service.allVersionsOf(master);
   while (qr.hasMoreElements()) {
     epm = (EPMDocument) qr.nextElement();
   }
   return epm;
 }
Ejemplo n.º 3
0
 private static ArrayList<WTObject> getDataOrderList(DataSendOrder dso) throws WTException {
   ArrayList<WTObject> list = new ArrayList<WTObject>();
   QueryResult queryresult =
       PersistenceHelper.manager.navigate(dso, "roleBObject", SendObjectLink.class, false);
   while (queryresult.hasMoreElements()) {
     SendObjectLink solink = (SendObjectLink) queryresult.nextElement();
     WTObject obj = (WTObject) solink.getRoleBObject();
     list.add(obj);
   }
   return list;
 }
Ejemplo n.º 4
0
  public static Set<WTPart> getAllChildPart(WTPart part) throws WTException {
    Set<WTPart> result = new HashSet<WTPart>();

    QueryResult qr = StructHelper.service.navigateUses(part, true);
    while (qr.hasMoreElements()) {
      WTPartMaster master = (WTPartMaster) qr.nextElement();
      WTPart childPart = getLatestObject(master);
      result.add(childPart);
      result.addAll(getAllChildPart(childPart));
    }
    return result;
  }
Ejemplo n.º 5
0
  private static Element generatePart(WTPart parentPart, String fileLocation)
      throws WTException, PropertyVetoException, IOException {
    Element partEle = new BaseElement("Part");
    partEle.addAttribute("PartID", parentPart.getNumber());
    partEle.addAttribute("Version", parentPart.getVersionIdentifier().getValue());
    partEle.addAttribute("Revision", parentPart.getIterationIdentifier().getValue());

    Element attrs = new BaseElement("Attributes");
    attrs.add(new BaseElement("PartName").addText(parentPart.getName()));
    attrs.add(new BaseElement("PartDesc").addText(""));
    // 创建人所属组织
    attrs.add(
        new BaseElement("TeamID")
            .addText(parentPart.getCreator().getPrincipal().getOrganization().getName()));
    attrs.add(new BaseElement("CreatedBy").addText(parentPart.getCreatorFullName()));
    attrs.add(new BaseElement("UpdatedBy").addText(parentPart.getModifierFullName()));
    attrs.add(
        new BaseElement("CreatedTime")
            .addText(
                dateFormat.format(
                    new Date(PersistenceHelper.getCreateStamp(parentPart).getTime()))));
    attrs.add(
        new BaseElement("LastUpdated")
            .addText(
                dateFormat.format(
                    new Date(PersistenceHelper.getModifyStamp(parentPart).getTime()))));
    attrs.add(
        new BaseElement("Unit")
            .addText(parentPart.getDefaultUnit().getLocalizedMessage(Locale.CHINA)));
    attrs.add(
        new BaseElement("PartType").addText(parentPart.getPartType().getDisplay(Locale.CHINA)));

    // 开始获取软属性
    List<Element> ibaList = getIBAElement(parentPart);
    for (Element element : ibaList) {
      attrs.add(element);
      ;
    }
    partEle.add(attrs);

    QueryResult partUseBOMQR =
        PersistenceHelper.manager.navigate(
            parentPart, EPMBuildRule.BUILD_SOURCE_ROLE, EPMBuildRule.class);
    while (partUseBOMQR.hasMoreElements()) { // CADCOMPONENT || CADASSEMBLY || CADDRAWING
      EPMDocument parentEpm = (EPMDocument) partUseBOMQR.nextElement();
      // 装配或CAD部件时写CAD元素
      if (!parentEpm.getDocType().toString().equals("CADCOMPONENT")
          && !parentEpm.getDocType().toString().equals("CADASSEMBLY")) continue;

      if (parentEpm.getDocType().toString().equals("CADASSEMBLY")) { // 装配,才有使用关系
        Element partUses = new BaseElement("PartUses");

        QueryResult epmUseQR =
            PersistenceHelper.manager.navigate(
                parentEpm, EPMMemberLink.USES_ROLE, EPMMemberLink.class, false);
        while (epmUseQR.hasMoreElements()) {
          EPMMemberLink memberLink = (EPMMemberLink) epmUseQR.nextElement();
          long amount = Math.round(memberLink.getQuantity().getAmount());
          EPMDocumentMaster childEpmMaster = (EPMDocumentMaster) memberLink.getUses();
          EPMDocument childEpm = getLatestObject(childEpmMaster);
          Matrix4d matrix4d = memberLink.getTransform().toMatrix4d();

          Element usePart = new BaseElement("Part");
          usePart.addAttribute("PartID", childEpm.getNumber());
          usePart.addAttribute("PartVersion", childEpm.getVersionIdentifier().getValue());
          usePart.addAttribute("Amount", amount + "");
          for (long i = 1; i <= amount; i++) {
            Element partIntance = new BaseElement("PartIntance");
            partIntance.addAttribute("InstanceName", childEpm.getNumber() + "." + i);

            Element transform = matrix4d2Transform(matrix4d);
            partIntance.add(transform);

            Element cfgInfo = new BaseElement("CfgInfo");
            partIntance.add(cfgInfo);

            usePart.add(partIntance);
          }
          partUses.add(usePart);
        }
        partEle.add(partUses);
      }

      // 写部件与CAD文档的关系
      Element partDescBy = new BaseElement("PartDescBy");
      Element cadDocument = getCADElement(parentEpm, fileLocation);
      partDescBy.add(cadDocument);
      partEle.add(partDescBy);

      // 部件与普通文档关系
      Element partRef = new BaseElement("PartRef");
      QueryResult docQR = PartDocHelper.service.getAssociatedDocuments(parentPart);
      while (docQR.hasMoreElements()) {
        Object object = (Object) docQR.nextElement();
        if (object instanceof WTDocument) {
          WTDocument childDoc = (WTDocument) object;
          Element document = getWTDocElement(childDoc, fileLocation);
          partRef.add(document);
        }
      }

      partEle.add(partRef);
    }
    return partEle;
  }