Exemple #1
0
  @Override
  protected void start() {
    error = null;
    TypedProperties properties = getTypedProperties();
    this.sourceStep1Id = properties.get(SOURCE_1);
    if (isBlank(sourceStep1Id)) {
      throw new MisconfiguredException("Please choose a step where the original data comes from");
    }
    this.sourceStep2Id = properties.get(SOURCE_2);
    if (isBlank(sourceStep2Id)) {
      throw new MisconfiguredException("Please choose a step where the data to compare comes from");
    }

    this.inMemoryCompare = properties.is(IN_MEMORY_COMPARE);
    this.rowsPerMessage = properties.getInt(ROWS_PER_MESSAGE);
    Component comp = context.getFlowStep().getComponent();
    comp.setOutputModel(comp.getInputModel());
    Model inputModel = context.getFlowStep().getComponent().getInputModel();
    if (inputModel == null) {
      throw new MisconfiguredException("The input model is not set and it is required");
    }

    entities = new ArrayList<>(inputModel.getModelEntities());
    Collections.sort(
        entities,
        new Comparator<ModelEntity>() {
          @Override
          public int compare(ModelEntity o1, ModelEntity o2) {
            ComponentEntitySetting order1 =
                context
                    .getFlowStep()
                    .getComponent()
                    .getSingleEntitySetting(o1.getId(), DataDiff.ENTITY_ORDER);
            int orderValue1 = order1 != null ? Integer.parseInt(order1.getValue()) : 0;

            ComponentEntitySetting order2 =
                context
                    .getFlowStep()
                    .getComponent()
                    .getSingleEntitySetting(o2.getId(), DataDiff.ENTITY_ORDER);
            int orderValue2 = order2 != null ? Integer.parseInt(order2.getValue()) : 0;

            return new Integer(orderValue1).compareTo(new Integer(orderValue2));
          }
        });
  }