예제 #1
0
  public void objectsChanged(int mode, IDfPersistentObject[] objects) {

    // String selected = (String)combo.getSelectedItem();

    for (int i = 0; i < objects.length; i++) {
      if (objects[i] instanceof IDfSysObject) {
        IDfSysObject sys = (IDfSysObject) objects[i];

        try {

          if (mode == ApiObjectChanged.DELETED) {
            tree.objectDelete(sys.getObjectId());
          } else {

            for (int j = 0; j < sys.getFolderIdCount(); j++) {
              IDfFolder folderObject =
                  (IDfFolder) con.getExistingObject(((IDfSysObject) objects[i]).getFolderId(j));

              String folder = folderObject.getString("r_folder_path");

              // if ( folder.startsWith( selected ) ||
              // "[All]".equals( selected ) ) {
              if (mode == ApiObjectChanged.CREATED) tree.objectAdd(objects[i]);
              else if (mode == ApiObjectChanged.CHANGED) tree.objectUpdate(objects[i]);
              // }
            }
          }
        } catch (DfException e) {
          e.printStackTrace();
        }
      }
    }
  }
  /**
   * Checks whether breeze output is correct for all articles. In case there are errors from Breeze
   * it generates the list of articles with Error.
   *
   * @param issue
   * @return
   */
  private String identifyErrorneouArticleFromBreeze(Issue issue) {
    log.debug("identifyErrorneouArticleFromBreeze: Start; Issue: " + issue);
    StringBuilder strb = new StringBuilder();
    // strb.append(IConstants.MSG_AAU_REJECT_ARTICLE_LIST);
    List<Article> issueArticles = issue.getArticles();

    for (Object element : issueArticles) {
      Article article = (Article) element;

      if (article.getString(Article.ARTICLE_STATUS).equalsIgnoreCase(IConstants.MSG_ERROR_PDF_GEN)
          || article
              .getString(Article.ARTICLE_STATUS)
              .equalsIgnoreCase(IConstants.MSG_BREEZE_FILE_MISSING)
          || article
              .getString(Article.ARTICLE_STATUS)
              .equalsIgnoreCase(IConstants.MSG_CORRUPT_PACKAGE_BREEZE)
          || article
              .getString(Article.ARTICLE_STATUS)
              .equalsIgnoreCase(IConstants.MSG_ERROR_UNEXPECTED_FILES)) {

        try {
          strb.append(
              (article.getObjectName().substring(0, article.getObjectName().lastIndexOf("_")))
                  + ",");
        } catch (DfException e) {
          // TODO Auto-generated catch block
          log.debug("Error while fetching the Object name for article in Issue: " + issue);
          e.printStackTrace();
        }
      }
    }

    String errorArticleList = strb.toString().substring(0, strb.toString().lastIndexOf(","));
    log.debug("identifyErrorneouArticleFromBreeze: End; Issue: " + issue);
    return errorArticleList;
  }
  public void convert() throws Exception {
    // EFS:
    //  r_current_state: 2 == In-Approval, so 3 == Approved, 4 == ?Effective?
    //  a_content_type = 'pdf'

    IDfSession session = null;
    IDfSessionManager sMgr = null;
    try {
      IDfClientX clientx = new DfClientX();

      IDfClient client = clientx.getLocalClient();

      sMgr = client.newSessionManager();

      IDfLoginInfo loginInfoObj = clientx.getLoginInfo();
      loginInfoObj.setUser("mradmin");
      loginInfoObj.setPassword("mr2006");
      loginInfoObj.setDomain(null);

      sMgr.setIdentity("MRCS_Dev", loginInfoObj);
    } catch (DfException dfe) {
      dfe.printStackTrace();
    }

    // don't want to convert approved/effective copies...crap...
    //  - must not be in an "Approved" or "Effective" folder?

    // SELECT count(*) FROM m_mrcs_central_document WHERE a_content_type = 'pdf' AND any i_folder_id
    // NOT IN (SELECT r_object_id FROM dm_folder WHERE object_name = 'Effective');
    /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, " ", null, null);

    session = sMgr.getSession("MRCS_Dev");

    // get list of objects that are pdfs...
    // - should try folder clauses too...
    // - previous versions????
    String pdfdocs =
        "SELECT r_object_id FROM m_mrcs_central_document WHERE a_content_type = 'pdf' and object_name like '--test--%'";

    IDfQuery qry = new DfQuery();
    qry.setDQL(pdfdocs);

    IDfCollection myObj1 = (IDfCollection) qry.execute(session, IDfQuery.DF_READ_QUERY);

    while (myObj1.next()) {
      sMgr.beginTransaction();
      try {
        String curid = myObj1.getString("r_object_id");
        // look up object
        IDfDocument doc = (IDfDocument) session.getObject(new DfId(curid));

        String objname = doc.getObjectName();
        String fullpath = doc.getPath(0);
        String format = doc.getFormat().getName();
        String doctype = doc.getTypeName();

        // check that it's not a popped off copy (i_folder_id[0] != 'Approved') seems to be the only
        // indicator of this...
        IDfFolder folder = (IDfFolder) session.getObject(doc.getFolderId(0));
        String foldername = folder.getObjectName();

        if (!"Approved".equals(foldername)) {

          // check it's state
          String statename =
              doc
                  .getCurrentStateName(); // Approved or Effective are only active docs with
                                          // renditions
          String filename = doc.getFile(null);
          // if In-Progress: simply switch the content type
          if ("In-Progress".equals(statename)
              || "Approved".equals(statename)
              || "Effective".equals(statename)) {
            // change format - make sure this doesn't "zero out" the content or something else
            // weird.
            doc.setContentType("acro");
            doc.setFile(filename);
          }

          // clone content as rendition for approved and effective
          if ("Approved".equals(statename) || "Effective".equals(statename)) // In-Approval too?
          {
            doc.addRendition(filename, "pdf");
          }

          doc.save();
        }
      } catch (Exception e) {
        sMgr.abortTransaction();
        throw e;
      }
      sMgr.commitTransaction();
    }
    myObj1.close();

    sMgr.release(session);
  }
  public void convert() throws Exception {

    // select all documents and look for retired and obsolete versions
    // eff = 3 obs = 4 ret = 6 for NPP
    // app = 2 for efs?
    String query =
        "SELECT r_object_id FROM m_mrcs_efs_central_document WHERE r_current_state = 4 OR r_current_state = 6";

    IDfSession session = null;
    IDfSessionManager sMgr = null;
    try {
      IDfClientX clientx = new DfClientX();

      IDfClient client = clientx.getLocalClient();

      sMgr = client.newSessionManager();

      IDfLoginInfo loginInfoObj = clientx.getLoginInfo();
      loginInfoObj.setUser("mradmin");
      loginInfoObj.setPassword("mr2006");
      loginInfoObj.setDomain(null);

      sMgr.setIdentity("MRCS_Dev", loginInfoObj);
    } catch (DfException dfe) {
      dfe.printStackTrace();
    }
    /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, " ", null, null);

    // get list of objects that are pdfs...

    IDfQuery qry = new DfQuery();
    qry.setDQL(query);

    IDfCollection myObj1 = (IDfCollection) qry.execute(session, IDfQuery.DF_READ_QUERY);

    IDfTypedObject serverConfig = session.getServerConfig();
    String aclDomain = serverConfig.getString("operator_name");
    IDfACL obsoleteacl = session.getACL(aclDomain, "mrcs_central_archived");
    IDfACL retiredacl = session.getACL(aclDomain, "mrcs_central_retired_doc");

    while (myObj1.next()) {
      String curid = myObj1.getString("r_object_id");
      // look up object
      IDfDocument doc = (IDfDocument) session.getObject(new DfId(curid));

      // check that it's not a popped off copy (i_folder_id[0] != 'Approved') seems to be the only
      // indicator of this...
      IDfFolder folder = (IDfFolder) session.getObject(doc.getFolderId(0));
      String foldername = folder.getObjectName();

      // don't do this for approved copies...
      if (!"Approved".equals(foldername)) {

        // check it's state
        String statename = doc.getCurrentStateName();
        String chronicleid = doc.getChronicleId().getId();
        // if In-Progress: simply switch the content type
        if ("Obsolete".equals(statename)) {
          String previousquery =
              "SELECT r_object_id FROM dm_document(all) where i_chronicle_id = '"
                  + chronicleid
                  + "'";
          IDfQuery prevqry = new DfQuery();
          prevqry.setDQL(previousquery);
          IDfCollection previousversions =
              (IDfCollection) prevqry.execute(session, IDfQuery.DF_READ_QUERY);
          while (previousversions.next()) {

            String previd = previousversions.getString("r_object_id");
            // look up object
            IDfDocument prevdoc = (IDfDocument) session.getObject(new DfId(previd));
            // unlock
            sMgr.beginTransaction();
            try {
              prevdoc.setString("r_immutable_flag", "FALSE");
              prevdoc.save();

              prevdoc.fetch(prevdoc.getTypeName()); // necessary?	    	    	
              // set flags obsolete = true,retired = false
              prevdoc.setBoolean("retired", false);
              prevdoc.setBoolean("obsolete", true);
              // set acl
              prevdoc.setACL(obsoleteacl);
              prevdoc.setString("r_immutable_flag", "TRUE");
              prevdoc.save();
            } catch (Exception e) {
              sMgr.abortTransaction();
              throw e;
            }
            sMgr.commitTransaction();
          }
          previousversions.close();
        }

        if ("Effective".equals(statename)) {
          String previousquery =
              "SELECT r_object_id FROM dm_document(all) where i_chronicle_id = '"
                  + chronicleid
                  + "'";
          IDfQuery prevqry = new DfQuery();
          prevqry.setDQL(query);
          IDfCollection previousversions =
              (IDfCollection) qry.execute(session, IDfQuery.DF_READ_QUERY);
          while (previousversions.next()) {

            String previd = previousversions.getString("r_object_id");
            // look up object
            IDfDocument prevdoc = (IDfDocument) session.getObject(new DfId(previd));
            // unlock
            String currentstate = prevdoc.getCurrentStateName();
            if ("Retired".equals(currentstate)) {
              sMgr.beginTransaction();
              try {
                prevdoc.setString("r_immutable_flag", "FALSE");
                prevdoc.save();
                prevdoc.fetch(prevdoc.getTypeName()); // necessary?	    	    	
                // set flags obsolete = true,retired = false
                prevdoc.setBoolean("retired", true);
                prevdoc.setBoolean("obsolete", false);
                // set acl
                prevdoc.setACL(retiredacl);
                prevdoc.setString("r_immutable_flag", "TRUE");
                prevdoc.save();
              } catch (Exception e) {
                sMgr.abortTransaction();
                throw e;
              }
              sMgr.commitTransaction();
            }
          }
          previousversions.close();
        }
      }
    }
    myObj1.close();

    sMgr.release(session);
  }
