this.results = list;
this.listCount = list.size();
}
+ else {
+ this.results = new ArrayList<>();
+ }
}
public List<T> getResults() {
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;
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")
* @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.
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;
@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();
}
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;
+ }
+
}
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;
* @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.
*
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;
+ }
}
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;
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")
* @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();
}