Delete preprocessed flag from actors
[policy/models.git] / models-interactions / model-actors / actorServiceProvider / src / main / java / org / onap / policy / controlloop / actorserviceprovider / parameters / ControlLoopOperationParams.java
index 57fce40..2769697 100644 (file)
@@ -34,10 +34,10 @@ import org.onap.policy.common.parameters.BeanValidationResult;
 import org.onap.policy.common.parameters.BeanValidator;
 import org.onap.policy.common.parameters.annotations.NotNull;
 import org.onap.policy.controlloop.actorserviceprovider.ActorService;
+import org.onap.policy.controlloop.actorserviceprovider.Operation;
 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
+import org.onap.policy.controlloop.actorserviceprovider.TargetType;
 import org.onap.policy.controlloop.actorserviceprovider.Util;
-import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext;
-import org.onap.policy.controlloop.policy.Target;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,6 +52,13 @@ import org.slf4j.LoggerFactory;
 public class ControlLoopOperationParams {
     private static final Logger logger = LoggerFactory.getLogger(ControlLoopOperationParams.class);
 
+    public static final String PARAMS_ENTITY_RESOURCEID = "resourceID";
+    public static final String PARAMS_ENTITY_MODEL_INVARIANT_ID = "modelInvariantId";
+    public static final String PARAMS_ENTITY_MODEL_VERSION_ID = "modelVersionId";
+    public static final String PARAMS_ENTITY_MODEL_NAME = "modelName";
+    public static final String PARAMS_ENTITY_MODEL_VERSION = "modelVersion";
+    public static final String PARAMS_ENTITY_MODEL_CUSTOMIZATION_ID = "modelCustomizationId";
+
     /**
      * Actor name.
      */
@@ -65,10 +72,11 @@ public class ControlLoopOperationParams {
     private ActorService actorService;
 
     /**
-     * Event for which the operation applies.
+     * Request ID with which all actor operations are associated. Used to track requests
+     * across various components/servers.
      */
     @NotNull
-    private ControlLoopEventContext context;
+    private UUID requestId;
 
     /**
      * Executor to use to run the operation.
@@ -86,7 +94,7 @@ public class ControlLoopOperationParams {
     /**
      * Payload data for the request.
      */
-    private Map<String, String> payload;
+    private Map<String, Object> payload;
 
     /**
      * Number of retries allowed, or {@code null} if no retries.
@@ -94,16 +102,16 @@ public class ControlLoopOperationParams {
     private Integer retry;
 
     /**
-     * The entity's target information. May be {@code null}, depending on the requirement
-     * of the operation to be invoked.
+     * The Target Type information, extracted from the Policy. May be {@code null}, depending
+     * on the requirement of the operation to be invoked.
      */
-    private Target target;
+    private TargetType targetType;
 
     /**
-     * Target entity.
+     * Target entitiy ids, extracted from the Policy. May be (@code null}, depending on
+     * the requirement of the operation to be invoked.
      */
-    @NotNull
-    private String targetEntity;
+    private Map<String, String> targetEntityIds;
 
     /**
      * Timeout, in seconds, or {@code null} if no timeout. Zero and negative values also
@@ -137,6 +145,16 @@ public class ControlLoopOperationParams {
      * @throws IllegalArgumentException if the parameters are invalid
      */
     public CompletableFuture<OperationOutcome> start() {
+        return build().start();
+    }
+
+    /**
+     * Builds the specified operation.
+     *
+     * @return a new operation
+     * @throws IllegalArgumentException if the parameters are invalid
+     */
+    public Operation build() {
         BeanValidationResult result = validate();
         if (!result.isValid()) {
             logger.warn("parameter error in operation {}.{} for {}:\n{}", getActor(), getOperation(), getRequestId(),
@@ -148,7 +166,7 @@ public class ControlLoopOperationParams {
         return actorService
                     .getActor(getActor())
                     .getOperator(getOperation())
-                    .startOperation(this);
+                    .buildOperation(this);
         // @formatter:on
     }
 
@@ -158,7 +176,7 @@ public class ControlLoopOperationParams {
      * @return the event's request ID, or {@code null} if no request ID is available
      */
     public UUID getRequestId() {
-        return (context == null || context.getEvent() == null ? null : context.getEvent().getRequestId());
+        return requestId;
     }
 
     /**
@@ -167,6 +185,17 @@ public class ControlLoopOperationParams {
      * @return a new operation outcome
      */
     public OperationOutcome makeOutcome() {
+        return makeOutcome(null);
+    }
+
+    /**
+     * Makes an operation outcome, populating it from the parameters.
+     *
+     * @param targetEntity the target entity
+     *
+     * @return a new operation outcome
+     */
+    public OperationOutcome makeOutcome(String targetEntity) {
         OperationOutcome outcome = new OperationOutcome();
         outcome.setActor(getActor());
         outcome.setOperation(getOperation());