Пример #1
0
  /**
   * Returns all document act references for the specified short names.
   *
   * @param shortNames the shortNames
   * @return the matching document act references
   */
  private List<IMObjectReference> getDocumentActs(String[] shortNames) {
    ArchetypeQuery query = new ArchetypeQuery(new ShortNameConstraint(shortNames, false, true));
    if (log.isInfoEnabled()) {
      StringBuilder buff = new StringBuilder();
      for (String s : shortNames) {
        if (buff.length() != 0) {
          buff.append(", ");
        }
        buff.append(s);
      }
      log.info("Querying archetypes: " + buff);
    }
    List<IMObjectReference> refs = new ArrayList<IMObjectReference>();
    query.add(new NodeConstraint("document", RelationalOp.IS_NULL));
    query.setMaxResults(1000);
    List<String> nodes = Arrays.asList("fileName");
    Iterator<NodeSet> iter = new NodeSetQueryIterator(query, nodes);

    // need to build up a list of matching references first, as updates
    // to the document reference will affect paging
    while (iter.hasNext()) {
      NodeSet set = iter.next();
      String fileName = (String) set.get("fileName");
      if (!StringUtils.isEmpty(fileName)) {
        refs.add(set.getObjectReference());
      }
    }
    return refs;
  }