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

@@ -61,41 +61,41 @@ public class DDISimulatedDevice extends AbstractSimulatedDevice {
@Override
public void clean() {
super.clean();
this.removed = true;
removed = true;
}
public int getPollDelaySec() {
return this.pollDelaySec;
return pollDelaySec;
}
/**
* Polls the base URL for the DDI API interface.
*/
public void poll() {
if (!this.removed) {
final String basePollJson = this.controllerResource.get(getTenant(), getId());
if (!removed) {
final String basePollJson = controllerResource.get(getTenant(), getId());
try {
final String href = JsonPath.parse(basePollJson).read("_links.deploymentBase.href");
final long actionId = Long.parseLong(href.substring(href.lastIndexOf("/") + 1, href.indexOf("?")));
if (this.currentActionId == null) {
final String deploymentJson = this.controllerResource.getDeployment(getTenant(), getId(), actionId);
if (currentActionId == null) {
final String deploymentJson = controllerResource.getDeployment(getTenant(), getId(), actionId);
final String swVersion = JsonPath.parse(deploymentJson).read("deployment.chunks[0].version");
this.currentActionId = actionId;
this.deviceUpdater.startUpdate(getTenant(), getId(), actionId, swVersion, (device, actionId1) -> {
currentActionId = actionId;
deviceUpdater.startUpdate(getTenant(), getId(), actionId, swVersion, (device, actionId1) -> {
switch (device.getResponseStatus()) {
case SUCCESSFUL:
DDISimulatedDevice.this.controllerResource.postSuccessFeedback(getTenant(), getId(),
controllerResource.postSuccessFeedback(getTenant(), getId(),
actionId1);
break;
case ERROR:
DDISimulatedDevice.this.controllerResource.postErrorFeedback(getTenant(), getId(),
controllerResource.postErrorFeedback(getTenant(), getId(),
actionId1);
break;
default:
throw new IllegalStateException(
"simulated device has an unknown response status + " + device.getResponseStatus());
}
DDISimulatedDevice.this.currentActionId = null;
currentActionId = null;
});
}
} catch (final PathNotFoundException e) {

View File

@@ -58,13 +58,12 @@ public class DeviceSimulatorUpdater {
*/
public void startUpdate(final String tenant, final String id, final long actionId, final String swVersion,
final UpdaterCallback callback) {
final AbstractSimulatedDevice device = this.repository.get(tenant, id);
final AbstractSimulatedDevice device = repository.get(tenant, id);
device.setProgress(0.0);
device.setSwversion(swVersion);
this.eventbus.post(new InitUpdate(device));
threadPool.schedule(
new DeviceSimulatorUpdateThread(device, this.spSenderService, actionId, this.eventbus, callback), 2000,
TimeUnit.MILLISECONDS);
eventbus.post(new InitUpdate(device));
threadPool.schedule(new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus, callback),
2000, TimeUnit.MILLISECONDS);
}
private static final class DeviceSimulatorUpdateThread implements Runnable {
@@ -87,15 +86,16 @@ public class DeviceSimulatorUpdater {
@Override
public void run() {
final double newProgress = this.device.getProgress() + 0.2;
this.device.setProgress(newProgress);
final double newProgress = device.getProgress() + 0.2;
device.setProgress(newProgress);
if (newProgress < 1.0) {
threadPool.schedule(new DeviceSimulatorUpdateThread(this.device, this.spSenderService, this.actionId,
this.eventbus, this.callback), rndSleep.nextInt(3000), TimeUnit.MILLISECONDS);
threadPool.schedule(
new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus, callback),
rndSleep.nextInt(3000), TimeUnit.MILLISECONDS);
} else {
this.callback.updateFinished(this.device, this.actionId);
callback.updateFinished(device, actionId);
}
this.eventbus.post(new ProgressUpdate(this.device));
eventbus.post(new ProgressUpdate(device));
}
}

View File

@@ -54,7 +54,7 @@ public class NextPollTimeController {
private class NextPollUpdaterRunnable implements Runnable {
@Override
public void run() {
final List<AbstractSimulatedDevice> devices = NextPollTimeController.this.repository.getAll().stream()
final List<AbstractSimulatedDevice> devices = repository.getAll().stream()
.filter(device -> device instanceof DDISimulatedDevice).collect(Collectors.toList());
devices.forEach(device -> {
@@ -71,7 +71,7 @@ public class NextPollTimeController {
}
device.setNextPollCounterSec(nextCounter);
});
NextPollTimeController.this.eventBus.post(new NextPollCounterUpdate(devices));
eventBus.post(new NextPollCounterUpdate(devices));
}
}
}

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);

View File

@@ -120,7 +120,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
final SecurityContext oldContext = SecurityContextHolder.getContext();
try {
access(new DispatcherRunnable(this.eventBus, session, userContext, event));
access(new DispatcherRunnable(eventBus, session, userContext, event));
} finally {
SecurityContextHolder.setContext(oldContext);
}
@@ -156,7 +156,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
protected void init(final VaadinRequest vaadinRequest) {
LOG.info("ManagementUI init starts uiid - {}", getUI().getUIId());
addDetachListener(this);
SpringContextHelper.setContext(this.context);
SpringContextHelper.setContext(context);
Responsive.makeResponsive(this);
addStyleName(ValoTheme.UI_WITH_MENU);
@@ -165,25 +165,25 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
final HorizontalLayout rootLayout = new HorizontalLayout();
rootLayout.setSizeFull();
this.dashboardMenu.init();
this.dashboardMenu.setResponsive(Boolean.TRUE);
dashboardMenu.init();
dashboardMenu.setResponsive(Boolean.TRUE);
final VerticalLayout contentVerticalLayout = new VerticalLayout();
contentVerticalLayout.addComponent(buildHeader());
contentVerticalLayout.setSizeFull();
rootLayout.addComponent(this.dashboardMenu);
rootLayout.addComponent(dashboardMenu);
rootLayout.addComponent(contentVerticalLayout);
this.content = new HorizontalLayout();
contentVerticalLayout.addComponent(this.content);
this.content.setStyleName("view-content");
this.content.setSizeFull();
content = new HorizontalLayout();
contentVerticalLayout.addComponent(content);
content.setStyleName("view-content");
content.setSizeFull();
rootLayout.setExpandRatio(contentVerticalLayout, 1.0f);
contentVerticalLayout.setStyleName("main-content");
contentVerticalLayout.setExpandRatio(this.content, 1.0F);
contentVerticalLayout.setExpandRatio(content, 1.0F);
setContent(rootLayout);
final Resource resource = this.context
final Resource resource = context
.getResource("classpath:/VAADIN/themes/" + UI.getCurrent().getTheme() + "/layouts/footer.html");
try {
final CustomLayout customLayout = new CustomLayout(resource.getInputStream());
@@ -192,7 +192,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
} catch (final IOException ex) {
LOG.error("Footer file is missing", ex);
}
final Navigator navigator = new Navigator(this, this.content);
final Navigator navigator = new Navigator(this, content);
navigator.addViewChangeListener(new ViewChangeListener() {
@Override
public boolean beforeViewChange(final ViewChangeEvent event) {
@@ -201,17 +201,17 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
@Override
public void afterViewChange(final ViewChangeEvent event) {
final DashboardMenuItem view = HawkbitUI.this.dashboardMenu.getByViewName(event.getViewName());
HawkbitUI.this.dashboardMenu.postViewChange(new PostViewChangeEvent(view));
final DashboardMenuItem view = dashboardMenu.getByViewName(event.getViewName());
dashboardMenu.postViewChange(new PostViewChangeEvent(view));
if (view == null) {
HawkbitUI.this.content.setCaption(null);
content.setCaption(null);
return;
}
HawkbitUI.this.content.setCaption(view.getDashboardCaptionLong());
content.setCaption(view.getDashboardCaptionLong());
}
});
navigator.setErrorView(this.errorview);
navigator.setErrorView(errorview);
navigator.addProvider(new ManagementViewProvider());
setNavigator(navigator);
navigator.addView(EMPTY_VIEW, new Navigator.EmptyView());
@@ -221,7 +221,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
setLocale(new Locale(locale));
UI.getCurrent().setErrorHandler(new SPUIErrorHandler());
LOG.info("Current locale of the application is : {}", this.i18n.getLocale());
LOG.info("Current locale of the application is : {}", i18n.getLocale());
}
private Component buildHeader() {
@@ -276,20 +276,20 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
@Override
public String getViewName(final String viewAndParameters) {
return HawkbitUI.this.viewProvider.getViewName(getStartView(viewAndParameters));
return viewProvider.getViewName(getStartView(viewAndParameters));
}
@Override
public View getView(final String viewName) {
return HawkbitUI.this.viewProvider.getView(getStartView(viewName));
return viewProvider.getView(getStartView(viewName));
}
private String getStartView(final String viewName) {
final DashboardMenuItem view = HawkbitUI.this.dashboardMenu.getByViewName(viewName);
if ("".equals(viewName) && !HawkbitUI.this.dashboardMenu.isAccessibleViewsEmpty()) {
return HawkbitUI.this.dashboardMenu.getInitialViewName();
final DashboardMenuItem view = dashboardMenu.getByViewName(viewName);
if ("".equals(viewName) && !dashboardMenu.isAccessibleViewsEmpty()) {
return dashboardMenu.getInitialViewName();
}
if (view == null || HawkbitUI.this.dashboardMenu.isAccessDenied(viewName)) {
if (view == null || dashboardMenu.isAccessDenied(viewName)) {
return " ";
}
return viewName;

View File

@@ -91,11 +91,11 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
@Override
protected Map<String, ConfirmationTab> getConfimrationTabs() {
final Map<String, ConfirmationTab> tabs = new HashMap<>();
if (!this.artifactUploadState.getDeleteSofwareModules().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
if (!artifactUploadState.getDeleteSofwareModules().isEmpty()) {
tabs.put(i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
}
if (!this.artifactUploadState.getSelectedDeleteSWModuleTypes().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab());
if (!artifactUploadState.getSelectedDeleteSWModuleTypes().isEmpty()) {
tabs.put(i18n.get("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab());
}
return tabs;
}
@@ -105,10 +105,10 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
tab.getConfirmAll().setId(SPUIComponetIdProvider.SW_DELETE_ALL);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(this.i18n.get("button.delete.all"));
tab.getConfirmAll().setCaption(i18n.get("button.delete.all"));
tab.getConfirmAll().addClickListener(event -> deleteSMAll(tab));
tab.getDiscardAll().setCaption(this.i18n.get("button.discard.all"));
tab.getDiscardAll().setCaption(i18n.get("button.discard.all"));
tab.getDiscardAll().addClickListener(event -> discardSMAll(tab));
// Add items container to the table.
@@ -131,8 +131,8 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(SW_MODULE_NAME_MSG);
visibleColumnIds.add(SW_DISCARD_CHGS);
visibleColumnLabels.add(this.i18n.get("upload.swModuleTable.header"));
visibleColumnLabels.add(this.i18n.get("header.second.deletetarget.table"));
visibleColumnLabels.add(i18n.get("upload.swModuleTable.header"));
visibleColumnLabels.add(i18n.get("header.second.deletetarget.table"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
@@ -153,11 +153,11 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
final IndexedContainer swcontactContainer = new IndexedContainer();
swcontactContainer.addContainerProperty("SWModuleId", String.class, "");
swcontactContainer.addContainerProperty(SW_MODULE_NAME_MSG, String.class, "");
for (final Long swModuleID : this.artifactUploadState.getDeleteSofwareModules().keySet()) {
for (final Long swModuleID : artifactUploadState.getDeleteSofwareModules().keySet()) {
final Item item = swcontactContainer.addItem(swModuleID);
item.getItemProperty("SWModuleId").setValue(swModuleID.toString());
item.getItemProperty(SW_MODULE_NAME_MSG)
.setValue(this.artifactUploadState.getDeleteSofwareModules().get(swModuleID));
.setValue(artifactUploadState.getDeleteSofwareModules().get(swModuleID));
}
return swcontactContainer;
}
@@ -165,35 +165,35 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
private void discardSoftwareDelete(final Button.ClickEvent event, final Object itemId, final ConfirmationTab tab) {
final Long swmoduleId = (Long) ((Button) event.getComponent()).getData();
if (null != this.artifactUploadState.getDeleteSofwareModules()
&& !this.artifactUploadState.getDeleteSofwareModules().isEmpty()
&& this.artifactUploadState.getDeleteSofwareModules().containsKey(swmoduleId)) {
this.artifactUploadState.getDeleteSofwareModules().remove(swmoduleId);
if (null != artifactUploadState.getDeleteSofwareModules()
&& !artifactUploadState.getDeleteSofwareModules().isEmpty()
&& artifactUploadState.getDeleteSofwareModules().containsKey(swmoduleId)) {
artifactUploadState.getDeleteSofwareModules().remove(swmoduleId);
}
tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size();
if (0 == deleteCount) {
removeCurrentTab(tab);
this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE);
eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE);
} else {
this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE);
eventBus.publish(this, UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE);
}
}
private void deleteSMAll(final ConfirmationTab tab) {
final Set<Long> swmoduleIds = this.artifactUploadState.getDeleteSofwareModules().keySet();
this.softwareManagement.deleteSoftwareModules(swmoduleIds);
final Set<Long> swmoduleIds = artifactUploadState.getDeleteSofwareModules().keySet();
softwareManagement.deleteSoftwareModules(swmoduleIds);
addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ this.i18n.get("message.swModule.deleted", this.artifactUploadState.getDeleteSofwareModules().size()));
+ i18n.get("message.swModule.deleted", artifactUploadState.getDeleteSofwareModules().size()));
/*
* Check if any information / files pending to upload for the deleted
* software modules. If so, then delete the files from the upload list.
*/
final List<CustomFile> tobeRemoved = new ArrayList<>();
for (final Long id : swmoduleIds) {
final String deleteSoftwareNameVersion = this.artifactUploadState.getDeleteSofwareModules().get(id);
final String deleteSoftwareNameVersion = artifactUploadState.getDeleteSofwareModules().get(id);
for (final CustomFile customFile : this.artifactUploadState.getFileSelected()) {
for (final CustomFile customFile : artifactUploadState.getFileSelected()) {
final String swNameVersion = HawkbitCommonUtil.getFormattedNameVersion(
customFile.getBaseSoftwareModuleName(), customFile.getBaseSoftwareModuleVersion());
if (deleteSoftwareNameVersion != null && deleteSoftwareNameVersion.equals(swNameVersion)) {
@@ -202,19 +202,19 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
}
}
if (!tobeRemoved.isEmpty()) {
this.artifactUploadState.getFileSelected().removeAll(tobeRemoved);
artifactUploadState.getFileSelected().removeAll(tobeRemoved);
}
this.artifactUploadState.getDeleteSofwareModules().clear();
artifactUploadState.getDeleteSofwareModules().clear();
removeCurrentTab(tab);
setActionMessage(this.i18n.get("message.software.delete.success"));
this.eventBus.publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFWARE);
setActionMessage(i18n.get("message.software.delete.success"));
eventBus.publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFWARE);
}
private void discardSMAll(final ConfirmationTab tab) {
removeCurrentTab(tab);
this.artifactUploadState.getDeleteSofwareModules().clear();
setActionMessage(this.i18n.get("message.software.discard.success"));
this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE);
artifactUploadState.getDeleteSofwareModules().clear();
setActionMessage(i18n.get("message.software.discard.success"));
eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE);
}
private ConfirmationTab createSMtypeDeleteConfirmationTab() {
@@ -222,10 +222,10 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
tab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_DELETE_SW_MODULE_TYPE);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(this.i18n.get("button.delete.all"));
tab.getConfirmAll().setCaption(i18n.get("button.delete.all"));
tab.getConfirmAll().addClickListener(event -> deleteSMtypeAll(tab));
tab.getDiscardAll().setCaption(this.i18n.get("button.discard.all"));
tab.getDiscardAll().setCaption(i18n.get("button.discard.all"));
tab.getDiscardAll().addClickListener(event -> discardSMtypeAll(tab));
// Add items container to the table.
@@ -251,8 +251,8 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(SW_MODULE_TYPE_NAME);
visibleColumnIds.add(DISCARD);
visibleColumnLabels.add(this.i18n.get("header.first.delete.swmodule.type.table"));
visibleColumnLabels.add(this.i18n.get("header.second.delete.swmodule.type.table"));
visibleColumnLabels.add(i18n.get("header.first.delete.swmodule.type.table"));
visibleColumnLabels.add(i18n.get("header.second.delete.swmodule.type.table"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
@@ -270,7 +270,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
private Container getSWModuleTypeTableContainer() {
final IndexedContainer contactContainer = new IndexedContainer();
contactContainer.addContainerProperty(SW_MODULE_TYPE_NAME, String.class, "");
for (final String swModuleTypeName : this.artifactUploadState.getSelectedDeleteSWModuleTypes()) {
for (final String swModuleTypeName : artifactUploadState.getSelectedDeleteSWModuleTypes()) {
final Item saveTblitem = contactContainer.addItem(swModuleTypeName);
saveTblitem.getItemProperty(SW_MODULE_TYPE_NAME).setValue(swModuleTypeName);
}
@@ -279,40 +279,40 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
private void discardSoftwareTypeDelete(final String discardSWModuleType, final Object itemId,
final ConfirmationTab tab) {
if (null != this.artifactUploadState.getSelectedDeleteSWModuleTypes()
&& !this.artifactUploadState.getSelectedDeleteSWModuleTypes().isEmpty()
&& this.artifactUploadState.getSelectedDeleteSWModuleTypes().contains(discardSWModuleType)) {
this.artifactUploadState.getSelectedDeleteSWModuleTypes().remove(discardSWModuleType);
if (null != artifactUploadState.getSelectedDeleteSWModuleTypes()
&& !artifactUploadState.getSelectedDeleteSWModuleTypes().isEmpty()
&& artifactUploadState.getSelectedDeleteSWModuleTypes().contains(discardSWModuleType)) {
artifactUploadState.getSelectedDeleteSWModuleTypes().remove(discardSWModuleType);
}
tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size();
if (0 == deleteCount) {
removeCurrentTab(tab);
this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE_TYPE);
eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE_TYPE);
} else {
this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE_TYPE);
eventBus.publish(this, UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE_TYPE);
}
}
private void deleteSMtypeAll(final ConfirmationTab tab) {
final int deleteSWModuleTypeCount = this.artifactUploadState.getSelectedDeleteSWModuleTypes().size();
for (final String swModuleTypeName : this.artifactUploadState.getSelectedDeleteSWModuleTypes()) {
final int deleteSWModuleTypeCount = artifactUploadState.getSelectedDeleteSWModuleTypes().size();
for (final String swModuleTypeName : artifactUploadState.getSelectedDeleteSWModuleTypes()) {
this.softwareManagement
.deleteSoftwareModuleType(this.softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName));
softwareManagement
.deleteSoftwareModuleType(softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName));
}
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ this.i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount }));
this.artifactUploadState.getSelectedDeleteSWModuleTypes().clear();
+ i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount }));
artifactUploadState.getSelectedDeleteSWModuleTypes().clear();
removeCurrentTab(tab);
setActionMessage(this.i18n.get("message.software.type.delete.success"));
this.eventBus.publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFWARE_TYPE);
setActionMessage(i18n.get("message.software.type.delete.success"));
eventBus.publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFWARE_TYPE);
}
private void discardSMtypeAll(final ConfirmationTab tab) {
removeCurrentTab(tab);
this.artifactUploadState.getSelectedDeleteSWModuleTypes().clear();
setActionMessage(this.i18n.get("message.software.type.discard.success"));
this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE_TYPE);
artifactUploadState.getSelectedDeleteSWModuleTypes().clear();
setActionMessage(i18n.get("message.software.type.discard.success"));
eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE_TYPE);
}
}

View File

@@ -64,28 +64,28 @@ public class ArtifactUploadState implements Serializable {
* @return
*/
public SoftwareModuleFilters getSoftwareModuleFilters() {
return this.softwareModuleFilters;
return softwareModuleFilters;
}
/**
* @return the selectedSofwareModules
*/
public Map<Long, String> getDeleteSofwareModules() {
return this.deleteSofwareModules;
return deleteSofwareModules;
}
/**
* @return the fileSelected
*/
public Set<CustomFile> getFileSelected() {
return this.fileSelected;
return fileSelected;
}
/**
* @return the selectedBaseSwModuleId
*/
public Optional<Long> getSelectedBaseSwModuleId() {
return this.selectedBaseSwModuleId != null ? Optional.of(this.selectedBaseSwModuleId) : Optional.empty();
return selectedBaseSwModuleId != null ? Optional.of(selectedBaseSwModuleId) : Optional.empty();
}
/**
@@ -100,8 +100,7 @@ public class ArtifactUploadState implements Serializable {
* @return the selectedBaseSoftwareModule
*/
public Optional<SoftwareModule> getSelectedBaseSoftwareModule() {
return this.selectedBaseSoftwareModule == null ? Optional.empty()
: Optional.of(this.selectedBaseSoftwareModule);
return selectedBaseSoftwareModule == null ? Optional.empty() : Optional.of(selectedBaseSoftwareModule);
}
/**
@@ -116,14 +115,14 @@ public class ArtifactUploadState implements Serializable {
* @return the baseSwModuleList
*/
public Map<String, SoftwareModule> getBaseSwModuleList() {
return this.baseSwModuleList;
return baseSwModuleList;
}
/**
* @return the selectedSoftwareModules
*/
public Set<Long> getSelectedSoftwareModules() {
return this.selectedSoftwareModules;
return selectedSoftwareModules;
}
/**
@@ -138,7 +137,7 @@ public class ArtifactUploadState implements Serializable {
* @return the swTypeFilterClosed
*/
public boolean isSwTypeFilterClosed() {
return this.swTypeFilterClosed;
return swTypeFilterClosed;
}
/**
@@ -153,7 +152,7 @@ public class ArtifactUploadState implements Serializable {
* @return the isSwModuleTableMaximized
*/
public boolean isSwModuleTableMaximized() {
return this.isSwModuleTableMaximized;
return isSwModuleTableMaximized;
}
/**
@@ -165,14 +164,14 @@ public class ArtifactUploadState implements Serializable {
}
public Set<String> getSelectedDeleteSWModuleTypes() {
return this.selectedDeleteSWModuleTypes;
return selectedDeleteSWModuleTypes;
}
/**
* @return the isArtifactDetailsMaximized
*/
public boolean isArtifactDetailsMaximized() {
return this.isArtifactDetailsMaximized;
return isArtifactDetailsMaximized;
}
/**
@@ -187,7 +186,7 @@ public class ArtifactUploadState implements Serializable {
* @return the noDataAvilableSoftwareModule
*/
public boolean isNoDataAvilableSoftwareModule() {
return this.noDataAvilableSoftwareModule;
return noDataAvilableSoftwareModule;
}
/**

View File

@@ -96,7 +96,7 @@ public class CustomFile implements Serializable {
}
public String getBaseSoftwareModuleName() {
return this.baseSoftwareModuleName;
return baseSoftwareModuleName;
}
public void setBaseSoftwareModuleName(final String baseSoftwareModuleName) {
@@ -104,7 +104,7 @@ public class CustomFile implements Serializable {
}
public String getBaseSoftwareModuleVersion() {
return this.baseSoftwareModuleVersion;
return baseSoftwareModuleVersion;
}
public void setBaseSoftwareModuleVersion(final String baseSoftwareModuleVersion) {
@@ -112,11 +112,11 @@ public class CustomFile implements Serializable {
}
public String getFileName() {
return this.fileName;
return fileName;
}
public long getFileSize() {
return this.fileSize;
return fileSize;
}
public void setFileSize(final long fileSize) {
@@ -124,7 +124,7 @@ public class CustomFile implements Serializable {
}
public String getFilePath() {
return this.filePath;
return filePath;
}
public void setFilePath(final String filePath) {
@@ -132,7 +132,7 @@ public class CustomFile implements Serializable {
}
public String getMimeType() {
return this.mimeType;
return mimeType;
}
/**
@@ -140,7 +140,7 @@ public class CustomFile implements Serializable {
* @return the isValid
*/
public Boolean getIsValid() {
return this.isValid;
return isValid;
}
/**
@@ -163,17 +163,16 @@ public class CustomFile implements Serializable {
* @return the failureReason
*/
public String getFailureReason() {
return this.failureReason;
return failureReason;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((this.baseSoftwareModuleName == null) ? 0 : this.baseSoftwareModuleName.hashCode());
result = prime * result
+ ((this.baseSoftwareModuleVersion == null) ? 0 : this.baseSoftwareModuleVersion.hashCode());
result = prime * result + ((this.fileName == null) ? 0 : this.fileName.hashCode());
result = prime * result + ((baseSoftwareModuleName == null) ? 0 : baseSoftwareModuleName.hashCode());
result = prime * result + ((baseSoftwareModuleVersion == null) ? 0 : baseSoftwareModuleVersion.hashCode());
result = prime * result + ((fileName == null) ? 0 : fileName.hashCode());
return result;
}
@@ -189,25 +188,25 @@ public class CustomFile implements Serializable {
return false;
}
final CustomFile other = (CustomFile) obj;
if (this.baseSoftwareModuleName == null) {
if (baseSoftwareModuleName == null) {
if (other.baseSoftwareModuleName != null) {
return false;
}
} else if (!this.baseSoftwareModuleName.equals(other.baseSoftwareModuleName)) {
} else if (!baseSoftwareModuleName.equals(other.baseSoftwareModuleName)) {
return false;
}
if (this.baseSoftwareModuleVersion == null) {
if (baseSoftwareModuleVersion == null) {
if (other.baseSoftwareModuleVersion != null) {
return false;
}
} else if (!this.baseSoftwareModuleVersion.equals(other.baseSoftwareModuleVersion)) {
} else if (!baseSoftwareModuleVersion.equals(other.baseSoftwareModuleVersion)) {
return false;
}
if (this.fileName == null) {
if (fileName == null) {
if (other.fileName != null) {
return false;
}
} else if (!this.fileName.equals(other.fileName)) {
} else if (!fileName.equals(other.fileName)) {
return false;
}
return true;

View File

@@ -38,18 +38,18 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
if (isButtonUnClicked(clickedButton)) {
/* If same button clicked */
clickedButton.removeStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
this.alreadyClickedButton = null;
alreadyClickedButton = null;
filterUnClicked(clickedButton);
} else if (this.alreadyClickedButton != null) {
} else if (alreadyClickedButton != null) {
/* If button clicked and some other button is already clicked */
this.alreadyClickedButton.removeStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
alreadyClickedButton.removeStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
clickedButton.addStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
this.alreadyClickedButton = clickedButton;
alreadyClickedButton = clickedButton;
filterClicked(clickedButton);
} else {
/* If button clicked and not other button is clicked currently */
clickedButton.addStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
this.alreadyClickedButton = clickedButton;
alreadyClickedButton = clickedButton;
filterClicked(clickedButton);
}
}
@@ -59,7 +59,7 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
* @return
*/
private boolean isButtonUnClicked(final Button clickedButton) {
return this.alreadyClickedButton != null && this.alreadyClickedButton.equals(clickedButton);
return alreadyClickedButton != null && alreadyClickedButton.equals(clickedButton);
}
/*
@@ -70,7 +70,7 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
*/
@Override
protected void setDefaultClickedButton(final Button button) {
this.alreadyClickedButton = button;
alreadyClickedButton = button;
if (button != null) {
button.addStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
}
@@ -80,7 +80,7 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
* @return the alreadyClickedButton
*/
public Button getAlreadyClickedButton() {
return this.alreadyClickedButton;
return alreadyClickedButton;
}
/**

View File

@@ -63,16 +63,16 @@ public abstract class AbstractTagToken implements Serializable {
private void createTokenField() {
final Container tokenContainer = createContainer();
this.tokenField = createTokenField(tokenContainer);
this.tokenField.setContainerDataSource(tokenContainer);
this.tokenField.setNewTokensAllowed(false);
this.tokenField.setFilteringMode(FilteringMode.CONTAINS);
this.tokenField.setInputPrompt(getTokenInputPrompt());
this.tokenField.setTokenInsertPosition(InsertPosition.AFTER);
this.tokenField.setImmediate(true);
this.tokenField.addStyleName(ValoTheme.COMBOBOX_TINY);
this.tokenField.setSizeFull();
this.tokenField.setTokenCaptionPropertyId("name");
tokenField = createTokenField(tokenContainer);
tokenField.setContainerDataSource(tokenContainer);
tokenField.setNewTokensAllowed(false);
tokenField.setFilteringMode(FilteringMode.CONTAINS);
tokenField.setInputPrompt(getTokenInputPrompt());
tokenField.setTokenInsertPosition(InsertPosition.AFTER);
tokenField.setImmediate(true);
tokenField.addStyleName(ValoTheme.COMBOBOX_TINY);
tokenField.setSizeFull();
tokenField.setTokenCaptionPropertyId("name");
}
protected void repopulateToken() {
@@ -81,26 +81,26 @@ public abstract class AbstractTagToken implements Serializable {
}
private Container createContainer() {
this.container = new IndexedContainer();
this.container.addContainerProperty("name", String.class, "");
this.container.addContainerProperty("id", Long.class, "");
this.container.addContainerProperty(COLOR_PROPERTY, String.class, "");
return this.container;
container = new IndexedContainer();
container.addContainerProperty("name", String.class, "");
container.addContainerProperty("id", Long.class, "");
container.addContainerProperty(COLOR_PROPERTY, String.class, "");
return container;
}
protected void addNewToken(final Long tagId) {
this.tokenField.addToken(tagId);
tokenField.addToken(tagId);
removeTagAssignedFromCombo(tagId);
}
private void removeTagAssignedFromCombo(final Long tagId) {
this.tokensAdded.put(tagId, new TagData(tagId, getTagName(tagId), getColor(tagId)));
this.container.removeItem(tagId);
tokensAdded.put(tagId, new TagData(tagId, getTagName(tagId), getColor(tagId)));
container.removeItem(tagId);
}
protected void setContainerPropertValues(final Long tagId, final String tagName, final String tagColor) {
this.tagDetails.put(tagId, new TagData(tagId, tagName, tagColor));
final Item item = this.container.addItem(tagId);
tagDetails.put(tagId, new TagData(tagId, tagName, tagColor));
final Item item = container.addItem(tagId);
item.getItemProperty("id").setValue(tagId);
updateItem(tagName, tagColor, item);
}
@@ -112,18 +112,18 @@ public abstract class AbstractTagToken implements Serializable {
protected void checkIfTagAssignedIsAllowed() {
if (!isToggleTagAssignmentAllowed()) {
this.tokenField.addStyleName("hideTokenFieldcombo");
tokenField.addStyleName("hideTokenFieldcombo");
}
}
private TokenField createTokenField(final Container tokenContainer) {
return new CustomTokenField(this.tokenLayout, tokenContainer);
return new CustomTokenField(tokenLayout, tokenContainer);
}
class CustomTokenField extends TokenField {
private static final long serialVersionUID = 694216966472937436L;
final Container tokenContainer;
Container tokenContainer;
CustomTokenField(final CssLayout cssLayout, final Container tokenContainer) {
super(cssLayout);
@@ -166,12 +166,12 @@ public abstract class AbstractTagToken implements Serializable {
}
private Property getItemNameProperty(final Object tokenId) {
final Item item = this.tokenField.getContainerDataSource().getItem(tokenId);
final Item item = tokenField.getContainerDataSource().getItem(tokenId);
return item.getItemProperty("name");
}
private String getColor(final Object tokenId) {
final Item item = this.tokenField.getContainerDataSource().getItem(tokenId);
final Item item = tokenField.getContainerDataSource().getItem(tokenId);
if (item.getItemProperty(COLOR_PROPERTY).getValue() != null) {
return (String) item.getItemProperty(COLOR_PROPERTY).getValue();
} else {
@@ -180,23 +180,23 @@ public abstract class AbstractTagToken implements Serializable {
}
private String getTagName(final Object tokenId) {
final Item item = this.tokenField.getContainerDataSource().getItem(tokenId);
final Item item = tokenField.getContainerDataSource().getItem(tokenId);
return (String) item.getItemProperty("name").getValue();
}
private void tokenClick(final Object tokenId) {
final Item item = this.tokenField.getContainerDataSource().addItem(tokenId);
item.getItemProperty("name").setValue(this.tagDetails.get(tokenId).getName());
item.getItemProperty(COLOR_PROPERTY).setValue(this.tagDetails.get(tokenId).getColor());
unassignTag(this.tagDetails.get(tokenId).getName());
final Item item = tokenField.getContainerDataSource().addItem(tokenId);
item.getItemProperty("name").setValue(tagDetails.get(tokenId).getName());
item.getItemProperty(COLOR_PROPERTY).setValue(tagDetails.get(tokenId).getColor());
unassignTag(tagDetails.get(tokenId).getName());
}
protected void removePreviouslyAddedTokens() {
this.tokensAdded.keySet().forEach(previouslyAddedToken -> this.tokenField.removeToken(previouslyAddedToken));
tokensAdded.keySet().forEach(previouslyAddedToken -> tokenField.removeToken(previouslyAddedToken));
}
protected Long getTagIdByTagName(final String tagName) {
final Optional<Map.Entry<Long, TagData>> mapEntry = this.tagDetails.entrySet().stream()
final Optional<Map.Entry<Long, TagData>> mapEntry = tagDetails.entrySet().stream()
.filter(entry -> entry.getValue().getName().equals(tagName)).findFirst();
if (mapEntry.isPresent()) {
return mapEntry.get().getKey();
@@ -205,13 +205,13 @@ public abstract class AbstractTagToken implements Serializable {
}
protected void removeTokenItem(final Long tokenId, final String name) {
this.tokenField.removeToken(tokenId);
setContainerPropertValues(tokenId, name, this.tokensAdded.get(tokenId).getColor());
tokenField.removeToken(tokenId);
setContainerPropertValues(tokenId, name, tokensAdded.get(tokenId).getColor());
}
protected void removeTagFromCombo(final Long deletedTagId) {
if (deletedTagId != null) {
this.container.removeItem(deletedTagId);
container.removeItem(deletedTagId);
}
}
@@ -230,7 +230,7 @@ public abstract class AbstractTagToken implements Serializable {
protected abstract void populateContainer();
public TokenField getTokenField() {
return this.tokenField;
return tokenField;
}
/**
@@ -264,7 +264,7 @@ public abstract class AbstractTagToken implements Serializable {
* @return the name
*/
public String getName() {
return this.name;
return name;
}
/**
@@ -279,7 +279,7 @@ public abstract class AbstractTagToken implements Serializable {
* @return the id
*/
public Long getId() {
return this.id;
return id;
}
/**
@@ -294,7 +294,7 @@ public abstract class AbstractTagToken implements Serializable {
* @return the color
*/
public String getColor() {
return this.color;
return color;
}
/**

View File

@@ -114,17 +114,16 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
@Override
@PostConstruct
protected void init() {
this.softwareModuleTable = new SoftwareModuleDetailsTable();
this.softwareModuleTable.init(this.i18n, true, this.permissionChecker, this.distributionSetManagement,
this.eventBus, this.manageDistUIState);
softwareModuleTable = new SoftwareModuleDetailsTable();
softwareModuleTable.init(i18n, true, permissionChecker, distributionSetManagement, eventBus, manageDistUIState);
super.init();
this.ui = UI.getCurrent();
this.eventBus.subscribe(this);
ui = UI.getCurrent();
eventBus.subscribe(this);
}
protected VerticalLayout createTagsLayout() {
this.tagsLayout = getTabLayout();
return this.tagsLayout;
tagsLayout = getTabLayout();
return tagsLayout;
}
private void populateDetailsWidget(final DistributionSet ds) {
@@ -148,17 +147,17 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
}
private void populteModule(final DistributionSet distributionSet) {
this.softwareModuleTable.populateModule(distributionSet);
softwareModuleTable.populateModule(distributionSet);
showUnsavedAssignment();
}
@SuppressWarnings("unchecked")
private void showUnsavedAssignment() {
Item item;
final Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> assignedList = this.manageDistUIState
final Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> assignedList = manageDistUIState
.getAssignedList();
final Long selectedDistId = this.manageDistUIState.getLastSelectedDistribution().isPresent()
? this.manageDistUIState.getLastSelectedDistribution().get().getId() : null;
final Long selectedDistId = manageDistUIState.getLastSelectedDistribution().isPresent()
? manageDistUIState.getLastSelectedDistribution().get().getId() : null;
Set<SoftwareModuleIdName> softwareModuleIdNameList = null;
for (final Map.Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entry : assignedList.entrySet()) {
@@ -170,22 +169,22 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
if (null != softwareModuleIdNameList) {
for (final SoftwareModuleIdName swIdName : softwareModuleIdNameList) {
final SoftwareModule softwareModule = this.softwareManagement.findSoftwareModuleById(swIdName.getId());
if (this.assignedSWModule.containsKey(softwareModule.getType().getName())) {
this.assignedSWModule.get(softwareModule.getType().getName()).append("</br>").append("<I>")
final SoftwareModule softwareModule = softwareManagement.findSoftwareModuleById(swIdName.getId());
if (assignedSWModule.containsKey(softwareModule.getType().getName())) {
assignedSWModule.get(softwareModule.getType().getName()).append("</br>").append("<I>")
.append(getUnsavedAssigedSwModule(softwareModule.getName(), softwareModule.getVersion()))
.append("<I>");
} else {
this.assignedSWModule.put(softwareModule.getType().getName(),
assignedSWModule.put(softwareModule.getType().getName(),
new StringBuilder().append("<I>").append(
getUnsavedAssigedSwModule(softwareModule.getName(), softwareModule.getVersion()))
.append("<I>"));
}
}
for (final Map.Entry<String, StringBuilder> entry : this.assignedSWModule.entrySet()) {
item = this.softwareModuleTable.getContainerDataSource().getItem(entry.getKey());
for (final Map.Entry<String, StringBuilder> entry : assignedSWModule.entrySet()) {
item = softwareModuleTable.getContainerDataSource().getItem(entry.getKey());
if (item != null) {
item.getItemProperty(SOFT_MODULE)
.setValue(HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString()));
@@ -201,8 +200,8 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
* @param entry
*/
private void assignSoftModuleButton(final Item item, final Map.Entry<String, StringBuilder> entry) {
if (this.permissionChecker.hasUpdateDistributionPermission() && this.distributionSetManagement
.findDistributionSetById(this.manageDistUIState.getLastSelectedDistribution().get().getId())
if (permissionChecker.hasUpdateDistributionPermission() && distributionSetManagement
.findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId())
.getAssignedTargets().isEmpty()) {
final Button reassignSoftModule = SPUIComponentProvider.getButton(entry.getKey(), "", "", "", true,
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
@@ -218,8 +217,8 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
@SuppressWarnings("unchecked")
private void updateSoftwareModule(final SoftwareModule module) {
this.softwareModuleTable.getContainerDataSource().getItemIds();
if (this.assignedSWModule.containsKey(module.getType().getName())) {
softwareModuleTable.getContainerDataSource().getItemIds();
if (assignedSWModule.containsKey(module.getType().getName())) {
/*
* If software module type is software, means multiple softwares can
* assigned to that type. Hence if multipe softwares belongs to same
@@ -227,7 +226,7 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
*/
if (module.getType().getMaxAssignments() == Integer.MAX_VALUE) {
this.assignedSWModule.get(module.getType().getName()).append("</br>").append("<I>")
assignedSWModule.get(module.getType().getName()).append("</br>").append("<I>")
.append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())).append("</I>");
}
@@ -237,17 +236,17 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
* same type is dropped, then override with previous one.
*/
if (module.getType().getMaxAssignments() == 1) {
this.assignedSWModule.put(module.getType().getName(), new StringBuilder().append("<I>")
assignedSWModule.put(module.getType().getName(), new StringBuilder().append("<I>")
.append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())).append("</I>"));
}
} else {
this.assignedSWModule.put(module.getType().getName(), new StringBuilder().append("<I>")
assignedSWModule.put(module.getType().getName(), new StringBuilder().append("<I>")
.append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())).append("</I>"));
}
for (final Map.Entry<String, StringBuilder> entry : this.assignedSWModule.entrySet()) {
final Item item = this.softwareModuleTable.getContainerDataSource().getItem(entry.getKey());
for (final Map.Entry<String, StringBuilder> entry : assignedSWModule.entrySet()) {
final Item item = softwareModuleTable.getContainerDataSource().getItem(entry.getKey());
if (item != null) {
item.getItemProperty(SOFT_MODULE)
.setValue(HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString()));
@@ -260,23 +259,23 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
private VerticalLayout createSoftwareModuleTab() {
final VerticalLayout softwareLayout = getTabLayout();
softwareLayout.setSizeFull();
softwareLayout.addComponent(this.softwareModuleTable);
softwareLayout.addComponent(softwareModuleTable);
return softwareLayout;
}
private void populateTags(final DistributionSet ds) {
this.tagsLayout.removeAllComponents();
tagsLayout.removeAllComponents();
if (null != ds) {
this.tagsLayout.addComponent(this.distributionTagToken.getTokenField());
tagsLayout.addComponent(distributionTagToken.getTokenField());
}
}
private void populateLog(final DistributionSet ds) {
if (null != ds) {
updateLogLayout(getLogLayout(), ds.getLastModifiedAt(), ds.getLastModifiedBy(), ds.getCreatedAt(),
ds.getCreatedBy(), this.i18n);
ds.getCreatedBy(), i18n);
} else {
updateLogLayout(getLogLayout(), null, HawkbitCommonUtil.SP_STRING_EMPTY, null, null, this.i18n);
updateLogLayout(getLogLayout(), null, HawkbitCommonUtil.SP_STRING_EMPTY, null, null, i18n);
}
}
@@ -290,9 +289,9 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
private void populateDescription(final DistributionSet ds) {
if (ds != null) {
updateDescriptionLayout(this.i18n.get("label.description"), ds.getDescription());
updateDescriptionLayout(i18n.get("label.description"), ds.getDescription());
} else {
updateDescriptionLayout(this.i18n.get("label.description"), null);
updateDescriptionLayout(i18n.get("label.description"), null);
}
}
@@ -301,21 +300,21 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
detailsTabLayout.removeAllComponents();
if (type != null) {
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(this.i18n.get("label.dist.details.type"),
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.type"),
type);
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
detailsTabLayout.addComponent(typeLabel);
}
if (isMigrationRequired != null) {
detailsTabLayout.addComponent(SPUIComponentProvider.createNameValueLabel(
this.i18n.get("checkbox.dist.migration.required"),
isMigrationRequired.equals(Boolean.TRUE) ? this.i18n.get("label.yes") : this.i18n.get("label.no")));
detailsTabLayout.addComponent(
SPUIComponentProvider.createNameValueLabel(i18n.get("checkbox.dist.migration.required"),
isMigrationRequired.equals(Boolean.TRUE) ? i18n.get("label.yes") : i18n.get("label.no")));
}
}
public Long getDsId() {
return this.dsId;
return dsId;
}
public void setDsId(final Long dsId) {
@@ -330,9 +329,9 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
*/
@Override
protected void onEdit(final ClickEvent event) {
final Window newDistWindow = this.distributionAddUpdateWindowLayout.getWindow();
this.distributionAddUpdateWindowLayout.populateValuesOfDistribution(getDsId());
newDistWindow.setCaption(this.i18n.get("caption.update.dist"));
final Window newDistWindow = distributionAddUpdateWindowLayout.getWindow();
distributionAddUpdateWindowLayout.populateValuesOfDistribution(getDsId());
newDistWindow.setCaption(i18n.get("caption.update.dist"));
UI.getCurrent().addWindow(newDistWindow);
newDistWindow.setVisible(Boolean.TRUE);
}
@@ -356,8 +355,8 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
*/
@Override
protected Boolean onLoadIsTableRowSelected() {
return this.manageDistUIState.getSelectedDistributions().isPresent()
&& !this.manageDistUIState.getSelectedDistributions().get().isEmpty();
return manageDistUIState.getSelectedDistributions().isPresent()
&& !manageDistUIState.getSelectedDistributions().get().isEmpty();
}
/*
@@ -368,7 +367,7 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
*/
@Override
protected Boolean onLoadIsTableMaximized() {
return this.manageDistUIState.isDsTableMaximized();
return manageDistUIState.isDsTableMaximized();
}
/*
@@ -379,7 +378,7 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
*/
@Override
protected void populateDetailsWidget() {
populateDetailsWidget(this.selectedDsModule);
populateDetailsWidget(selectedDsModule);
}
/*
@@ -390,7 +389,7 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
*/
@Override
protected String getDefaultCaption() {
return this.i18n.get("distribution.details.header");
return i18n.get("distribution.details.header");
}
/*
@@ -401,11 +400,11 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
*/
@Override
protected void addTabs(final TabSheet detailsTab) {
detailsTab.addTab(createDetailsLayout(), this.i18n.get("caption.tab.details"), null);
detailsTab.addTab(createDescriptionLayout(), this.i18n.get("caption.tab.description"), null);
detailsTab.addTab(createSoftwareModuleTab(), this.i18n.get("caption.softwares.distdetail.tab"), null);
detailsTab.addTab(createTagsLayout(), this.i18n.get("caption.tags.tab"), null);
detailsTab.addTab(createLogLayout(), this.i18n.get("caption.logs.tab"), null);
detailsTab.addTab(createDetailsLayout(), i18n.get("caption.tab.details"), null);
detailsTab.addTab(createDescriptionLayout(), i18n.get("caption.tab.description"), null);
detailsTab.addTab(createSoftwareModuleTab(), i18n.get("caption.softwares.distdetail.tab"), null);
detailsTab.addTab(createTagsLayout(), i18n.get("caption.tags.tab"), null);
detailsTab.addTab(createLogLayout(), i18n.get("caption.logs.tab"), null);
}
/*
@@ -427,13 +426,13 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
*/
@Override
protected Boolean hasEditPermission() {
return this.permissionChecker.hasUpdateDistributionPermission();
return permissionChecker.hasUpdateDistributionPermission();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleEvent event) {
if (event.getSoftwareModuleEventType() == SoftwareModuleEventType.ASSIGN_SOFTWARE_MODULE) {
this.ui.access(() -> updateSoftwareModule(event.getSoftwareModule()));
ui.access(() -> updateSoftwareModule(event.getSoftwareModule()));
}
}
@@ -442,37 +441,37 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.ON_VALUE_CHANGE
|| distributionTableEvent
.getDistributionComponentEvent() == DistributionComponentEvent.EDIT_DISTRIBUTION) {
this.assignedSWModule.clear();
this.ui.access(() -> {
assignedSWModule.clear();
ui.access(() -> {
/**
* distributionTableEvent.getDistributionSet() is null when
* table has no data.
*/
if (distributionTableEvent.getDistributionSet() != null) {
this.selectedDsModule = distributionTableEvent.getDistributionSet();
selectedDsModule = distributionTableEvent.getDistributionSet();
populateData(true);
} else {
populateData(false);
}
});
} else if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.MINIMIZED) {
this.ui.access(() -> showLayout());
ui.access(() -> showLayout());
} else if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.MAXIMIZED) {
this.ui.access(() -> hideLayout());
ui.access(() -> hideLayout());
}
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleAssignmentDiscardEvent softwareModuleAssignmentDiscardEvent) {
if (softwareModuleAssignmentDiscardEvent.getDistributionSetIdName() != null) {
this.ui.access(() -> {
ui.access(() -> {
final DistributionSetIdName distIdName = softwareModuleAssignmentDiscardEvent
.getDistributionSetIdName();
if (distIdName.getId().equals(this.selectedDsModule.getId())
&& distIdName.getName().equals(this.selectedDsModule.getName())) {
this.selectedDsModule = this.distributionSetManagement
.findDistributionSetByIdWithDetails(this.selectedDsModule.getId());
populteModule(this.selectedDsModule);
if (distIdName.getId().equals(selectedDsModule.getId())
&& distIdName.getName().equals(selectedDsModule.getName())) {
selectedDsModule = distributionSetManagement
.findDistributionSetByIdWithDetails(selectedDsModule.getId());
populteModule(selectedDsModule);
}
});
}
@@ -482,11 +481,10 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
void onEvent(final SaveActionWindowEvent saveActionWindowEvent) {
if ((saveActionWindowEvent == SaveActionWindowEvent.SAVED_ASSIGNMENTS
|| saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS)
&& this.selectedDsModule != null) {
this.assignedSWModule.clear();
this.selectedDsModule = this.distributionSetManagement
.findDistributionSetByIdWithDetails(this.selectedDsModule.getId());
this.ui.access(() -> populteModule(this.selectedDsModule));
&& selectedDsModule != null) {
assignedSWModule.clear();
selectedDsModule = distributionSetManagement.findDistributionSetByIdWithDetails(selectedDsModule.getId());
ui.access(() -> populteModule(selectedDsModule));
}
}
@@ -495,7 +493,7 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
if (saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ASSIGNMENT
|| saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS
|| saveActionWindowEvent == SaveActionWindowEvent.DELETE_ALL_SOFWARE) {
this.assignedSWModule.clear();
assignedSWModule.clear();
showUnsavedAssignment();
}
}
@@ -506,7 +504,7 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
* It's good to do this, even though vaadin-spring will automatically
* unsubscribe .
*/
this.eventBus.unsubscribe(this);
eventBus.unsubscribe(this);
}
/*

View File

@@ -124,7 +124,7 @@ public class DistributionSetTable extends AbstractTable {
super.init();
addTableStyleGenerator();
setNoDataAvailable();
this.eventBus.subscribe(this);
eventBus.subscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -158,12 +158,12 @@ public class DistributionSetTable extends AbstractTable {
protected Container createContainer() {
final Map<String, Object> queryConfiguration = new HashMap<>();
this.manageDistUIState.getManageDistFilters().getSearchText()
manageDistUIState.getManageDistFilters().getSearchText()
.ifPresent(value -> queryConfiguration.put(SPUIDefinitions.FILTER_BY_TEXT, value));
if (null != this.manageDistUIState.getManageDistFilters().getClickedDistSetType()) {
if (null != manageDistUIState.getManageDistFilters().getClickedDistSetType()) {
queryConfiguration.put(SPUIDefinitions.FILTER_BY_DISTRIBUTION_SET_TYPE,
this.manageDistUIState.getManageDistFilters().getClickedDistSetType());
manageDistUIState.getManageDistFilters().getClickedDistSetType());
}
final BeanQueryFactory<ManageDistBeanQuery> distributionQF = new BeanQueryFactory<>(ManageDistBeanQuery.class);
@@ -207,8 +207,8 @@ public class DistributionSetTable extends AbstractTable {
*/
@Override
protected boolean isFirstRowSelectedOnLoad() {
return !this.manageDistUIState.getSelectedDistributions().isPresent()
|| this.manageDistUIState.getSelectedDistributions().get().isEmpty();
return !manageDistUIState.getSelectedDistributions().isPresent()
|| manageDistUIState.getSelectedDistributions().get().isEmpty();
}
/*
@@ -218,8 +218,8 @@ public class DistributionSetTable extends AbstractTable {
*/
@Override
protected Object getItemIdToSelect() {
if (this.manageDistUIState.getSelectedDistributions().isPresent()) {
return this.manageDistUIState.getSelectedDistributions().get();
if (manageDistUIState.getSelectedDistributions().isPresent()) {
return manageDistUIState.getSelectedDistributions().get();
}
return null;
}
@@ -232,7 +232,7 @@ public class DistributionSetTable extends AbstractTable {
*/
@Override
protected void onValueChange() {
this.eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
@SuppressWarnings("unchecked")
final Set<DistributionSetIdName> values = (Set<DistributionSetIdName>) getValue();
DistributionSetIdName value = null;
@@ -247,20 +247,20 @@ public class DistributionSetTable extends AbstractTable {
* getValue returns null.
*/
if (null != value) {
this.manageDistUIState.setSelectedDistributions(values);
this.manageDistUIState.setLastSelectedDistribution(value);
manageDistUIState.setSelectedDistributions(values);
manageDistUIState.setLastSelectedDistribution(value);
final DistributionSet lastSelectedDistSet = this.distributionSetManagement
final DistributionSet lastSelectedDistSet = distributionSetManagement
.findDistributionSetByIdWithDetails(value.getId());
this.eventBus.publish(this,
eventBus.publish(this,
new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, lastSelectedDistSet));
}
} else {
this.manageDistUIState.setSelectedDistributions(null);
this.manageDistUIState.setLastSelectedDistribution(null);
this.eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, null));
manageDistUIState.setSelectedDistributions(null);
manageDistUIState.setLastSelectedDistribution(null);
eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, null));
}
this.eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
}
@@ -272,7 +272,7 @@ public class DistributionSetTable extends AbstractTable {
*/
@Override
protected boolean isMaximized() {
return this.manageDistUIState.isDsTableMaximized();
return manageDistUIState.isDsTableMaximized();
}
/*
@@ -283,7 +283,7 @@ public class DistributionSetTable extends AbstractTable {
*/
@Override
protected List<TableColumn> getTableVisibleColumns() {
return HawkbitCommonUtil.getTableVisibleColumns(isMaximized(), false, this.i18n);
return HawkbitCommonUtil.getTableVisibleColumns(isMaximized(), false, i18n);
}
/*
@@ -298,7 +298,7 @@ public class DistributionSetTable extends AbstractTable {
@Override
public AcceptCriterion getAcceptCriterion() {
return DistributionSetTable.this.distributionsViewAcceptCriteria;
return distributionsViewAcceptCriteria;
}
@Override
@@ -343,11 +343,11 @@ public class DistributionSetTable extends AbstractTable {
final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distId, distName, distVersion);
final HashMap<Long, HashSet<SoftwareModuleIdName>> map;
if (this.manageDistUIState.getConsolidatedDistSoftwarewList().containsKey(distributionSetIdName)) {
map = this.manageDistUIState.getConsolidatedDistSoftwarewList().get(distributionSetIdName);
if (manageDistUIState.getConsolidatedDistSoftwarewList().containsKey(distributionSetIdName)) {
map = manageDistUIState.getConsolidatedDistSoftwarewList().get(distributionSetIdName);
} else {
map = new HashMap<>();
this.manageDistUIState.getConsolidatedDistSoftwarewList().put(distributionSetIdName, map);
manageDistUIState.getConsolidatedDistSoftwarewList().put(distributionSetIdName, map);
}
for (final Long softwareModuleId : softwareModulesIdList) {
@@ -355,7 +355,7 @@ public class DistributionSetTable extends AbstractTable {
final String name = (String) softwareItem.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
final String swVersion = (String) softwareItem.getItemProperty(SPUILabelDefinitions.VAR_VERSION).getValue();
final SoftwareModule softwareModule = this.softwareManagement.findSoftwareModuleById(softwareModuleId);
final SoftwareModule softwareModule = softwareManagement.findSoftwareModuleById(softwareModuleId);
if (validSoftwareModule(distId, softwareModule)) {
final SoftwareModuleIdName softwareModuleIdName = new SoftwareModuleIdName(softwareModuleId,
name.concat(":" + swVersion));
@@ -391,9 +391,9 @@ public class DistributionSetTable extends AbstractTable {
* @param softwareModule
*/
private void publishAssignEvent(final Long distId, final SoftwareModule softwareModule) {
if (this.manageDistUIState.getLastSelectedDistribution().isPresent()
&& this.manageDistUIState.getLastSelectedDistribution().get().getId().equals(distId)) {
this.eventBus.publish(this,
if (manageDistUIState.getLastSelectedDistribution().isPresent()
&& manageDistUIState.getLastSelectedDistribution().get().getId().equals(distId)) {
eventBus.publish(this,
new SoftwareModuleEvent(SoftwareModuleEventType.ASSIGN_SOFTWARE_MODULE, softwareModule));
}
}
@@ -434,41 +434,41 @@ public class DistributionSetTable extends AbstractTable {
private void updateDropedDetails(final DistributionSetIdName distributionSetIdName,
final HashSet<SoftwareModuleIdName> softwareModules) {
LOG.debug("Adding a log to check if distributionSetIdName is null : {} ", distributionSetIdName);
this.manageDistUIState.getAssignedList().put(distributionSetIdName, softwareModules);
manageDistUIState.getAssignedList().put(distributionSetIdName, softwareModules);
this.eventBus.publish(this, DistributionsUIEvent.UPDATE_COUNT);
this.eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
eventBus.publish(this, DistributionsUIEvent.UPDATE_COUNT);
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
}
private boolean validSoftwareModule(final Long distId, final SoftwareModule sm) {
if (!isSoftwareModuleDragged(distId, sm)) {
return false;
}
final DistributionSet ds = this.distributionSetManagement.findDistributionSetByIdWithDetails(distId);
final DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(distId);
if (!validateSoftwareModule(sm, ds)) {
return false;
}
try {
this.distributionSetManagement.checkDistributionSetAlreadyUse(ds);
distributionSetManagement.checkDistributionSetAlreadyUse(ds);
} catch (final EntityLockedException exception) {
LOG.error("Unable to update distribution : ", exception);
this.notification.displayValidationError(exception.getMessage());
notification.displayValidationError(exception.getMessage());
return false;
}
return true;
}
private boolean validateSoftwareModule(final SoftwareModule sm, final DistributionSet ds) {
if (this.targetManagement.countTargetByFilters(null, null, ds.getId(), Boolean.FALSE, new String[] {}) > 0) {
if (targetManagement.countTargetByFilters(null, null, ds.getId(), Boolean.FALSE, new String[] {}) > 0) {
/* Distribution is already assigned */
this.notification.displayValidationError(this.i18n.get("message.dist.inuse",
notification.displayValidationError(i18n.get("message.dist.inuse",
HawkbitCommonUtil.concatStrings(":", ds.getName(), ds.getVersion())));
return false;
}
if (ds.getModules().contains(sm)) {
/* Already has software module */
this.notification.displayValidationError(this.i18n.get("message.software.dist.already.assigned",
notification.displayValidationError(i18n.get("message.software.dist.already.assigned",
HawkbitCommonUtil.concatStrings(":", ds.getName(), ds.getVersion()),
HawkbitCommonUtil.concatStrings(":", sm.getName(), sm.getVersion())));
return false;
@@ -476,7 +476,7 @@ public class DistributionSetTable extends AbstractTable {
if (!ds.getType().containsModuleType(sm.getType())) {
/* Invalid type of the software module */
this.notification.displayValidationError(this.i18n.get("message.software.dist.type.notallowed",
notification.displayValidationError(i18n.get("message.software.dist.type.notallowed",
HawkbitCommonUtil.concatStrings(":", sm.getName(), sm.getVersion()),
HawkbitCommonUtil.concatStrings(":", ds.getName(), ds.getVersion())));
return false;
@@ -485,7 +485,7 @@ public class DistributionSetTable extends AbstractTable {
}
private boolean isSoftwareModuleDragged(final Long distId, final SoftwareModule sm) {
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entry : this.manageDistUIState
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entry : manageDistUIState
.getAssignedList().entrySet()) {
if (!distId.equals(entry.getKey().getId())) {
continue;
@@ -493,7 +493,7 @@ public class DistributionSetTable extends AbstractTable {
final Set<SoftwareModuleIdName> swModuleIdNames = entry.getValue();
for (final SoftwareModuleIdName swModuleIdName : swModuleIdNames) {
if ((sm.getName().concat(":" + sm.getVersion())).equals(swModuleIdName.getName())) {
this.notification.displayValidationError(this.i18n.get("message.software.already.dragged",
notification.displayValidationError(i18n.get("message.software.already.dragged",
HawkbitCommonUtil.concatStrings(":", sm.getName(), sm.getVersion())));
return false;
}
@@ -511,19 +511,19 @@ public class DistributionSetTable extends AbstractTable {
* @return boolean as flag
*/
private Boolean doValidation(final DragAndDropEvent dragEvent) {
if (!this.permissionChecker.hasUpdateDistributionPermission()) {
this.notification.displayValidationError(this.i18n.get("message.permission.insufficient"));
if (!permissionChecker.hasUpdateDistributionPermission()) {
notification.displayValidationError(i18n.get("message.permission.insufficient"));
return false;
} else {
final Component compsource = dragEvent.getTransferable().getSourceComponent();
final Table source = (Table) compsource;
if (compsource instanceof Table) {
if (!source.getId().equals(SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE)) {
this.notification.displayValidationError(this.i18n.get("message.action.not.allowed"));
notification.displayValidationError(i18n.get("message.action.not.allowed"));
return false;
}
} else {
this.notification.displayValidationError(this.i18n.get("message.action.not.allowed"));
notification.displayValidationError(i18n.get("message.action.not.allowed"));
return false;
}
}
@@ -555,8 +555,8 @@ public class DistributionSetTable extends AbstractTable {
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).setValue(distributionSet.isComplete());
if (this.manageDistUIState.getSelectedDistributions().isPresent()) {
this.manageDistUIState.getSelectedDistributions().get().stream().forEach(dsNameId -> unselect(dsNameId));
if (manageDistUIState.getSelectedDistributions().isPresent()) {
manageDistUIState.getSelectedDistributions().get().stream().forEach(dsNameId -> unselect(dsNameId));
}
select(distributionSet.getDistributionSetIdName());
}
@@ -617,15 +617,15 @@ public class DistributionSetTable extends AbstractTable {
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
this.eventBus.unsubscribe(this);
eventBus.unsubscribe(this);
}
private void setNoDataAvailable() {
final int containerSize = getContainerDataSource().size();
if (containerSize == 0) {
this.manageDistUIState.setNoDataAvailableDist(true);
manageDistUIState.setNoDataAvailableDist(true);
} else {
this.manageDistUIState.setNoDataAvailableDist(false);
manageDistUIState.setNoDataAvailableDist(false);
}
}
}

View File

@@ -102,7 +102,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
@PostConstruct
protected void init() {
super.init();
this.eventBus.subscribe(this);
eventBus.subscribe(this);
}
@PreDestroy
@@ -111,7 +111,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
this.eventBus.unsubscribe(this);
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -129,9 +129,9 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
UI.getCurrent().access(() -> {
if (!hasUnsavedActions()) {
closeUnsavedActionsWindow();
final String message = this.distConfirmationWindowLayout.getConsolidatedMessage();
final String message = distConfirmationWindowLayout.getConsolidatedMessage();
if (message != null && message.length() > 0) {
this.notification.displaySuccess(message);
notification.displaySuccess(message);
}
}
updateDSActionCount();
@@ -148,7 +148,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
*/
@Override
protected boolean hasDeletePermission() {
return this.permChecker.hasDeleteDistributionPermission();
return permChecker.hasDeleteDistributionPermission();
}
@@ -162,7 +162,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override
protected boolean hasUpdatePermission() {
return this.permChecker.hasUpdateDistributionPermission();
return permChecker.hasUpdateDistributionPermission();
}
/*
@@ -174,7 +174,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
*/
@Override
protected String getDeleteAreaLabel() {
return this.i18n.get("label.components.drop.area");
return i18n.get("label.components.drop.area");
}
/*
@@ -200,7 +200,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override
protected AcceptCriterion getDeleteLayoutAcceptCriteria() {
return this.distributionsViewAcceptCriteria;
return distributionsViewAcceptCriteria;
}
/*
@@ -228,7 +228,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
processDeleteSWType(sourceComponent.getId());
}
this.eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
hideDropHints();
}
@@ -237,12 +237,12 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
final String distTypeName = HawkbitCommonUtil.removePrefix(distTypeId,
SPUIDefinitions.DISTRIBUTION_SET_TYPE_ID_PREFIXS);
if (isDsTypeSelected(distTypeName)) {
this.notification.displayValidationError(
this.i18n.get("message.dist.type.check.delete", new Object[] { distTypeName }));
notification
.displayValidationError(i18n.get("message.dist.type.check.delete", new Object[] { distTypeName }));
} else if (isDefaultDsType(distTypeName)) {
this.notification.displayValidationError(this.i18n.get("message.cannot.delete.default.dstype"));
notification.displayValidationError(i18n.get("message.cannot.delete.default.dstype"));
} else {
this.manageDistUIState.getSelectedDeleteDistSetTypes().add(distTypeName);
manageDistUIState.getSelectedDeleteDistSetTypes().add(distTypeName);
updateDSActionCount();
}
}
@@ -254,7 +254,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* @return true if ds type is selected
*/
private boolean isDsTypeSelected(final String distTypeName) {
return null != this.manageDistUIState.getManageDistFilters().getClickedDistSetType() && this.manageDistUIState
return null != manageDistUIState.getManageDistFilters().getClickedDistSetType() && manageDistUIState
.getManageDistFilters().getClickedDistSetType().getName().equalsIgnoreCase(distTypeName);
}
@@ -262,13 +262,13 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
final String swModuleTypeName = HawkbitCommonUtil.removePrefix(swTypeId,
SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS);
if (this.manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent()
&& this.manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName()
if (manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent()
&& manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName()
.equalsIgnoreCase(swModuleTypeName)) {
this.notification.displayValidationError(
this.i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName }));
notification.displayValidationError(
i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName }));
} else {
this.manageDistUIState.getSelectedDeleteSWModuleTypes().add(swModuleTypeName);
manageDistUIState.getSelectedDeleteSWModuleTypes().add(swModuleTypeName);
updateDSActionCount();
}
@@ -288,9 +288,9 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* the deleted list (or) some distributions are already in the deleted
* distribution list.
*/
final int existingDeletedDistributionsSize = this.manageDistUIState.getDeletedDistributionList().size();
this.manageDistUIState.getDeletedDistributionList().addAll(distributionIdNameSet);
final int newDeletedDistributionsSize = this.manageDistUIState.getDeletedDistributionList().size();
final int existingDeletedDistributionsSize = manageDistUIState.getDeletedDistributionList().size();
manageDistUIState.getDeletedDistributionList().addAll(distributionIdNameSet);
final int newDeletedDistributionsSize = manageDistUIState.getDeletedDistributionList().size();
if (newDeletedDistributionsSize == existingDeletedDistributionsSize) {
/*
* No new distributions are added, all distributions dropped now are
@@ -298,7 +298,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* message accordingly.
*/
this.uiNotification.displayValidationError(this.i18n.get("message.targets.already.deleted"));
uiNotification.displayValidationError(i18n.get("message.targets.already.deleted"));
} else if (newDeletedDistributionsSize - existingDeletedDistributionsSize != distributionIdNameSet.size()) {
/*
* Not the all distributions dropped now are added to the delete
@@ -306,7 +306,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* delete list. Hence display warning message accordingly.
*/
this.uiNotification.displayValidationError(this.i18n.get("message.dist.deleted.pending"));
uiNotification.displayValidationError(i18n.get("message.dist.deleted.pending"));
}
}
@@ -324,7 +324,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
swModuleIdNameSet.forEach(id -> {
final String swModuleName = (String) sourceTable.getContainerDataSource().getItem(id)
.getItemProperty(SPUILabelDefinitions.NAME_VERSION).getValue();
this.manageDistUIState.getDeleteSofwareModulesList().put(id, swModuleName);
manageDistUIState.getDeleteSofwareModulesList().put(id, swModuleName);
});
}
@@ -332,14 +332,14 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* Update the software module delete count.
*/
private void updateDSActionCount() {
int count = this.manageDistUIState.getSelectedDeleteDistSetTypes().size()
+ this.manageDistUIState.getSelectedDeleteSWModuleTypes().size()
+ this.manageDistUIState.getDeleteSofwareModulesList().size()
+ this.manageDistUIState.getDeletedDistributionList().size();
int count = manageDistUIState.getSelectedDeleteDistSetTypes().size()
+ manageDistUIState.getSelectedDeleteSWModuleTypes().size()
+ manageDistUIState.getDeleteSofwareModulesList().size()
+ manageDistUIState.getDeletedDistributionList().size();
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> mapEntry : this.manageDistUIState
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> mapEntry : manageDistUIState
.getAssignedList().entrySet()) {
count += this.manageDistUIState.getAssignedList().get(mapEntry.getKey()).size();
count += manageDistUIState.getAssignedList().get(mapEntry.getKey()).size();
}
updateActionsCount(count);
}
@@ -375,7 +375,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
*/
@Override
protected String getNoActionsButtonLabel() {
return this.i18n.get("button.no.actions");
return i18n.get("button.no.actions");
}
/*
@@ -388,7 +388,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override
protected String getActionsButtonLabel() {
return this.i18n.get("button.actions");
return i18n.get("button.actions");
}
@@ -414,7 +414,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
*/
@Override
protected String getUnsavedActionsWindowCaption() {
return this.i18n.get("caption.save.window");
return i18n.get("caption.save.window");
}
/*
@@ -426,9 +426,9 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
*/
@Override
protected void unsavedActionsWindowClosed() {
final String message = this.distConfirmationWindowLayout.getConsolidatedMessage();
final String message = distConfirmationWindowLayout.getConsolidatedMessage();
if (message != null && message.length() > 0) {
this.notification.displaySuccess(message);
notification.displaySuccess(message);
}
}
@@ -442,8 +442,8 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
*/
@Override
protected Component getUnsavedActionsWindowContent() {
this.distConfirmationWindowLayout.init();
return this.distConfirmationWindowLayout;
distConfirmationWindowLayout.init();
return distConfirmationWindowLayout;
}
/*
@@ -457,12 +457,12 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
protected boolean hasUnsavedActions() {
boolean unSavedActionsTypes = false;
boolean unSavedActionsTables = false;
if (!this.manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()
|| !this.manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()) {
if (!manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()
|| !manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()) {
unSavedActionsTypes = true;
} else if (!this.manageDistUIState.getDeleteSofwareModulesList().isEmpty()
|| !this.manageDistUIState.getDeletedDistributionList().isEmpty()
|| !this.manageDistUIState.getAssignedList().isEmpty()) {
} else if (!manageDistUIState.getDeleteSofwareModulesList().isEmpty()
|| !manageDistUIState.getDeletedDistributionList().isEmpty()
|| !manageDistUIState.getAssignedList().isEmpty()) {
unSavedActionsTables = true;
}
@@ -517,7 +517,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
}
private DistributionSetType getCurrentDistributionSetType() {
return this.systemManagement.getTenantMetadata().getDefaultDsType();
return systemManagement.getTenantMetadata().getDefaultDsType();
}
/**

View File

@@ -116,30 +116,29 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
protected Map<String, ConfirmationTab> getConfimrationTabs() {
final Map<String, ConfirmationTab> tabs = new HashMap<>();
/* Create tab for SW Modules delete */
if (!this.manageDistUIState.getDeleteSofwareModulesList().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
if (!manageDistUIState.getDeleteSofwareModulesList().isEmpty()) {
tabs.put(i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
}
/* Create tab for SW Module Type delete */
if (!this.manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab());
if (!manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()) {
tabs.put(i18n.get("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab());
}
/* Create tab for Distributions delete */
if (!this.manageDistUIState.getDeletedDistributionList().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.dist.accordion.tab"), createDistDeleteConfirmationTab());
if (!manageDistUIState.getDeletedDistributionList().isEmpty()) {
tabs.put(i18n.get("caption.delete.dist.accordion.tab"), createDistDeleteConfirmationTab());
}
/* Create tab for Distribution Set Types delete */
if (!this.manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.dist.set.type.accordion.tab"),
createDistSetTypeDeleteConfirmationTab());
if (!manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()) {
tabs.put(i18n.get("caption.delete.dist.set.type.accordion.tab"), createDistSetTypeDeleteConfirmationTab());
}
/* Create tab for Assign Software Module */
if (!this.manageDistUIState.getAssignedList().isEmpty()) {
tabs.put(this.i18n.get("caption.assign.dist.accordion.tab"), createAssignSWModuleConfirmationTab());
if (!manageDistUIState.getAssignedList().isEmpty()) {
tabs.put(i18n.get("caption.assign.dist.accordion.tab"), createAssignSWModuleConfirmationTab());
}
return tabs;
@@ -151,10 +150,10 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
tab.getConfirmAll().setId(SPUIComponetIdProvider.SW_DELETE_ALL);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().addClickListener(event -> deleteSMAll(tab));
tab.getDiscardAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().addClickListener(event -> discardSMAll(tab));
/* Add items container to the table. */
@@ -177,8 +176,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(SW_MODULE_NAME_MSG);
visibleColumnIds.add(SW_DISCARD_CHGS);
visibleColumnLabels.add(this.i18n.get("upload.swModuleTable.header"));
visibleColumnLabels.add(this.i18n.get("header.second.deletetarget.table"));
visibleColumnLabels.add(i18n.get("upload.swModuleTable.header"));
visibleColumnLabels.add(i18n.get("header.second.deletetarget.table"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
@@ -190,36 +189,35 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
}
private void deleteSMAll(final ConfirmationTab tab) {
final Set<Long> swmoduleIds = this.manageDistUIState.getDeleteSofwareModulesList().keySet();
final Set<Long> swmoduleIds = manageDistUIState.getDeleteSofwareModulesList().keySet();
if (this.manageDistUIState.getAssignedList() == null || this.manageDistUIState.getAssignedList().isEmpty()) {
if (manageDistUIState.getAssignedList() == null || manageDistUIState.getAssignedList().isEmpty()) {
removeAssignedSoftwareModules();
}
this.softwareManagement.deleteSoftwareModules(swmoduleIds);
softwareManagement.deleteSoftwareModules(swmoduleIds);
addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ this.i18n.get("message.swModule.deleted", swmoduleIds.size()));
this.manageDistUIState.getDeleteSofwareModulesList().clear();
+ i18n.get("message.swModule.deleted", swmoduleIds.size()));
manageDistUIState.getDeleteSofwareModulesList().clear();
removeCurrentTab(tab);
setActionMessage(this.i18n.get("message.software.delete.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DELETE_ALL_SOFWARE);
setActionMessage(i18n.get("message.software.delete.success"));
eventBus.publish(this, SaveActionWindowEvent.DELETE_ALL_SOFWARE);
}
private void removeAssignedSoftwareModules() {
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entryAssignSM : this.manageDistUIState
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entryAssignSM : manageDistUIState
.getAssignedList().entrySet()) {
for (final Entry<Long, String> entryDeleteSM : this.manageDistUIState.getDeleteSofwareModulesList()
.entrySet()) {
for (final Entry<Long, String> entryDeleteSM : manageDistUIState.getDeleteSofwareModulesList().entrySet()) {
final SoftwareModuleIdName smIdName = new SoftwareModuleIdName(entryDeleteSM.getKey(),
entryDeleteSM.getValue());
if (entryAssignSM.getValue().contains(smIdName)) {
entryAssignSM.getValue().remove(smIdName);
this.assignmnetTab.getTable().removeItem(HawkbitCommonUtil.concatStrings("|||",
assignmnetTab.getTable().removeItem(HawkbitCommonUtil.concatStrings("|||",
entryAssignSM.getKey().getId().toString(), smIdName.getId().toString()));
}
if (entryAssignSM.getValue().isEmpty()) {
this.manageDistUIState.getAssignedList().remove(entryAssignSM.getKey());
manageDistUIState.getAssignedList().remove(entryAssignSM.getKey());
}
}
}
@@ -227,9 +225,9 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private void discardSMAll(final ConfirmationTab tab) {
removeCurrentTab(tab);
this.manageDistUIState.getDeleteSofwareModulesList().clear();
setActionMessage(this.i18n.get("message.software.discard.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_SOFTWARE);
manageDistUIState.getDeleteSofwareModulesList().clear();
setActionMessage(i18n.get("message.software.discard.success"));
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_SOFTWARE);
}
/**
@@ -242,29 +240,29 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
final IndexedContainer swcontactContainer = new IndexedContainer();
swcontactContainer.addContainerProperty("SWModuleId", String.class, "");
swcontactContainer.addContainerProperty(SW_MODULE_NAME_MSG, String.class, "");
for (final Long swModuleID : this.manageDistUIState.getDeleteSofwareModulesList().keySet()) {
for (final Long swModuleID : manageDistUIState.getDeleteSofwareModulesList().keySet()) {
final Item item = swcontactContainer.addItem(swModuleID);
item.getItemProperty("SWModuleId").setValue(swModuleID.toString());
item.getItemProperty(SW_MODULE_NAME_MSG)
.setValue(this.manageDistUIState.getDeleteSofwareModulesList().get(swModuleID));
.setValue(manageDistUIState.getDeleteSofwareModulesList().get(swModuleID));
}
return swcontactContainer;
}
private void discardSoftwareDelete(final Button.ClickEvent event, final Object itemId, final ConfirmationTab tab) {
final Long swmoduleId = (Long) ((Button) event.getComponent()).getData();
if (null != this.manageDistUIState.getDeleteSofwareModulesList()
&& !this.manageDistUIState.getDeleteSofwareModulesList().isEmpty()
&& this.manageDistUIState.getDeleteSofwareModulesList().containsKey(swmoduleId)) {
this.manageDistUIState.getDeleteSofwareModulesList().remove(swmoduleId);
if (null != manageDistUIState.getDeleteSofwareModulesList()
&& !manageDistUIState.getDeleteSofwareModulesList().isEmpty()
&& manageDistUIState.getDeleteSofwareModulesList().containsKey(swmoduleId)) {
manageDistUIState.getDeleteSofwareModulesList().remove(swmoduleId);
}
tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size();
if (0 == deleteCount) {
removeCurrentTab(tab);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_SOFTWARE);
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_SOFTWARE);
} else {
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_DELETE_SOFTWARE);
eventBus.publish(this, SaveActionWindowEvent.DISCARD_DELETE_SOFTWARE);
}
}
@@ -273,10 +271,10 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
tab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_DELETE_SW_MODULE_TYPE);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().addClickListener(event -> deleteSMtypeAll(tab));
tab.getDiscardAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_SW_MODULE_TYPE);
tab.getDiscardAll().addClickListener(event -> discardSMtypeAll(tab));
@@ -303,8 +301,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(SW_MODULE_TYPE_NAME);
visibleColumnIds.add(DISCARD);
visibleColumnLabels.add(this.i18n.get("header.first.delete.swmodule.type.table"));
visibleColumnLabels.add(this.i18n.get("header.second.delete.swmodule.type.table"));
visibleColumnLabels.add(i18n.get("header.first.delete.swmodule.type.table"));
visibleColumnLabels.add(i18n.get("header.second.delete.swmodule.type.table"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
@@ -317,32 +315,32 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
}
private void deleteSMtypeAll(final ConfirmationTab tab) {
final int deleteSWModuleTypeCount = this.manageDistUIState.getSelectedDeleteSWModuleTypes().size();
for (final String swModuleTypeName : this.manageDistUIState.getSelectedDeleteSWModuleTypes()) {
final int deleteSWModuleTypeCount = manageDistUIState.getSelectedDeleteSWModuleTypes().size();
for (final String swModuleTypeName : manageDistUIState.getSelectedDeleteSWModuleTypes()) {
this.softwareManagement
.deleteSoftwareModuleType(this.softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName));
softwareManagement
.deleteSoftwareModuleType(softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName));
}
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ this.i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount }));
this.manageDistUIState.getSelectedDeleteSWModuleTypes().clear();
+ i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount }));
manageDistUIState.getSelectedDeleteSWModuleTypes().clear();
removeCurrentTab(tab);
setActionMessage(this.i18n.get("message.software.type.delete.success"));
this.eventBus.publish(this, SaveActionWindowEvent.SAVED_DELETE_SW_MODULE_TYPES);
setActionMessage(i18n.get("message.software.type.delete.success"));
eventBus.publish(this, SaveActionWindowEvent.SAVED_DELETE_SW_MODULE_TYPES);
}
private void discardSMtypeAll(final ConfirmationTab tab) {
removeCurrentTab(tab);
this.manageDistUIState.getSelectedDeleteSWModuleTypes().clear();
setActionMessage(this.i18n.get("message.software.type.discard.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_SW_MODULE_TYPES);
manageDistUIState.getSelectedDeleteSWModuleTypes().clear();
setActionMessage(i18n.get("message.software.type.discard.success"));
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_SW_MODULE_TYPES);
}
private Container getSWModuleTypeTableContainer() {
final IndexedContainer contactContainer = new IndexedContainer();
contactContainer.addContainerProperty(SW_MODULE_TYPE_NAME, String.class, "");
for (final String swModuleTypeName : this.manageDistUIState.getSelectedDeleteSWModuleTypes()) {
for (final String swModuleTypeName : manageDistUIState.getSelectedDeleteSWModuleTypes()) {
final Item saveTblitem = contactContainer.addItem(swModuleTypeName);
saveTblitem.getItemProperty(SW_MODULE_TYPE_NAME).setValue(swModuleTypeName);
@@ -353,18 +351,18 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private void discardSoftwareTypeDelete(final String discardSWModuleType, final Object itemId,
final ConfirmationTab tab) {
if (null != this.manageDistUIState.getSelectedDeleteSWModuleTypes()
&& !this.manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()
&& this.manageDistUIState.getSelectedDeleteSWModuleTypes().contains(discardSWModuleType)) {
this.manageDistUIState.getSelectedDeleteSWModuleTypes().remove(discardSWModuleType);
if (null != manageDistUIState.getSelectedDeleteSWModuleTypes()
&& !manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()
&& manageDistUIState.getSelectedDeleteSWModuleTypes().contains(discardSWModuleType)) {
manageDistUIState.getSelectedDeleteSWModuleTypes().remove(discardSWModuleType);
}
tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size();
if (0 == deleteCount) {
removeCurrentTab(tab);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_SW_MODULE_TYPES);
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_SW_MODULE_TYPES);
} else {
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_DELETE_SW_MODULE_TYPE);
eventBus.publish(this, SaveActionWindowEvent.DISCARD_DELETE_SW_MODULE_TYPE);
}
}
@@ -374,10 +372,10 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
tab.getConfirmAll().setId(SPUIComponetIdProvider.DIST_DELETE_ALL);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().addClickListener(event -> deleteDistAll(tab));
tab.getDiscardAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().addClickListener(event -> discardDistAll(tab));
/* Add items container to the table. */
@@ -400,8 +398,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(DIST_NAME);
visibleColumnIds.add(DISCARD);
visibleColumnLabels.add(this.i18n.get("header.one.deletedist.table"));
visibleColumnLabels.add(this.i18n.get("header.second.deletedist.table"));
visibleColumnLabels.add(i18n.get("header.one.deletedist.table"));
visibleColumnLabels.add(i18n.get("header.second.deletedist.table"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
@@ -414,12 +412,12 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
/* Delete Distributions. */
private void deleteDistAll(final ConfirmationTab tab) {
final Long[] deletedIds = this.manageDistUIState.getDeletedDistributionList().stream()
.map(idName -> idName.getId()).toArray(Long[]::new);
if (null != this.manageDistUIState.getAssignedList() && !this.manageDistUIState.getAssignedList().isEmpty()) {
this.manageDistUIState.getDeletedDistributionList().forEach(distSetName -> {
if (this.manageDistUIState.getAssignedList().containsKey(distSetName)) {
this.manageDistUIState.getAssignedList().remove(distSetName);
final Long[] deletedIds = manageDistUIState.getDeletedDistributionList().stream().map(idName -> idName.getId())
.toArray(Long[]::new);
if (null != manageDistUIState.getAssignedList() && !manageDistUIState.getAssignedList().isEmpty()) {
manageDistUIState.getDeletedDistributionList().forEach(distSetName -> {
if (manageDistUIState.getAssignedList().containsKey(distSetName)) {
manageDistUIState.getAssignedList().remove(distSetName);
}
@@ -427,23 +425,23 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
}
this.dsManagement.deleteDistributionSet(deletedIds);
dsManagement.deleteDistributionSet(deletedIds);
addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ this.i18n.get("message.dist.deleted", deletedIds.length));
+ i18n.get("message.dist.deleted", deletedIds.length));
this.manageDistUIState.getDeletedDistributionList()
.forEach(deletedIdname -> this.manageDistUIState.getAssignedList().remove(deletedIdname));
manageDistUIState.getDeletedDistributionList()
.forEach(deletedIdname -> manageDistUIState.getAssignedList().remove(deletedIdname));
removeCurrentTab(tab);
this.manageDistUIState.getDeletedDistributionList().clear();
this.eventBus.publish(this, SaveActionWindowEvent.DELETED_DISTRIBUTIONS);
manageDistUIState.getDeletedDistributionList().clear();
eventBus.publish(this, SaveActionWindowEvent.DELETED_DISTRIBUTIONS);
}
private void discardDistAll(final ConfirmationTab tab) {
removeCurrentTab(tab);
this.manageDistUIState.getDeletedDistributionList().clear();
setActionMessage(this.i18n.get("message.dist.discard.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DISTRIBUTIONS);
manageDistUIState.getDeletedDistributionList().clear();
setActionMessage(i18n.get("message.dist.discard.success"));
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DISTRIBUTIONS);
}
@@ -452,7 +450,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
contactContainer.addContainerProperty(DIST_ID_NAME, DistributionSetIdName.class, "");
contactContainer.addContainerProperty(DIST_NAME, String.class, "");
Item item;
for (final DistributionSetIdName distIdName : this.manageDistUIState.getDeletedDistributionList()) {
for (final DistributionSetIdName distIdName : manageDistUIState.getDeletedDistributionList()) {
item = contactContainer.addItem(distIdName);
item.getItemProperty(DIST_NAME).setValue(distIdName.getName().concat(":" + distIdName.getVersion()));
}
@@ -463,18 +461,18 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private void discardDistDelete(final Button.ClickEvent event, final Object itemId, final ConfirmationTab tab) {
final DistributionSetIdName distId = (DistributionSetIdName) ((Button) event.getComponent()).getData();
if (null != this.manageDistUIState.getDeletedDistributionList()
&& !this.manageDistUIState.getDeletedDistributionList().isEmpty()
&& this.manageDistUIState.getDeletedDistributionList().contains(distId)) {
this.manageDistUIState.getDeletedDistributionList().remove(distId);
if (null != manageDistUIState.getDeletedDistributionList()
&& !manageDistUIState.getDeletedDistributionList().isEmpty()
&& manageDistUIState.getDeletedDistributionList().contains(distId)) {
manageDistUIState.getDeletedDistributionList().remove(distId);
}
tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size();
if (0 == deleteCount) {
removeCurrentTab(tab);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DISTRIBUTIONS);
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DISTRIBUTIONS);
} else {
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_DEL_DISTRIBUTION);
eventBus.publish(this, SaveActionWindowEvent.DISCARD_DEL_DISTRIBUTION);
}
}
@@ -485,10 +483,10 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
tab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_DELETE_DIST_SET_TYPE);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().addClickListener(event -> deleteDistSetTypeAll(tab));
tab.getDiscardAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_DIST_SET_TYPE);
tab.getDiscardAll().addClickListener(event -> discardDistSetTypeAll(tab));
@@ -515,8 +513,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(DIST_SET_NAME);
visibleColumnIds.add(DISCARD);
visibleColumnLabels.add(this.i18n.get("header.first.delete.dist.type.table"));
visibleColumnLabels.add(this.i18n.get("header.second.delete.dist.type.table"));
visibleColumnLabels.add(i18n.get("header.first.delete.dist.type.table"));
visibleColumnLabels.add(i18n.get("header.second.delete.dist.type.table"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
@@ -530,32 +528,31 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private void deleteDistSetTypeAll(final ConfirmationTab tab) {
final int deleteDistTypeCount = this.manageDistUIState.getSelectedDeleteDistSetTypes().size();
for (final String deleteDistTypeName : this.manageDistUIState.getSelectedDeleteDistSetTypes()) {
final int deleteDistTypeCount = manageDistUIState.getSelectedDeleteDistSetTypes().size();
for (final String deleteDistTypeName : manageDistUIState.getSelectedDeleteDistSetTypes()) {
this.dsManagement
.deleteDistributionSetType(this.dsManagement.findDistributionSetTypeByName(deleteDistTypeName));
dsManagement.deleteDistributionSetType(dsManagement.findDistributionSetTypeByName(deleteDistTypeName));
}
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ this.i18n.get("message.dist.type.delete", new Object[] { deleteDistTypeCount }));
this.manageDistUIState.getSelectedDeleteDistSetTypes().clear();
+ i18n.get("message.dist.type.delete", new Object[] { deleteDistTypeCount }));
manageDistUIState.getSelectedDeleteDistSetTypes().clear();
removeCurrentTab(tab);
setActionMessage(this.i18n.get("message.dist.set.type.deleted.success"));
this.eventBus.publish(this, SaveActionWindowEvent.SAVED_DELETE_DIST_SET_TYPES);
setActionMessage(i18n.get("message.dist.set.type.deleted.success"));
eventBus.publish(this, SaveActionWindowEvent.SAVED_DELETE_DIST_SET_TYPES);
}
private void discardDistSetTypeAll(final ConfirmationTab tab) {
removeCurrentTab(tab);
this.manageDistUIState.getSelectedDeleteDistSetTypes().clear();
setActionMessage(this.i18n.get("message.dist.type.discard.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_DIST_SET_TYPES);
manageDistUIState.getSelectedDeleteDistSetTypes().clear();
setActionMessage(i18n.get("message.dist.type.discard.success"));
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_DIST_SET_TYPES);
}
private IndexedContainer getDistSetTypeTableContainer() {
final IndexedContainer contactContainer = new IndexedContainer();
contactContainer.addContainerProperty(DIST_SET_NAME, String.class, "");
for (final String distTypeMName : this.manageDistUIState.getSelectedDeleteDistSetTypes()) {
for (final String distTypeMName : manageDistUIState.getSelectedDeleteDistSetTypes()) {
final Item saveTblitem = contactContainer.addItem(distTypeMName);
saveTblitem.getItemProperty(DIST_SET_NAME).setValue(distTypeMName);
@@ -567,40 +564,40 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private void discardDistTypeDelete(final String discardDSType, final Object itemId, final ConfirmationTab tab) {
if (null != this.manageDistUIState.getSelectedDeleteDistSetTypes()
&& !this.manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()
&& this.manageDistUIState.getSelectedDeleteDistSetTypes().contains(discardDSType)) {
this.manageDistUIState.getSelectedDeleteDistSetTypes().remove(discardDSType);
if (null != manageDistUIState.getSelectedDeleteDistSetTypes()
&& !manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()
&& manageDistUIState.getSelectedDeleteDistSetTypes().contains(discardDSType)) {
manageDistUIState.getSelectedDeleteDistSetTypes().remove(discardDSType);
}
tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size();
if (0 == deleteCount) {
removeCurrentTab(tab);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_DIST_SET_TYPES);
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_DIST_SET_TYPES);
} else {
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_DELETE_DIST_SET_TYPE);
eventBus.publish(this, SaveActionWindowEvent.DISCARD_DELETE_DIST_SET_TYPE);
}
}
/* For Assign software modules */
private ConfirmationTab createAssignSWModuleConfirmationTab() {
this.assignmnetTab = new ConfirmationTab();
assignmnetTab = new ConfirmationTab();
this.assignmnetTab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_ASSIGNMENT);
this.assignmnetTab.getConfirmAll().setIcon(FontAwesome.SAVE);
this.assignmnetTab.getConfirmAll().setCaption(this.i18n.get("button.assign.all"));
this.assignmnetTab.getConfirmAll().addClickListener(event -> saveAllAssignments(this.assignmnetTab));
assignmnetTab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_ASSIGNMENT);
assignmnetTab.getConfirmAll().setIcon(FontAwesome.SAVE);
assignmnetTab.getConfirmAll().setCaption(i18n.get("button.assign.all"));
assignmnetTab.getConfirmAll().addClickListener(event -> saveAllAssignments(assignmnetTab));
this.assignmnetTab.getDiscardAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
this.assignmnetTab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_ASSIGNMENT);
this.assignmnetTab.getDiscardAll().addClickListener(event -> discardAllSWAssignments(this.assignmnetTab));
assignmnetTab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
assignmnetTab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_ASSIGNMENT);
assignmnetTab.getDiscardAll().addClickListener(event -> discardAllSWAssignments(assignmnetTab));
// Add items container to the table.
this.assignmnetTab.getTable().setContainerDataSource(getSWAssignmentsTableContainer());
assignmnetTab.getTable().setContainerDataSource(getSWAssignmentsTableContainer());
// Add the discard action column
this.assignmnetTab.getTable().addGeneratedColumn(DISCARD, (source, itemId, columnId) -> {
assignmnetTab.getTable().addGeneratedColumn(DISCARD, (source, itemId, columnId) -> {
final StringBuilder style = new StringBuilder(ValoTheme.BUTTON_TINY);
style.append(' ');
style.append(SPUIStyleDefinitions.REDICON);
@@ -609,7 +606,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
deleteIcon.setData(itemId);
deleteIcon.setImmediate(true);
deleteIcon.addClickListener(event -> discardSWAssignment((String) ((Button) event.getComponent()).getData(),
itemId, this.assignmnetTab));
itemId, assignmnetTab));
return deleteIcon;
});
@@ -620,19 +617,19 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
visibleColumnIds.add(DIST_NAME);
visibleColumnIds.add(SOFTWARE_MODULE_NAME);
visibleColumnIds.add(DISCARD);
visibleColumnLabels.add(this.i18n.get("header.dist.first.assignment.table"));
visibleColumnLabels.add(this.i18n.get("header.dist.second.assignment.table"));
visibleColumnLabels.add(this.i18n.get("header.third.assignment.table"));
visibleColumnLabels.add(i18n.get("header.dist.first.assignment.table"));
visibleColumnLabels.add(i18n.get("header.dist.second.assignment.table"));
visibleColumnLabels.add(i18n.get("header.third.assignment.table"));
}
this.assignmnetTab.getTable().setVisibleColumns(visibleColumnIds.toArray());
this.assignmnetTab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
assignmnetTab.getTable().setVisibleColumns(visibleColumnIds.toArray());
assignmnetTab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
this.assignmnetTab.getTable().setColumnExpandRatio(DIST_NAME, 2);
this.assignmnetTab.getTable().setColumnExpandRatio(SOFTWARE_MODULE_NAME, 2);
this.assignmnetTab.getTable().setColumnExpandRatio(DISCARD, SPUIDefinitions.DISCARD_COLUMN_WIDTH);
this.assignmnetTab.getTable().setColumnAlignment(DISCARD, Align.CENTER);
return this.assignmnetTab;
assignmnetTab.getTable().setColumnExpandRatio(DIST_NAME, 2);
assignmnetTab.getTable().setColumnExpandRatio(SOFTWARE_MODULE_NAME, 2);
assignmnetTab.getTable().setColumnExpandRatio(DISCARD, SPUIDefinitions.DISCARD_COLUMN_WIDTH);
assignmnetTab.getTable().setColumnAlignment(DISCARD, Align.CENTER);
return assignmnetTab;
}
@@ -644,7 +641,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
contactContainer.addContainerProperty(DIST_ID_NAME, DistributionSetIdName.class, "");
contactContainer.addContainerProperty(SOFTWARE_MODULE_ID_NAME, SoftwareModuleIdName.class, "");
final Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> assignedList = this.manageDistUIState
final Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> assignedList = manageDistUIState
.getAssignedList();
assignedList.forEach((distIdname, softIdNameSet) -> softIdNameSet.forEach(softIdName -> {
@@ -663,38 +660,38 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
}
private void saveAllAssignments(final ConfirmationTab tab) {
this.manageDistUIState.getAssignedList().forEach((distIdName, softIdNameSet) -> {
manageDistUIState.getAssignedList().forEach((distIdName, softIdNameSet) -> {
final DistributionSet ds = this.dsManagement.findDistributionSetByIdWithDetails(distIdName.getId());
final DistributionSet ds = dsManagement.findDistributionSetByIdWithDetails(distIdName.getId());
final List<Long> softIds = softIdNameSet.stream().map(softIdName -> softIdName.getId())
.collect(Collectors.toList());
final List<SoftwareModule> softwareModules = this.softwareManagement.findSoftwareModulesById(softIds);
final List<SoftwareModule> softwareModules = softwareManagement.findSoftwareModulesById(softIds);
softwareModules.forEach(ds::addModule);
this.dsManagement.updateDistributionSet(ds);
dsManagement.updateDistributionSet(ds);
});
int count = 0;
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entry : this.manageDistUIState
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entry : manageDistUIState
.getAssignedList().entrySet()) {
count += entry.getValue().size();
}
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ this.i18n.get("message.software.assignment", new Object[] { count }));
this.manageDistUIState.getAssignedList().clear();
this.manageDistUIState.getConsolidatedDistSoftwarewList().clear();
+ i18n.get("message.software.assignment", new Object[] { count }));
manageDistUIState.getAssignedList().clear();
manageDistUIState.getConsolidatedDistSoftwarewList().clear();
removeCurrentTab(tab);
this.eventBus.publish(this, SaveActionWindowEvent.SAVED_ASSIGNMENTS);
eventBus.publish(this, SaveActionWindowEvent.SAVED_ASSIGNMENTS);
}
private void discardAllSWAssignments(final ConfirmationTab tab) {
removeCurrentTab(tab);
this.manageDistUIState.getAssignedList().clear();
this.manageDistUIState.getConsolidatedDistSoftwarewList().clear();
setActionMessage(this.i18n.get("message.assign.discard.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS);
manageDistUIState.getAssignedList().clear();
manageDistUIState.getConsolidatedDistSoftwarewList().clear();
setActionMessage(i18n.get("message.assign.discard.success"));
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS);
}
private void discardSWAssignment(final String discardSW, final Object itemId, final ConfirmationTab tab) {
@@ -705,23 +702,23 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
final SoftwareModuleIdName discardSoftIdName = (SoftwareModuleIdName) rowitem
.getItemProperty(SOFTWARE_MODULE_ID_NAME).getValue();
final Set<SoftwareModuleIdName> softIdNameSet = this.manageDistUIState.getAssignedList().get(discardDistIdName);
this.manageDistUIState.getAssignedList().get(discardDistIdName).remove(discardSoftIdName);
final Set<SoftwareModuleIdName> softIdNameSet = manageDistUIState.getAssignedList().get(discardDistIdName);
manageDistUIState.getAssignedList().get(discardDistIdName).remove(discardSoftIdName);
softIdNameSet.remove(discardSoftIdName);
tab.getTable().getContainerDataSource().removeItem(itemId);
if (softIdNameSet.isEmpty()) {
this.manageDistUIState.getAssignedList().remove(discardDistIdName);
manageDistUIState.getAssignedList().remove(discardDistIdName);
}
final Map<Long, HashSet<SoftwareModuleIdName>> map = this.manageDistUIState.getConsolidatedDistSoftwarewList()
final Map<Long, HashSet<SoftwareModuleIdName>> map = manageDistUIState.getConsolidatedDistSoftwarewList()
.get(discardDistIdName);
map.keySet().forEach(typeId -> map.get(typeId).remove(discardSoftIdName));
final int assigCount = tab.getTable().getContainerDataSource().size();
if (0 == assigCount) {
removeCurrentTab(tab);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS);
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS);
} else {
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ASSIGNMENT);
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ASSIGNMENT);
}
}

View File

@@ -78,14 +78,14 @@ public class ManageDistUIState implements Serializable {
* @return the manageDistFilters
*/
public ManageDistFilters getManageDistFilters() {
return this.manageDistFilters;
return manageDistFilters;
}
/**
* @return the deletedDistributionList
*/
public Set<DistributionSetIdName> getDeletedDistributionList() {
return this.deletedDistributionList;
return deletedDistributionList;
}
/**
@@ -94,21 +94,21 @@ public class ManageDistUIState implements Serializable {
* @return the assignedList
*/
public Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> getAssignedList() {
return this.assignedList;
return assignedList;
}
/**
* @return the slectedDistributions
*/
public Optional<Set<DistributionSetIdName>> getSelectedDistributions() {
return this.selectedDistributions == null ? Optional.empty() : Optional.of(this.selectedDistributions);
return selectedDistributions == null ? Optional.empty() : Optional.of(selectedDistributions);
}
/**
* @return the lastSelectedDistribution
*/
public Optional<DistributionSetIdName> getLastSelectedDistribution() {
return this.lastSelectedDistribution == null ? Optional.empty() : Optional.of(this.lastSelectedDistribution);
return lastSelectedDistribution == null ? Optional.empty() : Optional.of(lastSelectedDistribution);
}
/**
@@ -120,28 +120,28 @@ public class ManageDistUIState implements Serializable {
}
public void setSelectedDistributions(final Set<DistributionSetIdName> slectedDistributions) {
this.selectedDistributions = slectedDistributions;
selectedDistributions = slectedDistributions;
}
/**
* @return the softwareModuleFilters
*/
public ManageSoftwareModuleFilters getSoftwareModuleFilters() {
return this.softwareModuleFilters;
return softwareModuleFilters;
}
/**
* @return the selectedSoftwareModules
*/
public Set<Long> getSelectedSoftwareModules() {
return this.selectedSoftwareModules;
return selectedSoftwareModules;
}
/**
* @return the selectedBaseSwModuleId
*/
public Optional<Long> getSelectedBaseSwModuleId() {
return this.selectedBaseSwModuleId != null ? Optional.of(this.selectedBaseSwModuleId) : Optional.empty();
return selectedBaseSwModuleId != null ? Optional.of(selectedBaseSwModuleId) : Optional.empty();
}
/**
@@ -164,7 +164,7 @@ public class ManageDistUIState implements Serializable {
* @return the distTypeFilterClosed
*/
public boolean isDistTypeFilterClosed() {
return this.distTypeFilterClosed;
return distTypeFilterClosed;
}
/**
@@ -179,7 +179,7 @@ public class ManageDistUIState implements Serializable {
* @return the swTypeFilterClosed
*/
public boolean isSwTypeFilterClosed() {
return this.swTypeFilterClosed;
return swTypeFilterClosed;
}
/**
@@ -194,11 +194,11 @@ public class ManageDistUIState implements Serializable {
* @return the deleteSofwareModulesList
*/
public Map<Long, String> getDeleteSofwareModulesList() {
return this.deleteSofwareModulesList;
return deleteSofwareModulesList;
}
public Set<String> getSelectedDeleteDistSetTypes() {
return this.selectedDeleteDistSetTypes;
return selectedDeleteDistSetTypes;
}
public void setSelectedDeleteDistSetTypes(final Set<String> selectedDeleteDistSetTypes) {
@@ -206,7 +206,7 @@ public class ManageDistUIState implements Serializable {
}
public Set<String> getSelectedDeleteSWModuleTypes() {
return this.selectedDeleteSWModuleTypes;
return selectedDeleteSWModuleTypes;
}
public void setSelectedDeleteSWModuleTypes(final Set<String> selectedDeleteSWModuleTypes) {
@@ -219,7 +219,7 @@ public class ManageDistUIState implements Serializable {
* @return boolean
*/
public boolean isDsTableMaximized() {
return this.isDsTableMaximized;
return isDsTableMaximized;
}
/***
@@ -228,18 +228,18 @@ public class ManageDistUIState implements Serializable {
* @param isDsModuleTableMaximized
*/
public void setDsTableMaximized(final boolean isDsModuleTableMaximized) {
this.isDsTableMaximized = isDsModuleTableMaximized;
isDsTableMaximized = isDsModuleTableMaximized;
}
public Map<String, SoftwareModuleIdName> getAssignedSoftwareModuleDetails() {
return this.assignedSoftwareModuleDetails;
return assignedSoftwareModuleDetails;
}
/**
* @return the isSwModuleTableMaximized
*/
public boolean isSwModuleTableMaximized() {
return this.isSwModuleTableMaximized;
return isSwModuleTableMaximized;
}
/**
@@ -254,7 +254,7 @@ public class ManageDistUIState implements Serializable {
* @return the noDataAvilableSwModule
*/
public boolean isNoDataAvilableSwModule() {
return this.noDataAvilableSwModule;
return noDataAvilableSwModule;
}
/**
@@ -269,7 +269,7 @@ public class ManageDistUIState implements Serializable {
* @return the noDataAvailableDist
*/
public boolean isNoDataAvailableDist() {
return this.noDataAvailableDist;
return noDataAvailableDist;
}
/**
@@ -286,7 +286,7 @@ public class ManageDistUIState implements Serializable {
* @return map
*/
public Map<DistributionSetIdName, HashMap<Long, HashSet<SoftwareModuleIdName>>> getConsolidatedDistSoftwarewList() {
return this.consolidatedDistSoftwarewList;
return consolidatedDistSoftwarewList;
}
}

View File

@@ -53,7 +53,7 @@ public class HawkbitLoginUI extends DefaultHawkbitUI {
@Override
protected void init(final VaadinRequest request) {
SpringContextHelper.setContext(this.context);
SpringContextHelper.setContext(context);
final VerticalLayout rootLayout = new VerticalLayout();
final Component header = buildHeader();
@@ -69,7 +69,7 @@ public class HawkbitLoginUI extends DefaultHawkbitUI {
rootLayout.setExpandRatio(header, 1.0F);
rootLayout.setExpandRatio(content, 2.0F);
final Resource resource = this.context
final Resource resource = context
.getResource("classpath:/VAADIN/themes/" + UI.getCurrent().getTheme() + "/layouts/footer.html");
try {
final CustomLayout customLayout = new CustomLayout(resource.getInputStream());
@@ -81,7 +81,7 @@ public class HawkbitLoginUI extends DefaultHawkbitUI {
setContent(rootLayout);
final Navigator navigator = new Navigator(this, content);
navigator.addProvider(this.viewProvider);
navigator.addProvider(viewProvider);
setNavigator(navigator);
}

View File

@@ -106,21 +106,21 @@ public class ActionHistoryTable extends TreeTable implements Handler {
*/
@PostConstruct
public void init() {
this.actionCancel = new com.vaadin.event.Action(this.i18n.get("message.cancel.action"));
this.actionForceQuit = new com.vaadin.event.Action(this.i18n.get("message.forcequit.action"));
this.actionForceQuit.setIcon(FontAwesome.WARNING);
this.actionForce = new com.vaadin.event.Action(this.i18n.get("message.force.action"));
actionCancel = new com.vaadin.event.Action(i18n.get("message.cancel.action"));
actionForceQuit = new com.vaadin.event.Action(i18n.get("message.forcequit.action"));
actionForceQuit.setIcon(FontAwesome.WARNING);
actionForce = new com.vaadin.event.Action(i18n.get("message.force.action"));
initializeTableSettings();
buildComponent();
restorePreviousState();
setVisibleColumns(getVisbleColumns().toArray());
this.eventBus.subscribe(this);
eventBus.subscribe(this);
setPageLength(SPUIDefinitions.PAGE_SIZE);
}
@PreDestroy
void destroy() {
this.eventBus.unsubscribe(this);
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -140,7 +140,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
private void buildComponent() {
// create an empty container
createContainer();
setContainerDataSource(this.hierarchicalContainer);
setContainerDataSource(hierarchicalContainer);
addGeneratedColumns();
setColumnExpandRatioForMinimisedTable();
}
@@ -171,11 +171,11 @@ public class ActionHistoryTable extends TreeTable implements Handler {
// listeners for child
addExpandListener(event -> {
expandParentActionRow(event.getItemId());
this.managementUIState.getExpandParentActionRowId().add(event.getItemId());
managementUIState.getExpandParentActionRowId().add(event.getItemId());
});
addCollapseListener(event -> {
collapseParentActionRow(event.getItemId());
this.managementUIState.getExpandParentActionRowId().remove(event.getItemId());
managementUIState.getExpandParentActionRowId().remove(event.getItemId());
});
/*
* Add the cancel action handler for active actions. To be used to
@@ -189,20 +189,17 @@ public class ActionHistoryTable extends TreeTable implements Handler {
*/
public void createContainer() {
/* Create HierarchicalContainer container */
this.hierarchicalContainer = new HierarchicalContainer();
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN, String.class,
null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED, Action.class, null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN, Long.class,
null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID, String.class, null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST, String.class, null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME, String.class, null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN,
Action.Status.class, null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_MSGS_HIDDEN, List.class, null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME, String.class,
hierarchicalContainer = new HierarchicalContainer();
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN, String.class, null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED, Action.class, null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN, Long.class, null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID, String.class, null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST, String.class, null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME, String.class, null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN, Action.Status.class,
null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_MSGS_HIDDEN, List.class, null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME, String.class, null);
}
/**
@@ -220,7 +217,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_DATETIME);
visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_STATUS);
visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_FORCED);
if (this.managementUIState.isActionHistoryMaximized()) {
if (managementUIState.isActionHistoryMaximized()) {
visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME);
visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_MSGS);
visibleColumnIds.add(1, SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID);
@@ -235,7 +232,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* reference of target
*/
public void populateTableData(final Target selectedTarget) {
this.target = selectedTarget;
target = selectedTarget;
refreshContainer();
}
@@ -248,10 +245,10 @@ public class ActionHistoryTable extends TreeTable implements Handler {
}
private void getcontainerData() {
this.hierarchicalContainer.removeAllItems();
hierarchicalContainer.removeAllItems();
/* service method to create action history for target */
final List<ActionWithStatusCount> actionHistory = this.deploymentManagement
.findActionsWithStatusCountByTargetOrderByIdDesc(this.target);
final List<ActionWithStatusCount> actionHistory = deploymentManagement
.findActionsWithStatusCountByTargetOrderByIdDesc(target);
addDetailsToContainer(actionHistory);
}
@@ -276,7 +273,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
final Action action = actionWithStatusCount.getAction();
final Item item = this.hierarchicalContainer.addItem(actionWithStatusCount.getActionId());
final Item item = hierarchicalContainer.addItem(actionWithStatusCount.getActionId());
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN)
.setValue(actionWithStatusCount.getActionStatus());
@@ -309,7 +306,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).setValue(action);
/* Default no child */
((Hierarchical) this.hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), false);
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), false);
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME)
.setValue(SPDateTimeUtil.getFormattedDate((actionWithStatusCount.getActionLastModifiedAt() != null)
@@ -320,8 +317,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
.setValue(actionWithStatusCount.getRolloutName());
if (actionWithStatusCount.getActionStatusCount() > 0) {
((Hierarchical) this.hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(),
true);
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), true);
}
}
}
@@ -362,7 +358,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* @return
*/
private Component getForcedColumn(final Object itemId) {
final Action actionWithActiveStatus = (Action) this.hierarchicalContainer.getItem(itemId)
final Action actionWithActiveStatus = (Action) hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).getValue();
final Label actionLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
actionLabel.setContentMode(ContentMode.HTML);
@@ -382,19 +378,19 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* @return
*/
private Component getActiveColumn(final Object itemId) {
final Action.Status status = (Action.Status) this.hierarchicalContainer.getItem(itemId)
final Action.Status status = (Action.Status) hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).getValue();
String activeValue;
if (status == Action.Status.SCHEDULED) {
activeValue = Action.Status.SCHEDULED.toString().toLowerCase();
} else {
activeValue = (String) this.hierarchicalContainer.getItem(itemId)
activeValue = (String) hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).getValue();
}
final String distName = (String) this.hierarchicalContainer.getItem(itemId)
final String distName = (String) hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).getValue();
final Label activeStatusIcon = createActiveStatusLabel(activeValue,
(Action.Status) this.hierarchicalContainer.getItem(itemId)
(Action.Status) hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN)
.getValue() == Action.Status.ERROR);
activeStatusIcon.setId(new StringJoiner(".").add(distName).add(itemId.toString())
@@ -407,7 +403,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* @return
*/
private Component getStatusColumn(final Object itemId) {
final Action.Status status = (Action.Status) this.hierarchicalContainer.getItem(itemId)
final Action.Status status = (Action.Status) hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).getValue();
return getStatusIcon(status);
}
@@ -422,17 +418,17 @@ public class ActionHistoryTable extends TreeTable implements Handler {
@SuppressWarnings("unchecked")
private void expandParentActionRow(final Object parentRowIdx) {
/* Get the item for which the expand is made */
final Item item = this.hierarchicalContainer.getItem(parentRowIdx);
final Item item = hierarchicalContainer.getItem(parentRowIdx);
if (null != item) {
final Long actionId = (Long) item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN)
.getValue();
final org.eclipse.hawkbit.repository.model.Action action = this.deploymentManagement
final org.eclipse.hawkbit.repository.model.Action action = deploymentManagement
.findActionWithDetails(actionId);
final Pageable pageReq = new PageRequest(0, 1000);
final Page<ActionStatus> actionStatusList = this.deploymentManagement
final Page<ActionStatus> actionStatusList = deploymentManagement
.findActionStatusMessagesByActionInDescOrder(pageReq, action,
this.managementUIState.isActionHistoryMaximized());
managementUIState.isActionHistoryMaximized());
final List<ActionStatus> content = actionStatusList.getContent();
/*
* Since the recent action status and messages are already
@@ -442,7 +438,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
int childIdx = 1;
for (final ActionStatus actionStatus : content) {
final String childId = parentRowIdx + " -> " + childIdx;
final Item childItem = this.hierarchicalContainer.addItem(childId);
final Item childItem = hierarchicalContainer.addItem(childId);
if (null != childItem) {
/*
* For better UI, no need to display active/inactive icon
@@ -460,9 +456,9 @@ public class ActionHistoryTable extends TreeTable implements Handler {
.setValue(actionStatus.getStatus());
showOrHideMessage(childItem, actionStatus);
/* No further child items allowed for the child items */
((Hierarchical) this.hierarchicalContainer).setChildrenAllowed(childId, false);
((Hierarchical) hierarchicalContainer).setChildrenAllowed(childId, false);
/* Assign this childItem to the parent */
((Hierarchical) this.hierarchicalContainer).setParent(childId, parentRowIdx);
((Hierarchical) hierarchicalContainer).setParent(childId, parentRowIdx);
childIdx++;
}
@@ -478,12 +474,12 @@ public class ActionHistoryTable extends TreeTable implements Handler {
*/
public void collapseParentActionRow(final Object parentRowIdx) {
/* Remove all child items for the clear the memory. */
final Collection<?> children = ((Hierarchical) this.hierarchicalContainer).getChildren(parentRowIdx);
final Collection<?> children = ((Hierarchical) hierarchicalContainer).getChildren(parentRowIdx);
if (children != null && !children.isEmpty()) {
String ids = children.toString().substring(1);
ids = ids.substring(0, ids.length() - 1);
for (final String childId : ids.split(", ")) {
((Hierarchical) this.hierarchicalContainer).removeItem(childId);
((Hierarchical) hierarchicalContainer).removeItem(childId);
}
}
}
@@ -500,42 +496,42 @@ public class ActionHistoryTable extends TreeTable implements Handler {
final String statusIconPending = "statusIconPending";
label.setContentMode(ContentMode.HTML);
if (Action.Status.FINISHED == status) {
label.setDescription(this.i18n.get("label.finished"));
label.setDescription(i18n.get("label.finished"));
label.setStyleName(STATUS_ICON_GREEN);
label.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
} else if (Action.Status.ERROR == status) {
label.setDescription(this.i18n.get("label.error"));
label.setDescription(i18n.get("label.error"));
label.setStyleName("statusIconRed");
label.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
} else if (Action.Status.WARNING == status) {
label.setStyleName("statusIconOrange");
label.setDescription(this.i18n.get("label.warning"));
label.setDescription(i18n.get("label.warning"));
label.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
} else if (Action.Status.RUNNING == status) {
// dynamic spinner
label.setStyleName(statusIconPending);
label.setDescription(this.i18n.get("label.running"));
label.setDescription(i18n.get("label.running"));
label.setValue(FontAwesome.ADJUST.getHtml());
} else if (Action.Status.CANCELING == status) {
label.setStyleName(statusIconPending);
label.setDescription(this.i18n.get("label.cancelling"));
label.setDescription(i18n.get("label.cancelling"));
label.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
} else if (Action.Status.CANCELED == status) {
label.setStyleName(statusIconPending);
label.setDescription(this.i18n.get("label.cancelled"));
label.setDescription(i18n.get("label.cancelled"));
label.setStyleName(STATUS_ICON_GREEN);
label.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
} else if (Action.Status.RETRIEVED == status) {
label.setStyleName(statusIconPending);
label.setDescription(this.i18n.get("label.retrieved"));
label.setDescription(i18n.get("label.retrieved"));
label.setValue(FontAwesome.CIRCLE_O.getHtml());
} else if (Action.Status.DOWNLOAD == status) {
label.setStyleName(statusIconPending);
label.setDescription(this.i18n.get("label.download"));
label.setDescription(i18n.get("label.download"));
label.setValue(FontAwesome.CLOUD_DOWNLOAD.getHtml());
} else if (Action.Status.SCHEDULED == status) {
label.setStyleName(statusIconPending);
label.setDescription(this.i18n.get("label.scheduled"));
label.setDescription(i18n.get("label.scheduled"));
label.setValue(FontAwesome.BULLSEYE.getHtml());
} else {
label.setDescription("");
@@ -565,10 +561,10 @@ public class ActionHistoryTable extends TreeTable implements Handler {
autoForceLabel.setDescription("autoforced");
autoForceLabel.setStyleName(STATUS_ICON_GREEN);
autoForceLabel.setDescription("auto forced since " + SPDateTimeUtil
.getDurationFormattedString(actionWithActiveStatus.getForcedTime(), currentTimeMillis, this.i18n));
.getDurationFormattedString(actionWithActiveStatus.getForcedTime(), currentTimeMillis, i18n));
} else {
autoForceLabel.setDescription("auto forcing in " + SPDateTimeUtil
.getDurationFormattedString(currentTimeMillis, actionWithActiveStatus.getForcedTime(), this.i18n));
.getDurationFormattedString(currentTimeMillis, actionWithActiveStatus.getForcedTime(), i18n));
autoForceLabel.setStyleName("statusIconPending");
autoForceLabel.setValue(FontAwesome.HISTORY.getHtml());
}
@@ -610,7 +606,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
*/
private void createTableContentForMax() {
setColumnCollapsingAllowed(true);
if (!this.alreadyHasMessages) {
if (!alreadyHasMessages) {
/*
* check to avoid DB call for fetching the messages again and again
* if already available in container.
@@ -618,7 +614,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
getcontainerData();
// to expand parent row , if already expanded.
expandParentRow();
this.alreadyHasMessages = true;
alreadyHasMessages = true;
}
addGeneratedColumn(SPUIDefinitions.ACTION_HIS_TBL_MSGS, new Table.ColumnGenerator() {
@@ -627,8 +623,8 @@ public class ActionHistoryTable extends TreeTable implements Handler {
@SuppressWarnings("unchecked")
@Override
public Component generateCell(final Table source, final Object itemId, final Object columnId) {
final List<String> messages = (List<String>) ActionHistoryTable.this.hierarchicalContainer
.getItem(itemId).getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_MSGS_HIDDEN).getValue();
final List<String> messages = (List<String>) hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_MSGS_HIDDEN).getValue();
return createMessagesBlock(messages);
}
});
@@ -672,7 +668,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
}
} else {
/* Messages are not available */
updateStatusMessages.append(this.i18n.get("message.no.available"));
updateStatusMessages.append(i18n.get("message.no.available"));
}
textArea.setValue(updateStatusMessages.toString());
textArea.setReadOnly(Boolean.TRUE);
@@ -691,7 +687,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
*/
@SuppressWarnings("unchecked")
private void showOrHideMessage(final Item childItem, final ActionStatus actionStatus) {
if (this.managementUIState.isActionHistoryMaximized()) {
if (managementUIState.isActionHistoryMaximized()) {
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_MSGS_HIDDEN).setValue(actionStatus.getMessages());
}
}
@@ -701,7 +697,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
*/
private void normalActionHistoryTable() {
setColumnCollapsingAllowed(false);
this.managementUIState.setActionHistoryMaximized(false);
managementUIState.setActionHistoryMaximized(false);
removeGeneratedColumn(SPUIDefinitions.ACTION_HIS_TBL_MSGS);
setVisibleColumns(getVisbleColumns().toArray());
setColumnExpandRatioForMinimisedTable();
@@ -710,15 +706,15 @@ public class ActionHistoryTable extends TreeTable implements Handler {
@Override
public void handleAction(final com.vaadin.event.Action action, final Object sender, final Object target) {
/* Get the actionId details of the cancel item or row */
final Item item = this.hierarchicalContainer.getItem(target);
final Item item = hierarchicalContainer.getItem(target);
final Long actionId = (Long) item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN).getValue();
if (action.equals(this.actionCancel)) {
if (action.equals(actionCancel)) {
if (actionId != null) {
confirmAndCancelAction(actionId);
}
} else if (action.equals(this.actionForce)) {
} else if (action.equals(actionForce)) {
confirmAndForceAction(actionId);
} else if (action.equals(this.actionForceQuit)) {
} else if (action.equals(actionForceQuit)) {
confirmAndForceQuitAction(actionId);
}
}
@@ -728,18 +724,18 @@ public class ActionHistoryTable extends TreeTable implements Handler {
final List<com.vaadin.event.Action> actions = Lists.newArrayList();
if (target != null) {
/* Check if the row or item belongs to active action */
final String activeValue = (String) this.hierarchicalContainer.getItem(target)
final String activeValue = (String) hierarchicalContainer.getItem(target)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).getValue();
if (SPUIDefinitions.ACTIVE.equals(activeValue)) {
final Action actionWithActiveStatus = (Action) this.hierarchicalContainer.getItem(target)
final Action actionWithActiveStatus = (Action) hierarchicalContainer.getItem(target)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).getValue();
if (!actionWithActiveStatus.isForce()) {
actions.add(this.actionForce);
actions.add(actionForce);
}
if (!actionWithActiveStatus.isCancelingOrCanceled()) {
actions.add(this.actionCancel);
actions.add(actionCancel);
} else {
actions.add(this.actionForceQuit);
actions.add(actionForceQuit);
}
}
@@ -755,12 +751,11 @@ public class ActionHistoryTable extends TreeTable implements Handler {
*/
private void confirmAndForceAction(final Long actionId) {
/* Display the confirmation */
final ConfirmationDialog confirmDialog = new ConfirmationDialog(
this.i18n.get("caption.force.action.confirmbox"), this.i18n.get("message.force.action.confirm"),
this.i18n.get("button.ok"), this.i18n.get("button.cancel"), ok -> {
final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.force.action.confirmbox"),
i18n.get("message.force.action.confirm"), i18n.get("button.ok"), i18n.get("button.cancel"), ok -> {
if (ok) {
/* cancel the action */
this.deploymentManagement.forceTargetAction(actionId);
deploymentManagement.forceTargetAction(actionId);
/*
* Refresh the action history table to show latest
@@ -768,8 +763,8 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* Target Details
*/
populateAndupdateTargetDetails(this.target);
this.notification.displaySuccess(this.i18n.get("message.force.action.success"));
populateAndupdateTargetDetails(target);
notification.displaySuccess(i18n.get("message.force.action.success"));
}
});
UI.getCurrent().addWindow(confirmDialog.getWindow());
@@ -778,9 +773,8 @@ public class ActionHistoryTable extends TreeTable implements Handler {
private void confirmAndForceQuitAction(final Long actionId) {
/* Display the confirmation */
final ConfirmationDialog confirmDialog = new ConfirmationDialog(
this.i18n.get("caption.forcequit.action.confirmbox"), this.i18n.get("message.forcequit.action.confirm"),
this.i18n.get("button.ok"), this.i18n.get("button.cancel"), ok -> {
final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.forcequit.action.confirmbox"),
i18n.get("message.forcequit.action.confirm"), i18n.get("button.ok"), i18n.get("button.cancel"), ok -> {
if (ok) {
final boolean cancelResult = forceQuitActiveAction(actionId);
if (cancelResult) {
@@ -789,10 +783,10 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* change of the action cancellation and update the
* Target Details
*/
populateAndupdateTargetDetails(this.target);
this.notification.displaySuccess(this.i18n.get("message.forcequit.action.success"));
populateAndupdateTargetDetails(target);
notification.displaySuccess(i18n.get("message.forcequit.action.success"));
} else {
this.notification.displayValidationError(this.i18n.get("message.forcequit.action.failed"));
notification.displayValidationError(i18n.get("message.forcequit.action.failed"));
}
}
} , FontAwesome.WARNING);
@@ -807,9 +801,8 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* as Id if the action needs to be cancelled.
*/
private void confirmAndCancelAction(final Long actionId) {
final ConfirmationDialog confirmDialog = new ConfirmationDialog(
this.i18n.get("caption.cancel.action.confirmbox"), this.i18n.get("message.cancel.action.confirm"),
this.i18n.get("button.ok"), this.i18n.get("button.cancel"), ok -> {
final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.cancel.action.confirmbox"),
i18n.get("message.cancel.action.confirm"), i18n.get("button.ok"), i18n.get("button.cancel"), ok -> {
if (ok) {
final boolean cancelResult = cancelActiveAction(actionId);
if (cancelResult) {
@@ -818,10 +811,10 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* change of the action cancellation and update the
* Target Details
*/
populateAndupdateTargetDetails(this.target);
this.notification.displaySuccess(this.i18n.get("message.cancel.action.success"));
populateAndupdateTargetDetails(target);
notification.displaySuccess(i18n.get("message.cancel.action.success"));
} else {
this.notification.displayValidationError(this.i18n.get("message.cancel.action.failed"));
notification.displayValidationError(i18n.get("message.cancel.action.failed"));
}
}
});
@@ -839,9 +832,9 @@ public class ActionHistoryTable extends TreeTable implements Handler {
// service call to cancel the active action
private boolean cancelActiveAction(final Long actionId) {
if (actionId != null) {
final Action activeAction = this.deploymentManagement.findAction(actionId);
final Action activeAction = deploymentManagement.findAction(actionId);
try {
this.deploymentManagement.cancelAction(activeAction, this.target);
deploymentManagement.cancelAction(activeAction, target);
return true;
} catch (final CancelActionNotAllowedException e) {
LOG.info("Cancel action not allowed exception :{}", e);
@@ -854,9 +847,9 @@ public class ActionHistoryTable extends TreeTable implements Handler {
// service call to cancel the active action
private boolean forceQuitActiveAction(final Long actionId) {
if (actionId != null) {
final Action activeAction = this.deploymentManagement.findAction(actionId);
final Action activeAction = deploymentManagement.findAction(actionId);
try {
this.deploymentManagement.forceQuitAction(activeAction, this.target);
deploymentManagement.forceQuitAction(activeAction, target);
return true;
} catch (final CancelActionNotAllowedException e) {
LOG.info("Force Cancel action not allowed exception :{}", e);
@@ -871,7 +864,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* Update the target status in the Target table and update the color
* settings for DS in DS table.
*/
this.eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.EDIT_TARGET, this.target));
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.EDIT_TARGET, target));
updateDistributionTableStyle();
}
@@ -881,13 +874,13 @@ public class ActionHistoryTable extends TreeTable implements Handler {
*/
private void updateDistributionTableStyle() {
if (this.managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()
&& null != this.managementUIState.getDistributionTableFilters().getPinnedTargetId().get()) {
final String alreadyPinnedControllerId = this.managementUIState.getDistributionTableFilters()
.getPinnedTargetId().get();
if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()
&& null != managementUIState.getDistributionTableFilters().getPinnedTargetId().get()) {
final String alreadyPinnedControllerId = managementUIState.getDistributionTableFilters().getPinnedTargetId()
.get();
// if the current target is pinned publish a pin event again
if (null != alreadyPinnedControllerId && alreadyPinnedControllerId.equals(this.target.getControllerId())) {
this.eventBus.publish(this, PinUnpinEvent.PIN_TARGET);
if (null != alreadyPinnedControllerId && alreadyPinnedControllerId.equals(target.getControllerId())) {
eventBus.publish(this, PinUnpinEvent.PIN_TARGET);
}
}
}
@@ -910,15 +903,15 @@ public class ActionHistoryTable extends TreeTable implements Handler {
}
private void restorePreviousState() {
if (this.managementUIState.isActionHistoryMaximized()) {
if (managementUIState.isActionHistoryMaximized()) {
createTableContentForMax();
}
}
private void expandParentRow() {
if (null != this.managementUIState.getExpandParentActionRowId()
&& !this.managementUIState.getExpandParentActionRowId().isEmpty()) {
for (final Object obj : this.managementUIState.getExpandParentActionRowId()) {
if (null != managementUIState.getExpandParentActionRowId()
&& !managementUIState.getExpandParentActionRowId().isEmpty()) {
for (final Object obj : managementUIState.getExpandParentActionRowId()) {
expandParentActionRow(obj);
}
}

View File

@@ -131,9 +131,9 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
final HorizontalLayout buttonsLayout = new HorizontalLayout();
buttonsLayout.setSizeFull();
buttonsLayout.setStyleName("dist-buttons-horz-layout");
buttonsLayout.addComponents(this.saveDistribution, this.discardDistribution);
buttonsLayout.setComponentAlignment(this.saveDistribution, Alignment.BOTTOM_LEFT);
buttonsLayout.setComponentAlignment(this.discardDistribution, Alignment.BOTTOM_RIGHT);
buttonsLayout.addComponents(saveDistribution, discardDistribution);
buttonsLayout.setComponentAlignment(saveDistribution, Alignment.BOTTOM_LEFT);
buttonsLayout.setComponentAlignment(discardDistribution, Alignment.BOTTOM_RIGHT);
buttonsLayout.addStyleName("window-style");
/*
@@ -143,11 +143,11 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
setSpacing(Boolean.TRUE);
addStyleName("lay-color");
setSizeUndefined();
addComponents(this.madatoryLabel, this.distsetTypeNameComboBox, this.distNameTextField,
this.distVersionTextField, this.descTextArea, this.reqMigStepCheckbox);
addComponents(madatoryLabel, distsetTypeNameComboBox, distNameTextField, distVersionTextField, descTextArea,
reqMigStepCheckbox);
addComponent(buttonsLayout);
setComponentAlignment(this.madatoryLabel, Alignment.MIDDLE_LEFT);
setComponentAlignment(madatoryLabel, Alignment.MIDDLE_LEFT);
}
@@ -155,45 +155,45 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
* Create required UI components.
*/
private void createRequiredComponents() {
this.distNameTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
this.i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
this.distNameTextField.setId(SPUIComponetIdProvider.DIST_ADD_NAME);
this.distNameTextField.setNullRepresentation("");
distNameTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
distNameTextField.setId(SPUIComponetIdProvider.DIST_ADD_NAME);
distNameTextField.setNullRepresentation("");
this.distVersionTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
this.i18n.get("textfield.version"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
this.distVersionTextField.setId(SPUIComponetIdProvider.DIST_ADD_VERSION);
this.distVersionTextField.setNullRepresentation("");
distVersionTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
i18n.get("textfield.version"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
distVersionTextField.setId(SPUIComponetIdProvider.DIST_ADD_VERSION);
distVersionTextField.setNullRepresentation("");
this.distsetTypeNameComboBox = SPUIComponentProvider.getComboBox("", "", null, "", false, "",
this.i18n.get("label.combobox.type"));
this.distsetTypeNameComboBox.setImmediate(true);
this.distsetTypeNameComboBox.setNullSelectionAllowed(false);
this.distsetTypeNameComboBox.setId(SPUIComponetIdProvider.DIST_ADD_DISTSETTYPE);
distsetTypeNameComboBox = SPUIComponentProvider.getComboBox("", "", null, "", false, "",
i18n.get("label.combobox.type"));
distsetTypeNameComboBox.setImmediate(true);
distsetTypeNameComboBox.setNullSelectionAllowed(false);
distsetTypeNameComboBox.setId(SPUIComponetIdProvider.DIST_ADD_DISTSETTYPE);
this.descTextArea = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTAREA_TINY, false, null,
this.i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
this.descTextArea.setId(SPUIComponetIdProvider.DIST_ADD_DESC);
this.descTextArea.setNullRepresentation("");
descTextArea = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTAREA_TINY, false, null,
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
descTextArea.setId(SPUIComponetIdProvider.DIST_ADD_DESC);
descTextArea.setNullRepresentation("");
/* Label for mandatory symbol */
this.madatoryLabel = new Label(this.i18n.get("label.mandatory.field"));
this.madatoryLabel.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR + " " + ValoTheme.LABEL_SMALL);
madatoryLabel = new Label(i18n.get("label.mandatory.field"));
madatoryLabel.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR + " " + ValoTheme.LABEL_SMALL);
this.reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(
this.i18n.get("checkbox.dist.required.migration.step"), "dist-checkbox-style", null, false, "");
this.reqMigStepCheckbox.addStyleName(ValoTheme.CHECKBOX_SMALL);
this.reqMigStepCheckbox.setId(SPUIComponetIdProvider.DIST_ADD_MIGRATION_CHECK);
reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(i18n.get("checkbox.dist.required.migration.step"),
"dist-checkbox-style", null, false, "");
reqMigStepCheckbox.addStyleName(ValoTheme.CHECKBOX_SMALL);
reqMigStepCheckbox.setId(SPUIComponetIdProvider.DIST_ADD_MIGRATION_CHECK);
/* save or update button */
this.saveDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_SAVE, "", "", "", true,
saveDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_SAVE, "", "", "", true,
FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class);
this.saveDistribution.addClickListener(event -> saveDistribution());
saveDistribution.addClickListener(event -> saveDistribution());
/* close button */
this.discardDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "",
true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
this.discardDistribution.addClickListener(event -> discardDistribution());
discardDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "", true,
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
discardDistribution.addClickListener(event -> discardDistribution());
}
/**
@@ -216,22 +216,22 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
}
private void enableSaveButton() {
this.saveDistribution.setEnabled(true);
saveDistribution.setEnabled(true);
}
private DistributionSetType getDefaultDistributionSetType() {
final TenantMetaData tenantMetaData = this.tenantMetaDataRepository
.findByTenantIgnoreCase(this.systemManagement.currentTenant());
final TenantMetaData tenantMetaData = tenantMetaDataRepository
.findByTenantIgnoreCase(systemManagement.currentTenant());
return tenantMetaData.getDefaultDsType();
}
private void disableSaveButton() {
this.saveDistribution.setEnabled(false);
saveDistribution.setEnabled(false);
}
private void saveDistribution() {
/* add new or update target */
if (this.editDistribution) {
if (editDistribution) {
updateDistribution();
} else {
addNewDistribution();
@@ -243,73 +243,71 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
* Update Distribution.
*/
private void updateDistribution() {
final String name = HawkbitCommonUtil.trimAndNullIfEmpty(this.distNameTextField.getValue());
final String version = HawkbitCommonUtil.trimAndNullIfEmpty(this.distVersionTextField.getValue());
final String name = HawkbitCommonUtil.trimAndNullIfEmpty(distNameTextField.getValue());
final String version = HawkbitCommonUtil.trimAndNullIfEmpty(distVersionTextField.getValue());
final String distSetTypeName = HawkbitCommonUtil
.trimAndNullIfEmpty((String) this.distsetTypeNameComboBox.getValue());
.trimAndNullIfEmpty((String) distsetTypeNameComboBox.getValue());
if (mandatoryCheck(name, version, distSetTypeName) && duplicateCheck(name, version)) {
final DistributionSet currentDS = this.distributionSetManagement
.findDistributionSetByIdWithDetails(this.editDistId);
final String desc = HawkbitCommonUtil.trimAndNullIfEmpty(this.descTextArea.getValue());
final boolean isMigStepReq = this.reqMigStepCheckbox.getValue();
final DistributionSet currentDS = distributionSetManagement.findDistributionSetByIdWithDetails(editDistId);
final String desc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
final boolean isMigStepReq = reqMigStepCheckbox.getValue();
/* identify the changes */
setDistributionValues(currentDS, name, version, distSetTypeName, desc, isMigStepReq);
try {
this.distributionSetManagement.updateDistributionSet(currentDS);
this.notificationMessage.displaySuccess(this.i18n.get("message.new.dist.save.success",
distributionSetManagement.updateDistributionSet(currentDS);
notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success",
new Object[] { currentDS.getName(), currentDS.getVersion() }));
// update table row+details layout
this.eventBus.publish(this,
eventBus.publish(this,
new DistributionTableEvent(DistributionComponentEvent.EDIT_DISTRIBUTION, currentDS));
} catch (final EntityAlreadyExistsException entityAlreadyExistsException) {
LOG.error("Update distribution failed {}", entityAlreadyExistsException);
this.notificationMessage.displayValidationError(this.i18n.get("message.distribution.no.update",
currentDS.getName() + ":" + currentDS.getVersion()));
notificationMessage.displayValidationError(
i18n.get("message.distribution.no.update", currentDS.getName() + ":" + currentDS.getVersion()));
}
closeThisWindow();
}
}
private void addListeners() {
this.reqMigStepCheckboxListerner = event -> checkValueChanged(this.originalReqMigStep, event);
this.descTextAreaListener = event -> checkValueChanged(this.originalDistDescription, event);
this.distNameTextFieldListener = event -> checkValueChanged(this.originalDistName, event);
this.distVersionTextFieldListener = event -> checkValueChanged(this.originalDistVersion, event);
this.distsetTypeNameComboBoxListener = event -> checkValueChanged(this.originalDistSetType, event);
this.reqMigStepCheckbox.addValueChangeListener(this.reqMigStepCheckboxListerner);
this.descTextArea.addTextChangeListener(this.descTextAreaListener);
this.distNameTextField.addTextChangeListener(this.distNameTextFieldListener);
this.distVersionTextField.addTextChangeListener(this.distVersionTextFieldListener);
this.distsetTypeNameComboBox.addValueChangeListener(this.distsetTypeNameComboBoxListener);
reqMigStepCheckboxListerner = event -> checkValueChanged(originalReqMigStep, event);
descTextAreaListener = event -> checkValueChanged(originalDistDescription, event);
distNameTextFieldListener = event -> checkValueChanged(originalDistName, event);
distVersionTextFieldListener = event -> checkValueChanged(originalDistVersion, event);
distsetTypeNameComboBoxListener = event -> checkValueChanged(originalDistSetType, event);
reqMigStepCheckbox.addValueChangeListener(reqMigStepCheckboxListerner);
descTextArea.addTextChangeListener(descTextAreaListener);
distNameTextField.addTextChangeListener(distNameTextFieldListener);
distVersionTextField.addTextChangeListener(distVersionTextFieldListener);
distsetTypeNameComboBox.addValueChangeListener(distsetTypeNameComboBoxListener);
}
/**
* Add new Distribution set.
*/
private void addNewDistribution() {
this.editDistribution = Boolean.FALSE;
final String name = HawkbitCommonUtil.trimAndNullIfEmpty(this.distNameTextField.getValue());
final String version = HawkbitCommonUtil.trimAndNullIfEmpty(this.distVersionTextField.getValue());
editDistribution = Boolean.FALSE;
final String name = HawkbitCommonUtil.trimAndNullIfEmpty(distNameTextField.getValue());
final String version = HawkbitCommonUtil.trimAndNullIfEmpty(distVersionTextField.getValue());
final String distSetTypeName = HawkbitCommonUtil
.trimAndNullIfEmpty((String) this.distsetTypeNameComboBox.getValue());
.trimAndNullIfEmpty((String) distsetTypeNameComboBox.getValue());
if (mandatoryCheck(name, version, distSetTypeName) && duplicateCheck(name, version)) {
final String desc = HawkbitCommonUtil.trimAndNullIfEmpty(this.descTextArea.getValue());
final boolean isMigStepReq = this.reqMigStepCheckbox.getValue();
final String desc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
final boolean isMigStepReq = reqMigStepCheckbox.getValue();
DistributionSet newDist = new DistributionSet();
setDistributionValues(newDist, name, version, distSetTypeName, desc, isMigStepReq);
newDist = this.distributionSetManagement.createDistributionSet(newDist);
newDist = distributionSetManagement.createDistributionSet(newDist);
this.notificationMessage.displaySuccess(this.i18n.get("message.new.dist.save.success",
notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success",
new Object[] { newDist.getName(), newDist.getVersion() }));
/* close the window */
closeThisWindow();
this.eventBus.publish(this,
new DistributionTableEvent(DistributionComponentEvent.ADD_DISTRIBUTION, newDist));
eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ADD_DISTRIBUTION, newDist));
}
}
@@ -317,8 +315,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
* Close window.
*/
private void closeThisWindow() {
this.addDistributionWindow.close();
UI.getCurrent().removeWindow(this.addDistributionWindow);
addDistributionWindow.close();
UI.getCurrent().removeWindow(addDistributionWindow);
}
/**
@@ -339,7 +337,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
final String distSetTypeName, final String desc, final boolean isMigStepReq) {
distributionSet.setName(name);
distributionSet.setVersion(version);
distributionSet.setType(this.distributionSetManagement.findDistributionSetTypeByName(distSetTypeName));
distributionSet.setType(distributionSetManagement.findDistributionSetTypeByName(distSetTypeName));
distributionSet.setDescription(desc != null ? desc : "");
distributionSet.setRequiredMigrationStep(isMigStepReq);
}
@@ -354,20 +352,18 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
* @return
*/
private boolean duplicateCheck(final String name, final String version) {
final DistributionSet existingDs = this.distributionSetManagement.findDistributionSetByNameAndVersion(name,
version);
final DistributionSet existingDs = distributionSetManagement.findDistributionSetByNameAndVersion(name, version);
/*
* Distribution should not exists with the same name & version. Display
* error message, when the "existingDs" is not null and it is add window
* (or) when the "existingDs" is not null and it is edit window and the
* distribution Id of the edit window is different then the "existingDs"
*/
if (existingDs != null
&& (!this.editDistribution || this.editDistribution && !existingDs.getId().equals(this.editDistId))) {
this.distNameTextField.addStyleName("v-textfield-error");
this.distVersionTextField.addStyleName("v-textfield-error");
this.notificationMessage.displayValidationError(this.i18n.get("message.duplicate.dist",
new Object[] { existingDs.getName(), existingDs.getVersion() }));
if (existingDs != null && (!editDistribution || editDistribution && !existingDs.getId().equals(editDistId))) {
distNameTextField.addStyleName("v-textfield-error");
distVersionTextField.addStyleName("v-textfield-error");
notificationMessage.displayValidationError(
i18n.get("message.duplicate.dist", new Object[] { existingDs.getName(), existingDs.getVersion() }));
return false;
} else {
@@ -394,16 +390,16 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
if (name == null || version == null || distSetTypeName == null) {
if (name == null) {
this.distNameTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
distNameTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
}
if (version == null) {
this.distVersionTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
distVersionTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
}
if (distSetTypeName == null) {
this.distsetTypeNameComboBox.addStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR);
distsetTypeNameComboBox.addStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR);
}
this.notificationMessage.displayValidationError(this.i18n.get("message.mandatory.check"));
notificationMessage.displayValidationError(i18n.get("message.mandatory.check"));
return false;
}
@@ -412,7 +408,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
private void discardDistribution() {
/* Just close this window */
this.distsetTypeNameComboBox.removeValueChangeListener(this.distsetTypeNameComboBoxListener);
distsetTypeNameComboBox.removeValueChangeListener(distsetTypeNameComboBoxListener);
closeThisWindow();
}
@@ -420,17 +416,17 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
* clear all the fields.
*/
public void resetComponents() {
this.editDistribution = Boolean.FALSE;
this.distNameTextField.clear();
this.distNameTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
this.distVersionTextField.clear();
this.distVersionTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
this.distsetTypeNameComboBox.removeStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR);
this.descTextArea.clear();
this.reqMigStepCheckbox.clear();
this.saveDistribution.setEnabled(true);
editDistribution = Boolean.FALSE;
distNameTextField.clear();
distNameTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
distVersionTextField.clear();
distVersionTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
distsetTypeNameComboBox.removeStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR);
descTextArea.clear();
reqMigStepCheckbox.clear();
saveDistribution.setEnabled(true);
removeListeners();
this.changedComponents.clear();
changedComponents.clear();
}
private void populateRequiredComponents() {
@@ -438,10 +434,10 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
}
private void removeListeners() {
this.reqMigStepCheckbox.removeValueChangeListener(this.reqMigStepCheckboxListerner);
this.descTextArea.removeTextChangeListener(this.descTextAreaListener);
this.distNameTextField.removeTextChangeListener(this.distNameTextFieldListener);
this.distVersionTextField.removeTextChangeListener(this.distVersionTextFieldListener);
reqMigStepCheckbox.removeValueChangeListener(reqMigStepCheckboxListerner);
descTextArea.removeTextChangeListener(descTextAreaListener);
distNameTextField.removeTextChangeListener(distNameTextFieldListener);
distVersionTextField.removeTextChangeListener(distVersionTextFieldListener);
}
public void setOriginalDistName(final String originalDistName) {
@@ -457,41 +453,41 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
}
private void checkValueChanged(final String originalValue, final TextChangeEvent event) {
if (this.editDistribution) {
if (editDistribution) {
final String newValue = event.getText();
if (!originalValue.equalsIgnoreCase(newValue)) {
this.changedComponents.add(event.getComponent());
changedComponents.add(event.getComponent());
} else {
this.changedComponents.remove(event.getComponent());
changedComponents.remove(event.getComponent());
}
enableDisableSaveButton();
}
}
private void checkValueChanged(final Boolean originalValue, final ValueChangeEvent event) {
if (this.editDistribution) {
if (editDistribution) {
if (!originalValue.equals(event.getProperty().getValue())) {
this.changedComponents.add(this.reqMigStepCheckbox);
changedComponents.add(reqMigStepCheckbox);
} else {
this.changedComponents.remove(this.reqMigStepCheckbox);
changedComponents.remove(reqMigStepCheckbox);
}
enableDisableSaveButton();
}
}
private void checkValueChanged(final String originalValue, final ValueChangeEvent event) {
if (this.editDistribution) {
if (editDistribution) {
if (!originalValue.equals(event.getProperty().getValue())) {
this.changedComponents.add(this.distsetTypeNameComboBox);
changedComponents.add(distsetTypeNameComboBox);
} else {
this.changedComponents.remove(this.distsetTypeNameComboBox);
changedComponents.remove(distsetTypeNameComboBox);
}
enableDisableSaveButton();
}
}
private void enableDisableSaveButton() {
if (this.changedComponents.isEmpty()) {
if (changedComponents.isEmpty()) {
disableSaveButton();
} else {
enableSaveButton();
@@ -509,19 +505,19 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
*/
public void populateValuesOfDistribution(final Long editDistId) {
this.editDistId = editDistId;
this.editDistribution = Boolean.TRUE;
this.saveDistribution.setEnabled(false);
final DistributionSet distSet = this.distributionSetManagement.findDistributionSetByIdWithDetails(editDistId);
editDistribution = Boolean.TRUE;
saveDistribution.setEnabled(false);
final DistributionSet distSet = distributionSetManagement.findDistributionSetByIdWithDetails(editDistId);
if (distSet != null) {
this.distNameTextField.setValue(distSet.getName());
this.distVersionTextField.setValue(distSet.getVersion());
distNameTextField.setValue(distSet.getName());
distVersionTextField.setValue(distSet.getVersion());
if (distSet.getType().isDeleted()) {
this.distsetTypeNameComboBox.addItem(distSet.getType().getName());
distsetTypeNameComboBox.addItem(distSet.getType().getName());
}
this.distsetTypeNameComboBox.setValue(distSet.getType().getName());
this.reqMigStepCheckbox.setValue(distSet.isRequiredMigrationStep());
distsetTypeNameComboBox.setValue(distSet.getType().getName());
reqMigStepCheckbox.setValue(distSet.isRequiredMigrationStep());
if (distSet.getDescription() != null) {
this.descTextArea.setValue(distSet.getDescription());
descTextArea.setValue(distSet.getDescription());
}
setOriginalDistName(distSet.getName());
setOriginalDistVersion(distSet.getVersion());
@@ -533,22 +529,22 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
}
public Window getWindow() {
this.eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
populateRequiredComponents();
resetComponents();
this.addDistributionWindow = SPUIComponentProvider.getWindow(this.i18n.get("caption.add.new.dist"), null,
addDistributionWindow = SPUIComponentProvider.getWindow(i18n.get("caption.add.new.dist"), null,
SPUIDefinitions.CREATE_UPDATE_WINDOW);
this.addDistributionWindow.setContent(this);
return this.addDistributionWindow;
addDistributionWindow.setContent(this);
return addDistributionWindow;
}
/**
* Populate DistributionSet Type name combo.
*/
public void populateDistSetTypeNameCombo() {
this.distsetTypeNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer());
this.distsetTypeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
this.distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getName());
distsetTypeNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer());
distsetTypeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getName());
}
/**

View File

@@ -91,7 +91,7 @@ public class ManagementUIState implements Serializable {
* @return the bulkUploadWindowMinimised
*/
public boolean isBulkUploadWindowMinimised() {
return this.bulkUploadWindowMinimised;
return bulkUploadWindowMinimised;
}
/**
@@ -106,7 +106,7 @@ public class ManagementUIState implements Serializable {
* @return the isCustomFilterSelected
*/
public boolean isCustomFilterSelected() {
return this.customFilterSelected;
return customFilterSelected;
}
/**
@@ -114,15 +114,15 @@ public class ManagementUIState implements Serializable {
* the isCustomFilterSelected to set
*/
public void setCustomFilterSelected(final boolean isCustomFilterSelected) {
this.customFilterSelected = isCustomFilterSelected;
customFilterSelected = isCustomFilterSelected;
}
public Set<Object> getExpandParentActionRowId() {
return this.expandParentActionRowId;
return expandParentActionRowId;
}
public Set<String> getCanceledTargetName() {
return this.canceledTargetName;
return canceledTargetName;
}
public void setDistTagLayoutVisible(final Boolean distTagLayoutVisible) {
@@ -130,39 +130,39 @@ public class ManagementUIState implements Serializable {
}
public Boolean getDistTagLayoutVisible() {
return this.distTagLayoutVisible;
return distTagLayoutVisible;
}
public void setTargetTagLayoutVisible(final Boolean targetTagVisible) {
this.targetTagLayoutVisible = targetTagVisible;
targetTagLayoutVisible = targetTagVisible;
}
public Boolean getTargetTagLayoutVisible() {
return this.targetTagLayoutVisible;
return targetTagLayoutVisible;
}
public TargetTableFilters getTargetTableFilters() {
return this.targetTableFilters;
return targetTableFilters;
}
public DistributionTableFilters getDistributionTableFilters() {
return this.distributionTableFilters;
return distributionTableFilters;
}
public Map<TargetIdName, DistributionSetIdName> getAssignedList() {
return this.assignedList;
return assignedList;
}
public Set<DistributionSetIdName> getDeletedDistributionList() {
return this.deletedDistributionList;
return deletedDistributionList;
}
public Set<TargetIdName> getDeletedTargetList() {
return this.deletedTargetList;
return deletedTargetList;
}
public TargetIdName getLastSelectedTargetIdName() {
return this.lastSelectedTargetIdName;
return lastSelectedTargetIdName;
}
public void setLastSelectedTargetIdName(final TargetIdName lastSelectedTargetIdName) {
@@ -170,7 +170,7 @@ public class ManagementUIState implements Serializable {
}
public Optional<Set<TargetIdName>> getSelectedTargetIdName() {
return this.selectedTargetIdName == null ? Optional.empty() : Optional.of(this.selectedTargetIdName);
return selectedTargetIdName == null ? Optional.empty() : Optional.of(selectedTargetIdName);
}
public void setSelectedTargetIdName(final Set<TargetIdName> selectedTargetIdName) {
@@ -181,7 +181,7 @@ public class ManagementUIState implements Serializable {
* @return the targetTagFilterClosed
*/
public boolean isTargetTagFilterClosed() {
return this.targetTagFilterClosed;
return targetTagFilterClosed;
}
/**
@@ -196,7 +196,7 @@ public class ManagementUIState implements Serializable {
* @return the distTagFilterClosed
*/
public boolean isDistTagFilterClosed() {
return this.distTagFilterClosed;
return distTagFilterClosed;
}
/**
@@ -211,7 +211,7 @@ public class ManagementUIState implements Serializable {
* @return the targetsTruncated
*/
public Long getTargetsTruncated() {
return this.targetsTruncated;
return targetsTruncated;
}
/**
@@ -226,7 +226,7 @@ public class ManagementUIState implements Serializable {
* @return the targetsCountAll
*/
public long getTargetsCountAll() {
return this.targetsCountAll.get();
return targetsCountAll.get();
}
/**
@@ -241,21 +241,21 @@ public class ManagementUIState implements Serializable {
* increments the targets all counter.
*/
public void incrementTargetsCountAll() {
this.targetsCountAll.incrementAndGet();
targetsCountAll.incrementAndGet();
}
/**
* decrement the targets all counter.
*/
public void decrementTargetsCountAll() {
final long decrementAndGet = this.targetsCountAll.decrementAndGet();
final long decrementAndGet = targetsCountAll.decrementAndGet();
if (decrementAndGet < 0) {
this.targetsCountAll.set(0);
targetsCountAll.set(0);
}
}
public boolean isDsTableMaximized() {
return this.isDsTableMaximized;
return isDsTableMaximized;
}
public void setDsTableMaximized(final boolean isDsTableMaximized) {
@@ -263,7 +263,7 @@ public class ManagementUIState implements Serializable {
}
public DistributionSetIdName getLastSelectedDsIdName() {
return this.lastSelectedDsIdName;
return lastSelectedDsIdName;
}
public void setLastSelectedDsIdName(final DistributionSetIdName lastSelectedDsIdName) {
@@ -275,14 +275,14 @@ public class ManagementUIState implements Serializable {
}
public Optional<Set<DistributionSetIdName>> getSelectedDsIdName() {
return this.selectedDsIdName == null ? Optional.empty() : Optional.of(this.selectedDsIdName);
return selectedDsIdName == null ? Optional.empty() : Optional.of(selectedDsIdName);
}
/**
* @return the isTargetTableMaximized
*/
public boolean isTargetTableMaximized() {
return this.isTargetTableMaximized;
return isTargetTableMaximized;
}
/**
@@ -297,7 +297,7 @@ public class ManagementUIState implements Serializable {
* @return the isActionHistoryMaximized
*/
public boolean isActionHistoryMaximized() {
return this.isActionHistoryMaximized;
return isActionHistoryMaximized;
}
/**
@@ -312,7 +312,7 @@ public class ManagementUIState implements Serializable {
* @return the noDataAvilableTarget
*/
public boolean isNoDataAvilableTarget() {
return this.noDataAvilableTarget;
return noDataAvilableTarget;
}
/**
@@ -327,7 +327,7 @@ public class ManagementUIState implements Serializable {
* @return the noDataAvailableDistribution
*/
public boolean isNoDataAvailableDistribution() {
return this.noDataAvailableDistribution;
return noDataAvailableDistribution;
}
/**

View File

@@ -150,126 +150,126 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
createRequiredComponents();
addListeners();
buildLayout();
this.eventBus.subscribe(this);
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
this.eventBus.unsubscribe(this);
eventBus.unsubscribe(this);
}
private void createRequiredComponents() {
this.createTagNw = this.i18n.get("label.create.tag");
this.updateTagNw = this.i18n.get("label.update.tag");
this.createTag = SPUIComponentProvider.getLabel(this.createTagNw, null);
this.updateTag = SPUIComponentProvider.getLabel(this.i18n.get("label.update.tag"), null);
this.comboLabel = SPUIComponentProvider.getLabel(this.i18n.get("label.choose.tag"), null);
this.madatoryLabel = getMandatoryLabel();
this.colorLabel = SPUIComponentProvider.getLabel(this.i18n.get("label.choose.tag.color"), null);
this.colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
createTagNw = i18n.get("label.create.tag");
updateTagNw = i18n.get("label.update.tag");
createTag = SPUIComponentProvider.getLabel(createTagNw, null);
updateTag = SPUIComponentProvider.getLabel(i18n.get("label.update.tag"), null);
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag"), null);
madatoryLabel = getMandatoryLabel();
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag.color"), null);
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
this.tagName = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME,
true, "", this.i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
this.tagName.setId(SPUIDefinitions.NEW_TARGET_TAG_NAME);
tagName = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME,
true, "", i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
tagName.setId(SPUIDefinitions.NEW_TARGET_TAG_NAME);
this.tagDesc = SPUIComponentProvider.getTextArea("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC,
false, "", this.i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
tagDesc = SPUIComponentProvider.getTextArea("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC,
false, "", i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
this.tagDesc.setId(SPUIDefinitions.NEW_TARGET_TAG_DESC);
this.tagDesc.setImmediate(true);
this.tagDesc.setNullRepresentation("");
tagDesc.setId(SPUIDefinitions.NEW_TARGET_TAG_DESC);
tagDesc.setImmediate(true);
tagDesc.setNullRepresentation("");
this.tagNameComboBox = SPUIComponentProvider.getComboBox("", "", null, null, false, "",
this.i18n.get("label.combobox.tag"));
this.tagNameComboBox.addStyleName(SPUIDefinitions.FILTER_TYPE_COMBO_STYLE);
this.tagNameComboBox.setImmediate(true);
tagNameComboBox = SPUIComponentProvider.getComboBox("", "", null, null, false, "",
i18n.get("label.combobox.tag"));
tagNameComboBox.addStyleName(SPUIDefinitions.FILTER_TYPE_COMBO_STYLE);
tagNameComboBox.setImmediate(true);
this.saveTag = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_TARGET_TAG_SAVE, "", "", "", true,
saveTag = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_TARGET_TAG_SAVE, "", "", "", true,
FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class);
this.saveTag.addStyleName(ValoTheme.BUTTON_BORDERLESS);
saveTag.addStyleName(ValoTheme.BUTTON_BORDERLESS);
this.discardTag = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_TARGET_TAG_DISRACD, "", "",
discardTag = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_TARGET_TAG_DISRACD, "", "",
"discard-button-style", true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
this.discardTag.addStyleName(ValoTheme.BUTTON_BORDERLESS);
discardTag.addStyleName(ValoTheme.BUTTON_BORDERLESS);
this.tagColorPreviewBtn = new Button();
this.tagColorPreviewBtn.setId(SPUIComponetIdProvider.TAG_COLOR_PREVIEW_ID);
tagColorPreviewBtn = new Button();
tagColorPreviewBtn.setId(SPUIComponetIdProvider.TAG_COLOR_PREVIEW_ID);
getPreviewButtonColor(DEFAULT_COLOR);
this.tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
this.selectors = new HashSet<>();
this.selectedColor = new Color(44, 151, 32);
this.selPreview = new SpColorPickerPreview(this.selectedColor);
selectors = new HashSet<>();
selectedColor = new Color(44, 151, 32);
selPreview = new SpColorPickerPreview(selectedColor);
this.colorSelect = new ColorPickerGradient("rgb-gradient", this.rgbConverter);
this.colorSelect.setColor(this.selectedColor);
this.colorSelect.setWidth("220px");
colorSelect = new ColorPickerGradient("rgb-gradient", rgbConverter);
colorSelect.setColor(selectedColor);
colorSelect.setWidth("220px");
this.redSlider = createRGBSlider("", "red");
this.greenSlider = createRGBSlider("", "green");
this.blueSlider = createRGBSlider("", "blue");
setRgbSliderValues(this.selectedColor);
redSlider = createRGBSlider("", "red");
greenSlider = createRGBSlider("", "green");
blueSlider = createRGBSlider("", "blue");
setRgbSliderValues(selectedColor);
createOptionGroup();
}
private void buildLayout() {
this.comboLayout = new VerticalLayout();
comboLayout = new VerticalLayout();
this.sliders = new VerticalLayout();
this.sliders.addComponents(this.redSlider, this.greenSlider, this.blueSlider);
sliders = new VerticalLayout();
sliders.addComponents(redSlider, greenSlider, blueSlider);
this.selectors.add(this.colorSelect);
selectors.add(colorSelect);
this.colorPickerLayout = new VerticalLayout();
this.colorPickerLayout.setStyleName("rgb-vertical-layout");
this.colorPickerLayout.addComponent(this.selPreview);
this.colorPickerLayout.addComponent(this.colorSelect);
colorPickerLayout = new VerticalLayout();
colorPickerLayout.setStyleName("rgb-vertical-layout");
colorPickerLayout.addComponent(selPreview);
colorPickerLayout.addComponent(colorSelect);
this.fieldLayout = new VerticalLayout();
this.fieldLayout.setSpacing(false);
this.fieldLayout.setMargin(false);
this.fieldLayout.setWidth("100%");
this.fieldLayout.setHeight(null);
this.fieldLayout.addComponent(this.optiongroup);
this.fieldLayout.addComponent(this.comboLayout);
this.fieldLayout.addComponent(this.madatoryLabel);
this.fieldLayout.addComponent(this.tagName);
this.fieldLayout.addComponent(this.tagDesc);
fieldLayout = new VerticalLayout();
fieldLayout.setSpacing(false);
fieldLayout.setMargin(false);
fieldLayout.setWidth("100%");
fieldLayout.setHeight(null);
fieldLayout.addComponent(optiongroup);
fieldLayout.addComponent(comboLayout);
fieldLayout.addComponent(madatoryLabel);
fieldLayout.addComponent(tagName);
fieldLayout.addComponent(tagDesc);
final HorizontalLayout colorLabelLayout = new HorizontalLayout();
colorLabelLayout.addComponents(this.colorLabel, this.tagColorPreviewBtn);
this.fieldLayout.addComponent(colorLabelLayout);
colorLabelLayout.addComponents(colorLabel, tagColorPreviewBtn);
fieldLayout.addComponent(colorLabelLayout);
final HorizontalLayout buttonLayout = new HorizontalLayout();
buttonLayout.addComponent(this.saveTag);
buttonLayout.addComponent(this.discardTag);
buttonLayout.setComponentAlignment(this.discardTag, Alignment.BOTTOM_RIGHT);
buttonLayout.setComponentAlignment(this.saveTag, Alignment.BOTTOM_LEFT);
buttonLayout.addComponent(saveTag);
buttonLayout.addComponent(discardTag);
buttonLayout.setComponentAlignment(discardTag, Alignment.BOTTOM_RIGHT);
buttonLayout.setComponentAlignment(saveTag, Alignment.BOTTOM_LEFT);
buttonLayout.addStyleName("window-style");
buttonLayout.setWidth("152px");
final VerticalLayout fieldButtonLayout = new VerticalLayout();
fieldButtonLayout.addComponent(this.fieldLayout);
fieldButtonLayout.addComponent(fieldLayout);
fieldButtonLayout.addComponent(buttonLayout);
fieldButtonLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_CENTER);
this.mainLayout = new HorizontalLayout();
this.mainLayout.addComponent(fieldButtonLayout);
mainLayout = new HorizontalLayout();
mainLayout.addComponent(fieldButtonLayout);
setCompositionRoot(this.mainLayout);
setCompositionRoot(mainLayout);
}
private void addListeners() {
this.saveTag.addClickListener(event -> save(event));
this.discardTag.addClickListener(event -> discard(event));
this.colorSelect.addColorChangeListener(this);
this.selPreview.addColorChangeListener(this);
this.tagColorPreviewBtn.addClickListener(event -> previewButtonClicked());
this.optiongroup.addValueChangeListener(event -> optionValueChanged(event));
this.tagNameComboBox.addValueChangeListener(event -> tagNameChosen(event));
saveTag.addClickListener(event -> save(event));
discardTag.addClickListener(event -> discard(event));
colorSelect.addColorChangeListener(this);
selPreview.addColorChangeListener(this);
tagColorPreviewBtn.addClickListener(event -> previewButtonClicked());
optiongroup.addValueChangeListener(event -> optionValueChanged(event));
tagNameComboBox.addValueChangeListener(event -> tagNameChosen(event));
slidersValueChangeListeners();
}
@@ -278,38 +278,37 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
* on target tag if already selected.
*/
private void previewButtonClicked() {
if (!this.tagPreviewBtnClicked) {
if (!tagPreviewBtnClicked) {
setColor();
this.selPreview.setColor(this.selectedColor);
this.fieldLayout.addComponent(this.sliders);
this.mainLayout.addComponent(this.colorPickerLayout);
this.mainLayout.setComponentAlignment(this.colorPickerLayout, Alignment.BOTTOM_CENTER);
selPreview.setColor(selectedColor);
fieldLayout.addComponent(sliders);
mainLayout.addComponent(colorPickerLayout);
mainLayout.setComponentAlignment(colorPickerLayout, Alignment.BOTTOM_CENTER);
}
this.tagPreviewBtnClicked = !this.tagPreviewBtnClicked;
tagPreviewBtnClicked = !tagPreviewBtnClicked;
}
private void setColor() {
final String selectedOption = (String) this.optiongroup.getValue();
if (selectedOption == null || !selectedOption.equalsIgnoreCase(this.updateTagNw)) {
final String selectedOption = (String) optiongroup.getValue();
if (selectedOption == null || !selectedOption.equalsIgnoreCase(updateTagNw)) {
return;
}
if (this.tagNameComboBox.getValue() == null) {
this.selectedColor = rgbToColorConverter(DEFAULT_COLOR);
if (tagNameComboBox.getValue() == null) {
selectedColor = rgbToColorConverter(DEFAULT_COLOR);
return;
}
final TargetTag targetTagSelected = this.tagManagement
.findTargetTag(this.tagNameComboBox.getValue().toString());
final TargetTag targetTagSelected = tagManagement.findTargetTag(tagNameComboBox.getValue().toString());
if (targetTagSelected == null) {
final DistributionSetTag distTag = this.tagManagement
.findDistributionSetTag(this.tagNameComboBox.getValue().toString());
this.selectedColor = distTag.getColour() != null ? rgbToColorConverter(distTag.getColour())
final DistributionSetTag distTag = tagManagement
.findDistributionSetTag(tagNameComboBox.getValue().toString());
selectedColor = distTag.getColour() != null ? rgbToColorConverter(distTag.getColour())
: rgbToColorConverter(DEFAULT_COLOR);
} else {
this.selectedColor = targetTagSelected.getColour() != null
? rgbToColorConverter(targetTagSelected.getColour()) : rgbToColorConverter(DEFAULT_COLOR);
selectedColor = targetTagSelected.getColour() != null ? rgbToColorConverter(targetTagSelected.getColour())
: rgbToColorConverter(DEFAULT_COLOR);
}
}
@@ -339,7 +338,7 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
}
private Label getMandatoryLabel() {
final Label label = new Label(this.i18n.get("label.mandatory.field"));
final Label label = new Label(i18n.get("label.mandatory.field"));
label.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR + " " + ValoTheme.LABEL_SMALL);
return label;
}
@@ -354,16 +353,16 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
}
private void resetTagNameField() {
this.tagName.setEnabled(false);
this.tagName.clear();
tagName.setEnabled(false);
tagName.clear();
this.tagDesc.clear();
tagDesc.clear();
restoreComponentStyles();
this.fieldLayout.removeComponent(this.sliders);
this.mainLayout.removeComponent(this.colorPickerLayout);
this.selectedColor = new Color(44, 151, 32);
this.selPreview.setColor(this.selectedColor);
this.tagPreviewBtnClicked = false;
fieldLayout.removeComponent(sliders);
mainLayout.removeComponent(colorPickerLayout);
selectedColor = new Color(44, 151, 32);
selPreview.setColor(selectedColor);
tagPreviewBtnClicked = false;
}
@@ -375,30 +374,30 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
*/
private void optionValueChanged(final ValueChangeEvent event) {
if ("Update Tag".equals(event.getProperty().getValue())) {
this.tagName.clear();
this.tagDesc.clear();
this.tagName.setEnabled(false);
tagName.clear();
tagDesc.clear();
tagName.setEnabled(false);
populateTagNameCombo();
// show target name combo
this.comboLayout.addComponent(this.comboLabel);
this.comboLayout.addComponent(this.tagNameComboBox);
comboLayout.addComponent(comboLabel);
comboLayout.addComponent(tagNameComboBox);
} else {
this.tagName.setEnabled(true);
this.tagName.clear();
this.tagDesc.clear();
tagName.setEnabled(true);
tagName.clear();
tagDesc.clear();
// hide target name combo
this.comboLayout.removeComponent(this.comboLabel);
this.comboLayout.removeComponent(this.tagNameComboBox);
comboLayout.removeComponent(comboLabel);
comboLayout.removeComponent(tagNameComboBox);
}
// close the color picker layout
this.tagPreviewBtnClicked = false;
tagPreviewBtnClicked = false;
// reset the selected color - Set defualt color
restoreComponentStyles();
getPreviewButtonColor(DEFAULT_COLOR);
this.selPreview.setColor(rgbToColorConverter(DEFAULT_COLOR));
selPreview.setColor(rgbToColorConverter(DEFAULT_COLOR));
// remove the sliders and color picker layout
this.fieldLayout.removeComponent(this.sliders);
this.mainLayout.removeComponent(this.colorPickerLayout);
fieldLayout.removeComponent(sliders);
mainLayout.removeComponent(colorPickerLayout);
}
@@ -406,23 +405,23 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
* reset the components.
*/
protected void reset() {
this.tagName.setEnabled(true);
this.tagName.clear();
this.tagDesc.clear();
tagName.setEnabled(true);
tagName.clear();
tagDesc.clear();
restoreComponentStyles();
// hide target name combo
this.comboLayout.removeComponent(this.comboLabel);
this.comboLayout.removeComponent(this.tagNameComboBox);
this.fieldLayout.removeComponent(this.sliders);
this.mainLayout.removeComponent(this.colorPickerLayout);
comboLayout.removeComponent(comboLabel);
comboLayout.removeComponent(tagNameComboBox);
fieldLayout.removeComponent(sliders);
mainLayout.removeComponent(colorPickerLayout);
this.optiongroup.select(this.createTagNw);
optiongroup.select(createTagNw);
// Default green color
this.selectedColor = new Color(44, 151, 32);
this.selPreview.setColor(this.selectedColor);
this.tagPreviewBtnClicked = false;
selectedColor = new Color(44, 151, 32);
selPreview.setColor(selectedColor);
tagPreviewBtnClicked = false;
}
/**
@@ -432,15 +431,14 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
@Override
public void colorChanged(final ColorChangeEvent event) {
setColor(event.getColor());
for (final ColorSelector select : this.selectors) {
if (!event.getSource().equals(select) && select.equals(this)
&& !select.getColor().equals(this.selectedColor)) {
select.setColor(this.selectedColor);
for (final ColorSelector select : selectors) {
if (!event.getSource().equals(select) && select.equals(this) && !select.getColor().equals(selectedColor)) {
select.setColor(selectedColor);
}
}
setRgbSliderValues(this.selectedColor);
setRgbSliderValues(selectedColor);
getPreviewButtonColor(event.getColor().getCSS());
createDynamicStyleForComponents(this.tagName, this.tagDesc, event.getColor().getCSS());
createDynamicStyleForComponents(tagName, tagDesc, event.getColor().getCSS());
}
/**
@@ -466,11 +464,11 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
private void setRgbSliderValues(final Color color) {
try {
final double redColorValue = color.getRed();
this.redSlider.setValue(new Double(redColorValue));
redSlider.setValue(new Double(redColorValue));
final double blueColorValue = color.getBlue();
this.blueSlider.setValue(new Double(blueColorValue));
blueSlider.setValue(new Double(blueColorValue));
final double greenColorValue = color.getGreen();
this.greenSlider.setValue(new Double(greenColorValue));
greenSlider.setValue(new Double(greenColorValue));
} catch (final ValueOutOfBoundsException e) {
LOG.error("Unable to set RGB color value to " + color.getRed() + "," + color.getGreen() + ","
+ color.getBlue(), e);
@@ -497,10 +495,10 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
* reset the tag name and tag description component border color.
*/
private void restoreComponentStyles() {
this.tagName.removeStyleName(TAG_NAME_DYNAMIC_STYLE);
this.tagDesc.removeStyleName(TAG_DESC_DYNAMIC_STYLE);
this.tagName.addStyleName(SPUIDefinitions.TAG_NAME);
this.tagDesc.addStyleName(SPUIDefinitions.TAG_DESC);
tagName.removeStyleName(TAG_NAME_DYNAMIC_STYLE);
tagDesc.removeStyleName(TAG_DESC_DYNAMIC_STYLE);
tagName.addStyleName(SPUIDefinitions.TAG_NAME);
tagDesc.addStyleName(SPUIDefinitions.TAG_DESC);
getPreviewButtonColor(DEFAULT_COLOR);
}
@@ -525,12 +523,12 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
if (color == null) {
return;
}
this.selectedColor = color;
this.selPreview.setColor(this.selectedColor);
final String colorPickedPreview = this.selPreview.getColor().getCSS();
if (this.tagName.isEnabled() && null != this.colorSelect) {
createDynamicStyleForComponents(this.tagName, this.tagDesc, colorPickedPreview);
this.colorSelect.setColor(this.selPreview.getColor());
selectedColor = color;
selPreview.setColor(selectedColor);
final String colorPickedPreview = selPreview.getColor().getCSS();
if (tagName.isEnabled() && null != colorSelect) {
createDynamicStyleForComponents(tagName, tagDesc, colorPickedPreview);
colorSelect.setColor(selPreview.getColor());
}
}
@@ -538,36 +536,33 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
* Value change listeners implementations of sliders.
*/
private void slidersValueChangeListeners() {
this.redSlider.addValueChangeListener(new ValueChangeListener() {
redSlider.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = -8336732888800920839L;
@Override
public void valueChange(final ValueChangeEvent event) {
final double red = (Double) event.getProperty().getValue();
final Color newColor = new Color((int) red, CreateUpdateTagLayout.this.selectedColor.getGreen(),
CreateUpdateTagLayout.this.selectedColor.getBlue());
final Color newColor = new Color((int) red, selectedColor.getGreen(), selectedColor.getBlue());
setColorToComponents(newColor);
}
});
this.greenSlider.addValueChangeListener(new ValueChangeListener() {
greenSlider.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1236358037766775663L;
@Override
public void valueChange(final ValueChangeEvent event) {
final double green = (Double) event.getProperty().getValue();
final Color newColor = new Color(CreateUpdateTagLayout.this.selectedColor.getRed(), (int) green,
CreateUpdateTagLayout.this.selectedColor.getBlue());
final Color newColor = new Color(selectedColor.getRed(), (int) green, selectedColor.getBlue());
setColorToComponents(newColor);
}
});
this.blueSlider.addValueChangeListener(new ValueChangeListener() {
blueSlider.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 8466370763686043947L;
@Override
public void valueChange(final ValueChangeEvent event) {
final double blue = (Double) event.getProperty().getValue();
final Color newColor = new Color(CreateUpdateTagLayout.this.selectedColor.getRed(),
CreateUpdateTagLayout.this.selectedColor.getGreen(), (int) blue);
final Color newColor = new Color(selectedColor.getRed(), selectedColor.getGreen(), (int) blue);
setColorToComponents(newColor);
}
});
@@ -575,9 +570,9 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
private void setColorToComponents(final Color newColor) {
setColor(newColor);
this.colorSelect.setColor(newColor);
colorSelect.setColor(newColor);
getPreviewButtonColor(newColor.getCSS());
createDynamicStyleForComponents(this.tagName, this.tagDesc, newColor.getCSS());
createDynamicStyleForComponents(tagName, tagDesc, newColor.getCSS());
}
@Override

View File

@@ -57,7 +57,7 @@ import com.vaadin.ui.UI;
/**
* Common util class.
*
*
*
*
*/
@@ -122,7 +122,7 @@ public final class HawkbitCommonUtil {
/**
* Check Map is valid.
*
*
* @param mapCheck
* as Map
* @return boolean as flag
@@ -138,7 +138,7 @@ public final class HawkbitCommonUtil {
/**
* Check Map is valid.
*
*
* @param mapCheck
* as Map
* @return boolean as flag
@@ -154,7 +154,7 @@ public final class HawkbitCommonUtil {
/**
* Check Map is valid.
*
*
* @param mapCheck
* as Map
* @return boolean as flag
@@ -170,7 +170,7 @@ public final class HawkbitCommonUtil {
/**
* Check List is valid.
*
*
* @param listCheck
* as List
* @return boolean as flag
@@ -186,7 +186,7 @@ public final class HawkbitCommonUtil {
/**
* Check Boolean Array is valid.
*
*
* @param bolArray
* as List
* @return boolean as flag
@@ -202,7 +202,7 @@ public final class HawkbitCommonUtil {
/**
* Check String null, return empty.
*
*
* @param nString
* as String
* @return String
@@ -217,7 +217,7 @@ public final class HawkbitCommonUtil {
/**
* Check valid String.
*
*
* @param nString
* as String
* @return boolean as flag
@@ -232,7 +232,7 @@ public final class HawkbitCommonUtil {
/**
* Trim the text and convert into null in case of empty string.
*
*
* @param text
* as text to be trimed
* @return null if the text is null or if the text is blank, text.trim() if
@@ -249,7 +249,7 @@ public final class HawkbitCommonUtil {
/**
* Concatenate the given text all the string arguments with the given
* delimiter.
*
*
* @param delimiter
* the delimiter text to be used while concatenation.
* @param texts
@@ -275,7 +275,7 @@ public final class HawkbitCommonUtil {
/**
* Returns the input text within html bold tag <b>..</b>.
*
*
* @param text
* is the text to be converted in to Bold
* @return null if the input text param is null returns text with <b>...</b>
@@ -294,7 +294,7 @@ public final class HawkbitCommonUtil {
/**
* Get target label Id.
*
*
* @param controllerId
* as String
* @return String as label name
@@ -360,7 +360,7 @@ public final class HawkbitCommonUtil {
/**
* Get Label for Artifact Details.
*
*
* @param name
* @return
*/
@@ -373,7 +373,7 @@ public final class HawkbitCommonUtil {
/**
* Get Label for Artifact Details.
*
*
* @param caption
* as caption of the details
* @param name
@@ -389,7 +389,7 @@ public final class HawkbitCommonUtil {
/**
* Get Label for Action History Details.
*
*
* @param name
* @return
*/
@@ -402,7 +402,7 @@ public final class HawkbitCommonUtil {
/**
* Get tool tip for Poll status.
*
*
* @param pollStatus
* @param i18N
* @return
@@ -449,7 +449,7 @@ public final class HawkbitCommonUtil {
/**
* Find extra height required to increase by all the components to utilize
* the full height of browser for the responsive UI.
*
*
* @param newBrowserHeight
* as current browser height.
* @return extra height required to increase.
@@ -668,7 +668,7 @@ public final class HawkbitCommonUtil {
/**
* Create javascript to display number of targets or distributions your are
* dragging in the drag image.
*
*
* @param count
* @return
*/
@@ -688,7 +688,7 @@ public final class HawkbitCommonUtil {
/**
* Get IM User for user UUID.
*
*
* @param uuid
* @return imReslovedUser user details
*/
@@ -699,7 +699,7 @@ public final class HawkbitCommonUtil {
final UserDetailsService idManagement = SpringContextHelper.getBean(UserDetailsService.class);
try {
imReslovedUser = HawkbitCommonUtil.getFormattedName(idManagement.loadUserByUsername(uuid));
} catch (final UsernameNotFoundException e) {
} catch (final UsernameNotFoundException e) { // NOSONAR
// nope not need to handle
}
// If Null display the UID
@@ -712,7 +712,7 @@ public final class HawkbitCommonUtil {
/**
* Get formatted label.Appends ellipses if content does not fit the label.
*
*
* @param labelContent
* content
* @return Label
@@ -790,7 +790,7 @@ public final class HawkbitCommonUtil {
/**
* Duplicate check - Unique Key.
*
*
* @param name
* as string
* @param version
@@ -809,7 +809,7 @@ public final class HawkbitCommonUtil {
/**
* Add new base software module.
*
*
* @param bsname
* base software module name
* @param bsversion
@@ -857,7 +857,7 @@ public final class HawkbitCommonUtil {
/**
* Display Target Tag action message.
*
*
* @param targTagName
* as tag name
* @param result
@@ -903,7 +903,7 @@ public final class HawkbitCommonUtil {
/**
* Get message to be displayed after distribution tag assignment.
*
*
* @param targTagName
* tag name
* @param result
@@ -949,7 +949,7 @@ public final class HawkbitCommonUtil {
/**
* Create a lazy query container for the given query bean factory with empty
* configurations.
*
*
* @param queryFactory
* is reference of {@link BeanQueryFactory<? extends
* AbstractBeanQuery>} on which lazy container should create.
@@ -963,9 +963,9 @@ public final class HawkbitCommonUtil {
}
/**
*
*
* Create lazy query container for DS type.
*
*
* @param queryFactory
* @return LazyQueryContainer
*/
@@ -978,7 +978,7 @@ public final class HawkbitCommonUtil {
/**
* Set distribution table column properties.
*
*
* @param container
* table container
*/
@@ -996,7 +996,7 @@ public final class HawkbitCommonUtil {
/**
* Get visible columns in table.
*
*
* @param isMaximized
* true if table is maximized
* @param isShowPinColumn
@@ -1033,7 +1033,7 @@ public final class HawkbitCommonUtil {
/**
* Reset the software module table rows highlight css.
*
*
* @return javascript to rest software module table rows highlight css.
*/
public static String getScriptSMHighlightReset() {
@@ -1042,7 +1042,7 @@ public final class HawkbitCommonUtil {
/**
* Highlight software module rows with the color of sw-type.
*
*
* @param colorCSS
* color to generate the css script.
* @return javascript to append software module table rows with highlighted
@@ -1058,7 +1058,7 @@ public final class HawkbitCommonUtil {
/**
* Get javascript to reflect new color selection in color picker preview for
* name and description fields .
*
*
* @param colorPickedPreview
* changed color
* @return javascript for the selected color.
@@ -1078,7 +1078,7 @@ public final class HawkbitCommonUtil {
/**
* Get javascript to reflect new color selection for preview button.
*
*
* @param color
* changed color
* @return javascript for the selected color.
@@ -1095,7 +1095,7 @@ public final class HawkbitCommonUtil {
/**
* Java script to display drop hints for tags.
*
*
* @return javascript
*/
public static String dispTargetTagsDropHintScript() {
@@ -1108,7 +1108,7 @@ public final class HawkbitCommonUtil {
/**
* Java script to hide drop hints for tags.
*
*
* @return javascript
*/
public static String hideTargetTagsDropHintScript() {
@@ -1117,7 +1117,7 @@ public final class HawkbitCommonUtil {
/**
* Java script to display drop hint for Delete button.
*
*
* @return javascript
*/
public static String dispDeleteDropHintScript() {
@@ -1130,7 +1130,7 @@ public final class HawkbitCommonUtil {
/**
* Java script to hide drop hint for delete button.
*
*
* @return javascript
*/
public static String hideDeleteDropHintScript() {
@@ -1139,7 +1139,7 @@ public final class HawkbitCommonUtil {
/**
* Get the details of selected rows of {@link TargetTable}.
*
*
* @param sourceTable
* @return set of {@link TargetIdName}
*/
@@ -1154,7 +1154,7 @@ public final class HawkbitCommonUtil {
/**
* Get the details of selected rows of {@link DistributionTable}.
*
*
* @param sourceTable
* @return set of {@link DistributionSetIdName}
*/
@@ -1168,9 +1168,9 @@ public final class HawkbitCommonUtil {
}
/**
*
*
* Add target table container properties.
*
*
* @param container
* table container
*/
@@ -1202,9 +1202,9 @@ public final class HawkbitCommonUtil {
}
/**
*
*
* Apply style for status label in target table.
*
*
* @param targetTable
* target table
* @param pinBtn
@@ -1234,7 +1234,7 @@ public final class HawkbitCommonUtil {
/**
* Set status progress bar value.
*
*
* @param bar
* DistributionBar
* @param statusName
@@ -1253,7 +1253,7 @@ public final class HawkbitCommonUtil {
/**
* Initialize status progress bar with values and number of parts on load.
*
*
* @param bar
* DistributionBar
* @param item
@@ -1282,7 +1282,7 @@ public final class HawkbitCommonUtil {
/**
* Formats the finished percentage of a rollout group into a string with one
* digit after comma.
*
*
* @param rolloutGroup
* the rollout group
* @param finishedPercentage
@@ -1311,7 +1311,7 @@ public final class HawkbitCommonUtil {
/**
* Reset the values of status progress bar on change of values.
*
*
* @param bar
* DistributionBar
* @param item