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 @Override
public void clean() { public void clean() {
super.clean(); super.clean();
this.removed = true; removed = true;
} }
public int getPollDelaySec() { public int getPollDelaySec() {
return this.pollDelaySec; return pollDelaySec;
} }
/** /**
* Polls the base URL for the DDI API interface. * Polls the base URL for the DDI API interface.
*/ */
public void poll() { public void poll() {
if (!this.removed) { if (!removed) {
final String basePollJson = this.controllerResource.get(getTenant(), getId()); final String basePollJson = controllerResource.get(getTenant(), getId());
try { try {
final String href = JsonPath.parse(basePollJson).read("_links.deploymentBase.href"); final String href = JsonPath.parse(basePollJson).read("_links.deploymentBase.href");
final long actionId = Long.parseLong(href.substring(href.lastIndexOf("/") + 1, href.indexOf("?"))); final long actionId = Long.parseLong(href.substring(href.lastIndexOf("/") + 1, href.indexOf("?")));
if (this.currentActionId == null) { if (currentActionId == null) {
final String deploymentJson = this.controllerResource.getDeployment(getTenant(), getId(), actionId); final String deploymentJson = controllerResource.getDeployment(getTenant(), getId(), actionId);
final String swVersion = JsonPath.parse(deploymentJson).read("deployment.chunks[0].version"); final String swVersion = JsonPath.parse(deploymentJson).read("deployment.chunks[0].version");
this.currentActionId = actionId; currentActionId = actionId;
this.deviceUpdater.startUpdate(getTenant(), getId(), actionId, swVersion, (device, actionId1) -> { deviceUpdater.startUpdate(getTenant(), getId(), actionId, swVersion, (device, actionId1) -> {
switch (device.getResponseStatus()) { switch (device.getResponseStatus()) {
case SUCCESSFUL: case SUCCESSFUL:
DDISimulatedDevice.this.controllerResource.postSuccessFeedback(getTenant(), getId(), controllerResource.postSuccessFeedback(getTenant(), getId(),
actionId1); actionId1);
break; break;
case ERROR: case ERROR:
DDISimulatedDevice.this.controllerResource.postErrorFeedback(getTenant(), getId(), controllerResource.postErrorFeedback(getTenant(), getId(),
actionId1); actionId1);
break; break;
default: default:
throw new IllegalStateException( throw new IllegalStateException(
"simulated device has an unknown response status + " + device.getResponseStatus()); "simulated device has an unknown response status + " + device.getResponseStatus());
} }
DDISimulatedDevice.this.currentActionId = null; currentActionId = null;
}); });
} }
} catch (final PathNotFoundException e) { } 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, public void startUpdate(final String tenant, final String id, final long actionId, final String swVersion,
final UpdaterCallback callback) { final UpdaterCallback callback) {
final AbstractSimulatedDevice device = this.repository.get(tenant, id); final AbstractSimulatedDevice device = repository.get(tenant, id);
device.setProgress(0.0); device.setProgress(0.0);
device.setSwversion(swVersion); device.setSwversion(swVersion);
this.eventbus.post(new InitUpdate(device)); eventbus.post(new InitUpdate(device));
threadPool.schedule( threadPool.schedule(new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus, callback),
new DeviceSimulatorUpdateThread(device, this.spSenderService, actionId, this.eventbus, callback), 2000, 2000, TimeUnit.MILLISECONDS);
TimeUnit.MILLISECONDS);
} }
private static final class DeviceSimulatorUpdateThread implements Runnable { private static final class DeviceSimulatorUpdateThread implements Runnable {
@@ -87,15 +86,16 @@ public class DeviceSimulatorUpdater {
@Override @Override
public void run() { public void run() {
final double newProgress = this.device.getProgress() + 0.2; final double newProgress = device.getProgress() + 0.2;
this.device.setProgress(newProgress); device.setProgress(newProgress);
if (newProgress < 1.0) { if (newProgress < 1.0) {
threadPool.schedule(new DeviceSimulatorUpdateThread(this.device, this.spSenderService, this.actionId, threadPool.schedule(
this.eventbus, this.callback), rndSleep.nextInt(3000), TimeUnit.MILLISECONDS); new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus, callback),
rndSleep.nextInt(3000), TimeUnit.MILLISECONDS);
} else { } 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 { private class NextPollUpdaterRunnable implements Runnable {
@Override @Override
public void run() { 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()); .filter(device -> device instanceof DDISimulatedDevice).collect(Collectors.toList());
devices.forEach(device -> { devices.forEach(device -> {
@@ -71,7 +71,7 @@ public class NextPollTimeController {
} }
device.setNextPollCounterSec(nextCounter); 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) { private void setData(final List<DataReportSeriesItem<T>> values) {
this.data.clear(); data.clear();
this.data.addAll(values); data.addAll(values);
} }
/** /**
@@ -58,10 +58,10 @@ public class DataReportSeries<T extends Serializable> extends AbstractReportSeri
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public DataReportSeriesItem<T>[] getData() { 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() { 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 * @return the type of the data report item
*/ */
public T getType() { public T getType() {
return this.type; return type;
} }
/** /**
* @return the data of the data report item * @return the data of the data report item
*/ */
public Number getData() { public Number getData() {
return this.data; return data;
} }
} }

View File

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

View File

@@ -117,7 +117,7 @@ public class DistributionSetManagement {
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public DistributionSet findDistributionSetByIdWithDetails(@NotNull final Long distid) { 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) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public DistributionSet findDistributionSetById(@NotNull final Long distid) { 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) { @NotNull final String tagName) {
final Iterable<DistributionSet> sets = findDistributionSetListWithDetails(dsIds); final Iterable<DistributionSet> sets = findDistributionSetListWithDetails(dsIds);
final DistributionSetTag myTag = this.tagManagement.findDistributionSetTag(tagName); final DistributionSetTag myTag = tagManagement.findDistributionSetTag(tagName);
DistributionSetTagAssigmentResult result = null; DistributionSetTagAssigmentResult result = null;
final List<DistributionSet> allDSs = new ArrayList<>(); final List<DistributionSet> allDSs = new ArrayList<>();
@@ -192,18 +192,18 @@ public class DistributionSetManagement {
} }
} }
result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), 0, allDSs.size(), result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), 0, allDSs.size(),
Collections.emptyList(), this.distributionSetRepository.save(allDSs), myTag); Collections.emptyList(), distributionSetRepository.save(allDSs), myTag);
} else { } else {
result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), allDSs.size(), 0, 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; final DistributionSetTagAssigmentResult resultAssignment = result;
this.afterCommit afterCommit
.afterCommit(() -> this.eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment))); .afterCommit(() -> eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment)));
// no reason to persist the tag // no reason to persist the tag
this.entityManager.detach(myTag); entityManager.detach(myTag);
return result; return result;
} }
@@ -218,7 +218,7 @@ public class DistributionSetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public List<DistributionSet> findDistributionSetListWithDetails( public List<DistributionSet> findDistributionSetListWithDetails(
@NotEmpty final Collection<Long> distributionIdSet) { @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()); checkNotNull(ds.getId());
final DistributionSet persisted = findDistributionSetByIdWithDetails(ds.getId()); final DistributionSet persisted = findDistributionSetByIdWithDetails(ds.getId());
checkDistributionSetSoftwareModulesIsAllowedToModify(ds, persisted.getModules()); checkDistributionSetSoftwareModulesIsAllowedToModify(ds, persisted.getModules());
return this.distributionSetRepository.save(ds); return distributionSetRepository.save(ds);
} }
/** /**
@@ -260,7 +260,7 @@ public class DistributionSetManagement {
@Transactional @Transactional
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
public void deleteDistributionSet(@NotNull final DistributionSet set) { 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) { public void deleteDistributionSet(@NotEmpty final Long... distributionSetIDs) {
final List<Long> toHardDelete = new ArrayList<>(); final List<Long> toHardDelete = new ArrayList<>();
final List<Long> assigned = this.distributionSetRepository.findAssignedDistributionSetsById(distributionSetIDs); final List<Long> assigned = distributionSetRepository.findAssignedDistributionSetsById(distributionSetIDs);
// soft delete assigned // soft delete assigned
if (!assigned.isEmpty()) { 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 // 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 // don't give the delete statement an empty list, JPA/Oracle cannot
// handle the empty list, // handle the empty list,
// see MECS-403 // see MECS-403
this.distributionSetRepository.deleteByIdIn(toHardDelete); distributionSetRepository.deleteByIdIn(toHardDelete);
} }
} }
@@ -319,9 +319,9 @@ public class DistributionSetManagement {
public DistributionSet createDistributionSet(@NotNull final DistributionSet dSet) { public DistributionSet createDistributionSet(@NotNull final DistributionSet dSet) {
prepareDsSave(dSet); prepareDsSave(dSet);
if (dSet.getType() == null) { 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) { 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"); 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."); throw new EntityAlreadyExistsException("DistributionSet with that name and version already exists.");
} }
@@ -354,7 +354,7 @@ public class DistributionSetManagement {
for (final DistributionSet ds : distributionSets) { for (final DistributionSet ds : distributionSets) {
prepareDsSave(ds); prepareDsSave(ds);
} }
return this.distributionSetRepository.save(distributionSets); return distributionSetRepository.save(distributionSets);
} }
/** /**
@@ -375,7 +375,7 @@ public class DistributionSetManagement {
for (final SoftwareModule softwareModule : softwareModules) { for (final SoftwareModule softwareModule : softwareModules) {
ds.addModule(softwareModule); ds.addModule(softwareModule);
} }
return this.distributionSetRepository.save(ds); return distributionSetRepository.save(ds);
} }
/** /**
@@ -397,7 +397,7 @@ public class DistributionSetManagement {
softwareModules.add(softwareModule); softwareModules.add(softwareModule);
ds.removeModule(softwareModule); ds.removeModule(softwareModule);
checkDistributionSetSoftwareModulesIsAllowedToModify(ds, softwareModules); 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) { public DistributionSetType updateDistributionSetType(@NotNull final DistributionSetType dsType) {
checkNotNull(dsType.getId()); 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 // throw exception if user tries to update a DS type that is already in
// use // use
if (!persisted.areModuleEntriesIdentical(dsType) && this.distributionSetRepository.countByType(persisted) > 0) { if (!persisted.areModuleEntriesIdentical(dsType) && distributionSetRepository.countByType(persisted) > 0) {
throw new EntityReadOnlyException( throw new EntityReadOnlyException(
String.format("distribution set type %s set is already assigned to targets and cannot be changed", String.format("distribution set type %s set is already assigned to targets and cannot be changed",
dsType.getName())); dsType.getName()));
} }
return this.distributionSetTypeRepository.save(dsType); return distributionSetTypeRepository.save(dsType);
} }
/** /**
@@ -445,7 +445,7 @@ public class DistributionSetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Page<DistributionSetType> findDistributionSetTypesByPredicate( public Page<DistributionSetType> findDistributionSetTypesByPredicate(
@NotNull final Specification<DistributionSetType> spec, @NotNull final Pageable pageable) { @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) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Page<DistributionSetType> findDistributionSetTypesAll(@NotNull final Pageable pageable) { 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()) { if (specList == null || specList.isEmpty()) {
return null; 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) { @NotEmpty final String version) {
final Specification<DistributionSet> spec = DistributionSetSpecification final Specification<DistributionSet> spec = DistributionSetSpecification
.equalsNameAndVersionIgnoreCase(distributionName, version); .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) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Iterable<DistributionSet> findDistributionSetList(@NotEmpty final Collection<Long> dist) { 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); final Specification<DistributionSet> spec = DistributionSetSpecification.isDeleted(Boolean.FALSE);
specList.add(spec); 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) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public Long countDistributionSetTypesAll() { 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) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public DistributionSetType findDistributionSetTypeByName(@NotNull final String name) { 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) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public DistributionSetType findDistributionSetTypeById(@NotNull final Long id) { 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) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public DistributionSetType findDistributionSetTypeByKey(@NotNull final String key) { 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!"); 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) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
public void deleteDistributionSetType(@NotNull final DistributionSetType type) { public void deleteDistributionSetType(@NotNull final DistributionSetType type) {
if (this.distributionSetRepository.countByType(type) > 0) { if (distributionSetRepository.countByType(type) > 0) {
final DistributionSetType toDelete = this.entityManager.merge(type); final DistributionSetType toDelete = entityManager.merge(type);
toDelete.setDeleted(true); toDelete.setDeleted(true);
this.distributionSetTypeRepository.save(toDelete); distributionSetTypeRepository.save(toDelete);
} else { } else {
this.distributionSetTypeRepository.delete(type.getId()); distributionSetTypeRepository.delete(type.getId());
} }
} }
@@ -760,15 +760,15 @@ public class DistributionSetManagement {
@Modifying @Modifying
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
public DistributionSetMetadata createDistributionSetMetadata(@NotNull final DistributionSetMetadata metadata) { public DistributionSetMetadata createDistributionSetMetadata(@NotNull final DistributionSetMetadata metadata) {
if (this.distributionSetMetadataRepository.exists(metadata.getId())) { if (distributionSetMetadataRepository.exists(metadata.getId())) {
throwMetadataKeyAlreadyExists(metadata.getId().getKey()); throwMetadataKeyAlreadyExists(metadata.getId().getKey());
} }
// merge base software module so optLockRevision gets updated and audit // merge base software module so optLockRevision gets updated and audit
// log written because // log written because
// modifying metadata is modifying the base distribution set itself for // modifying metadata is modifying the base distribution set itself for
// auditing purposes. // auditing purposes.
this.entityManager.merge(metadata.getDistributionSet()).setLastModifiedAt(0L); entityManager.merge(metadata.getDistributionSet()).setLastModifiedAt(0L);
return this.distributionSetMetadataRepository.save(metadata); return distributionSetMetadataRepository.save(metadata);
} }
/** /**
@@ -789,8 +789,8 @@ public class DistributionSetManagement {
for (final DistributionSetMetadata distributionSetMetadata : metadata) { for (final DistributionSetMetadata distributionSetMetadata : metadata) {
checkAndThrowAlreadyIfDistributionSetMetadataExists(distributionSetMetadata.getId()); checkAndThrowAlreadyIfDistributionSetMetadataExists(distributionSetMetadata.getId());
} }
metadata.forEach(m -> this.entityManager.merge(m.getDistributionSet()).setLastModifiedAt(-1L)); metadata.forEach(m -> entityManager.merge(m.getDistributionSet()).setLastModifiedAt(-1L));
return (List<DistributionSetMetadata>) this.distributionSetMetadataRepository.save(metadata); return (List<DistributionSetMetadata>) distributionSetMetadataRepository.save(metadata);
} }
/** /**
@@ -811,8 +811,8 @@ public class DistributionSetManagement {
findOne(metadata.getId()); findOne(metadata.getId());
// touch it to update the lock revision because we are modifying the // touch it to update the lock revision because we are modifying the
// DS indirectly // DS indirectly
this.entityManager.merge(metadata.getDistributionSet()).setLastModifiedAt(0L); entityManager.merge(metadata.getDistributionSet()).setLastModifiedAt(0L);
return this.distributionSetMetadataRepository.save(metadata); return distributionSetMetadataRepository.save(metadata);
} }
/** /**
@@ -825,7 +825,7 @@ public class DistributionSetManagement {
@Modifying @Modifying
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
public void deleteDistributionSetMetadata(@NotNull final DsMetadataCompositeKey id) { 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( public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(
@NotNull final Long distributionSetId, @NotNull final Pageable pageable) { @NotNull final Long distributionSetId, @NotNull final Pageable pageable) {
return this.distributionSetMetadataRepository.findAll( return distributionSetMetadataRepository.findAll(
(Specification<DistributionSetMetadata>) (root, query, cb) -> cb.equal( (Specification<DistributionSetMetadata>) (root, query, cb) -> cb.equal(
root.get(DistributionSetMetadata_.distributionSet).get(DistributionSet_.id), distributionSetId), root.get(DistributionSetMetadata_.distributionSet).get(DistributionSet_.id), distributionSetId),
pageable); pageable);
@@ -865,7 +865,7 @@ public class DistributionSetManagement {
public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId( public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(
@NotNull final Long distributionSetId, @NotNull final Specification<DistributionSetMetadata> spec, @NotNull final Long distributionSetId, @NotNull final Specification<DistributionSetMetadata> spec,
@NotNull final Pageable pageable) { @NotNull final Pageable pageable) {
return this.distributionSetMetadataRepository return distributionSetMetadataRepository
.findAll( .findAll(
(Specification<DistributionSetMetadata>) (root, query, (Specification<DistributionSetMetadata>) (root, query,
cb) -> cb.and( cb) -> cb.and(
@@ -887,7 +887,7 @@ public class DistributionSetManagement {
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public DistributionSetMetadata findOne(@NotNull final DsMetadataCompositeKey id) { public DistributionSetMetadata findOne(@NotNull final DsMetadataCompositeKey id) {
final DistributionSetMetadata findOne = this.distributionSetMetadataRepository.findOne(id); final DistributionSetMetadata findOne = distributionSetMetadataRepository.findOne(id);
if (findOne == null) { if (findOne == null) {
throw new EntityNotFoundException("Metadata with key '" + id.getKey() + "' does not exist"); throw new EntityNotFoundException("Metadata with key '" + id.getKey() + "' does not exist");
} }
@@ -903,7 +903,7 @@ public class DistributionSetManagement {
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public DistributionSet findDistributionSetByAction(@NotNull final Action action) { 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, private void checkDistributionSetSoftwareModulesIsAllowedToModify(final DistributionSet distributionSet,
final Set<SoftwareModule> softwareModules) { final Set<SoftwareModule> softwareModules) {
if (!new HashSet<SoftwareModule>(distributionSet.getModules()).equals(softwareModules) if (!new HashSet<SoftwareModule>(distributionSet.getModules()).equals(softwareModules)
&& this.actionRepository.countByDistributionSet(distributionSet) > 0) { && actionRepository.countByDistributionSet(distributionSet) > 0) {
throw new EntityLockedException( throw new EntityLockedException(
String.format("distribution set %s:%s is already assigned to targets and cannot be changed", String.format("distribution set %s:%s is already assigned to targets and cannot be changed",
distributionSet.getName(), distributionSet.getVersion())); distributionSet.getName(), distributionSet.getVersion()));
@@ -986,7 +986,7 @@ public class DistributionSetManagement {
} }
private void checkDistributionSetSoftwareModulesIsAllowedToModify(final DistributionSet distributionSet) { private void checkDistributionSetSoftwareModulesIsAllowedToModify(final DistributionSet distributionSet) {
if (this.actionRepository.countByDistributionSet(distributionSet) > 0) { if (actionRepository.countByDistributionSet(distributionSet) > 0) {
throw new EntityLockedException( throw new EntityLockedException(
String.format("distribution set %s:%s is already assigned to targets and cannot be changed", String.format("distribution set %s:%s is already assigned to targets and cannot be changed",
distributionSet.getName(), distributionSet.getVersion())); distributionSet.getName(), distributionSet.getVersion()));
@@ -1021,14 +1021,14 @@ public class DistributionSetManagement {
final List<Specification<DistributionSet>> specList) { final List<Specification<DistributionSet>> specList) {
if (specList == null || specList.isEmpty()) { 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) { private void checkAndThrowAlreadyIfDistributionSetMetadataExists(final DsMetadataCompositeKey metadataId) {
if (this.distributionSetMetadataRepository.exists(metadataId)) { if (distributionSetMetadataRepository.exists(metadataId)) {
throw new EntityAlreadyExistsException( throw new EntityAlreadyExistsException(
"Metadata entry with key '" + metadataId.getKey() + "' already exists"); "Metadata entry with key '" + metadataId.getKey() + "' already exists");
} }
@@ -1057,13 +1057,13 @@ public class DistributionSetManagement {
final List<DistributionSet> allDs = findDistributionSetListWithDetails(dsIds); final List<DistributionSet> allDs = findDistributionSetListWithDetails(dsIds);
allDs.forEach(ds -> ds.getTags().add(tag)); 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, final DistributionSetTagAssigmentResult result = new DistributionSetTagAssigmentResult(0, save.size(), 0,
save, Collections.emptyList(), tag); save, Collections.emptyList(), tag);
this.eventBus.post(new DistributionSetTagAssigmentResultEvent(result)); eventBus.post(new DistributionSetTagAssigmentResultEvent(result));
}); });
return save; return save;
@@ -1107,6 +1107,6 @@ public class DistributionSetManagement {
private List<DistributionSet> unAssignTag(final Collection<DistributionSet> distributionSets, private List<DistributionSet> unAssignTag(final Collection<DistributionSet> distributionSets,
final DistributionSetTag tag) { final DistributionSetTag tag) {
distributionSets.forEach(ds -> ds.getTags().remove(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") @Cacheable("targetStatus")
public DataReportSeries<TargetUpdateStatus> 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 CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
final Root<Target> targetRoot = query.from(Target.class); final Root<Target> targetRoot = query.from(Target.class);
final Join<Target, TargetInfo> targetInfo = targetRoot.join(Target_.targetInfo); final Join<Target, TargetInfo> targetInfo = targetRoot.join(Target_.targetInfo);
@@ -111,7 +111,7 @@ public class ReportManagement {
// | col1 | col2 | // | col1 | col2 |
// | U_STATUS | COUNT | // | 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() final List<DataReportSeriesItem<TargetUpdateStatus>> reportSeriesItems = resultList.stream()
.map(r -> new DataReportSeriesItem<TargetUpdateStatus>((TargetUpdateStatus) r[0], (Long) r[1])) .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) { public List<InnerOuterDataReportSeries<String>> distributionUsageAssigned(final int topXEntries) {
// top X entries distribution usage // 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 CriteriaQuery<Object[]> queryTopX = cbTopX.createQuery(Object[].class);
final Root<DistributionSet> rootTopX = queryTopX.from(DistributionSet.class); final Root<DistributionSet> rootTopX = queryTopX.from(DistributionSet.class);
final ListJoin<DistributionSet, Target> joinTopX = rootTopX.join(DistributionSet_.assignedToTargets, 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))); .orderBy(cbTopX.desc(countColumn), cbTopX.asc(rootTopX.get(DistributionSet_.name)));
// | col1 | col2 | col3 | // | col1 | col2 | col3 |
// | NAME | VER | COUNT | // | 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 // end of top X entries distribution usage
return mapDistirbutionUsageResultToDataReport(topXEntries, resultListTop); return mapDistirbutionUsageResultToDataReport(topXEntries, resultListTop);
@@ -180,7 +180,7 @@ public class ReportManagement {
@Cacheable("distributionUsageInstalled") @Cacheable("distributionUsageInstalled")
public List<InnerOuterDataReportSeries<String>> distributionUsageInstalled(final int topXEntries) { public List<InnerOuterDataReportSeries<String>> distributionUsageInstalled(final int topXEntries) {
// top X entries distribution usage // 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 CriteriaQuery<Object[]> queryTopX = cbTopX.createQuery(Object[].class);
final Root<DistributionSet> rootTopX = queryTopX.from(DistributionSet.class); final Root<DistributionSet> rootTopX = queryTopX.from(DistributionSet.class);
final ListJoin<DistributionSet, TargetInfo> joinTopX = rootTopX.join(DistributionSet_.installedAtTargets, 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))); .orderBy(cbTopX.desc(countColumn), cbTopX.asc(rootTopX.get(DistributionSet_.name)));
// | col1 | col2 | col3 | // | col1 | col2 | col3 |
// | NAME | VER | COUNT | // | 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 // end of top X entries distribution usage
return mapDistirbutionUsageResultToDataReport(topXEntries, resultListTop); return mapDistirbutionUsageResultToDataReport(topXEntries, resultListTop);
@@ -215,7 +215,7 @@ public class ReportManagement {
@Cacheable("targetsCreatedOverPeriod") @Cacheable("targetsCreatedOverPeriod")
public <T extends Serializable> DataReportSeries<T> targetsCreatedOverPeriod(final DateType<T> dateType, public <T extends Serializable> DataReportSeries<T> targetsCreatedOverPeriod(final DateType<T> dateType,
final LocalDateTime from, final LocalDateTime to) { final LocalDateTime from, final LocalDateTime to) {
final Query createNativeQuery = this.entityManager final Query createNativeQuery = entityManager
.createNativeQuery(getTargetsCreatedQueryTemplate(dateType, from, to)); .createNativeQuery(getTargetsCreatedQueryTemplate(dateType, from, to));
final List<Object[]> resultList = createNativeQuery.getResultList(); final List<Object[]> resultList = createNativeQuery.getResultList();
@@ -228,16 +228,16 @@ public class ReportManagement {
private String getTargetsCreatedQueryTemplate(final DateType<?> dateType, final LocalDateTime from, private String getTargetsCreatedQueryTemplate(final DateType<?> dateType, final LocalDateTime from,
final LocalDateTime to) { final LocalDateTime to) {
switch (this.databaseType) { switch (databaseType) {
case H2_DB_TYPE: case H2_DB_TYPE:
return String.format(H2_TARGET_CREATED_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType), return String.format(H2_TARGET_CREATED_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType),
dateTimeFormatToSqlFormat(dateType), from.format(DATE_FORMAT), 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)); dateTimeFormatToSqlFormat(dateType));
case MYSQL_DB_TYPE: case MYSQL_DB_TYPE:
return String.format(MYSQL_TARGET_CREATED_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType), return String.format(MYSQL_TARGET_CREATED_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType),
dateTimeFormatToSqlFormat(dateType), from.toString(), dateTimeFormatToSqlFormat(dateType), dateTimeFormatToSqlFormat(dateType), from.toString(), dateTimeFormatToSqlFormat(dateType),
to.toString(), dateTimeFormatToSqlFormat(dateType), this.tenantAware.getCurrentTenant(), to.toString(), dateTimeFormatToSqlFormat(dateType), tenantAware.getCurrentTenant(),
dateTimeFormatToSqlFormat(dateType)); dateTimeFormatToSqlFormat(dateType));
default: default:
return null; return null;
@@ -246,16 +246,16 @@ public class ReportManagement {
private String getFeedbackReceivedQueryTemplate(final DateType<?> dateType, final LocalDateTime from, private String getFeedbackReceivedQueryTemplate(final DateType<?> dateType, final LocalDateTime from,
final LocalDateTime to) { final LocalDateTime to) {
switch (this.databaseType) { switch (databaseType) {
case H2_DB_TYPE: case H2_DB_TYPE:
return String.format(H2_CONTROLLER_FRRDBACK_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType), return String.format(H2_CONTROLLER_FRRDBACK_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType),
dateTimeFormatToSqlFormat(dateType), from.format(DATE_FORMAT), 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)); dateTimeFormatToSqlFormat(dateType));
case MYSQL_DB_TYPE: case MYSQL_DB_TYPE:
return String.format(MYSQL_CONTROLLER_FRRDBACK_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType), return String.format(MYSQL_CONTROLLER_FRRDBACK_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType),
dateTimeFormatToSqlFormat(dateType), from.toString(), dateTimeFormatToSqlFormat(dateType), dateTimeFormatToSqlFormat(dateType), from.toString(), dateTimeFormatToSqlFormat(dateType),
to.toString(), dateTimeFormatToSqlFormat(dateType), this.tenantAware.getCurrentTenant(), to.toString(), dateTimeFormatToSqlFormat(dateType), tenantAware.getCurrentTenant(),
dateTimeFormatToSqlFormat(dateType)); dateTimeFormatToSqlFormat(dateType));
default: default:
return null; return null;
@@ -277,7 +277,7 @@ public class ReportManagement {
@Cacheable("feedbackReceivedOverTime") @Cacheable("feedbackReceivedOverTime")
public <T extends Serializable> DataReportSeries<T> feedbackReceivedOverTime(final DateType<T> dateType, public <T extends Serializable> DataReportSeries<T> feedbackReceivedOverTime(final DateType<T> dateType,
final LocalDateTime from, final LocalDateTime to) { final LocalDateTime from, final LocalDateTime to) {
final Query createNativeQuery = this.entityManager final Query createNativeQuery = entityManager
.createNativeQuery(getFeedbackReceivedQueryTemplate(dateType, from, to)); .createNativeQuery(getFeedbackReceivedQueryTemplate(dateType, from, to));
final List<Object[]> resultList = createNativeQuery.getResultList(); final List<Object[]> resultList = createNativeQuery.getResultList();
@@ -311,30 +311,30 @@ public class ReportManagement {
final LocalDateTime beforeMonth = now.minusMonths(1); final LocalDateTime beforeMonth = now.minusMonths(1);
final LocalDateTime beforeYear = now.minusYears(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<>(); final List<DataReportSeriesItem<SeriesTime>> resultList = new ArrayList<>();
// hours // hours
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.HOUR, this.entityManager resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.HOUR,
.createQuery(createCountSelectTargetsLastPoll(cb, beforeHour, now)).getSingleResult())); entityManager.createQuery(createCountSelectTargetsLastPoll(cb, beforeHour, now)).getSingleResult()));
// days // days
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.DAY, this.entityManager resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.DAY, entityManager
.createQuery(createCountSelectTargetsLastPoll(cb, beforeDay, beforeHour)).getSingleResult())); .createQuery(createCountSelectTargetsLastPoll(cb, beforeDay, beforeHour)).getSingleResult()));
// weeks // weeks
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.WEEK, this.entityManager resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.WEEK, entityManager
.createQuery(createCountSelectTargetsLastPoll(cb, beforeWeek, beforeDay)).getSingleResult())); .createQuery(createCountSelectTargetsLastPoll(cb, beforeWeek, beforeDay)).getSingleResult()));
// months // months
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.MONTH, this.entityManager resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.MONTH, entityManager
.createQuery(createCountSelectTargetsLastPoll(cb, beforeMonth, beforeWeek)).getSingleResult())); .createQuery(createCountSelectTargetsLastPoll(cb, beforeMonth, beforeWeek)).getSingleResult()));
// years // years
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.YEAR, this.entityManager resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.YEAR, entityManager
.createQuery(createCountSelectTargetsLastPoll(cb, beforeYear, beforeMonth)).getSingleResult())); .createQuery(createCountSelectTargetsLastPoll(cb, beforeYear, beforeMonth)).getSingleResult()));
// years // years
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.MORE_THAN_YEAR, this.entityManager resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.MORE_THAN_YEAR,
.createQuery(createCountSelectTargetsLastPoll(cb, null, beforeYear)).getSingleResult())); entityManager.createQuery(createCountSelectTargetsLastPoll(cb, null, beforeYear)).getSingleResult()));
// never // never
resultList.add(new DataReportSeriesItem<SeriesTime>(SeriesTime.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); return new DataReportSeries<>("TargetLastPoll", resultList);
} }
@@ -415,23 +415,23 @@ public class ReportManagement {
final List<InnerOuter> outer; final List<InnerOuter> outer;
private InnerOuter(final DSName idName) { private InnerOuter(final DSName idName) {
this.name = idName; name = idName;
this.outer = new ArrayList<>(); outer = new ArrayList<>();
} }
private InnerOuter(final DSName idName, final long count) { private InnerOuter(final DSName idName, final long count) {
this.name = idName; name = idName;
this.count = count; this.count = count;
this.outer = new ArrayList<>(); outer = new ArrayList<>();
} }
private void addOuter(final DSName idName, final long count) { 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; this.count += count;
} }
private DataReportSeriesItem<String> toItem() { 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 * @return the name
*/ */
private String getName() { private String getName() {
return this.name; return name;
} }
/* /*
@@ -472,7 +472,7 @@ public class ReportManagement {
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + (this.name == null ? 0 : this.name.hashCode()); result = prime * result + (name == null ? 0 : name.hashCode());
return result; return result;
} }
@@ -494,11 +494,11 @@ public class ReportManagement {
return false; return false;
} }
final DSName other = (DSName) obj; final DSName other = (DSName) obj;
if (this.name == null) { if (name == null) {
if (other.name != null) { if (other.name != null) {
return false; return false;
} }
} else if (!this.name.equals(other.name)) { } else if (!name.equals(other.name)) {
return false; return false;
} }
return true; return true;
@@ -511,12 +511,12 @@ public class ReportManagement {
*/ */
@Override @Override
public String toString() { public String toString() {
return "DSName [name=" + this.name + "]"; return "DSName [name=" + name + "]";
} }
} }
private String dateTimeFormatToSqlFormat(final DateType<?> datatype) { private String dateTimeFormatToSqlFormat(final DateType<?> datatype) {
switch (this.databaseType) { switch (databaseType) {
case H2_DB_TYPE: case H2_DB_TYPE:
return datatype.h2Format(); return datatype.h2Format();
case MYSQL_DB_TYPE: case MYSQL_DB_TYPE:

View File

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

View File

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

View File

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

View File

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

View File

@@ -63,6 +63,6 @@ public class RolloutTargetGroup implements Serializable {
} }
public RolloutTargetGroupId getId() { 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 * @return the statusTotalCountMap the state map
*/ */
public Map<Status, Long> getStatusTotalCountMap() { 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> * @return the current target count cannot be <null>
*/ */
public Long getTotalTargetCountByStatus(final Status status) { public Long getTotalTargetCountByStatus(final Status status) {
final Long count = this.statusTotalCountMap.get(status); final Long count = statusTotalCountMap.get(status);
return count == null ? 0L : count; return count == null ? 0L : count;
} }
@@ -87,39 +87,39 @@ public class TotalTargetCountStatus {
private final void mapActionStatusToTotalTargetCountStatus( private final void mapActionStatusToTotalTargetCountStatus(
final List<TotalTargetCountActionStatus> targetCountActionStatus) { final List<TotalTargetCountActionStatus> targetCountActionStatus) {
if (targetCountActionStatus == null) { if (targetCountActionStatus == null) {
this.statusTotalCountMap.put(TotalTargetCountStatus.Status.NOTSTARTED, this.totalTargetCount); statusTotalCountMap.put(TotalTargetCountStatus.Status.NOTSTARTED, totalTargetCount);
return; return;
} }
this.statusTotalCountMap.put(Status.RUNNING, 0L); statusTotalCountMap.put(Status.RUNNING, 0L);
Long notStartedTargetCount = this.totalTargetCount; Long notStartedTargetCount = totalTargetCount;
for (final TotalTargetCountActionStatus item : targetCountActionStatus) { for (final TotalTargetCountActionStatus item : targetCountActionStatus) {
switch (item.getStatus()) { switch (item.getStatus()) {
case SCHEDULED: case SCHEDULED:
this.statusTotalCountMap.put(Status.SCHEDULED, item.getCount()); statusTotalCountMap.put(Status.SCHEDULED, item.getCount());
break; break;
case ERROR: case ERROR:
this.statusTotalCountMap.put(Status.ERROR, item.getCount()); statusTotalCountMap.put(Status.ERROR, item.getCount());
break; break;
case FINISHED: case FINISHED:
this.statusTotalCountMap.put(Status.FINISHED, item.getCount()); statusTotalCountMap.put(Status.FINISHED, item.getCount());
break; break;
case RETRIEVED: case RETRIEVED:
case RUNNING: case RUNNING:
case WARNING: case WARNING:
case DOWNLOAD: case DOWNLOAD:
case CANCELING: case CANCELING:
final Long runningItemsCount = this.statusTotalCountMap.get(Status.RUNNING) + item.getCount(); final Long runningItemsCount = statusTotalCountMap.get(Status.RUNNING) + item.getCount();
this.statusTotalCountMap.put(Status.RUNNING, runningItemsCount); statusTotalCountMap.put(Status.RUNNING, runningItemsCount);
break; break;
case CANCELED: case CANCELED:
this.statusTotalCountMap.put(Status.CANCELLED, item.getCount()); statusTotalCountMap.put(Status.CANCELLED, item.getCount());
break; break;
default: default:
throw new IllegalArgumentException("State " + item.getStatus() + "is not valid"); throw new IllegalArgumentException("State " + item.getStatus() + "is not valid");
} }
notStartedTargetCount -= item.getCount(); 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 @Override
public boolean eval(final Rollout rollout, final RolloutGroup rolloutGroup, final String expression) { public boolean eval(final Rollout rollout, final RolloutGroup rolloutGroup, final String expression) {
final Long totalGroup = this.actionRepository.countByRolloutAndRolloutGroup(rollout, rolloutGroup); final Long totalGroup = actionRepository.countByRolloutAndRolloutGroup(rollout, rolloutGroup);
final Long error = this.actionRepository.countByRolloutIdAndRolloutGroupIdAndStatus(rollout.getId(), final Long error = actionRepository.countByRolloutIdAndRolloutGroupIdAndStatus(rollout.getId(),
rolloutGroup.getId(), Action.Status.ERROR); rolloutGroup.getId(), Action.Status.ERROR);
try { try {
final Integer threshold = Integer.valueOf(expression); final Integer threshold = Integer.valueOf(expression);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -102,7 +102,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
@PostConstruct @PostConstruct
protected void init() { protected void init() {
super.init(); super.init();
this.eventBus.subscribe(this); eventBus.subscribe(this);
} }
@PreDestroy @PreDestroy
@@ -111,7 +111,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* It's good manners to do this, even though vaadin-spring will * It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected. * automatically unsubscribe when this UI is garbage collected.
*/ */
this.eventBus.unsubscribe(this); eventBus.unsubscribe(this);
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
@@ -129,9 +129,9 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
UI.getCurrent().access(() -> { UI.getCurrent().access(() -> {
if (!hasUnsavedActions()) { if (!hasUnsavedActions()) {
closeUnsavedActionsWindow(); closeUnsavedActionsWindow();
final String message = this.distConfirmationWindowLayout.getConsolidatedMessage(); final String message = distConfirmationWindowLayout.getConsolidatedMessage();
if (message != null && message.length() > 0) { if (message != null && message.length() > 0) {
this.notification.displaySuccess(message); notification.displaySuccess(message);
} }
} }
updateDSActionCount(); updateDSActionCount();
@@ -148,7 +148,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
*/ */
@Override @Override
protected boolean hasDeletePermission() { protected boolean hasDeletePermission() {
return this.permChecker.hasDeleteDistributionPermission(); return permChecker.hasDeleteDistributionPermission();
} }
@@ -162,7 +162,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override @Override
protected boolean hasUpdatePermission() { protected boolean hasUpdatePermission() {
return this.permChecker.hasUpdateDistributionPermission(); return permChecker.hasUpdateDistributionPermission();
} }
/* /*
@@ -174,7 +174,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
*/ */
@Override @Override
protected String getDeleteAreaLabel() { 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 @Override
protected AcceptCriterion getDeleteLayoutAcceptCriteria() { protected AcceptCriterion getDeleteLayoutAcceptCriteria() {
return this.distributionsViewAcceptCriteria; return distributionsViewAcceptCriteria;
} }
/* /*
@@ -228,7 +228,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
processDeleteSWType(sourceComponent.getId()); processDeleteSWType(sourceComponent.getId());
} }
this.eventBus.publish(this, DragEvent.HIDE_DROP_HINT); eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
hideDropHints(); hideDropHints();
} }
@@ -237,12 +237,12 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
final String distTypeName = HawkbitCommonUtil.removePrefix(distTypeId, final String distTypeName = HawkbitCommonUtil.removePrefix(distTypeId,
SPUIDefinitions.DISTRIBUTION_SET_TYPE_ID_PREFIXS); SPUIDefinitions.DISTRIBUTION_SET_TYPE_ID_PREFIXS);
if (isDsTypeSelected(distTypeName)) { if (isDsTypeSelected(distTypeName)) {
this.notification.displayValidationError( notification
this.i18n.get("message.dist.type.check.delete", new Object[] { distTypeName })); .displayValidationError(i18n.get("message.dist.type.check.delete", new Object[] { distTypeName }));
} else if (isDefaultDsType(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 { } else {
this.manageDistUIState.getSelectedDeleteDistSetTypes().add(distTypeName); manageDistUIState.getSelectedDeleteDistSetTypes().add(distTypeName);
updateDSActionCount(); updateDSActionCount();
} }
} }
@@ -254,7 +254,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* @return true if ds type is selected * @return true if ds type is selected
*/ */
private boolean isDsTypeSelected(final String distTypeName) { 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); .getManageDistFilters().getClickedDistSetType().getName().equalsIgnoreCase(distTypeName);
} }
@@ -262,13 +262,13 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
final String swModuleTypeName = HawkbitCommonUtil.removePrefix(swTypeId, final String swModuleTypeName = HawkbitCommonUtil.removePrefix(swTypeId,
SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS); SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS);
if (this.manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent() if (manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent()
&& this.manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName() && manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName()
.equalsIgnoreCase(swModuleTypeName)) { .equalsIgnoreCase(swModuleTypeName)) {
this.notification.displayValidationError( notification.displayValidationError(
this.i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName })); i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName }));
} else { } else {
this.manageDistUIState.getSelectedDeleteSWModuleTypes().add(swModuleTypeName); manageDistUIState.getSelectedDeleteSWModuleTypes().add(swModuleTypeName);
updateDSActionCount(); updateDSActionCount();
} }
@@ -288,9 +288,9 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* the deleted list (or) some distributions are already in the deleted * the deleted list (or) some distributions are already in the deleted
* distribution list. * distribution list.
*/ */
final int existingDeletedDistributionsSize = this.manageDistUIState.getDeletedDistributionList().size(); final int existingDeletedDistributionsSize = manageDistUIState.getDeletedDistributionList().size();
this.manageDistUIState.getDeletedDistributionList().addAll(distributionIdNameSet); manageDistUIState.getDeletedDistributionList().addAll(distributionIdNameSet);
final int newDeletedDistributionsSize = this.manageDistUIState.getDeletedDistributionList().size(); final int newDeletedDistributionsSize = manageDistUIState.getDeletedDistributionList().size();
if (newDeletedDistributionsSize == existingDeletedDistributionsSize) { if (newDeletedDistributionsSize == existingDeletedDistributionsSize) {
/* /*
* No new distributions are added, all distributions dropped now are * No new distributions are added, all distributions dropped now are
@@ -298,7 +298,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* message accordingly. * 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()) { } else if (newDeletedDistributionsSize - existingDeletedDistributionsSize != distributionIdNameSet.size()) {
/* /*
* Not the all distributions dropped now are added to the delete * 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. * 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 -> { swModuleIdNameSet.forEach(id -> {
final String swModuleName = (String) sourceTable.getContainerDataSource().getItem(id) final String swModuleName = (String) sourceTable.getContainerDataSource().getItem(id)
.getItemProperty(SPUILabelDefinitions.NAME_VERSION).getValue(); .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. * Update the software module delete count.
*/ */
private void updateDSActionCount() { private void updateDSActionCount() {
int count = this.manageDistUIState.getSelectedDeleteDistSetTypes().size() int count = manageDistUIState.getSelectedDeleteDistSetTypes().size()
+ this.manageDistUIState.getSelectedDeleteSWModuleTypes().size() + manageDistUIState.getSelectedDeleteSWModuleTypes().size()
+ this.manageDistUIState.getDeleteSofwareModulesList().size() + manageDistUIState.getDeleteSofwareModulesList().size()
+ this.manageDistUIState.getDeletedDistributionList().size(); + manageDistUIState.getDeletedDistributionList().size();
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> mapEntry : this.manageDistUIState for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> mapEntry : manageDistUIState
.getAssignedList().entrySet()) { .getAssignedList().entrySet()) {
count += this.manageDistUIState.getAssignedList().get(mapEntry.getKey()).size(); count += manageDistUIState.getAssignedList().get(mapEntry.getKey()).size();
} }
updateActionsCount(count); updateActionsCount(count);
} }
@@ -375,7 +375,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
*/ */
@Override @Override
protected String getNoActionsButtonLabel() { 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 @Override
protected String getActionsButtonLabel() { protected String getActionsButtonLabel() {
return this.i18n.get("button.actions"); return i18n.get("button.actions");
} }
@@ -414,7 +414,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
*/ */
@Override @Override
protected String getUnsavedActionsWindowCaption() { 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 @Override
protected void unsavedActionsWindowClosed() { protected void unsavedActionsWindowClosed() {
final String message = this.distConfirmationWindowLayout.getConsolidatedMessage(); final String message = distConfirmationWindowLayout.getConsolidatedMessage();
if (message != null && message.length() > 0) { if (message != null && message.length() > 0) {
this.notification.displaySuccess(message); notification.displaySuccess(message);
} }
} }
@@ -442,8 +442,8 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
*/ */
@Override @Override
protected Component getUnsavedActionsWindowContent() { protected Component getUnsavedActionsWindowContent() {
this.distConfirmationWindowLayout.init(); distConfirmationWindowLayout.init();
return this.distConfirmationWindowLayout; return distConfirmationWindowLayout;
} }
/* /*
@@ -457,12 +457,12 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
protected boolean hasUnsavedActions() { protected boolean hasUnsavedActions() {
boolean unSavedActionsTypes = false; boolean unSavedActionsTypes = false;
boolean unSavedActionsTables = false; boolean unSavedActionsTables = false;
if (!this.manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty() if (!manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()
|| !this.manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()) { || !manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()) {
unSavedActionsTypes = true; unSavedActionsTypes = true;
} else if (!this.manageDistUIState.getDeleteSofwareModulesList().isEmpty() } else if (!manageDistUIState.getDeleteSofwareModulesList().isEmpty()
|| !this.manageDistUIState.getDeletedDistributionList().isEmpty() || !manageDistUIState.getDeletedDistributionList().isEmpty()
|| !this.manageDistUIState.getAssignedList().isEmpty()) { || !manageDistUIState.getAssignedList().isEmpty()) {
unSavedActionsTables = true; unSavedActionsTables = true;
} }
@@ -517,7 +517,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
} }
private DistributionSetType getCurrentDistributionSetType() { 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() { protected Map<String, ConfirmationTab> getConfimrationTabs() {
final Map<String, ConfirmationTab> tabs = new HashMap<>(); final Map<String, ConfirmationTab> tabs = new HashMap<>();
/* Create tab for SW Modules delete */ /* Create tab for SW Modules delete */
if (!this.manageDistUIState.getDeleteSofwareModulesList().isEmpty()) { if (!manageDistUIState.getDeleteSofwareModulesList().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab()); tabs.put(i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
} }
/* Create tab for SW Module Type delete */ /* Create tab for SW Module Type delete */
if (!this.manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()) { if (!manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab()); tabs.put(i18n.get("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab());
} }
/* Create tab for Distributions delete */ /* Create tab for Distributions delete */
if (!this.manageDistUIState.getDeletedDistributionList().isEmpty()) { if (!manageDistUIState.getDeletedDistributionList().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.dist.accordion.tab"), createDistDeleteConfirmationTab()); tabs.put(i18n.get("caption.delete.dist.accordion.tab"), createDistDeleteConfirmationTab());
} }
/* Create tab for Distribution Set Types delete */ /* Create tab for Distribution Set Types delete */
if (!this.manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()) { if (!manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.dist.set.type.accordion.tab"), tabs.put(i18n.get("caption.delete.dist.set.type.accordion.tab"), createDistSetTypeDeleteConfirmationTab());
createDistSetTypeDeleteConfirmationTab());
} }
/* Create tab for Assign Software Module */ /* Create tab for Assign Software Module */
if (!this.manageDistUIState.getAssignedList().isEmpty()) { if (!manageDistUIState.getAssignedList().isEmpty()) {
tabs.put(this.i18n.get("caption.assign.dist.accordion.tab"), createAssignSWModuleConfirmationTab()); tabs.put(i18n.get("caption.assign.dist.accordion.tab"), createAssignSWModuleConfirmationTab());
} }
return tabs; return tabs;
@@ -151,10 +150,10 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
tab.getConfirmAll().setId(SPUIComponetIdProvider.SW_DELETE_ALL); tab.getConfirmAll().setId(SPUIComponetIdProvider.SW_DELETE_ALL);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); 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.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)); tab.getDiscardAll().addClickListener(event -> discardSMAll(tab));
/* Add items container to the table. */ /* Add items container to the table. */
@@ -177,8 +176,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) { if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(SW_MODULE_NAME_MSG); visibleColumnIds.add(SW_MODULE_NAME_MSG);
visibleColumnIds.add(SW_DISCARD_CHGS); visibleColumnIds.add(SW_DISCARD_CHGS);
visibleColumnLabels.add(this.i18n.get("upload.swModuleTable.header")); visibleColumnLabels.add(i18n.get("upload.swModuleTable.header"));
visibleColumnLabels.add(this.i18n.get("header.second.deletetarget.table")); visibleColumnLabels.add(i18n.get("header.second.deletetarget.table"));
} }
tab.getTable().setVisibleColumns(visibleColumnIds.toArray()); tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0])); tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
@@ -190,36 +189,35 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
} }
private void deleteSMAll(final ConfirmationTab tab) { 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(); removeAssignedSoftwareModules();
} }
this.softwareManagement.deleteSoftwareModules(swmoduleIds); softwareManagement.deleteSoftwareModules(swmoduleIds);
addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ this.i18n.get("message.swModule.deleted", swmoduleIds.size())); + i18n.get("message.swModule.deleted", swmoduleIds.size()));
this.manageDistUIState.getDeleteSofwareModulesList().clear(); manageDistUIState.getDeleteSofwareModulesList().clear();
removeCurrentTab(tab); removeCurrentTab(tab);
setActionMessage(this.i18n.get("message.software.delete.success")); setActionMessage(i18n.get("message.software.delete.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DELETE_ALL_SOFWARE); eventBus.publish(this, SaveActionWindowEvent.DELETE_ALL_SOFWARE);
} }
private void removeAssignedSoftwareModules() { private void removeAssignedSoftwareModules() {
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entryAssignSM : this.manageDistUIState for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entryAssignSM : manageDistUIState
.getAssignedList().entrySet()) { .getAssignedList().entrySet()) {
for (final Entry<Long, String> entryDeleteSM : this.manageDistUIState.getDeleteSofwareModulesList() for (final Entry<Long, String> entryDeleteSM : manageDistUIState.getDeleteSofwareModulesList().entrySet()) {
.entrySet()) {
final SoftwareModuleIdName smIdName = new SoftwareModuleIdName(entryDeleteSM.getKey(), final SoftwareModuleIdName smIdName = new SoftwareModuleIdName(entryDeleteSM.getKey(),
entryDeleteSM.getValue()); entryDeleteSM.getValue());
if (entryAssignSM.getValue().contains(smIdName)) { if (entryAssignSM.getValue().contains(smIdName)) {
entryAssignSM.getValue().remove(smIdName); entryAssignSM.getValue().remove(smIdName);
this.assignmnetTab.getTable().removeItem(HawkbitCommonUtil.concatStrings("|||", assignmnetTab.getTable().removeItem(HawkbitCommonUtil.concatStrings("|||",
entryAssignSM.getKey().getId().toString(), smIdName.getId().toString())); entryAssignSM.getKey().getId().toString(), smIdName.getId().toString()));
} }
if (entryAssignSM.getValue().isEmpty()) { 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) { private void discardSMAll(final ConfirmationTab tab) {
removeCurrentTab(tab); removeCurrentTab(tab);
this.manageDistUIState.getDeleteSofwareModulesList().clear(); manageDistUIState.getDeleteSofwareModulesList().clear();
setActionMessage(this.i18n.get("message.software.discard.success")); setActionMessage(i18n.get("message.software.discard.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_SOFTWARE); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_SOFTWARE);
} }
/** /**
@@ -242,29 +240,29 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
final IndexedContainer swcontactContainer = new IndexedContainer(); final IndexedContainer swcontactContainer = new IndexedContainer();
swcontactContainer.addContainerProperty("SWModuleId", String.class, ""); swcontactContainer.addContainerProperty("SWModuleId", String.class, "");
swcontactContainer.addContainerProperty(SW_MODULE_NAME_MSG, 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); final Item item = swcontactContainer.addItem(swModuleID);
item.getItemProperty("SWModuleId").setValue(swModuleID.toString()); item.getItemProperty("SWModuleId").setValue(swModuleID.toString());
item.getItemProperty(SW_MODULE_NAME_MSG) item.getItemProperty(SW_MODULE_NAME_MSG)
.setValue(this.manageDistUIState.getDeleteSofwareModulesList().get(swModuleID)); .setValue(manageDistUIState.getDeleteSofwareModulesList().get(swModuleID));
} }
return swcontactContainer; return swcontactContainer;
} }
private void discardSoftwareDelete(final Button.ClickEvent event, final Object itemId, final ConfirmationTab tab) { private void discardSoftwareDelete(final Button.ClickEvent event, final Object itemId, final ConfirmationTab tab) {
final Long swmoduleId = (Long) ((Button) event.getComponent()).getData(); final Long swmoduleId = (Long) ((Button) event.getComponent()).getData();
if (null != this.manageDistUIState.getDeleteSofwareModulesList() if (null != manageDistUIState.getDeleteSofwareModulesList()
&& !this.manageDistUIState.getDeleteSofwareModulesList().isEmpty() && !manageDistUIState.getDeleteSofwareModulesList().isEmpty()
&& this.manageDistUIState.getDeleteSofwareModulesList().containsKey(swmoduleId)) { && manageDistUIState.getDeleteSofwareModulesList().containsKey(swmoduleId)) {
this.manageDistUIState.getDeleteSofwareModulesList().remove(swmoduleId); manageDistUIState.getDeleteSofwareModulesList().remove(swmoduleId);
} }
tab.getTable().getContainerDataSource().removeItem(itemId); tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size(); final int deleteCount = tab.getTable().size();
if (0 == deleteCount) { if (0 == deleteCount) {
removeCurrentTab(tab); removeCurrentTab(tab);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_SOFTWARE); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_SOFTWARE);
} else { } 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().setId(SPUIComponetIdProvider.SAVE_DELETE_SW_MODULE_TYPE);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); 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.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().setId(SPUIComponetIdProvider.DISCARD_SW_MODULE_TYPE);
tab.getDiscardAll().addClickListener(event -> discardSMtypeAll(tab)); tab.getDiscardAll().addClickListener(event -> discardSMtypeAll(tab));
@@ -303,8 +301,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) { if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(SW_MODULE_TYPE_NAME); visibleColumnIds.add(SW_MODULE_TYPE_NAME);
visibleColumnIds.add(DISCARD); visibleColumnIds.add(DISCARD);
visibleColumnLabels.add(this.i18n.get("header.first.delete.swmodule.type.table")); visibleColumnLabels.add(i18n.get("header.first.delete.swmodule.type.table"));
visibleColumnLabels.add(this.i18n.get("header.second.delete.swmodule.type.table")); visibleColumnLabels.add(i18n.get("header.second.delete.swmodule.type.table"));
} }
tab.getTable().setVisibleColumns(visibleColumnIds.toArray()); tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
@@ -317,32 +315,32 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
} }
private void deleteSMtypeAll(final ConfirmationTab tab) { private void deleteSMtypeAll(final ConfirmationTab tab) {
final int deleteSWModuleTypeCount = this.manageDistUIState.getSelectedDeleteSWModuleTypes().size(); final int deleteSWModuleTypeCount = manageDistUIState.getSelectedDeleteSWModuleTypes().size();
for (final String swModuleTypeName : this.manageDistUIState.getSelectedDeleteSWModuleTypes()) { for (final String swModuleTypeName : manageDistUIState.getSelectedDeleteSWModuleTypes()) {
this.softwareManagement softwareManagement
.deleteSoftwareModuleType(this.softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName)); .deleteSoftwareModuleType(softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName));
} }
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ this.i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount })); + i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount }));
this.manageDistUIState.getSelectedDeleteSWModuleTypes().clear(); manageDistUIState.getSelectedDeleteSWModuleTypes().clear();
removeCurrentTab(tab); removeCurrentTab(tab);
setActionMessage(this.i18n.get("message.software.type.delete.success")); setActionMessage(i18n.get("message.software.type.delete.success"));
this.eventBus.publish(this, SaveActionWindowEvent.SAVED_DELETE_SW_MODULE_TYPES); eventBus.publish(this, SaveActionWindowEvent.SAVED_DELETE_SW_MODULE_TYPES);
} }
private void discardSMtypeAll(final ConfirmationTab tab) { private void discardSMtypeAll(final ConfirmationTab tab) {
removeCurrentTab(tab); removeCurrentTab(tab);
this.manageDistUIState.getSelectedDeleteSWModuleTypes().clear(); manageDistUIState.getSelectedDeleteSWModuleTypes().clear();
setActionMessage(this.i18n.get("message.software.type.discard.success")); setActionMessage(i18n.get("message.software.type.discard.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_SW_MODULE_TYPES); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_SW_MODULE_TYPES);
} }
private Container getSWModuleTypeTableContainer() { private Container getSWModuleTypeTableContainer() {
final IndexedContainer contactContainer = new IndexedContainer(); final IndexedContainer contactContainer = new IndexedContainer();
contactContainer.addContainerProperty(SW_MODULE_TYPE_NAME, String.class, ""); 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); final Item saveTblitem = contactContainer.addItem(swModuleTypeName);
saveTblitem.getItemProperty(SW_MODULE_TYPE_NAME).setValue(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, private void discardSoftwareTypeDelete(final String discardSWModuleType, final Object itemId,
final ConfirmationTab tab) { final ConfirmationTab tab) {
if (null != this.manageDistUIState.getSelectedDeleteSWModuleTypes() if (null != manageDistUIState.getSelectedDeleteSWModuleTypes()
&& !this.manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty() && !manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()
&& this.manageDistUIState.getSelectedDeleteSWModuleTypes().contains(discardSWModuleType)) { && manageDistUIState.getSelectedDeleteSWModuleTypes().contains(discardSWModuleType)) {
this.manageDistUIState.getSelectedDeleteSWModuleTypes().remove(discardSWModuleType); manageDistUIState.getSelectedDeleteSWModuleTypes().remove(discardSWModuleType);
} }
tab.getTable().getContainerDataSource().removeItem(itemId); tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size(); final int deleteCount = tab.getTable().size();
if (0 == deleteCount) { if (0 == deleteCount) {
removeCurrentTab(tab); removeCurrentTab(tab);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_SW_MODULE_TYPES); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_SW_MODULE_TYPES);
} else { } 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().setId(SPUIComponetIdProvider.DIST_DELETE_ALL);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); 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.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)); tab.getDiscardAll().addClickListener(event -> discardDistAll(tab));
/* Add items container to the table. */ /* Add items container to the table. */
@@ -400,8 +398,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) { if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(DIST_NAME); visibleColumnIds.add(DIST_NAME);
visibleColumnIds.add(DISCARD); visibleColumnIds.add(DISCARD);
visibleColumnLabels.add(this.i18n.get("header.one.deletedist.table")); visibleColumnLabels.add(i18n.get("header.one.deletedist.table"));
visibleColumnLabels.add(this.i18n.get("header.second.deletedist.table")); visibleColumnLabels.add(i18n.get("header.second.deletedist.table"));
} }
tab.getTable().setVisibleColumns(visibleColumnIds.toArray()); tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0])); tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
@@ -414,12 +412,12 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
/* Delete Distributions. */ /* Delete Distributions. */
private void deleteDistAll(final ConfirmationTab tab) { private void deleteDistAll(final ConfirmationTab tab) {
final Long[] deletedIds = this.manageDistUIState.getDeletedDistributionList().stream() final Long[] deletedIds = manageDistUIState.getDeletedDistributionList().stream().map(idName -> idName.getId())
.map(idName -> idName.getId()).toArray(Long[]::new); .toArray(Long[]::new);
if (null != this.manageDistUIState.getAssignedList() && !this.manageDistUIState.getAssignedList().isEmpty()) { if (null != manageDistUIState.getAssignedList() && !manageDistUIState.getAssignedList().isEmpty()) {
this.manageDistUIState.getDeletedDistributionList().forEach(distSetName -> { manageDistUIState.getDeletedDistributionList().forEach(distSetName -> {
if (this.manageDistUIState.getAssignedList().containsKey(distSetName)) { if (manageDistUIState.getAssignedList().containsKey(distSetName)) {
this.manageDistUIState.getAssignedList().remove(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 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() manageDistUIState.getDeletedDistributionList()
.forEach(deletedIdname -> this.manageDistUIState.getAssignedList().remove(deletedIdname)); .forEach(deletedIdname -> manageDistUIState.getAssignedList().remove(deletedIdname));
removeCurrentTab(tab); removeCurrentTab(tab);
this.manageDistUIState.getDeletedDistributionList().clear(); manageDistUIState.getDeletedDistributionList().clear();
this.eventBus.publish(this, SaveActionWindowEvent.DELETED_DISTRIBUTIONS); eventBus.publish(this, SaveActionWindowEvent.DELETED_DISTRIBUTIONS);
} }
private void discardDistAll(final ConfirmationTab tab) { private void discardDistAll(final ConfirmationTab tab) {
removeCurrentTab(tab); removeCurrentTab(tab);
this.manageDistUIState.getDeletedDistributionList().clear(); manageDistUIState.getDeletedDistributionList().clear();
setActionMessage(this.i18n.get("message.dist.discard.success")); setActionMessage(i18n.get("message.dist.discard.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DISTRIBUTIONS); 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_ID_NAME, DistributionSetIdName.class, "");
contactContainer.addContainerProperty(DIST_NAME, String.class, ""); contactContainer.addContainerProperty(DIST_NAME, String.class, "");
Item item; Item item;
for (final DistributionSetIdName distIdName : this.manageDistUIState.getDeletedDistributionList()) { for (final DistributionSetIdName distIdName : manageDistUIState.getDeletedDistributionList()) {
item = contactContainer.addItem(distIdName); item = contactContainer.addItem(distIdName);
item.getItemProperty(DIST_NAME).setValue(distIdName.getName().concat(":" + distIdName.getVersion())); 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) { private void discardDistDelete(final Button.ClickEvent event, final Object itemId, final ConfirmationTab tab) {
final DistributionSetIdName distId = (DistributionSetIdName) ((Button) event.getComponent()).getData(); final DistributionSetIdName distId = (DistributionSetIdName) ((Button) event.getComponent()).getData();
if (null != this.manageDistUIState.getDeletedDistributionList() if (null != manageDistUIState.getDeletedDistributionList()
&& !this.manageDistUIState.getDeletedDistributionList().isEmpty() && !manageDistUIState.getDeletedDistributionList().isEmpty()
&& this.manageDistUIState.getDeletedDistributionList().contains(distId)) { && manageDistUIState.getDeletedDistributionList().contains(distId)) {
this.manageDistUIState.getDeletedDistributionList().remove(distId); manageDistUIState.getDeletedDistributionList().remove(distId);
} }
tab.getTable().getContainerDataSource().removeItem(itemId); tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size(); final int deleteCount = tab.getTable().size();
if (0 == deleteCount) { if (0 == deleteCount) {
removeCurrentTab(tab); removeCurrentTab(tab);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DISTRIBUTIONS); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DISTRIBUTIONS);
} else { } 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().setId(SPUIComponetIdProvider.SAVE_DELETE_DIST_SET_TYPE);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); 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.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().setId(SPUIComponetIdProvider.DISCARD_DIST_SET_TYPE);
tab.getDiscardAll().addClickListener(event -> discardDistSetTypeAll(tab)); tab.getDiscardAll().addClickListener(event -> discardDistSetTypeAll(tab));
@@ -515,8 +513,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) { if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(DIST_SET_NAME); visibleColumnIds.add(DIST_SET_NAME);
visibleColumnIds.add(DISCARD); visibleColumnIds.add(DISCARD);
visibleColumnLabels.add(this.i18n.get("header.first.delete.dist.type.table")); visibleColumnLabels.add(i18n.get("header.first.delete.dist.type.table"));
visibleColumnLabels.add(this.i18n.get("header.second.delete.dist.type.table")); visibleColumnLabels.add(i18n.get("header.second.delete.dist.type.table"));
} }
tab.getTable().setVisibleColumns(visibleColumnIds.toArray()); tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
@@ -530,32 +528,31 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private void deleteDistSetTypeAll(final ConfirmationTab tab) { private void deleteDistSetTypeAll(final ConfirmationTab tab) {
final int deleteDistTypeCount = this.manageDistUIState.getSelectedDeleteDistSetTypes().size(); final int deleteDistTypeCount = manageDistUIState.getSelectedDeleteDistSetTypes().size();
for (final String deleteDistTypeName : this.manageDistUIState.getSelectedDeleteDistSetTypes()) { for (final String deleteDistTypeName : manageDistUIState.getSelectedDeleteDistSetTypes()) {
this.dsManagement dsManagement.deleteDistributionSetType(dsManagement.findDistributionSetTypeByName(deleteDistTypeName));
.deleteDistributionSetType(this.dsManagement.findDistributionSetTypeByName(deleteDistTypeName));
} }
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ this.i18n.get("message.dist.type.delete", new Object[] { deleteDistTypeCount })); + i18n.get("message.dist.type.delete", new Object[] { deleteDistTypeCount }));
this.manageDistUIState.getSelectedDeleteDistSetTypes().clear(); manageDistUIState.getSelectedDeleteDistSetTypes().clear();
removeCurrentTab(tab); removeCurrentTab(tab);
setActionMessage(this.i18n.get("message.dist.set.type.deleted.success")); setActionMessage(i18n.get("message.dist.set.type.deleted.success"));
this.eventBus.publish(this, SaveActionWindowEvent.SAVED_DELETE_DIST_SET_TYPES); eventBus.publish(this, SaveActionWindowEvent.SAVED_DELETE_DIST_SET_TYPES);
} }
private void discardDistSetTypeAll(final ConfirmationTab tab) { private void discardDistSetTypeAll(final ConfirmationTab tab) {
removeCurrentTab(tab); removeCurrentTab(tab);
this.manageDistUIState.getSelectedDeleteDistSetTypes().clear(); manageDistUIState.getSelectedDeleteDistSetTypes().clear();
setActionMessage(this.i18n.get("message.dist.type.discard.success")); setActionMessage(i18n.get("message.dist.type.discard.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_DIST_SET_TYPES); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_DIST_SET_TYPES);
} }
private IndexedContainer getDistSetTypeTableContainer() { private IndexedContainer getDistSetTypeTableContainer() {
final IndexedContainer contactContainer = new IndexedContainer(); final IndexedContainer contactContainer = new IndexedContainer();
contactContainer.addContainerProperty(DIST_SET_NAME, String.class, ""); 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); final Item saveTblitem = contactContainer.addItem(distTypeMName);
saveTblitem.getItemProperty(DIST_SET_NAME).setValue(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) { private void discardDistTypeDelete(final String discardDSType, final Object itemId, final ConfirmationTab tab) {
if (null != this.manageDistUIState.getSelectedDeleteDistSetTypes() if (null != manageDistUIState.getSelectedDeleteDistSetTypes()
&& !this.manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty() && !manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()
&& this.manageDistUIState.getSelectedDeleteDistSetTypes().contains(discardDSType)) { && manageDistUIState.getSelectedDeleteDistSetTypes().contains(discardDSType)) {
this.manageDistUIState.getSelectedDeleteDistSetTypes().remove(discardDSType); manageDistUIState.getSelectedDeleteDistSetTypes().remove(discardDSType);
} }
tab.getTable().getContainerDataSource().removeItem(itemId); tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size(); final int deleteCount = tab.getTable().size();
if (0 == deleteCount) { if (0 == deleteCount) {
removeCurrentTab(tab); removeCurrentTab(tab);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_DIST_SET_TYPES); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_DIST_SET_TYPES);
} else { } else {
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_DELETE_DIST_SET_TYPE); eventBus.publish(this, SaveActionWindowEvent.DISCARD_DELETE_DIST_SET_TYPE);
} }
} }
/* For Assign software modules */ /* For Assign software modules */
private ConfirmationTab createAssignSWModuleConfirmationTab() { private ConfirmationTab createAssignSWModuleConfirmationTab() {
this.assignmnetTab = new ConfirmationTab(); assignmnetTab = new ConfirmationTab();
this.assignmnetTab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_ASSIGNMENT); assignmnetTab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_ASSIGNMENT);
this.assignmnetTab.getConfirmAll().setIcon(FontAwesome.SAVE); assignmnetTab.getConfirmAll().setIcon(FontAwesome.SAVE);
this.assignmnetTab.getConfirmAll().setCaption(this.i18n.get("button.assign.all")); assignmnetTab.getConfirmAll().setCaption(i18n.get("button.assign.all"));
this.assignmnetTab.getConfirmAll().addClickListener(event -> saveAllAssignments(this.assignmnetTab)); assignmnetTab.getConfirmAll().addClickListener(event -> saveAllAssignments(assignmnetTab));
this.assignmnetTab.getDiscardAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); assignmnetTab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
this.assignmnetTab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_ASSIGNMENT); assignmnetTab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_ASSIGNMENT);
this.assignmnetTab.getDiscardAll().addClickListener(event -> discardAllSWAssignments(this.assignmnetTab)); assignmnetTab.getDiscardAll().addClickListener(event -> discardAllSWAssignments(assignmnetTab));
// Add items container to the table. // Add items container to the table.
this.assignmnetTab.getTable().setContainerDataSource(getSWAssignmentsTableContainer()); assignmnetTab.getTable().setContainerDataSource(getSWAssignmentsTableContainer());
// Add the discard action column // 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); final StringBuilder style = new StringBuilder(ValoTheme.BUTTON_TINY);
style.append(' '); style.append(' ');
style.append(SPUIStyleDefinitions.REDICON); style.append(SPUIStyleDefinitions.REDICON);
@@ -609,7 +606,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
deleteIcon.setData(itemId); deleteIcon.setData(itemId);
deleteIcon.setImmediate(true); deleteIcon.setImmediate(true);
deleteIcon.addClickListener(event -> discardSWAssignment((String) ((Button) event.getComponent()).getData(), deleteIcon.addClickListener(event -> discardSWAssignment((String) ((Button) event.getComponent()).getData(),
itemId, this.assignmnetTab)); itemId, assignmnetTab));
return deleteIcon; return deleteIcon;
}); });
@@ -620,19 +617,19 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
visibleColumnIds.add(DIST_NAME); visibleColumnIds.add(DIST_NAME);
visibleColumnIds.add(SOFTWARE_MODULE_NAME); visibleColumnIds.add(SOFTWARE_MODULE_NAME);
visibleColumnIds.add(DISCARD); visibleColumnIds.add(DISCARD);
visibleColumnLabels.add(this.i18n.get("header.dist.first.assignment.table")); visibleColumnLabels.add(i18n.get("header.dist.first.assignment.table"));
visibleColumnLabels.add(this.i18n.get("header.dist.second.assignment.table")); visibleColumnLabels.add(i18n.get("header.dist.second.assignment.table"));
visibleColumnLabels.add(this.i18n.get("header.third.assignment.table")); visibleColumnLabels.add(i18n.get("header.third.assignment.table"));
} }
this.assignmnetTab.getTable().setVisibleColumns(visibleColumnIds.toArray()); assignmnetTab.getTable().setVisibleColumns(visibleColumnIds.toArray());
this.assignmnetTab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0])); assignmnetTab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
this.assignmnetTab.getTable().setColumnExpandRatio(DIST_NAME, 2); assignmnetTab.getTable().setColumnExpandRatio(DIST_NAME, 2);
this.assignmnetTab.getTable().setColumnExpandRatio(SOFTWARE_MODULE_NAME, 2); assignmnetTab.getTable().setColumnExpandRatio(SOFTWARE_MODULE_NAME, 2);
this.assignmnetTab.getTable().setColumnExpandRatio(DISCARD, SPUIDefinitions.DISCARD_COLUMN_WIDTH); assignmnetTab.getTable().setColumnExpandRatio(DISCARD, SPUIDefinitions.DISCARD_COLUMN_WIDTH);
this.assignmnetTab.getTable().setColumnAlignment(DISCARD, Align.CENTER); assignmnetTab.getTable().setColumnAlignment(DISCARD, Align.CENTER);
return this.assignmnetTab; return assignmnetTab;
} }
@@ -644,7 +641,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
contactContainer.addContainerProperty(DIST_ID_NAME, DistributionSetIdName.class, ""); contactContainer.addContainerProperty(DIST_ID_NAME, DistributionSetIdName.class, "");
contactContainer.addContainerProperty(SOFTWARE_MODULE_ID_NAME, SoftwareModuleIdName.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(); .getAssignedList();
assignedList.forEach((distIdname, softIdNameSet) -> softIdNameSet.forEach(softIdName -> { assignedList.forEach((distIdname, softIdNameSet) -> softIdNameSet.forEach(softIdName -> {
@@ -663,38 +660,38 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
} }
private void saveAllAssignments(final ConfirmationTab tab) { 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()) final List<Long> softIds = softIdNameSet.stream().map(softIdName -> softIdName.getId())
.collect(Collectors.toList()); .collect(Collectors.toList());
final List<SoftwareModule> softwareModules = this.softwareManagement.findSoftwareModulesById(softIds); final List<SoftwareModule> softwareModules = softwareManagement.findSoftwareModulesById(softIds);
softwareModules.forEach(ds::addModule); softwareModules.forEach(ds::addModule);
this.dsManagement.updateDistributionSet(ds); dsManagement.updateDistributionSet(ds);
}); });
int count = 0; int count = 0;
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entry : this.manageDistUIState for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entry : manageDistUIState
.getAssignedList().entrySet()) { .getAssignedList().entrySet()) {
count += entry.getValue().size(); count += entry.getValue().size();
} }
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ this.i18n.get("message.software.assignment", new Object[] { count })); + i18n.get("message.software.assignment", new Object[] { count }));
this.manageDistUIState.getAssignedList().clear(); manageDistUIState.getAssignedList().clear();
this.manageDistUIState.getConsolidatedDistSoftwarewList().clear(); manageDistUIState.getConsolidatedDistSoftwarewList().clear();
removeCurrentTab(tab); removeCurrentTab(tab);
this.eventBus.publish(this, SaveActionWindowEvent.SAVED_ASSIGNMENTS); eventBus.publish(this, SaveActionWindowEvent.SAVED_ASSIGNMENTS);
} }
private void discardAllSWAssignments(final ConfirmationTab tab) { private void discardAllSWAssignments(final ConfirmationTab tab) {
removeCurrentTab(tab); removeCurrentTab(tab);
this.manageDistUIState.getAssignedList().clear(); manageDistUIState.getAssignedList().clear();
this.manageDistUIState.getConsolidatedDistSoftwarewList().clear(); manageDistUIState.getConsolidatedDistSoftwarewList().clear();
setActionMessage(this.i18n.get("message.assign.discard.success")); setActionMessage(i18n.get("message.assign.discard.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS);
} }
private void discardSWAssignment(final String discardSW, final Object itemId, final ConfirmationTab tab) { 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 final SoftwareModuleIdName discardSoftIdName = (SoftwareModuleIdName) rowitem
.getItemProperty(SOFTWARE_MODULE_ID_NAME).getValue(); .getItemProperty(SOFTWARE_MODULE_ID_NAME).getValue();
final Set<SoftwareModuleIdName> softIdNameSet = this.manageDistUIState.getAssignedList().get(discardDistIdName); final Set<SoftwareModuleIdName> softIdNameSet = manageDistUIState.getAssignedList().get(discardDistIdName);
this.manageDistUIState.getAssignedList().get(discardDistIdName).remove(discardSoftIdName); manageDistUIState.getAssignedList().get(discardDistIdName).remove(discardSoftIdName);
softIdNameSet.remove(discardSoftIdName); softIdNameSet.remove(discardSoftIdName);
tab.getTable().getContainerDataSource().removeItem(itemId); tab.getTable().getContainerDataSource().removeItem(itemId);
if (softIdNameSet.isEmpty()) { 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); .get(discardDistIdName);
map.keySet().forEach(typeId -> map.get(typeId).remove(discardSoftIdName)); map.keySet().forEach(typeId -> map.get(typeId).remove(discardSoftIdName));
final int assigCount = tab.getTable().getContainerDataSource().size(); final int assigCount = tab.getTable().getContainerDataSource().size();
if (0 == assigCount) { if (0 == assigCount) {
removeCurrentTab(tab); removeCurrentTab(tab);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS);
} else { } 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 * @return the manageDistFilters
*/ */
public ManageDistFilters getManageDistFilters() { public ManageDistFilters getManageDistFilters() {
return this.manageDistFilters; return manageDistFilters;
} }
/** /**
* @return the deletedDistributionList * @return the deletedDistributionList
*/ */
public Set<DistributionSetIdName> getDeletedDistributionList() { public Set<DistributionSetIdName> getDeletedDistributionList() {
return this.deletedDistributionList; return deletedDistributionList;
} }
/** /**
@@ -94,21 +94,21 @@ public class ManageDistUIState implements Serializable {
* @return the assignedList * @return the assignedList
*/ */
public Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> getAssignedList() { public Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> getAssignedList() {
return this.assignedList; return assignedList;
} }
/** /**
* @return the slectedDistributions * @return the slectedDistributions
*/ */
public Optional<Set<DistributionSetIdName>> getSelectedDistributions() { 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 * @return the lastSelectedDistribution
*/ */
public Optional<DistributionSetIdName> getLastSelectedDistribution() { 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) { public void setSelectedDistributions(final Set<DistributionSetIdName> slectedDistributions) {
this.selectedDistributions = slectedDistributions; selectedDistributions = slectedDistributions;
} }
/** /**
* @return the softwareModuleFilters * @return the softwareModuleFilters
*/ */
public ManageSoftwareModuleFilters getSoftwareModuleFilters() { public ManageSoftwareModuleFilters getSoftwareModuleFilters() {
return this.softwareModuleFilters; return softwareModuleFilters;
} }
/** /**
* @return the selectedSoftwareModules * @return the selectedSoftwareModules
*/ */
public Set<Long> getSelectedSoftwareModules() { public Set<Long> getSelectedSoftwareModules() {
return this.selectedSoftwareModules; return selectedSoftwareModules;
} }
/** /**
* @return the selectedBaseSwModuleId * @return the selectedBaseSwModuleId
*/ */
public Optional<Long> getSelectedBaseSwModuleId() { 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 * @return the distTypeFilterClosed
*/ */
public boolean isDistTypeFilterClosed() { public boolean isDistTypeFilterClosed() {
return this.distTypeFilterClosed; return distTypeFilterClosed;
} }
/** /**
@@ -179,7 +179,7 @@ public class ManageDistUIState implements Serializable {
* @return the swTypeFilterClosed * @return the swTypeFilterClosed
*/ */
public boolean isSwTypeFilterClosed() { public boolean isSwTypeFilterClosed() {
return this.swTypeFilterClosed; return swTypeFilterClosed;
} }
/** /**
@@ -194,11 +194,11 @@ public class ManageDistUIState implements Serializable {
* @return the deleteSofwareModulesList * @return the deleteSofwareModulesList
*/ */
public Map<Long, String> getDeleteSofwareModulesList() { public Map<Long, String> getDeleteSofwareModulesList() {
return this.deleteSofwareModulesList; return deleteSofwareModulesList;
} }
public Set<String> getSelectedDeleteDistSetTypes() { public Set<String> getSelectedDeleteDistSetTypes() {
return this.selectedDeleteDistSetTypes; return selectedDeleteDistSetTypes;
} }
public void setSelectedDeleteDistSetTypes(final Set<String> selectedDeleteDistSetTypes) { public void setSelectedDeleteDistSetTypes(final Set<String> selectedDeleteDistSetTypes) {
@@ -206,7 +206,7 @@ public class ManageDistUIState implements Serializable {
} }
public Set<String> getSelectedDeleteSWModuleTypes() { public Set<String> getSelectedDeleteSWModuleTypes() {
return this.selectedDeleteSWModuleTypes; return selectedDeleteSWModuleTypes;
} }
public void setSelectedDeleteSWModuleTypes(final Set<String> selectedDeleteSWModuleTypes) { public void setSelectedDeleteSWModuleTypes(final Set<String> selectedDeleteSWModuleTypes) {
@@ -219,7 +219,7 @@ public class ManageDistUIState implements Serializable {
* @return boolean * @return boolean
*/ */
public boolean isDsTableMaximized() { public boolean isDsTableMaximized() {
return this.isDsTableMaximized; return isDsTableMaximized;
} }
/*** /***
@@ -228,18 +228,18 @@ public class ManageDistUIState implements Serializable {
* @param isDsModuleTableMaximized * @param isDsModuleTableMaximized
*/ */
public void setDsTableMaximized(final boolean isDsModuleTableMaximized) { public void setDsTableMaximized(final boolean isDsModuleTableMaximized) {
this.isDsTableMaximized = isDsModuleTableMaximized; isDsTableMaximized = isDsModuleTableMaximized;
} }
public Map<String, SoftwareModuleIdName> getAssignedSoftwareModuleDetails() { public Map<String, SoftwareModuleIdName> getAssignedSoftwareModuleDetails() {
return this.assignedSoftwareModuleDetails; return assignedSoftwareModuleDetails;
} }
/** /**
* @return the isSwModuleTableMaximized * @return the isSwModuleTableMaximized
*/ */
public boolean isSwModuleTableMaximized() { public boolean isSwModuleTableMaximized() {
return this.isSwModuleTableMaximized; return isSwModuleTableMaximized;
} }
/** /**
@@ -254,7 +254,7 @@ public class ManageDistUIState implements Serializable {
* @return the noDataAvilableSwModule * @return the noDataAvilableSwModule
*/ */
public boolean isNoDataAvilableSwModule() { public boolean isNoDataAvilableSwModule() {
return this.noDataAvilableSwModule; return noDataAvilableSwModule;
} }
/** /**
@@ -269,7 +269,7 @@ public class ManageDistUIState implements Serializable {
* @return the noDataAvailableDist * @return the noDataAvailableDist
*/ */
public boolean isNoDataAvailableDist() { public boolean isNoDataAvailableDist() {
return this.noDataAvailableDist; return noDataAvailableDist;
} }
/** /**
@@ -286,7 +286,7 @@ public class ManageDistUIState implements Serializable {
* @return map * @return map
*/ */
public Map<DistributionSetIdName, HashMap<Long, HashSet<SoftwareModuleIdName>>> getConsolidatedDistSoftwarewList() { 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 @Override
protected void init(final VaadinRequest request) { protected void init(final VaadinRequest request) {
SpringContextHelper.setContext(this.context); SpringContextHelper.setContext(context);
final VerticalLayout rootLayout = new VerticalLayout(); final VerticalLayout rootLayout = new VerticalLayout();
final Component header = buildHeader(); final Component header = buildHeader();
@@ -69,7 +69,7 @@ public class HawkbitLoginUI extends DefaultHawkbitUI {
rootLayout.setExpandRatio(header, 1.0F); rootLayout.setExpandRatio(header, 1.0F);
rootLayout.setExpandRatio(content, 2.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"); .getResource("classpath:/VAADIN/themes/" + UI.getCurrent().getTheme() + "/layouts/footer.html");
try { try {
final CustomLayout customLayout = new CustomLayout(resource.getInputStream()); final CustomLayout customLayout = new CustomLayout(resource.getInputStream());
@@ -81,7 +81,7 @@ public class HawkbitLoginUI extends DefaultHawkbitUI {
setContent(rootLayout); setContent(rootLayout);
final Navigator navigator = new Navigator(this, content); final Navigator navigator = new Navigator(this, content);
navigator.addProvider(this.viewProvider); navigator.addProvider(viewProvider);
setNavigator(navigator); setNavigator(navigator);
} }

View File

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

View File

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

View File

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

View File

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

View File

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