예제 #1
0
 private static DataPoolElement getDataPoolElement(
     String objectId, TransformationResult transformationResult) {
   for (DataPoolElement dataPoolElement : transformationResult.getDataPoolElements()) {
     if (dataPoolElement.getMappingCorrelationId().equals(objectId)) {
       return dataPoolElement;
     }
   }
   return null;
 }
예제 #2
0
  public static void createDataSnapshotWithMultiParamsandResults(
      Map<String, Object> parameters,
      Map<String, Object> results,
      TransformationResult transformationResult) {

    DataPoolElement dataPoolElement = null;
    for (Entry<String, Object> entry : results.entrySet()) {
      if (!(entry.getValue() instanceof BPIMDataObject)) {
        continue;
      }
      dataPoolElement =
          DataPoolElementHelper.create(
              (BPIMDataObject) entry.getValue(), entry.getValue().getClass().getSimpleName());
      transformationResult.getDataPoolElements().add(dataPoolElement);
    }

    boolean isVoid = false;
    if (results == null || results.isEmpty()) {
      isVoid = true;
    }
    ObjectFactory dataObjectFactory = new ObjectFactory();

    if (parameters == null || parameters.isEmpty()) {
      DataSnapshotElement sourceDataSnapshotElement = DataSnapshotElementHelper.createEmpty();
      DataTransition dataTransition = null;
      DataSnapshotElement targetDataSnapshotElement = null;
      for (Entry<String, Object> entry : results.entrySet()) {
        dataTransition = dataObjectFactory.createDataTransition();
        dataTransition.setId(UniqueIdGenerator.nextId());
        dataTransition.setName(transformationResult.getFlowNode().getName());
        dataPoolElement =
            getDataPoolElement(
                ((BPIMDataObject) entry.getValue()).getObjectId(), transformationResult);
        targetDataSnapshotElement = DataSnapshotElementHelper.create(dataPoolElement);
        dataTransition.setDataSnapshotElement(targetDataSnapshotElement);
        sourceDataSnapshotElement.getDataTransition().add(dataTransition);
      }
      transformationResult.getSourceDataSnapshotElement().add(sourceDataSnapshotElement);
      return;
    }

    DataSnapshotElement sourceDataSnapshotElement = null;
    DataTransition dataTransition = null;
    DataSnapshotElement targetDataSnapshotElement = DataSnapshotElementHelper.createEmpty();
    for (Entry<String, Object> parameter : parameters.entrySet()) {
      sourceDataSnapshotElement = dataObjectFactory.createDataSnapshotElement();
      if (!(parameter.getValue() instanceof BPIMDataObject)) {
        continue;
      }
      sourceDataSnapshotElement.setMappingCorrelationId(
          ((BPIMDataObject) parameter.getValue()).getObjectId());
      sourceDataSnapshotElement.setEmpty(false);
      if (isVoid) {
        dataTransition = dataObjectFactory.createDataTransition();
        dataTransition.setId(UniqueIdGenerator.nextId());
        dataTransition.setName(transformationResult.getFlowNode().getName());
        //				targetDataSnapshotElement = DataSnapshotElementHelper.createEmpty();
        dataTransition.setDataSnapshotElement(targetDataSnapshotElement);
        sourceDataSnapshotElement.getDataTransition().add(dataTransition);
        transformationResult.getSourceDataSnapshotElement().add(sourceDataSnapshotElement);
      } else {
        for (Entry<String, Object> entry : results.entrySet()) {
          dataTransition = dataObjectFactory.createDataTransition();
          dataTransition.setId(UniqueIdGenerator.nextId());
          dataTransition.setName(transformationResult.getFlowNode().getName());
          dataPoolElement =
              getDataPoolElement(
                  ((BPIMDataObject) entry.getValue()).getObjectId(), transformationResult);
          targetDataSnapshotElement = DataSnapshotElementHelper.create(dataPoolElement);
          dataTransition.setDataSnapshotElement(targetDataSnapshotElement);
          sourceDataSnapshotElement.getDataTransition().add(dataTransition);
          transformationResult.getSourceDataSnapshotElement().add(sourceDataSnapshotElement);
        }
      }
    }
  }