From 453831564d4af7eb7603a50a2d75505ad858db2b Mon Sep 17 00:00:00 2001 From: ayalaben Date: Thu, 4 Oct 2018 14:24:58 +0300 Subject: Entities are not ordered by Name user feedback Change-Id: I937b744c13d3cdf08a2ba23e365c7138494ac491 Issue-ID: SDC-1818 Signed-off-by: ayalaben --- .../rest/services/LicenseKeyGroupsImpl.java | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) (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/LicenseKeyGroupsImpl.java') 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 licenseKeyGroups = - vendorLicenseManager.listLicenseKeyGroups(vlmId, new Version(versionId)); - GenericCollectionWrapper result = new GenericCollectionWrapper<>(); MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto outputMapper = - new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(); - for (LicenseKeyGroupEntity ep : licenseKeyGroups) { - result.add(outputMapper.applyMapping(ep, LicenseKeyGroupEntityDto.class)); - } + new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(); + + GenericCollectionWrapper 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(); } -- cgit 1.2.3-korg