예제 #5
0
  public void selectedEvent(NodeValue[] value, int mode, JComponent src, int x, int y) {

    try {
      if (value == null) {
        if (mode == Listener.MODE_HOT_SELECT) {
          ApiObjectHotSelect[] list = (ApiObjectHotSelect[]) node.getApi(ApiObjectHotSelect.class);
          if (list == null) return;

          for (int i = 0; i < list.length; i++)
            try {
              list[i].apiObjectHotSelected(con, null, null);
            } catch (Throwable t) {
              t.printStackTrace();
            }
        }
        return;
      }

      final IDfPersistentObject[] obj = new IDfPersistentObject[value.length];
      final IDfPersistentObject[] parents = new IDfPersistentObject[value.length];

      for (int i = 0; i < value.length; i++) {
        obj[i] = con.getPersistentObject(value[i].getId());
        if (value[i].getParentId() != null)
          parents[i] = con.getPersistentObject(value[i].getParentId());
      }

      if (mode == Listener.MODE_HOT_SELECT) {
        final ApiObjectHotSelect[] list =
            (ApiObjectHotSelect[]) node.getApi(ApiObjectHotSelect.class);
        if (list == null) return;

        for (int i = 0; i < list.length; i++)
          try {
            if (!list[i].equals(TreePlugin.this)) list[i].apiObjectDepricated();
          } catch (Throwable t) {
            t.printStackTrace();
          }

        timer.schedule(
            new TimerTask() {

              public void run() {
                for (int i = 0; i < list.length; i++)
                  try {
                    if (!list[i].equals(TreePlugin.this))
                      list[i].apiObjectHotSelected(con, parents, obj);
                  } catch (Throwable t) {
                    t.printStackTrace();
                  }
              }
            },
            1);
      } else if (mode == Listener.MODE_SELECT) {
        /*
         * final ApiObjectSelect[] list =
         * (ApiObjectSelect[])node.getApi( ApiObjectSelect.class ); if (
         * list == null ) return;
         *
         * timer.schedule( new TimerTask() {
         *
         * public void run() { for ( int i = 0; i < list.length; i++ )
         * try { list[i].apiObjectSelected( con, obj ); } catch (
         * Throwable t ) { t.printStackTrace(); } }
         *
         * },1);
         */
      } else if (mode == Listener.MODE_MENU) {
        ObjectWorkerTool.showMenu(node, con, obj, src, x, y);
      }

    } catch (DfException e) {
      e.printStackTrace();
    }
  }