diff options
Diffstat (limited to 'tosca-controlloop/models/src/main')
37 files changed, 0 insertions, 3467 deletions
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java deleted file mode 100644 index 4ef9bdcd9..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.io.Serializable; -import java.time.Instant; -import java.util.UUID; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import lombok.ToString; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -@NoArgsConstructor -@Data -@ToString -public class ClElementStatistics implements Serializable { - - private static final long serialVersionUID = 3284285693112271055L; - - @NonNull - private UUID id = UUID.randomUUID(); - - @NonNull - private ToscaConceptIdentifier participantId; - - @NonNull - private Instant timeStamp; - - @NonNull - private ControlLoopState controlLoopState; - - private long clElementUptime; - -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsList.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsList.java deleted file mode 100644 index 166f1e48f..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsList.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -@Getter -@Setter -@ToString -public class ClElementStatisticsList { - private List<ClElementStatistics> clElementStatistics; -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java deleted file mode 100644 index d0d79274c..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import org.apache.commons.collections4.MapUtils; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; - -/** - * Class to represent a control loop instance. - */ -@NoArgsConstructor -@Data -@EqualsAndHashCode(callSuper = true) -public class ControlLoop extends ToscaEntity implements Comparable<ControlLoop> { - @NonNull - private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); - - @NonNull - private ControlLoopState state = ControlLoopState.UNINITIALISED; - - @NonNull - private ControlLoopOrderedState orderedState = ControlLoopOrderedState.UNINITIALISED; - - private Map<UUID, ControlLoopElement> elements; - - @Override - public String getType() { - return definition.getName(); - } - - @Override - public String getTypeVersion() { - return definition.getVersion(); - } - - /** - * Copy contructor, does a deep copy. - * - * @param otherControlLoop the other element to copy from - */ - public ControlLoop(final ControlLoop otherControlLoop) { - super(otherControlLoop); - this.definition = new ToscaConceptIdentifier(otherControlLoop.definition); - this.state = otherControlLoop.state; - this.orderedState = otherControlLoop.orderedState; - this.elements = PfUtils.mapMap(otherControlLoop.elements, ControlLoopElement::new); - } - - @Override - public int compareTo(final ControlLoop other) { - return compareNameVersion(this, other); - } - - /** - * Set the ordered state on the control loop and on all its control loop elements. - * - * @param orderedState the state we want the control loop to transition to - */ - public void setCascadedOrderedState(final ControlLoopOrderedState orderedState) { - this.orderedState = orderedState; - - if (MapUtils.isEmpty(elements)) { - return; - } - - elements.values().forEach(element -> element.setOrderedState(orderedState)); - } - - /** - * Get a list of control loop element statistics. - * - * @param controlLoop the control loop - * @return List of ClElementStatistics - */ - public List<ClElementStatistics> getControlLoopElementStatisticsList(final ControlLoop controlLoop) { - if (MapUtils.isEmpty(controlLoop.elements)) { - return null; - } - - return controlLoop.elements.values().stream().map(ControlLoopElement::getClElementStatistics) - .collect(Collectors.toList()); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java deleted file mode 100644 index 83f062c74..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.util.UUID; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import lombok.ToString; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent a control loop instance. - */ -@NoArgsConstructor -@Data -@ToString -public class ControlLoopElement { - @NonNull - private UUID id = UUID.randomUUID(); - - @NonNull - private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); - - @NonNull - private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); - - @NonNull - private ToscaConceptIdentifier participantId = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); - - @NonNull - private ControlLoopState state = ControlLoopState.UNINITIALISED; - - @NonNull - private ControlLoopOrderedState orderedState = ControlLoopOrderedState.UNINITIALISED; - - private String description; - - private ClElementStatistics clElementStatistics; - - /** - * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. - * - * @param otherElement the other element to copy from - */ - public ControlLoopElement(final ControlLoopElement otherElement) { - this.id = otherElement.id; - this.definition = new ToscaConceptIdentifier(otherElement.definition); - this.participantType = new ToscaConceptIdentifier(otherElement.participantType); - this.participantId = new ToscaConceptIdentifier(otherElement.participantId); - this.state = otherElement.state; - this.orderedState = otherElement.orderedState; - this.description = otherElement.description; - this.clElementStatistics = otherElement.clElementStatistics; - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopOrderedState.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopOrderedState.java deleted file mode 100644 index 91f90275e..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopOrderedState.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -public enum ControlLoopOrderedState { - /** - * The control loop or control loop element should become uninitialised on participants, it should not exist on - * participants. - */ - UNINITIALISED, - /** - * The control loop or control loop element should initialised on the participants and be passive, that is, it is - * not handling control loop messages yet. - */ - PASSIVE, - /** The control loop or control loop element should running and is executing control loops. */ - RUNNING; - - public boolean equalsControlLoopState(final ControlLoopState controlLoopState) { - return this.name().equals(controlLoopState.name()); - } - - public ControlLoopState asState() { - return ControlLoopState.valueOf(this.name()); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopState.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopState.java deleted file mode 100644 index ff0d553af..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopState.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -public enum ControlLoopState { - /** - * The control loop or control loop element is not initialised on participants, it does not exist on participants. - */ - UNINITIALISED, - /** - * The control loop or control loop element is changing from unitialised to passive, it is being initialised onto - * participants. - */ - UNINITIALISED2PASSIVE, - /** - * The control loop or control loop element is initialised on the participants but is passive, that is, it is not - * handling control loop messages yet. - */ - PASSIVE, - /** - * The control loop or control loop element is changing from passive to running, the participants are preparing to - * execute control loops. - */ - PASSIVE2RUNNING, - /** The control loop or control loop element is running and is executing control loops. */ - RUNNING, - /** - * The control loop or control loop element is completing execution of current control loops but will not start - * running any more control loops and will become passive. - */ - RUNNING2PASSIVE, - /** - * The control loop or control loop element is changing from passive to unitialised, the control loop is being - * removed from participants. - */ - PASSIVE2UNINITIALISED; - - public boolean equalsControlLoopOrderedState(final ControlLoopOrderedState controlLoopOrderedState) { - return this.name().equals(controlLoopOrderedState.name()); - } - - public ControlLoopOrderedState asOrderedState() { - return ControlLoopOrderedState.valueOf(this.name()); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java deleted file mode 100644 index 8edcc3c11..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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.clamp.controlloop.models.controlloop.concepts; - -import java.util.List; -import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.models.base.PfUtils; - -@Getter -@Setter -@ToString -@NoArgsConstructor -@AllArgsConstructor -@EqualsAndHashCode -public class ControlLoops { - private List<ControlLoop> controlLoopList; - - /** - * Copy contructor, does a deep copy. - * - * @param otherControlLoops the other element to copy from - */ - public ControlLoops(final ControlLoops otherControlLoops) { - this.controlLoopList = PfUtils.mapList(controlLoopList, ControlLoop::new); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java deleted file mode 100644 index 3130b6c2f..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; - -/** - * Class to represent details of a running participant instance. - */ -@NoArgsConstructor -@Data -@EqualsAndHashCode(callSuper = true) -public class Participant extends ToscaEntity implements Comparable<Participant> { - @NonNull - private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); - - @NonNull - private ParticipantState participantState = ParticipantState.UNKNOWN; - - @NonNull - private ParticipantHealthStatus healthStatus = ParticipantHealthStatus.UNKNOWN; - - @Override - public String getType() { - return definition.getName(); - } - - @Override - public String getTypeVersion() { - return definition.getVersion(); - } - - @Override - public int compareTo(final Participant other) { - return compareNameVersion(this, other); - } - - /** - * Copy constructor. - * - * @param otherParticipant the participant to copy from - */ - public Participant(Participant otherParticipant) { - super(otherParticipant); - this.definition = new ToscaConceptIdentifier(otherParticipant.definition); - this.participantState = otherParticipant.participantState; - this.healthStatus = otherParticipant.healthStatus; - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantHealthStatus.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantHealthStatus.java deleted file mode 100644 index 0cf41c9cd..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantHealthStatus.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -/** - * Class to hold the possible values for health status of Participant. - */ -public enum ParticipantHealthStatus { - - /** - * Participant is healthy and working fine. - */ - HEALTHY, - - /** - * Participant is not healthy. - */ - NOT_HEALTHY, - - /** - * Participant is currently under test state and performing tests. - */ - TEST_IN_PROGRESS, - - /** - * The health status of the Participant is unknown. - */ - UNKNOWN -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantState.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantState.java deleted file mode 100644 index 1af32660d..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantState.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -/** - * Class to hold the possible values for mode of participant. - */ -public enum ParticipantState { - - /** - * Control Loop execution is unknown. - */ - UNKNOWN, - - /** - * Control Loop execution is always rejected. - */ - PASSIVE, - - /** - * Control Loop execution execution proceeds, but changes to domain state or context are not carried out. The - * participant returns an indication that it is running in SAFE mode together with the action it would have - * performed if it was operating in ACTIVE mode. - */ - SAFE, - - /** - * Control Loop execution execution proceeds and changes to domain and state are carried out in a test environment. - * The participant returns an indication that it is running in TEST mode together with the action it has performed - * on the test environment. - */ - TEST, - - /** - * Control Loop execution execution is executed in the live environment by the participant. - */ - ACTIVE, - - /** - * Control Loop execution execution is terminated and not available. - */ - TERMINATED -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java deleted file mode 100644 index 3a7b21fa1..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.io.Serializable; -import java.time.Instant; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import lombok.ToString; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -@NoArgsConstructor -@Data -@ToString -public class ParticipantStatistics implements Serializable { - private static final long serialVersionUID = 744036598792333124L; - - - @NonNull - private ToscaConceptIdentifier participantId; - - @NonNull - private Instant timeStamp; - - private ParticipantState state; - private ParticipantHealthStatus healthStatus; - private long eventCount; - private long lastExecutionTime; - private double averageExecutionTime; - private long upTime; - private long lastEnterTime; - private long lastStart; -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsList.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsList.java deleted file mode 100644 index a69f96f85..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsList.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -@Getter -@Setter -@ToString -public class ParticipantStatisticsList { - private List<ParticipantStatistics> statisticsList; -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java deleted file mode 100644 index c5ce99677..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java +++ /dev/null @@ -1,194 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import java.io.Serializable; -import java.util.List; -import java.util.UUID; -import javax.persistence.AttributeOverride; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import org.apache.commons.lang3.builder.CompareToBuilder; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.common.parameters.annotations.NotNull; -import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.base.PfReferenceTimestampKey; -import org.onap.policy.models.base.validation.annotations.VerifyKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent a controlloop element statistics in the database. - * - * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech) - */ -@Entity -@Table(name = "ClElementStatistics") -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) -@Data -@AllArgsConstructor -@EqualsAndHashCode(callSuper = false) -public class JpaClElementStatistics extends PfConcept implements PfAuthorative<ClElementStatistics>, Serializable { - - private static final long serialVersionUID = 621426717868738629L; - - @EmbeddedId - @VerifyKey - @NotNull - private PfReferenceTimestampKey key = new PfReferenceTimestampKey(); - - - @VerifyKey - @NotNull - // @formatter:off - @AttributeOverride(name = "name", column = @Column(name = "participant_name")) - @AttributeOverride(name = "version", column = @Column(name = "participant_version")) - private PfConceptKey participantId; - // @formatter: on - - @Column - @NotNull - private ControlLoopState state; - - @Column - private long clElementUptime; - - - /** - * The Default Constructor creates a {@link JpaClElementStatistics} object with a null key. - */ - public JpaClElementStatistics() { - this(new PfReferenceTimestampKey()); - } - - - /** - * The Key Constructor creates a {@link JpaClElementStatistics} object with the given Reference Timestamp key. - * - * @param key the key - */ - public JpaClElementStatistics(@NonNull final PfReferenceTimestampKey key) { - this(key, new PfConceptKey(), ControlLoopState.PASSIVE, 0L); - } - - /** - * The Key Constructor creates a {@link JpaClElementStatistics} object with all mandatory fields. - * - * @param key the key - * @param participantId the TOSCA definition of the control loop element - */ - public JpaClElementStatistics(@NonNull final PfReferenceTimestampKey key, - @NonNull final PfConceptKey participantId) { - this.key = key; - this.participantId = participantId; - } - - /** - * Copy constructor. - * - * @param copyConcept the concept to copy from - */ - public JpaClElementStatistics(@NonNull final JpaClElementStatistics copyConcept) { - super(copyConcept); - this.key = new PfReferenceTimestampKey(copyConcept.key); - this.participantId = new PfConceptKey(copyConcept.participantId); - this.state = copyConcept.state; - this.clElementUptime = copyConcept.clElementUptime; - } - - - /** - * Authorative constructor. - * - * @param authorativeConcept the authorative concept to copy from - */ - public JpaClElementStatistics(@NonNull final ClElementStatistics authorativeConcept) { - this.fromAuthorative(authorativeConcept); - } - - - - @Override - public ClElementStatistics toAuthorative() { - ClElementStatistics clElementStatistics = new ClElementStatistics(); - clElementStatistics.setId(UUID.fromString(getKey().getReferenceKey().getLocalName())); - clElementStatistics.setTimeStamp(key.getInstant()); - clElementStatistics.setParticipantId(new ToscaConceptIdentifier(participantId)); - clElementStatistics.setControlLoopState(state); - clElementStatistics.setClElementUptime(clElementUptime); - - return clElementStatistics; - } - - @Override - public void fromAuthorative(@NonNull ClElementStatistics clElementStatistics) { - // @formatter:off - if (this.key == null || this.getKey().isNullKey()) { - this.setKey(new PfReferenceTimestampKey(clElementStatistics.getParticipantId().getName(), - clElementStatistics.getParticipantId().getVersion(), clElementStatistics.getId().toString(), - clElementStatistics.getTimeStamp())); - } - // @formatter:on - this.setParticipantId(clElementStatistics.getParticipantId().asConceptKey()); - this.setState(clElementStatistics.getControlLoopState()); - this.setClElementUptime(clElementStatistics.getClElementUptime()); - } - - @Override - public List<PfKey> getKeys() { - return getKey().getKeys(); - } - - @Override - public void clean() { - key.clean(); - participantId.clean(); - } - - - @Override - public int compareTo(PfConcept otherConcept) { - if (otherConcept == null) { - return -1; - } - if (this == otherConcept) { - return 0; - } - if (getClass() != otherConcept.getClass()) { - return getClass().getName().compareTo(otherConcept.getClass().getName()); - } - - final JpaClElementStatistics other = (JpaClElementStatistics) otherConcept; - return new CompareToBuilder().append(this.key, other.key).append(this.state, other.state) - .append(this.clElementUptime, other.clElementUptime).toComparison(); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java deleted file mode 100644 index cac405abd..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java +++ /dev/null @@ -1,258 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.UUID; -import javax.persistence.AttributeOverride; -import javax.persistence.AttributeOverrides; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.ManyToMany; -import javax.persistence.Table; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import org.apache.commons.lang3.ObjectUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.common.parameters.annotations.NotNull; -import org.onap.policy.common.parameters.annotations.Valid; -import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.base.PfReferenceKey; -import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.base.validation.annotations.VerifyKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent a control loop in the database. - * - * @author Liam Fallon (liam.fallon@est.tech) - */ -@Entity -@Table(name = "ControlLoop") -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) -@Data -@EqualsAndHashCode(callSuper = false) -public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLoop> { - private static final long serialVersionUID = -4725410933242154805L; - - @EmbeddedId - @VerifyKey - @NotNull - private PfConceptKey key; - - // @formatter:off - @VerifyKey - @NotNull - @AttributeOverrides({ - @AttributeOverride(name = "name", column = @Column(name = "definition_name")), - @AttributeOverride(name = "version", column = @Column(name = "definition_version")) - } - ) - private PfConceptKey definition; - // @formatter:on - - @Column - @NotNull - private ControlLoopState state; - - @Column - @NotNull - private ControlLoopOrderedState orderedState; - - @Column - private String description; - - // @formatter:off - @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) - @NotNull - private Map<@NotNull UUID, @NotNull @Valid JpaControlLoopElement> elements; - - /** - * The Default Constructor creates a {@link JpaControlLoop} object with a null key. - */ - public JpaControlLoop() { - this(new PfConceptKey()); - } - - /** - * The Key Constructor creates a {@link JpaControlLoop} object with the given concept key. - * - * @param key the key - */ - public JpaControlLoop(@NonNull final PfConceptKey key) { - this(key, new PfConceptKey(), ControlLoopState.UNINITIALISED, new LinkedHashMap<>()); - } - - /** - * The Key Constructor creates a {@link JpaControlLoop} object with all mandatory fields. - * - * @param key the key - * @param definition the TOSCA definition of the control loop - * @param state the state of the control loop - * @param elements the elements of the control looop in participants - */ - public JpaControlLoop(@NonNull final PfConceptKey key, @NonNull final PfConceptKey definition, - @NonNull final ControlLoopState state, @NonNull final Map<UUID, JpaControlLoopElement> elements) { - this.key = key; - this.definition = definition; - this.state = state; - this.elements = elements; - } - - /** - * Copy constructor. - * - * @param copyConcept the concept to copy from - */ - public JpaControlLoop(@NonNull final JpaControlLoop copyConcept) { - super(copyConcept); - this.key = new PfConceptKey(copyConcept.key); - this.definition = new PfConceptKey(copyConcept.definition); - this.state = copyConcept.state; - this.orderedState = copyConcept.orderedState; - this.description = copyConcept.description; - this.elements = PfUtils.mapMap(copyConcept.elements, JpaControlLoopElement::new, new LinkedHashMap<>(0)); - } - - /** - * Authorative constructor. - * - * @param authorativeConcept the authorative concept to copy from - */ - public JpaControlLoop(@NonNull final ControlLoop authorativeConcept) { - this.fromAuthorative(authorativeConcept); - } - - @Override - public ControlLoop toAuthorative() { - ControlLoop controlLoop = new ControlLoop(); - - controlLoop.setName(getKey().getName()); - controlLoop.setVersion(getKey().getVersion()); - controlLoop.setDefinition(new ToscaConceptIdentifier(definition)); - controlLoop.setState(state); - controlLoop.setOrderedState(orderedState != null ? orderedState : state.asOrderedState()); - controlLoop.setDescription(description); - controlLoop.setElements(PfUtils.mapMap(elements, JpaControlLoopElement::toAuthorative, new LinkedHashMap<>(0))); - - return controlLoop; - } - - @Override - public void fromAuthorative(@NonNull final ControlLoop controlLoop) { - if (this.key == null || this.getKey().isNullKey()) { - this.setKey(new PfConceptKey(controlLoop.getName(), controlLoop.getVersion())); - } - - this.definition = controlLoop.getDefinition().asConceptKey(); - this.state = controlLoop.getState(); - this.orderedState = controlLoop.getOrderedState(); - this.description = controlLoop.getDescription(); - - this.elements = new LinkedHashMap<>(controlLoop.getElements().size()); - for (Entry<UUID, ControlLoopElement> elementEntry : controlLoop.getElements().entrySet()) { - JpaControlLoopElement jpaControlLoopElement = new JpaControlLoopElement(); - jpaControlLoopElement.setKey(new PfReferenceKey(getKey(), elementEntry.getValue().getId().toString())); - jpaControlLoopElement.fromAuthorative(elementEntry.getValue()); - this.elements.put(elementEntry.getKey(), jpaControlLoopElement); - } - } - - @Override - public List<PfKey> getKeys() { - List<PfKey> keyList = getKey().getKeys(); - - keyList.add(definition); - - for (JpaControlLoopElement element : elements.values()) { - keyList.addAll(element.getKeys()); - } - - return keyList; - } - - @Override - public void clean() { - key.clean(); - definition.clean(); - description = (description == null ? null : description.trim()); - - for (JpaControlLoopElement element : elements.values()) { - element.clean(); - } - } - - @Override - public int compareTo(final PfConcept otherConcept) { - if (otherConcept == null) { - return -1; - } - if (this == otherConcept) { - return 0; - } - if (getClass() != otherConcept.getClass()) { - return this.getClass().getName().compareTo(otherConcept.getClass().getName()); - } - - final JpaControlLoop other = (JpaControlLoop) otherConcept; - int result = key.compareTo(other.key); - if (result != 0) { - return result; - } - - result = definition.compareTo(other.definition); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(state, other.state); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(orderedState, other.orderedState); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(description, other.description); - if (result != 0) { - return result; - } - - return PfUtils.compareObjects(elements, other.elements); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java deleted file mode 100644 index 911a52089..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java +++ /dev/null @@ -1,251 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import java.util.List; -import java.util.UUID; -import javax.persistence.AttributeOverride; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import org.apache.commons.lang3.ObjectUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.common.parameters.annotations.NotNull; -import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.base.PfReferenceKey; -import org.onap.policy.models.base.validation.annotations.VerifyKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent a participant control loop element in the database. - * - * @author Liam Fallon (liam.fallon@est.tech) - */ -@Entity -@Table(name = "ControlLoopElement") -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) -@Data -@EqualsAndHashCode(callSuper = false) -public class JpaControlLoopElement extends PfConcept implements PfAuthorative<ControlLoopElement> { - private static final long serialVersionUID = -1791732273187890213L; - - @EmbeddedId - @VerifyKey - @NotNull - private PfReferenceKey key; - - // @formatter:off - @VerifyKey - @NotNull - @AttributeOverride(name = "name", column = @Column(name = "definition_name")) - @AttributeOverride(name = "version", column = @Column(name = "definition_version")) - private PfConceptKey definition; - - @VerifyKey - @NotNull - @AttributeOverride(name = "name", column = @Column(name = "participant_type_name")) - @AttributeOverride(name = "version", column = @Column(name = "participant_type_version")) - private PfConceptKey participantType; - - @NotNull - @AttributeOverride(name = "name", column = @Column(name = "participant_name")) - @AttributeOverride(name = "version", column = @Column(name = "participant_version")) - private PfConceptKey participantId; - // @formatter:on - - @Column - @NotNull - private ControlLoopState state; - - @Column - @NotNull - private ControlLoopOrderedState orderedState; - - @Column - private String description; - - /** - * The Default Constructor creates a {@link JpaControlLoopElement} object with a null key. - */ - public JpaControlLoopElement() { - this(new PfReferenceKey()); - } - - /** - * The Key Constructor creates a {@link JpaControlLoopElement} object with the given concept key. - * - * @param key the key - */ - public JpaControlLoopElement(@NonNull final PfReferenceKey key) { - this(key, new PfConceptKey(), new PfConceptKey(), ControlLoopState.UNINITIALISED); - } - - /** - * The Key Constructor creates a {@link JpaControlLoopElement} object with all mandatory fields. - * - * @param key the key - * @param definition the TOSCA definition of the control loop element - * @param participantType the TOSCA definition of the participant running the control loop element - * @param state the state of the control loop - */ - public JpaControlLoopElement(@NonNull final PfReferenceKey key, @NonNull final PfConceptKey definition, - @NonNull final PfConceptKey participantType, @NonNull final ControlLoopState state) { - this.key = key; - this.definition = definition; - this.participantType = participantType; - this.state = state; - } - - /** - * Copy constructor. - * - * @param copyConcept the concept to copy from - */ - public JpaControlLoopElement(@NonNull final JpaControlLoopElement copyConcept) { - super(copyConcept); - this.key = new PfReferenceKey(copyConcept.key); - this.definition = new PfConceptKey(copyConcept.definition); - this.participantType = new PfConceptKey(copyConcept.participantType); - this.participantId = new PfConceptKey(copyConcept.participantId); - this.state = copyConcept.state; - this.orderedState = copyConcept.orderedState; - this.description = copyConcept.description; - } - - /** - * Authorative constructor. - * - * @param authorativeConcept the authorative concept to copy from - */ - public JpaControlLoopElement(@NonNull final ControlLoopElement authorativeConcept) { - this.fromAuthorative(authorativeConcept); - } - - @Override - public ControlLoopElement toAuthorative() { - ControlLoopElement element = new ControlLoopElement(); - - element.setId(UUID.fromString(getKey().getLocalName())); - element.setDefinition(new ToscaConceptIdentifier(definition)); - element.setParticipantType(new ToscaConceptIdentifier(participantType)); - element.setParticipantId(new ToscaConceptIdentifier(participantId)); - element.setState(state); - element.setOrderedState(orderedState != null ? orderedState : state.asOrderedState()); - element.setDescription(description); - - return element; - } - - @Override - public void fromAuthorative(@NonNull final ControlLoopElement element) { - if (this.key == null || this.getKey().isNullKey()) { - this.setKey(new PfReferenceKey()); - getKey().setLocalName(element.getId().toString()); - } - - this.definition = element.getDefinition().asConceptKey(); - this.participantType = element.getParticipantType().asConceptKey(); - this.participantId = element.getParticipantId().asConceptKey(); - this.state = element.getState(); - this.orderedState = element.getOrderedState(); - this.description = element.getDescription(); - } - - @Override - public List<PfKey> getKeys() { - List<PfKey> keyList = getKey().getKeys(); - - keyList.add(definition); - keyList.add(participantType); - keyList.add(participantId); - - return keyList; - } - - @Override - public void clean() { - key.clean(); - definition.clean(); - participantType.clean(); - participantId.clean(); - - if (description != null) { - description = description.trim(); - } - } - - @Override - public int compareTo(final PfConcept otherConcept) { - if (otherConcept == null) { - return -1; - } - if (this == otherConcept) { - return 0; - } - if (getClass() != otherConcept.getClass()) { - return this.getClass().getName().compareTo(otherConcept.getClass().getName()); - } - - final JpaControlLoopElement other = (JpaControlLoopElement) otherConcept; - int result = key.compareTo(other.key); - if (result != 0) { - return result; - } - - result = definition.compareTo(other.definition); - if (result != 0) { - return result; - } - - result = participantType.compareTo(other.participantType); - if (result != 0) { - return result; - } - - result = participantId.compareTo(other.participantId); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(state, other.state); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(orderedState, other.orderedState); - if (result != 0) { - return result; - } - - return ObjectUtils.compare(description, other.description); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java deleted file mode 100644 index 69b565266..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java +++ /dev/null @@ -1,220 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import java.io.Serializable; -import java.util.List; -import javax.persistence.AttributeOverride; -import javax.persistence.AttributeOverrides; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import org.apache.commons.lang3.ObjectUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.common.parameters.annotations.NotNull; -import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.base.validation.annotations.VerifyKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent a participant in the database. - * - * @author Liam Fallon (liam.fallon@est.tech) - */ -@Entity -@Table(name = "Participant") -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) -@Data -@EqualsAndHashCode(callSuper = false) -public class JpaParticipant extends PfConcept implements PfAuthorative<Participant>, Serializable { - private static final long serialVersionUID = -4697758484642403483L; - - @EmbeddedId - @VerifyKey - @NotNull - private PfConceptKey key; - - // @formatter:off - @VerifyKey - @NotNull - @AttributeOverrides({ - @AttributeOverride(name = "name", column = @Column(name = "definition_name")), - @AttributeOverride(name = "version", column = @Column(name = "definition_version")) - } - ) - private PfConceptKey definition; - // @formatter:on - - @Column - @NotNull - private ParticipantState participantState; - - @Column - @NotNull - private ParticipantHealthStatus healthStatus; - - @Column - private String description; - - /** - * The Default Constructor creates a {@link JpaParticipant} object with a null key. - */ - public JpaParticipant() { - this(new PfConceptKey()); - } - - /** - * The Key Constructor creates a {@link JpaParticipant} object with the given concept key. - * - * @param key the key - */ - public JpaParticipant(@NonNull final PfConceptKey key) { - this(key, new PfConceptKey(), ParticipantState.PASSIVE, ParticipantHealthStatus.UNKNOWN); - } - - /** - * The Key Constructor creates a {@link JpaParticipant} object with all mandatory fields. - * - * @param key the key - * @param definition the TOSCA definition of the participant - * @param participantState the state of the participant - * @param healthStatus the health state of the participant - */ - public JpaParticipant(@NonNull final PfConceptKey key, @NonNull final PfConceptKey definition, - @NonNull final ParticipantState participantState, @NonNull ParticipantHealthStatus healthStatus) { - this.key = key; - this.definition = definition; - this.participantState = participantState; - this.healthStatus = healthStatus; - } - - /** - * Copy constructor. - * - * @param copyConcept the concept to copy from - */ - public JpaParticipant(@NonNull final JpaParticipant copyConcept) { - super(copyConcept); - this.key = new PfConceptKey(copyConcept.key); - this.definition = new PfConceptKey(copyConcept.definition); - this.participantState = copyConcept.participantState; - this.healthStatus = copyConcept.healthStatus; - this.description = copyConcept.description; - } - - /** - * Authorative constructor. - * - * @param authorativeConcept the authorative concept to copy from - */ - public JpaParticipant(@NonNull final Participant authorativeConcept) { - this.fromAuthorative(authorativeConcept); - } - - @Override - public Participant toAuthorative() { - Participant participant = new Participant(); - - participant.setName(key.getName()); - participant.setVersion(key.getVersion()); - participant.setDefinition(new ToscaConceptIdentifier(definition)); - participant.setParticipantState(participantState); - participant.setHealthStatus(healthStatus); - participant.setDescription(description); - - return participant; - } - - @Override - public void fromAuthorative(@NonNull final Participant participant) { - if (this.key == null || this.getKey().isNullKey()) { - this.setKey(new PfConceptKey(participant.getName(), participant.getVersion())); - } - - this.definition = participant.getDefinition().asConceptKey(); - this.setParticipantState(participant.getParticipantState()); - this.setHealthStatus(participant.getHealthStatus()); - this.setDescription(participant.getDescription()); - } - - @Override - public List<PfKey> getKeys() { - List<PfKey> keyList = getKey().getKeys(); - - keyList.add(definition); - - return keyList; - } - - @Override - public void clean() { - key.clean(); - definition.clean(); - description = (description == null ? null : description.trim()); - } - - @Override - public int compareTo(final PfConcept otherConcept) { - if (otherConcept == null) { - return -1; - } - if (this == otherConcept) { - return 0; - } - if (getClass() != otherConcept.getClass()) { - return getClass().getName().compareTo(otherConcept.getClass().getName()); - } - - final JpaParticipant other = (JpaParticipant) otherConcept; - int result = key.compareTo(other.key); - if (result != 0) { - return result; - } - - result = definition.compareTo(other.definition); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(participantState, other.participantState); - if (result != 0) { - return result; - } - - result = ObjectUtils.compare(healthStatus, other.healthStatus); - if (result != 0) { - return result; - } - - return ObjectUtils.compare(description, other.description); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java deleted file mode 100644 index b97f9ed69..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java +++ /dev/null @@ -1,237 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; - -import java.io.Serializable; -import java.util.List; -import javax.persistence.AttributeOverride; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import org.apache.commons.lang3.builder.CompareToBuilder; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; -import org.onap.policy.common.parameters.annotations.NotNull; -import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.base.PfTimestampKey; -import org.onap.policy.models.base.validation.annotations.VerifyKey; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent a control loop statistics in the database. - * - * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech) - */ -@Entity -@Table(name = "ParticipantStatistics") -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) -@Data -@AllArgsConstructor -@EqualsAndHashCode(callSuper = false) -public class JpaParticipantStatistics extends PfConcept implements PfAuthorative<ParticipantStatistics>, Serializable { - - private static final long serialVersionUID = -5992214428190133190L; - - @EmbeddedId - @VerifyKey - @NotNull - private PfTimestampKey key; - - @VerifyKey - @NotNull - @AttributeOverride(name = "name", column = @Column(name = "participant_name")) - @AttributeOverride(name = "version", column = @Column(name = "participant_version")) - private PfConceptKey participantId; - - @Column - @NotNull - private ParticipantState state; - - @Column - @NotNull - private ParticipantHealthStatus healthStatus; - - @Column - private long eventCount; - - @Column - private long lastExecutionTime; - - @Column - private double averageExecutionTime; - - @Column - private long upTime; - - @Column - private long lastEnterTime; - - @Column - private long lastStart; - - - /** - * The Default Constructor creates a {@link JpaParticipantStatistics} object with a null key. - */ - public JpaParticipantStatistics() { - this(new PfTimestampKey()); - } - - /** - * The Key Constructor creates a {@link JpaParticipantStatistics} object with the given Timestamp key. - * - * @param key the key - */ - public JpaParticipantStatistics(@NonNull final PfTimestampKey key) { - this(key, new PfConceptKey(), ParticipantState.PASSIVE, ParticipantHealthStatus.HEALTHY, 0L, 0L, 0.0d, 0L, 0L, - 0L); - } - - - /** - * The Key Constructor creates a {@link JpaParticipantStatistics} object with all mandatory fields. - * - * @param key the key - * @param participantId the TOSCA definition of the control loop participant - */ - public JpaParticipantStatistics(@NonNull final PfTimestampKey key, @NonNull final PfConceptKey participantId) { - this.key = key; - this.participantId = participantId; - } - - - /** - * Copy constructor. - * - * @param copyConcept the concept to copy from - */ - public JpaParticipantStatistics(@NonNull final JpaParticipantStatistics copyConcept) { - super(copyConcept); - this.key = new PfTimestampKey(copyConcept.key); - this.participantId = new PfConceptKey(copyConcept.participantId); - this.state = copyConcept.state; - this.healthStatus = copyConcept.healthStatus; - this.eventCount = copyConcept.eventCount; - this.lastExecutionTime = copyConcept.lastExecutionTime; - this.averageExecutionTime = copyConcept.averageExecutionTime; - this.upTime = copyConcept.upTime; - this.lastEnterTime = copyConcept.lastEnterTime; - this.lastStart = copyConcept.lastStart; - } - - /** - * Authorative constructor. - * - * @param authorativeConcept the authorative concept to copy from - */ - public JpaParticipantStatistics(@NonNull final ParticipantStatistics authorativeConcept) { - this.fromAuthorative(authorativeConcept); - } - - - @Override - public int compareTo(PfConcept otherConcept) { - if (otherConcept == null) { - return -1; - } - if (this == otherConcept) { - return 0; - } - if (getClass() != otherConcept.getClass()) { - return getClass().getName().compareTo(otherConcept.getClass().getName()); - } - - final JpaParticipantStatistics other = (JpaParticipantStatistics) otherConcept; - // @formatter:off - return new CompareToBuilder() - .append(this.key, other.key) - .append(this.participantId, other.participantId) - .append(this.state, other.state) - .append(this.healthStatus, other.healthStatus) - .append(this.eventCount, other.eventCount) - .append(this.lastExecutionTime, other.lastExecutionTime) - .append(this.averageExecutionTime, other.averageExecutionTime) - .append(this.upTime, other.upTime) - .append(this.lastEnterTime, other.lastEnterTime) - .append(this.lastStart, other.lastStart).toComparison(); - // @formatter:on - } - - @Override - public ParticipantStatistics toAuthorative() { - ParticipantStatistics participantStatistics = new ParticipantStatistics(); - participantStatistics.setTimeStamp(key.getTimeStamp().toInstant()); - participantStatistics.setParticipantId(new ToscaConceptIdentifier(participantId)); - participantStatistics.setState(state); - participantStatistics.setHealthStatus(healthStatus); - participantStatistics.setAverageExecutionTime(averageExecutionTime); - participantStatistics.setEventCount(eventCount); - participantStatistics.setLastExecutionTime(lastExecutionTime); - participantStatistics.setUpTime(upTime); - participantStatistics.setLastEnterTime(lastEnterTime); - participantStatistics.setLastStart(lastStart); - - return participantStatistics; - } - - @Override - public void fromAuthorative(@NonNull final ParticipantStatistics participantStatistics) { - if (this.key == null || this.getKey().isNullKey()) { - this.setKey(new PfTimestampKey(participantStatistics.getParticipantId().getName(), - participantStatistics.getParticipantId().getVersion(), participantStatistics.getTimeStamp())); - } - this.setParticipantId(participantStatistics.getParticipantId().asConceptKey()); - this.setState(participantStatistics.getState()); - this.setHealthStatus(participantStatistics.getHealthStatus()); - this.setAverageExecutionTime(participantStatistics.getAverageExecutionTime()); - this.setEventCount(participantStatistics.getEventCount()); - this.setLastExecutionTime(participantStatistics.getLastExecutionTime()); - this.setUpTime(participantStatistics.getUpTime()); - this.setLastEnterTime(participantStatistics.getLastEnterTime()); - this.setLastStart(participantStatistics.getLastStart()); - - } - - @Override - public List<PfKey> getKeys() { - List<PfKey> keyList = getKey().getKeys(); - keyList.addAll(participantId.getKeys()); - return keyList; - } - - @Override - public void clean() { - key.clean(); - participantId.clean(); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java deleted file mode 100644 index 8a06cbf1e..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java +++ /dev/null @@ -1,154 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import javax.ws.rs.core.Response; -import lombok.NonNull; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics; -import org.onap.policy.common.parameters.BeanValidationResult; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.base.PfModelRuntimeException; -import org.onap.policy.models.base.PfReferenceTimestampKey; -import org.onap.policy.models.provider.PolicyModelsProviderParameters; -import org.onap.policy.models.provider.impl.AbstractModelsProvider; - -/** - * This class provides the provision of information on control loop element statistics in the database to callers. - * - * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech) - */ -public class ClElementStatisticsProvider extends AbstractModelsProvider { - - /** - * Create a provider for control loop element statistics. - * - * @param parameters the parameters for database access - * @throws PfModelException on initiation errors - */ - public ClElementStatisticsProvider(@NonNull PolicyModelsProviderParameters parameters) throws PfModelException { - super(parameters); - this.init(); - } - - /** - * Creates control loop element statistics. - * - * @param clElementStatisticsList a specification of the CL element statistics to create - * @return the clElement statistics created - * @throws PfModelException on errors creating clElement statistics - */ - public List<ClElementStatistics> createClElementStatistics( - @NonNull final List<ClElementStatistics> clElementStatisticsList) throws PfModelException { - - BeanValidationResult validationResult = - new BeanValidationResult("control loop element statistics list", clElementStatisticsList); - for (ClElementStatistics clElementStatistics : clElementStatisticsList) { - JpaClElementStatistics jpaClElementStatistics = new JpaClElementStatistics(); - jpaClElementStatistics.fromAuthorative(clElementStatistics); - - validationResult.addResult(jpaClElementStatistics.validate("control loop element statistics")); - } - - if (!validationResult.isValid()) { - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); - } - - for (ClElementStatistics clElementStatistics : clElementStatisticsList) { - JpaClElementStatistics jpaClElementStatistics = new JpaClElementStatistics(); - jpaClElementStatistics.fromAuthorative(clElementStatistics); - getPfDao().create(jpaClElementStatistics); - } - - // Return the created control loop element statistics - List<ClElementStatistics> elementStatistics = new ArrayList<>(clElementStatisticsList.size()); - - for (ClElementStatistics clElementStat : clElementStatisticsList) { - JpaClElementStatistics jpaClElementStatistics = getPfDao().get(JpaClElementStatistics.class, - new PfReferenceTimestampKey(clElementStat.getParticipantId().getName(), - clElementStat.getParticipantId().getVersion(), clElementStat.getId().toString(), - clElementStat.getTimeStamp())); - elementStatistics.add(jpaClElementStatistics.toAuthorative()); - } - - return elementStatistics; - } - - /** - * Convert JPA clElement statistics list to clElement statistics list. - * - * @param jpaClElementStatistics the list to convert - * @return the clElement statistics list - */ - private List<ClElementStatistics> asClElementStatisticsList(List<JpaClElementStatistics> jpaClElementStatistics) { - return jpaClElementStatistics.stream().map(JpaClElementStatistics::toAuthorative).collect(Collectors.toList()); - } - - /** - * Get clElement statistics. - * - * @param name the name of the participant - * @param version version of the participant - * @param id of the control loop element - * @param timestamp timestamp of the statistics - * @return the clElement statistics found - * @throws PfModelException on errors getting clElement statistics - */ - public List<ClElementStatistics> getClElementStatistics(final String name, final String version, final String id, - final Instant timestamp) throws PfModelException { - List<ClElementStatistics> clElementStatistics = new ArrayList<>(1); - if (name != null && version != null && timestamp != null && id != null) { - clElementStatistics.add(getPfDao() - .get(JpaClElementStatistics.class, new PfReferenceTimestampKey(name, version, id, timestamp)) - .toAuthorative()); - return clElementStatistics; - } else if (name != null) { - clElementStatistics.addAll(getFilteredClElementStatistics(name, version, null, null, null, - "DESC", 0)); - } else { - clElementStatistics.addAll(asClElementStatisticsList(getPfDao().getAll(JpaClElementStatistics.class))); - } - return clElementStatistics; - } - - /** - * Get filtered clElement statistics. - * - * @param name the clElement name for the statistics to get - * @param startTimeStamp startTimeStamp to filter statistics - * @param endTimeStamp endTimeStamp to filter statistics - * @param sortOrder sortOrder to query database - * @param getRecordNum Total query count from database - * @return the clElement statistics found - * @throws PfModelException on errors getting policies - */ - public List<ClElementStatistics> getFilteredClElementStatistics(final String name, final String version, - final Instant startTimeStamp, final Instant endTimeStamp, Map<String, Object> filterMap, - final String sortOrder, final int getRecordNum) { - return asClElementStatisticsList(getPfDao().getFiltered(JpaClElementStatistics.class, name, version, - startTimeStamp, endTimeStamp, filterMap, sortOrder, getRecordNum)); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java deleted file mode 100644 index 520e9b864..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java +++ /dev/null @@ -1,248 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; -import javax.ws.rs.core.Response; -import lombok.NonNull; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop; -import org.onap.policy.common.parameters.BeanValidationResult; -import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.base.PfModelRuntimeException; -import org.onap.policy.models.provider.PolicyModelsProviderParameters; -import org.onap.policy.models.provider.impl.AbstractModelsProvider; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter; -import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate; - -/** - * This class provides information on control loop concepts in the database to callers. - */ -public class ControlLoopProvider extends AbstractModelsProvider { - - /** - * Create a provider for control loops. - * - * @param parameters the parameters for database access - * @throws PfModelException on initiation errors - */ - public ControlLoopProvider(@NonNull PolicyModelsProviderParameters parameters) throws PfModelException { - super(parameters); - this.init(); - } - - /** - * Get Control Loop. - * - * @param controlLoopId the ID of the control loop to get - * @return the control loop found - * @throws PfModelException on errors getting the control loop - */ - public ControlLoop getControlLoop(final ToscaConceptIdentifier controlLoopId) throws PfModelException { - JpaControlLoop jpaControlLoop = getPfDao().get(JpaControlLoop.class, controlLoopId.asConceptKey()); - - return jpaControlLoop == null ? null : jpaControlLoop.toAuthorative(); - } - - /** - * Update Control Loop. - * - * @param controlLoop the control loop to update - * @return the updated control loop - * @throws PfModelException on errors updating the control loop - */ - public ControlLoop updateControlLoop(final ControlLoop controlLoop) throws PfModelException { - return updateControlLoops(Collections.singletonList(controlLoop)).get(0); - } - - /** - * Get Control Loops. - * - * @param name the name of the control loop to get, null to get all control loops - * @param version the version of the control loop to get, null to get all control loops - * @return the control loops found - * @throws PfModelException on errors getting control loops - */ - public List<ControlLoop> getControlLoops(final String name, final String version) throws PfModelException { - - return asEntityList(getPfDao().getFiltered(JpaControlLoop.class, name, version)); - } - - /** - * Get filtered control loops. - * - * @param filter the filter for the control loops to get - * @return the control loops found - * @throws PfModelException on errors getting control loops - */ - public List<ControlLoop> getFilteredControlLoops(@NonNull final ToscaTypedEntityFilter<ControlLoop> filter) { - - return filter.filter( - asEntityList(getPfDao().getFiltered(JpaControlLoop.class, filter.getName(), PfKey.NULL_KEY_VERSION))); - } - - /** - * Creates control loops. - * - * @param controlLoops a specification of the control loops to create - * @return the control loops created - * @throws PfModelException on errors creating control loops - */ - public List<ControlLoop> createControlLoops(@NonNull final List<ControlLoop> controlLoops) throws PfModelException { - - BeanValidationResult validationResult = new BeanValidationResult("control loops", controlLoops); - - for (ControlLoop controlLoop : controlLoops) { - JpaControlLoop jpaControlLoop = new JpaControlLoop(); - jpaControlLoop.fromAuthorative(controlLoop); - - validationResult.addResult(jpaControlLoop.validate("control loop")); - } - - if (!validationResult.isValid()) { - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); - } - - for (ControlLoop controlLoop : controlLoops) { - JpaControlLoop jpaControlLoop = new JpaControlLoop(); - jpaControlLoop.fromAuthorative(controlLoop); - - getPfDao().create(jpaControlLoop); - } - - // Return the created control loops - List<ControlLoop> returnControlLoops = new ArrayList<>(controlLoops.size()); - - for (ControlLoop controlLoop : controlLoops) { - JpaControlLoop jpaControlLoop = getPfDao().get(JpaControlLoop.class, - new PfConceptKey(controlLoop.getName(), controlLoop.getVersion())); - returnControlLoops.add(jpaControlLoop.toAuthorative()); - } - - return returnControlLoops; - } - - /** - * Updates control loops. - * - * @param controlLoops a specification of the control loops to update - * @return the control loops updated - * @throws PfModelException on errors updating control loops - */ - public List<ControlLoop> updateControlLoops(@NonNull final List<ControlLoop> controlLoops) throws PfModelException { - - BeanValidationResult validationResult = new BeanValidationResult("control loops", controlLoops); - - for (ControlLoop controlLoop : controlLoops) { - JpaControlLoop jpaControlLoop = new JpaControlLoop(); - jpaControlLoop.fromAuthorative(controlLoop); - - validationResult.addResult(jpaControlLoop.validate("control loop")); - } - - if (!validationResult.isValid()) { - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); - } - - // Return the created control loops - List<ControlLoop> returnControlLoops = new ArrayList<>(controlLoops.size()); - - for (ControlLoop controlLoop : controlLoops) { - JpaControlLoop jpaControlLoop = new JpaControlLoop(); - jpaControlLoop.fromAuthorative(controlLoop); - - JpaControlLoop returnJpaControlLoop = getPfDao().update(jpaControlLoop); - returnControlLoops.add(returnJpaControlLoop.toAuthorative()); - } - - return returnControlLoops; - } - - /** - * Delete a control loop. - * - * @param name the name of the control loop to delete - * @param version the version of the control loop to delete - * @return the control loop deleted - * @throws PfModelException on errors deleting the control loop - */ - public ControlLoop deleteControlLoop(@NonNull final String name, @NonNull final String version) { - - PfConceptKey controlLoopKey = new PfConceptKey(name, version); - - JpaControlLoop jpaDeleteControlLoop = getPfDao().get(JpaControlLoop.class, controlLoopKey); - - if (jpaDeleteControlLoop == null) { - String errorMessage = - "delete of control loop \"" + controlLoopKey.getId() + "\" failed, control loop does not exist"; - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage); - } - - getPfDao().delete(jpaDeleteControlLoop); - - return jpaDeleteControlLoop.toAuthorative(); - } - - /** - * Get Node Templates. - * - * @param name the name of the node template to get, null to get all node templates - * @param version the version of the node template to get, null to get all node templates - * @return the node templates found - * @throws PfModelException on errors getting node templates - */ - public List<ToscaNodeTemplate> getNodeTemplates(final String name, final String version) { - return asEntityList(getPfDao().getFiltered(JpaToscaNodeTemplate.class, name, version)); - } - - /** - * Get filtered node templates. - * - * @param filter the filter for the node templates to get - * @return the node templates found - * @throws PfModelException on errors getting node templates - */ - public List<ToscaNodeTemplate> getFilteredNodeTemplates( - @NonNull final ToscaTypedEntityFilter<ToscaNodeTemplate> filter) { - - return filter.filter(asEntityList( - getPfDao().getFiltered(JpaToscaNodeTemplate.class, filter.getName(), filter.getVersion()))); - } - - /** - * Convert JPA control loop list to an authorative control loop list. - * - * @param jpaEntityList the list to convert - * @return the authorative list - */ - private <T extends ToscaEntity, J extends PfAuthorative<T>> List<T> asEntityList(List<J> jpaEntityList) { - return jpaEntityList.stream().map(J::toAuthorative).collect(Collectors.toList()); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java deleted file mode 100644 index e82956f93..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java +++ /dev/null @@ -1,195 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; -import javax.ws.rs.core.Response; -import lombok.NonNull; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant; -import org.onap.policy.common.parameters.BeanValidationResult; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.base.PfModelRuntimeException; -import org.onap.policy.models.provider.PolicyModelsProviderParameters; -import org.onap.policy.models.provider.impl.AbstractModelsProvider; -import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter; - -/** - * This class provides information on participant concepts in the database to callers. - */ -public class ParticipantProvider extends AbstractModelsProvider { - /** - * Create a provider for participants. - * - * @param parameters the parameters for database access - * @throws PfModelException on initiation errors - */ - public ParticipantProvider(@NonNull PolicyModelsProviderParameters parameters) throws PfModelException { - super(parameters); - this.init(); - } - - /** - * Get participants. - * - * @param name the name of the participant to get, null to get all participants - * @param version the version of the participant to get, null to get all participants - * @return the participants found - * @throws PfModelException on errors getting participants - */ - public List<Participant> getParticipants(final String name, final String version) throws PfModelException { - - return asParticipantList(getPfDao().getFiltered(JpaParticipant.class, name, version)); - } - - /** - * Get filtered participants. - * - * @param filter the filter for the participants to get - * @return the participants found - * @throws PfModelException on errors getting policies - */ - public List<Participant> getFilteredParticipants(@NonNull final ToscaTypedEntityFilter<Participant> filter) { - - return filter.filter(asParticipantList( - getPfDao().getFiltered(JpaParticipant.class, filter.getName(), filter.getVersion()))); - } - - /** - * Creates participants. - * - * @param participants a specification of the participants to create - * @return the participants created - * @throws PfModelException on errors creating participants - */ - public List<Participant> createParticipants(@NonNull final List<Participant> participants) throws PfModelException { - - BeanValidationResult validationResult = new BeanValidationResult("participants", participants); - - for (Participant participant : participants) { - JpaParticipant jpaParticipant = new JpaParticipant(); - jpaParticipant.fromAuthorative(participant); - - validationResult.addResult(jpaParticipant.validate("participant")); - } - - if (!validationResult.isValid()) { - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); - } - - for (Participant participant : participants) { - JpaParticipant jpaParticipant = new JpaParticipant(); - jpaParticipant.fromAuthorative(participant); - - getPfDao().create(jpaParticipant); - } - - // Return the created participants - List<Participant> returnParticipants = new ArrayList<>(participants.size()); - - for (Participant participant : participants) { - JpaParticipant jpaParticipant = getPfDao().get(JpaParticipant.class, - new PfConceptKey(participant.getName(), participant.getVersion())); - returnParticipants.add(jpaParticipant.toAuthorative()); - } - - return returnParticipants; - } - - /** - * Updates participants. - * - * @param participants a specification of the participants to update - * @return the participants updated - * @throws PfModelException on errors updating participants - */ - public List<Participant> updateParticipants(@NonNull final List<Participant> participants) throws PfModelException { - - BeanValidationResult validationResult = new BeanValidationResult("participants", participants); - - for (Participant participant : participants) { - JpaParticipant jpaParticipant = new JpaParticipant(); - jpaParticipant.fromAuthorative(participant); - - validationResult.addResult(jpaParticipant.validate("participant")); - } - - if (!validationResult.isValid()) { - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); - } - - for (Participant participant : participants) { - JpaParticipant jpaParticipant = new JpaParticipant(); - jpaParticipant.fromAuthorative(participant); - - getPfDao().update(jpaParticipant); - } - - // Return the created participants - List<Participant> returnParticipants = new ArrayList<>(participants.size()); - - for (Participant participant : participants) { - JpaParticipant jpaParticipant = getPfDao().get(JpaParticipant.class, - new PfConceptKey(participant.getName(), participant.getVersion())); - returnParticipants.add(jpaParticipant.toAuthorative()); - } - - return returnParticipants; - } - - /** - * Delete a participant. - * - * @param name the name of the participant to delete - * @param version the version of the participant to get - * @return the participant deleted - * @throws PfModelException on errors deleting participants - */ - public Participant deleteParticipant(@NonNull final String name, @NonNull final String version) { - - PfConceptKey participantKey = new PfConceptKey(name, version); - - JpaParticipant jpaDeleteParticipant = getPfDao().get(JpaParticipant.class, participantKey); - - if (jpaDeleteParticipant == null) { - String errorMessage = - "delete of participant \"" + participantKey.getId() + "\" failed, participant does not exist"; - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage); - } - - getPfDao().delete(jpaDeleteParticipant); - - return jpaDeleteParticipant.toAuthorative(); - } - - /** - * Convert JPA participant list to an authorative participant list. - * - * @param foundParticipants the list to convert - * @return the authorative list - */ - private List<Participant> asParticipantList(List<JpaParticipant> jpaParticipantList) { - return jpaParticipantList.stream().map(JpaParticipant::toAuthorative).collect(Collectors.toList()); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java deleted file mode 100644 index 6b075278c..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java +++ /dev/null @@ -1,159 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import javax.ws.rs.core.Response; -import lombok.NonNull; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics; -import org.onap.policy.common.parameters.BeanValidationResult; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.base.PfModelRuntimeException; -import org.onap.policy.models.base.PfTimestampKey; -import org.onap.policy.models.provider.PolicyModelsProviderParameters; -import org.onap.policy.models.provider.impl.AbstractModelsProvider; - -/** - * This class provides the provision of information on participant statistics in the database to callers. - * - * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech) - */ -public class ParticipantStatisticsProvider extends AbstractModelsProvider { - - /** - * Create a provider for control loops statistics. - * - * @param parameters the parameters for database access - * @throws PfModelException on initiation errors - */ - public ParticipantStatisticsProvider(@NonNull PolicyModelsProviderParameters parameters) throws PfModelException { - super(parameters); - this.init(); - } - - /** - * Get Participant statistics. - * - * @param name the name of the participant statistics to get, null to get all stats - * @return the participant statistics found - * @throws PfModelException on errors getting participant statistics - */ - public List<ParticipantStatistics> getParticipantStatistics(final String name, final String version, - final Instant timestamp) throws PfModelException { - - if (name != null && version != null && timestamp != null) { - List<ParticipantStatistics> participantStatistics = new ArrayList<>(1); - participantStatistics.add(getPfDao() - .get(JpaParticipantStatistics.class, new PfTimestampKey(name, version, timestamp)).toAuthorative()); - return participantStatistics; - } else if (name != null) { - return getFilteredParticipantStatistics(name, version, timestamp, null, null, - "DESC", 0); - } else { - return asParticipantStatisticsList(getPfDao().getAll(JpaParticipantStatistics.class)); - } - } - - - /** - * Get filtered participant statistics. - * - * @param name the participant name for the statistics to get - * @param startTimeStamp startTimeStamp to filter statistics - * @param endTimeStamp endTimeStamp to filter statistics - * @param sortOrder sortOrder to query database - * @param getRecordNum Total query count from database - * @return the participant statistics found - * @throws PfModelException on errors getting policies - */ - public List<ParticipantStatistics> getFilteredParticipantStatistics(final String name, final String version, - final Instant startTimeStamp, final Instant endTimeStamp, Map<String, Object> filterMap, - final String sortOrder, final int getRecordNum) { - - return asParticipantStatisticsList(getPfDao().getFiltered(JpaParticipantStatistics.class, name, version, - startTimeStamp, endTimeStamp, filterMap, sortOrder, getRecordNum)); - } - - - /** - * Creates Participant statistics. - * - * @param participantStatisticsList a specification of the CL statistics to create - * @return the participant statistics created - * @throws PfModelException on errors creating participant statistics - */ - public List<ParticipantStatistics> createParticipantStatistics( - @NonNull final List<ParticipantStatistics> participantStatisticsList) throws PfModelException { - - BeanValidationResult validationResult = - new BeanValidationResult("participant statistics List", participantStatisticsList); - - for (ParticipantStatistics participantStatistics : participantStatisticsList) { - JpaParticipantStatistics jpaParticipantStatistics = new JpaParticipantStatistics(); - jpaParticipantStatistics.fromAuthorative(participantStatistics); - - validationResult.addResult(jpaParticipantStatistics.validate("participant statistics")); - } - - if (!validationResult.isValid()) { - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); - } - - for (ParticipantStatistics participantStatistics : participantStatisticsList) { - JpaParticipantStatistics jpaParticipantStatistics = new JpaParticipantStatistics(); - jpaParticipantStatistics.fromAuthorative(participantStatistics); - - getPfDao().create(jpaParticipantStatistics); - } - - // Return the created participant statistics - List<ParticipantStatistics> participantStatistics = new ArrayList<>(participantStatisticsList.size()); - - for (ParticipantStatistics participantStatisticsItem : participantStatisticsList) { - JpaParticipantStatistics jpaParticipantStatistics = getPfDao().get(JpaParticipantStatistics.class, - new PfTimestampKey(participantStatisticsItem.getParticipantId().getName(), - participantStatisticsItem.getParticipantId().getVersion(), - participantStatisticsItem.getTimeStamp())); - participantStatistics.add(jpaParticipantStatistics.toAuthorative()); - } - - return participantStatistics; - } - - - /** - * Convert JPA participant statistics list to participant statistics list. - * - * @param jpaParticipantStatisticsList the list to convert - * @return the participant statistics list - */ - private List<ParticipantStatistics> asParticipantStatisticsList( - List<JpaParticipantStatistics> jpaParticipantStatisticsList) { - - return jpaParticipantStatisticsList.stream().map(JpaParticipantStatistics::toAuthorative) - .collect(Collectors.toList()); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotification.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotification.java deleted file mode 100644 index c6bbd81d6..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotification.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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.clamp.controlloop.models.messages.dmaap.notification; - -import com.google.gson.annotations.SerializedName; -import java.util.ArrayList; -import java.util.List; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.apache.commons.collections4.CollectionUtils; - -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ControlLoopNotification { - - /** - * Status of control loops that are being added to participants. - */ - @SerializedName("deployed-control-loops") - private List<ControlLoopStatus> added = new ArrayList<>(); - - /** - * Status of policies that are being deleted from PDPs. - */ - @SerializedName("undeployed-control-loops") - private List<ControlLoopStatus> deleted = new ArrayList<>(); - - - /** - * Determines if the notification is empty (i.e., has no added or delete control loop - * notifications). - * - * @return {@code true} if the notification is empty, {@code false} otherwise - */ - public boolean isEmpty() { - return (CollectionUtils.isEmpty(added) && CollectionUtils.isEmpty(deleted)); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatus.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatus.java deleted file mode 100644 index 033843e75..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatus.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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.clamp.controlloop.models.messages.dmaap.notification; - -import com.google.gson.annotations.SerializedName; -import java.util.UUID; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ControlLoopStatus { - @SerializedName("control-loop-id") - private UUID id; - - private ToscaConceptIdentifier definition; -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChange.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChange.java deleted file mode 100644 index 1a9a891f6..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChange.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; - -/** - * Class to represent the PARTICIPANT_CONTROL_LOOP_STATE_CHANGE message that the control loop runtime will send to - * participants to change the state of a control loop they are running. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ParticipantControlLoopStateChange extends ParticipantMessage { - private ControlLoopOrderedState orderedState; - - /** - * Constructor for instantiating ParticipantControlLoopStateChange class with message name. - * - */ - public ParticipantControlLoopStateChange() { - super(ParticipantMessageType.PARTICIPANT_CONTROL_LOOP_STATE_CHANGE); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantControlLoopStateChange(ParticipantControlLoopStateChange source) { - super(source); - - this.orderedState = source.orderedState; - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdate.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdate.java deleted file mode 100644 index ed729a64b..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdate.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; - -/** - * Class to represent the PARTICIPANT_CONTROL_LOOP_UPDATE message that the control loop runtime sends to a participant. - * When a participant receives this message, it creates the control loop elements contained in the message and sets them - * to state PASSIVE. subsequent PARTICIPANT_CONTROL_LOOP_STATE_CHANGE messages are used to activate the control loops. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ParticipantControlLoopUpdate extends ParticipantMessage { - // The control loop - private ControlLoop controlLoop; - - // A service template containing a complete definition of the control loop - private ToscaServiceTemplate controlLoopDefinition; - - /** - * Constructor for instantiating ParticipantControlLoopUpdate class with message name. - * - */ - public ParticipantControlLoopUpdate() { - super(ParticipantMessageType.PARTICIPANT_CONTROL_LOOP_UPDATE); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantControlLoopUpdate(ParticipantControlLoopUpdate source) { - super(source); - - this.controlLoop = new ControlLoop(source.controlLoop); - this.controlLoopDefinition = new ToscaServiceTemplate(source.controlLoopDefinition); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheck.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheck.java deleted file mode 100644 index e472e15fe..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheck.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; - -/** - * Class to represent the PARTICIPANT_HEALTHCHECK message that the control loop runtime will send to - * participants to change the state of a control loop they are running. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ParticipantHealthCheck extends ParticipantMessage { - private ParticipantState state; - - /** - * Constructor for instantiating ParticipantHealthCheck class with message name. - * - */ - public ParticipantHealthCheck() { - super(ParticipantMessageType.PARTICIPANT_HEALTH_CHECK); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantHealthCheck(ParticipantHealthCheck source) { - super(source); - - this.state = source.state; - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java deleted file mode 100644 index 3ca4d3d34..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import java.time.Instant; -import java.util.UUID; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NonNull; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Class to represent the base class for various messages that will be exchanged between the control loop runtime and - * participants. - */ -@Getter -@Setter -@ToString -public class ParticipantMessage { - @Setter(AccessLevel.NONE) - private ParticipantMessageType messageType; - - private UUID messageId = UUID.randomUUID(); - - /** - * Time-stamp, in milliseconds, when the message was created. Defaults to the current time. - */ - private Instant timestamp = Instant.now(); - - /** - * Participant Type, or {@code null} for messages from participants. - */ - private ToscaConceptIdentifier participantType; - - /** - * Participant ID, or {@code null} for messages from participants. - */ - private ToscaConceptIdentifier participantId; - - /** - * Control loop ID, or {@code null} for messages to participants. - */ - private ToscaConceptIdentifier controlLoopId; - - /** - * Constructor for instantiating a participant message class. - * - * @param messageType the message type - */ - public ParticipantMessage(final ParticipantMessageType messageType) { - this.messageType = messageType; - } - - /** - * Constructs the object, making a deep copy. Does <i>not</i> copy the request id or the time stamp. - * - * @param source source from which to copy - */ - public ParticipantMessage(final ParticipantMessage source) { - this.messageType = source.messageType; - this.participantType = source.participantType; - this.participantId = source.participantId; - this.controlLoopId = source.controlLoopId; - } - - /** - * Determines if this message applies to this participant type. - * - * @param participantType type of the participant to match against - * @param participantId id of the participant to match against - * @return {@code true} if this message applies to this participant, {@code false} otherwise - */ - public boolean appliesTo(@NonNull final ToscaConceptIdentifier participantType, - @NonNull final ToscaConceptIdentifier participantId) { - // Broadcast message to all participants - if (this.participantType == null) { - return true; - } - - // Broadcast message to all control loop elements on this participant - if (participantType.equals(this.participantType) && this.participantId == null) { - return true; - } - - // Targeted message at this specific participant - if (participantType.equals(this.participantType) && participantId.equals(this.participantId)) { - return true; - } - - // Message is not for this participant - return false; - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java deleted file mode 100644 index 77a50bd36..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -/** - * Class to hold the possible values for the type of participant messages. - */ -public enum ParticipantMessageType { - - /** - * Used by participants to report status to the control loop runtime. - */ - PARTICIPANT_STATUS, - - /** - * Used by the control loop runtime to change the state of participants, triggers a PARTICIPANT_STATUS message with - * the result of the PARTICIPANT_STATE_CHANGE operation. - */ - PARTICIPANT_STATE_CHANGE, - - /** - * Used by the control loop runtime to update the control loops running on participants, triggers a - * PARTICIPANT_STATUS message with the result of the PARTICIPANT_CONTROL_LOOP_UPDATE operation. - */ - PARTICIPANT_CONTROL_LOOP_UPDATE, - - /** - * Used by the control loop runtime to change the state of control loops in participants, triggers a - * PARTICIPANT_STATUS message with the result of the PARTICIPANT_CONTROL_LOOP_STATE_CHANGE operation. - */ - PARTICIPANT_CONTROL_LOOP_STATE_CHANGE, - - /** - * Used by the control loop runtime to order a health check on participants, triggers a PARTICIPANT_STATUS message - * with the result of the PARTICIPANT_HEALTH_CHECK operation. - */ - PARTICIPANT_HEALTH_CHECK -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseDetails.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseDetails.java deleted file mode 100644 index 4c771b405..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseDetails.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import java.util.UUID; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; - -/** - * Class to represent participant response details. - */ -@Getter -@Setter -@ToString -@NoArgsConstructor -public class ParticipantResponseDetails { - - // The responseTo field should match the original request id in the request. - private UUID responseTo; - private ParticipantResponseStatus responseStatus; - private String responseMessage; - - /** - * Constructs the object as a response to. - * - * @param triggerMessage the message to which this is a response - */ - public ParticipantResponseDetails(ParticipantMessage triggerMessage) { - this.responseMessage = null; - this.responseStatus = ParticipantResponseStatus.FAIL; - this.responseTo = triggerMessage.getMessageId(); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantResponseDetails(ParticipantResponseDetails source) { - this.responseMessage = source.responseMessage; - this.responseStatus = source.responseStatus; - this.responseTo = source.responseTo; - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java deleted file mode 100644 index f014529b3..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -/** - * Class to hold the possible values for participant response status. - */ -public enum ParticipantResponseStatus { - - /** - * participant operation was successful. - */ - SUCCESS, - - /** - * participant operation failed. - */ - FAIL, - - /** - * periodic response. - */ - PERIODIC -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChange.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChange.java deleted file mode 100644 index 5f5150077..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChange.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; - -/** - * Class to represent the PARTICIPANT_STATE_CHANGE message that the control loop runtime will send to participants - * to change their state. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ParticipantStateChange extends ParticipantMessage { - private ParticipantState state; - - /** - * Constructor for instantiating ParticipantStateChange class with message name. - * - */ - public ParticipantStateChange() { - super(ParticipantMessageType.PARTICIPANT_STATE_CHANGE); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantStateChange(ParticipantStateChange source) { - super(source); - - this.state = source.state; - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java deleted file mode 100644 index 5b9284243..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; - -/** - * Class to represent the PARTICIPANT_STATUS message that all the participants send to the control loop runtime. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class ParticipantStatus extends ParticipantMessage { - // The response should be completed if this message is a response to a request from the Control Loop Runtime - private ParticipantResponseDetails response; - - // State and health status of the participant - private ParticipantState state; - private ParticipantHealthStatus healthStatus; - - // Control Loops on the participant - private ControlLoops controlLoops; - - // Participant statistics - private ParticipantStatistics participantStatistics; - - // Description. May be left {@code null}. - private String message; - - /** - * Constructor for instantiating ParticipantStatus class with message name. - * - */ - public ParticipantStatus() { - super(ParticipantMessageType.PARTICIPANT_STATUS); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public ParticipantStatus(final ParticipantStatus source) { - super(source); - - this.state = source.state; - this.healthStatus = source.healthStatus; - this.message = source.message; - this.controlLoops = (source.controlLoops == null ? null : new ControlLoops(source.controlLoops)); - this.response = (source.response == null ? null : new ParticipantResponseDetails(source.response)); - } -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/SimpleResponse.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/SimpleResponse.java deleted file mode 100644 index 2bd09c632..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/SimpleResponse.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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.clamp.controlloop.models.messages.rest; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - * Response returned when no extra output fields are needed. - */ -@Getter -@Setter -@ToString -public class SimpleResponse { - - /** - * Optional detailed message in error cases. - */ - private String errorDetails; -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/TypedSimpleResponse.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/TypedSimpleResponse.java deleted file mode 100644 index 199ac8ee1..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/TypedSimpleResponse.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - * Response returned when no extra output fields are needed. - */ -@Getter -@Setter -@ToString -public class TypedSimpleResponse<T> extends SimpleResponse { - private T response; -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/commissioning/CommissioningResponse.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/commissioning/CommissioningResponse.java deleted file mode 100644 index 6363db8d2..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/commissioning/CommissioningResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest.commissioning; - -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Response to Commissioning requests that affect a change. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class CommissioningResponse extends SimpleResponse { - private List<ToscaConceptIdentifier> affectedControlLoopDefinitions; -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommand.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommand.java deleted file mode 100644 index 71b7ab92c..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; - -import java.util.List; -import lombok.Data; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -@Data -public class InstantiationCommand { - // The state to which the control loops are to be set - private ControlLoopOrderedState orderedState; - - // The list of control loops on which the command is to be issued - private List<ToscaConceptIdentifier> controlLoopIdentifierList; -} diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationResponse.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationResponse.java deleted file mode 100644 index d932f29ac..000000000 --- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; - -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; - -/** - * Response to Commissioning requests that affect a change. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class InstantiationResponse extends SimpleResponse { - private List<ToscaConceptIdentifier> affectedControlLoops; -} |