Merge "Add extra authorative TOSCA concepts"
[policy/models.git] / models-interactions / model-actors / actorServiceProvider / src / main / java / org / onap / policy / controlloop / actorserviceprovider / parameters / ControlLoopOperationParams.java
index 9259160..f287770 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,16 @@ import org.slf4j.LoggerFactory;
 public class ControlLoopOperationParams {
     private static final Logger logger = LoggerFactory.getLogger(ControlLoopOperationParams.class);
 
+    /*
+     * Optional keys within the "targetEntityIds" map.
+     */
+    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 +75,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 +97,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 +105,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 +148,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,8 +169,7 @@ public class ControlLoopOperationParams {
         return actorService
                     .getActor(getActor())
                     .getOperator(getOperation())
-                    .buildOperation(this)
-                    .start();
+                    .buildOperation(this);
         // @formatter:on
     }
 
@@ -159,7 +179,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;
     }
 
     /**
@@ -171,7 +191,6 @@ public class ControlLoopOperationParams {
         OperationOutcome outcome = new OperationOutcome();
         outcome.setActor(getActor());
         outcome.setOperation(getOperation());
-        outcome.setTarget(targetEntity);
 
         return outcome;
     }