summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-impl/events/src/main/java
diff options
context:
space:
mode:
authorHengye <yehui.wang@est.tech>2019-03-25 14:32:21 +0000
committerHengye <yehui.wang@est.tech>2019-03-25 14:32:21 +0000
commitb150aa8197e8a21ab7ad4cf1d91cfa30f56fa3df (patch)
tree60c296267f496f3b40d838294e8f80b04ceb2607 /models-interactions/model-impl/events/src/main/java
parent2a245ef80e39a101015efb164de53f1753fa5d47 (diff)
migrate model-impl from drools-applications
migrate controlloop/common/model-impl from drools-applicaitons to policy/models Issue-ID: POLICY-1264 Change-Id: Ibe0bb5c49a7b1344f4104b30455f52834041e187 Signed-off-by: Hengye <yehui.wang@est.tech>
Diffstat (limited to 'models-interactions/model-impl/events/src/main/java')
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java193
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java60
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java191
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java74
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java230
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java55
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java60
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java37
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java38
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java86
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java85
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/params/ControlLoopParams.java93
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java126
13 files changed, 1328 insertions, 0 deletions
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
new file mode 100644
index 000000000..37d7538c6
--- /dev/null
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
@@ -0,0 +1,193 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import com.google.gson.annotations.SerializedName;
+import java.io.Serializable;
+import java.util.UUID;
+
+public abstract class ControlLoopEvent implements Serializable {
+
+ private static final long serialVersionUID = 2391252138583119195L;
+
+ @SerializedName("closedLoopControlName")
+ private String closedLoopControlName;
+
+ @SerializedName("version")
+ private String version = "1.0.2";
+
+ @SerializedName("requestID")
+ private UUID requestId;
+
+ @SerializedName("closedLoopEventClient")
+ private String closedLoopEventClient;
+
+ @SerializedName("target_type")
+ private ControlLoopTargetType targetType;
+
+ @SerializedName("target")
+ private String target;
+
+ @SerializedName("from")
+ private String from;
+
+ @SerializedName("policyScope")
+ private String policyScope;
+
+ @SerializedName("policyName")
+ private String policyName;
+
+ @SerializedName("policyVersion")
+ private String policyVersion;
+
+ @SerializedName("closedLoopEventStatus")
+ private ControlLoopEventStatus closedLoopEventStatus;
+
+ @SerializedName("payload")
+ private String payload;
+
+ public ControlLoopEvent() {
+
+ }
+
+ /**
+ * Construct an instace from an existing instance.
+ *
+ * @param event the existing instance
+ */
+ public ControlLoopEvent(ControlLoopEvent event) {
+ if (event == null) {
+ return;
+ }
+ this.closedLoopControlName = event.closedLoopControlName;
+ this.requestId = event.requestId;
+ this.closedLoopEventClient = event.closedLoopEventClient;
+ this.targetType = event.targetType;
+ this.target = event.target;
+ this.from = event.from;
+ this.policyScope = event.policyScope;
+ this.policyName = event.policyName;
+ this.policyVersion = event.policyVersion;
+ this.closedLoopEventStatus = event.closedLoopEventStatus;
+ this.payload = event.payload;
+ }
+
+ public boolean isEventStatusValid() {
+ return this.closedLoopEventStatus != null;
+ }
+
+ public String getClosedLoopControlName() {
+ return closedLoopControlName;
+ }
+
+ public void setClosedLoopControlName(String closedLoopControlName) {
+ this.closedLoopControlName = closedLoopControlName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public UUID getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(UUID requestId) {
+ this.requestId = requestId;
+ }
+
+ public String getClosedLoopEventClient() {
+ return closedLoopEventClient;
+ }
+
+ public void setClosedLoopEventClient(String closedLoopEventClient) {
+ this.closedLoopEventClient = closedLoopEventClient;
+ }
+
+ public ControlLoopTargetType getTargetType() {
+ return targetType;
+ }
+
+ public void setTargetType(ControlLoopTargetType targetType) {
+ this.targetType = targetType;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getFrom() {
+ return from;
+ }
+
+ public void setFrom(String from) {
+ this.from = from;
+ }
+
+ public String getPolicyScope() {
+ return policyScope;
+ }
+
+ public void setPolicyScope(String policyScope) {
+ this.policyScope = policyScope;
+ }
+
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+ public String getPolicyVersion() {
+ return policyVersion;
+ }
+
+ public void setPolicyVersion(String policyVersion) {
+ this.policyVersion = policyVersion;
+ }
+
+ public ControlLoopEventStatus getClosedLoopEventStatus() {
+ return closedLoopEventStatus;
+ }
+
+ public void setClosedLoopEventStatus(ControlLoopEventStatus closedLoopEventStatus) {
+ this.closedLoopEventStatus = closedLoopEventStatus;
+ }
+
+ public String getPayload() {
+ return payload;
+ }
+
+ public void setPayload(String payload) {
+ this.payload = payload;
+ }
+}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java
new file mode 100644
index 000000000..961a4f8f2
--- /dev/null
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+public enum ControlLoopEventStatus {
+ ONSET("ONSET"), ABATED("ABATED");
+
+ private String status;
+
+ private ControlLoopEventStatus(String status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ return this.status;
+ }
+
+ /**
+ * Convert a String status to a ControlLoopEventStatus.
+ *
+ * @param status the String status
+ * @return the ControlLoopEventStatus
+ */
+ public static ControlLoopEventStatus toStatus(String status) {
+ if (ONSET.status.equalsIgnoreCase(status)) {
+ return ONSET;
+ }
+ if (ABATED.status.equalsIgnoreCase(status)) {
+ return ABATED;
+ }
+ //
+ // In case DCAE uses the old abatement
+ //
+ if ("abatement".equalsIgnoreCase(status)) {
+ return ABATED;
+ }
+ return null;
+ }
+
+}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
new file mode 100644
index 000000000..a55c65e2f
--- /dev/null
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
@@ -0,0 +1,191 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import java.io.Serializable;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.UUID;
+
+public abstract class ControlLoopNotification implements Serializable {
+
+ private static final long serialVersionUID = 7538596984567127915L;
+
+ private String closedLoopControlName;
+ private String version = "1.0.2";
+ private UUID requestId;
+ private String closedLoopEventClient;
+ private ControlLoopTargetType targetType;
+ private String target;
+ private String from;
+ private String policyScope;
+ private String policyName;
+ private String policyVersion;
+ private ControlLoopNotificationType notification;
+ private String message;
+ private ZonedDateTime notificationTime = ZonedDateTime.now(ZoneOffset.UTC);
+ private Integer opsClTimer;
+ private List<ControlLoopOperation> history = new LinkedList<>();
+
+ public ControlLoopNotification() {
+
+ }
+
+ /**
+ * Construct an instance.
+ *
+ * @param event the event
+ */
+ public ControlLoopNotification(ControlLoopEvent event) {
+ if (event == null) {
+ return;
+ }
+
+ this.setClosedLoopControlName(event.getClosedLoopControlName());
+ this.setRequestId(event.getRequestId());
+ this.setClosedLoopEventClient(event.getClosedLoopEventClient());
+ this.setTargetType(event.getTargetType());
+ this.setTarget(event.getTarget());
+ }
+
+ public String getClosedLoopControlName() {
+ return closedLoopControlName;
+ }
+
+ public void setClosedLoopControlName(String closedLoopControlName) {
+ this.closedLoopControlName = closedLoopControlName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public UUID getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(UUID requestId) {
+ this.requestId = requestId;
+ }
+
+ public String getClosedLoopEventClient() {
+ return closedLoopEventClient;
+ }
+
+ public void setClosedLoopEventClient(String closedLoopEventClient) {
+ this.closedLoopEventClient = closedLoopEventClient;
+ }
+
+ public ControlLoopTargetType getTargetType() {
+ return targetType;
+ }
+
+ public void setTargetType(ControlLoopTargetType targetType) {
+ this.targetType = targetType;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getFrom() {
+ return from;
+ }
+
+ public void setFrom(String from) {
+ this.from = from;
+ }
+
+ public String getPolicyScope() {
+ return policyScope;
+ }
+
+ public void setPolicyScope(String policyScope) {
+ this.policyScope = policyScope;
+ }
+
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+ public String getPolicyVersion() {
+ return policyVersion;
+ }
+
+ public void setPolicyVersion(String policyVersion) {
+ this.policyVersion = policyVersion;
+ }
+
+ public ControlLoopNotificationType getNotification() {
+ return notification;
+ }
+
+ public void setNotification(ControlLoopNotificationType notification) {
+ this.notification = notification;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public ZonedDateTime getNotificationTime() {
+ return notificationTime;
+ }
+
+ public void setNotificationTime(ZonedDateTime notificationTime) {
+ this.notificationTime = notificationTime;
+ }
+
+ public Integer getOpsClTimer() {
+ return opsClTimer;
+ }
+
+ public void setOpsClTimer(Integer opsClTimer) {
+ this.opsClTimer = opsClTimer;
+ }
+
+ public List<ControlLoopOperation> getHistory() {
+ return history;
+ }
+
+ public void setHistory(List<ControlLoopOperation> history) {
+ this.history = history;
+ }
+}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java
new file mode 100644
index 000000000..51df8749d
--- /dev/null
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+public enum ControlLoopNotificationType {
+ ACTIVE("ACTIVE"), REJECTED("REJECTED"), OPERATION("OPERATION"), OPERATION_SUCCESS(
+ "OPERATION: SUCCESS"), OPERATION_FAILURE("OPERATION: FAILURE"), FINAL_FAILURE(
+ "FINAL: FAILURE"), FINAL_SUCCESS("FINAL: SUCCESS"), FINAL_OPENLOOP("FINAL: OPENLOOP");
+
+ private String type;
+
+ private ControlLoopNotificationType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String toString() {
+ return this.type;
+ }
+
+ /**
+ * Convert a String type to a ControlLoopNotificationType.
+ *
+ * @param type the String type
+ * @return the ControlLoopNotificationType
+ */
+ public static ControlLoopNotificationType toType(String type) {
+ if (ACTIVE.toString().equals(type)) {
+ return ACTIVE;
+ }
+ if (REJECTED.toString().equals(type)) {
+ return REJECTED;
+ }
+ if (OPERATION.toString().equals(type)) {
+ return OPERATION;
+ }
+ if (OPERATION_SUCCESS.toString().equals(type)) {
+ return OPERATION_SUCCESS;
+ }
+ if (OPERATION_FAILURE.toString().equals(type)) {
+ return OPERATION_FAILURE;
+ }
+ if (FINAL_FAILURE.toString().equals(type)) {
+ return FINAL_FAILURE;
+ }
+ if (FINAL_SUCCESS.toString().equals(type)) {
+ return FINAL_SUCCESS;
+ }
+ if (FINAL_OPENLOOP.toString().equals(type)) {
+ return FINAL_OPENLOOP;
+ }
+ return null;
+ }
+
+}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java
new file mode 100644
index 000000000..8fd4148ef
--- /dev/null
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java
@@ -0,0 +1,230 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import java.io.Serializable;
+import java.time.Instant;
+
+public class ControlLoopOperation implements Serializable {
+
+ private static final long serialVersionUID = 8662706581293017099L;
+
+ private String actor;
+ private String operation;
+ private String target;
+ private Instant start = Instant.now();
+ private Instant end;
+ private String subRequestId;
+ private String outcome;
+ private String message;
+
+ public ControlLoopOperation() {
+
+ }
+
+ /**
+ * Construct an instance from an existing instance.
+ *
+ * @param op the existing instance
+ */
+ public ControlLoopOperation(ControlLoopOperation op) {
+ if (op == null) {
+ return;
+ }
+
+ this.actor = op.actor;
+ this.operation = op.operation;
+ this.target = op.target;
+ this.start = op.start;
+ this.end = op.end;
+ this.subRequestId = op.subRequestId;
+ this.outcome = op.outcome;
+ this.message = op.message;
+ }
+
+ public String toMessage() {
+ return "actor=" + actor + ",operation=" + operation + ",target=" + target + ",subRequestId=" + subRequestId;
+ }
+
+ public String toHistory() {
+ return "actor=" + actor + ",operation=" + operation + ",target=" + target + ",start=" + start + ",end=" + end
+ + ",subRequestId=" + subRequestId + ",outcome=" + outcome + ",message=" + message;
+ }
+
+ public String getActor() {
+ return actor;
+ }
+
+ public void setActor(String actor) {
+ this.actor = actor;
+ }
+
+ public String getOperation() {
+ return operation;
+ }
+
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public Instant getStart() {
+ return start;
+ }
+
+ public void setStart(Instant start) {
+ this.start = start;
+ }
+
+ public Instant getEnd() {
+ return end;
+ }
+
+ public void setEnd(Instant end) {
+ this.end = end;
+ }
+
+ public String getSubRequestId() {
+ return subRequestId;
+ }
+
+ public void setSubRequestId(String subRequestId) {
+ this.subRequestId = subRequestId;
+ }
+
+ public String getOutcome() {
+ return outcome;
+ }
+
+ public void setOutcome(String outcome) {
+ this.outcome = outcome;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ @Override
+ public String toString() {
+ return "ControlLoopOperation [actor=" + actor + ", operation=" + operation + ", target=" + target + ", start="
+ + start + ", end=" + end + ", subRequestId=" + subRequestId + ", outcome=" + outcome + ", message="
+ + message + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((actor == null) ? 0 : actor.hashCode());
+ result = prime * result + ((end == null) ? 0 : end.hashCode());
+ result = prime * result + ((message == null) ? 0 : message.hashCode());
+ result = prime * result + ((operation == null) ? 0 : operation.hashCode());
+ result = prime * result + ((outcome == null) ? 0 : outcome.hashCode());
+ result = prime * result + ((start == null) ? 0 : start.hashCode());
+ result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
+ result = prime * result + ((target == null) ? 0 : target.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ControlLoopOperation other = (ControlLoopOperation) obj;
+ if (actor == null) {
+ if (other.actor != null) {
+ return false;
+ }
+ } else if (!actor.equals(other.actor)) {
+ return false;
+ }
+ if (end == null) {
+ if (other.end != null) {
+ return false;
+ }
+ } else if (!end.equals(other.end)) {
+ return false;
+ }
+ if (message == null) {
+ if (other.message != null) {
+ return false;
+ }
+ } else if (!message.equals(other.message)) {
+ return false;
+ }
+ if (operation == null) {
+ if (other.operation != null) {
+ return false;
+ }
+ } else if (!operation.equals(other.operation)) {
+ return false;
+ }
+ if (outcome == null) {
+ if (other.outcome != null) {
+ return false;
+ }
+ } else if (!outcome.equals(other.outcome)) {
+ return false;
+ }
+ if (start == null) {
+ if (other.start != null) {
+ return false;
+ }
+ } else if (!start.equals(other.start)) {
+ return false;
+ }
+ if (subRequestId == null) {
+ if (other.subRequestId != null) {
+ return false;
+ }
+ } else if (!subRequestId.equals(other.subRequestId)) {
+ return false;
+ }
+ if (target == null) {
+ if (other.target != null) {
+ return false;
+ }
+ } else if (!target.equals(other.target)) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java
new file mode 100644
index 000000000..35f482104
--- /dev/null
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import java.util.UUID;
+
+public class ControlLoopOperationWrapper {
+
+ private UUID requestId;
+ private ControlLoopOperation operation;
+
+ public ControlLoopOperationWrapper() {
+
+ }
+
+ public ControlLoopOperationWrapper(UUID requestId, ControlLoopOperation operation) {
+ this.requestId = requestId;
+ this.operation = operation;
+ }
+
+ public UUID getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(UUID requestId) {
+ this.requestId = requestId;
+ }
+
+ public ControlLoopOperation getOperation() {
+ return operation;
+ }
+
+ public void setOperation(ControlLoopOperation operation) {
+ this.operation = operation;
+ }
+}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java
new file mode 100644
index 000000000..e1d107be4
--- /dev/null
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+public enum ControlLoopTargetType {
+ VM("VM"), VF("VF"), VFC("VFC"), VNF("VNF");
+
+ private String type;
+
+ private ControlLoopTargetType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String toString() {
+ return this.type;
+ }
+
+ /**
+ * Convert a String type to a ControlLoopTargetType.
+ *
+ * @param type the String type
+ * @return the ControlLoopTargetType
+ */
+ public static ControlLoopTargetType toType(String type) {
+ if (VM.toString().equals(type)) {
+ return VM;
+ }
+ if (VF.toString().equals(type)) {
+ return VF;
+ }
+ if (VFC.toString().equals(type)) {
+ return VFC;
+ }
+ if (VNF.toString().equals(type)) {
+ return VNF;
+ }
+
+ return null;
+ }
+}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java
new file mode 100644
index 000000000..245e3a6bd
--- /dev/null
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+public class PhysicalControlLoopEvent extends ControlLoopEvent {
+ private static final long serialVersionUID = -7282930271094849487L;
+
+ public PhysicalControlLoopEvent() {}
+
+ /**
+ * Construct an instance from an existing instance.
+ *
+ * @param event the existing instance
+ */
+ public PhysicalControlLoopEvent(PhysicalControlLoopEvent event) {
+ super(event);
+ }
+}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java
new file mode 100644
index 000000000..a76b807f4
--- /dev/null
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+public class PhysicalControlLoopNotification extends ControlLoopNotification {
+ private static final long serialVersionUID = 8105197217140032892L;
+
+ public PhysicalControlLoopNotification() {}
+
+ /**
+ * Construct an instance from an existing instance.
+ *
+ * @param event the existing instance
+ */
+ public PhysicalControlLoopNotification(PhysicalControlLoopEvent event) {
+ super(event);
+ }
+
+}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java
new file mode 100644
index 000000000..1223d564c
--- /dev/null
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.Map;
+
+public class VirtualControlLoopEvent extends ControlLoopEvent {
+
+ private static final long serialVersionUID = -5752405682246066226L;
+
+ @SerializedName("closedLoopAlarmStart")
+ private Instant closedLoopAlarmStart;
+
+ @SerializedName("closedLoopAlarmEnd")
+ private Instant closedLoopAlarmEnd;
+
+ @SerializedName("AAI")
+ private Map<String, String> aai = new HashMap<>();
+
+ public VirtualControlLoopEvent() {}
+
+
+ /**
+ * Construct an instance from an existing instance.
+ *
+ * @param event the existing instance
+ */
+ public VirtualControlLoopEvent(VirtualControlLoopEvent event) {
+ super(event);
+ if (event == null) {
+ return;
+ }
+ if (event.aai != null) {
+ this.aai = new HashMap<>(event.aai);
+ }
+ this.closedLoopAlarmStart = event.closedLoopAlarmStart;
+ this.closedLoopAlarmEnd = event.closedLoopAlarmEnd;
+ }
+
+ public Instant getClosedLoopAlarmStart() {
+ return closedLoopAlarmStart;
+ }
+
+ public void setClosedLoopAlarmStart(Instant closedLoopAlarmStart) {
+ this.closedLoopAlarmStart = closedLoopAlarmStart;
+ }
+
+ public Instant getClosedLoopAlarmEnd() {
+ return closedLoopAlarmEnd;
+ }
+
+ public void setClosedLoopAlarmEnd(Instant closedLoopAlarmEnd) {
+ this.closedLoopAlarmEnd = closedLoopAlarmEnd;
+ }
+
+ public Map<String, String> getAai() {
+ return aai;
+ }
+
+ public void setAai(Map<String, String> aai) {
+ this.aai = aai;
+ }
+}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java
new file mode 100644
index 000000000..0a7436520
--- /dev/null
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.Map;
+
+public class VirtualControlLoopNotification extends ControlLoopNotification {
+
+ private static final long serialVersionUID = 5354756047932144017L;
+
+ @SerializedName("AAI")
+ private Map<String, String> aai = new HashMap<>();
+
+ @SerializedName("closedLoopAlarmStart")
+ private Instant closedLoopAlarmStart;
+
+ @SerializedName("closedLoopAlarmEnd")
+ private Instant closedLoopAlarmEnd;
+
+ public VirtualControlLoopNotification() {}
+
+ /**
+ * Construct an instance.
+ *
+ * @param event the event
+ */
+ public VirtualControlLoopNotification(VirtualControlLoopEvent event) {
+ super(event);
+ if (event == null) {
+ return;
+ }
+ if (event.getAai() != null) {
+ this.setAai(new HashMap<>(event.getAai()));
+ }
+ this.closedLoopAlarmStart = event.getClosedLoopAlarmStart();
+ this.closedLoopAlarmEnd = event.getClosedLoopAlarmEnd();
+ }
+
+ public Map<String, String> getAai() {
+ return aai;
+ }
+
+ public void setAai(Map<String, String> aai) {
+ this.aai = aai;
+ }
+
+ public Instant getClosedLoopAlarmStart() {
+ return closedLoopAlarmStart;
+ }
+
+ public void setClosedLoopAlarmStart(Instant closedLoopAlarmStart) {
+ this.closedLoopAlarmStart = closedLoopAlarmStart;
+ }
+
+ public Instant getClosedLoopAlarmEnd() {
+ return closedLoopAlarmEnd;
+ }
+
+ public void setClosedLoopAlarmEnd(Instant closedLoopAlarmEnd) {
+ this.closedLoopAlarmEnd = closedLoopAlarmEnd;
+ }
+}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/params/ControlLoopParams.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/params/ControlLoopParams.java
new file mode 100644
index 000000000..11b90af99
--- /dev/null
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/params/ControlLoopParams.java
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * AppcLcmActorServiceProvider
+ * ================================================================================
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.params;
+
+import java.io.Serializable;
+
+public class ControlLoopParams implements Serializable {
+
+ private static final long serialVersionUID = 970755684770982776L;
+
+ private String closedLoopControlName;
+ private String controlLoopYaml;
+ private String policyName;
+ private String policyScope;
+ private String policyVersion;
+
+ public ControlLoopParams() {
+ super();
+ }
+
+ /**
+ * Construct an instance from an existing instance.
+ *
+ * @param params the existing instance
+ */
+ public ControlLoopParams(ControlLoopParams params) {
+ this.closedLoopControlName = params.closedLoopControlName;
+ this.controlLoopYaml = params.controlLoopYaml;
+ this.policyName = params.policyName;
+ this.policyScope = params.policyScope;
+ this.policyVersion = params.policyVersion;
+ }
+
+ public String getClosedLoopControlName() {
+ return closedLoopControlName;
+ }
+
+ public void setClosedLoopControlName(String closedLoopControlName) {
+ this.closedLoopControlName = closedLoopControlName;
+ }
+
+ public String getControlLoopYaml() {
+ return controlLoopYaml;
+ }
+
+ public void setControlLoopYaml(String controlLoopYaml) {
+ this.controlLoopYaml = controlLoopYaml;
+ }
+
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+ public String getPolicyScope() {
+ return policyScope;
+ }
+
+ public void setPolicyScope(String policyScope) {
+ this.policyScope = policyScope;
+ }
+
+ public String getPolicyVersion() {
+ return policyVersion;
+ }
+
+ public void setPolicyVersion(String policyVersion) {
+ this.policyVersion = policyVersion;
+ }
+
+}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
new file mode 100644
index 000000000..b36ee7f6b
--- /dev/null
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
@@ -0,0 +1,126 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.util;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+import java.lang.reflect.Type;
+import java.time.Instant;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+import org.onap.policy.controlloop.ControlLoopNotificationType;
+import org.onap.policy.controlloop.ControlLoopTargetType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class Serialization {
+ public static final Gson gson =
+ new GsonBuilder().disableHtmlEscaping().registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter())
+ .registerTypeAdapter(Instant.class, new GsonInstantAdapter())
+ .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter()).create();
+
+
+ public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter())
+ .registerTypeAdapter(Instant.class, new GsonInstantAdapter())
+ .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter()).create();
+
+ public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter())
+ .registerTypeAdapter(Instant.class, new GsonInstantAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter()).create();
+
+ private Serialization() {}
+
+ public static class NotificationTypeAdapter
+ implements JsonSerializer<ControlLoopNotificationType>, JsonDeserializer<ControlLoopNotificationType> {
+ @Override
+ public JsonElement serialize(ControlLoopNotificationType src, Type typeOfSrc,
+ JsonSerializationContext context) {
+ return new JsonPrimitive(src.toString());
+ }
+
+ @Override
+ public ControlLoopNotificationType deserialize(JsonElement json, Type typeOfT,
+ JsonDeserializationContext context) {
+ return ControlLoopNotificationType.toType(json.getAsString());
+ }
+ }
+
+ public static class TargetTypeAdapter
+ implements JsonSerializer<ControlLoopTargetType>, JsonDeserializer<ControlLoopTargetType> {
+ @Override
+ public JsonElement serialize(ControlLoopTargetType src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toString());
+ }
+
+ @Override
+ public ControlLoopTargetType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
+ return ControlLoopTargetType.toType(json.getAsString());
+ }
+ }
+
+ public static class GsonUtcAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
+ private static final Logger logger = LoggerFactory.getLogger(GsonUtcAdapter.class);
+ public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
+
+ @Override
+ public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context) {
+ try {
+ return ZonedDateTime.parse(element.getAsString(), format);
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ }
+ return null;
+ }
+
+ @Override
+ public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) {
+ return new JsonPrimitive(datetime.format(format));
+ }
+ }
+
+ public static class GsonInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+
+ @Override
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
+ return Instant.ofEpochMilli(json.getAsLong());
+ }
+
+ @Override
+ public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toEpochMilli());
+ }
+
+ }
+
+}