Refactoring of RepostioryManagement and extending classes (#2174)
* createMetaData renamed to putMetaData * getXXX methods returing Optional are renamed to findXXX * unified method order (code cosmetics) Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -119,7 +119,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
final Slice<DistributionSet> findDsPage;
|
||||
final long countModulesAll;
|
||||
if (rsqlParam != null) {
|
||||
findDsPage = distributionSetManagement.findByRsql(pageable, rsqlParam);
|
||||
findDsPage = distributionSetManagement.findByRsql(rsqlParam, pageable);
|
||||
countModulesAll = ((Page<DistributionSet>) findDsPage).getTotalElements();
|
||||
} else {
|
||||
findDsPage = distributionSetManagement.findAll(pageable);
|
||||
@@ -150,7 +150,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
|
||||
//check if there is already deleted DS Type
|
||||
for (MgmtDistributionSetRequestBodyPost ds : sets) {
|
||||
final Optional<DistributionSetType> opt = distributionSetTypeManagement.getByKey(ds.getType());
|
||||
final Optional<DistributionSetType> opt = distributionSetTypeManagement.findByKey(ds.getType());
|
||||
opt.ifPresent(dsType -> {
|
||||
if (dsType.isDeleted()) {
|
||||
final String text = "Cannot create Distribution Set from type with key {0}. Distribution Set Type already deleted!";
|
||||
@@ -288,10 +288,10 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
final Page<DistributionSetMetadata> metaDataPage;
|
||||
|
||||
if (rsqlParam != null) {
|
||||
metaDataPage = distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(pageable, distributionSetId,
|
||||
rsqlParam);
|
||||
metaDataPage = distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(distributionSetId, rsqlParam, pageable
|
||||
);
|
||||
} else {
|
||||
metaDataPage = distributionSetManagement.findMetaDataByDistributionSetId(pageable, distributionSetId);
|
||||
metaDataPage = distributionSetManagement.findMetaDataByDistributionSetId(distributionSetId, pageable);
|
||||
}
|
||||
|
||||
return ResponseEntity
|
||||
@@ -302,7 +302,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
public ResponseEntity<MgmtMetadata> getMetadataValue(final Long distributionSetId, final String metadataKey) {
|
||||
// check if distribution set exists otherwise throw exception immediately
|
||||
final DistributionSetMetadata findOne = distributionSetManagement
|
||||
.getMetaDataByDistributionSetId(distributionSetId, metadataKey)
|
||||
.findMetaDataByDistributionSetId(distributionSetId, metadataKey)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetMetadata.class, distributionSetId, metadataKey));
|
||||
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDsMetadata(findOne));
|
||||
}
|
||||
@@ -326,7 +326,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
@Override
|
||||
public ResponseEntity<List<MgmtMetadata>> createMetadata(final Long distributionSetId, final List<MgmtMetadata> metadataRest) {
|
||||
// check if distribution set exists otherwise throw exception immediately
|
||||
final List<DistributionSetMetadata> created = distributionSetManagement.createMetaData(distributionSetId,
|
||||
final List<DistributionSetMetadata> created = distributionSetManagement.putMetaData(distributionSetId,
|
||||
MgmtDistributionSetMapper.fromRequestDsMetadata(metadataRest, entityFactory));
|
||||
return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDsMetadata(created), HttpStatus.CREATED);
|
||||
|
||||
@@ -357,7 +357,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
|
||||
final Sort sorting = PagingUtility.sanitizeSoftwareModuleSortParam(sortParam);
|
||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||
final Page<SoftwareModule> softwaremodules = softwareModuleManagement.findByAssignedTo(pageable, distributionSetId);
|
||||
final Page<SoftwareModule> softwaremodules = softwareModuleManagement.findByAssignedTo(distributionSetId, pageable);
|
||||
return ResponseEntity.ok(new PagedList<>(MgmtSoftwareModuleMapper.toResponse(
|
||||
softwaremodules.getContent()), softwaremodules.getTotalElements()));
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
||||
distributionSetTags = distributionSetTagManagement.findAll(pageable);
|
||||
count = distributionSetTagManagement.count();
|
||||
} else {
|
||||
final Page<DistributionSetTag> page = distributionSetTagManagement.findByRsql(pageable, rsqlParam);
|
||||
final Page<DistributionSetTag> page = distributionSetTagManagement.findByRsql(rsqlParam, pageable);
|
||||
distributionSetTags = page;
|
||||
count = page.getTotalElements();
|
||||
}
|
||||
@@ -137,9 +137,9 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||
Page<DistributionSet> findDistrAll;
|
||||
if (rsqlParam == null) {
|
||||
findDistrAll = distributionSetManagement.findByTag(pageable, distributionsetTagId);
|
||||
findDistrAll = distributionSetManagement.findByTag(distributionsetTagId, pageable);
|
||||
} else {
|
||||
findDistrAll = distributionSetManagement.findByRsqlAndTag(pageable, rsqlParam, distributionsetTagId);
|
||||
findDistrAll = distributionSetManagement.findByRsqlAndTag(rsqlParam, distributionsetTagId, pageable);
|
||||
}
|
||||
|
||||
final List<MgmtDistributionSet> rest = MgmtDistributionSetMapper.toResponseFromDsList(findDistrAll.getContent());
|
||||
|
||||
@@ -65,7 +65,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
|
||||
final Slice<DistributionSetType> findModuleTypessAll;
|
||||
long countModulesAll;
|
||||
if (rsqlParam != null) {
|
||||
findModuleTypessAll = distributionSetTypeManagement.findByRsql(pageable, rsqlParam);
|
||||
findModuleTypessAll = distributionSetTypeManagement.findByRsql(rsqlParam, pageable);
|
||||
countModulesAll = ((Page<DistributionSetType>) findModuleTypessAll).getTotalElements();
|
||||
} else {
|
||||
findModuleTypessAll = distributionSetTypeManagement.findAll(pageable);
|
||||
|
||||
@@ -165,7 +165,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
||||
final Slice<SoftwareModule> findModulesAll;
|
||||
final long countModulesAll;
|
||||
if (rsqlParam != null) {
|
||||
findModulesAll = softwareModuleManagement.findByRsql(pageable, rsqlParam);
|
||||
findModulesAll = softwareModuleManagement.findByRsql(rsqlParam, pageable);
|
||||
countModulesAll = ((Page<SoftwareModule>) findModulesAll).getTotalElements();
|
||||
} else {
|
||||
findModulesAll = softwareModuleManagement.findAll(pageable);
|
||||
@@ -191,7 +191,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
||||
log.debug("creating {} softwareModules", softwareModules.size());
|
||||
|
||||
for (final MgmtSoftwareModuleRequestBodyPost sm : softwareModules) {
|
||||
final Optional<SoftwareModuleType> opt = softwareModuleTypeManagement.getByKey(sm.getType());
|
||||
final Optional<SoftwareModuleType> opt = softwareModuleTypeManagement.findByKey(sm.getType());
|
||||
opt.ifPresent(smType -> {
|
||||
if (smType.isDeleted()) {
|
||||
final String text = "Cannot create Software Module from type with key {0}. Software Module Type already deleted!";
|
||||
@@ -245,7 +245,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
||||
final Page<SoftwareModuleMetadata> metaDataPage;
|
||||
|
||||
if (rsqlParam != null) {
|
||||
metaDataPage = softwareModuleManagement.findMetaDataByRsql(pageable, softwareModuleId, rsqlParam);
|
||||
metaDataPage = softwareModuleManagement.findMetaDataByRsql(softwareModuleId, rsqlParam, pageable);
|
||||
} else {
|
||||
metaDataPage = softwareModuleManagement.findMetaDataBySoftwareModuleId(pageable, softwareModuleId);
|
||||
}
|
||||
@@ -257,7 +257,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
||||
@Override
|
||||
public ResponseEntity<MgmtSoftwareModuleMetadata> getMetadataValue(final Long softwareModuleId, final String metadataKey) {
|
||||
final SoftwareModuleMetadata findOne = softwareModuleManagement
|
||||
.getMetaDataBySoftwareModuleId(softwareModuleId, metadataKey).orElseThrow(
|
||||
.findMetaDataBySoftwareModuleId(softwareModuleId, metadataKey).orElseThrow(
|
||||
() -> new EntityNotFoundException(SoftwareModuleMetadata.class, softwareModuleId, metadataKey));
|
||||
|
||||
return ResponseEntity.ok(MgmtSoftwareModuleMapper.toResponseSwMetadata(findOne));
|
||||
@@ -282,7 +282,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
||||
@Override
|
||||
public ResponseEntity<List<MgmtSoftwareModuleMetadata>> createMetadata(
|
||||
final Long softwareModuleId, final List<MgmtSoftwareModuleMetadata> metadataRest) {
|
||||
final List<SoftwareModuleMetadata> created = softwareModuleManagement.createMetaData(
|
||||
final List<SoftwareModuleMetadata> created = softwareModuleManagement.putMetaData(
|
||||
MgmtSoftwareModuleMapper.fromRequestSwMetadata(entityFactory, softwareModuleId, metadataRest));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(MgmtSoftwareModuleMapper.toResponseSwMetadata(created));
|
||||
|
||||
@@ -56,7 +56,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
|
||||
final Slice<SoftwareModuleType> findModuleTypessAll;
|
||||
final long countModulesAll;
|
||||
if (rsqlParam != null) {
|
||||
findModuleTypessAll = softwareModuleTypeManagement.findByRsql(pageable, rsqlParam);
|
||||
findModuleTypessAll = softwareModuleTypeManagement.findByRsql(rsqlParam, pageable);
|
||||
countModulesAll = ((Page<SoftwareModuleType>) findModuleTypessAll).getTotalElements();
|
||||
} else {
|
||||
findModuleTypessAll = softwareModuleTypeManagement.findAll(pageable);
|
||||
|
||||
Reference in New Issue
Block a user