Remove this for member variable

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-02-09 11:29:01 +01:00
parent 1bb29338ac
commit ceb23e65e4
33 changed files with 1214 additions and 1241 deletions

View File

@@ -49,8 +49,8 @@ public class DataReportSeries<T extends Serializable> extends AbstractReportSeri
}
private void setData(final List<DataReportSeriesItem<T>> values) {
this.data.clear();
this.data.addAll(values);
data.clear();
data.addAll(values);
}
/**
@@ -58,10 +58,10 @@ public class DataReportSeries<T extends Serializable> extends AbstractReportSeri
*/
@SuppressWarnings("unchecked")
public DataReportSeriesItem<T>[] getData() {
return this.data.toArray(new DataReportSeriesItem[this.data.size()]);
return data.toArray(new DataReportSeriesItem[data.size()]);
}
public Stream<DataReportSeriesItem<T>> getDataStream() {
return this.data.stream();
return data.stream();
}
}

View File

@@ -39,13 +39,13 @@ public class DataReportSeriesItem<T extends Serializable> implements Serializabl
* @return the type of the data report item
*/
public T getType() {
return this.type;
return type;
}
/**
* @return the data of the data report item
*/
public Number getData() {
return this.data;
return data;
}
}

View File

@@ -39,13 +39,13 @@ public class InnerOuterDataReportSeries<T extends Serializable> {
* @return the innerSeries
*/
public DataReportSeries<T> getInnerSeries() {
return this.innerSeries;
return innerSeries;
}
/**
* @return the outerSeries
*/
public DataReportSeries<T> getOuterSeries() {
return this.outerSeries;
return outerSeries;
}
}

View File

