LogoLogo
timvero.comMaven Repository
  • timveroOS SDK guide
  • timveroOS how-to
  • timveroOS admin-side setup
  • How to use Maven credentials
  • timveroOS SDKs
    • v. 7.11
      • Ubuntu environment setup
      • Data model setup
      • New data source connection, with Bud Financial example
      • Flow customization
      • Decision process execution
      • Participant/ assets dynamic profile setup
      • Documents flow integration setup
      • Application form setup
      • Application API Integration Guide
      • UI/ UX components
        • Collapsing blocks
    • v. 7.10
      • Ubuntu environment setup
      • Data model setup
      • New data source connection, with Bud Financial example
      • Flow customization
      • Participant/ assets dynamic profile setup
      • Documents flow integration setup
      • Application form setup
      • Application API Integration Guide
      • UI/ UX components
        • Collapsing blocks
Powered by GitBook
On this page

Was this helpful?

  1. timveroOS SDKs
  2. v. 7.11

Decision process execution

PreviousFlow customizationNextParticipant/ assets dynamic profile setup

Last updated 1 month ago

Was this helpful?

timveroOS allows the creation, configuration, and execution of an unlimited number of verification trees at any time from different parts of the system. timveroOS offers a ready-to-use module named flowable which includes a service for testing and launching verification trees named DecisionProcessStarter. This is a Java class that provides a public method start(DecisionProcessType<A extends ProcessEntity> processType, UUID entityId). This method accepts two parameters:

  • DecisionProcessType<A extends ProcessEntity> processType - the type of the verification tree being launched.

  • UUID entityId - the identification number of the entity being verified.

The Java class DecisionProcessType<A extends ProcessEntity> is an instance that represents the type of a specific tree.

  • A - the verified entity.

The DecisionProcessType class provides the following methods:

  • public DecisionProcessType(String name, Class<A> entityClass) - constructor, where the first parameter is the system name of the type in the form of a String, and the second parameter is the Java class of the verified entity.

The Java interface ProcessEntity should be inherited by the entity for which the verification trees need to be launched.

The ProcessEntity interface provides the following ready methods:

  • Map<UUID, ProcessExecution> getProcessExecutions() - a method that returns all ProcessExecution of the process entity.

  • Stream<ProcessExecution> getRealExecutions(DecisionProcessType<?> processType) - a method that allows getting a stream of all ProcessExecution of a specific type.

  • Optional<ProcessExecution> getLastRealExecution(DecisionProcessType<?> processType) - a method that allows getting an Optional of the last ProcessExecution of a specific type.

  • boolean isLastRealExecutionFailed(DecisionProcessType<?> processType) - a method that checks if the last launched tree of a specific type has failed. The result is true/false.

  • boolean isLastRealExecutionCompleted(DecisionProcessType<?> processType) - a method that checks if the last launched tree of a specific type has completed without errors. The result is true/false.

  • boolean hasRunningExecution(DecisionProcessType<?> processType) - a method that checks if the process entity has an execution of a specific type having execution status CREATED or STARTED.

*Stream - A sequence of elements supporting sequential and parallel aggregate operations()

**ProcessExecution - a Java object of the Flowable module that gathers all the information about the execution of a specific verification tree, including the type of tree, execution status, execution result, etc. The abstract Java class DecisionProcessPostProcessor<A extends ProcessEntity<?>> is intended for checking and processing data from the results of the verification trees. It provides the following methods:

  • public DecisionProcessPostProcessor(DecisionProcessType<?> processType) - a constructor that requires passing the DecisionProcessType, the type of a specific tree for which post-processing is needed.

  • abstract void postProcess - an abstract method that needs to be implemented according to the requirements of a specific project.

The auxiliary Java class DecisionFactValue allows setting up custom criteria-characteristics of the verified entity, analyzing which can help make one decision or another in the post-processing of the executed tree. To launch specific checks, it's necessary to configure the verified entity, configure the types of verification trees, set up criteria/characteristics of the verified entity, implement post-processings, and call the method to launch the tree. For illustration, let's consider an example of setting up a preliminary verification tree, Soft Hit, for a loan application participant. The first step is to configure the verified entity (participant), implementing the ProcessEntity interface:

@Entity
@Table(name = "participant")
public class Participant implements ProcessEntity {

    @Id
    @GeneratedValue
    @Nullable
    private UUID id; // ID entity

    private ParticipantStatus status;

    private String primaryId;

    ...

The Participant Java class inherits the ProcessEntity interface specifying the type of identification number, in this example, it's java.util.Long. The second step is to configure the type of verification tree, in our case, Soft Hit:

@Configuration
public class ApplicationConfiguration {

    // Soft Hit
    public static final DecisionProcessType<Participant> SOFT_HIT_TYPE = 
        new DecisionProcessType<>("SOFT_HIT", Participant.class);

The third step of the setup requires specifying the system criteria-characteristics of the verified entity. For our example, three criteria are sufficient:

  • WARNING - the participant needs to be sent for additional (manual) review.

  • ALERT - the participant has failed the check.

@Configuration
public class ApplicationDecisionFactValue {

    public static final DecisionFactValue WARNING = new DecisionFactValue("WARNING");
    public static final DecisionFactValue ALERT = new DecisionFactValue("ALERT");
}

This mechanism allows flexible configuration of the decision-making tree by saving warnings and alerts with custom details, based on which the reasons for specific events can be determined. The fourth and final setup step is to implement the logic for post-processing the executed verification tree. The Soft Hit tree post-processor:

@Component
public class SoftHitPostProcessor extends DecisionProcessPostProcessor<Participant> {

    public SoftHitPostProcessor() {
        super(ApplicationConfiguration.SOFT_HIT_TYPE);
    }

    @Override
    public void postProcess(ProcessExecution processExecution,
        ProcessExecutionResult processExecutionResult, A processEntity {
          // Getting a list of criteria-characteristics of the verified entity
          Set<DecisionFactValue> scoringValues = processExecutionResult
              .getDecisionFacts().stream()
              .map(DecisionFact::getValue)
              .collect(Collectors.toSet());

          if (scoringValues.contains(ApplicationDecisionFactValue.ALERT)) {
              log.debug("[SoftHit] Decline");
              // project-specific logic for declining the participant
          } else if (scoringValues.contains(ApplicationDecisionFactValue.WARNING)) {
              log.debug("[SoftHit] Manual Review");
              // project-specific logic for sending the participant for manual review
          } else {
              // project-specific logic for a successful check
          }
      }
}

After that, decision process can be launched by calling the start method of the DecisionProcessStarter service with process type and ID of the entity to verify:

@Service
public class ParticipantStateEventListener implements EntityEventListener<ParticipantStateChangeEvent> {

    @Autowired
    private DecisionProcessStarter decisionProcessStarter;
    
    @Override
    public void handle(ParticipantStateChangeEvent event) {
        Long participantId = event.getId();

        decisionProcessStarter.start(ApplicationConfiguration.SOFT_HIT_TYPE, participantId);
    }
}

In this example, a state tracking tool for the participant is used to launch the verification tree.

https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html