/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2023-2025 Nordix Foundation.
+ * Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@NonNull
private DeployOrder orderedState = DeployOrder.DEPLOY;
+ @NonNull
+ private MigrationState migrationState = MigrationState.DEFAULT;
+
// backward compatibility
private ToscaServiceTemplate toscaServiceTemplateFragment = new ToscaServiceTemplate();
this.orderedState = otherElement.orderedState;
this.toscaServiceTemplateFragment = otherElement.toscaServiceTemplateFragment;
this.properties = PfUtils.mapMap(otherElement.properties, UnaryOperator.identity());
+ this.migrationState = otherElement.migrationState;
}
@Override
+ "id=" + id
+ ", definition=" + definition
+ ", orderedState=" + orderedState
+ + ", migrationState=" + migrationState
+ ", toscaServiceTemplateFragment="
+ toscaServiceTemplateFragment + '}';
}
@NonNull
private SubState subState = SubState.NONE;
+ private MigrationState migrationState = MigrationState.DEFAULT;
+
private Integer stage;
private String operationalState;
this.useState = otherElement.useState;
this.stage = otherElement.stage;
this.message = otherElement.message;
+ this.migrationState = otherElement.migrationState;
}
}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.
+ * ================================================================================
+ * 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.models.acm.concepts;
+
+public enum MigrationState {
+ DEFAULT,
+ REMOVED,
+ NEW
+}
import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.Table;
-import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import java.util.function.UnaryOperator;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
+import org.onap.policy.clamp.models.acm.concepts.MigrationState;
import org.onap.policy.clamp.models.acm.concepts.SubState;
import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.common.parameters.annotations.Valid;
@NotNull
private SubState subState;
+ @Column
+ @NotNull
+ private MigrationState migrationState;
+
@Column
private String operationalState;
* @param instanceId The id of the automation composition instance
*/
public JpaAutomationCompositionElement(@NonNull final String elementId, @NonNull final String instanceId) {
- this(elementId, instanceId, new PfConceptKey(),
- DeployState.UNDEPLOYED, LockState.NONE, SubState.NONE);
- }
-
- /**
- * The Key Constructor creates a {@link JpaAutomationCompositionElement} object with all mandatory fields.
- *
- * @param elementId The id of the automation composition instance Element
- * @param instanceId The id of the automation composition instance
- * @param definition the TOSCA definition of the automation composition element
- * @param deployState the Deploy State of the automation composition
- * @param lockState the Lock State of the automation composition
- * @param subState the Sub State of the automation composition
- */
- public JpaAutomationCompositionElement(@NonNull final String elementId, @NonNull final String instanceId,
- @NonNull final PfConceptKey definition,
- @NonNull final DeployState deployState, @NonNull final LockState lockState,
- @NonNull final SubState subState) {
this.elementId = elementId;
this.instanceId = instanceId;
- this.definition = definition;
- this.deployState = deployState;
- this.lockState = lockState;
- this.subState = subState;
+ this.definition = new PfConceptKey();
+ this.deployState = DeployState.UNDEPLOYED;
+ this.lockState = LockState.NONE;
+ this.subState = SubState.NONE;
+ this.migrationState = MigrationState.DEFAULT;
}
/**
this.deployState = copyConcept.deployState;
this.lockState = copyConcept.lockState;
this.subState = copyConcept.subState;
+ this.migrationState = copyConcept.migrationState;
this.operationalState = copyConcept.operationalState;
this.useState = copyConcept.useState;
this.stage = copyConcept.stage;
element.setDeployState(deployState);
element.setLockState(lockState);
element.setSubState(subState);
+ element.setMigrationState(migrationState);
element.setOperationalState(operationalState);
element.setUseState(useState);
element.setStage(stage);
this.deployState = element.getDeployState();
this.lockState = element.getLockState();
this.subState = element.getSubState();
+ this.migrationState = element.getMigrationState();
this.operationalState = element.getOperationalState();
this.useState = element.getUseState();
this.stage = element.getStage();
return result;
}
+ result = ObjectUtils.compare(migrationState, other.migrationState);
+ if (result != 0) {
+ return result;
+ }
+
result = ObjectUtils.compare(useState, other.useState);
if (result != 0) {
return result;
acElementDeploy.setId(element.getId());
acElementDeploy.setDefinition(new ToscaConceptIdentifier(element.getDefinition()));
acElementDeploy.setOrderedState(deployOrder);
+ acElementDeploy.setMigrationState(element.getMigrationState());
acElementDeploy.setProperties(PfUtils.mapMap(element.getProperties(), UnaryOperator.identity()));
return acElementDeploy;
}
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
+import org.onap.policy.clamp.models.acm.concepts.MigrationState;
import org.onap.policy.clamp.models.acm.concepts.SubState;
import org.onap.policy.clamp.models.acm.utils.CommonTestData;
import org.onap.policy.models.base.PfConceptKey;
private static final String KEY = "key";
private static final String BAD_VALUE = "BadValue";
- private static final PfConceptKey CONCEPT_KEY = new PfConceptKey();
-
@Test
void testJpaAutomationCompositionElementConstructor() {
assertThatThrownBy(() -> {
new JpaAutomationCompositionElement(null, null);
}).hasMessageMatching(NULL_ELEMENT_ID_ERROR);
- assertThatThrownBy(() -> {
- new JpaAutomationCompositionElement(null, null, null, null, null, null);
- }).hasMessageMatching(NULL_ELEMENT_ID_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaAutomationCompositionElement(KEY, null, null,
- DeployState.UNDEPLOYED, LockState.LOCKED, SubState.NONE);
- }).hasMessageMatching(NULL_INSTANCE_ID_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaAutomationCompositionElement(KEY, KEY, null,
- DeployState.UNDEPLOYED, LockState.LOCKED, SubState.NONE);
- }).hasMessageMatching("definition" + NULL_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaAutomationCompositionElement(KEY, KEY, CONCEPT_KEY,
- null, LockState.LOCKED, SubState.NONE);
- }).hasMessageMatching("deployState" + NULL_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaAutomationCompositionElement(KEY, KEY, CONCEPT_KEY,
- DeployState.UNDEPLOYED, null, SubState.NONE);
- }).hasMessageMatching("lockState" + NULL_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaAutomationCompositionElement(KEY, KEY, CONCEPT_KEY,
- DeployState.UNDEPLOYED, LockState.NONE, null);
- }).hasMessageMatching("subState" + NULL_ERROR);
-
assertDoesNotThrow(() -> new JpaAutomationCompositionElement());
assertDoesNotThrow(() -> new JpaAutomationCompositionElement(KEY, KEY));
- assertDoesNotThrow(() -> new JpaAutomationCompositionElement(KEY, KEY,
- new PfConceptKey(), DeployState.UNDEPLOYED, LockState.LOCKED, SubState.NONE));
}
@Test
testJpaAcElement.setSubState(SubState.NONE);
assertEquals(0, testJpaAcElement.compareTo(otherJpaAcElement));
+ testJpaAcElement.setMigrationState(MigrationState.REMOVED);
+ assertNotEquals(0, testJpaAcElement.compareTo(otherJpaAcElement));
+ testJpaAcElement.setMigrationState(MigrationState.DEFAULT);
+ assertEquals(0, testJpaAcElement.compareTo(otherJpaAcElement));
+
testJpaAcElement.setUseState(BAD_VALUE);
assertNotEquals(0, testJpaAcElement.compareTo(otherJpaAcElement));
testJpaAcElement.setUseState("IDLE");
- dropColumn:
tableName: NodeTemplateState
columnName: restarting
+
+ - changeSet:
+ author: policy
+ id: 1800-3
+ changes:
+ - addColumn:
+ tableName: AutomationCompositionElement
+ columns:
+ - column:
+ name: migrationState
+ type: SMALLINT
+ defaultValue: 0
+ constraints:
+ nullable: false