summaryrefslogtreecommitdiffstats
path: root/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 options
context:
space:
mode:
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/LicenseKeyGroupsImpl.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/LicenseKeyGroupsImpl.java24
1 files changed, 13 insertions, 11 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/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();
}