diff options
author | ayalaben <ayala.benzvi@amdocs.com> | 2018-10-04 14:24:58 +0300 |
---|---|---|
committer | ayalaben <ayala.benzvi@amdocs.com> | 2018-10-07 13:15:53 +0300 |
commit | 453831564d4af7eb7603a50a2d75505ad858db2b (patch) | |
tree | 1a06c433d2d9b458c4e47531fb39abc9db1fb66a /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 | |
parent | 454cfef267e87a2e0fba46964106c6fe03c220fd (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/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java')
-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.java | 27 |
1 files changed, 14 insertions, 13 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. |