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;
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.
*/
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.
/**
* Payload data for the request.
*/
- private Map<String, String> payload;
+ private Map<String, Object> payload;
+
+ /**
+ * {@code True} if the preprocessing steps have already been executed, {@code false}
+ * otherwise.
+ */
+ // TODO remove this once the rules no longer reference it
+ 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 entitiy ids, extracted from the Policy. May be (@code null}, depending on
+ * the requirement of the operation to be invoked.
+ */
+ private Map<String, String> targetEntityIds;
/**
* Target entity.
*/
- @NotNull
+ // TODO to be removed
private String targetEntity;
/**
* @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(),
return actorService
.getActor(getActor())
.getOperator(getOperation())
- .startOperation(this);
+ .buildOperation(this);
// @formatter:on
}
* @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;
}
/**
*
* @return a new operation outcome
*/
+ // TODO to be removed
public OperationOutcome makeOutcome() {
+ return makeOutcome(getTargetEntity());
+ }
+
+ /**
+ * 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());