From 950cbb8872fb2227f4a0382a756a7e1dff53b09c Mon Sep 17 00:00:00 2001 From: liamfallon Date: Fri, 20 Nov 2020 10:24:44 +0000 Subject: 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 --- .../concepts/ToscaCapabilityAssignment.java | 34 ++++++++++++++++ .../authorative/concepts/ToscaCapabilityType.java | 35 ++++++++++++++++ .../authorative/concepts/ToscaConstraint.java | 4 +- .../tosca/authorative/concepts/ToscaDataType.java | 2 +- .../tosca/authorative/concepts/ToscaEntity.java | 2 - .../authorative/concepts/ToscaEntrySchema.java | 45 --------------------- .../authorative/concepts/ToscaNodeTemplate.java | 39 ++++++++++++++++++ .../tosca/authorative/concepts/ToscaNodeType.java | 37 +++++++++++++++++ .../tosca/authorative/concepts/ToscaParameter.java | 41 +++++++++++++++++++ .../tosca/authorative/concepts/ToscaPolicy.java | 9 +---- .../concepts/ToscaPolicyComparator.java | 34 ++++++++++++++++ .../authorative/concepts/ToscaPolicyFilter.java | 4 +- .../concepts/ToscaPolicyIdentifierOptVersion.java | 3 ++ .../authorative/concepts/ToscaPolicyType.java | 9 +---- .../concepts/ToscaPolicyTypeComparator.java | 34 ++++++++++++++++ .../concepts/ToscaPolicyTypeFilter.java | 4 +- .../tosca/authorative/concepts/ToscaProperty.java | 11 +++-- .../concepts/ToscaRelationshipType.java | 35 ++++++++++++++++ .../authorative/concepts/ToscaRequirement.java | 34 ++++++++++++++++ .../concepts/ToscaSchemaDefinition.java | 47 ++++++++++++++++++++++ .../authorative/concepts/ToscaServiceTemplate.java | 37 +++++++++++------ .../concepts/ToscaTopologyTemplate.java | 10 ++++- .../tosca/authorative/concepts/package-info.java | 2 +- .../tosca/simple/concepts/JpaToscaEntrySchema.java | 12 +++--- 24 files changed, 430 insertions(+), 94 deletions(-) create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaCapabilityAssignment.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaCapabilityType.java delete mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntrySchema.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeTemplate.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeType.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaParameter.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyComparator.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeComparator.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaRelationshipType.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaRequirement.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaSchemaDefinition.java (limited to 'models-tosca/src/main/java/org') 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 properties; + private Map attributes; + private List 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 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 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 metadata; - private String description; /** 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/ToscaEntrySchema.java deleted file mode 100644 index 352dfa7fa..000000000 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntrySchema.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP Policy Model - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.tosca.authorative.concepts; - -import java.util.List; -import lombok.Data; - -/** - * Class to represent TOSCA entry schema matching input/output from/to client. - * - * @author Chenfei Gao (cgao@research.att.com) - */ -@Data -public class ToscaEntrySchema { - private String name; - - private String type; - - private String typeVersion; - - private String description; - - private List constraints; -} 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 properties; + private List> requirements; + private Map 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 properties; + private List> 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 { +public class ToscaPolicy extends ToscaEntity { private String type; @ApiModelProperty(name = "type_version") @@ -88,9 +88,4 @@ public class ToscaPolicy extends ToscaEntity implements Comparable 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 { + + @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 { // @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 { @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 { +public class ToscaPolicyType extends ToscaEntity { private Map properties; /** @@ -57,9 +57,4 @@ public class ToscaPolicyType extends ToscaEntity implements Comparable { + + @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 { // @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 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 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 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 occurrences; + private Map properties; +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaSchemaDefinition.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaSchemaDefinition.java new file mode 100644 index 000000000..758711c98 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaSchemaDefinition.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Model + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 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 java.util.List; +import lombok.Data; + +/** + * Class to represent TOSCA schema matching input/output from/to client. + * + * @author Chenfei Gao (cgao@research.att.com) + */ +@Data +public class ToscaSchemaDefinition { + private String name; + private String type; + + @ApiModelProperty(name = "type_version") + @SerializedName("type_version") + private String typeVersion; + + private String description; + private List 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 dataTypes; + + @ApiModelProperty(name = "capability_types") + @SerializedName("capability_types") + private Map capabilityTypes; + + @ApiModelProperty(name = "node_types") + @SerializedName("node_types") + private Map nodeTypes; + + @ApiModelProperty(name = "relationship_types") + @SerializedName("relationship_types") + private Map relationshipTypes; @ApiModelProperty(name = "policy_types") @SerializedName("policy_types") private Map policyTypes; - @ApiModelProperty(name = "data_types") - @SerializedName("data_types") - private Map dataTypes; - - public Map getPolicyTypesAsMap() { - return ToscaEntity.getEntityMapAsMap(policyTypes); - } + @ApiModelProperty(name = "topology_template") + @SerializedName("topology_template") + private ToscaTopologyTemplate toscaTopologyTemplate; public Map getDataTypesAsMap() { return ToscaEntity.getEntityMapAsMap(dataTypes); } -} \ No newline at end of file + + public Map 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 inputs; + + @ApiModelProperty(name = "node_templates") + @SerializedName("node_templates") + private Map nodeTemplates; + private List> policies; public Map 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, Serializable, Comparable { + implements PfAuthorative, Serializable, Comparable { 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 { -- cgit 1.2.3-korg