Beispiel #1
0
  private static Element getCADElement(EPMDocument epmDocument, String fileLocation)
      throws WTException, PropertyVetoException, IOException {
    Element cadDocument = new BaseElement("CADDocument");
    cadDocument.addAttribute("DocID", epmDocument.getNumber());
    cadDocument.addAttribute("Revision", epmDocument.getIterationIdentifier().getValue());
    cadDocument.addAttribute("Version", epmDocument.getVersionIdentifier().getValue());

    epmDocument = (EPMDocument) ContentHelper.service.getContents(epmDocument);
    ContentItem contentHolder = ContentHelper.getPrimary(epmDocument);
    ApplicationData applicationdataPrimary = (ApplicationData) contentHolder;

    String docType = "CATPart";
    if (epmDocument.getDocType().toString().equals("CADASSEMBLY")) docType = "CATProd";
    else if (epmDocument.getDocType().toString().equals("CADDRAWING")) docType = "CATDraw";

    Element cadAttr = new BaseElement("Attributes");
    cadAttr.add(new BaseElement("DocName").addText(applicationdataPrimary.getFileName()));
    cadAttr.add(new BaseElement("DocType").addText(docType));
    cadAttr.add(
        new BaseElement("TeamID")
            .addText(epmDocument.getCreator().getPrincipal().getOrganization().getName()));
    cadAttr.add(new BaseElement("CreatedBy").addText(epmDocument.getCreatorFullName()));
    cadAttr.add(new BaseElement("UpdatedBy").addText(epmDocument.getModifierFullName()));
    cadAttr.add(
        new BaseElement("CreatedTime")
            .addText(
                dateFormat.format(
                    new Date(PersistenceHelper.getCreateStamp(epmDocument).getTime()))));
    cadAttr.add(
        new BaseElement("LastUpdated")
            .addText(
                dateFormat.format(
                    new Date(PersistenceHelper.getModifyStamp(epmDocument).getTime()))));

    cadDocument.add(cadAttr);

    Element docContent = new BaseElement("DocContent");
    if (applicationdataPrimary != null) {
      File file = new File(fileLocation + "/CONTENTS/");
      if (!file.exists()) file.mkdirs();
      ContentServerHelper.service.writeContentStream(
          applicationdataPrimary,
          fileLocation + "/CONTENTS/" + applicationdataPrimary.getFileName());

      docContent.add(
          new BaseElement("ContentPath")
              .addText("CONTENTS/" + applicationdataPrimary.getFileName()));
      docContent.add(
          new BaseElement("ContentFileName").addText(applicationdataPrimary.getFileName()));
      docContent.add(new BaseElement("ContentType").addText("ApplicationData"));
      docContent.add(new BaseElement("ContentType").addText(contentHolder.getRole().toString()));
    }

    cadDocument.add(docContent);
    ;
    return cadDocument;
  }
Beispiel #2
0
  private static Element getWTDocElement(WTDocument doc, String fileLocation)
      throws WTException, PropertyVetoException, IOException {
    Element document = new BaseElement("Document");
    document.addAttribute("DocID", doc.getNumber());
    document.addAttribute("Version", doc.getVersionIdentifier().getValue());
    document.addAttribute("Revision", doc.getIterationIdentifier().getValue());
    document.addAttribute("Type", ""); // TODO 类型

    doc = (WTDocument) ContentHelper.service.getContents(doc);
    ContentItem contentHolder = ContentHelper.getPrimary(doc);
    ApplicationData applicationdataPrimary = (ApplicationData) contentHolder;

    Element docAttr = new BaseElement("Attributes");
    docAttr.add(new BaseElement("DocName").addText(applicationdataPrimary.getFileName()));
    docAttr.add(
        new BaseElement("TeamID")
            .addText(doc.getCreator().getPrincipal().getOrganization().getName()));
    docAttr.add(new BaseElement("CreatedBy").addText(doc.getCreatorFullName()));
    docAttr.add(new BaseElement("UpdatedBy").addText(doc.getModifierFullName()));
    docAttr.add(
        new BaseElement("CreatedTime")
            .addText(dateFormat.format(new Date(PersistenceHelper.getCreateStamp(doc).getTime()))));
    docAttr.add(
        new BaseElement("LastUpdated")
            .addText(dateFormat.format(new Date(PersistenceHelper.getModifyStamp(doc).getTime()))));

    document.add(docAttr);

    Element docContent = new BaseElement("DocContent");
    if (applicationdataPrimary != null) {
      File file = new File(fileLocation + "/CONTENTS/");
      if (!file.exists()) file.mkdirs();

      ContentServerHelper.service.writeContentStream(
          applicationdataPrimary,
          fileLocation + "/CONTENTS/" + applicationdataPrimary.getFileName());

      docContent.add(
          new BaseElement("ContentPath")
              .addText("CONTENTS/" + applicationdataPrimary.getFileName()));
      docContent.add(
          new BaseElement("ContentFileName").addText(applicationdataPrimary.getFileName()));
      docContent.add(new BaseElement("ContentType").addText("ApplicationData"));
      docContent.add(new BaseElement("ContentType").addText(contentHolder.getRole().toString()));
    }
    document.add(docContent);

    return document;
  }