public void execute(WorkItem item, WorkflowSession session, MetaDataMap args)
      throws WorkflowException {
    WorkflowData workflowData = item.getWorkflowData();
    log.info("==================== <> ======================");
    Iterator props = args.entrySet().iterator();
    String pathToArchive = args.get("PROCESS_ARGS", String.class);
    if (pathToArchive != null)
      if (workflowData.getPayloadType().equals(TYPE_JCR_PATH)) {
        String path = workflowData.getPayload().toString();
        try {
          Node node = (Node) session.getSession().getItem(path + "/jcr:content");

          String orderBy = node.getProperty("orderby").getString();
          log.info("----------orderby: " + orderBy);
          Node nodeToOrder = (Node) session.getSession().getItem(pathToArchive);
          Iterator<Node> iterator = nodeToOrder.getNodes();
          List<Node> nodes = copyIterator(iterator);

          Collections.sort(nodes, new NodeComparator(orderBy));

          for (Node orderNode : nodes) {
            session
                .getSession()
                .getWorkspace()
                .move(
                    pathToArchive + "/" + orderNode.getName(),
                    pathToArchive + "/" + orderNode.getName());
          }

        } catch (RepositoryException e) {
          throw new WorkflowException(e.getMessage(), e);
        }
      }
  }
Ejemplo n.º 2
0
 private void assertSize(int size) {
   int wrapperSize = wrapper.size();
   int metaDataSize = metaData.size();
   // assert size
   assertEquals("number of meta data entries does not match", size, metaDataSize);
   assertEquals("number of wrapper entries does not match", size, wrapperSize);
 }
Ejemplo n.º 3
0
  /**
   * Tests putting and getting to/from the original map.
   *
   * @throws MetaDataException
   */
  public void testPutAndGetMetaData() {
    String testValue = "testValue";

    // add entry to wrapper
    metaData.put(KEY, testValue);

    testGet(KEY, testValue);
  }
Ejemplo n.º 4
0
  /**
   * @param testValue
   * @throws MetaDataException
   */
  private void testGet(String key, String refValue) {
    // get from wrapper
    String wrapperValue = wrapper.get(key);
    // get from metaData
    String metaDataValue = metaData.get(key, String.class);

    // assert wrapper size and content
    assertEquals(refValue, wrapperValue);
    assertEquals(refValue, metaDataValue);
  }
Ejemplo n.º 5
0
  public Workflow startWorkflow(
      final WorkflowModel model, final WorkflowData data, final Map<String, Object> metaData)
      throws WorkflowException {
    final Date now = Calendar.getInstance().getTime();
    final MetaDataMap metaDataMap = new SimpleMetaDataMap();
    metaDataMap.putAll(metaData);
    Workflow wf =
        new Workflow() {

          public String getId() {
            return now.toString();
          }

          public List<WorkItem> getWorkItems() {
            return null;
          }

          public List<WorkItem> getWorkItems(WorkItemFilter filter) {
            return null;
          }

          public WorkflowModel getWorkflowModel() {
            return model;
          }

          public boolean isActive() {
            return true;
          }

          public String getState() {
            return null;
          }

          public String getInitiator() {
            return session.getUserID();
          }

          public Date getTimeStarted() {
            return now;
          }

          public Date getTimeEnded() {
            return now;
          }

          public WorkflowData getWorkflowData() {
            return data;
          }

          public Dictionary<String, String> getMetaData() {
            return null;
          }

          public MetaDataMap getMetaDataMap() {
            return metaDataMap;
          }
        };

    List<Workflow> all =
        payloadMap.containsKey(data.getPayload())
            ? payloadMap.get(data.getPayload())
            : new ArrayList<Workflow>();
    all.add(wf);
    this.payloadMap.put(data.getPayload(), all);
    return wf;
  }