--- /dev/null
+/*-
+ * ============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.base;
+
+import java.util.Comparator;
+
+/**
+ * Compare two PfNameVersion objects.
+ */
+public class PfConceptComparator implements Comparator<PfConcept> {
+
+ @Override
+ public int compare(PfConcept left, PfConcept right) {
+ return left.getKey().compareTo(right.getKey());
+ }
+}
/*-
* ============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");
// @formatter:off
if (LATEST_VERSION.equals(version)) {
- return this.latestVersionFilter(returnList);
+ return this.latestVersionFilter(returnList, new PfConceptComparator());
} else {
return returnList;
}
/*-
* ============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.
public void setVersion(final String version);
/**
- * COmpare two name version implementation objects.
+ * Compare two name version implementation objects.
*
* @param left the left name/version implementation
* @param right the right name/version implementation
/*-
* ============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");
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import java.util.function.Function;
import java.util.function.Predicate;
* @author Liam Fallon (liam.fallon@est.tech)
*/
@FunctionalInterface
-public interface PfObjectFilter<T extends Comparable<T>> {
+public interface PfObjectFilter<T> {
/**
* Filter an incoming list, removing items that do not match the filter.
*
* Sort an incoming list and remove all but the latest version of each concept.
*
* @param originalList the incoming list
+ * @param versionComparator the comparator to use to order versions of the incoming object
* @return the filtered list
*/
- public default List<T> latestVersionFilter(final List<T> originalList) {
+ public default List<T> latestVersionFilter(final List<T> originalList, final Comparator<T> versionComparator) {
if (originalList.size() <= 1) {
return originalList;
}
List<T> filteredList = new ArrayList<>(originalList);
- Collections.sort(filteredList);
+ Collections.sort(filteredList, versionComparator);
int icur = 0;
for (int j = 1; j < filteredList.size(); j++) {
--- /dev/null
+/*-
+ * ============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.base;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.onap.policy.models.base.testconcepts.DummyBadPfConcept;
+import org.onap.policy.models.base.testconcepts.DummyPfConcept;
+
+public class PfConceptComparatorTest {
+
+ @Test
+ public void testPfConceptComparator() {
+ assertEquals(0, new PfConceptComparator().compare(new DummyPfConcept(), new DummyPfConcept()));
+ }
+}
package org.onap.policy.models.base;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
final PfConceptFilter conceptFilterNull = new PfConceptFilter(null, null, null);
conceptFilterNull.filter(null);
}).hasMessageMatching("^originalList is marked .*on.*ull but is null$");
+
+ conceptFilter.setName("hello");
+ assertEquals("hello", conceptFilter.getName());
+
+ conceptFilter.setVersion("1.2.3");
+ assertEquals("1.2.3", conceptFilter.getVersion());
+
+ conceptFilter.setVersionPrefix("AAA");
+ assertEquals("AAA", conceptFilter.getVersionPrefix());
}
}
MyKey someKey8 = new MyKey();
someKey8.setVersion(VERSION001);
assertFalse(someKey8.isNullKey());
+
+ someKey8.setVersion("10");
+ assertEquals(0, someKey8.getMinorVersion());
+
+ someKey8.setVersion("10.11");
+ assertEquals(0, someKey8.getPatchVersion());
}
@Test
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import javax.ws.rs.core.Response;
import org.junit.Test;
final PfModelException pfme = new PfModelException(Response.Status.ACCEPTED, "HELLO");
assertThat(pfme).hasMessage("HELLO");
assertEquals("Server returned: Accepted", getErrorMessage(pfme).substring(0, 25));
+ assertNotNull(pfme.toString());
final PfModelRuntimeException pfmr = new PfModelRuntimeException(Response.Status.ACCEPTED, "HELLO");
assertThat(pfmr).hasMessage("HELLO");
assertEquals("Server returned: Accepted", getErrorMessage(pfmr).substring(0, 25));
+ assertNotNull(pfmr.toString());
}
private String getErrorMessage(final ErrorResponseInfo eri) {
/*-
* ============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.
dnv0.setVersion("1.2.3");
assertEquals(-1, dnv0.compareNameVersion(dnv0, dnv1));
+ dnv1.setVersion(null);
+ assertEquals(-1, dnv0.compareNameVersion(dnv0, dnv1));
+
dnv1.setVersion("1.2.3");
assertEquals(0, dnv0.compareNameVersion(dnv0, dnv1));
}
/*-
* ============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");
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Predicate;
import org.junit.Test;
import org.onap.policy.models.base.testconcepts.DummyPfObject;
+import org.onap.policy.models.base.testconcepts.DummyPfObjectComparator;
import org.onap.policy.models.base.testconcepts.DummyPfObjectFilter;
/**
assertEquals(true, dof.filterString(HELLO, HELLO));
assertEquals(true, dof.filterString(HELLO, null));
- List<DummyPfObject> latestVersionList = dof.latestVersionFilter(doList);
+ List<DummyPfObject> latestVersionList = dof.latestVersionFilter(doList, new DummyPfObjectComparator());
assertEquals(3, latestVersionList.size());
assertEquals("aaaaa", latestVersionList.get(0).getName());
assertEquals(VERSION002, latestVersionList.get(0).getVersion());
latestVersionList.remove(2);
latestVersionList.remove(1);
- List<DummyPfObject> newestVersionList = dof.latestVersionFilter(latestVersionList);
+ List<DummyPfObject> newestVersionList = dof.latestVersionFilter(latestVersionList,
+ new DummyPfObjectComparator());
assertEquals(latestVersionList, newestVersionList);
MyFilter filter = new MyFilter();
/*-
* ============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.
*/
@Data
@RequiredArgsConstructor
-public class DummyPfObject implements PfNameVersion, Comparable<DummyPfObject> {
+public class DummyPfObject implements PfNameVersion {
private String name;
private String version;
private String description;
-
- @Override
- public int compareTo(@NonNull final DummyPfObject otherObject) {
- int result = ObjectUtils.compare(this.name, otherObject.name);
- if (result != 0) {
- return result;
- }
- result = ObjectUtils.compare(this.version, otherObject.version);
- if (result != 0) {
- return result;
- }
- return ObjectUtils.compare(this.description, otherObject.description);
- }
}
--- /dev/null
+/*-
+ * ============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.base.testconcepts;
+
+import java.util.Comparator;
+import org.onap.policy.models.base.PfNameVersion;
+
+/**
+ * Compare two PfNameVersion objects.
+ */
+public class DummyPfObjectComparator implements Comparator<DummyPfObject> {
+
+ @Override
+ public int compare(final DummyPfObject left, final DummyPfObject right) {
+ return left.compareNameVersion(left, right);
+ }
+}
--- /dev/null
+/*-
+ * ============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;
+}
--- /dev/null
+/*-
+ * ============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;
+}
* 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.
*/
@Data
public class ToscaConstraint {
-
@ApiModelProperty(name = "valid_values")
@SerializedName("valid_values")
private List<String> validValues;
@ApiModelProperty(name = "less_or_equal")
@SerializedName("less_or_equal")
private String lessOrEqual;
-
}
* 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.
@NoArgsConstructor
public class ToscaEntity implements PfNameVersion {
private String name;
-
private String version;
@ApiModelProperty(name = "derived_from")
private String derivedFrom;
private Map<String, String> metadata;
-
private String description;
/**
--- /dev/null
+/*-
+ * ============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;
+}
--- /dev/null
+/*-
+ * ============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;
+}
--- /dev/null
+/*-
+ * ============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;
+}
* 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.
@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")
public ToscaPolicyTypeIdentifier getTypeIdentifier() {
return new ToscaPolicyTypeIdentifier(getType(), getTypeVersion());
}
-
- @Override
- public int compareTo(final ToscaPolicy other) {
- return compareNameVersion(this, other);
- }
}
--- /dev/null
+/*-
+ * ============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);
+ }
+}
/*-
* ============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");
// @formatter:off
if (LATEST_VERSION.equals(version)) {
- return this.latestVersionFilter(returnList);
+ return this.latestVersionFilter(returnList, new ToscaPolicyComparator());
} else {
return returnList;
}
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;
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;
* 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.
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
-public class ToscaPolicyType extends ToscaEntity implements Comparable<ToscaPolicyType> {
+public class ToscaPolicyType extends ToscaEntity {
private Map<String, ToscaProperty> properties;
/**
}
}
}
-
- @Override
- public int compareTo(final ToscaPolicyType other) {
- return compareNameVersion(this, other);
- }
}
--- /dev/null
+/*-
+ * ============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);
+ }
+}
/*-
* ============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.
// @formatter:off
if (LATEST_VERSION.equals(version)) {
- return this.latestVersionFilter(returnList);
+ return this.latestVersionFilter(returnList, new ToscaPolicyTypeComparator());
} else {
return returnList;
}
}
private String name;
-
private String type;
+ @ApiModelProperty(name = "type_version")
+ @SerializedName("type_version")
private String typeVersion;
private String description;
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;
}
--- /dev/null
+/*-
+ * ============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;
+}
--- /dev/null
+/*
+ * ============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;
+}
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;
}
* 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.
@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);
+ }
+}
* 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.
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;
*/
@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() {
* @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;
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.
@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;
*
* @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());
}
@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 {
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));
}
}
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<>());
tpt.getProperties().put("Property0", tp);
ToscaPolicyType clonedTpt1 = new ToscaPolicyType(tpt);
- assertEquals(0, tpt.compareTo(clonedTpt1));
+ assertEquals(0, new ToscaPolicyTypeComparator().compare(tpt, clonedTpt1));
}
}