diff options
author | liamfallon <liam.fallon@est.tech> | 2020-11-20 10:24:44 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2020-12-01 12:27:54 +0000 |
commit | 950cbb8872fb2227f4a0382a756a7e1dff53b09c (patch) | |
tree | ce493c7161872360f4d88c5065c0730d53987c82 /models-tosca/src | |
parent | 1dd41890f83702d47c5a957493046433989ef36c (diff) |
Add extra authorative TOSCA concepts
This review brings in extra TOSCA concepts for Node types, nodes, and
capabilities.
The TOSCA handling is also amended to make the handling of equality
consistent. Now, if filtering or ordering is required using an order
rather than natural ordering, a comparator must be supplied by the user.
Issue-ID: POLICY-2900
Change-Id: Ie40e86870b97eb993b1338bdc0666ac116f72f67
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-tosca/src')
25 files changed, 393 insertions, 57 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaCapabilityAssignment.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaCapabilityAssignment.java new file mode 100644 index 000000000..207f07a8f --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaCapabilityAssignment.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 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.models.tosca.authorative.concepts; + +import java.util.List; +import java.util.Map; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class ToscaCapabilityAssignment extends ToscaEntity { + private Map<String, Object> properties; + private Map<String, Object> attributes; + private List<Object> occurrences; +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaCapabilityType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaCapabilityType.java new file mode 100644 index 000000000..dd8fb05f4 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaCapabilityType.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Model + * ================================================================================ + * Copyright (C) 2020 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.models.tosca.authorative.concepts; + +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class ToscaCapabilityType extends ToscaEntity { + private Map<String, ToscaProperty> properties; +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConstraint.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConstraint.java index 582b73cc6..33235a45a 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConstraint.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConstraint.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,6 @@ import lombok.Data; */ @Data public class ToscaConstraint { - @ApiModelProperty(name = "valid_values") @SerializedName("valid_values") private List<String> validValues; @@ -57,5 +56,4 @@ public class ToscaConstraint { @ApiModelProperty(name = "less_or_equal") @SerializedName("less_or_equal") private String lessOrEqual; - } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaDataType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaDataType.java index b07163b6e..6ea8804ca 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaDataType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaDataType.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java index b242bff65..10d3b7a14 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java @@ -44,7 +44,6 @@ import org.onap.policy.models.base.PfNameVersion; @NoArgsConstructor public class ToscaEntity implements PfNameVersion { private String name; - private String version; @ApiModelProperty(name = "derived_from") @@ -52,7 +51,6 @@ public class ToscaEntity implements PfNameVersion { private String derivedFrom; private Map<String, String> metadata; - private String description; /** diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeTemplate.java new file mode 100644 index 000000000..343eb8e2c --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeTemplate.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Model + * ================================================================================ + * Copyright (C) 2020 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.models.tosca.authorative.concepts; + +import java.util.List; +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class ToscaNodeTemplate extends ToscaEntity { + private String type; + private Map<String, Object> properties; + private List<Map<String, ToscaRequirement>> requirements; + private Map<String, ToscaCapabilityAssignment> capabilities; +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeType.java new file mode 100644 index 000000000..5a4c94126 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeType.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Model + * ================================================================================ + * Copyright (C) 2020 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.models.tosca.authorative.concepts; + +import java.util.List; +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class ToscaNodeType extends ToscaEntity { + private Map<String, ToscaProperty> properties; + private List<Map<String, ToscaRequirement>> requirements; +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaParameter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaParameter.java new file mode 100644 index 000000000..290bdacfe --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaParameter.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Model + * ================================================================================ + * Copyright (C) 2020 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.models.tosca.authorative.concepts; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class ToscaParameter { + private String name; + private String type; + + @ApiModelProperty(name = "type_version") + @SerializedName("type_version") + + private String typeVersion; + private Object value; +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicy.java index 27d4eb2e7..c98a844e5 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicy.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicy.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ import lombok.ToString; @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) -public class ToscaPolicy extends ToscaEntity implements Comparable<ToscaPolicy> { +public class ToscaPolicy extends ToscaEntity { private String type; @ApiModelProperty(name = "type_version") @@ -88,9 +88,4 @@ public class ToscaPolicy extends ToscaEntity implements Comparable<ToscaPolicy> public ToscaPolicyTypeIdentifier getTypeIdentifier() { return new ToscaPolicyTypeIdentifier(getType(), getTypeVersion()); } - - @Override - public int compareTo(final ToscaPolicy other) { - return compareNameVersion(this, other); - } } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyComparator.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyComparator.java new file mode 100644 index 000000000..8bbe70db2 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyComparator.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 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.models.tosca.authorative.concepts; + +import java.util.Comparator; + +/** + * Compare two ToscaPolicy objects. + */ +public class ToscaPolicyComparator implements Comparator<ToscaPolicy> { + + @Override + public int compare(final ToscaPolicy left, final ToscaPolicy right) { + return left.compareNameVersion(left, right); + } +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java index 33170db18..86c2e6f3e 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -67,7 +67,7 @@ public class ToscaPolicyFilter implements PfObjectFilter<ToscaPolicy> { // @formatter:off if (LATEST_VERSION.equals(version)) { - return this.latestVersionFilter(returnList); + return this.latestVersionFilter(returnList, new ToscaPolicyComparator()); } else { return returnList; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java index 43e7114be..29bff911f 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java @@ -22,6 +22,7 @@ package org.onap.policy.models.tosca.authorative.concepts; import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.NoArgsConstructor; import lombok.NonNull; @@ -35,9 +36,11 @@ import org.apache.commons.lang3.ObjectUtils; public class ToscaPolicyIdentifierOptVersion implements Comparable<ToscaPolicyIdentifierOptVersion> { @NonNull + @ApiModelProperty(name = "policy-id") @SerializedName("policy-id") private String name; + @ApiModelProperty(name = "policy-version") @SerializedName("policy-version") private String version; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyType.java index f948eda38..af8f5fa90 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyType.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ import lombok.NonNull; @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor -public class ToscaPolicyType extends ToscaEntity implements Comparable<ToscaPolicyType> { +public class ToscaPolicyType extends ToscaEntity { private Map<String, ToscaProperty> properties; /** @@ -57,9 +57,4 @@ public class ToscaPolicyType extends ToscaEntity implements Comparable<ToscaPoli } } } - - @Override - public int compareTo(final ToscaPolicyType other) { - return compareNameVersion(this, other); - } } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeComparator.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeComparator.java new file mode 100644 index 000000000..9f45a7854 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeComparator.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 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.models.tosca.authorative.concepts; + +import java.util.Comparator; + +/** + * Compare two ToscaPolicyType objects. + */ +public class ToscaPolicyTypeComparator implements Comparator<ToscaPolicyType> { + + @Override + public int compare(final ToscaPolicyType left, final ToscaPolicyType right) { + return left.compareNameVersion(left, right); + } +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java index da6c561ce..4e9810b98 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ public class ToscaPolicyTypeFilter implements PfObjectFilter<ToscaPolicyType> { // @formatter:off if (LATEST_VERSION.equals(version)) { - return this.latestVersionFilter(returnList); + return this.latestVersionFilter(returnList, new ToscaPolicyTypeComparator()); } else { return returnList; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaProperty.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaProperty.java index 59fbc8b22..0bd0d44e8 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaProperty.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaProperty.java @@ -41,9 +41,10 @@ public class ToscaProperty { } private String name; - private String type; + @ApiModelProperty(name = "type_version") + @SerializedName("type_version") private String typeVersion; private String description; @@ -53,14 +54,16 @@ public class ToscaProperty { private Object defaultValue; private boolean required = false; - private Status status; - private List<ToscaConstraint> constraints; + @ApiModelProperty(name = "key_schema") + @SerializedName("key_schema") + private ToscaSchemaDefinition keySchema; + @ApiModelProperty(name = "entry_schema") @SerializedName("entry_schema") - private ToscaEntrySchema entrySchema; + private ToscaSchemaDefinition entrySchema; private Map<String, String> metadata; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaRelationshipType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaRelationshipType.java new file mode 100644 index 000000000..9e43d8954 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaRelationshipType.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Model + * ================================================================================ + * Copyright (C) 2020 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.models.tosca.authorative.concepts; + +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class ToscaRelationshipType extends ToscaEntity { + private Map<String, ToscaProperty> properties; +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaRequirement.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaRequirement.java new file mode 100644 index 000000000..34dbb4f82 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaRequirement.java @@ -0,0 +1,34 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 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.models.tosca.authorative.concepts; + +import java.util.List; +import java.util.Map; +import lombok.Data; + +@Data +public class ToscaRequirement extends ToscaEntity { + private String capability; + private String node; + private String relationship; + private List<Object> occurrences; + private Map<String, Object> properties; +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntrySchema.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaSchemaDefinition.java index 352dfa7fa..758711c98 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntrySchema.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaSchemaDefinition.java @@ -23,23 +23,25 @@ package org.onap.policy.models.tosca.authorative.concepts; +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; import java.util.List; import lombok.Data; /** - * Class to represent TOSCA entry schema matching input/output from/to client. + * Class to represent TOSCA schema matching input/output from/to client. * * @author Chenfei Gao (cgao@research.att.com) */ @Data -public class ToscaEntrySchema { +public class ToscaSchemaDefinition { private String name; - private String type; + @ApiModelProperty(name = "type_version") + @SerializedName("type_version") private String typeVersion; private String description; - private List<ToscaConstraint> constraints; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplate.java index 17391964e..e83d173de 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplate.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplate.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,28 +37,39 @@ import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class ToscaServiceTemplate extends ToscaEntity { - @ApiModelProperty(name = "tosca_definitions_version") @SerializedName("tosca_definitions_version") private String toscaDefinitionsVersion; - @ApiModelProperty(name = "topology_template") - @SerializedName("topology_template") - private ToscaTopologyTemplate toscaTopologyTemplate; + @ApiModelProperty(name = "data_types") + @SerializedName("data_types") + private Map<String, ToscaDataType> dataTypes; + + @ApiModelProperty(name = "capability_types") + @SerializedName("capability_types") + private Map<String, ToscaCapabilityType> capabilityTypes; + + @ApiModelProperty(name = "node_types") + @SerializedName("node_types") + private Map<String, ToscaNodeType> nodeTypes; + + @ApiModelProperty(name = "relationship_types") + @SerializedName("relationship_types") + private Map<String, ToscaRelationshipType> relationshipTypes; @ApiModelProperty(name = "policy_types") @SerializedName("policy_types") private Map<String, ToscaPolicyType> policyTypes; - @ApiModelProperty(name = "data_types") - @SerializedName("data_types") - private Map<String, ToscaDataType> dataTypes; - - public Map<ToscaEntityKey, ToscaPolicyType> getPolicyTypesAsMap() { - return ToscaEntity.getEntityMapAsMap(policyTypes); - } + @ApiModelProperty(name = "topology_template") + @SerializedName("topology_template") + private ToscaTopologyTemplate toscaTopologyTemplate; public Map<ToscaEntityKey, ToscaDataType> getDataTypesAsMap() { return ToscaEntity.getEntityMapAsMap(dataTypes); } -}
\ No newline at end of file + + public Map<ToscaEntityKey, ToscaPolicyType> getPolicyTypesAsMap() { + return ToscaEntity.getEntityMapAsMap(policyTypes); + } +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplate.java index 74ebf07e0..a243b1688 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplate.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplate.java @@ -3,6 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +23,8 @@ package org.onap.policy.models.tosca.authorative.concepts; +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; import java.util.List; import java.util.Map; import lombok.Data; @@ -33,9 +36,14 @@ import lombok.Data; */ @Data public class ToscaTopologyTemplate { - private String description; + private Map<String, ToscaParameter> inputs; + + @ApiModelProperty(name = "node_templates") + @SerializedName("node_templates") + private Map<String, ToscaNodeTemplate> nodeTemplates; + private List<Map<String, ToscaPolicy>> policies; public Map<ToscaEntityKey, ToscaPolicy> getPoliciesAsMap() { diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/package-info.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/package-info.java index 1db09b863..f100c89c3 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/package-info.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/package-info.java @@ -27,4 +27,4 @@ * @author Chenfei Gao (cgao@research.att.com) * */ -package org.onap.policy.models.tosca.authorative.concepts;
\ No newline at end of file +package org.onap.policy.models.tosca.authorative.concepts; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntrySchema.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntrySchema.java index b697d5100..ef6aa7e92 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntrySchema.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntrySchema.java @@ -42,7 +42,7 @@ import org.onap.policy.models.base.PfValidationMessage; import org.onap.policy.models.base.PfValidationResult; import org.onap.policy.models.base.PfValidationResult.ValidationResult; import org.onap.policy.models.tosca.authorative.concepts.ToscaConstraint; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntrySchema; +import org.onap.policy.models.tosca.authorative.concepts.ToscaSchemaDefinition; /** * Class to represent the EntrySchema of list/map property in TOSCA definition. @@ -54,7 +54,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaEntrySchema; @EqualsAndHashCode(callSuper = false) @NoArgsConstructor public class JpaToscaEntrySchema - implements PfAuthorative<ToscaEntrySchema>, Serializable, Comparable<JpaToscaEntrySchema> { + implements PfAuthorative<ToscaSchemaDefinition>, Serializable, Comparable<JpaToscaEntrySchema> { private static final long serialVersionUID = 3645882081163287058L; @@ -93,13 +93,13 @@ public class JpaToscaEntrySchema * * @param authorativeConcept the authorative concept to copy from */ - public JpaToscaEntrySchema(final ToscaEntrySchema authorativeConcept) { + public JpaToscaEntrySchema(final ToscaSchemaDefinition authorativeConcept) { this.fromAuthorative(authorativeConcept); } @Override - public ToscaEntrySchema toAuthorative() { - ToscaEntrySchema toscaEntrySchema = new ToscaEntrySchema(); + public ToscaSchemaDefinition toAuthorative() { + ToscaSchemaDefinition toscaEntrySchema = new ToscaSchemaDefinition(); toscaEntrySchema.setType(type.getName()); toscaEntrySchema.setTypeVersion(type.getVersion()); @@ -120,7 +120,7 @@ public class JpaToscaEntrySchema } @Override - public void fromAuthorative(final ToscaEntrySchema toscaEntrySchema) { + public void fromAuthorative(final ToscaSchemaDefinition toscaEntrySchema) { if (toscaEntrySchema.getTypeVersion() != null) { type = new PfConceptKey(toscaEntrySchema.getType(), toscaEntrySchema.getTypeVersion()); } else { diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java index faafa8c60..9fd559392 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java @@ -56,11 +56,11 @@ public class ToscaPolicyTest { assertEquals("3.2.1", type.getVersion()); ToscaPolicy clonedPolicy0 = new ToscaPolicy(policy); - assertEquals(0, policy.compareTo(clonedPolicy0)); + assertEquals(0, new ToscaPolicyComparator().compare(policy, clonedPolicy0)); policy.setProperties(new LinkedHashMap<String, Object>()); policy.getProperties().put("PropertyKey", "PropertyValue"); ToscaPolicy clonedPolicy1 = new ToscaPolicy(policy); - assertEquals(0, policy.compareTo(clonedPolicy1)); + assertEquals(0, new ToscaPolicyComparator().compare(policy, clonedPolicy1)); } } diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeTest.java index fc9c69319..75c6b51e3 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeTest.java @@ -46,7 +46,7 @@ public class ToscaPolicyTypeTest { tpt.setDescription("Desc"); ToscaPolicyType clonedTpt0 = new ToscaPolicyType(tpt); - assertEquals(0, tpt.compareTo(clonedTpt0)); + assertEquals(0, new ToscaPolicyTypeComparator().compare(tpt, clonedTpt0)); tpt.setMetadata(new LinkedHashMap<>()); tpt.setProperties(new LinkedHashMap<>()); @@ -57,6 +57,6 @@ public class ToscaPolicyTypeTest { tpt.getProperties().put("Property0", tp); ToscaPolicyType clonedTpt1 = new ToscaPolicyType(tpt); - assertEquals(0, tpt.compareTo(clonedTpt1)); + assertEquals(0, new ToscaPolicyTypeComparator().compare(tpt, clonedTpt1)); } } |