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 d0b7c26..f287770 100644 (file)
@@ -33,13 +33,11 @@ import lombok.Getter;
 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.VirtualControlLoopEvent;
 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;
 
@@ -54,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.
      */
@@ -67,13 +75,10 @@ public class ControlLoopOperationParams {
     private ActorService actorService;
 
     /**
-     * Event for which the operation applies.
-     */
-    private ControlLoopEventContext context;
-
-    /**
-     * If {@code null}, this value is extracted from the context.
+     * Request ID with which all actor operations are associated. Used to track requests
+     * across various components/servers.
      */
+    @NotNull
     private UUID requestId;
 
     /**
@@ -94,28 +99,22 @@ public class ControlLoopOperationParams {
      */
     private Map<String, Object> payload;
 
-    /**
-     * {@code True} if the preprocessing steps have already been executed, {@code false}
-     * otherwise.
-     */
-    private boolean preprocessed;
-
     /**
      * Number of retries allowed, or {@code null} if no retries.
      */
     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
@@ -180,11 +179,6 @@ public class ControlLoopOperationParams {
      * @return the event's request ID, or {@code null} if no request ID is available
      */
     public UUID getRequestId() {
-        if (requestId == null && context != null && context.getEvent() != null) {
-            // cache the request ID
-            requestId = context.getEvent().getRequestId();
-        }
-
         return requestId;
     }
 
@@ -197,7 +191,6 @@ public class ControlLoopOperationParams {
         OperationOutcome outcome = new OperationOutcome();
         outcome.setActor(getActor());
         outcome.setOperation(getOperation());
-        outcome.setTarget(targetEntity);
 
         return outcome;
     }
@@ -240,34 +233,6 @@ public class ControlLoopOperationParams {
      * @return the validation result
      */
     public BeanValidationResult validate() {
-        BeanValidationResult result =
-                        new BeanValidator().validateTop(ControlLoopOperationParams.class.getSimpleName(), this);
-
-        // validate that we have a request ID, or that we can get it from the context's
-        // event
-
-        if (context == null) {
-            // no context specified - invoker must provide a request ID then
-            result.validateNotNull("requestId", requestId);
-
-        } else if (requestId == null) {
-            // have a context, but no request ID - check the context's event for the
-            // request ID
-            BeanValidationResult contextResult = new BeanValidationResult("context", context);
-            VirtualControlLoopEvent event = context.getEvent();
-            contextResult.validateNotNull("event", event);
-
-            if (event != null) {
-                // cache the request id for later use
-                BeanValidationResult eventResult = new BeanValidationResult("event", event);
-                eventResult.validateNotNull("requestId", event.getRequestId());
-
-                contextResult.addResult(eventResult);
-            }
-
-            result.addResult(contextResult);
-        }
-
-        return result;
+        return new BeanValidator().validateTop(ControlLoopOperationParams.class.getSimpleName(), this);
     }
 }