@@ -117,7 +117,7 @@ public class DistributionSetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public DistributionSet findDistributionSetByIdWithDetails(@NotNull final Long distid) {
return this.distributionSetRepository.findOne(DistributionSetSpecification.byId(distid));
return distributionSetRepository.findOne(DistributionSetSpecification.byId(distid));
}
/**
@@ -130,7 +130,7 @@ public class DistributionSetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public DistributionSet findDistributionSetById(@NotNull final Long distid) {
return this.distributionSetRepository.findOne(distid);
return distributionSetRepository.findOne(distid);
}
/**
@@ -174,7 +174,7 @@ public class DistributionSetManagement {
@NotNull final String tagName) {
final Iterable<DistributionSet> sets = findDistributionSetListWithDetails(dsIds);
final DistributionSetTag myTag = this.tagManagement.findDistributionSetTag(tagName);
final DistributionSetTag myTag = tagManagement.findDistributionSetTag(tagName);
DistributionSetTagAssigmentResult result = null;
final List<DistributionSet> allDSs = new ArrayList<>();
@@ -192,18 +192,18 @@ public class DistributionSetManagement {
}
}
result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), 0, allDSs.size(),
Collections.emptyList(), this.distributionSetRepository.save(allDSs), myTag);
Collections.emptyList(), distributionSetRepository.save(allDSs), myTag);
} else {
result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), allDSs.size(), 0,
this.distributionSetRepository.save(allDSs), Collections.emptyList(), myTag);
distributionSetRepository.save(allDSs), Collections.emptyList(), myTag);
}
final DistributionSetTagAssigmentResult resultAssignment = result;
this.afterCommit
.afterCommit(() -> this.eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment)));
afterCommit
.afterCommit(() -> eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment)));
// no reason to persist the tag
this.entityManager.detach(myTag);
entityManager.detach(myTag);
return result;
}
@@ -218,7 +218,7 @@ public class DistributionSetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public List<DistributionSet> findDistributionSetListWithDetails(
@NotEmpty final Collection<Long> distributionIdSet) {
return this.distributionSetRepository.findAll(DistributionSetSpecification.byIds(distributionIdSet));
return distributionSetRepository.findAll(DistributionSetSpecification.byIds(distributionIdSet));
}
/**
@@ -238,7 +238,7 @@ public class DistributionSetManagement {
checkNotNull(ds.getId());
final DistributionSet persisted = findDistributionSetByIdWithDetails(ds.getId());
checkDistributionSetSoftwareModulesIsAllowedToModify(ds, persisted.getModules());
return this.distributionSetRepository.save(ds);
return distributionSetRepository.save(ds);
}
/**
@@ -260,7 +260,7 @@ public class DistributionSetManagement {
@Transactional
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
public void deleteDistributionSet(@NotNull final DistributionSet set) {
this.deleteDistributionSet(set.getId());
deleteDistributionSet(set.getId());
}
/**
@@ -277,11 +277,11 @@ public class DistributionSetManagement {
public void deleteDistributionSet(@NotEmpty final Long... distributionSetIDs) {
final List<Long> toHardDelete = new ArrayList<>();
final List<Long> assigned = this.distributionSetRepository.findAssignedDistributionSetsById(distributionSetIDs);
final List<Long> assigned = distributionSetRepository.findAssignedDistributionSetsById(distributionSetIDs);
// soft delete assigned
if (!assigned.isEmpty()) {
this.distributionSetRepository.deleteDistributionSet(assigned.toArray(new Long[assigned.size()]));
distributionSetRepository.deleteDistributionSet(assigned.toArray(new Long[assigned.size()]));
}
// mark the rest as hard delete
@@ -296,7 +296,7 @@ public class DistributionSetManagement {
// don't give the delete statement an empty list, JPA/Oracle cannot
// handle the empty list,
// see MECS-403
this.distributionSetRepository.deleteByIdIn(toHardDelete);
distributionSetRepository.deleteByIdIn(toHardDelete);
}
}
@@ -319,9 +319,9 @@ public class DistributionSetManagement {
public DistributionSet createDistributionSet(@NotNull final DistributionSet dSet) {
prepareDsSave(dSet);
if (dSet.getType() == null) {
dSet.setType(this.systemManagement.getTenantMetadata().getDefaultDsType());
dSet.setType(systemManagement.getTenantMetadata().getDefaultDsType());
}
return this.distributionSetRepository.save(dSet);
return distributionSetRepository.save(dSet);
}
private void prepareDsSave(final DistributionSet dSet) {
@@ -329,7 +329,7 @@ public class DistributionSetManagement {
throw new EntityAlreadyExistsException("Parameter seems to be an existing, already persisted entity");
}
if (this.distributionSetRepository.countByNameAndVersion(dSet.getName(), dSet.getVersion()) > 0) {
if (distributionSetRepository.countByNameAndVersion(dSet.getName(), dSet.getVersion()) > 0) {
throw new EntityAlreadyExistsException("DistributionSet with that name and version already exists.");
}
@@ -354,7 +354,7 @@ public class DistributionSetManagement {
for (final DistributionSet ds : distributionSets) {
prepareDsSave(ds);
}
return this.distributionSetRepository.save(distributionSets);
return distributionSetRepository.save(distributionSets);
}
/**
@@ -375,7 +375,7 @@ public class DistributionSetManagement {
for (final SoftwareModule softwareModule : softwareModules) {
ds.addModule(softwareModule);
}
return this.distributionSetRepository.save(ds);
return distributionSetRepository.save(ds);
}
/**
@@ -397,7 +397,7 @@ public class DistributionSetManagement {
softwareModules.add(softwareModule);
ds.removeModule(softwareModule);
checkDistributionSetSoftwareModulesIsAllowedToModify(ds, softwareModules);
return this.distributionSetRepository.save(ds);
return distributionSetRepository.save(ds);
}
/**
@@ -419,17 +419,17 @@ public class DistributionSetManagement {
public DistributionSetType updateDistributionSetType(@NotNull final DistributionSetType dsType) {
checkNotNull(dsType.getId());
final DistributionSetType persisted = this.distributionSetTypeRepository.findOne(dsType.getId());
final DistributionSetType persisted = distributionSetTypeRepository.findOne(dsType.getId());
// throw exception if user tries to update a DS type that is already in
// use
if (!persisted.areModuleEntriesIdentical(dsType) && this.distributionSetRepository.countByType(persisted) > 0) {
if (!persisted.areModuleEntriesIdentical(dsType) && distributionSetRepository.countByType(persisted) > 0) {
throw new EntityReadOnlyException(
String.format("distribution set type %s set is already assigned to targets and cannot be changed",
dsType.getName()));
}
return this.distributionSetTypeRepository.save(dsType);
return distributionSetTypeRepository.save(dsType);
}
/**
@@ -445,7 +445,7 @@ public class DistributionSetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Page<DistributionSetType> findDistributionSetTypesByPredicate(
@NotNull final Specification<DistributionSetType> spec, @NotNull final Pageable pageable) {
return this.distributionSetTypeRepository.findAll(spec, pageable);
return distributionSetTypeRepository.findAll(spec, pageable);
}
/**
@@ -455,7 +455,7 @@ public class DistributionSetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Page<DistributionSetType> findDistributionSetTypesAll(@NotNull final Pageable pageable) {
return this.distributionSetTypeRepository.findByDeleted(pageable, false);
return distributionSetTypeRepository.findByDeleted(pageable, false);
}
/**
@@ -488,7 +488,7 @@ public class DistributionSetManagement {
if (specList == null || specList.isEmpty()) {
return null;
}
return this.distributionSetRepository.findOne(SpecificationsBuilder.combineWithAnd(specList));
return distributionSetRepository.findOne(SpecificationsBuilder.combineWithAnd(specList));
}
/**
@@ -633,7 +633,7 @@ public class DistributionSetManagement {
@NotEmpty final String version) {
final Specification<DistributionSet> spec = DistributionSetSpecification
.equalsNameAndVersionIgnoreCase(distributionName, version);
return this.distributionSetRepository.findOne(spec);
return distributionSetRepository.findOne(spec);
}
@@ -650,7 +650,7 @@ public class DistributionSetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Iterable<DistributionSet> findDistributionSetList(@NotEmpty final Collection<Long> dist) {
return this.distributionSetRepository.findAll(dist);
return distributionSetRepository.findAll(dist);
}
/**
@@ -667,7 +667,7 @@ public class DistributionSetManagement {
final Specification<DistributionSet> spec = DistributionSetSpecification.isDeleted(Boolean.FALSE);
specList.add(spec);
return this.distributionSetRepository.count(SpecificationsBuilder.combineWithAnd(specList));
return distributionSetRepository.count(SpecificationsBuilder.combineWithAnd(specList));
}
/**
@@ -675,7 +675,7 @@ public class DistributionSetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Long countDistributionSetTypesAll() {
return this.distributionSetTypeRepository.countByDeleted(false);
return distributionSetTypeRepository.countByDeleted(false);
}
/**
@@ -685,7 +685,7 @@ public class DistributionSetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public DistributionSetType findDistributionSetTypeByName(@NotNull final String name) {
return this.distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byName(name));
return distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byName(name));
}
/**
@@ -695,7 +695,7 @@ public class DistributionSetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public DistributionSetType findDistributionSetTypeById(@NotNull final Long id) {
return this.distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byId(id));
return distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byId(id));
}
/**
@@ -705,7 +705,7 @@ public class DistributionSetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public DistributionSetType findDistributionSetTypeByKey(@NotNull final String key) {
return this.distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byKey(key));
return distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byKey(key));
}
/**
@@ -723,7 +723,7 @@ public class DistributionSetManagement {
throw new EntityAlreadyExistsException("Given type contains an Id!");
}
return this.distributionSetTypeRepository.save(type);
return distributionSetTypeRepository.save(type);
}
/**
@@ -737,12 +737,12 @@ public class DistributionSetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
public void deleteDistributionSetType(@NotNull final DistributionSetType type) {
if (this.distributionSetRepository.countByType(type) > 0) {
final DistributionSetType toDelete = this.entityManager.merge(type);
if (distributionSetRepository.countByType(type) > 0) {
final DistributionSetType toDelete = entityManager.merge(type);
toDelete.setDeleted(true);
this.distributionSetTypeRepository.save(toDelete);
distributionSetTypeRepository.save(toDelete);
} else {
this.distributionSetTypeRepository.delete(type.getId());
distributionSetTypeRepository.delete(type.getId());
}
}
@@ -760,15 +760,15 @@ public class DistributionSetManagement {
@Modifying
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
public DistributionSetMetadata createDistributionSetMetadata(@NotNull final DistributionSetMetadata metadata) {
if (this.distributionSetMetadataRepository.exists(metadata.getId())) {
if (distributionSetMetadataRepository.exists(metadata.getId())) {
throwMetadataKeyAlreadyExists(metadata.getId().getKey());
}
// merge base software module so optLockRevision gets updated and audit
// log written because
// modifying metadata is modifying the base distribution set itself for
// auditing purposes.
this.entityManager.merge(metadata.getDistributionSet()).setLastModifiedAt(0L);
return this.distributionSetMetadataRepository.save(metadata);
entityManager.merge(metadata.getDistributionSet()).setLastModifiedAt(0L);
return distributionSetMetadataRepository.save(metadata);
}
/**
@@ -789,8 +789,8 @@ public class DistributionSetManagement {
for (final DistributionSetMetadata distributionSetMetadata : metadata) {
checkAndThrowAlreadyIfDistributionSetMetadataExists(distributionSetMetadata.getId());
}
metadata.forEach(m -> this.entityManager.merge(m.getDistributionSet()).setLastModifiedAt(-1L));
return (List<DistributionSetMetadata>) this.distributionSetMetadataRepository.save(metadata);
metadata.forEach(m -> entityManager.merge(m.getDistributionSet()).setLastModifiedAt(-1L));
return (List<DistributionSetMetadata>) distributionSetMetadataRepository.save(metadata);
}
/**
@@ -811,8 +811,8 @@ public class DistributionSetManagement {
findOne(metadata.getId());
// touch it to update the lock revision because we are modifying the
// DS indirectly
this.entityManager.merge(metadata.getDistributionSet()).setLastModifiedAt(0L);
return this.distributionSetMetadataRepository.save(metadata);
entityManager.merge(metadata.getDistributionSet()).setLastModifiedAt(0L);
return distributionSetMetadataRepository.save(metadata);
}
/**
@@ -825,7 +825,7 @@ public class DistributionSetManagement {
@Modifying
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
public void deleteDistributionSetMetadata(@NotNull final DsMetadataCompositeKey id) {
this.distributionSetMetadataRepository.delete(id);
distributionSetMetadataRepository.delete(id);
}
/**
@@ -842,7 +842,7 @@ public class DistributionSetManagement {
public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(
@NotNull final Long distributionSetId, @NotNull final Pageable pageable) {
return this.distributionSetMetadataRepository.findAll(
return distributionSetMetadataRepository.findAll(
(Specification<DistributionSetMetadata>) (root, query, cb) -> cb.equal(
root.get(DistributionSetMetadata_.distributionSet).get(DistributionSet_.id), distributionSetId),
pageable);
@@ -865,7 +865,7 @@ public class DistributionSetManagement {
public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(
@NotNull final Long distributionSetId, @NotNull final Specification<DistributionSetMetadata> spec,
@NotNull final Pageable pageable) {
return this.distributionSetMetadataRepository
return distributionSetMetadataRepository
.findAll(
(Specification<DistributionSetMetadata>) (root, query,
cb) -> cb.and(
@@ -887,7 +887,7 @@ public class DistributionSetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public DistributionSetMetadata findOne(@NotNull final DsMetadataCompositeKey id) {
final DistributionSetMetadata findOne = this.distributionSetMetadataRepository.findOne(id);
final DistributionSetMetadata findOne = distributionSetMetadataRepository.findOne(id);
if (findOne == null) {
throw new EntityNotFoundException("Metadata with key '" + id.getKey() + "' does not exist");
}
@@ -903,7 +903,7 @@ public class DistributionSetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public DistributionSet findDistributionSetByAction(@NotNull final Action action) {
return this.distributionSetRepository.findByAction(action);
return distributionSetRepository.findByAction(action);
}
/**
@@ -978,7 +978,7 @@ public class DistributionSetManagement {
private void checkDistributionSetSoftwareModulesIsAllowedToModify(final DistributionSet distributionSet,
final Set<SoftwareModule> softwareModules) {
if (!new HashSet<SoftwareModule>(distributionSet.getModules()).equals(softwareModules)
&& this.actionRepository.countByDistributionSet(distributionSet) > 0) {
&& actionRepository.countByDistributionSet(distributionSet) > 0) {
throw new EntityLockedException(
String.format("distribution set %s:%s is already assigned to targets and cannot be changed",
distributionSet.getName(), distributionSet.getVersion()));
@@ -986,7 +986,7 @@ public class DistributionSetManagement {
}
private void checkDistributionSetSoftwareModulesIsAllowedToModify(final DistributionSet distributionSet) {
if (this.actionRepository.countByDistributionSet(distributionSet) > 0) {
if (actionRepository.countByDistributionSet(distributionSet) > 0) {
throw new EntityLockedException(
String.format("distribution set %s:%s is already assigned to targets and cannot be changed",
distributionSet.getName(), distributionSet.getVersion()));
@@ -1021,14 +1021,14 @@ public class DistributionSetManagement {
final List<Specification<DistributionSet>> specList) {
if (specList == null || specList.isEmpty()) {
return this.distributionSetRepository.findAll(pageable);
return distributionSetRepository.findAll(pageable);
}
return this.distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable);
return distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable);
}
private void checkAndThrowAlreadyIfDistributionSetMetadataExists(final DsMetadataCompositeKey metadataId) {
if (this.distributionSetMetadataRepository.exists(metadataId)) {
if (distributionSetMetadataRepository.exists(metadataId)) {
throw new EntityAlreadyExistsException(
"Metadata entry with key '" + metadataId.getKey() + "' already exists");
}
@@ -1057,13 +1057,13 @@ public class DistributionSetManagement {
final List<DistributionSet> allDs = findDistributionSetListWithDetails(dsIds);
allDs.forEach(ds -> ds.getTags().add(tag));
final List<DistributionSet> save = this.distributionSetRepository.save(allDs);
final List<DistributionSet> save = distributionSetRepository.save(allDs);
this.afterCommit.afterCommit(() -> {
afterCommit.afterCommit(() -> {
final DistributionSetTagAssigmentResult result = new DistributionSetTagAssigmentResult(0, save.size(), 0,
save, Collections.emptyList(), tag);
this.eventBus.post(new DistributionSetTagAssigmentResultEvent(result));
eventBus.post(new DistributionSetTagAssigmentResultEvent(result));
});
return save;
@@ -1107,6 +1107,6 @@ public class DistributionSetManagement {
private List<DistributionSet> unAssignTag(final Collection<DistributionSet> distributionSets,
final DistributionSetTag tag) {
distributionSets.forEach(ds -> ds.getTags().remove(tag));
return this.distributionSetRepository.save(distributionSets);
return distributionSetRepository.save(distributionSets);
}
}

View File

@@ -99,7 +99,7 @@ public class ReportManagement {
@Cacheable("targetStatus")
public DataReportSeries<TargetUpdateStatus> targetStatus() {
final CriteriaBuilder cb = this.entityManager.getCriteriaBuilder();
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
final Root<Target> targetRoot = query.from(Target.class);
final Join<Target, TargetInfo> targetInfo = targetRoot.join(Target_.targetInfo);
@@ -111,7 +111,7 @@ public class ReportManagement {
// | col1 | col2 |
// | U_STATUS | COUNT |
final List<Object[]> resultList = this.entityManager.createQuery(multiselect).getResultList();
final List<Object[]> resultList = entityManager.createQuery(multiselect).getResultList();
final List<DataReportSeriesItem<TargetUpdateStatus>> reportSeriesItems = resultList.stream()
.map(r -> new DataReportSeriesItem<TargetUpdateStatus>((TargetUpdateStatus) r[0], (Long) r[1]))
@@ -140,7 +140,7 @@ public class ReportManagement {
public List<InnerOuterDataReportSeries<String>> distributionUsageAssigned(final int topXEntries) {
// top X entries distribution usage
final CriteriaBuilder cbTopX = this.entityManager.getCriteriaBuilder();
final CriteriaBuilder cbTopX = entityManager.getCriteriaBuilder();
final CriteriaQuery<Object[]> queryTopX = cbTopX.createQuery(Object[].class);
final Root<DistributionSet> rootTopX = queryTopX.from(DistributionSet.class);
final ListJoin<DistributionSet, Target> joinTopX = rootTopX.join(DistributionSet_.assignedToTargets,
@@ -154,7 +154,7 @@ public class ReportManagement {
.orderBy(cbTopX.desc(countColumn), cbTopX.asc(rootTopX.get(DistributionSet_.name)));
// | col1 | col2 | col3 |
// | NAME | VER | COUNT |
final List<Object[]> resultListTop = this.entityManager.createQuery(groupBy).getResultList();
final List<Object[]> resultListTop = entityManager.createQuery(groupBy).getResultList();
// end of top X entries distribution usage
return mapDistirbutionUsageResultToDataReport(topXEntries, resultListTop);
@@ -180,7 +180,7 @@ public class ReportManagement {
@Cacheable("distributionUsageInstalled")
public List<InnerOuterDataReportSeries<String>> distributionUsageInstalled(final int topXEntries) {
// top X entries distribution usage
final CriteriaBuilder cbTopX = this.entityManager.getCriteriaBuilder();
final CriteriaBuilder cbTopX = entityManager.getCriteriaBuilder();
final CriteriaQuery<Object[]> queryTopX = cbTopX.createQuery(Object[].class);
final Root<DistributionSet> rootTopX = queryTopX.from(DistributionSet.class);
final ListJoin<DistributionSet, TargetInfo> joinTopX = rootTopX.join(DistributionSet_.installedAtTargets,
@@ -194,7 +194,7 @@ public class ReportManagement {
.orderBy(cbTopX.desc(countColumn), cbTopX.asc(rootTopX.get(DistributionSet_.name)));
// | col1 | col2 | col3 |
// | NAME | VER | COUNT |
final List<Object[]> resultListTop = this.entityManager.createQuery(groupBy).getResultList();
final List<Object[]> resultListTop = entityManager.createQuery(groupBy).getResultList();
// end of top X entries distribution usage
return mapDistirbutionUsageResultToDataReport(topXEntries, resultListTop);
@@ -215,7 +215,7 @@ public class ReportManagement {
@Cacheable("targetsCreatedOverPeriod")
public <T extends Serializable> DataReportSeries<T> targetsCreatedOverPeriod(final DateType<T> dateType,
final LocalDateTime from, final LocalDateTime to) {
final Query createNativeQuery = this.entityManager
final Query createNativeQuery = entityManager
.createNativeQuery(getTargetsCreatedQueryTemplate(dateType, from, to));
final List<Object[]> resultList = createNativeQuery.getResultList();
@@ -228,16 +228,16 @@ public class ReportManagement {
private String getTargetsCreatedQueryTemplate(final DateType<?> dateType, final LocalDateTime from,
final LocalDateTime to) {
switch (this.databaseType) {
switch (databaseType) {
case H2_DB_TYPE:
return String.format(H2_TARGET_CREATED_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType),
dateTimeFormatToSqlFormat(dateType), from.format(DATE_FORMAT), dateTimeFormatToSqlFormat(dateType),
to.format(DATE_FORMAT), dateTimeFormatToSqlFormat(dateType), this.tenantAware.getCurrentTenant(),
to.format(DATE_FORMAT), dateTimeFormatToSqlFormat(dateType), tenantAware.getCurrentTenant(),
dateTimeFormatToSqlFormat(dateType));
case MYSQL_DB_TYPE:
return String.format(MYSQL_TARGET_CREATED_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType),
dateTimeFormatToSqlFormat(dateType), from.toString(), dateTimeFormatToSqlFormat(dateType),
to.toString(), dateTimeFormatToSqlFormat(dateType), this.tenantAware.getCurrentTenant(),
to.toString(), dateTimeFormatToSqlFormat(dateType), tenantAware.getCurrentTenant(),
dateTimeFormatToSqlFormat(dateType));
default:
return null;
@@ -246,16 +246,16 @@ public class ReportManagement {
private String getFeedbackReceivedQueryTemplate(final DateType<?> dateType, final LocalDateTime from,
final LocalDateTime to) {
switch (this.databaseType) {
switch (databaseType) {
case H2_DB_TYPE:
return String.format(H2_CONTROLLER_FRRDBACK_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType),
dateTimeFormatToSqlFormat(dateType), from.format(DATE_FORMAT), dateTimeFormatToSqlFormat(dateType),
to.format(DATE_FORMAT), dateTimeFormatToSqlFormat(dateType), this.tenantAware.getCurrentTenant(),
to.format(DATE_FORMAT), dateTimeFormatToSqlFormat(dateType), tenantAware.getCurrentTenant(),
dateTimeFormatToSqlFormat(dateType));
case MYSQL_DB_TYPE:
return String.format(MYSQL_CONTROLLER_FRRDBACK_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType),
dateTimeFormatToSqlFormat(dateType), from.toString(), dateTimeFormatToSqlFormat(dateType),
to.toString(), dateTimeFormatToSqlFormat(dateType), this.tenantAware.getCurrentTenant(),
to.toString(), dateTimeFormatToSqlFormat(dateType), tenantAware.getCurrentTenant(),
dateTimeFormatToSqlFormat(dateType));
default:
return null;
@@ -277,7 +277,7 @@ public class ReportManagement {
@Cacheable("feedbackReceivedOverTime")
public <T extends Serializable> DataReportSeries<T> feedbackReceivedOverTime(final DateType<T> dateType,
final LocalDateTime from, final LocalDateTime to) {
final Query createNativeQuery = this.entityManager
final Query createNativeQuery = entityManager
.createNativeQuery(getFeedbackReceivedQueryTemplate(dateType, from, to));
final List<Object[]> resultList = createNativeQuery.getResultList();
@@ -311,30 +311,30 @@ public class ReportManagement {
final LocalDateTime beforeMonth = now.minusMonths(1);
final LocalDateTime beforeYear = now.minusYears(1);
final CriteriaBuilder cb = this.entityManager.getCriteriaBuilder();
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
final List<DataReportSeriesItem<SeriesTime>> resultList = new ArrayList<>();
// hours
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.HOUR, this.entityManager
.createQuery(createCountSelectTargetsLastPoll(cb, beforeHour, now)).getSingleResult()));
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.HOUR,
entityManager.createQuery(createCountSelectTargetsLastPoll(cb, beforeHour, now)).getSingleResult()));
// days
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.DAY, this.entityManager
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.DAY, entityManager
.createQuery(createCountSelectTargetsLastPoll(cb, beforeDay, beforeHour)).getSingleResult()));
// weeks
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.WEEK, this.entityManager
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.WEEK, entityManager
.createQuery(createCountSelectTargetsLastPoll(cb, beforeWeek, beforeDay)).getSingleResult()));
// months
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.MONTH, this.entityManager
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.MONTH, entityManager
.createQuery(createCountSelectTargetsLastPoll(cb, beforeMonth, beforeWeek)).getSingleResult()));
// years
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.YEAR, this.entityManager
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.YEAR, entityManager
.createQuery(createCountSelectTargetsLastPoll(cb, beforeYear, beforeMonth)).getSingleResult()));
// years
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.MORE_THAN_YEAR, this.entityManager
.createQuery(createCountSelectTargetsLastPoll(cb, null, beforeYear)).getSingleResult()));
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.MORE_THAN_YEAR,
entityManager.createQuery(createCountSelectTargetsLastPoll(cb, null, beforeYear)).getSingleResult()));
// never
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.NEVER,
this.entityManager.createQuery(createCountSelectTargetsLastPoll(cb, null, null)).getSingleResult()));
entityManager.createQuery(createCountSelectTargetsLastPoll(cb, null, null)).getSingleResult()));
return new DataReportSeries<>("TargetLastPoll", resultList);
}
@@ -415,23 +415,23 @@ public class ReportManagement {
final List<InnerOuter> outer;
private InnerOuter(final DSName idName) {
this.name = idName;
this.outer = new ArrayList<>();
name = idName;
outer = new ArrayList<>();
}
private InnerOuter(final DSName idName, final long count) {
this.name = idName;
name = idName;
this.count = count;
this.outer = new ArrayList<>();
outer = new ArrayList<>();
}
private void addOuter(final DSName idName, final long count) {
this.outer.add(new InnerOuter(idName, count));
outer.add(new InnerOuter(idName, count));
this.count += count;
}
private DataReportSeriesItem<String> toItem() {
return new DataReportSeriesItem<>(this.name.getName() != null ? this.name.getName() : "misc", this.count);
return new DataReportSeriesItem<>(name.getName() != null ? name.getName() : "misc", count);
}
}
@@ -460,7 +460,7 @@ public class ReportManagement {
* @return the name
*/
private String getName() {
return this.name;
return name;
}
/*
@@ -472,7 +472,7 @@ public class ReportManagement {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (this.name == null ? 0 : this.name.hashCode());
result = prime * result + (name == null ? 0 : name.hashCode());
return result;
}
@@ -494,11 +494,11 @@ public class ReportManagement {
return false;
}
final DSName other = (DSName) obj;
if (this.name == null) {
if (name == null) {
if (other.name != null) {
return false;
}
} else if (!this.name.equals(other.name)) {
} else if (!name.equals(other.name)) {
return false;
}
return true;
@@ -511,12 +511,12 @@ public class ReportManagement {
*/
@Override
public String toString() {
return "DSName [name=" + this.name + "]";
return "DSName [name=" + name + "]";
}
}
private String dateTimeFormatToSqlFormat(final DateType<?> datatype) {
switch (this.databaseType) {
switch (databaseType) {
case H2_DB_TYPE:
return datatype.h2Format();
case MYSQL_DB_TYPE:

View File

@@ -117,7 +117,7 @@ public class SoftwareManagement {
public SoftwareModule updateSoftwareModule(@NotNull final SoftwareModule sm) {
checkNotNull(sm.getId());
final SoftwareModule module = this.softwareModuleRepository.findOne(sm.getId());
final SoftwareModule module = softwareModuleRepository.findOne(sm.getId());
if (null == sm.getDescription() || !sm.getDescription().equals(module.getDescription())) {
module.setDescription(sm.getDescription());
@@ -125,7 +125,7 @@ public class SoftwareManagement {
if (null == sm.getVendor() || !sm.getVendor().equals(module.getVendor())) {
module.setVendor(sm.getVendor());
}
return this.softwareModuleRepository.save(module);
return softwareModuleRepository.save(module);
}
/**
@@ -143,7 +143,7 @@ public class SoftwareManagement {
public SoftwareModuleType updateSoftwareModuleType(@NotNull final SoftwareModuleType sm) {
checkNotNull(sm.getId());
final SoftwareModuleType type = this.softwareModuleTypeRepository.findOne(sm.getId());
final SoftwareModuleType type = softwareModuleTypeRepository.findOne(sm.getId());
if (sm.getDescription() != null && !sm.getDescription().equals(type.getDescription())) {
type.setDescription(sm.getDescription());
@@ -151,7 +151,7 @@ public class SoftwareManagement {
if (sm.getColour() != null && !sm.getColour().equals(type.getColour())) {
type.setColour(sm.getColour());
}
return this.softwareModuleTypeRepository.save(type);
return softwareModuleTypeRepository.save(type);
}
/**
@@ -169,7 +169,7 @@ public class SoftwareManagement {
if (null != swModule.getId()) {
throw new EntityAlreadyExistsException();
}
return this.softwareModuleRepository.save(swModule);
return softwareModuleRepository.save(swModule);
}
/**
@@ -191,7 +191,7 @@ public class SoftwareManagement {
}
});
return this.softwareModuleRepository.save(swModules);
return softwareModuleRepository.save(swModules);
}
@@ -252,7 +252,7 @@ public class SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_CONTROLLER)
public SoftwareModule findSoftwareModuleById(@NotNull final Long id) {
return this.artifactManagement.findSoftwareModuleById(id);
return artifactManagement.findSoftwareModuleById(id);
}
/**
@@ -268,7 +268,7 @@ public class SoftwareManagement {
public List<SoftwareModule> findSoftwareModuleByNameAndVersion(@NotEmpty final String name,
@NotEmpty final String version) {
return this.softwareModuleRepository.findByNameAndVersion(name, version);
return softwareModuleRepository.findByNameAndVersion(name, version);
}
/**
@@ -286,22 +286,22 @@ public class SoftwareManagement {
}
private boolean isUnassigned(final SoftwareModule bsmMerged) {
return this.distributionSetRepository.findByModules(bsmMerged).isEmpty();
return distributionSetRepository.findByModules(bsmMerged).isEmpty();
}
private Slice<SoftwareModule> findSwModuleByCriteriaAPI(@NotNull final Pageable pageable,
@NotEmpty final List<Specification<SoftwareModule>> specList) {
return this.criteriaNoCountDao.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable,
return criteriaNoCountDao.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable,
SoftwareModule.class);
}
private Long countSwModuleByCriteriaAPI(@NotEmpty final List<Specification<SoftwareModule>> specList) {
return this.softwareModuleRepository.count(SpecificationsBuilder.combineWithAnd(specList));
return softwareModuleRepository.count(SpecificationsBuilder.combineWithAnd(specList));
}
private void deleteGridFsArtifacts(final SoftwareModule swModule) {
for (final LocalArtifact localArtifact : swModule.getLocalArtifacts()) {
this.artifactManagement.deleteGridFsArtifact(localArtifact);
artifactManagement.deleteGridFsArtifact(localArtifact);
}
}
@@ -315,7 +315,7 @@ public class SoftwareManagement {
@Transactional
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
public void deleteSoftwareModules(@NotNull final Iterable<Long> ids) {
final List<SoftwareModule> swModulesToDelete = this.softwareModuleRepository.findByIdIn(ids);
final List<SoftwareModule> swModulesToDelete = softwareModuleRepository.findByIdIn(ids);
final Set<Long> assignedModuleIds = new HashSet<>();
swModulesToDelete.forEach(swModule -> {
@@ -324,7 +324,7 @@ public class SoftwareManagement {
if (isUnassigned(swModule)) {
this.softwareModuleRepository.delete(swModule);
softwareModuleRepository.delete(swModule);
} else {
@@ -334,10 +334,10 @@ public class SoftwareManagement {
if (!assignedModuleIds.isEmpty()) {
String currentUser = null;
if (this.auditorProvider != null) {
currentUser = this.auditorProvider.getCurrentAuditor();
if (auditorProvider != null) {
currentUser = auditorProvider.getCurrentAuditor();
}
this.softwareModuleRepository.deleteSoftwareModule(System.currentTimeMillis(), currentUser,
softwareModuleRepository.deleteSoftwareModule(System.currentTimeMillis(), currentUser,
assignedModuleIds.toArray(new Long[0]));
}
}
@@ -398,7 +398,7 @@ public class SoftwareManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public SoftwareModule findSoftwareModuleWithDetails(@NotNull final Long id) {
return this.artifactManagement.findSoftwareModuleWithDetails(id);
return artifactManagement.findSoftwareModuleWithDetails(id);
}
/**
@@ -413,7 +413,7 @@ public class SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Page<SoftwareModule> findSoftwareModulesByPredicate(@NotNull final Specification<SoftwareModule> spec,
@NotNull final Pageable pageable) {
return this.softwareModuleRepository.findAll(spec, pageable);
return softwareModuleRepository.findAll(spec, pageable);
}
/**
@@ -428,7 +428,7 @@ public class SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Page<SoftwareModuleType> findSoftwareModuleTypesByPredicate(
@NotNull final Specification<SoftwareModuleType> spec, @NotNull final Pageable pageable) {
return this.softwareModuleTypeRepository.findAll(spec, pageable);
return softwareModuleTypeRepository.findAll(spec, pageable);
}
/**
@@ -441,7 +441,7 @@ public class SoftwareManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public List<SoftwareModule> findSoftwareModulesById(@NotEmpty final List<Long> ids) {
return this.softwareModuleRepository.findByIdIn(ids);
return softwareModuleRepository.findByIdIn(ids);
}
/**
@@ -509,7 +509,7 @@ public class SoftwareManagement {
final List<CustomSoftwareModule> resultList = new ArrayList<>();
final int pageSize = pageable.getPageSize();
final CriteriaBuilder cb = this.entityManager.getCriteriaBuilder();
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
// get the assigned software modules
final CriteriaQuery<SoftwareModule> assignedQuery = cb.createQuery(SoftwareModule.class);
@@ -529,8 +529,7 @@ public class SoftwareManagement {
// don't page the assigned query on database, we need all assigned
// software modules to filter
// them out in the unassigned query
final List<SoftwareModule> assignedSoftwareModules = this.entityManager.createQuery(assignedQuery)
.getResultList();
final List<SoftwareModule> assignedSoftwareModules = entityManager.createQuery(assignedQuery).getResultList();
// map result
if (pageable.getOffset() < assignedSoftwareModules.size()) {
assignedSoftwareModules
@@ -560,7 +559,7 @@ public class SoftwareManagement {
unassignedQuery.where(unassignedSpec);
unassignedQuery.orderBy(cb.asc(unassignedRoot.get(SoftwareModule_.name)),
cb.asc(unassignedRoot.get(SoftwareModule_.version)));
final List<SoftwareModule> unassignedSoftwareModules = this.entityManager.createQuery(unassignedQuery)
final List<SoftwareModule> unassignedSoftwareModules = entityManager.createQuery(unassignedQuery)
.setFirstResult(Math.max(0, pageable.getOffset() - assignedSoftwareModules.size()))
.setMaxResults(pageSize).getResultList();
// map result
@@ -635,7 +634,7 @@ public class SoftwareManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Page<SoftwareModuleType> findSoftwareModuleTypesAll(@NotNull final Pageable pageable) {
return this.softwareModuleTypeRepository.findByDeleted(pageable, false);
return softwareModuleTypeRepository.findByDeleted(pageable, false);
}
/**
@@ -643,7 +642,7 @@ public class SoftwareManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Long countSoftwareModuleTypesAll() {
return this.softwareModuleTypeRepository.countByDeleted(false);
return softwareModuleTypeRepository.countByDeleted(false);
}
/**
@@ -655,7 +654,7 @@ public class SoftwareManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public SoftwareModuleType findSoftwareModuleTypeByKey(@NotNull final String key) {
return this.softwareModuleTypeRepository.findByKey(key);
return softwareModuleTypeRepository.findByKey(key);
}
/**
@@ -667,7 +666,7 @@ public class SoftwareManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public SoftwareModuleType findSoftwareModuleTypeById(@NotNull final Long id) {
return this.softwareModuleTypeRepository.findOne(id);
return softwareModuleTypeRepository.findOne(id);
}
/**
@@ -679,7 +678,7 @@ public class SoftwareManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public SoftwareModuleType findSoftwareModuleTypeByName(@NotNull final String name) {
return this.softwareModuleTypeRepository.findByName(name);
return softwareModuleTypeRepository.findByName(name);
}
/**
@@ -697,7 +696,7 @@ public class SoftwareManagement {
throw new EntityAlreadyExistsException("Given type contains an Id!");
}
return this.softwareModuleTypeRepository.save(type);
return softwareModuleTypeRepository.save(type);
}
/**
@@ -725,13 +724,13 @@ public class SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
public void deleteSoftwareModuleType(@NotNull final SoftwareModuleType type) {
if (this.softwareModuleRepository.countByType(type) > 0
|| this.distributionSetTypeRepository.countByElementsSmType(type) > 0) {
final SoftwareModuleType toDelete = this.entityManager.merge(type);
if (softwareModuleRepository.countByType(type) > 0
|| distributionSetTypeRepository.countByElementsSmType(type) > 0) {
final SoftwareModuleType toDelete = entityManager.merge(type);
toDelete.setDeleted(true);
this.softwareModuleTypeRepository.save(toDelete);
softwareModuleTypeRepository.save(toDelete);
} else {
this.softwareModuleTypeRepository.delete(type.getId());
softwareModuleTypeRepository.delete(type.getId());
}
}
@@ -746,7 +745,7 @@ public class SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Page<SoftwareModule> findSoftwareModuleByAssignedTo(@NotNull final Pageable pageable,
@NotNull final DistributionSet set) {
return this.softwareModuleRepository.findByAssignedTo(pageable, set);
return softwareModuleRepository.findByAssignedTo(pageable, set);
}
/**
@@ -762,7 +761,7 @@ public class SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Page<SoftwareModule> findSoftwareModuleByAssignedToAndType(@NotNull final Pageable pageable,
@NotNull final DistributionSet set, @NotNull final SoftwareModuleType type) {
return this.softwareModuleRepository.findByAssignedToAndType(pageable, set, type);
return softwareModuleRepository.findByAssignedToAndType(pageable, set, type);
}
/**
@@ -779,15 +778,15 @@ public class SoftwareManagement {
@Modifying
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
public SoftwareModuleMetadata createSoftwareModuleMetadata(@NotNull final SoftwareModuleMetadata metadata) {
if (this.softwareModuleMetadataRepository.exists(metadata.getId())) {
if (softwareModuleMetadataRepository.exists(metadata.getId())) {
throwMetadataKeyAlreadyExists(metadata.getId().getKey());
}
// merge base software module so optLockRevision gets updated and audit
// log written because
// modifying metadata is modifying the base software module itself for
// auditing purposes.
this.entityManager.merge(metadata.getSoftwareModule()).setLastModifiedAt(-1L);
return this.softwareModuleMetadataRepository.save(metadata);
entityManager.merge(metadata.getSoftwareModule()).setLastModifiedAt(-1L);
return softwareModuleMetadataRepository.save(metadata);
}
/**
@@ -808,8 +807,8 @@ public class SoftwareManagement {
for (final SoftwareModuleMetadata softwareModuleMetadata : metadata) {
checkAndThrowAlreadyExistsIfSoftwareModuleMetadataExists(softwareModuleMetadata.getId());
}
metadata.forEach(m -> this.entityManager.merge(m.getSoftwareModule()).setLastModifiedAt(-1L));
return this.softwareModuleMetadataRepository.save(metadata);
metadata.forEach(m -> entityManager.merge(m.getSoftwareModule()).setLastModifiedAt(-1L));
return softwareModuleMetadataRepository.save(metadata);
}
/**
@@ -831,8 +830,8 @@ public class SoftwareManagement {
// touch it to update the lock revision because we are modifying the
// software module
// indirectly
this.entityManager.merge(metadata.getSoftwareModule()).setLastModifiedAt(-1L);
return this.softwareModuleMetadataRepository.save(metadata);
entityManager.merge(metadata.getSoftwareModule()).setLastModifiedAt(-1L);
return softwareModuleMetadataRepository.save(metadata);
}
/**
@@ -845,7 +844,7 @@ public class SoftwareManagement {
@Modifying
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
public void deleteSoftwareModuleMetadata(@NotNull final SwMetadataCompositeKey id) {
this.softwareModuleMetadataRepository.delete(id);
softwareModuleMetadataRepository.delete(id);
}
/**
@@ -861,7 +860,7 @@ public class SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull final Long swId,
@NotNull final Pageable pageable) {
return this.softwareModuleMetadataRepository.findBySoftwareModuleId(swId, pageable);
return softwareModuleMetadataRepository.findBySoftwareModuleId(swId, pageable);
}
/**
@@ -879,7 +878,7 @@ public class SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(final Long softwareModuleId,
@NotNull final Specification<SoftwareModuleMetadata> spec, @NotNull final Pageable pageable) {
return this.softwareModuleMetadataRepository
return softwareModuleMetadataRepository
.findAll(
(Specification<SoftwareModuleMetadata>) (root, query,
cb) -> cb.and(
@@ -901,7 +900,7 @@ public class SoftwareManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public SoftwareModuleMetadata findOne(@NotNull final SwMetadataCompositeKey id) {
final SoftwareModuleMetadata findOne = this.softwareModuleMetadataRepository.findOne(id);
final SoftwareModuleMetadata findOne = softwareModuleMetadataRepository.findOne(id);
if (findOne == null) {
throw new EntityNotFoundException("Metadata with key '" + id.getKey() + "' does not exist");
}
@@ -909,7 +908,7 @@ public class SoftwareManagement {
}
private void checkAndThrowAlreadyExistsIfSoftwareModuleMetadataExists(final SwMetadataCompositeKey metadataId) {
if (this.softwareModuleMetadataRepository.exists(metadataId)) {
if (softwareModuleMetadataRepository.exists(metadataId)) {
throw new EntityAlreadyExistsException(
"Metadata entry with key '" + metadataId.getKey() + "' already exists");
}

View File

@@ -58,10 +58,10 @@ public class TargetFilterQueryManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
public TargetFilterQuery createTargetFilterQuery(@NotNull final TargetFilterQuery customTargetFilter) {
if (this.targetFilterQueryRepository.findByName(customTargetFilter.getName()) != null) {
if (targetFilterQueryRepository.findByName(customTargetFilter.getName()) != null) {
throw new EntityAlreadyExistsException(customTargetFilter.getName());
}
return this.targetFilterQueryRepository.save(customTargetFilter);
return targetFilterQueryRepository.save(customTargetFilter);
}
/**
@@ -74,7 +74,7 @@ public class TargetFilterQueryManagement {
@Transactional
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
public void deleteTargetFilterQuery(@NotNull final Long targetFilterQueryId) {
this.targetFilterQueryRepository.delete(targetFilterQueryId);
targetFilterQueryRepository.delete(targetFilterQueryId);
}
/**
@@ -87,7 +87,7 @@ public class TargetFilterQueryManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public Page<TargetFilterQuery> findAllTargetFilterQuery(@NotNull final Pageable pageable) {
return this.targetFilterQueryRepository.findAll(pageable);
return targetFilterQueryRepository.findAll(pageable);
}
/**
@@ -120,11 +120,11 @@ public class TargetFilterQueryManagement {
private Page<TargetFilterQuery> findTargetFilterQueryByCriteriaAPI(@NotNull final Pageable pageable,
final List<Specification<TargetFilterQuery>> specList) {
if (specList == null || specList.isEmpty()) {
return this.targetFilterQueryRepository.findAll(pageable);
return targetFilterQueryRepository.findAll(pageable);
}
final Specifications<TargetFilterQuery> specs = SpecificationsBuilder.combineWithAnd(specList);
return this.targetFilterQueryRepository.findAll(specs, pageable);
return targetFilterQueryRepository.findAll(specs, pageable);
}
/**
@@ -137,7 +137,7 @@ public class TargetFilterQueryManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public TargetFilterQuery findTargetFilterQueryByName(@NotNull final String targetFilterQueryName) {
return this.targetFilterQueryRepository.findByName(targetFilterQueryName);
return targetFilterQueryRepository.findByName(targetFilterQueryName);
}
/**
@@ -150,7 +150,7 @@ public class TargetFilterQueryManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public TargetFilterQuery findTargetFilterQueryById(@NotNull final Long targetFilterQueryId) {
return this.targetFilterQueryRepository.findOne(targetFilterQueryId);
return targetFilterQueryRepository.findOne(targetFilterQueryId);
}
/**
@@ -166,7 +166,7 @@ public class TargetFilterQueryManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
public TargetFilterQuery updateTargetFilterQuery(@NotNull final TargetFilterQuery targetFilterQuery) {
Assert.notNull(targetFilterQuery.getId());
return this.targetFilterQueryRepository.save(targetFilterQuery);
return targetFilterQueryRepository.save(targetFilterQuery);
}
}

View File

@@ -114,7 +114,7 @@ public class TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public Target findTargetByControllerID(@NotEmpty final String controllerId) {
return this.targetRepository.findByControllerId(controllerId);
return targetRepository.findByControllerId(controllerId);
}
/**
@@ -131,7 +131,7 @@ public class TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public Target findTargetByControllerIDWithDetails(@NotEmpty final String controllerId) {
final Target result = this.targetRepository.findByControllerId(controllerId);
final Target result = targetRepository.findByControllerId(controllerId);
// load lazy relations
if (result != null) {
result.getTargetInfo().getControllerAttributes().size();
@@ -158,8 +158,7 @@ public class TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public List<Target> findTargetsByControllerID(@NotEmpty final Collection<String> controllerIDs) {
return this.targetRepository
.findAll(TargetSpecifications.byControllerIdWithStatusAndAssignedInJoin(controllerIDs));
return targetRepository.findAll(TargetSpecifications.byControllerIdWithStatusAndAssignedInJoin(controllerIDs));
}
/**
@@ -169,7 +168,7 @@ public class TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public Long countTargetsAll() {
return this.targetRepository.count();
return targetRepository.count();
}
/**
@@ -191,7 +190,7 @@ public class TargetManagement {
}
return cb.conjunction();
};
return this.criteriaNoCountDao.findAll(spec, pageable, Target.class);
return criteriaNoCountDao.findAll(spec, pageable, Target.class);
}
/**
@@ -234,7 +233,7 @@ public class TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public Page<Target> findTargetsAll(@NotNull final Specification<Target> spec, @NotNull final Pageable pageable) {
return this.targetRepository.findAll(spec, pageable);
return targetRepository.findAll(spec, pageable);
}
/**
@@ -252,8 +251,7 @@ public class TargetManagement {
public List<Target> findTargetsByControllerIDsWithTags(@NotNull final List<String> controllerIDs) {
final List<List<String>> partition = Lists.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT);
return partition.stream()
.map(ids -> this.targetRepository
.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(ids)))
.map(ids -> targetRepository.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(ids)))
.flatMap(t -> t.stream()).collect(Collectors.toList());
}
@@ -272,7 +270,7 @@ public class TargetManagement {
public Target updateTarget(@NotNull final Target target) {
Assert.notNull(target.getId());
target.setNew(false);
return this.targetRepository.save(target);
return targetRepository.save(target);
}
/**
@@ -289,7 +287,7 @@ public class TargetManagement {
+ SpringEvalExpressions.IS_CONTROLLER)
public List<Target> updateTargets(@NotNull final List<Target> targets) {
targets.forEach(target -> target.setNew(false));
return this.targetRepository.save(targets);
return targetRepository.save(targets);
}
/**
@@ -307,11 +305,11 @@ public class TargetManagement {
// tenant! Delete statement are not automatically enhanced with the
// @FilterDef of the
// hibernate session.
final List<Long> targetsForCurrentTenant = this.targetRepository.findAll(Lists.newArrayList(targetIDs)).stream()
final List<Long> targetsForCurrentTenant = targetRepository.findAll(Lists.newArrayList(targetIDs)).stream()
.map(Target::getId).collect(Collectors.toList());
if (!targetsForCurrentTenant.isEmpty()) {
this.targetInfoRepository.deleteByTargetIdIn(targetsForCurrentTenant);
this.targetRepository.deleteByIdIn(targetsForCurrentTenant);
targetInfoRepository.deleteByTargetIdIn(targetsForCurrentTenant);
targetRepository.deleteByIdIn(targetsForCurrentTenant);
}
}
@@ -331,7 +329,7 @@ public class TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
public Page<Target> findTargetByAssignedDistributionSet(@NotNull final Long distributionSetID,
@NotNull final Pageable pageReq) {
return this.targetRepository.findByAssignedDistributionSetId(pageReq, distributionSetID);
return targetRepository.findByAssignedDistributionSetId(pageReq, distributionSetID);
}
/**
@@ -352,7 +350,7 @@ public class TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
public Page<Target> findTargetByAssignedDistributionSet(@NotNull final Long distributionSetID,
final Specification<Target> spec, @NotNull final Pageable pageReq) {
return this.targetRepository.findAll((Specification<Target>) (root, query, cb) -> cb.and(
return targetRepository.findAll((Specification<Target>) (root, query, cb) -> cb.and(
TargetSpecifications.hasAssignedDistributionSet(distributionSetID).toPredicate(root, query, cb),
spec.toPredicate(root, query, cb)), pageReq);
}
@@ -372,7 +370,7 @@ public class TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
public Page<Target> findTargetByInstalledDistributionSet(@NotNull final Long distributionSetID,
@NotNull final Pageable pageReq) {
return this.targetRepository.findByTargetInfoInstalledDistributionSetId(pageReq, distributionSetID);
return targetRepository.findByTargetInfoInstalledDistributionSetId(pageReq, distributionSetID);
}
/**
@@ -391,7 +389,7 @@ public class TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
public Page<Target> findTargetByInstalledDistributionSet(final Long distributionSetId,
final Specification<Target> spec, final Pageable pageable) {
return this.targetRepository.findAll((Specification<Target>) (root, query, cb) -> cb.and(
return targetRepository.findAll((Specification<Target>) (root, query, cb) -> cb.and(
TargetSpecifications.hasInstalledDistributionSet(distributionSetId).toPredicate(root, query, cb),
spec.toPredicate(root, query, cb)), pageable);
}
@@ -411,7 +409,7 @@ public class TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public Page<Target> findTargetByUpdateStatus(@NotNull final Pageable pageable,
@NotNull final TargetUpdateStatus status) {
return this.targetRepository.findByTargetInfoUpdateStatus(pageable, status);
return targetRepository.findByTargetInfoUpdateStatus(pageable, status);
}
/**
@@ -511,17 +509,17 @@ public class TargetManagement {
*/
private Slice<Target> findByCriteriaAPI(final Pageable pageable, final List<Specification<Target>> specList) {
if (specList == null || specList.isEmpty()) {
return this.criteriaNoCountDao.findAll(pageable, Target.class);
return criteriaNoCountDao.findAll(pageable, Target.class);
}
return this.criteriaNoCountDao.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable, Target.class);
return criteriaNoCountDao.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable, Target.class);
}
private Long countByCriteriaAPI(final List<Specification<Target>> specList) {
if (specList == null || specList.isEmpty()) {
return this.targetRepository.count();
return targetRepository.count();
}
return this.targetRepository.count(SpecificationsBuilder.combineWithAnd(specList));
return targetRepository.count(SpecificationsBuilder.combineWithAnd(specList));
}
/**
@@ -562,10 +560,9 @@ public class TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
public TargetTagAssigmentResult toggleTagAssignment(@NotEmpty final Collection<String> targetIds,
@NotNull final String tagName) {
final TargetTag tag = this.targetTagRepository.findByNameEquals(tagName);
final List<Target> alreadyAssignedTargets = this.targetRepository.findByTagNameAndControllerIdIn(tagName,
targetIds);
final List<Target> allTargets = this.targetRepository
final TargetTag tag = targetTagRepository.findByNameEquals(tagName);
final List<Target> alreadyAssignedTargets = targetRepository.findByTagNameAndControllerIdIn(tagName, targetIds);
final List<Target> allTargets = targetRepository
.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(targetIds));
// all are already assigned -> unassign
@@ -574,7 +571,7 @@ public class TargetManagement {
final TargetTagAssigmentResult result = new TargetTagAssigmentResult(0, 0, alreadyAssignedTargets.size(),
Collections.emptyList(), alreadyAssignedTargets, tag);
this.afterCommit.afterCommit(() -> this.eventBus.post(new TargetTagAssigmentResultEvent(result)));
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
return result;
}
@@ -582,12 +579,12 @@ public class TargetManagement {
// some or none are assigned -> assign
allTargets.forEach(target -> target.getTags().add(tag));
final TargetTagAssigmentResult result = new TargetTagAssigmentResult(alreadyAssignedTargets.size(),
allTargets.size(), 0, this.targetRepository.save(allTargets), Collections.emptyList(), tag);
allTargets.size(), 0, targetRepository.save(allTargets), Collections.emptyList(), tag);
this.afterCommit.afterCommit(() -> this.eventBus.post(new TargetTagAssigmentResultEvent(result)));
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
// no reason to persist the tag
this.entityManager.detach(tag);
entityManager.detach(tag);
return result;
}
@@ -605,16 +602,16 @@ public class TargetManagement {
@NotNull
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
public List<Target> assignTag(@NotEmpty final Collection<String> targetIds, @NotNull final TargetTag tag) {
final List<Target> allTargets = this.targetRepository
final List<Target> allTargets = targetRepository
.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(targetIds));
allTargets.forEach(target -> target.getTags().add(tag));
final List<Target> save = this.targetRepository.save(allTargets);
final List<Target> save = targetRepository.save(allTargets);
this.afterCommit.afterCommit(() -> {
afterCommit.afterCommit(() -> {
final TargetTagAssigmentResult assigmentResult = new TargetTagAssigmentResult(0, save.size(), 0, save,
Collections.emptyList(), tag);
this.eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
});
return save;
@@ -623,11 +620,11 @@ public class TargetManagement {
private List<Target> unAssignTag(@NotEmpty final Collection<Target> targets, @NotNull final TargetTag tag) {
targets.forEach(target -> target.getTags().remove(tag));
final List<Target> save = this.targetRepository.save(targets);
this.afterCommit.afterCommit(() -> {
final List<Target> save = targetRepository.save(targets);
afterCommit.afterCommit(() -> {
final TargetTagAssigmentResult assigmentResult = new TargetTagAssigmentResult(0, 0, save.size(),
Collections.emptyList(), save, tag);
this.eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
});
return save;
}
@@ -660,7 +657,7 @@ public class TargetManagement {
@Transactional
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
public Target unAssignTag(@NotNull final String controllerID, @NotNull final TargetTag targetTag) {
final List<Target> allTargets = this.targetRepository
final List<Target> allTargets = targetRepository
.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(Arrays.asList(controllerID)));
final List<Target> unAssignTag = unAssignTag(allTargets, targetTag);
return unAssignTag.isEmpty() ? null : unAssignTag.get(0);
@@ -711,7 +708,7 @@ public class TargetManagement {
@NotNull final Long orderByDistributionId, final Long filterByDistributionId,
final Collection<TargetUpdateStatus> filterByStatus, final String filterBySearchText,
final Boolean selectTargetWithNoTag, final String... filterByTagNames) {
final CriteriaBuilder cb = this.entityManager.getCriteriaBuilder();
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
final CriteriaQuery<Target> query = cb.createQuery(Target.class);
final Root<Target> targetRoot = query.from(Target.class);
@@ -753,7 +750,7 @@ public class TargetManagement {
// multiselect order) of the array and
// the 2nd contains the selectCase int value.
final int pageSize = pageable.getPageSize();
final List<Target> resultList = this.entityManager.createQuery(query).setFirstResult(pageable.getOffset())
final List<Target> resultList = entityManager.createQuery(query).setFirstResult(pageable.getOffset())
.setMaxResults(pageSize + 1).getResultList();
final boolean hasNext = resultList.size() > pageSize;
return new SliceImpl<>(resultList, pageable, hasNext);
@@ -782,7 +779,7 @@ public class TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public Long countTargetByAssignedDistributionSet(final Long distId) {
return this.targetRepository.countByAssignedDistributionSetId(distId);
return targetRepository.countByAssignedDistributionSetId(distId);
}
/**
@@ -795,7 +792,7 @@ public class TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public Long countTargetByInstalledDistributionSet(final Long distId) {
return this.targetRepository.countByTargetInfoInstalledDistributionSetId(distId);
return targetRepository.countByTargetInfoInstalledDistributionSetId(distId);
}
/**
@@ -806,10 +803,10 @@ public class TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public List<TargetIdName> findAllTargetIds() {
final CriteriaBuilder cb = this.entityManager.getCriteriaBuilder();
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
final CriteriaQuery<TargetIdName> query = cb.createQuery(TargetIdName.class);
final Root<Target> targetRoot = query.from(Target.class);
return this.entityManager.createQuery(query.multiselect(targetRoot.get(Target_.id),
return entityManager.createQuery(query.multiselect(targetRoot.get(Target_.id),
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name))).getResultList();
}
@@ -842,7 +839,7 @@ public class TargetManagement {
public List<TargetIdName> findAllTargetIdsByFilters(final PageRequest pageRequest,
final Long filterByDistributionId, final Collection<TargetUpdateStatus> filterByStatus,
final String filterBySearchText, final Boolean selectTargetWithNoTag, final String... filterByTagNames) {
final CriteriaBuilder cb = this.entityManager.getCriteriaBuilder();
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
final Root<Target> targetRoot = query.from(Target.class);
List<Object[]> resultList;
@@ -879,7 +876,7 @@ public class TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public List<TargetIdName> findAllTargetIdsByTargetFilterQuery(final PageRequest pageRequest,
@NotNull final TargetFilterQuery targetFilterQuery) {
final CriteriaBuilder cb = this.entityManager.getCriteriaBuilder();
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
final Root<Target> targetRoot = query.from(Target.class);
final CriteriaQuery<Object[]> multiselect = query.multiselect(targetRoot.get(Target_.id),
@@ -905,7 +902,7 @@ public class TargetManagement {
@PreDestroy
void destroy() {
this.eventBus.unregister(this);
eventBus.unregister(this);
}
/**
@@ -934,12 +931,12 @@ public class TargetManagement {
public Target createTarget(@NotNull final Target target, @NotNull final TargetUpdateStatus status,
final Long lastTargetQuery, final URI address) {
if (this.targetRepository.findByControllerId(target.getControllerId()) != null) {
if (targetRepository.findByControllerId(target.getControllerId()) != null) {
throw new EntityAlreadyExistsException(target.getControllerId());
}
target.setNew(true);
final Target savedTarget = this.targetRepository.save(target);
final Target savedTarget = targetRepository.save(target);
final TargetInfo targetInfo = savedTarget.getTargetInfo();
targetInfo.setUpdateStatus(status);
if (lastTargetQuery != null) {
@@ -949,7 +946,7 @@ public class TargetManagement {
targetInfo.setAddress(address.toString());
}
targetInfo.setNew(true);
final Target targetToReturn = this.targetInfoRepository.save(targetInfo).getTarget();
final Target targetToReturn = targetInfoRepository.save(targetInfo).getTarget();
targetInfo.setNew(false);
return targetToReturn;
@@ -992,7 +989,7 @@ public class TargetManagement {
@NotNull
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
public List<Target> createTargets(@NotNull final List<Target> targets) {
if (!targets.isEmpty() && this.targetRepository.countByControllerIdIn(
if (!targets.isEmpty() && targetRepository.countByControllerIdIn(
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList())) > 0) {
throw new EntityAlreadyExistsException();
}
@@ -1025,7 +1022,7 @@ public class TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
public List<Target> createTargets(@NotNull final Collection<Target> targets,
@NotNull final TargetUpdateStatus status, final long lastTargetQuery, final URI address) {
if (this.targetRepository.countByControllerIdIn(
if (targetRepository.countByControllerIdIn(
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList())) > 0) {
throw new EntityAlreadyExistsException();
}
@@ -1047,8 +1044,8 @@ public class TargetManagement {
@NotNull
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public List<Target> findTargetsByTag(@NotNull final String tagName) {
final TargetTag tag = this.targetTagRepository.findByNameEquals(tagName);
return this.targetRepository.findByTag(tag);
final TargetTag tag = targetTagRepository.findByNameEquals(tagName);
return targetRepository.findByTag(tag);
}
/**
@@ -1061,7 +1058,7 @@ public class TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public Long countTargetByTargetFilterQuery(@NotNull final TargetFilterQuery targetFilterQuery) {
final Specification<Target> specs = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class);
return this.targetRepository.count(specs);
return targetRepository.count(specs);
}
/**
@@ -1074,7 +1071,7 @@ public class TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public Long countTargetByTargetFilterQuery(@NotNull final String targetFilterQuery) {
final Specification<Target> specs = RSQLUtility.parse(targetFilterQuery, TargetFields.class);
return this.targetRepository.count(specs);
return targetRepository.count(specs);
}
private List<Object[]> getTargetIdNameResultSet(final PageRequest pageRequest, final CriteriaBuilder cb,
@@ -1091,10 +1088,10 @@ public class TargetManagement {
}
}
multiselect.orderBy(orders);
resultList = this.entityManager.createQuery(multiselect).setFirstResult(pageRequest.getOffset())
resultList = entityManager.createQuery(multiselect).setFirstResult(pageRequest.getOffset())
.setMaxResults(pageRequest.getPageSize()).getResultList();
} else {
resultList = this.entityManager.createQuery(multiselect).getResultList();
resultList = entityManager.createQuery(multiselect).getResultList();
}
return resultList;
}

View File

@@ -83,7 +83,7 @@ public class Rollout extends NamedEntity {
* @return the distributionSet
*/
public DistributionSet getDistributionSet() {
return this.distributionSet;
return distributionSet;
}
/**
@@ -98,7 +98,7 @@ public class Rollout extends NamedEntity {
* @return the rolloutGroups
*/
public List<RolloutGroup> getRolloutGroups() {
return this.rolloutGroups;
return rolloutGroups;
}
/**
@@ -113,7 +113,7 @@ public class Rollout extends NamedEntity {
* @return the targetFilterQuery
*/
public String getTargetFilterQuery() {
return this.targetFilterQuery;
return targetFilterQuery;
}
/**
@@ -128,7 +128,7 @@ public class Rollout extends NamedEntity {
* @return the status
*/
public RolloutStatus getStatus() {
return this.status;
return status;
}
/**
@@ -143,7 +143,7 @@ public class Rollout extends NamedEntity {
* @return the lastCheck
*/
public long getLastCheck() {
return this.lastCheck;
return lastCheck;
}
/**
@@ -158,7 +158,7 @@ public class Rollout extends NamedEntity {
* @return the actionType
*/
public ActionType getActionType() {
return this.actionType;
return actionType;
}
/**
@@ -173,7 +173,7 @@ public class Rollout extends NamedEntity {
* @return the forcedTime
*/
public long getForcedTime() {
return this.forcedTime;
return forcedTime;
}
/**
@@ -188,7 +188,7 @@ public class Rollout extends NamedEntity {
* @return the totalTargets
*/
public long getTotalTargets() {
return this.totalTargets;
return totalTargets;
}
/**
@@ -203,7 +203,7 @@ public class Rollout extends NamedEntity {
* @return the rolloutGroupsTotal
*/
public int getRolloutGroupsTotal() {
return this.rolloutGroupsTotal;
return rolloutGroupsTotal;
}
/**
@@ -218,7 +218,7 @@ public class Rollout extends NamedEntity {
* @return the rolloutGroupsCreated
*/
public int getRolloutGroupsCreated() {
return this.rolloutGroupsCreated;
return rolloutGroupsCreated;
}
/**
@@ -233,10 +233,10 @@ public class Rollout extends NamedEntity {
* @return the totalTargetCountStatus
*/
public TotalTargetCountStatus getTotalTargetCountStatus() {
if (this.totalTargetCountStatus == null) {
this.totalTargetCountStatus = new TotalTargetCountStatus(this.totalTargets);
if (totalTargetCountStatus == null) {
totalTargetCountStatus = new TotalTargetCountStatus(totalTargets);
}
return this.totalTargetCountStatus;
return totalTargetCountStatus;
}
/**
@@ -249,9 +249,9 @@ public class Rollout extends NamedEntity {
@Override
public String toString() {
return "Rollout [rolloutGroups=" + this.rolloutGroups + ", targetFilterQuery=" + this.targetFilterQuery
+ ", distributionSet=" + this.distributionSet + ", status=" + this.status + ", lastCheck="
+ this.lastCheck + ", getName()=" + getName() + ", getId()=" + getId() + "]";
return "Rollout [rolloutGroups=" + rolloutGroups + ", targetFilterQuery=" + targetFilterQuery
+ ", distributionSet=" + distributionSet + ", status=" + status + ", lastCheck=" + lastCheck
+ ", getName()=" + getName() + ", getId()=" + getId() + "]";
}
/**

View File

@@ -27,7 +27,7 @@ import javax.persistence.UniqueConstraint;
/**
* JPA entity definition of persisting a group of an rollout.
*
*
* @author Michael Hirsch
*
*/
@@ -116,7 +116,7 @@ public class RolloutGroup extends NamedEntity {
}
public void setSuccessCondition(final RolloutGroupSuccessCondition finishCondition) {
this.successCondition = finishCondition;
successCondition = finishCondition;
}
public String getSuccessConditionExp() {
@@ -124,7 +124,7 @@ public class RolloutGroup extends NamedEntity {
}
public void setSuccessConditionExp(final String finishExp) {
this.successConditionExp = finishExp;
successConditionExp = finishExp;
}
public RolloutGroupErrorCondition getErrorCondition() {
@@ -140,7 +140,7 @@ public class RolloutGroup extends NamedEntity {
}
public void setErrorConditionExp(final String errorExp) {
this.errorConditionExp = errorExp;
errorConditionExp = errorExp;
}
public RolloutGroupErrorAction getErrorAction() {
@@ -188,7 +188,7 @@ public class RolloutGroup extends NamedEntity {
*/
public TotalTargetCountStatus getTotalTargetCountStatus() {
if (totalTargetCountStatus == null) {
this.totalTargetCountStatus = new TotalTargetCountStatus(totalTargets);
totalTargetCountStatus = new TotalTargetCountStatus(totalTargets);
}
return totalTargetCountStatus;
}
@@ -210,7 +210,7 @@ public class RolloutGroup extends NamedEntity {
}
/**
*
*
* @author Michael Hirsch
*
*/
@@ -343,7 +343,7 @@ public class RolloutGroup extends NamedEntity {
}
public void setSuccessCondition(final RolloutGroupSuccessCondition finishCondition) {
this.successCondition = finishCondition;
successCondition = finishCondition;
}
public String getSuccessConditionExp() {
@@ -351,7 +351,7 @@ public class RolloutGroup extends NamedEntity {
}
public void setSuccessConditionExp(final String finishConditionExp) {
this.successConditionExp = finishConditionExp;
successConditionExp = finishConditionExp;
}
public RolloutGroupSuccessAction getSuccessAction() {
@@ -416,7 +416,7 @@ public class RolloutGroup extends NamedEntity {
/**
* Sets the finish condition and expression on the builder.
*
*
* @param condition
* the finish condition
* @param expression
@@ -432,7 +432,7 @@ public class RolloutGroup extends NamedEntity {
/**
* Sets the success action and expression on the builder.
*
*
* @param action
* the success action
* @param expression
@@ -448,7 +448,7 @@ public class RolloutGroup extends NamedEntity {
/**
* Sets the error condition and expression on the builder.
*
*
* @param condition
* the error condition
* @param expression
@@ -464,7 +464,7 @@ public class RolloutGroup extends NamedEntity {
/**
* Sets the error action and expression on the builder.
*
*
* @param action
* the error action
* @param expression

View File

@@ -63,6 +63,6 @@ public class RolloutTargetGroup implements Serializable {
}
public RolloutTargetGroupId getId() {
return new RolloutTargetGroupId(this.rolloutGroup, this.target);
return new RolloutTargetGroupId(rolloutGroup, target);
}
}

View File

@@ -60,7 +60,7 @@ public class TotalTargetCountStatus {
* @return the statusTotalCountMap the state map
*/
public Map<Status, Long> getStatusTotalCountMap() {
return this.statusTotalCountMap;
return statusTotalCountMap;
}
/**
@@ -71,7 +71,7 @@ public class TotalTargetCountStatus {
* @return the current target count cannot be <null>
*/
public Long getTotalTargetCountByStatus(final Status status) {
final Long count = this.statusTotalCountMap.get(status);
final Long count = statusTotalCountMap.get(status);
return count == null ? 0L : count;
}
@@ -87,39 +87,39 @@ public class TotalTargetCountStatus {
private final void mapActionStatusToTotalTargetCountStatus(
final List<TotalTargetCountActionStatus> targetCountActionStatus) {
if (targetCountActionStatus == null) {
this.statusTotalCountMap.put(TotalTargetCountStatus.Status.NOTSTARTED, this.totalTargetCount);
statusTotalCountMap.put(TotalTargetCountStatus.Status.NOTSTARTED, totalTargetCount);
return;
}
this.statusTotalCountMap.put(Status.RUNNING, 0L);
Long notStartedTargetCount = this.totalTargetCount;
statusTotalCountMap.put(Status.RUNNING, 0L);
Long notStartedTargetCount = totalTargetCount;
for (final TotalTargetCountActionStatus item : targetCountActionStatus) {
switch (item.getStatus()) {
case SCHEDULED:
this.statusTotalCountMap.put(Status.SCHEDULED, item.getCount());
statusTotalCountMap.put(Status.SCHEDULED, item.getCount());
break;
case ERROR:
this.statusTotalCountMap.put(Status.ERROR, item.getCount());
statusTotalCountMap.put(Status.ERROR, item.getCount());
break;
case FINISHED:
this.statusTotalCountMap.put(Status.FINISHED, item.getCount());
statusTotalCountMap.put(Status.FINISHED, item.getCount());
break;
case RETRIEVED:
case RUNNING:
case WARNING:
case DOWNLOAD:
case CANCELING:
final Long runningItemsCount = this.statusTotalCountMap.get(Status.RUNNING) + item.getCount();
this.statusTotalCountMap.put(Status.RUNNING, runningItemsCount);
final Long runningItemsCount = statusTotalCountMap.get(Status.RUNNING) + item.getCount();
statusTotalCountMap.put(Status.RUNNING, runningItemsCount);
break;
case CANCELED:
this.statusTotalCountMap.put(Status.CANCELLED, item.getCount());
statusTotalCountMap.put(Status.CANCELLED, item.getCount());
break;
default:
throw new IllegalArgumentException("State " + item.getStatus() + "is not valid");
}
notStartedTargetCount -= item.getCount();
}
this.statusTotalCountMap.put(TotalTargetCountStatus.Status.NOTSTARTED, notStartedTargetCount);
statusTotalCountMap.put(TotalTargetCountStatus.Status.NOTSTARTED, notStartedTargetCount);
}
}

View File

@@ -30,8 +30,8 @@ public class ThresholdRolloutGroupErrorCondition implements RolloutGroupConditio
@Override
public boolean eval(final Rollout rollout, final RolloutGroup rolloutGroup, final String expression) {
final Long totalGroup = this.actionRepository.countByRolloutAndRolloutGroup(rollout, rolloutGroup);
final Long error = this.actionRepository.countByRolloutIdAndRolloutGroupIdAndStatus(rollout.getId(),
final Long totalGroup = actionRepository.countByRolloutAndRolloutGroup(rollout, rolloutGroup);
final Long error = actionRepository.countByRolloutIdAndRolloutGroupIdAndStatus(rollout.getId(),
rolloutGroup.getId(), Action.Status.ERROR);
try {
final Integer threshold = Integer.valueOf(expression);