From 1bb29338ac44175324037f2c844001c2d3f9457e Mon Sep 17 00:00:00 2001 From: SirWayne Date: Tue, 9 Feb 2016 10:16:07 +0100 Subject: [PATCH] Clean Code Refactoring Signed-off-by: SirWayne --- .../hawkbit/simulator/DDISimulatedDevice.java | 46 +-- .../simulator/DeviceSimulatorUpdater.java | 35 +- .../simulator/NextPollTimeController.java | 21 +- .../report/model/DataReportSeries.java | 13 +- .../report/model/DataReportSeriesItem.java | 9 +- .../model/InnerOuterDataReportSeries.java | 8 +- .../repository/DistributionSetManagement.java | 180 ++++----- .../hawkbit/repository/ReportManagement.java | 86 ++-- .../repository/SoftwareManagement.java | 192 ++++----- .../hawkbit/repository/model/Rollout.java | 38 +- .../repository/model/RolloutTargetGroup.java | 11 +- .../model/TotalTargetCountStatus.java | 40 +- .../RolloutGroupConditionEvaluator.java | 14 +- .../ThresholdRolloutGroupErrorCondition.java | 25 +- ...ThresholdRolloutGroupSuccessCondition.java | 42 +- .../org/eclipse/hawkbit/ui/HawkbitUI.java | 91 +++-- .../UploadViewConfirmationWindowLayout.java | 115 +++--- .../artifacts/state/ArtifactUploadState.java | 26 +- .../ui/artifacts/state/CustomFile.java | 65 +-- .../AbstractFilterSingleButtonClick.java | 36 +- .../common/tagdetails/AbstractTagToken.java | 90 +++-- .../dstable/DistributionSetDetails.java | 166 ++++---- .../dstable/DistributionSetTable.java | 195 +++++---- .../footer/DSDeleteActionsLayout.java | 151 ++++--- ...DistributionsConfirmationWindowLayout.java | 343 ++++++++-------- .../state/ManageDistUIState.java | 62 +-- .../hawkbit/ui/login/HawkbitLoginUI.java | 8 +- .../actionhistory/ActionHistoryTable.java | 281 ++++++------- .../DistributionAddUpdateWindowLayout.java | 261 ++++++------ .../footer/DeleteActionsLayoutHelper.java | 15 +- .../management/state/ManagementUIState.java | 60 +-- .../management/tag/CreateUpdateTagLayout.java | 378 +++++++++--------- .../CustomTargetTagFilterButtonClick.java | 29 +- .../TenantConfigurationItem.java | 11 +- .../hawkbit/ui/utils/HawkbitCommonUtil.java | 140 +++---- 35 files changed, 1614 insertions(+), 1669 deletions(-) diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DDISimulatedDevice.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DDISimulatedDevice.java index 1417c3153..bf6d669c4 100644 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DDISimulatedDevice.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DDISimulatedDevice.java @@ -10,7 +10,6 @@ package org.eclipse.hawkbit.simulator; import java.util.concurrent.ScheduledExecutorService; -import org.eclipse.hawkbit.simulator.DeviceSimulatorUpdater.UpdaterCallback; import org.eclipse.hawkbit.simulator.http.ControllerResource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,48 +61,47 @@ public class DDISimulatedDevice extends AbstractSimulatedDevice { @Override public void clean() { super.clean(); - removed = true; + this.removed = true; } public int getPollDelaySec() { - return pollDelaySec; + return this.pollDelaySec; } /** * Polls the base URL for the DDI API interface. */ public void poll() { - if (!removed) { - final String basePollJson = controllerResource.get(getTenant(), getId()); + if (!this.removed) { + final String basePollJson = this.controllerResource.get(getTenant(), getId()); try { final String href = JsonPath.parse(basePollJson).read("_links.deploymentBase.href"); final long actionId = Long.parseLong(href.substring(href.lastIndexOf("/") + 1, href.indexOf("?"))); - if (currentActionId == null) { - final String deploymentJson = controllerResource.getDeployment(getTenant(), getId(), actionId); + if (this.currentActionId == null) { + final String deploymentJson = this.controllerResource.getDeployment(getTenant(), getId(), actionId); final String swVersion = JsonPath.parse(deploymentJson).read("deployment.chunks[0].version"); - currentActionId = actionId; - deviceUpdater.startUpdate(getTenant(), getId(), actionId, swVersion, new UpdaterCallback() { - @Override - public void updateFinished(final AbstractSimulatedDevice device, final Long actionId) { - switch (device.getResponseStatus()) { - case SUCCESSFUL: - controllerResource.postSuccessFeedback(getTenant(), getId(), actionId); - break; - case ERROR: - controllerResource.postErrorFeedback(getTenant(), getId(), actionId); - break; - default: - throw new IllegalStateException("simulated device has an unknown response status + " - + device.getResponseStatus()); - } - currentActionId = null; + this.currentActionId = actionId; + this.deviceUpdater.startUpdate(getTenant(), getId(), actionId, swVersion, (device, actionId1) -> { + switch (device.getResponseStatus()) { + case SUCCESSFUL: + DDISimulatedDevice.this.controllerResource.postSuccessFeedback(getTenant(), getId(), + actionId1); + break; + case ERROR: + DDISimulatedDevice.this.controllerResource.postErrorFeedback(getTenant(), getId(), + actionId1); + break; + default: + throw new IllegalStateException( + "simulated device has an unknown response status + " + device.getResponseStatus()); } + DDISimulatedDevice.this.currentActionId = null; }); } } catch (final PathNotFoundException e) { // href might not be in the json response, so ignore // exception here. - LOGGER.trace("Response does not contain a deploymentbase href link, ignoring."); + LOGGER.trace("Response does not contain a deploymentbase href link, ignoring.", e); } } diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java index 6e93b7d04..048268897 100644 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java @@ -8,6 +8,7 @@ */ package org.eclipse.hawkbit.simulator; +import java.security.SecureRandom; import java.util.Random; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -41,7 +42,7 @@ public class DeviceSimulatorUpdater { /** * Starting an simulated update process of an simulated device. - * + * * @param tenant * the tenant of the device * @param id @@ -57,16 +58,17 @@ public class DeviceSimulatorUpdater { */ public void startUpdate(final String tenant, final String id, final long actionId, final String swVersion, final UpdaterCallback callback) { - final AbstractSimulatedDevice device = repository.get(tenant, id); + final AbstractSimulatedDevice device = this.repository.get(tenant, id); device.setProgress(0.0); device.setSwversion(swVersion); - eventbus.post(new InitUpdate(device)); - threadPool.schedule(new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus, callback), - 2000, TimeUnit.MILLISECONDS); + this.eventbus.post(new InitUpdate(device)); + threadPool.schedule( + new DeviceSimulatorUpdateThread(device, this.spSenderService, actionId, this.eventbus, callback), 2000, + TimeUnit.MILLISECONDS); } private static final class DeviceSimulatorUpdateThread implements Runnable { - private static final Random rndSleep = new Random(); + private static final Random rndSleep = new SecureRandom(); private final AbstractSimulatedDevice device; private final SpSenderService spSenderService; @@ -74,9 +76,8 @@ public class DeviceSimulatorUpdater { private final EventBus eventbus; private final UpdaterCallback callback; - private DeviceSimulatorUpdateThread(final AbstractSimulatedDevice device, - final SpSenderService spSenderService, final long actionId, final EventBus eventbus, - final UpdaterCallback callback) { + private DeviceSimulatorUpdateThread(final AbstractSimulatedDevice device, final SpSenderService spSenderService, + final long actionId, final EventBus eventbus, final UpdaterCallback callback) { this.device = device; this.spSenderService = spSenderService; this.actionId = actionId; @@ -86,15 +87,15 @@ public class DeviceSimulatorUpdater { @Override public void run() { - final double newProgress = device.getProgress() + 0.2; - device.setProgress(newProgress); + final double newProgress = this.device.getProgress() + 0.2; + this.device.setProgress(newProgress); if (newProgress < 1.0) { - threadPool.schedule(new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus, - callback), rndSleep.nextInt(3000), TimeUnit.MILLISECONDS); + threadPool.schedule(new DeviceSimulatorUpdateThread(this.device, this.spSenderService, this.actionId, + this.eventbus, this.callback), rndSleep.nextInt(3000), TimeUnit.MILLISECONDS); } else { - callback.updateFinished(device, actionId); + this.callback.updateFinished(this.device, this.actionId); } - eventbus.post(new ProgressUpdate(device)); + this.eventbus.post(new ProgressUpdate(this.device)); } } @@ -102,7 +103,7 @@ public class DeviceSimulatorUpdater { * Callback interface which is called when the simulated update process has * been finished and the caller of starting the simulated update process can * send the result to the hawkbit update server back. - * + * * @author Michael Hirsch * */ @@ -111,7 +112,7 @@ public class DeviceSimulatorUpdater { /** * Callback method to indicate that the simulated update process has * been finished. - * + * * @param device * the device which has been updated * @param actionId diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/NextPollTimeController.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/NextPollTimeController.java index 81acf897e..acb1ab731 100644 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/NextPollTimeController.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/NextPollTimeController.java @@ -16,6 +16,8 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import org.eclipse.hawkbit.simulator.event.NextPollCounterUpdate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -24,13 +26,15 @@ import com.google.common.eventbus.EventBus; /** * Poll time trigger which executes the {@link DDISimulatedDevice#poll()} every * second. - * + * * @author Michael Hirsch * */ @Component public class NextPollTimeController { + private static final Logger LOGGER = LoggerFactory.getLogger(NextPollTimeController.class); + private static final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1); private static final ExecutorService pollService = Executors.newFixedThreadPool(1); @@ -50,7 +54,7 @@ public class NextPollTimeController { private class NextPollUpdaterRunnable implements Runnable { @Override public void run() { - final List devices = repository.getAll().stream() + final List devices = NextPollTimeController.this.repository.getAll().stream() .filter(device -> device instanceof DDISimulatedDevice).collect(Collectors.toList()); devices.forEach(device -> { @@ -58,21 +62,16 @@ public class NextPollTimeController { if (nextCounter < 0) { if (device instanceof DDISimulatedDevice) { try { - pollService.submit(new Runnable() { - @Override - public void run() { - ((DDISimulatedDevice) device).poll(); - } - }); - } catch (final Exception e) { - + pollService.submit(() -> ((DDISimulatedDevice) device).poll()); + } catch (final IllegalStateException e) { + LOGGER.trace("Device could not be polled", e); } nextCounter = ((DDISimulatedDevice) device).getPollDelaySec(); } } device.setNextPollCounterSec(nextCounter); }); - eventBus.post(new NextPollCounterUpdate(devices)); + NextPollTimeController.this.eventBus.post(new NextPollCounterUpdate(devices)); } } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/DataReportSeries.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/DataReportSeries.java index 97623d9d0..409294cce 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/DataReportSeries.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/DataReportSeries.java @@ -8,19 +8,22 @@ */ package org.eclipse.hawkbit.report.model; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; /** * A data report series which contains a list of {@link DataReportSeriesItem}. - * + * * * * @param * the type of the report series item */ -public class DataReportSeries extends AbstractReportSeries { +public class DataReportSeries extends AbstractReportSeries { + + private static final long serialVersionUID = 1L; private final List> data = new ArrayList<>(); @@ -47,7 +50,7 @@ public class DataReportSeries extends AbstractReportSeries { private void setData(final List> values) { this.data.clear(); - data.addAll(values); + this.data.addAll(values); } /** @@ -55,10 +58,10 @@ public class DataReportSeries extends AbstractReportSeries { */ @SuppressWarnings("unchecked") public DataReportSeriesItem[] getData() { - return data.toArray(new DataReportSeriesItem[data.size()]); + return this.data.toArray(new DataReportSeriesItem[this.data.size()]); } public Stream> getDataStream() { - return data.stream(); + return this.data.stream(); } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/DataReportSeriesItem.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/DataReportSeriesItem.java index 3369ef1c0..c1a39817e 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/DataReportSeriesItem.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/DataReportSeriesItem.java @@ -8,6 +8,8 @@ */ package org.eclipse.hawkbit.report.model; +import java.io.Serializable; + /** * An data report series item which contains a type and a value. * @@ -16,8 +18,9 @@ package org.eclipse.hawkbit.report.model; * @param * the type of the report series item */ -public class DataReportSeriesItem { +public class DataReportSeriesItem implements Serializable { + private static final long serialVersionUID = 1L; private final T type; private final Number data; @@ -36,13 +39,13 @@ public class DataReportSeriesItem { * @return the type of the data report item */ public T getType() { - return type; + return this.type; } /** * @return the data of the data report item */ public Number getData() { - return data; + return this.data; } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/InnerOuterDataReportSeries.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/InnerOuterDataReportSeries.java index 1568847de..acc3699ac 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/InnerOuterDataReportSeries.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/InnerOuterDataReportSeries.java @@ -8,6 +8,8 @@ */ package org.eclipse.hawkbit.report.model; +import java.io.Serializable; + /** * A double data series which contains an inner and an outer series ideal for * showing donut charts. @@ -17,7 +19,7 @@ package org.eclipse.hawkbit.report.model; * @param * The type parameter for the report series data */ -public class InnerOuterDataReportSeries { +public class InnerOuterDataReportSeries { private final DataReportSeries innerSeries; private final DataReportSeries outerSeries; @@ -37,13 +39,13 @@ public class InnerOuterDataReportSeries { * @return the innerSeries */ public DataReportSeries getInnerSeries() { - return innerSeries; + return this.innerSeries; } /** * @return the outerSeries */ public DataReportSeries getOuterSeries() { - return outerSeries; + return this.outerSeries; } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java index 53f47dae7..952acf04c 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java @@ -22,10 +22,6 @@ import java.util.stream.Collectors; import javax.persistence.Entity; import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.eventbus.event.DistributionSetTagAssigmentResultEvent; @@ -53,13 +49,13 @@ import org.eclipse.hawkbit.repository.model.Tag; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.specifications.DistributionSetSpecification; import org.eclipse.hawkbit.repository.specifications.DistributionSetTypeSpecification; +import org.eclipse.hawkbit.repository.specifications.SpecificationsBuilder; import org.hibernate.validator.constraints.NotEmpty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; -import org.springframework.data.jpa.domain.Specifications; import org.springframework.data.jpa.repository.Modifying; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; @@ -121,7 +117,7 @@ public class DistributionSetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public DistributionSet findDistributionSetByIdWithDetails(@NotNull final Long distid) { - return distributionSetRepository.findOne(DistributionSetSpecification.byId(distid)); + return this.distributionSetRepository.findOne(DistributionSetSpecification.byId(distid)); } /** @@ -134,7 +130,7 @@ public class DistributionSetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public DistributionSet findDistributionSetById(@NotNull final Long distid) { - return distributionSetRepository.findOne(distid); + return this.distributionSetRepository.findOne(distid); } /** @@ -178,7 +174,7 @@ public class DistributionSetManagement { @NotNull final String tagName) { final Iterable sets = findDistributionSetListWithDetails(dsIds); - final DistributionSetTag myTag = tagManagement.findDistributionSetTag(tagName); + final DistributionSetTag myTag = this.tagManagement.findDistributionSetTag(tagName); DistributionSetTagAssigmentResult result = null; final List allDSs = new ArrayList<>(); @@ -196,17 +192,18 @@ public class DistributionSetManagement { } } result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), 0, allDSs.size(), - Collections.emptyList(), distributionSetRepository.save(allDSs), myTag); + Collections.emptyList(), this.distributionSetRepository.save(allDSs), myTag); } else { result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), allDSs.size(), 0, - distributionSetRepository.save(allDSs), Collections.emptyList(), myTag); + this.distributionSetRepository.save(allDSs), Collections.emptyList(), myTag); } final DistributionSetTagAssigmentResult resultAssignment = result; - afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment))); + this.afterCommit + .afterCommit(() -> this.eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment))); // no reason to persist the tag - entityManager.detach(myTag); + this.entityManager.detach(myTag); return result; } @@ -221,7 +218,7 @@ public class DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public List findDistributionSetListWithDetails( @NotEmpty final Collection distributionIdSet) { - return distributionSetRepository.findAll(DistributionSetSpecification.byIds(distributionIdSet)); + return this.distributionSetRepository.findAll(DistributionSetSpecification.byIds(distributionIdSet)); } /** @@ -241,7 +238,7 @@ public class DistributionSetManagement { checkNotNull(ds.getId()); final DistributionSet persisted = findDistributionSetByIdWithDetails(ds.getId()); checkDistributionSetSoftwareModulesIsAllowedToModify(ds, persisted.getModules()); - return distributionSetRepository.save(ds); + return this.distributionSetRepository.save(ds); } /** @@ -280,11 +277,11 @@ public class DistributionSetManagement { public void deleteDistributionSet(@NotEmpty final Long... distributionSetIDs) { final List toHardDelete = new ArrayList<>(); - final List assigned = distributionSetRepository.findAssignedDistributionSetsById(distributionSetIDs); + final List assigned = this.distributionSetRepository.findAssignedDistributionSetsById(distributionSetIDs); // soft delete assigned if (!assigned.isEmpty()) { - distributionSetRepository.deleteDistributionSet(assigned.toArray(new Long[assigned.size()])); + this.distributionSetRepository.deleteDistributionSet(assigned.toArray(new Long[assigned.size()])); } // mark the rest as hard delete @@ -299,7 +296,7 @@ public class DistributionSetManagement { // don't give the delete statement an empty list, JPA/Oracle cannot // handle the empty list, // see MECS-403 - distributionSetRepository.deleteByIdIn(toHardDelete); + this.distributionSetRepository.deleteByIdIn(toHardDelete); } } @@ -322,9 +319,9 @@ public class DistributionSetManagement { public DistributionSet createDistributionSet(@NotNull final DistributionSet dSet) { prepareDsSave(dSet); if (dSet.getType() == null) { - dSet.setType(systemManagement.getTenantMetadata().getDefaultDsType()); + dSet.setType(this.systemManagement.getTenantMetadata().getDefaultDsType()); } - return distributionSetRepository.save(dSet); + return this.distributionSetRepository.save(dSet); } private void prepareDsSave(final DistributionSet dSet) { @@ -332,7 +329,7 @@ public class DistributionSetManagement { throw new EntityAlreadyExistsException("Parameter seems to be an existing, already persisted entity"); } - if (distributionSetRepository.countByNameAndVersion(dSet.getName(), dSet.getVersion()) > 0) { + if (this.distributionSetRepository.countByNameAndVersion(dSet.getName(), dSet.getVersion()) > 0) { throw new EntityAlreadyExistsException("DistributionSet with that name and version already exists."); } @@ -357,7 +354,7 @@ public class DistributionSetManagement { for (final DistributionSet ds : distributionSets) { prepareDsSave(ds); } - return distributionSetRepository.save(distributionSets); + return this.distributionSetRepository.save(distributionSets); } /** @@ -378,7 +375,7 @@ public class DistributionSetManagement { for (final SoftwareModule softwareModule : softwareModules) { ds.addModule(softwareModule); } - return distributionSetRepository.save(ds); + return this.distributionSetRepository.save(ds); } /** @@ -400,7 +397,7 @@ public class DistributionSetManagement { softwareModules.add(softwareModule); ds.removeModule(softwareModule); checkDistributionSetSoftwareModulesIsAllowedToModify(ds, softwareModules); - return distributionSetRepository.save(ds); + return this.distributionSetRepository.save(ds); } /** @@ -422,17 +419,17 @@ public class DistributionSetManagement { public DistributionSetType updateDistributionSetType(@NotNull final DistributionSetType dsType) { checkNotNull(dsType.getId()); - final DistributionSetType persisted = distributionSetTypeRepository.findOne(dsType.getId()); + final DistributionSetType persisted = this.distributionSetTypeRepository.findOne(dsType.getId()); // throw exception if user tries to update a DS type that is already in // use - if (!persisted.areModuleEntriesIdentical(dsType) && distributionSetRepository.countByType(persisted) > 0) { + if (!persisted.areModuleEntriesIdentical(dsType) && this.distributionSetRepository.countByType(persisted) > 0) { throw new EntityReadOnlyException( String.format("distribution set type %s set is already assigned to targets and cannot be changed", dsType.getName())); } - return distributionSetTypeRepository.save(dsType); + return this.distributionSetTypeRepository.save(dsType); } /** @@ -448,7 +445,7 @@ public class DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Page findDistributionSetTypesByPredicate( @NotNull final Specification spec, @NotNull final Pageable pageable) { - return distributionSetTypeRepository.findAll(spec, pageable); + return this.distributionSetTypeRepository.findAll(spec, pageable); } /** @@ -458,7 +455,7 @@ public class DistributionSetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Page findDistributionSetTypesAll(@NotNull final Pageable pageable) { - return distributionSetTypeRepository.findByDeleted(pageable, false); + return this.distributionSetTypeRepository.findByDeleted(pageable, false); } /** @@ -488,15 +485,10 @@ public class DistributionSetManagement { private DistributionSet findDistributionSetsByFiltersAndInstalledOrAssignedTarget( final DistributionSetFilter distributionSetFilter) { final List> specList = buildDistributionSetSpecifications(distributionSetFilter); - if (!specList.isEmpty()) { - Specifications specs = Specifications.where(specList.get(0)); - specList.remove(0); - for (final Specification s : specList) { - specs = specs.and(s); - } - return distributionSetRepository.findOne(specs); + if (specList == null || specList.isEmpty()) { + return null; } - return null; + return this.distributionSetRepository.findOne(SpecificationsBuilder.combineWithAnd(specList)); } /** @@ -627,17 +619,6 @@ public class DistributionSetManagement { return new PageImpl<>(resultSet, pageable, findDistributionSetsByFilters.getTotalElements()); } - private Long countDistributionSetByCriteriaAPI(@NotEmpty final List> specList) { - Specifications specs = Specifications.where(specList.get(0)); - if (specList.size() > 1) { - for (final Specification s : specList.subList(1, specList.size())) { - specs = specs.and(s); - } - } - - return distributionSetRepository.count(specs); - } - /** * Find distribution set by name and version. * @@ -652,7 +633,7 @@ public class DistributionSetManagement { @NotEmpty final String version) { final Specification spec = DistributionSetSpecification .equalsNameAndVersionIgnoreCase(distributionName, version); - return distributionSetRepository.findOne(spec); + return this.distributionSetRepository.findOne(spec); } @@ -669,7 +650,7 @@ public class DistributionSetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Iterable findDistributionSetList(@NotEmpty final Collection dist) { - return distributionSetRepository.findAll(dist); + return this.distributionSetRepository.findAll(dist); } /** @@ -686,7 +667,7 @@ public class DistributionSetManagement { final Specification spec = DistributionSetSpecification.isDeleted(Boolean.FALSE); specList.add(spec); - return countDistributionSetByCriteriaAPI(specList); + return this.distributionSetRepository.count(SpecificationsBuilder.combineWithAnd(specList)); } /** @@ -694,7 +675,7 @@ public class DistributionSetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Long countDistributionSetTypesAll() { - return distributionSetTypeRepository.countByDeleted(false); + return this.distributionSetTypeRepository.countByDeleted(false); } /** @@ -704,7 +685,7 @@ public class DistributionSetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public DistributionSetType findDistributionSetTypeByName(@NotNull final String name) { - return distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byName(name)); + return this.distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byName(name)); } /** @@ -714,7 +695,7 @@ public class DistributionSetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public DistributionSetType findDistributionSetTypeById(@NotNull final Long id) { - return distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byId(id)); + return this.distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byId(id)); } /** @@ -724,7 +705,7 @@ public class DistributionSetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public DistributionSetType findDistributionSetTypeByKey(@NotNull final String key) { - return distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byKey(key)); + return this.distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byKey(key)); } /** @@ -742,7 +723,7 @@ public class DistributionSetManagement { throw new EntityAlreadyExistsException("Given type contains an Id!"); } - return distributionSetTypeRepository.save(type); + return this.distributionSetTypeRepository.save(type); } /** @@ -756,12 +737,12 @@ public class DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) public void deleteDistributionSetType(@NotNull final DistributionSetType type) { - if (distributionSetRepository.countByType(type) > 0) { - final DistributionSetType toDelete = entityManager.merge(type); + if (this.distributionSetRepository.countByType(type) > 0) { + final DistributionSetType toDelete = this.entityManager.merge(type); toDelete.setDeleted(true); - distributionSetTypeRepository.save(toDelete); + this.distributionSetTypeRepository.save(toDelete); } else { - distributionSetTypeRepository.delete(type.getId()); + this.distributionSetTypeRepository.delete(type.getId()); } } @@ -779,15 +760,15 @@ public class DistributionSetManagement { @Modifying @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) public DistributionSetMetadata createDistributionSetMetadata(@NotNull final DistributionSetMetadata metadata) { - if (distributionSetMetadataRepository.exists(metadata.getId())) { + if (this.distributionSetMetadataRepository.exists(metadata.getId())) { throwMetadataKeyAlreadyExists(metadata.getId().getKey()); } // merge base software module so optLockRevision gets updated and audit // log written because // modifying metadata is modifying the base distribution set itself for // auditing purposes. - entityManager.merge(metadata.getDistributionSet()).setLastModifiedAt(0L); - return distributionSetMetadataRepository.save(metadata); + this.entityManager.merge(metadata.getDistributionSet()).setLastModifiedAt(0L); + return this.distributionSetMetadataRepository.save(metadata); } /** @@ -808,8 +789,8 @@ public class DistributionSetManagement { for (final DistributionSetMetadata distributionSetMetadata : metadata) { checkAndThrowAlreadyIfDistributionSetMetadataExists(distributionSetMetadata.getId()); } - metadata.forEach(m -> entityManager.merge(m.getDistributionSet()).setLastModifiedAt(-1L)); - return (List) distributionSetMetadataRepository.save(metadata); + metadata.forEach(m -> this.entityManager.merge(m.getDistributionSet()).setLastModifiedAt(-1L)); + return (List) this.distributionSetMetadataRepository.save(metadata); } /** @@ -830,8 +811,8 @@ public class DistributionSetManagement { findOne(metadata.getId()); // touch it to update the lock revision because we are modifying the // DS indirectly - entityManager.merge(metadata.getDistributionSet()).setLastModifiedAt(0L); - return distributionSetMetadataRepository.save(metadata); + this.entityManager.merge(metadata.getDistributionSet()).setLastModifiedAt(0L); + return this.distributionSetMetadataRepository.save(metadata); } /** @@ -844,7 +825,7 @@ public class DistributionSetManagement { @Modifying @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) public void deleteDistributionSetMetadata(@NotNull final DsMetadataCompositeKey id) { - distributionSetMetadataRepository.delete(id); + this.distributionSetMetadataRepository.delete(id); } /** @@ -861,14 +842,10 @@ public class DistributionSetManagement { public Page findDistributionSetMetadataByDistributionSetId( @NotNull final Long distributionSetId, @NotNull final Pageable pageable) { - return distributionSetMetadataRepository.findAll(new Specification() { - @Override - public Predicate toPredicate(final Root root, final CriteriaQuery query, - final CriteriaBuilder cb) { - return cb.equal(root.get(DistributionSetMetadata_.distributionSet).get(DistributionSet_.id), - distributionSetId); - } - }, pageable); + return this.distributionSetMetadataRepository.findAll( + (Specification) (root, query, cb) -> cb.equal( + root.get(DistributionSetMetadata_.distributionSet).get(DistributionSet_.id), distributionSetId), + pageable); } @@ -888,14 +865,14 @@ public class DistributionSetManagement { public Page findDistributionSetMetadataByDistributionSetId( @NotNull final Long distributionSetId, @NotNull final Specification spec, @NotNull final Pageable pageable) { - return distributionSetMetadataRepository.findAll(new Specification() { - @Override - public Predicate toPredicate(final Root root, final CriteriaQuery query, - final CriteriaBuilder cb) { - return cb.and(cb.equal(root.get(DistributionSetMetadata_.distributionSet).get(DistributionSet_.id), - distributionSetId), spec.toPredicate(root, query, cb)); - } - }, pageable); + return this.distributionSetMetadataRepository + .findAll( + (Specification) (root, query, + cb) -> cb.and( + cb.equal(root.get(DistributionSetMetadata_.distributionSet) + .get(DistributionSet_.id), distributionSetId), + spec.toPredicate(root, query, cb)), + pageable); } /** @@ -910,7 +887,7 @@ public class DistributionSetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public DistributionSetMetadata findOne(@NotNull final DsMetadataCompositeKey id) { - final DistributionSetMetadata findOne = distributionSetMetadataRepository.findOne(id); + final DistributionSetMetadata findOne = this.distributionSetMetadataRepository.findOne(id); if (findOne == null) { throw new EntityNotFoundException("Metadata with key '" + id.getKey() + "' does not exist"); } @@ -926,7 +903,7 @@ public class DistributionSetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public DistributionSet findDistributionSetByAction(@NotNull final Action action) { - return distributionSetRepository.findByAction(action); + return this.distributionSetRepository.findByAction(action); } /** @@ -945,7 +922,7 @@ public class DistributionSetManagement { /** * Checking Distribution Set is already using while assign Software module. - * + * * @param distributionSet * @param softwareModules */ @@ -1001,7 +978,7 @@ public class DistributionSetManagement { private void checkDistributionSetSoftwareModulesIsAllowedToModify(final DistributionSet distributionSet, final Set softwareModules) { if (!new HashSet(distributionSet.getModules()).equals(softwareModules) - && actionRepository.countByDistributionSet(distributionSet) > 0) { + && this.actionRepository.countByDistributionSet(distributionSet) > 0) { throw new EntityLockedException( String.format("distribution set %s:%s is already assigned to targets and cannot be changed", distributionSet.getName(), distributionSet.getVersion())); @@ -1009,7 +986,7 @@ public class DistributionSetManagement { } private void checkDistributionSetSoftwareModulesIsAllowedToModify(final DistributionSet distributionSet) { - if (actionRepository.countByDistributionSet(distributionSet) > 0) { + if (this.actionRepository.countByDistributionSet(distributionSet) > 0) { throw new EntityLockedException( String.format("distribution set %s:%s is already assigned to targets and cannot be changed", distributionSet.getName(), distributionSet.getVersion())); @@ -1042,25 +1019,16 @@ public class DistributionSetManagement { */ private Page findByCriteriaAPI(@NotNull final Pageable pageable, final List> specList) { - Specifications specs = null; - if (!specList.isEmpty()) { - specs = Specifications.where(specList.get(0)); - } - if (specList.size() > 1) { - for (final Specification s : specList.subList(1, specList.size())) { - specs = specs.and(s); - } + + if (specList == null || specList.isEmpty()) { + return this.distributionSetRepository.findAll(pageable); } - if (specs == null) { - return distributionSetRepository.findAll(pageable); - } else { - return distributionSetRepository.findAll(specs, pageable); - } + return this.distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable); } private void checkAndThrowAlreadyIfDistributionSetMetadataExists(final DsMetadataCompositeKey metadataId) { - if (distributionSetMetadataRepository.exists(metadataId)) { + if (this.distributionSetMetadataRepository.exists(metadataId)) { throw new EntityAlreadyExistsException( "Metadata entry with key '" + metadataId.getKey() + "' already exists"); } @@ -1089,13 +1057,13 @@ public class DistributionSetManagement { final List allDs = findDistributionSetListWithDetails(dsIds); allDs.forEach(ds -> ds.getTags().add(tag)); - final List save = distributionSetRepository.save(allDs); + final List save = this.distributionSetRepository.save(allDs); - afterCommit.afterCommit(() -> { + this.afterCommit.afterCommit(() -> { final DistributionSetTagAssigmentResult result = new DistributionSetTagAssigmentResult(0, save.size(), 0, save, Collections.emptyList(), tag); - eventBus.post(new DistributionSetTagAssigmentResultEvent(result)); + this.eventBus.post(new DistributionSetTagAssigmentResultEvent(result)); }); return save; @@ -1139,6 +1107,6 @@ public class DistributionSetManagement { private List unAssignTag(final Collection distributionSets, final DistributionSetTag tag) { distributionSets.forEach(ds -> ds.getTags().remove(tag)); - return distributionSetRepository.save(distributionSets); + return this.distributionSetRepository.save(distributionSets); } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ReportManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ReportManagement.java index 801f6c80d..da739570b 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ReportManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ReportManagement.java @@ -99,7 +99,7 @@ public class ReportManagement { @Cacheable("targetStatus") public DataReportSeries targetStatus() { - final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + final CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); final CriteriaQuery query = cb.createQuery(Object[].class); final Root targetRoot = query.from(Target.class); final Join targetInfo = targetRoot.join(Target_.targetInfo); @@ -111,7 +111,7 @@ public class ReportManagement { // | col1 | col2 | // | U_STATUS | COUNT | - final List resultList = entityManager.createQuery(multiselect).getResultList(); + final List resultList = this.entityManager.createQuery(multiselect).getResultList(); final List> reportSeriesItems = resultList.stream() .map(r -> new DataReportSeriesItem((TargetUpdateStatus) r[0], (Long) r[1])) @@ -140,7 +140,7 @@ public class ReportManagement { public List> distributionUsageAssigned(final int topXEntries) { // top X entries distribution usage - final CriteriaBuilder cbTopX = entityManager.getCriteriaBuilder(); + final CriteriaBuilder cbTopX = this.entityManager.getCriteriaBuilder(); final CriteriaQuery queryTopX = cbTopX.createQuery(Object[].class); final Root rootTopX = queryTopX.from(DistributionSet.class); final ListJoin joinTopX = rootTopX.join(DistributionSet_.assignedToTargets, @@ -154,7 +154,7 @@ public class ReportManagement { .orderBy(cbTopX.desc(countColumn), cbTopX.asc(rootTopX.get(DistributionSet_.name))); // | col1 | col2 | col3 | // | NAME | VER | COUNT | - final List resultListTop = entityManager.createQuery(groupBy).getResultList(); + final List resultListTop = this.entityManager.createQuery(groupBy).getResultList(); // end of top X entries distribution usage return mapDistirbutionUsageResultToDataReport(topXEntries, resultListTop); @@ -180,7 +180,7 @@ public class ReportManagement { @Cacheable("distributionUsageInstalled") public List> distributionUsageInstalled(final int topXEntries) { // top X entries distribution usage - final CriteriaBuilder cbTopX = entityManager.getCriteriaBuilder(); + final CriteriaBuilder cbTopX = this.entityManager.getCriteriaBuilder(); final CriteriaQuery queryTopX = cbTopX.createQuery(Object[].class); final Root rootTopX = queryTopX.from(DistributionSet.class); final ListJoin joinTopX = rootTopX.join(DistributionSet_.installedAtTargets, @@ -194,7 +194,7 @@ public class ReportManagement { .orderBy(cbTopX.desc(countColumn), cbTopX.asc(rootTopX.get(DistributionSet_.name))); // | col1 | col2 | col3 | // | NAME | VER | COUNT | - final List resultListTop = entityManager.createQuery(groupBy).getResultList(); + final List resultListTop = this.entityManager.createQuery(groupBy).getResultList(); // end of top X entries distribution usage return mapDistirbutionUsageResultToDataReport(topXEntries, resultListTop); @@ -213,9 +213,9 @@ public class ReportManagement { * count */ @Cacheable("targetsCreatedOverPeriod") - public DataReportSeries targetsCreatedOverPeriod(final DateType dateType, final LocalDateTime from, - final LocalDateTime to) { - final Query createNativeQuery = entityManager + public DataReportSeries targetsCreatedOverPeriod(final DateType dateType, + final LocalDateTime from, final LocalDateTime to) { + final Query createNativeQuery = this.entityManager .createNativeQuery(getTargetsCreatedQueryTemplate(dateType, from, to)); final List resultList = createNativeQuery.getResultList(); @@ -223,22 +223,21 @@ public class ReportManagement { .map(r -> new DataReportSeriesItem<>(dateType.format((String) r[0]), ((Number) r[1]).longValue())) .collect(Collectors.toList()); - final DataReportSeries report = new DataReportSeries<>("CreatedTargets", reportItems); - return report; + return new DataReportSeries<>("CreatedTargets", reportItems); } private String getTargetsCreatedQueryTemplate(final DateType dateType, final LocalDateTime from, final LocalDateTime to) { - switch (databaseType) { + switch (this.databaseType) { case H2_DB_TYPE: return String.format(H2_TARGET_CREATED_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType), dateTimeFormatToSqlFormat(dateType), from.format(DATE_FORMAT), dateTimeFormatToSqlFormat(dateType), - to.format(DATE_FORMAT), dateTimeFormatToSqlFormat(dateType), tenantAware.getCurrentTenant(), + to.format(DATE_FORMAT), dateTimeFormatToSqlFormat(dateType), this.tenantAware.getCurrentTenant(), dateTimeFormatToSqlFormat(dateType)); case MYSQL_DB_TYPE: return String.format(MYSQL_TARGET_CREATED_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType), dateTimeFormatToSqlFormat(dateType), from.toString(), dateTimeFormatToSqlFormat(dateType), - to.toString(), dateTimeFormatToSqlFormat(dateType), tenantAware.getCurrentTenant(), + to.toString(), dateTimeFormatToSqlFormat(dateType), this.tenantAware.getCurrentTenant(), dateTimeFormatToSqlFormat(dateType)); default: return null; @@ -247,16 +246,16 @@ public class ReportManagement { private String getFeedbackReceivedQueryTemplate(final DateType dateType, final LocalDateTime from, final LocalDateTime to) { - switch (databaseType) { + switch (this.databaseType) { case H2_DB_TYPE: return String.format(H2_CONTROLLER_FRRDBACK_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType), dateTimeFormatToSqlFormat(dateType), from.format(DATE_FORMAT), dateTimeFormatToSqlFormat(dateType), - to.format(DATE_FORMAT), dateTimeFormatToSqlFormat(dateType), tenantAware.getCurrentTenant(), + to.format(DATE_FORMAT), dateTimeFormatToSqlFormat(dateType), this.tenantAware.getCurrentTenant(), dateTimeFormatToSqlFormat(dateType)); case MYSQL_DB_TYPE: return String.format(MYSQL_CONTROLLER_FRRDBACK_SQL_TEMPLATE, dateTimeFormatToSqlFormat(dateType), dateTimeFormatToSqlFormat(dateType), from.toString(), dateTimeFormatToSqlFormat(dateType), - to.toString(), dateTimeFormatToSqlFormat(dateType), tenantAware.getCurrentTenant(), + to.toString(), dateTimeFormatToSqlFormat(dateType), this.tenantAware.getCurrentTenant(), dateTimeFormatToSqlFormat(dateType)); default: return null; @@ -276,9 +275,9 @@ public class ReportManagement { * count */ @Cacheable("feedbackReceivedOverTime") - public DataReportSeries feedbackReceivedOverTime(final DateType dateType, final LocalDateTime from, - final LocalDateTime to) { - final Query createNativeQuery = entityManager + public DataReportSeries feedbackReceivedOverTime(final DateType dateType, + final LocalDateTime from, final LocalDateTime to) { + final Query createNativeQuery = this.entityManager .createNativeQuery(getFeedbackReceivedQueryTemplate(dateType, from, to)); final List resultList = createNativeQuery.getResultList(); @@ -286,8 +285,7 @@ public class ReportManagement { .map(r -> new DataReportSeriesItem<>(dateType.format((String) r[0]), ((Number) r[1]).longValue())) .collect(Collectors.toList()); - final DataReportSeries report = new DataReportSeries<>("FeedbackRecieved", reportItems); - return report; + return new DataReportSeries<>("FeedbackRecieved", reportItems); } /** @@ -313,30 +311,30 @@ public class ReportManagement { final LocalDateTime beforeMonth = now.minusMonths(1); final LocalDateTime beforeYear = now.minusYears(1); - final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + final CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); final List> resultList = new ArrayList<>(); // hours - resultList.add(new DataReportSeriesItem(SeriesTime.HOUR, - entityManager.createQuery(createCountSelectTargetsLastPoll(cb, beforeHour, now)).getSingleResult())); + resultList.add(new DataReportSeriesItem(SeriesTime.HOUR, this.entityManager + .createQuery(createCountSelectTargetsLastPoll(cb, beforeHour, now)).getSingleResult())); // days - resultList.add(new DataReportSeriesItem(SeriesTime.DAY, entityManager + resultList.add(new DataReportSeriesItem(SeriesTime.DAY, this.entityManager .createQuery(createCountSelectTargetsLastPoll(cb, beforeDay, beforeHour)).getSingleResult())); // weeks - resultList.add(new DataReportSeriesItem(SeriesTime.WEEK, entityManager + resultList.add(new DataReportSeriesItem(SeriesTime.WEEK, this.entityManager .createQuery(createCountSelectTargetsLastPoll(cb, beforeWeek, beforeDay)).getSingleResult())); // months - resultList.add(new DataReportSeriesItem(SeriesTime.MONTH, entityManager + resultList.add(new DataReportSeriesItem(SeriesTime.MONTH, this.entityManager .createQuery(createCountSelectTargetsLastPoll(cb, beforeMonth, beforeWeek)).getSingleResult())); // years - resultList.add(new DataReportSeriesItem(SeriesTime.YEAR, entityManager + resultList.add(new DataReportSeriesItem(SeriesTime.YEAR, this.entityManager .createQuery(createCountSelectTargetsLastPoll(cb, beforeYear, beforeMonth)).getSingleResult())); // years - resultList.add(new DataReportSeriesItem(SeriesTime.MORE_THAN_YEAR, - entityManager.createQuery(createCountSelectTargetsLastPoll(cb, null, beforeYear)).getSingleResult())); + resultList.add(new DataReportSeriesItem(SeriesTime.MORE_THAN_YEAR, this.entityManager + .createQuery(createCountSelectTargetsLastPoll(cb, null, beforeYear)).getSingleResult())); // never resultList.add(new DataReportSeriesItem(SeriesTime.NEVER, - entityManager.createQuery(createCountSelectTargetsLastPoll(cb, null, null)).getSingleResult())); + this.entityManager.createQuery(createCountSelectTargetsLastPoll(cb, null, null)).getSingleResult())); return new DataReportSeries<>("TargetLastPoll", resultList); } @@ -417,23 +415,23 @@ public class ReportManagement { final List outer; private InnerOuter(final DSName idName) { - name = idName; - outer = new ArrayList<>(); + this.name = idName; + this.outer = new ArrayList<>(); } private InnerOuter(final DSName idName, final long count) { - name = idName; + this.name = idName; this.count = count; - outer = new ArrayList<>(); + this.outer = new ArrayList<>(); } private void addOuter(final DSName idName, final long count) { - outer.add(new InnerOuter(idName, count)); + this.outer.add(new InnerOuter(idName, count)); this.count += count; } private DataReportSeriesItem toItem() { - return new DataReportSeriesItem(name.getName() != null ? name.getName() : "misc", count); + return new DataReportSeriesItem<>(this.name.getName() != null ? this.name.getName() : "misc", this.count); } } @@ -462,7 +460,7 @@ public class ReportManagement { * @return the name */ private String getName() { - return name; + return this.name; } /* @@ -474,7 +472,7 @@ public class ReportManagement { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + (name == null ? 0 : name.hashCode()); + result = prime * result + (this.name == null ? 0 : this.name.hashCode()); return result; } @@ -496,11 +494,11 @@ public class ReportManagement { return false; } final DSName other = (DSName) obj; - if (name == null) { + if (this.name == null) { if (other.name != null) { return false; } - } else if (!name.equals(other.name)) { + } else if (!this.name.equals(other.name)) { return false; } return true; @@ -513,12 +511,12 @@ public class ReportManagement { */ @Override public String toString() { - return "DSName [name=" + name + "]"; + return "DSName [name=" + this.name + "]"; } } private String dateTimeFormatToSqlFormat(final DateType datatype) { - switch (databaseType) { + switch (this.databaseType) { case H2_DB_TYPE: return datatype.h2Format(); case MYSQL_DB_TYPE: diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java index 98cb1f418..2bc5ba25f 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java @@ -40,6 +40,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModule_; import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey; import org.eclipse.hawkbit.repository.specifications.SoftwareModuleSpecification; +import org.eclipse.hawkbit.repository.specifications.SpecificationsBuilder; import org.hibernate.validator.constraints.NotEmpty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.AuditorAware; @@ -48,7 +49,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; import org.springframework.data.domain.SliceImpl; import org.springframework.data.jpa.domain.Specification; -import org.springframework.data.jpa.domain.Specifications; import org.springframework.data.jpa.repository.Modifying; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; @@ -117,7 +117,7 @@ public class SoftwareManagement { public SoftwareModule updateSoftwareModule(@NotNull final SoftwareModule sm) { checkNotNull(sm.getId()); - final SoftwareModule module = softwareModuleRepository.findOne(sm.getId()); + final SoftwareModule module = this.softwareModuleRepository.findOne(sm.getId()); if (null == sm.getDescription() || !sm.getDescription().equals(module.getDescription())) { module.setDescription(sm.getDescription()); @@ -125,7 +125,7 @@ public class SoftwareManagement { if (null == sm.getVendor() || !sm.getVendor().equals(module.getVendor())) { module.setVendor(sm.getVendor()); } - return softwareModuleRepository.save(module); + return this.softwareModuleRepository.save(module); } /** @@ -143,7 +143,7 @@ public class SoftwareManagement { public SoftwareModuleType updateSoftwareModuleType(@NotNull final SoftwareModuleType sm) { checkNotNull(sm.getId()); - final SoftwareModuleType type = softwareModuleTypeRepository.findOne(sm.getId()); + final SoftwareModuleType type = this.softwareModuleTypeRepository.findOne(sm.getId()); if (sm.getDescription() != null && !sm.getDescription().equals(type.getDescription())) { type.setDescription(sm.getDescription()); @@ -151,7 +151,7 @@ public class SoftwareManagement { if (sm.getColour() != null && !sm.getColour().equals(type.getColour())) { type.setColour(sm.getColour()); } - return softwareModuleTypeRepository.save(type); + return this.softwareModuleTypeRepository.save(type); } /** @@ -169,7 +169,7 @@ public class SoftwareManagement { if (null != swModule.getId()) { throw new EntityAlreadyExistsException(); } - return softwareModuleRepository.save(swModule); + return this.softwareModuleRepository.save(swModule); } /** @@ -191,14 +191,14 @@ public class SoftwareManagement { } }); - return softwareModuleRepository.save(swModules); + return this.softwareModuleRepository.save(swModules); } /** * retrieves the {@link SoftwareModule}s by their {@link SoftwareModuleType} * . - * + * * @param pageable * page parameters * @param type @@ -209,7 +209,7 @@ public class SoftwareManagement { public Slice findSoftwareModulesByType(@NotNull final Pageable pageable, @NotNull final SoftwareModuleType type) { - final List> specList = new ArrayList>(); + final List> specList = new ArrayList<>(); Specification spec = SoftwareModuleSpecification.equalType(type); specList.add(spec); @@ -230,7 +230,7 @@ public class SoftwareManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Long countSoftwareModulesByType(@NotNull final SoftwareModuleType type) { - final List> specList = new ArrayList>(); + final List> specList = new ArrayList<>(); Specification spec = SoftwareModuleSpecification.equalType(type); specList.add(spec); @@ -252,12 +252,12 @@ public class SoftwareManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR + SpringEvalExpressions.IS_CONTROLLER) public SoftwareModule findSoftwareModuleById(@NotNull final Long id) { - return artifactManagement.findSoftwareModuleById(id); + return this.artifactManagement.findSoftwareModuleById(id); } /** * retrieves {@link SoftwareModule}s by their name AND version. - * + * * @param name * of the {@link SoftwareModule} * @param version @@ -268,12 +268,12 @@ public class SoftwareManagement { public List findSoftwareModuleByNameAndVersion(@NotEmpty final String name, @NotEmpty final String version) { - return softwareModuleRepository.findByNameAndVersion(name, version); + return this.softwareModuleRepository.findByNameAndVersion(name, version); } /** * Deletes the given {@link SoftwareModule} {@link Entity}. - * + * * @param bsm * is the {@link SoftwareModule} to be deleted */ @@ -286,42 +286,28 @@ public class SoftwareManagement { } private boolean isUnassigned(final SoftwareModule bsmMerged) { - return distributionSetRepository.findByModules(bsmMerged).isEmpty(); + return this.distributionSetRepository.findByModules(bsmMerged).isEmpty(); } private Slice findSwModuleByCriteriaAPI(@NotNull final Pageable pageable, @NotEmpty final List> specList) { - - Specifications specs = Specifications.where(specList.get(0)); - if (specList.size() > 1) { - for (final Specification s : specList.subList(1, specList.size())) { - specs = specs.and(s); - } - } - - return criteriaNoCountDao.findAll(specs, pageable, SoftwareModule.class); + return this.criteriaNoCountDao.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable, + SoftwareModule.class); } private Long countSwModuleByCriteriaAPI(@NotEmpty final List> specList) { - Specifications specs = Specifications.where(specList.get(0)); - if (specList.size() > 1) { - for (final Specification s : specList.subList(1, specList.size())) { - specs = specs.and(s); - } - } - - return softwareModuleRepository.count(specs); + return this.softwareModuleRepository.count(SpecificationsBuilder.combineWithAnd(specList)); } private void deleteGridFsArtifacts(final SoftwareModule swModule) { for (final LocalArtifact localArtifact : swModule.getLocalArtifacts()) { - artifactManagement.deleteGridFsArtifact(localArtifact); + this.artifactManagement.deleteGridFsArtifact(localArtifact); } } /** * Deletes {@link SoftwareModule}s which is any if the given ids. - * + * * @param ids * of the Software Moduels to be deleted */ @@ -329,7 +315,7 @@ public class SoftwareManagement { @Transactional @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) public void deleteSoftwareModules(@NotNull final Iterable ids) { - final List swModulesToDelete = softwareModuleRepository.findByIdIn(ids); + final List swModulesToDelete = this.softwareModuleRepository.findByIdIn(ids); final Set assignedModuleIds = new HashSet<>(); swModulesToDelete.forEach(swModule -> { @@ -338,7 +324,7 @@ public class SoftwareManagement { if (isUnassigned(swModule)) { - softwareModuleRepository.delete(swModule); + this.softwareModuleRepository.delete(swModule); } else { @@ -348,10 +334,10 @@ public class SoftwareManagement { if (!assignedModuleIds.isEmpty()) { String currentUser = null; - if (auditorProvider != null) { - currentUser = auditorProvider.getCurrentAuditor(); + if (this.auditorProvider != null) { + currentUser = this.auditorProvider.getCurrentAuditor(); } - softwareModuleRepository.deleteSoftwareModule(System.currentTimeMillis(), currentUser, + this.softwareModuleRepository.deleteSoftwareModule(System.currentTimeMillis(), currentUser, assignedModuleIds.toArray(new Long[0])); } } @@ -366,20 +352,16 @@ public class SoftwareManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Slice findSoftwareModulesAll(@NotNull final Pageable pageable) { - final List> specList = new ArrayList>(); + final List> specList = new ArrayList<>(); Specification spec = SoftwareModuleSpecification.isDeletedFalse(); specList.add(spec); - spec = new Specification() { - @Override - public Predicate toPredicate(final Root root, final CriteriaQuery query, - final CriteriaBuilder cb) { - if (!query.getResultType().isAssignableFrom(Long.class)) { - root.fetch(SoftwareModule_.type); - } - return cb.conjunction(); + spec = (root, query, cb) -> { + if (!query.getResultType().isAssignableFrom(Long.class)) { + root.fetch(SoftwareModule_.type); } + return cb.conjunction(); }; specList.add(spec); @@ -396,7 +378,7 @@ public class SoftwareManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Long countSoftwareModulesAll() { - final List> specList = new ArrayList>(); + final List> specList = new ArrayList<>(); final Specification spec = SoftwareModuleSpecification.isDeletedFalse(); specList.add(spec); @@ -416,7 +398,7 @@ public class SoftwareManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public SoftwareModule findSoftwareModuleWithDetails(@NotNull final Long id) { - return artifactManagement.findSoftwareModuleWithDetails(id); + return this.artifactManagement.findSoftwareModuleWithDetails(id); } /** @@ -431,7 +413,7 @@ public class SoftwareManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Page findSoftwareModulesByPredicate(@NotNull final Specification spec, @NotNull final Pageable pageable) { - return softwareModuleRepository.findAll(spec, pageable); + return this.softwareModuleRepository.findAll(spec, pageable); } /** @@ -446,7 +428,7 @@ public class SoftwareManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Page findSoftwareModuleTypesByPredicate( @NotNull final Specification spec, @NotNull final Pageable pageable) { - return softwareModuleTypeRepository.findAll(spec, pageable); + return this.softwareModuleTypeRepository.findAll(spec, pageable); } /** @@ -459,7 +441,7 @@ public class SoftwareManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public List findSoftwareModulesById(@NotEmpty final List ids) { - return softwareModuleRepository.findByIdIn(ids); + return this.softwareModuleRepository.findByIdIn(ids); } /** @@ -479,7 +461,7 @@ public class SoftwareManagement { public Slice findSoftwareModuleByFilters(@NotNull final Pageable pageable, final String searchText, final SoftwareModuleType type) { - final List> specList = new ArrayList>(); + final List> specList = new ArrayList<>(); Specification spec = SoftwareModuleSpecification.isDeletedFalse(); specList.add(spec); @@ -494,15 +476,11 @@ public class SoftwareManagement { specList.add(spec); } - spec = new Specification() { - @Override - public Predicate toPredicate(final Root root, final CriteriaQuery query, - final CriteriaBuilder cb) { - if (!query.getResultType().isAssignableFrom(Long.class)) { - root.fetch(SoftwareModule_.type); - } - return cb.conjunction(); + spec = (root, query, cb) -> { + if (!query.getResultType().isAssignableFrom(Long.class)) { + root.fetch(SoftwareModule_.type); } + return cb.conjunction(); }; specList.add(spec); @@ -531,7 +509,7 @@ public class SoftwareManagement { final List resultList = new ArrayList<>(); final int pageSize = pageable.getPageSize(); - final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + final CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // get the assigned software modules final CriteriaQuery assignedQuery = cb.createQuery(SoftwareModule.class); @@ -551,7 +529,8 @@ public class SoftwareManagement { // don't page the assigned query on database, we need all assigned // software modules to filter // them out in the unassigned query - final List assignedSoftwareModules = entityManager.createQuery(assignedQuery).getResultList(); + final List assignedSoftwareModules = this.entityManager.createQuery(assignedQuery) + .getResultList(); // map result if (pageable.getOffset() < assignedSoftwareModules.size()) { assignedSoftwareModules @@ -581,7 +560,7 @@ public class SoftwareManagement { unassignedQuery.where(unassignedSpec); unassignedQuery.orderBy(cb.asc(unassignedRoot.get(SoftwareModule_.name)), cb.asc(unassignedRoot.get(SoftwareModule_.version))); - final List unassignedSoftwareModules = entityManager.createQuery(unassignedQuery) + final List unassignedSoftwareModules = this.entityManager.createQuery(unassignedQuery) .setFirstResult(Math.max(0, pageable.getOffset() - assignedSoftwareModules.size())) .setMaxResults(pageSize).getResultList(); // map result @@ -592,7 +571,7 @@ public class SoftwareManagement { private List> buildSpecificationList(final String searchText, final SoftwareModuleType type) { - final List> specList = new ArrayList>(); + final List> specList = new ArrayList<>(); if (!Strings.isNullOrEmpty(searchText)) { specList.add(SoftwareModuleSpecification.likeNameOrVersion(searchText)); } @@ -631,7 +610,7 @@ public class SoftwareManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Long countSoftwareModuleByFilters(final String searchText, final SoftwareModuleType type) { - final List> specList = new ArrayList>(); + final List> specList = new ArrayList<>(); Specification spec = SoftwareModuleSpecification.isDeletedFalse(); specList.add(spec); @@ -656,7 +635,7 @@ public class SoftwareManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Page findSoftwareModuleTypesAll(@NotNull final Pageable pageable) { - return softwareModuleTypeRepository.findByDeleted(pageable, false); + return this.softwareModuleTypeRepository.findByDeleted(pageable, false); } /** @@ -664,7 +643,7 @@ public class SoftwareManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Long countSoftwareModuleTypesAll() { - return softwareModuleTypeRepository.countByDeleted(false); + return this.softwareModuleTypeRepository.countByDeleted(false); } /** @@ -676,7 +655,7 @@ public class SoftwareManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public SoftwareModuleType findSoftwareModuleTypeByKey(@NotNull final String key) { - return softwareModuleTypeRepository.findByKey(key); + return this.softwareModuleTypeRepository.findByKey(key); } /** @@ -688,7 +667,7 @@ public class SoftwareManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public SoftwareModuleType findSoftwareModuleTypeById(@NotNull final Long id) { - return softwareModuleTypeRepository.findOne(id); + return this.softwareModuleTypeRepository.findOne(id); } /** @@ -700,7 +679,7 @@ public class SoftwareManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public SoftwareModuleType findSoftwareModuleTypeByName(@NotNull final String name) { - return softwareModuleTypeRepository.findByName(name); + return this.softwareModuleTypeRepository.findByName(name); } /** @@ -718,7 +697,7 @@ public class SoftwareManagement { throw new EntityAlreadyExistsException("Given type contains an Id!"); } - return softwareModuleTypeRepository.save(type); + return this.softwareModuleTypeRepository.save(type); } /** @@ -746,13 +725,13 @@ public class SoftwareManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) public void deleteSoftwareModuleType(@NotNull final SoftwareModuleType type) { - if (softwareModuleRepository.countByType(type) > 0 - || distributionSetTypeRepository.countByElementsSmType(type) > 0) { - final SoftwareModuleType toDelete = entityManager.merge(type); + if (this.softwareModuleRepository.countByType(type) > 0 + || this.distributionSetTypeRepository.countByElementsSmType(type) > 0) { + final SoftwareModuleType toDelete = this.entityManager.merge(type); toDelete.setDeleted(true); - softwareModuleTypeRepository.save(toDelete); + this.softwareModuleTypeRepository.save(toDelete); } else { - softwareModuleTypeRepository.delete(type.getId()); + this.softwareModuleTypeRepository.delete(type.getId()); } } @@ -767,7 +746,7 @@ public class SoftwareManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Page findSoftwareModuleByAssignedTo(@NotNull final Pageable pageable, @NotNull final DistributionSet set) { - return softwareModuleRepository.findByAssignedTo(pageable, set); + return this.softwareModuleRepository.findByAssignedTo(pageable, set); } /** @@ -783,12 +762,12 @@ public class SoftwareManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Page findSoftwareModuleByAssignedToAndType(@NotNull final Pageable pageable, @NotNull final DistributionSet set, @NotNull final SoftwareModuleType type) { - return softwareModuleRepository.findByAssignedToAndType(pageable, set, type); + return this.softwareModuleRepository.findByAssignedToAndType(pageable, set, type); } /** * creates or updates a single software module meta data entry. - * + * * @param metadata * the meta data entry to create or update * @return the updated or created software module meta data entry @@ -800,20 +779,20 @@ public class SoftwareManagement { @Modifying @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) public SoftwareModuleMetadata createSoftwareModuleMetadata(@NotNull final SoftwareModuleMetadata metadata) { - if (softwareModuleMetadataRepository.exists(metadata.getId())) { + if (this.softwareModuleMetadataRepository.exists(metadata.getId())) { throwMetadataKeyAlreadyExists(metadata.getId().getKey()); } // merge base software module so optLockRevision gets updated and audit // log written because // modifying metadata is modifying the base software module itself for // auditing purposes. - entityManager.merge(metadata.getSoftwareModule()).setLastModifiedAt(-1L); - return softwareModuleMetadataRepository.save(metadata); + this.entityManager.merge(metadata.getSoftwareModule()).setLastModifiedAt(-1L); + return this.softwareModuleMetadataRepository.save(metadata); } /** * creates a list of software module meta data entries. - * + * * @param metadata * the meta data entries to create or update * @return the updated or created software module meta data entries @@ -829,13 +808,13 @@ public class SoftwareManagement { for (final SoftwareModuleMetadata softwareModuleMetadata : metadata) { checkAndThrowAlreadyExistsIfSoftwareModuleMetadataExists(softwareModuleMetadata.getId()); } - metadata.forEach(m -> entityManager.merge(m.getSoftwareModule()).setLastModifiedAt(-1L)); - return softwareModuleMetadataRepository.save(metadata); + metadata.forEach(m -> this.entityManager.merge(m.getSoftwareModule()).setLastModifiedAt(-1L)); + return this.softwareModuleMetadataRepository.save(metadata); } /** * updates a distribution set meta data value if corresponding entry exists. - * + * * @param metadata * the meta data entry to be updated * @return the updated meta data entry @@ -852,13 +831,13 @@ public class SoftwareManagement { // touch it to update the lock revision because we are modifying the // software module // indirectly - entityManager.merge(metadata.getSoftwareModule()).setLastModifiedAt(-1L); - return softwareModuleMetadataRepository.save(metadata); + this.entityManager.merge(metadata.getSoftwareModule()).setLastModifiedAt(-1L); + return this.softwareModuleMetadataRepository.save(metadata); } /** * deletes a software module meta data entry. - * + * * @param id * the ID of the software module meta data to delete */ @@ -866,12 +845,12 @@ public class SoftwareManagement { @Modifying @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) public void deleteSoftwareModuleMetadata(@NotNull final SwMetadataCompositeKey id) { - softwareModuleMetadataRepository.delete(id); + this.softwareModuleMetadataRepository.delete(id); } /** * finds all meta data by the given software module id. - * + * * @param swId * the software module id to retrieve the meta data from * @param pageable @@ -882,12 +861,12 @@ public class SoftwareManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Page findSoftwareModuleMetadataBySoftwareModuleId(@NotNull final Long swId, @NotNull final Pageable pageable) { - return softwareModuleMetadataRepository.findBySoftwareModuleId(swId, pageable); + return this.softwareModuleMetadataRepository.findBySoftwareModuleId(swId, pageable); } /** * finds all meta data by the given software module id. - * + * * @param softwareModuleId * the software module id to retrieve the meta data from * @param spec @@ -900,20 +879,19 @@ public class SoftwareManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Page findSoftwareModuleMetadataBySoftwareModuleId(final Long softwareModuleId, @NotNull final Specification spec, @NotNull final Pageable pageable) { - return softwareModuleMetadataRepository.findAll(new Specification() { - @Override - public Predicate toPredicate(final Root root, final CriteriaQuery query, - final CriteriaBuilder cb) { - - return cb.and(cb.equal(root.get(SoftwareModuleMetadata_.softwareModule).get(SoftwareModule_.id), - softwareModuleId), spec.toPredicate(root, query, cb)); - } - }, pageable); + return this.softwareModuleMetadataRepository + .findAll( + (Specification) (root, query, + cb) -> cb.and( + cb.equal(root.get(SoftwareModuleMetadata_.softwareModule) + .get(SoftwareModule_.id), softwareModuleId), + spec.toPredicate(root, query, cb)), + pageable); } /** * finds a single software module meta data by its id. - * + * * @param id * the id of the software module meta data containing the meta * data key and the ID of the software module @@ -923,7 +901,7 @@ public class SoftwareManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public SoftwareModuleMetadata findOne(@NotNull final SwMetadataCompositeKey id) { - final SoftwareModuleMetadata findOne = softwareModuleMetadataRepository.findOne(id); + final SoftwareModuleMetadata findOne = this.softwareModuleMetadataRepository.findOne(id); if (findOne == null) { throw new EntityNotFoundException("Metadata with key '" + id.getKey() + "' does not exist"); } @@ -931,7 +909,7 @@ public class SoftwareManagement { } private void checkAndThrowAlreadyExistsIfSoftwareModuleMetadataExists(final SwMetadataCompositeKey metadataId) { - if (softwareModuleMetadataRepository.exists(metadataId)) { + if (this.softwareModuleMetadataRepository.exists(metadataId)) { throw new EntityAlreadyExistsException( "Metadata entry with key '" + metadataId.getKey() + "' already exists"); } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java index 3b678ec48..5d219cb58 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java @@ -77,13 +77,13 @@ public class Rollout extends NamedEntity { private int rolloutGroupsCreated = 0; @Transient - private TotalTargetCountStatus totalTargetCountStatus; + private transient TotalTargetCountStatus totalTargetCountStatus; /** * @return the distributionSet */ public DistributionSet getDistributionSet() { - return distributionSet; + return this.distributionSet; } /** @@ -98,7 +98,7 @@ public class Rollout extends NamedEntity { * @return the rolloutGroups */ public List getRolloutGroups() { - return rolloutGroups; + return this.rolloutGroups; } /** @@ -113,7 +113,7 @@ public class Rollout extends NamedEntity { * @return the targetFilterQuery */ public String getTargetFilterQuery() { - return targetFilterQuery; + return this.targetFilterQuery; } /** @@ -128,7 +128,7 @@ public class Rollout extends NamedEntity { * @return the status */ public RolloutStatus getStatus() { - return status; + return this.status; } /** @@ -143,7 +143,7 @@ public class Rollout extends NamedEntity { * @return the lastCheck */ public long getLastCheck() { - return lastCheck; + return this.lastCheck; } /** @@ -158,7 +158,7 @@ public class Rollout extends NamedEntity { * @return the actionType */ public ActionType getActionType() { - return actionType; + return this.actionType; } /** @@ -173,7 +173,7 @@ public class Rollout extends NamedEntity { * @return the forcedTime */ public long getForcedTime() { - return forcedTime; + return this.forcedTime; } /** @@ -188,7 +188,7 @@ public class Rollout extends NamedEntity { * @return the totalTargets */ public long getTotalTargets() { - return totalTargets; + return this.totalTargets; } /** @@ -203,7 +203,7 @@ public class Rollout extends NamedEntity { * @return the rolloutGroupsTotal */ public int getRolloutGroupsTotal() { - return rolloutGroupsTotal; + return this.rolloutGroupsTotal; } /** @@ -218,7 +218,7 @@ public class Rollout extends NamedEntity { * @return the rolloutGroupsCreated */ public int getRolloutGroupsCreated() { - return rolloutGroupsCreated; + return this.rolloutGroupsCreated; } /** @@ -233,10 +233,10 @@ public class Rollout extends NamedEntity { * @return the totalTargetCountStatus */ public TotalTargetCountStatus getTotalTargetCountStatus() { - if (totalTargetCountStatus == null) { - this.totalTargetCountStatus = new TotalTargetCountStatus(totalTargets); + if (this.totalTargetCountStatus == null) { + this.totalTargetCountStatus = new TotalTargetCountStatus(this.totalTargets); } - return totalTargetCountStatus; + return this.totalTargetCountStatus; } /** @@ -249,17 +249,17 @@ public class Rollout extends NamedEntity { @Override public String toString() { - return "Rollout [rolloutGroups=" + rolloutGroups + ", targetFilterQuery=" + targetFilterQuery - + ", distributionSet=" + distributionSet + ", status=" + status + ", lastCheck=" + lastCheck - + ", getName()=" + getName() + ", getId()=" + getId() + "]"; + return "Rollout [rolloutGroups=" + this.rolloutGroups + ", targetFilterQuery=" + this.targetFilterQuery + + ", distributionSet=" + this.distributionSet + ", status=" + this.status + ", lastCheck=" + + this.lastCheck + ", getName()=" + getName() + ", getId()=" + getId() + "]"; } /** - * + * * @author Michael Hirsch * */ - public static enum RolloutStatus { + public enum RolloutStatus { /** * Rollouts is beeing created. diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java index a185f481f..e9def6f62 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java @@ -8,6 +8,7 @@ */ package org.eclipse.hawkbit.repository.model; +import java.io.Serializable; import java.util.List; import javax.persistence.CascadeType; @@ -30,16 +31,18 @@ import javax.persistence.Table; @IdClass(RolloutTargetGroupId.class) @Entity @Table(name = "sp_rollouttargetgroup") -public class RolloutTargetGroup { +public class RolloutTargetGroup implements Serializable { + + private static final long serialVersionUID = 1L; @Id @ManyToOne(targetEntity = RolloutGroup.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST }) - @JoinColumn(name = "rolloutGroup_Id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollouttargetgroup_group")) + @JoinColumn(name = "rolloutGroup_Id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollouttargetgroup_group") ) private RolloutGroup rolloutGroup; @Id @ManyToOne(targetEntity = Target.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST }) - @JoinColumn(name = "target_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollouttargetgroup_target")) + @JoinColumn(name = "target_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollouttargetgroup_target") ) private Target target; @OneToMany(targetEntity = Action.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST }) @@ -60,6 +63,6 @@ public class RolloutTargetGroup { } public RolloutTargetGroupId getId() { - return new RolloutTargetGroupId(rolloutGroup, target); + return new RolloutTargetGroupId(this.rolloutGroup, this.target); } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TotalTargetCountStatus.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TotalTargetCountStatus.java index f403ecc3d..0804cc9ef 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TotalTargetCountStatus.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TotalTargetCountStatus.java @@ -9,12 +9,12 @@ package org.eclipse.hawkbit.repository.model; import java.util.Collections; -import java.util.HashMap; +import java.util.EnumMap; import java.util.List; import java.util.Map; /** - * + * * Store all states with the target count of a rollout or rolloutgroup. * */ @@ -27,12 +27,12 @@ public class TotalTargetCountStatus { SCHEDULED, RUNNING, ERROR, FINISHED, CANCELLED, NOTSTARTED } - private final Map statusTotalCountMap = new HashMap<>(); + private final Map statusTotalCountMap = new EnumMap<>(Status.class); private final Long totalTargetCount; /** * Create a new states map with the target count for each state. - * + * * @param targetCountActionStatus * the action state map * @param totalTargets @@ -46,7 +46,7 @@ public class TotalTargetCountStatus { /** * Create a new states map with the target count for each state. - * + * * @param totalTargetCount * the total target count */ @@ -56,28 +56,28 @@ public class TotalTargetCountStatus { /** * The current state mape which the total target count - * + * * @return the statusTotalCountMap the state map */ public Map getStatusTotalCountMap() { - return statusTotalCountMap; + return this.statusTotalCountMap; } /** * Gets the total target count from a state. - * + * * @param status * the state key * @return the current target count cannot be */ public Long getTotalTargetCountByStatus(final Status status) { - final Long count = statusTotalCountMap.get(status); + final Long count = this.statusTotalCountMap.get(status); return count == null ? 0L : count; } /** * Populate all target status to a the given map - * + * * @param statusTotalCountMap * the map * @param rolloutStatusCountItems @@ -87,39 +87,39 @@ public class TotalTargetCountStatus { private final void mapActionStatusToTotalTargetCountStatus( final List targetCountActionStatus) { if (targetCountActionStatus == null) { - statusTotalCountMap.put(TotalTargetCountStatus.Status.NOTSTARTED, totalTargetCount); + this.statusTotalCountMap.put(TotalTargetCountStatus.Status.NOTSTARTED, this.totalTargetCount); return; } - statusTotalCountMap.put(Status.RUNNING, 0L); - Long notStartedTargetCount = totalTargetCount; + this.statusTotalCountMap.put(Status.RUNNING, 0L); + Long notStartedTargetCount = this.totalTargetCount; for (final TotalTargetCountActionStatus item : targetCountActionStatus) { switch (item.getStatus()) { case SCHEDULED: - statusTotalCountMap.put(Status.SCHEDULED, item.getCount()); + this.statusTotalCountMap.put(Status.SCHEDULED, item.getCount()); break; case ERROR: - statusTotalCountMap.put(Status.ERROR, item.getCount()); + this.statusTotalCountMap.put(Status.ERROR, item.getCount()); break; case FINISHED: - statusTotalCountMap.put(Status.FINISHED, item.getCount()); + this.statusTotalCountMap.put(Status.FINISHED, item.getCount()); break; case RETRIEVED: case RUNNING: case WARNING: case DOWNLOAD: case CANCELING: - final Long runningItemsCount = statusTotalCountMap.get(Status.RUNNING) + item.getCount(); - statusTotalCountMap.put(Status.RUNNING, runningItemsCount); + final Long runningItemsCount = this.statusTotalCountMap.get(Status.RUNNING) + item.getCount(); + this.statusTotalCountMap.put(Status.RUNNING, runningItemsCount); break; case CANCELED: - statusTotalCountMap.put(Status.CANCELLED, item.getCount()); + this.statusTotalCountMap.put(Status.CANCELLED, item.getCount()); break; default: throw new IllegalArgumentException("State " + item.getStatus() + "is not valid"); } notStartedTargetCount -= item.getCount(); } - statusTotalCountMap.put(TotalTargetCountStatus.Status.NOTSTARTED, notStartedTargetCount); + this.statusTotalCountMap.put(TotalTargetCountStatus.Status.NOTSTARTED, notStartedTargetCount); } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/RolloutGroupConditionEvaluator.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/RolloutGroupConditionEvaluator.java index 73580fd19..62c9050b1 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/RolloutGroupConditionEvaluator.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/RolloutGroupConditionEvaluator.java @@ -16,7 +16,19 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup; */ public interface RolloutGroupConditionEvaluator { - boolean verifyExpression(final String expression); + default boolean verifyExpression(final String expression) { + // percentage value between 0 and 100 + try { + final Integer value = Integer.valueOf(expression); + if (value >= 0 || value <= 100) { + return true; + } + return true; + } catch (final NumberFormatException e) { + + return false; + } + } boolean eval(Rollout rollout, RolloutGroup rolloutGroup, final String expression); } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/ThresholdRolloutGroupErrorCondition.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/ThresholdRolloutGroupErrorCondition.java index 2c2bc361f..c1560d2b8 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/ThresholdRolloutGroupErrorCondition.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/ThresholdRolloutGroupErrorCondition.java @@ -18,35 +18,20 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** - * + * */ @Component("thresholdRolloutGroupErrorCondition") public class ThresholdRolloutGroupErrorCondition implements RolloutGroupConditionEvaluator { - private static Logger logger = LoggerFactory.getLogger(ThresholdRolloutGroupErrorCondition.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ThresholdRolloutGroupErrorCondition.class); @Autowired private ActionRepository actionRepository; - @Override - public boolean verifyExpression(final String expression) { - // percentage value between 0 and 100 - try { - final Integer value = Integer.valueOf(expression); - if (value >= 0 || value <= 100) { - return true; - } - return true; - } catch (final RuntimeException e) { - - } - return false; - } - @Override public boolean eval(final Rollout rollout, final RolloutGroup rolloutGroup, final String expression) { - final Long totalGroup = actionRepository.countByRolloutAndRolloutGroup(rollout, rolloutGroup); - final Long error = actionRepository.countByRolloutIdAndRolloutGroupIdAndStatus(rollout.getId(), + final Long totalGroup = this.actionRepository.countByRolloutAndRolloutGroup(rollout, rolloutGroup); + final Long error = this.actionRepository.countByRolloutIdAndRolloutGroupIdAndStatus(rollout.getId(), rolloutGroup.getId(), Action.Status.ERROR); try { final Integer threshold = Integer.valueOf(expression); @@ -60,7 +45,7 @@ public class ThresholdRolloutGroupErrorCondition implements RolloutGroupConditio // calculate threshold return ((float) error / (float) totalGroup) > ((float) threshold / 100F); } catch (final NumberFormatException e) { - logger.error("Cannot evaluate condition expression " + expression, e); + LOGGER.error("Cannot evaluate condition expression " + expression, e); return false; } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/ThresholdRolloutGroupSuccessCondition.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/ThresholdRolloutGroupSuccessCondition.java index 81b5c7286..fcf9762c6 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/ThresholdRolloutGroupSuccessCondition.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/ThresholdRolloutGroupSuccessCondition.java @@ -12,47 +12,41 @@ import org.eclipse.hawkbit.repository.ActionRepository; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.RolloutGroup; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** - * + * */ @Component("thresholdRolloutGroupSuccessCondition") public class ThresholdRolloutGroupSuccessCondition implements RolloutGroupConditionEvaluator { + private static final Logger LOGGER = LoggerFactory.getLogger(ThresholdRolloutGroupSuccessCondition.class); @Autowired private ActionRepository actionRepository; - @Override - public boolean verifyExpression(final String expression) { - // percentage value between 0 and 100 - try { - final Integer value = Integer.valueOf(expression); - if (value >= 0 || value <= 100) { - return true; - } - return true; - } catch (final RuntimeException e) { - - } - return false; - } - @Override public boolean eval(final Rollout rollout, final RolloutGroup rolloutGroup, final String expression) { final Long totalGroup = rolloutGroup.getTotalTargets(); - final Long finished = actionRepository.countByRolloutIdAndRolloutGroupIdAndStatus(rollout.getId(), + final Long finished = this.actionRepository.countByRolloutIdAndRolloutGroupIdAndStatus(rollout.getId(), rolloutGroup.getId(), Action.Status.FINISHED); - final Integer threshold = Integer.valueOf(expression); + try { + final Integer threshold = Integer.valueOf(expression); - if (totalGroup == 0) { - // in case e.g. targets has been deleted we don't have any actions - // left for this group, so the group is finished - return true; + if (totalGroup == 0) { + // in case e.g. targets has been deleted we don't have any + // actions + // left for this group, so the group is finished + return true; + } + // calculate threshold + return ((float) finished / (float) totalGroup) >= ((float) threshold / 100F); + } catch (final NumberFormatException e) { + LOGGER.error("Cannot evaluate condition expression " + expression, e); + return false; } - // calculate threshold - return ((float) finished / (float) totalGroup) >= ((float) threshold / 100F); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java index b8e5545f3..bd7a35651 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java @@ -75,7 +75,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { private SpringViewProvider viewProvider; @Autowired - private ApplicationContext context; + private transient ApplicationContext context; @Autowired private I18N i18n; @@ -89,13 +89,13 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { private ErrorView errorview; @Autowired - protected EventBus.SessionEventBus eventBus; + protected transient EventBus.SessionEventBus eventBus; /** * An {@link com.google.common.eventbus.EventBus} subscriber which * subscribes {@link EntityEvent} from the repository to dispatch these * events to the UI {@link SessionEventBus}. - * + * * @param event * the entity event which has been published from the repository */ @@ -103,21 +103,28 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { @AllowConcurrentEvents public void dispatch(final org.eclipse.hawkbit.eventbus.event.Event event) { final VaadinSession session = getSession(); - if (session != null && session.getState() == State.OPEN) { - final WrappedSession wrappedSession = session.getSession(); - if (wrappedSession != null) { - final SecurityContext userContext = (SecurityContext) wrappedSession - .getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY); - if (eventSecurityCheck(userContext, event)) { - final SecurityContext oldContext = SecurityContextHolder.getContext(); - try { - access(new DispatcherRunnable(eventBus, session, userContext, event)); - } finally { - SecurityContextHolder.setContext(oldContext); - } - } - } + if (session == null || session.getState() != State.OPEN) { + return; } + + final WrappedSession wrappedSession = session.getSession(); + if (wrappedSession == null) { + return; + } + + final SecurityContext userContext = (SecurityContext) wrappedSession + .getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY); + if (!eventSecurityCheck(userContext, event)) { + return; + } + + final SecurityContext oldContext = SecurityContextHolder.getContext(); + try { + access(new DispatcherRunnable(this.eventBus, session, userContext, event)); + } finally { + SecurityContextHolder.setContext(oldContext); + } + } protected boolean eventSecurityCheck(final SecurityContext userContext, @@ -134,7 +141,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { /* * (non-Javadoc) - * + * * @see * com.vaadin.server.ClientConnector.DetachListener#detach(com.vaadin.server * .ClientConnector. DetachEvent) @@ -149,7 +156,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { protected void init(final VaadinRequest vaadinRequest) { LOG.info("ManagementUI init starts uiid - {}", getUI().getUIId()); addDetachListener(this); - SpringContextHelper.setContext(context); + SpringContextHelper.setContext(this.context); Responsive.makeResponsive(this); addStyleName(ValoTheme.UI_WITH_MENU); @@ -158,25 +165,25 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { final HorizontalLayout rootLayout = new HorizontalLayout(); rootLayout.setSizeFull(); - dashboardMenu.init(); - dashboardMenu.setResponsive(Boolean.TRUE); + this.dashboardMenu.init(); + this.dashboardMenu.setResponsive(Boolean.TRUE); final VerticalLayout contentVerticalLayout = new VerticalLayout(); contentVerticalLayout.addComponent(buildHeader()); contentVerticalLayout.setSizeFull(); - rootLayout.addComponent(dashboardMenu); + rootLayout.addComponent(this.dashboardMenu); rootLayout.addComponent(contentVerticalLayout); - content = new HorizontalLayout(); - contentVerticalLayout.addComponent(content); - content.setStyleName("view-content"); - content.setSizeFull(); + this.content = new HorizontalLayout(); + contentVerticalLayout.addComponent(this.content); + this.content.setStyleName("view-content"); + this.content.setSizeFull(); rootLayout.setExpandRatio(contentVerticalLayout, 1.0f); contentVerticalLayout.setStyleName("main-content"); - contentVerticalLayout.setExpandRatio(content, 1.0F); + contentVerticalLayout.setExpandRatio(this.content, 1.0F); setContent(rootLayout); - final Resource resource = context + final Resource resource = this.context .getResource("classpath:/VAADIN/themes/" + UI.getCurrent().getTheme() + "/layouts/footer.html"); try { final CustomLayout customLayout = new CustomLayout(resource.getInputStream()); @@ -185,7 +192,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { } catch (final IOException ex) { LOG.error("Footer file is missing", ex); } - final Navigator navigator = new Navigator(this, content); + final Navigator navigator = new Navigator(this, this.content); navigator.addViewChangeListener(new ViewChangeListener() { @Override public boolean beforeViewChange(final ViewChangeEvent event) { @@ -194,17 +201,17 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { @Override public void afterViewChange(final ViewChangeEvent event) { - final DashboardMenuItem view = dashboardMenu.getByViewName(event.getViewName()); - dashboardMenu.postViewChange(new PostViewChangeEvent(view)); + final DashboardMenuItem view = HawkbitUI.this.dashboardMenu.getByViewName(event.getViewName()); + HawkbitUI.this.dashboardMenu.postViewChange(new PostViewChangeEvent(view)); if (view == null) { - content.setCaption(null); + HawkbitUI.this.content.setCaption(null); return; } - content.setCaption(view.getDashboardCaptionLong()); + HawkbitUI.this.content.setCaption(view.getDashboardCaptionLong()); } }); - navigator.setErrorView(errorview); + navigator.setErrorView(this.errorview); navigator.addProvider(new ManagementViewProvider()); setNavigator(navigator); navigator.addView(EMPTY_VIEW, new Navigator.EmptyView()); @@ -214,7 +221,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { setLocale(new Locale(locale)); UI.getCurrent().setErrorHandler(new SPUIErrorHandler()); - LOG.info("Current locale of the application is : {}", i18n.getLocale()); + LOG.info("Current locale of the application is : {}", this.i18n.getLocale()); } private Component buildHeader() { @@ -225,7 +232,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { /** * Get Specific Locale. - * + * * @param availableLocalesInApp * as set * @return String as preferred locale @@ -269,20 +276,20 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { @Override public String getViewName(final String viewAndParameters) { - return viewProvider.getViewName(getStartView(viewAndParameters)); + return HawkbitUI.this.viewProvider.getViewName(getStartView(viewAndParameters)); } @Override public View getView(final String viewName) { - return viewProvider.getView(getStartView(viewName)); + return HawkbitUI.this.viewProvider.getView(getStartView(viewName)); } private String getStartView(final String viewName) { - final DashboardMenuItem view = dashboardMenu.getByViewName(viewName); - if ("".equals(viewName) && !dashboardMenu.isAccessibleViewsEmpty()) { - return dashboardMenu.getInitialViewName(); + final DashboardMenuItem view = HawkbitUI.this.dashboardMenu.getByViewName(viewName); + if ("".equals(viewName) && !HawkbitUI.this.dashboardMenu.isAccessibleViewsEmpty()) { + return HawkbitUI.this.dashboardMenu.getInitialViewName(); } - if (view == null || dashboardMenu.isAccessDenied(viewName)) { + if (view == null || HawkbitUI.this.dashboardMenu.isAccessDenied(viewName)) { return " "; } return viewName; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/UploadViewConfirmationWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/UploadViewConfirmationWindowLayout.java index 537a76a70..e32b63951 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/UploadViewConfirmationWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/UploadViewConfirmationWindowLayout.java @@ -44,9 +44,9 @@ import com.vaadin.ui.themes.ValoTheme; /** * Abstract layout of confirm actions window. - * * - * + * + * */ @SpringComponent @ViewScope @@ -84,18 +84,18 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind /* * (non-Javadoc) - * + * * @see org.eclipse.hawkbit.server.ui.common.confirmwindow.layout. * AbstractConfirmationWindowLayout# getConfimrationTabs() */ @Override protected Map getConfimrationTabs() { - final Map tabs = new HashMap(); - if (!artifactUploadState.getDeleteSofwareModules().isEmpty()) { - tabs.put(i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab()); + final Map tabs = new HashMap<>(); + if (!this.artifactUploadState.getDeleteSofwareModules().isEmpty()) { + tabs.put(this.i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab()); } - if (!artifactUploadState.getSelectedDeleteSWModuleTypes().isEmpty()) { - tabs.put(i18n.get("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab()); + if (!this.artifactUploadState.getSelectedDeleteSWModuleTypes().isEmpty()) { + tabs.put(this.i18n.get("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab()); } return tabs; } @@ -105,10 +105,10 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind tab.getConfirmAll().setId(SPUIComponetIdProvider.SW_DELETE_ALL); tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); - tab.getConfirmAll().setCaption(i18n.get("button.delete.all")); + tab.getConfirmAll().setCaption(this.i18n.get("button.delete.all")); tab.getConfirmAll().addClickListener(event -> deleteSMAll(tab)); - tab.getDiscardAll().setCaption(i18n.get("button.discard.all")); + tab.getDiscardAll().setCaption(this.i18n.get("button.discard.all")); tab.getDiscardAll().addClickListener(event -> discardSMAll(tab)); // Add items container to the table. @@ -131,8 +131,8 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) { visibleColumnIds.add(SW_MODULE_NAME_MSG); visibleColumnIds.add(SW_DISCARD_CHGS); - visibleColumnLabels.add(i18n.get("upload.swModuleTable.header")); - visibleColumnLabels.add(i18n.get("header.second.deletetarget.table")); + visibleColumnLabels.add(this.i18n.get("upload.swModuleTable.header")); + visibleColumnLabels.add(this.i18n.get("header.second.deletetarget.table")); } tab.getTable().setVisibleColumns(visibleColumnIds.toArray()); tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0])); @@ -145,7 +145,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind /** * Get SWModule table container. - * + * * @return IndexedContainer */ @SuppressWarnings("unchecked") @@ -153,12 +153,11 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind final IndexedContainer swcontactContainer = new IndexedContainer(); swcontactContainer.addContainerProperty("SWModuleId", String.class, ""); swcontactContainer.addContainerProperty(SW_MODULE_NAME_MSG, String.class, ""); - Item item = null; - for (final Long swModuleID : artifactUploadState.getDeleteSofwareModules().keySet()) { - item = swcontactContainer.addItem(swModuleID); + for (final Long swModuleID : this.artifactUploadState.getDeleteSofwareModules().keySet()) { + final Item item = swcontactContainer.addItem(swModuleID); item.getItemProperty("SWModuleId").setValue(swModuleID.toString()); item.getItemProperty(SW_MODULE_NAME_MSG) - .setValue(artifactUploadState.getDeleteSofwareModules().get(swModuleID)); + .setValue(this.artifactUploadState.getDeleteSofwareModules().get(swModuleID)); } return swcontactContainer; } @@ -166,56 +165,56 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind private void discardSoftwareDelete(final Button.ClickEvent event, final Object itemId, final ConfirmationTab tab) { final Long swmoduleId = (Long) ((Button) event.getComponent()).getData(); - if (null != artifactUploadState.getDeleteSofwareModules() - && !artifactUploadState.getDeleteSofwareModules().isEmpty() - && artifactUploadState.getDeleteSofwareModules().containsKey(swmoduleId)) { - artifactUploadState.getDeleteSofwareModules().remove(swmoduleId); + if (null != this.artifactUploadState.getDeleteSofwareModules() + && !this.artifactUploadState.getDeleteSofwareModules().isEmpty() + && this.artifactUploadState.getDeleteSofwareModules().containsKey(swmoduleId)) { + this.artifactUploadState.getDeleteSofwareModules().remove(swmoduleId); } tab.getTable().getContainerDataSource().removeItem(itemId); final int deleteCount = tab.getTable().size(); if (0 == deleteCount) { removeCurrentTab(tab); - eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE); + this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE); } else { - eventBus.publish(this, UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE); + this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE); } } private void deleteSMAll(final ConfirmationTab tab) { - final Set swmoduleIds = artifactUploadState.getDeleteSofwareModules().keySet(); - softwareManagement.deleteSoftwareModules(swmoduleIds); + final Set swmoduleIds = this.artifactUploadState.getDeleteSofwareModules().keySet(); + this.softwareManagement.deleteSoftwareModules(swmoduleIds); addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE - + i18n.get("message.swModule.deleted", artifactUploadState.getDeleteSofwareModules().size())); + + this.i18n.get("message.swModule.deleted", this.artifactUploadState.getDeleteSofwareModules().size())); /* * Check if any information / files pending to upload for the deleted * software modules. If so, then delete the files from the upload list. */ final List tobeRemoved = new ArrayList<>(); for (final Long id : swmoduleIds) { - final String deleteSoftwareNameVersion = artifactUploadState.getDeleteSofwareModules().get(id); + final String deleteSoftwareNameVersion = this.artifactUploadState.getDeleteSofwareModules().get(id); - for (final CustomFile customFile : artifactUploadState.getFileSelected()) { + for (final CustomFile customFile : this.artifactUploadState.getFileSelected()) { final String swNameVersion = HawkbitCommonUtil.getFormattedNameVersion( customFile.getBaseSoftwareModuleName(), customFile.getBaseSoftwareModuleVersion()); - if (HawkbitCommonUtil.bothSame(deleteSoftwareNameVersion, swNameVersion)) { + if (deleteSoftwareNameVersion != null && deleteSoftwareNameVersion.equals(swNameVersion)) { tobeRemoved.add(customFile); } } } if (!tobeRemoved.isEmpty()) { - artifactUploadState.getFileSelected().removeAll(tobeRemoved); + this.artifactUploadState.getFileSelected().removeAll(tobeRemoved); } - artifactUploadState.getDeleteSofwareModules().clear(); + this.artifactUploadState.getDeleteSofwareModules().clear(); removeCurrentTab(tab); - setActionMessage(i18n.get("message.software.delete.success")); - eventBus.publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFWARE); + setActionMessage(this.i18n.get("message.software.delete.success")); + this.eventBus.publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFWARE); } private void discardSMAll(final ConfirmationTab tab) { removeCurrentTab(tab); - artifactUploadState.getDeleteSofwareModules().clear(); - setActionMessage(i18n.get("message.software.discard.success")); - eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE); + this.artifactUploadState.getDeleteSofwareModules().clear(); + setActionMessage(this.i18n.get("message.software.discard.success")); + this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE); } private ConfirmationTab createSMtypeDeleteConfirmationTab() { @@ -223,10 +222,10 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind tab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_DELETE_SW_MODULE_TYPE); tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); - tab.getConfirmAll().setCaption(i18n.get("button.delete.all")); + tab.getConfirmAll().setCaption(this.i18n.get("button.delete.all")); tab.getConfirmAll().addClickListener(event -> deleteSMtypeAll(tab)); - tab.getDiscardAll().setCaption(i18n.get("button.discard.all")); + tab.getDiscardAll().setCaption(this.i18n.get("button.discard.all")); tab.getDiscardAll().addClickListener(event -> discardSMtypeAll(tab)); // Add items container to the table. @@ -252,8 +251,8 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) { visibleColumnIds.add(SW_MODULE_TYPE_NAME); visibleColumnIds.add(DISCARD); - visibleColumnLabels.add(i18n.get("header.first.delete.swmodule.type.table")); - visibleColumnLabels.add(i18n.get("header.second.delete.swmodule.type.table")); + visibleColumnLabels.add(this.i18n.get("header.first.delete.swmodule.type.table")); + visibleColumnLabels.add(this.i18n.get("header.second.delete.swmodule.type.table")); } tab.getTable().setVisibleColumns(visibleColumnIds.toArray()); @@ -271,7 +270,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind private Container getSWModuleTypeTableContainer() { final IndexedContainer contactContainer = new IndexedContainer(); contactContainer.addContainerProperty(SW_MODULE_TYPE_NAME, String.class, ""); - for (final String swModuleTypeName : artifactUploadState.getSelectedDeleteSWModuleTypes()) { + for (final String swModuleTypeName : this.artifactUploadState.getSelectedDeleteSWModuleTypes()) { final Item saveTblitem = contactContainer.addItem(swModuleTypeName); saveTblitem.getItemProperty(SW_MODULE_TYPE_NAME).setValue(swModuleTypeName); } @@ -280,40 +279,40 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind private void discardSoftwareTypeDelete(final String discardSWModuleType, final Object itemId, final ConfirmationTab tab) { - if (null != artifactUploadState.getSelectedDeleteSWModuleTypes() - && !artifactUploadState.getSelectedDeleteSWModuleTypes().isEmpty() - && artifactUploadState.getSelectedDeleteSWModuleTypes().contains(discardSWModuleType)) { - artifactUploadState.getSelectedDeleteSWModuleTypes().remove(discardSWModuleType); + if (null != this.artifactUploadState.getSelectedDeleteSWModuleTypes() + && !this.artifactUploadState.getSelectedDeleteSWModuleTypes().isEmpty() + && this.artifactUploadState.getSelectedDeleteSWModuleTypes().contains(discardSWModuleType)) { + this.artifactUploadState.getSelectedDeleteSWModuleTypes().remove(discardSWModuleType); } tab.getTable().getContainerDataSource().removeItem(itemId); final int deleteCount = tab.getTable().size(); if (0 == deleteCount) { removeCurrentTab(tab); - eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE_TYPE); + this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE_TYPE); } else { - eventBus.publish(this, UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE_TYPE); + this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE_TYPE); } } private void deleteSMtypeAll(final ConfirmationTab tab) { - final int deleteSWModuleTypeCount = artifactUploadState.getSelectedDeleteSWModuleTypes().size(); - for (final String swModuleTypeName : artifactUploadState.getSelectedDeleteSWModuleTypes()) { + final int deleteSWModuleTypeCount = this.artifactUploadState.getSelectedDeleteSWModuleTypes().size(); + for (final String swModuleTypeName : this.artifactUploadState.getSelectedDeleteSWModuleTypes()) { - softwareManagement - .deleteSoftwareModuleType(softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName)); + this.softwareManagement + .deleteSoftwareModuleType(this.softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName)); } addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE - + i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount })); - artifactUploadState.getSelectedDeleteSWModuleTypes().clear(); + + this.i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount })); + this.artifactUploadState.getSelectedDeleteSWModuleTypes().clear(); removeCurrentTab(tab); - setActionMessage(i18n.get("message.software.type.delete.success")); - eventBus.publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFWARE_TYPE); + setActionMessage(this.i18n.get("message.software.type.delete.success")); + this.eventBus.publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFWARE_TYPE); } private void discardSMtypeAll(final ConfirmationTab tab) { removeCurrentTab(tab); - artifactUploadState.getSelectedDeleteSWModuleTypes().clear(); - setActionMessage(i18n.get("message.software.type.discard.success")); - eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE_TYPE); + this.artifactUploadState.getSelectedDeleteSWModuleTypes().clear(); + setActionMessage(this.i18n.get("message.software.type.discard.success")); + this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE_TYPE); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadState.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadState.java index d653bb371..c29a4e287 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadState.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadState.java @@ -38,13 +38,13 @@ public class ArtifactUploadState implements Serializable { private final Map deleteSofwareModules = new HashMap<>(); - private final Set fileSelected = new HashSet(); + private final Set fileSelected = new HashSet<>(); private Long selectedBaseSwModuleId; private SoftwareModule selectedBaseSoftwareModule; - private final Map baseSwModuleList = new HashMap(); + private final Map baseSwModuleList = new HashMap<>(); private Set selectedSoftwareModules = Collections.emptySet(); @@ -60,25 +60,25 @@ public class ArtifactUploadState implements Serializable { /** * Set software. - * + * * @return */ public SoftwareModuleFilters getSoftwareModuleFilters() { - return softwareModuleFilters; + return this.softwareModuleFilters; } /** * @return the selectedSofwareModules */ public Map getDeleteSofwareModules() { - return deleteSofwareModules; + return this.deleteSofwareModules; } /** * @return the fileSelected */ public Set getFileSelected() { - return fileSelected; + return this.fileSelected; } /** @@ -116,14 +116,14 @@ public class ArtifactUploadState implements Serializable { * @return the baseSwModuleList */ public Map getBaseSwModuleList() { - return baseSwModuleList; + return this.baseSwModuleList; } /** * @return the selectedSoftwareModules */ public Set getSelectedSoftwareModules() { - return selectedSoftwareModules; + return this.selectedSoftwareModules; } /** @@ -138,7 +138,7 @@ public class ArtifactUploadState implements Serializable { * @return the swTypeFilterClosed */ public boolean isSwTypeFilterClosed() { - return swTypeFilterClosed; + return this.swTypeFilterClosed; } /** @@ -153,7 +153,7 @@ public class ArtifactUploadState implements Serializable { * @return the isSwModuleTableMaximized */ public boolean isSwModuleTableMaximized() { - return isSwModuleTableMaximized; + return this.isSwModuleTableMaximized; } /** @@ -165,14 +165,14 @@ public class ArtifactUploadState implements Serializable { } public Set getSelectedDeleteSWModuleTypes() { - return selectedDeleteSWModuleTypes; + return this.selectedDeleteSWModuleTypes; } /** * @return the isArtifactDetailsMaximized */ public boolean isArtifactDetailsMaximized() { - return isArtifactDetailsMaximized; + return this.isArtifactDetailsMaximized; } /** @@ -187,7 +187,7 @@ public class ArtifactUploadState implements Serializable { * @return the noDataAvilableSoftwareModule */ public boolean isNoDataAvilableSoftwareModule() { - return noDataAvilableSoftwareModule; + return this.noDataAvilableSoftwareModule; } /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/CustomFile.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/CustomFile.java index ff350511a..fbca33bb0 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/CustomFile.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/CustomFile.java @@ -10,8 +10,6 @@ package org.eclipse.hawkbit.ui.artifacts.state; import java.io.Serializable; -import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; - /** * Custom file to hold details of uploaded file. * @@ -98,7 +96,7 @@ public class CustomFile implements Serializable { } public String getBaseSoftwareModuleName() { - return baseSoftwareModuleName; + return this.baseSoftwareModuleName; } public void setBaseSoftwareModuleName(final String baseSoftwareModuleName) { @@ -106,7 +104,7 @@ public class CustomFile implements Serializable { } public String getBaseSoftwareModuleVersion() { - return baseSoftwareModuleVersion; + return this.baseSoftwareModuleVersion; } public void setBaseSoftwareModuleVersion(final String baseSoftwareModuleVersion) { @@ -114,11 +112,11 @@ public class CustomFile implements Serializable { } public String getFileName() { - return fileName; + return this.fileName; } public long getFileSize() { - return fileSize; + return this.fileSize; } public void setFileSize(final long fileSize) { @@ -126,7 +124,7 @@ public class CustomFile implements Serializable { } public String getFilePath() { - return filePath; + return this.filePath; } public void setFilePath(final String filePath) { @@ -134,7 +132,7 @@ public class CustomFile implements Serializable { } public String getMimeType() { - return mimeType; + return this.mimeType; } /** @@ -142,7 +140,7 @@ public class CustomFile implements Serializable { * @return the isValid */ public Boolean getIsValid() { - return isValid; + return this.isValid; } /** @@ -165,39 +163,54 @@ public class CustomFile implements Serializable { * @return the failureReason */ public String getFailureReason() { - return failureReason; + return this.failureReason; } - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ @Override - public int hashCode() { // NOSONAR - as this is generated + public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + (fileName == null ? 0 : fileName.hashCode()); + result = prime * result + ((this.baseSoftwareModuleName == null) ? 0 : this.baseSoftwareModuleName.hashCode()); + result = prime * result + + ((this.baseSoftwareModuleVersion == null) ? 0 : this.baseSoftwareModuleVersion.hashCode()); + result = prime * result + ((this.fileName == null) ? 0 : this.fileName.hashCode()); return result; } - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ @Override public boolean equals(final Object obj) { if (this == obj) { return true; } - if (!(obj instanceof CustomFile)) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { return false; } final CustomFile other = (CustomFile) obj; - return HawkbitCommonUtil.bothSame(fileName, other.fileName) - && HawkbitCommonUtil.bothSame(baseSoftwareModuleName, other.baseSoftwareModuleName) - && HawkbitCommonUtil.bothSame(baseSoftwareModuleVersion, other.baseSoftwareModuleVersion); + if (this.baseSoftwareModuleName == null) { + if (other.baseSoftwareModuleName != null) { + return false; + } + } else if (!this.baseSoftwareModuleName.equals(other.baseSoftwareModuleName)) { + return false; + } + if (this.baseSoftwareModuleVersion == null) { + if (other.baseSoftwareModuleVersion != null) { + return false; + } + } else if (!this.baseSoftwareModuleVersion.equals(other.baseSoftwareModuleVersion)) { + return false; + } + if (this.fileName == null) { + if (other.fileName != null) { + return false; + } + } else if (!this.fileName.equals(other.fileName)) { + return false; + } + return true; } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterSingleButtonClick.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterSingleButtonClick.java index ccfbc922c..230b148b1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterSingleButtonClick.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterSingleButtonClick.java @@ -8,8 +8,6 @@ */ package org.eclipse.hawkbit.ui.common.filterlayout; -import java.util.Optional; - import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import com.vaadin.ui.Button; @@ -17,20 +15,20 @@ import com.vaadin.ui.Button.ClickEvent; /** * Abstract Single button click behaviour of filter buttons layout. - * * * - * + * + * */ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButtonClickBehaviour { private static final long serialVersionUID = 478874092615793581L; - private Optional