aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java12
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java5
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java2
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfModel.java4
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfModelService.java3
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java14
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfReferenceKey.java10
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfValidator.java4
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/Validated.java2
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/PfFilter.java3
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/PfFilterFactory.java5
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java57
-rw-r--r--models-errors/src/main/java/org/onap/policy/models/errors/concepts/ErrorResponseUtils.java3
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java26
14 files changed, 71 insertions, 79 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
index e7cab460e..a98a7ac54 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
@@ -137,8 +137,8 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
this.conceptMap = new TreeMap<>();
for (final Entry<PfConceptKey, C> conceptMapEntry : copyConcept.conceptMap.entrySet()) {
- PfConceptKey newK = new PfConceptKey(conceptMapEntry.getKey());
- C newC = PfUtils.makeCopy(conceptMapEntry.getValue());
+ var newK = new PfConceptKey(conceptMapEntry.getKey());
+ var newC = PfUtils.makeCopy(conceptMapEntry.getValue());
this.conceptMap.put(newK, newC);
}
}
@@ -186,7 +186,7 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
// Add the map entries one by one
for (Entry<String, A> incomingConceptEntry : incomingConceptMap.entrySet()) {
- PfConceptKey conceptKey = new PfConceptKey();
+ var conceptKey = new PfConceptKey();
if (KEY_ID_PATTERN.matches(incomingConceptEntry.getKey())) {
conceptKey = new PfConceptKey(incomingConceptEntry.getKey());
} else {
@@ -203,7 +203,7 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
incomingConceptEntry.getValue().setVersion(findConceptField(conceptKey, conceptKey.getVersion(),
incomingConceptEntry.getValue(), PfNameVersion::getDefinedVersion));
- C jpaConcept = getConceptNewInstance();
+ var jpaConcept = getConceptNewInstance();
// This cast allows us to call the fromAuthorative method
@SuppressWarnings("unchecked")
PfAuthorative<A> authoritiveImpl = (PfAuthorative<A>) jpaConcept;
@@ -260,7 +260,7 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
* @return the validation result
*/
private ValidationResult validateConceptMap() {
- BeanValidationResult result = new BeanValidationResult("conceptMap", conceptMap);
+ var result = new BeanValidationResult("conceptMap", conceptMap);
for (final Entry<PfConceptKey, C> conceptEntry : conceptMap.entrySet()) {
BeanValidationResult result2 = null;
@@ -318,7 +318,7 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
return getAll(conceptKeyName, conceptKeyVersion);
} else {
final Set<C> returnSet = new TreeSet<>();
- C foundConcept = get(conceptKeyName, conceptKeyVersion);
+ var foundConcept = get(conceptKeyName, conceptKeyVersion);
if (foundConcept != null) {
returnSet.add(foundConcept);
}
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java
index 7a3e05582..3c186bbf8 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +55,7 @@ public class PfConceptGetterImpl<C> implements PfConceptGetter<C> {
Assertions.argumentNotNull(conceptKeyName, "conceptKeyName may not be null");
// The very fist key that could have this name
- final PfConceptKey lowestArtifactKey = new PfConceptKey(conceptKeyName, PfKey.NULL_KEY_VERSION);
+ final var lowestArtifactKey = new PfConceptKey(conceptKeyName, PfKey.NULL_KEY_VERSION);
// Check if we found a key for our name
PfConceptKey foundKey = conceptMap.ceilingKey(lowestArtifactKey);
@@ -100,7 +101,7 @@ public class PfConceptGetterImpl<C> implements PfConceptGetter<C> {
}
// The very fist key that could have this name
- final PfConceptKey lowestArtifactKey = new PfConceptKey(conceptKeyName, PfKey.NULL_KEY_VERSION);
+ final var lowestArtifactKey = new PfConceptKey(conceptKeyName, PfKey.NULL_KEY_VERSION);
if (conceptKeyVersion != null) {
lowestArtifactKey.setVersion(conceptKeyVersion);
}
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java b/models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java
index b6d12198c..3309fe9da 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java
@@ -169,7 +169,7 @@ public abstract class PfKeyImpl extends PfKey {
}
final PfKeyImpl otherConceptKey = (PfKeyImpl) otherKey;
- final Compatibility compatibility = this.getCompatibility(otherConceptKey);
+ final var compatibility = this.getCompatibility(otherConceptKey);
return !(compatibility == Compatibility.DIFFERENT || compatibility == Compatibility.MAJOR);
}
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfModel.java b/models-base/src/main/java/org/onap/policy/models/base/PfModel.java
index a73616df9..b7f074a5e 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfModel.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfModel.java
@@ -160,7 +160,7 @@ public abstract class PfModel extends PfConcept {
validateKeyNotNull(result, KEYS_TOKEN, artifactKey);
- BeanValidationResult result2 = new BeanValidationResult(KEYS_TOKEN, artifactKey);
+ var result2 = new BeanValidationResult(KEYS_TOKEN, artifactKey);
// Null key name start check
if (artifactKey.getName().toUpperCase().startsWith(PfKey.NULL_KEY_NAME)) {
@@ -191,7 +191,7 @@ public abstract class PfModel extends PfConcept {
addResult(result, KEYS_TOKEN, referenceKey, IS_A_NULL_KEY);
}
- BeanValidationResult result2 = new BeanValidationResult(KEYS_TOKEN, referenceKey);
+ var result2 = new BeanValidationResult(KEYS_TOKEN, referenceKey);
// Null parent key check
if (referenceKey.getParentConceptKey().isNullKey()) {
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfModelService.java b/models-base/src/main/java/org/onap/policy/models/base/PfModelService.java
index 1f4b8f66b..7353915b9 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfModelService.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfModelService.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,7 +77,7 @@ public abstract class PfModelService {
*/
@SuppressWarnings("unchecked")
public static <M extends PfConcept> M getModel(@NonNull final String modelKey) {
- final M model = (M) modelMap.get(modelKey);
+ final var model = (M) modelMap.get(modelKey);
if (model == null) {
throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR,
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java b/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java
index 342fbab73..843fde333 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,13 +21,13 @@
package org.onap.policy.models.base;
+import com.google.re2j.Pattern;
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;
-import java.util.regex.Pattern;
/**
* Interface for filtering a list of concepts.
@@ -103,7 +103,7 @@ public interface PfObjectFilter<T> {
return item -> true;
}
- Pattern pat = Pattern.compile(pattern);
+ var pat = Pattern.compile(pattern);
return item -> {
String value = extractor.apply(item);
@@ -126,11 +126,11 @@ public interface PfObjectFilter<T> {
List<T> filteredList = new ArrayList<>(originalList);
Collections.sort(filteredList, versionComparator);
- int icur = 0;
- for (int j = 1; j < filteredList.size(); j++) {
+ var icur = 0;
+ for (var j = 1; j < filteredList.size(); j++) {
// Get the current and last element
- T curElement = filteredList.get(icur);
- T lastElement = filteredList.get(j);
+ var curElement = filteredList.get(icur);
+ var lastElement = filteredList.get(j);
/*
* The list is sorted so if the last element name is the same as the current element name, the current
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfReferenceKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfReferenceKey.java
index b25d4632b..acbebf959 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfReferenceKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfReferenceKey.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019,2021 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -205,7 +205,7 @@ public class PfReferenceKey extends PfKey {
* the key ID in a format that respects the KEY_ID_REGEXP
*/
public PfReferenceKey(final String id) {
- final String conditionedId = Assertions.validateStringParameter("id", id, REFERENCE_KEY_ID_REGEXP);
+ final var conditionedId = Assertions.validateStringParameter("id", id, REFERENCE_KEY_ID_REGEXP);
// Split on colon, if the id passes the regular expression test above
// it'll have just three colons separating the parent name,
@@ -253,9 +253,9 @@ public class PfReferenceKey extends PfKey {
@Override
public boolean isNullKey() {
- return (PfReferenceKey.NULL_KEY_NAME.equals(this.getParentKeyName()) && PfReferenceKey.NULL_KEY_VERSION
- .equals(this.getParentKeyVersion()) && PfReferenceKey.NULL_KEY_NAME.equals(this.getParentLocalName())
- && PfReferenceKey.NULL_KEY_NAME.equals(this.getLocalName()));
+ return (PfKey.NULL_KEY_NAME.equals(this.getParentKeyName()) && PfKey.NULL_KEY_VERSION
+ .equals(this.getParentKeyVersion()) && PfKey.NULL_KEY_NAME.equals(this.getParentLocalName())
+ && PfKey.NULL_KEY_NAME.equals(this.getLocalName()));
}
/**
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java b/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java
index 57cc3c81f..db7b9d63e 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java
@@ -97,7 +97,7 @@ public class PfValidator extends BeanValidator {
return true;
}
- PfKey pfkey = (PfKey) value;
+ var pfkey = (PfKey) value;
if (annot.keyNotNull() && pfkey.isNullKey()) {
result.addResult(fieldName, xlate(pfkey), ValidationStatus.INVALID, Validated.IS_A_NULL_KEY);
return false;
@@ -111,7 +111,7 @@ public class PfValidator extends BeanValidator {
return true;
}
- BeanValidationResult result2 = new BeanValidationResult(fieldName, value);
+ var result2 = new BeanValidationResult(fieldName, value);
PfKeyImpl keyimpl = (PfKeyImpl) pfkey;
diff --git a/models-base/src/main/java/org/onap/policy/models/base/Validated.java b/models-base/src/main/java/org/onap/policy/models/base/Validated.java
index 6ed1a845a..711dd7be6 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/Validated.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/Validated.java
@@ -106,7 +106,7 @@ public class Validated {
public static void validateKeyVersionNotNull(BeanValidationResult result, @NonNull String fieldName,
PfConceptKey key) {
if (key != null && key.isNullVersion()) {
- BeanValidationResult result2 = new BeanValidationResult(fieldName, key);
+ var result2 = new BeanValidationResult(fieldName, key);
result2.addResult(makeNullResult(PfKeyImpl.VERSION_TOKEN, key.getVersion()));
result.addResult(result2);
}
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/PfFilter.java b/models-dao/src/main/java/org/onap/policy/models/dao/PfFilter.java
index fbe81b3ff..9ba2b4ee6 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/PfFilter.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/PfFilter.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,7 +58,7 @@ public abstract class PfFilter {
public String addFilter(final String inputFilterString,
final String name, final Instant startTime, final Instant endTime,
final Map<String, Object> filterMap, final String sortOrder, final int getRecordNum) {
- StringBuilder filterQueryString = new StringBuilder(inputFilterString);
+ var filterQueryString = new StringBuilder(inputFilterString);
if (filterMap != null) {
for (String key : filterMap.keySet()) {
filterQueryString.append(getKeyPrefix() + key + "= :" + key + AND);
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/PfFilterFactory.java b/models-dao/src/main/java/org/onap/policy/models/dao/PfFilterFactory.java
index 643481f39..fbfad18c2 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/PfFilterFactory.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/PfFilterFactory.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +21,6 @@
package org.onap.policy.models.dao;
-import java.time.Instant;
-import java.util.Map;
import org.onap.policy.models.base.PfConcept;
import org.onap.policy.models.dao.impl.PfNonTimestampKeyFilter;
import org.onap.policy.models.dao.impl.PfReferenceTimestampKeyFilter;
@@ -67,7 +66,7 @@ public class PfFilterFactory {
*/
private <T extends PfConcept> String getKeyName(final Class<T> someClass) {
try {
- String fullClassName = someClass.getDeclaredField("key").getType().toString();
+ var fullClassName = someClass.getDeclaredField("key").getType().toString();
return fullClassName.substring(fullClassName.lastIndexOf('.') + 1);
} catch (NoSuchFieldException e) {
LOGGER.error("Error getting the key:", e);
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
index 1bd2e09da..42a06acc4 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
@@ -72,7 +72,6 @@ public class DefaultPfDao implements PfDao {
private static final String WHERE = " WHERE ";
private static final String AND = " AND ";
- private static final String ORDER = " ORDER BY ";
private static final String NAME_FILTER = "c.key.name = :name";
private static final String VERSION_FILTER = "c.key.version = :version";
@@ -83,8 +82,6 @@ public class DefaultPfDao implements PfDao {
private static final String PARENT_VERSION_FILTER = "c.key.parentKeyVersion = :parentversion";
private static final String LOCAL_NAME_FILTER = "c.key.localName = :localname";
- private static final String PARENT_NAME_REF_FILTER = "c.key.referenceKey.parentKeyName = :parentKeyName";
-
private static final String CLONE_ERR_MSG = "Could not clone object of class \"{}\"";
private static final String DELETE_BY_CONCEPT_KEY =
@@ -168,7 +165,7 @@ public class DefaultPfDao implements PfDao {
if (obj == null) {
return;
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
try {
mg.getTransaction().begin();
mg.merge(obj);
@@ -183,7 +180,7 @@ public class DefaultPfDao implements PfDao {
if (obj == null) {
return;
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
try {
mg.getTransaction().begin();
mg.remove(mg.contains(obj) ? obj : mg.merge(obj));
@@ -198,7 +195,7 @@ public class DefaultPfDao implements PfDao {
if (key == null) {
return;
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
try {
// @formatter:off
mg.getTransaction().begin();
@@ -218,7 +215,7 @@ public class DefaultPfDao implements PfDao {
if (key == null) {
return;
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
try {
// @formatter:off
mg.getTransaction().begin();
@@ -239,7 +236,7 @@ public class DefaultPfDao implements PfDao {
if (key == null) {
return;
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
try {
// @formatter:off
mg.getTransaction().begin();
@@ -260,7 +257,7 @@ public class DefaultPfDao implements PfDao {
if (key == null) {
return;
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
try {
// @formatter:off
mg.getTransaction().begin();
@@ -281,7 +278,7 @@ public class DefaultPfDao implements PfDao {
if (objs == null || objs.isEmpty()) {
return;
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
try {
mg.getTransaction().begin();
for (final T t : objs) {
@@ -298,7 +295,7 @@ public class DefaultPfDao implements PfDao {
if (objs == null || objs.isEmpty()) {
return;
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
try {
mg.getTransaction().begin();
for (final T t : objs) {
@@ -315,8 +312,8 @@ public class DefaultPfDao implements PfDao {
if (keys == null || keys.isEmpty()) {
return 0;
}
- int deletedCount = 0;
- final EntityManager mg = getEntityManager();
+ var deletedCount = 0;
+ final var mg = getEntityManager();
try {
// @formatter:off
mg.getTransaction().begin();
@@ -340,8 +337,8 @@ public class DefaultPfDao implements PfDao {
if (keys == null || keys.isEmpty()) {
return 0;
}
- int deletedCount = 0;
- final EntityManager mg = getEntityManager();
+ var deletedCount = 0;
+ final var mg = getEntityManager();
try {
// @formatter:off
mg.getTransaction().begin();
@@ -362,7 +359,7 @@ public class DefaultPfDao implements PfDao {
@Override
public <T extends PfConcept> void deleteAll(final Class<T> someClass) {
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
try {
mg.getTransaction().begin();
mg.createQuery(setQueryTable(DELETE_FROM_TABLE, someClass), someClass).executeUpdate();
@@ -383,7 +380,7 @@ public class DefaultPfDao implements PfDao {
return getAllVersions(someClass, name);
}
- T foundConcept = get(someClass, new PfConceptKey(name, version));
+ var foundConcept = get(someClass, new PfConceptKey(name, version));
return (foundConcept == null ? Collections.emptyList() : Collections.singletonList(foundConcept));
}
@@ -392,9 +389,9 @@ public class DefaultPfDao implements PfDao {
public <T extends PfConcept> List<T> getFiltered(final Class<T> someClass, final String name, final String version,
final Instant startTime, final Instant endTime, final Map<String, Object> filterMap, final String sortOrder,
final int getRecordNum) {
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
- String filterQueryString = SELECT_FROM_TABLE + WHERE;
+ var filterQueryString = SELECT_FROM_TABLE + WHERE;
try {
PfFilter timeStampFilter = new PfFilterFactory().createFilter(someClass);
@@ -464,9 +461,9 @@ public class DefaultPfDao implements PfDao {
if (someClass == null) {
return null;
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
try {
- final T t = mg.find(someClass, key);
+ final var t = mg.find(someClass, key);
if (t != null) {
mg.refresh(t);
}
@@ -481,7 +478,7 @@ public class DefaultPfDao implements PfDao {
if (someClass == null) {
return Collections.emptyList();
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
try {
return mg.createQuery(setQueryTable(SELECT_FROM_TABLE, someClass), someClass).getResultList();
} finally {
@@ -494,7 +491,7 @@ public class DefaultPfDao implements PfDao {
if (someClass == null) {
return Collections.emptyList();
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
try {
// @formatter:off
return mg.createQuery(setQueryTable(SELECT_ALL_FOR_PARENT, someClass), someClass)
@@ -512,7 +509,7 @@ public class DefaultPfDao implements PfDao {
if (someClass == null || parentKeyName == null) {
return Collections.emptyList();
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
try {
// @formatter:off
return mg.createQuery(setQueryTable(SELECT_ALL_VERSIONS_FOR_PARENT, someClass), someClass)
@@ -529,7 +526,7 @@ public class DefaultPfDao implements PfDao {
if (someClass == null || conceptName == null) {
return Collections.emptyList();
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
try {
// @formatter:off
return mg.createQuery(setQueryTable(SELECT_ALL_VERSIONS, someClass), someClass)
@@ -549,7 +546,7 @@ public class DefaultPfDao implements PfDao {
return Collections.emptyList();
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
try {
// @formatter:off
return mg.createQuery(setQueryTable(SELECT_BY_TIMESTAMP_NOKEY, someClass), someClass)
@@ -568,7 +565,7 @@ public class DefaultPfDao implements PfDao {
if (someClass == null || key == null) {
return null;
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
List<T> ret;
try {
// @formatter:off
@@ -589,7 +586,7 @@ public class DefaultPfDao implements PfDao {
if (someClass == null || key == null) {
return null;
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
List<T> ret;
try {
// @formatter:off
@@ -608,7 +605,7 @@ public class DefaultPfDao implements PfDao {
@Override
public <T extends PfConcept> T update(final T obj) {
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
T ret;
try {
mg.getTransaction().begin();
@@ -626,7 +623,7 @@ public class DefaultPfDao implements PfDao {
if (someClass == null) {
return 0;
}
- final EntityManager mg = getEntityManager();
+ final var mg = getEntityManager();
long size = 0;
try {
size = mg.createQuery("SELECT COUNT(c) FROM " + someClass.getSimpleName() + " c", Long.class)
diff --git a/models-errors/src/main/java/org/onap/policy/models/errors/concepts/ErrorResponseUtils.java b/models-errors/src/main/java/org/onap/policy/models/errors/concepts/ErrorResponseUtils.java
index 67815a811..eb5212eb0 100644
--- a/models-errors/src/main/java/org/onap/policy/models/errors/concepts/ErrorResponseUtils.java
+++ b/models-errors/src/main/java/org/onap/policy/models/errors/concepts/ErrorResponseUtils.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +47,7 @@ public final class ErrorResponseUtils {
List<String> cascascadedErrorMessages = new ArrayList<>();
- for (Throwable t = throwable; t != null; t = t.getCause()) {
+ for (var t = throwable; t != null; t = t.getCause()) {
cascascadedErrorMessages.add(t.getMessage());
}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java
index 12e3a9d5a..362653650 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java
@@ -21,7 +21,6 @@
package org.onap.policy.models.tosca.utils;
-import java.util.Map;
import java.util.Map.Entry;
import javax.ws.rs.core.Response;
import lombok.NonNull;
@@ -102,16 +101,15 @@ public class ToscaServiceTemplateUtils {
/**
* Check entities from a fragment container can be added to an original container.
*
+ * @param <E> The type of TOSCA entity
+ * @param <J> The type of the JPA TOSCA entity
* @param <S> The type of container
*
* @param compositeContainer the original container
* @param fragmentContainer the fragment being added to the original container
* @return the composite container with the result
*/
- @SuppressWarnings("unchecked")
- // @formatter:off
- private static
- <S extends PfConceptContainer<? extends JpaToscaEntityType<? extends ToscaEntity>, ? extends ToscaEntity>>
+ private static <E extends ToscaEntity, J extends JpaToscaEntityType<E>, S extends PfConceptContainer<J, E>>
S addFragmentEntitites(final S compositeContainer, final S fragmentContainer,
final BeanValidationResult result) {
@@ -124,14 +122,13 @@ public class ToscaServiceTemplateUtils {
}
var result2 = new BeanValidationResult("incoming fragment", fragmentContainer);
+ var originalContainerMap = compositeContainer.getConceptMap();
+ var fragmentContainerMap = fragmentContainer.getConceptMap();
- for (Entry<PfConceptKey, ? extends JpaToscaEntityType<? extends ToscaEntity>> fragmentEntry : fragmentContainer
- .getConceptMap().entrySet()) {
- JpaToscaEntityType<? extends ToscaEntity> containerEntity =
- compositeContainer.getConceptMap().get(fragmentEntry.getKey());
+ for (Entry<PfConceptKey, J> fragmentEntry : fragmentContainerMap.entrySet()) {
+ J containerEntity = originalContainerMap.get(fragmentEntry.getKey());
if (containerEntity != null && containerEntity.compareTo(fragmentEntry.getValue()) != 0) {
- Validated.addResult(result, "entity", fragmentEntry.getKey(),
- "does not equal existing entity");
+ Validated.addResult(result, "entity", fragmentEntry.getKey(), "does not equal existing entity");
}
}
@@ -139,13 +136,8 @@ public class ToscaServiceTemplateUtils {
result.addResult(result2);
}
- // This use of a generic map is required to get around typing errors in directly adding the fragment map to the
- // original map
- @SuppressWarnings("rawtypes")
- Map originalContainerMap = compositeContainer.getConceptMap();
- originalContainerMap.putAll(fragmentContainer.getConceptMap());
+ originalContainerMap.putAll(fragmentContainerMap);
return compositeContainer;
}
- // @formatter:on
}