aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src
diff options
context:
space:
mode:
authorayalaben <ayala.benzvi@amdocs.com>2018-10-04 14:24:58 +0300
committerayalaben <ayala.benzvi@amdocs.com>2018-10-07 13:15:53 +0300
commit453831564d4af7eb7603a50a2d75505ad858db2b (patch)
tree1a06c433d2d9b458c4e47531fb39abc9db1fb66a /openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src
parent454cfef267e87a2e0fba46964106c6fe03c220fd (diff)
Entities are not ordered by Name user feedback
Change-Id: I937b744c13d3cdf08a2ba23e365c7138494ac491 Issue-ID: SDC-1818 Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java27
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java34
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java32
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java24
4 files changed, 64 insertions, 53 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java
index 076ae45017..83519198b7 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java
@@ -20,6 +20,10 @@
package org.openecomp.sdcrests.vendorlicense.rest.services;
+import java.util.Comparator;
+import java.util.stream.Collectors;
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
@@ -34,10 +38,6 @@ import org.openecomp.sdcrests.wrappers.StringWrapperResponse;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import javax.inject.Named;
-import javax.ws.rs.core.Response;
-import java.util.Collection;
-
@Named
@Service("entitlementPools")
@Scope(value = "prototype")
@@ -54,17 +54,18 @@ public class EntitlementPoolsImpl implements EntitlementPools {
* @return the response
*/
public Response listEntitlementPools(String vlmId, String versionId, String user) {
- Collection<EntitlementPoolEntity> entitlementPools =
- vendorLicenseManager.listEntitlementPools(vlmId, new Version(versionId));
- GenericCollectionWrapper<EntitlementPoolEntityDto> result = new GenericCollectionWrapper<>();
- MapEntitlementPoolEntityToEntitlementPoolEntityDto outputMapper =
- new MapEntitlementPoolEntityToEntitlementPoolEntityDto();
- for (EntitlementPoolEntity ep : entitlementPools) {
- result.add(outputMapper.applyMapping(ep, EntitlementPoolEntityDto.class));
+ MapEntitlementPoolEntityToEntitlementPoolEntityDto outputMapper =
+ new MapEntitlementPoolEntityToEntitlementPoolEntityDto();
+
+ GenericCollectionWrapper<EntitlementPoolEntityDto> result = new GenericCollectionWrapper<>(
+ vendorLicenseManager.listEntitlementPools(vlmId, new Version(versionId)).stream()
+ .sorted(Comparator.comparing(EntitlementPoolEntity::getName))
+ .map(item -> outputMapper.applyMapping(item, EntitlementPoolEntityDto.class))
+ .collect(Collectors.toList()));
+
+ return Response.ok(result).build();
}
- return Response.ok(result).build();
- }
/**
* Create entitlement pool response.
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java
index b2f7e88996..4ea35d321d 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java
@@ -20,12 +20,11 @@
package org.openecomp.sdcrests.vendorlicense.rest.services;
-import java.util.Collection;
+import java.util.Comparator;
import java.util.HashSet;
-
+import java.util.stream.Collectors;
import javax.inject.Named;
import javax.ws.rs.core.Response;
-
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory;
@@ -60,22 +59,15 @@ public class FeatureGroupsImpl implements FeatureGroups {
@Override
public Response listFeatureGroups(String vlmId, String versionId, String user) {
- Collection<FeatureGroupEntity> featureGroupEntities =
- vendorLicenseManager.listFeatureGroups(vlmId, new Version(versionId));
MapFeatureGroupEntityToFeatureGroupDescriptorDto outputMapper =
new MapFeatureGroupEntityToFeatureGroupDescriptorDto();
- GenericCollectionWrapper<FeatureGroupEntityDto> results = new GenericCollectionWrapper<>();
-
- for (FeatureGroupEntity fg : featureGroupEntities) {
- FeatureGroupEntityDto fgDto = new FeatureGroupEntityDto();
- fgDto.setId(fg.getId());
- fgDto.setLicenseKeyGroupsIds(fg.getLicenseKeyGroupIds());
- fgDto.setEntitlementPoolsIds(fg.getEntitlementPoolIds());
- fgDto.setReferencingLicenseAgreements(fg.getReferencingLicenseAgreements());
- outputMapper.doMapping(fg, fgDto);
- results.add(fgDto);
- }
+
+ GenericCollectionWrapper<FeatureGroupEntityDto> results = new GenericCollectionWrapper<>(
+ vendorLicenseManager.listFeatureGroups(vlmId, new Version(versionId)).stream()
+ .sorted(Comparator.comparing(FeatureGroupEntity::getName))
+ .map(fg -> getFeatureGroupEntityDto(outputMapper,fg)).collect(Collectors.toList()));
+
return Response.ok(results).build();
}
@@ -168,4 +160,14 @@ public class FeatureGroupsImpl implements FeatureGroups {
return Response.ok().build();
}
+ private FeatureGroupEntityDto getFeatureGroupEntityDto(MapFeatureGroupEntityToFeatureGroupDescriptorDto mapper,FeatureGroupEntity fg) {
+ FeatureGroupEntityDto fgDto = new FeatureGroupEntityDto();
+ fgDto.setId(fg.getId());
+ fgDto.setLicenseKeyGroupsIds(fg.getLicenseKeyGroupIds());
+ fgDto.setEntitlementPoolsIds(fg.getEntitlementPoolIds());
+ fgDto.setReferencingLicenseAgreements(fg.getReferencingLicenseAgreements());
+ mapper.doMapping(fg, fgDto);
+ return fgDto;
+ }
+
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java
index 05da9646b1..7c0539931b 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java
@@ -20,12 +20,11 @@
package org.openecomp.sdcrests.vendorlicense.rest.services;
-import java.util.Collection;
+import java.util.Comparator;
import java.util.HashSet;
-
+import java.util.stream.Collectors;
import javax.inject.Named;
import javax.ws.rs.core.Response;
-
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory;
@@ -64,22 +63,20 @@ public class LicenseAgreementsImpl implements LicenseAgreements {
* @return the response
*/
public Response listLicenseAgreements(String vlmId, String versionId, String user) {
- Collection<LicenseAgreementEntity> licenseAgreements =
- vendorLicenseManager.listLicenseAgreements(vlmId, new Version(versionId));
- GenericCollectionWrapper<LicenseAgreementEntityDto> results = new GenericCollectionWrapper<>();
MapLicenseAgreementEntityToLicenseAgreementDescriptorDto outputMapper =
new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto();
- for (LicenseAgreementEntity lae : licenseAgreements) {
- LicenseAgreementEntityDto laeDto = new LicenseAgreementEntityDto();
- laeDto.setId(lae.getId());
- laeDto.setFeatureGroupsIds(lae.getFeatureGroupIds());
- outputMapper.doMapping(lae, laeDto);
- results.add(laeDto);
- }
+
+ GenericCollectionWrapper<LicenseAgreementEntityDto> results = new GenericCollectionWrapper<>(
+ vendorLicenseManager.listLicenseAgreements(vlmId, new Version(versionId)).stream()
+ .sorted(Comparator.comparing(LicenseAgreementEntity::getName))
+ .map(lae -> getLicenseAgreementEntityDto(outputMapper, lae))
+ .collect(Collectors.toList()));
+
return Response.ok(results).build();
}
+
/**
* Create license agreement response.
*
@@ -184,4 +181,13 @@ public class LicenseAgreementsImpl implements LicenseAgreements {
vendorLicenseManager.deleteLicenseAgreement(vlmId, new Version(versionId), licenseAgreementId);
return Response.ok().build();
}
+
+ private LicenseAgreementEntityDto getLicenseAgreementEntityDto(
+ MapLicenseAgreementEntityToLicenseAgreementDescriptorDto mapper, LicenseAgreementEntity lae) {
+ LicenseAgreementEntityDto laeDto = new LicenseAgreementEntityDto();
+ laeDto.setId(lae.getId());
+ laeDto.setFeatureGroupsIds(lae.getFeatureGroupIds());
+ mapper.doMapping(lae, laeDto);
+ return laeDto;
+ }
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java
index 5f37d39720..3edee02080 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java
@@ -20,6 +20,11 @@
package org.openecomp.sdcrests.vendorlicense.rest.services;
+import java.util.Comparator;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
@@ -35,10 +40,6 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
-import javax.inject.Named;
-import javax.ws.rs.core.Response;
-import java.util.Collection;
-
@Named
@Service("licenseKeyGroups")
@Scope(value = "prototype")
@@ -56,15 +57,16 @@ public class LicenseKeyGroupsImpl implements LicenseKeyGroups {
* @return the response
*/
public Response listLicenseKeyGroups(String vlmId, String versionId, String user) {
- Collection<LicenseKeyGroupEntity> licenseKeyGroups =
- vendorLicenseManager.listLicenseKeyGroups(vlmId, new Version(versionId));
- GenericCollectionWrapper<LicenseKeyGroupEntityDto> result = new GenericCollectionWrapper<>();
MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto outputMapper =
- new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
- for (LicenseKeyGroupEntity ep : licenseKeyGroups) {
- result.add(outputMapper.applyMapping(ep, LicenseKeyGroupEntityDto.class));
- }
+ new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
+
+ GenericCollectionWrapper<LicenseKeyGroupEntityDto> result = new GenericCollectionWrapper<>(
+ vendorLicenseManager.listLicenseKeyGroups(vlmId, new Version(versionId)).stream()
+ .sorted(Comparator.comparing(LicenseKeyGroupEntity::getName))
+ .map(item -> outputMapper.applyMapping(item, LicenseKeyGroupEntityDto.class))
+ .collect(Collectors.toList()));
+
return Response.ok(result).build();
}