diff options
Diffstat (limited to 'models-pdp/src/main/java')
13 files changed, 39 insertions, 43 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroup.java index 8746c0721..79e5e79b9 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroup.java @@ -63,7 +63,7 @@ public class DeploymentGroup { * @return the validation result */ public ValidationResult validatePapRest() { - BeanValidationResult result = new BeanValidationResult("group", this); + var result = new BeanValidationResult("group", this); result.validateNotNull("name", name); result.validateNotNullList(SUBGROUP_FIELD, deploymentSubgroups, DeploymentSubGroup::validatePapRest); @@ -94,15 +94,15 @@ public class DeploymentGroup { Map<String, Action> pdpType2action = new HashMap<>(); for (DeploymentSubGroup subgrp : deploymentSubgroups) { - Action action = subgrp.getAction(); + var action = subgrp.getAction(); pdpType2action.compute(subgrp.getPdpType(), (pdpType, curact) -> { if (curact != null && action == Action.PATCH) { - BeanValidationResult subResult = new BeanValidationResult(pdpType, pdpType); + var subResult = new BeanValidationResult(pdpType, pdpType); subResult.addResult("action", action, ValidationStatus.INVALID, "incompatible with previous action: " + curact); - BeanValidationResult subResult2 = new BeanValidationResult(SUBGROUP_FIELD, subgrp); + var subResult2 = new BeanValidationResult(SUBGROUP_FIELD, subgrp); subResult2.addResult(subResult); result.addResult(subResult2); } diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroups.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroups.java index 0d810d210..dfdf3ac19 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroups.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroups.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Models * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * 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. @@ -49,7 +49,7 @@ public class DeploymentGroups { * @return the validation result */ public ValidationResult validatePapRest() { - BeanValidationResult result = new BeanValidationResult(GROUPS_FIELD, this); + var result = new BeanValidationResult(GROUPS_FIELD, this); result.validateNotNullList(GROUPS_FIELD, groups, DeploymentGroup::validatePapRest); if (!result.isValid()) { diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroup.java index 35443a291..361f7daa9 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroup.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -72,7 +72,7 @@ public class DeploymentSubGroup { * @return the validation result */ public ValidationResult validatePapRest() { - BeanValidationResult result = new BeanValidationResult("group", this); + var result = new BeanValidationResult("group", this); result.validateNotNull("pdpType", pdpType); result.validateNotNull("action", action); diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java index 6d7607924..845b7ad76 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java @@ -84,7 +84,7 @@ public class PdpGroup implements PfNameVersion, Comparable<PdpGroup> { * @return the validation result */ public ValidationResult validatePapRest(boolean updateGroupFlow) { - BeanValidationResult result = new BeanValidationResult("group", this); + var result = new BeanValidationResult("group", this); /* * Don't care about state, because we override it. Ok if description is null. diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java index a7ceaa9a5..ad64deb21 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.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. @@ -143,7 +143,7 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { for (ToscaConceptIdentifier supportedPolicyType : supportedPolicyTypes) { String supName = supportedPolicyType.getName(); if (supName.endsWith(".*")) { - String substr = supName.substring(0, supName.length() - 1); + var substr = supName.substring(0, supName.length() - 1); if (typeFilter.stream().anyMatch(type -> type.getName().startsWith(substr))) { return true; } diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java index 0e9554d03..3cf8b9b05 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java @@ -80,7 +80,7 @@ public class PdpSubGroup { * @return the validation result */ public ValidationResult validatePapRest(boolean updateGroupFlow) { - BeanValidationResult result = new BeanValidationResult("group", this); + var result = new BeanValidationResult("group", this); result.validateNotNull("pdpType", pdpType); // When doing PdpGroup Update operation, supported policy types and policies doesn't have to be validated. diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdp.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdp.java index 87a52fe38..daa327d9f 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdp.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdp.java @@ -131,7 +131,7 @@ public class JpaPdp extends PfConcept implements PfAuthorative<Pdp>, Serializabl @Override public Pdp toAuthorative() { - Pdp pdp = new Pdp(); + var pdp = new Pdp(); pdp.setInstanceId(key.getLocalName()); pdp.setPdpState(pdpState); diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java index c91bf9a62..c94cfdd91 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java @@ -153,7 +153,7 @@ public class JpaPdpGroup extends PfConcept implements PfAuthorative<PdpGroup> { @Override public PdpGroup toAuthorative() { - PdpGroup pdpGroup = new PdpGroup(); + var pdpGroup = new PdpGroup(); pdpGroup.setName(getKey().getName()); pdpGroup.setVersion(getKey().getVersion()); @@ -184,7 +184,7 @@ public class JpaPdpGroup extends PfConcept implements PfAuthorative<PdpGroup> { this.pdpSubGroups = new ArrayList<>(); for (PdpSubGroup pdpSubgroup : pdpGroup.getPdpSubgroups()) { - JpaPdpSubGroup jpaPdpSubGroup = new JpaPdpSubGroup(); + var jpaPdpSubGroup = new JpaPdpSubGroup(); jpaPdpSubGroup.setKey(new PfReferenceKey(getKey(), pdpSubgroup.getPdpType())); jpaPdpSubGroup.fromAuthorative(pdpSubgroup); this.pdpSubGroups.add(jpaPdpSubGroup); diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpPolicyStatus.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpPolicyStatus.java index 71ec6b8a9..536bb76a2 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpPolicyStatus.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpPolicyStatus.java @@ -154,10 +154,8 @@ public class JpaPdpPolicyStatus extends PfConcept implements PfAuthorative<PdpPo @Override public PdpPolicyStatus toAuthorative() { PfConceptKey policyKey = key.getParentConceptKey(); - ToscaConceptIdentifier policyIdent = new ToscaConceptIdentifier(policyKey.getName(), policyKey.getVersion()); - - ToscaConceptIdentifier policyTypeIdent = - new ToscaConceptIdentifier(policyType.getName(), policyType.getVersion()); + var policyIdent = new ToscaConceptIdentifier(policyKey.getName(), policyKey.getVersion()); + var policyTypeIdent = new ToscaConceptIdentifier(policyType.getName(), policyType.getVersion()); // @formatter:off return PdpPolicyStatus.builder() diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatistics.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatistics.java index ae859325d..a62eaa304 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatistics.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatistics.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019-2021 Nordix Foundation. - * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020-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. @@ -177,7 +177,7 @@ public class JpaPdpStatistics extends PfConcept implements PfAuthorative<PdpStat @Override public PdpStatistics toAuthorative() { - PdpStatistics pdpStatistics = new PdpStatistics(); + var pdpStatistics = new PdpStatistics(); pdpStatistics.setPdpInstanceId(key.getName()); pdpStatistics.setGeneratedId(key.getGeneratedId()); pdpStatistics.setTimeStamp(timeStamp.toInstant()); diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java index 4c0fe7630..1d49a9b8b 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java @@ -172,20 +172,20 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro @Override public PdpSubGroup toAuthorative() { - PdpSubGroup pdpSubgroup = new PdpSubGroup(); + var pdpSubgroup = new PdpSubGroup(); pdpSubgroup.setPdpType(getKey().getLocalName()); pdpSubgroup.setSupportedPolicyTypes(new ArrayList<>()); for (PfSearchableKey supportedPolicyTypeKey : supportedPolicyTypes) { - ToscaConceptIdentifier supportedPolicyTypeIdent = new ToscaConceptIdentifier( + var supportedPolicyTypeIdent = new ToscaConceptIdentifier( supportedPolicyTypeKey.getName(), supportedPolicyTypeKey.getVersion()); pdpSubgroup.getSupportedPolicyTypes().add(supportedPolicyTypeIdent); } pdpSubgroup.setPolicies(new ArrayList<>()); for (PfConceptKey policyKey : policies) { - ToscaConceptIdentifier toscaPolicyIdentifier = new ToscaConceptIdentifier(); + var toscaPolicyIdentifier = new ToscaConceptIdentifier(); toscaPolicyIdentifier.setName(policyKey.getName()); toscaPolicyIdentifier.setVersion(policyKey.getVersion()); pdpSubgroup.getPolicies().add(toscaPolicyIdentifier); @@ -233,7 +233,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro this.pdpInstances = new ArrayList<>(); if (pdpSubgroup.getPdpInstances() != null) { for (Pdp pdp : pdpSubgroup.getPdpInstances()) { - JpaPdp jpaPdp = new JpaPdp(); + var jpaPdp = new JpaPdp(); jpaPdp.setKey(new PfReferenceKey(getKey(), pdp.getInstanceId())); jpaPdp.fromAuthorative(pdp); this.pdpInstances.add(jpaPdp); diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java index 7d59166e2..4ffb1e40e 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java @@ -95,7 +95,7 @@ public class PdpProvider { throws PfModelException { for (PdpGroup pdpGroup : pdpGroups) { - JpaPdpGroup jpaPdpGroup = new JpaPdpGroup(); + var jpaPdpGroup = new JpaPdpGroup(); jpaPdpGroup.fromAuthorative(pdpGroup); BeanValidationResult validationResult = jpaPdpGroup.validate("PDP group"); @@ -110,8 +110,7 @@ public class PdpProvider { List<PdpGroup> returnPdpGroups = new ArrayList<>(); for (PdpGroup pdpGroup : pdpGroups) { - JpaPdpGroup jpaPdpGroup = - dao.get(JpaPdpGroup.class, new PfConceptKey(pdpGroup.getName(), PfKey.NULL_KEY_VERSION)); + var jpaPdpGroup = dao.get(JpaPdpGroup.class, new PfConceptKey(pdpGroup.getName(), PfKey.NULL_KEY_VERSION)); returnPdpGroups.add(jpaPdpGroup.toAuthorative()); } @@ -130,7 +129,7 @@ public class PdpProvider { throws PfModelException { for (PdpGroup pdpGroup : pdpGroups) { - JpaPdpGroup jpaPdpGroup = new JpaPdpGroup(); + var jpaPdpGroup = new JpaPdpGroup(); jpaPdpGroup.fromAuthorative(pdpGroup); BeanValidationResult validationResult = jpaPdpGroup.validate("PDP group"); @@ -145,7 +144,7 @@ public class PdpProvider { List<PdpGroup> returnPdpGroups = new ArrayList<>(); for (PdpGroup pdpGroup : pdpGroups) { - JpaPdpGroup jpaPdpGroup = + var jpaPdpGroup = dao.get(JpaPdpGroup.class, new PfConceptKey(pdpGroup.getName(), PfKey.NULL_KEY_VERSION)); returnPdpGroups.add(jpaPdpGroup.toAuthorative()); } @@ -164,9 +163,9 @@ public class PdpProvider { public void updatePdpSubGroup(@NonNull final PfDao dao, @NonNull final String pdpGroupName, @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException { - final PfReferenceKey subGroupKey = + final var subGroupKey = new PfReferenceKey(pdpGroupName, PfKey.NULL_KEY_VERSION, pdpSubGroup.getPdpType()); - final JpaPdpSubGroup jpaPdpSubgroup = new JpaPdpSubGroup(subGroupKey); + final var jpaPdpSubgroup = new JpaPdpSubGroup(subGroupKey); jpaPdpSubgroup.fromAuthorative(pdpSubGroup); BeanValidationResult validationResult = jpaPdpSubgroup.validate("PDP sub group"); @@ -189,9 +188,9 @@ public class PdpProvider { public void updatePdp(@NonNull final PfDao dao, @NonNull final String pdpGroupName, @NonNull final String pdpSubGroup, @NonNull final Pdp pdp) { - final PfReferenceKey pdpKey = + final var pdpKey = new PfReferenceKey(pdpGroupName, PfKey.NULL_KEY_VERSION, pdpSubGroup, pdp.getInstanceId()); - final JpaPdp jpaPdp = new JpaPdp(pdpKey); + final var jpaPdp = new JpaPdp(pdpKey); jpaPdp.fromAuthorative(pdp); BeanValidationResult validationResult = jpaPdp.validate("PDP"); @@ -212,7 +211,7 @@ public class PdpProvider { */ public PdpGroup deletePdpGroup(@NonNull final PfDao dao, @NonNull final String name) { - PfConceptKey pdpGroupKey = new PfConceptKey(name, PfKey.NULL_KEY_VERSION); + var pdpGroupKey = new PfConceptKey(name, PfKey.NULL_KEY_VERSION); JpaPdpGroup jpaDeletePdpGroup = dao.get(JpaPdpGroup.class, pdpGroupKey); @@ -341,9 +340,9 @@ public class PdpProvider { List<JpaPdpPolicyStatus> jpas = objs.stream().map(JpaPdpPolicyStatus::new).collect(Collectors.toList()); // validate the objects - BeanValidationResult result = new BeanValidationResult(fieldName, jpas); + var result = new BeanValidationResult(fieldName, jpas); - int count = 0; + var count = 0; for (JpaPdpPolicyStatus jpa: jpas) { result.addResult(jpa.validate(String.valueOf(count++))); } diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java index ece09b088..205761bf5 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019-2021 Nordix Foundation. - * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020-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. @@ -60,7 +60,6 @@ public class PdpStatisticsProvider { */ public List<PdpStatistics> getPdpStatistics(@NonNull final PfDao dao, final String name, final Instant timeStamp) throws PfModelException { - List<PdpStatistics> pdpStatistics = new ArrayList<>(); if (name != null && timeStamp != null) { return asPdpStatisticsList(dao.getByTimestamp(JpaPdpStatistics.class, new PfGeneratedIdKey(name, PfKey.NULL_KEY_VERSION), timeStamp)); @@ -130,7 +129,7 @@ public class PdpStatisticsProvider { public List<PdpStatistics> createPdpStatistics(@NonNull final PfDao dao, @NonNull final List<PdpStatistics> pdpStatisticsList) throws PfModelException { for (PdpStatistics pdpStatistics : pdpStatisticsList) { - JpaPdpStatistics jpaPdpStatistics = new JpaPdpStatistics(); + var jpaPdpStatistics = new JpaPdpStatistics(); jpaPdpStatistics.fromAuthorative(pdpStatistics); BeanValidationResult validationResult = jpaPdpStatistics.validate("pdp statistics"); if (!validationResult.isValid()) { @@ -145,7 +144,7 @@ public class PdpStatisticsProvider { List<PdpStatistics> pdpStatistics = new ArrayList<>(pdpStatisticsList.size()); for (PdpStatistics pdpStatisticsItem : pdpStatisticsList) { - JpaPdpStatistics jpaPdpStatistics = + var jpaPdpStatistics = dao.get(JpaPdpStatistics.class, new PfGeneratedIdKey(pdpStatisticsItem.getPdpInstanceId(), PfKey.NULL_KEY_VERSION, pdpStatisticsItem.getGeneratedId())); pdpStatistics.add(jpaPdpStatistics.toAuthorative()); @@ -165,7 +164,7 @@ public class PdpStatisticsProvider { @NonNull final List<PdpStatistics> pdpStatisticsList) throws PfModelException { for (PdpStatistics pdpStatistics : pdpStatisticsList) { - JpaPdpStatistics jpaPdpStatistics = new JpaPdpStatistics(); + var jpaPdpStatistics = new JpaPdpStatistics(); jpaPdpStatistics.fromAuthorative(pdpStatistics); BeanValidationResult validationResult = jpaPdpStatistics.validate("pdp statistics"); @@ -180,7 +179,7 @@ public class PdpStatisticsProvider { List<PdpStatistics> pdpStatistics = new ArrayList<>(pdpStatisticsList.size()); for (PdpStatistics pdpStatisticsItem : pdpStatisticsList) { - JpaPdpStatistics jpaPdpStatistics = + var jpaPdpStatistics = dao.get(JpaPdpStatistics.class, new PfGeneratedIdKey(pdpStatisticsItem.getPdpInstanceId(), PfKey.NULL_KEY_VERSION, pdpStatisticsItem.getGeneratedId())); pdpStatistics.add(jpaPdpStatistics.toAuthorative()); |