Merge remote-tracking branch 'refs/remotes/eclipse/master'
This commit is contained in:
@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.simulator;
|
|||||||
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.simulator.DeviceSimulatorUpdater.UpdaterCallback;
|
|
||||||
import org.eclipse.hawkbit.simulator.http.ControllerResource;
|
import org.eclipse.hawkbit.simulator.http.ControllerResource;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -82,28 +81,27 @@ public class DDISimulatedDevice extends AbstractSimulatedDevice {
|
|||||||
final String deploymentJson = controllerResource.getDeployment(getTenant(), getId(), actionId);
|
final String deploymentJson = controllerResource.getDeployment(getTenant(), getId(), actionId);
|
||||||
final String swVersion = JsonPath.parse(deploymentJson).read("deployment.chunks[0].version");
|
final String swVersion = JsonPath.parse(deploymentJson).read("deployment.chunks[0].version");
|
||||||
currentActionId = actionId;
|
currentActionId = actionId;
|
||||||
deviceUpdater.startUpdate(getTenant(), getId(), actionId, swVersion, new UpdaterCallback() {
|
deviceUpdater.startUpdate(getTenant(), getId(), actionId, swVersion, (device, actionId1) -> {
|
||||||
@Override
|
switch (device.getResponseStatus()) {
|
||||||
public void updateFinished(final AbstractSimulatedDevice device, final Long actionId) {
|
case SUCCESSFUL:
|
||||||
switch (device.getResponseStatus()) {
|
controllerResource.postSuccessFeedback(getTenant(), getId(),
|
||||||
case SUCCESSFUL:
|
actionId1);
|
||||||
controllerResource.postSuccessFeedback(getTenant(), getId(), actionId);
|
break;
|
||||||
break;
|
case ERROR:
|
||||||
case ERROR:
|
controllerResource.postErrorFeedback(getTenant(), getId(),
|
||||||
controllerResource.postErrorFeedback(getTenant(), getId(), actionId);
|
actionId1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("simulated device has an unknown response status + "
|
throw new IllegalStateException(
|
||||||
+ device.getResponseStatus());
|
"simulated device has an unknown response status + " + device.getResponseStatus());
|
||||||
}
|
|
||||||
currentActionId = null;
|
|
||||||
}
|
}
|
||||||
|
currentActionId = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (final PathNotFoundException e) {
|
} catch (final PathNotFoundException e) {
|
||||||
// href might not be in the json response, so ignore
|
// href might not be in the json response, so ignore
|
||||||
// exception here.
|
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.simulator;
|
package org.eclipse.hawkbit.simulator;
|
||||||
|
|
||||||
|
import java.security.SecureRandom;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
@@ -66,7 +67,7 @@ public class DeviceSimulatorUpdater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final class DeviceSimulatorUpdateThread implements Runnable {
|
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 AbstractSimulatedDevice device;
|
||||||
private final SpSenderService spSenderService;
|
private final SpSenderService spSenderService;
|
||||||
@@ -74,9 +75,8 @@ public class DeviceSimulatorUpdater {
|
|||||||
private final EventBus eventbus;
|
private final EventBus eventbus;
|
||||||
private final UpdaterCallback callback;
|
private final UpdaterCallback callback;
|
||||||
|
|
||||||
private DeviceSimulatorUpdateThread(final AbstractSimulatedDevice device,
|
private DeviceSimulatorUpdateThread(final AbstractSimulatedDevice device, final SpSenderService spSenderService,
|
||||||
final SpSenderService spSenderService, final long actionId, final EventBus eventbus,
|
final long actionId, final EventBus eventbus, final UpdaterCallback callback) {
|
||||||
final UpdaterCallback callback) {
|
|
||||||
this.device = device;
|
this.device = device;
|
||||||
this.spSenderService = spSenderService;
|
this.spSenderService = spSenderService;
|
||||||
this.actionId = actionId;
|
this.actionId = actionId;
|
||||||
@@ -89,8 +89,9 @@ public class DeviceSimulatorUpdater {
|
|||||||
final double newProgress = device.getProgress() + 0.2;
|
final double newProgress = device.getProgress() + 0.2;
|
||||||
device.setProgress(newProgress);
|
device.setProgress(newProgress);
|
||||||
if (newProgress < 1.0) {
|
if (newProgress < 1.0) {
|
||||||
threadPool.schedule(new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus,
|
threadPool.schedule(
|
||||||
callback), rndSleep.nextInt(3000), TimeUnit.MILLISECONDS);
|
new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus, callback),
|
||||||
|
rndSleep.nextInt(3000), TimeUnit.MILLISECONDS);
|
||||||
} else {
|
} else {
|
||||||
callback.updateFinished(device, actionId);
|
callback.updateFinished(device, actionId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.simulator.event.NextPollCounterUpdate;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -31,6 +33,8 @@ import com.google.common.eventbus.EventBus;
|
|||||||
@Component
|
@Component
|
||||||
public class NextPollTimeController {
|
public class NextPollTimeController {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(NextPollTimeController.class);
|
||||||
|
|
||||||
private static final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
|
private static final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
|
||||||
private static final ExecutorService pollService = Executors.newFixedThreadPool(1);
|
private static final ExecutorService pollService = Executors.newFixedThreadPool(1);
|
||||||
|
|
||||||
@@ -58,14 +62,9 @@ public class NextPollTimeController {
|
|||||||
if (nextCounter < 0) {
|
if (nextCounter < 0) {
|
||||||
if (device instanceof DDISimulatedDevice) {
|
if (device instanceof DDISimulatedDevice) {
|
||||||
try {
|
try {
|
||||||
pollService.submit(new Runnable() {
|
pollService.submit(() -> ((DDISimulatedDevice) device).poll());
|
||||||
@Override
|
} catch (final IllegalStateException e) {
|
||||||
public void run() {
|
LOGGER.trace("Device could not be polled", e);
|
||||||
((DDISimulatedDevice) device).poll();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (final Exception e) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
nextCounter = ((DDISimulatedDevice) device).getPollDelaySec();
|
nextCounter = ((DDISimulatedDevice) device).getPollDelaySec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.report.model;
|
package org.eclipse.hawkbit.report.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@@ -20,7 +21,9 @@ import java.util.stream.Stream;
|
|||||||
* @param <T>
|
* @param <T>
|
||||||
* the type of the report series item
|
* the type of the report series item
|
||||||
*/
|
*/
|
||||||
public class DataReportSeries<T extends Object> extends AbstractReportSeries {
|
public class DataReportSeries<T extends Serializable> extends AbstractReportSeries {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final List<DataReportSeriesItem<T>> data = new ArrayList<>();
|
private final List<DataReportSeriesItem<T>> data = new ArrayList<>();
|
||||||
|
|
||||||
@@ -46,7 +49,7 @@ public class DataReportSeries<T extends Object> extends AbstractReportSeries {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setData(final List<DataReportSeriesItem<T>> values) {
|
private void setData(final List<DataReportSeriesItem<T>> values) {
|
||||||
this.data.clear();
|
data.clear();
|
||||||
data.addAll(values);
|
data.addAll(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.report.model;
|
package org.eclipse.hawkbit.report.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An data report series item which contains a type and a value.
|
* An data report series item which contains a type and a value.
|
||||||
*
|
*
|
||||||
@@ -16,8 +18,9 @@ package org.eclipse.hawkbit.report.model;
|
|||||||
* @param <T>
|
* @param <T>
|
||||||
* the type of the report series item
|
* the type of the report series item
|
||||||
*/
|
*/
|
||||||
public class DataReportSeriesItem<T extends Object> {
|
public class DataReportSeriesItem<T extends Serializable> implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private final T type;
|
private final T type;
|
||||||
private final Number data;
|
private final Number data;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.report.model;
|
package org.eclipse.hawkbit.report.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A double data series which contains an inner and an outer series ideal for
|
* A double data series which contains an inner and an outer series ideal for
|
||||||
* showing donut charts.
|
* showing donut charts.
|
||||||
@@ -17,7 +19,7 @@ package org.eclipse.hawkbit.report.model;
|
|||||||
* @param <T>
|
* @param <T>
|
||||||
* The type parameter for the report series data
|
* The type parameter for the report series data
|
||||||
*/
|
*/
|
||||||
public class InnerOuterDataReportSeries<T> {
|
public class InnerOuterDataReportSeries<T extends Serializable> {
|
||||||
|
|
||||||
private final DataReportSeries<T> innerSeries;
|
private final DataReportSeries<T> innerSeries;
|
||||||
private final DataReportSeries<T> outerSeries;
|
private final DataReportSeries<T> outerSeries;
|
||||||
|
|||||||
@@ -22,10 +22,6 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.EntityManager;
|
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 javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagAssigmentResultEvent;
|
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.model.Target;
|
||||||
import org.eclipse.hawkbit.repository.specifications.DistributionSetSpecification;
|
import org.eclipse.hawkbit.repository.specifications.DistributionSetSpecification;
|
||||||
import org.eclipse.hawkbit.repository.specifications.DistributionSetTypeSpecification;
|
import org.eclipse.hawkbit.repository.specifications.DistributionSetTypeSpecification;
|
||||||
|
import org.eclipse.hawkbit.repository.specifications.SpecificationsBuilder;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageImpl;
|
import org.springframework.data.domain.PageImpl;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.data.jpa.domain.Specifications;
|
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -203,7 +199,8 @@ public class DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final DistributionSetTagAssigmentResult resultAssignment = result;
|
final DistributionSetTagAssigmentResult resultAssignment = result;
|
||||||
afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment)));
|
afterCommit
|
||||||
|
.afterCommit(() -> eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment)));
|
||||||
|
|
||||||
// no reason to persist the tag
|
// no reason to persist the tag
|
||||||
entityManager.detach(myTag);
|
entityManager.detach(myTag);
|
||||||
@@ -263,7 +260,7 @@ public class DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
public void deleteDistributionSet(@NotNull final DistributionSet set) {
|
public void deleteDistributionSet(@NotNull final DistributionSet set) {
|
||||||
this.deleteDistributionSet(set.getId());
|
deleteDistributionSet(set.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -321,14 +318,10 @@ public class DistributionSetManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public DistributionSet createDistributionSet(@NotNull final DistributionSet dSet) {
|
public DistributionSet createDistributionSet(@NotNull final DistributionSet dSet) {
|
||||||
prepareDsSave(dSet);
|
prepareDsSave(dSet);
|
||||||
|
|
||||||
if (dSet.getType() == null) {
|
if (dSet.getType() == null) {
|
||||||
dSet.setType(systemManagement.getTenantMetadata().getDefaultDsType());
|
dSet.setType(systemManagement.getTenantMetadata().getDefaultDsType());
|
||||||
}
|
}
|
||||||
|
return distributionSetRepository.save(dSet);
|
||||||
final DistributionSet result = distributionSetRepository.save(dSet);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareDsSave(final DistributionSet dSet) {
|
private void prepareDsSave(final DistributionSet dSet) {
|
||||||
@@ -400,7 +393,7 @@ public class DistributionSetManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
public DistributionSet unassignSoftwareModule(@NotNull final DistributionSet ds,
|
public DistributionSet unassignSoftwareModule(@NotNull final DistributionSet ds,
|
||||||
final SoftwareModule softwareModule) {
|
final SoftwareModule softwareModule) {
|
||||||
final Set<SoftwareModule> softwareModules = new HashSet<SoftwareModule>();
|
final Set<SoftwareModule> softwareModules = new HashSet<>();
|
||||||
softwareModules.add(softwareModule);
|
softwareModules.add(softwareModule);
|
||||||
ds.removeModule(softwareModule);
|
ds.removeModule(softwareModule);
|
||||||
checkDistributionSetSoftwareModulesIsAllowedToModify(ds, softwareModules);
|
checkDistributionSetSoftwareModulesIsAllowedToModify(ds, softwareModules);
|
||||||
@@ -491,20 +484,11 @@ public class DistributionSetManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
private DistributionSet findDistributionSetsByFiltersAndInstalledOrAssignedTarget(
|
private DistributionSet findDistributionSetsByFiltersAndInstalledOrAssignedTarget(
|
||||||
final DistributionSetFilter distributionSetFilter) {
|
final DistributionSetFilter distributionSetFilter) {
|
||||||
|
|
||||||
final List<Specification<DistributionSet>> specList = buildDistributionSetSpecifications(distributionSetFilter);
|
final List<Specification<DistributionSet>> specList = buildDistributionSetSpecifications(distributionSetFilter);
|
||||||
|
if (specList == null || specList.isEmpty()) {
|
||||||
Specifications<DistributionSet> specs = null;
|
return null;
|
||||||
if (!specList.isEmpty()) {
|
|
||||||
specs = Specifications.where(specList.get(0));
|
|
||||||
}
|
}
|
||||||
if (specList.size() > 1) {
|
return distributionSetRepository.findOne(SpecificationsBuilder.combineWithAnd(specList));
|
||||||
specList.remove(0);
|
|
||||||
for (final Specification<DistributionSet> s : specList) {
|
|
||||||
specs = specs.and(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return distributionSetRepository.findOne(specs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -531,7 +515,7 @@ public class DistributionSetManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Page<DistributionSet> findDistributionSetsAll(@NotNull final Pageable pageReq, final Boolean deleted,
|
public Page<DistributionSet> findDistributionSetsAll(@NotNull final Pageable pageReq, final Boolean deleted,
|
||||||
final Boolean complete) {
|
final Boolean complete) {
|
||||||
final List<Specification<DistributionSet>> specList = new ArrayList<Specification<DistributionSet>>();
|
final List<Specification<DistributionSet>> specList = new ArrayList<>();
|
||||||
|
|
||||||
if (deleted != null) {
|
if (deleted != null) {
|
||||||
final Specification<DistributionSet> spec = DistributionSetSpecification.isDeleted(deleted);
|
final Specification<DistributionSet> spec = DistributionSetSpecification.isDeleted(deleted);
|
||||||
@@ -563,7 +547,7 @@ public class DistributionSetManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Page<DistributionSet> findDistributionSetsAll(@NotNull final Specification<DistributionSet> spec,
|
public Page<DistributionSet> findDistributionSetsAll(@NotNull final Specification<DistributionSet> spec,
|
||||||
@NotNull final Pageable pageReq, final Boolean deleted) {
|
@NotNull final Pageable pageReq, final Boolean deleted) {
|
||||||
final List<Specification<DistributionSet>> specList = new ArrayList<Specification<DistributionSet>>();
|
final List<Specification<DistributionSet>> specList = new ArrayList<>();
|
||||||
if (deleted != null) {
|
if (deleted != null) {
|
||||||
specList.add(DistributionSetSpecification.isDeleted(deleted));
|
specList.add(DistributionSetSpecification.isDeleted(deleted));
|
||||||
}
|
}
|
||||||
@@ -635,17 +619,6 @@ public class DistributionSetManagement {
|
|||||||
return new PageImpl<>(resultSet, pageable, findDistributionSetsByFilters.getTotalElements());
|
return new PageImpl<>(resultSet, pageable, findDistributionSetsByFilters.getTotalElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long countDistributionSetByCriteriaAPI(@NotEmpty final List<Specification<DistributionSet>> specList) {
|
|
||||||
Specifications<DistributionSet> specs = Specifications.where(specList.get(0));
|
|
||||||
if (specList.size() > 1) {
|
|
||||||
for (final Specification<DistributionSet> s : specList.subList(1, specList.size())) {
|
|
||||||
specs = specs.and(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return distributionSetRepository.count(specs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find distribution set by name and version.
|
* Find distribution set by name and version.
|
||||||
*
|
*
|
||||||
@@ -689,12 +662,12 @@ public class DistributionSetManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Long countDistributionSetsAll() {
|
public Long countDistributionSetsAll() {
|
||||||
|
|
||||||
final List<Specification<DistributionSet>> specList = new ArrayList<Specification<DistributionSet>>();
|
final List<Specification<DistributionSet>> specList = new ArrayList<>();
|
||||||
|
|
||||||
final Specification<DistributionSet> spec = DistributionSetSpecification.isDeleted(Boolean.FALSE);
|
final Specification<DistributionSet> spec = DistributionSetSpecification.isDeleted(Boolean.FALSE);
|
||||||
specList.add(spec);
|
specList.add(spec);
|
||||||
|
|
||||||
return countDistributionSetByCriteriaAPI(specList);
|
return distributionSetRepository.count(SpecificationsBuilder.combineWithAnd(specList));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -869,17 +842,10 @@ public class DistributionSetManagement {
|
|||||||
public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(
|
public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(
|
||||||
@NotNull final Long distributionSetId, @NotNull final Pageable pageable) {
|
@NotNull final Long distributionSetId, @NotNull final Pageable pageable) {
|
||||||
|
|
||||||
return distributionSetMetadataRepository.findAll(new Specification<DistributionSetMetadata>() {
|
return distributionSetMetadataRepository.findAll(
|
||||||
@Override
|
(Specification<DistributionSetMetadata>) (root, query, cb) -> cb.equal(
|
||||||
public Predicate toPredicate(final Root<DistributionSetMetadata> root, final CriteriaQuery<?> query,
|
root.get(DistributionSetMetadata_.distributionSet).get(DistributionSet_.id), distributionSetId),
|
||||||
final CriteriaBuilder cb) {
|
pageable);
|
||||||
|
|
||||||
final Predicate predicate = cb.equal(
|
|
||||||
root.get(DistributionSetMetadata_.distributionSet).get(DistributionSet_.id), distributionSetId);
|
|
||||||
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
}, pageable);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -899,14 +865,14 @@ public class DistributionSetManagement {
|
|||||||
public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(
|
public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(
|
||||||
@NotNull final Long distributionSetId, @NotNull final Specification<DistributionSetMetadata> spec,
|
@NotNull final Long distributionSetId, @NotNull final Specification<DistributionSetMetadata> spec,
|
||||||
@NotNull final Pageable pageable) {
|
@NotNull final Pageable pageable) {
|
||||||
return distributionSetMetadataRepository.findAll(new Specification<DistributionSetMetadata>() {
|
return distributionSetMetadataRepository
|
||||||
@Override
|
.findAll(
|
||||||
public Predicate toPredicate(final Root<DistributionSetMetadata> root, final CriteriaQuery<?> query,
|
(Specification<DistributionSetMetadata>) (root, query,
|
||||||
final CriteriaBuilder cb) {
|
cb) -> cb.and(
|
||||||
return cb.and(cb.equal(root.get(DistributionSetMetadata_.distributionSet).get(DistributionSet_.id),
|
cb.equal(root.get(DistributionSetMetadata_.distributionSet)
|
||||||
distributionSetId), spec.toPredicate(root, query, cb));
|
.get(DistributionSet_.id), distributionSetId),
|
||||||
}
|
spec.toPredicate(root, query, cb)),
|
||||||
}, pageable);
|
pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -969,9 +935,9 @@ public class DistributionSetManagement {
|
|||||||
|
|
||||||
private List<Specification<DistributionSet>> buildDistributionSetSpecifications(
|
private List<Specification<DistributionSet>> buildDistributionSetSpecifications(
|
||||||
final DistributionSetFilter distributionSetFilter) {
|
final DistributionSetFilter distributionSetFilter) {
|
||||||
final List<Specification<DistributionSet>> specList = new ArrayList<Specification<DistributionSet>>();
|
final List<Specification<DistributionSet>> specList = new ArrayList<>();
|
||||||
|
|
||||||
Specification<DistributionSet> spec = null;
|
Specification<DistributionSet> spec;
|
||||||
|
|
||||||
if (null != distributionSetFilter.getIsComplete()) {
|
if (null != distributionSetFilter.getIsComplete()) {
|
||||||
spec = DistributionSetSpecification.isCompleted(distributionSetFilter.getIsComplete());
|
spec = DistributionSetSpecification.isCompleted(distributionSetFilter.getIsComplete());
|
||||||
@@ -1053,21 +1019,12 @@ public class DistributionSetManagement {
|
|||||||
*/
|
*/
|
||||||
private Page<DistributionSet> findByCriteriaAPI(@NotNull final Pageable pageable,
|
private Page<DistributionSet> findByCriteriaAPI(@NotNull final Pageable pageable,
|
||||||
final List<Specification<DistributionSet>> specList) {
|
final List<Specification<DistributionSet>> specList) {
|
||||||
Specifications<DistributionSet> specs = null;
|
|
||||||
if (!specList.isEmpty()) {
|
if (specList == null || specList.isEmpty()) {
|
||||||
specs = Specifications.where(specList.get(0));
|
return distributionSetRepository.findAll(pageable);
|
||||||
}
|
|
||||||
if (specList.size() > 1) {
|
|
||||||
for (final Specification<DistributionSet> s : specList.subList(1, specList.size())) {
|
|
||||||
specs = specs.and(s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (specs == null) {
|
return distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable);
|
||||||
return distributionSetRepository.findAll(pageable);
|
|
||||||
} else {
|
|
||||||
return distributionSetRepository.findAll(specs, pageable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAndThrowAlreadyIfDistributionSetMetadataExists(final DsMetadataCompositeKey metadataId) {
|
private void checkAndThrowAlreadyIfDistributionSetMetadataExists(final DsMetadataCompositeKey metadataId) {
|
||||||
|
|||||||
@@ -213,8 +213,8 @@ public class ReportManagement {
|
|||||||
* count
|
* count
|
||||||
*/
|
*/
|
||||||
@Cacheable("targetsCreatedOverPeriod")
|
@Cacheable("targetsCreatedOverPeriod")
|
||||||
public <T> DataReportSeries<T> targetsCreatedOverPeriod(final DateType<T> dateType, final LocalDateTime from,
|
public <T extends Serializable> DataReportSeries<T> targetsCreatedOverPeriod(final DateType<T> dateType,
|
||||||
final LocalDateTime to) {
|
final LocalDateTime from, final LocalDateTime to) {
|
||||||
final Query createNativeQuery = entityManager
|
final Query createNativeQuery = entityManager
|
||||||
.createNativeQuery(getTargetsCreatedQueryTemplate(dateType, from, to));
|
.createNativeQuery(getTargetsCreatedQueryTemplate(dateType, from, to));
|
||||||
final List<Object[]> resultList = createNativeQuery.getResultList();
|
final List<Object[]> resultList = createNativeQuery.getResultList();
|
||||||
@@ -223,8 +223,7 @@ public class ReportManagement {
|
|||||||
.map(r -> new DataReportSeriesItem<>(dateType.format((String) r[0]), ((Number) r[1]).longValue()))
|
.map(r -> new DataReportSeriesItem<>(dateType.format((String) r[0]), ((Number) r[1]).longValue()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
final DataReportSeries<T> report = new DataReportSeries<>("CreatedTargets", reportItems);
|
return new DataReportSeries<>("CreatedTargets", reportItems);
|
||||||
return report;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTargetsCreatedQueryTemplate(final DateType<?> dateType, final LocalDateTime from,
|
private String getTargetsCreatedQueryTemplate(final DateType<?> dateType, final LocalDateTime from,
|
||||||
@@ -276,8 +275,8 @@ public class ReportManagement {
|
|||||||
* count
|
* count
|
||||||
*/
|
*/
|
||||||
@Cacheable("feedbackReceivedOverTime")
|
@Cacheable("feedbackReceivedOverTime")
|
||||||
public <T> DataReportSeries<T> feedbackReceivedOverTime(final DateType<T> dateType, final LocalDateTime from,
|
public <T extends Serializable> DataReportSeries<T> feedbackReceivedOverTime(final DateType<T> dateType,
|
||||||
final LocalDateTime to) {
|
final LocalDateTime from, final LocalDateTime to) {
|
||||||
final Query createNativeQuery = entityManager
|
final Query createNativeQuery = entityManager
|
||||||
.createNativeQuery(getFeedbackReceivedQueryTemplate(dateType, from, to));
|
.createNativeQuery(getFeedbackReceivedQueryTemplate(dateType, from, to));
|
||||||
final List<Object[]> resultList = createNativeQuery.getResultList();
|
final List<Object[]> resultList = createNativeQuery.getResultList();
|
||||||
@@ -286,8 +285,7 @@ public class ReportManagement {
|
|||||||
.map(r -> new DataReportSeriesItem<>(dateType.format((String) r[0]), ((Number) r[1]).longValue()))
|
.map(r -> new DataReportSeriesItem<>(dateType.format((String) r[0]), ((Number) r[1]).longValue()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
final DataReportSeries<T> report = new DataReportSeries<>("FeedbackRecieved", reportItems);
|
return new DataReportSeries<>("FeedbackRecieved", reportItems);
|
||||||
return report;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -433,7 +431,7 @@ public class ReportManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DataReportSeriesItem<String> toItem() {
|
private DataReportSeriesItem<String> toItem() {
|
||||||
return new DataReportSeriesItem<String>(name.getName() != null ? name.getName() : "misc", count);
|
return new DataReportSeriesItem<>(name.getName() != null ? name.getName() : "misc", count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
|||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule_;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule_;
|
||||||
import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey;
|
import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey;
|
||||||
import org.eclipse.hawkbit.repository.specifications.SoftwareModuleSpecification;
|
import org.eclipse.hawkbit.repository.specifications.SoftwareModuleSpecification;
|
||||||
|
import org.eclipse.hawkbit.repository.specifications.SpecificationsBuilder;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.AuditorAware;
|
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.Slice;
|
||||||
import org.springframework.data.domain.SliceImpl;
|
import org.springframework.data.domain.SliceImpl;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.data.jpa.domain.Specifications;
|
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -209,7 +209,7 @@ public class SoftwareManagement {
|
|||||||
public Slice<SoftwareModule> findSoftwareModulesByType(@NotNull final Pageable pageable,
|
public Slice<SoftwareModule> findSoftwareModulesByType(@NotNull final Pageable pageable,
|
||||||
@NotNull final SoftwareModuleType type) {
|
@NotNull final SoftwareModuleType type) {
|
||||||
|
|
||||||
final List<Specification<SoftwareModule>> specList = new ArrayList<Specification<SoftwareModule>>();
|
final List<Specification<SoftwareModule>> specList = new ArrayList<>();
|
||||||
|
|
||||||
Specification<SoftwareModule> spec = SoftwareModuleSpecification.equalType(type);
|
Specification<SoftwareModule> spec = SoftwareModuleSpecification.equalType(type);
|
||||||
specList.add(spec);
|
specList.add(spec);
|
||||||
@@ -230,7 +230,7 @@ public class SoftwareManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Long countSoftwareModulesByType(@NotNull final SoftwareModuleType type) {
|
public Long countSoftwareModulesByType(@NotNull final SoftwareModuleType type) {
|
||||||
|
|
||||||
final List<Specification<SoftwareModule>> specList = new ArrayList<Specification<SoftwareModule>>();
|
final List<Specification<SoftwareModule>> specList = new ArrayList<>();
|
||||||
|
|
||||||
Specification<SoftwareModule> spec = SoftwareModuleSpecification.equalType(type);
|
Specification<SoftwareModule> spec = SoftwareModuleSpecification.equalType(type);
|
||||||
specList.add(spec);
|
specList.add(spec);
|
||||||
@@ -291,26 +291,12 @@ public class SoftwareManagement {
|
|||||||
|
|
||||||
private Slice<SoftwareModule> findSwModuleByCriteriaAPI(@NotNull final Pageable pageable,
|
private Slice<SoftwareModule> findSwModuleByCriteriaAPI(@NotNull final Pageable pageable,
|
||||||
@NotEmpty final List<Specification<SoftwareModule>> specList) {
|
@NotEmpty final List<Specification<SoftwareModule>> specList) {
|
||||||
|
return criteriaNoCountDao.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable,
|
||||||
Specifications<SoftwareModule> specs = Specifications.where(specList.get(0));
|
SoftwareModule.class);
|
||||||
if (specList.size() > 1) {
|
|
||||||
for (final Specification<SoftwareModule> s : specList.subList(1, specList.size())) {
|
|
||||||
specs = specs.and(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return criteriaNoCountDao.findAll(specs, pageable, SoftwareModule.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long countSwModuleByCriteriaAPI(@NotEmpty final List<Specification<SoftwareModule>> specList) {
|
private Long countSwModuleByCriteriaAPI(@NotEmpty final List<Specification<SoftwareModule>> specList) {
|
||||||
Specifications<SoftwareModule> specs = Specifications.where(specList.get(0));
|
return softwareModuleRepository.count(SpecificationsBuilder.combineWithAnd(specList));
|
||||||
if (specList.size() > 1) {
|
|
||||||
for (final Specification<SoftwareModule> s : specList.subList(1, specList.size())) {
|
|
||||||
specs = specs.and(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return softwareModuleRepository.count(specs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteGridFsArtifacts(final SoftwareModule swModule) {
|
private void deleteGridFsArtifacts(final SoftwareModule swModule) {
|
||||||
@@ -366,20 +352,16 @@ public class SoftwareManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Slice<SoftwareModule> findSoftwareModulesAll(@NotNull final Pageable pageable) {
|
public Slice<SoftwareModule> findSoftwareModulesAll(@NotNull final Pageable pageable) {
|
||||||
|
|
||||||
final List<Specification<SoftwareModule>> specList = new ArrayList<Specification<SoftwareModule>>();
|
final List<Specification<SoftwareModule>> specList = new ArrayList<>();
|
||||||
|
|
||||||
Specification<SoftwareModule> spec = SoftwareModuleSpecification.isDeletedFalse();
|
Specification<SoftwareModule> spec = SoftwareModuleSpecification.isDeletedFalse();
|
||||||
specList.add(spec);
|
specList.add(spec);
|
||||||
|
|
||||||
spec = new Specification<SoftwareModule>() {
|
spec = (root, query, cb) -> {
|
||||||
@Override
|
if (!query.getResultType().isAssignableFrom(Long.class)) {
|
||||||
public Predicate toPredicate(final Root<SoftwareModule> root, final CriteriaQuery<?> query,
|
root.fetch(SoftwareModule_.type);
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
if (!query.getResultType().isAssignableFrom(Long.class)) {
|
|
||||||
root.fetch(SoftwareModule_.type);
|
|
||||||
}
|
|
||||||
return cb.conjunction();
|
|
||||||
}
|
}
|
||||||
|
return cb.conjunction();
|
||||||
};
|
};
|
||||||
|
|
||||||
specList.add(spec);
|
specList.add(spec);
|
||||||
@@ -396,7 +378,7 @@ public class SoftwareManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Long countSoftwareModulesAll() {
|
public Long countSoftwareModulesAll() {
|
||||||
|
|
||||||
final List<Specification<SoftwareModule>> specList = new ArrayList<Specification<SoftwareModule>>();
|
final List<Specification<SoftwareModule>> specList = new ArrayList<>();
|
||||||
|
|
||||||
final Specification<SoftwareModule> spec = SoftwareModuleSpecification.isDeletedFalse();
|
final Specification<SoftwareModule> spec = SoftwareModuleSpecification.isDeletedFalse();
|
||||||
specList.add(spec);
|
specList.add(spec);
|
||||||
@@ -479,7 +461,7 @@ public class SoftwareManagement {
|
|||||||
public Slice<SoftwareModule> findSoftwareModuleByFilters(@NotNull final Pageable pageable, final String searchText,
|
public Slice<SoftwareModule> findSoftwareModuleByFilters(@NotNull final Pageable pageable, final String searchText,
|
||||||
final SoftwareModuleType type) {
|
final SoftwareModuleType type) {
|
||||||
|
|
||||||
final List<Specification<SoftwareModule>> specList = new ArrayList<Specification<SoftwareModule>>();
|
final List<Specification<SoftwareModule>> specList = new ArrayList<>();
|
||||||
|
|
||||||
Specification<SoftwareModule> spec = SoftwareModuleSpecification.isDeletedFalse();
|
Specification<SoftwareModule> spec = SoftwareModuleSpecification.isDeletedFalse();
|
||||||
specList.add(spec);
|
specList.add(spec);
|
||||||
@@ -494,15 +476,11 @@ public class SoftwareManagement {
|
|||||||
specList.add(spec);
|
specList.add(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
spec = new Specification<SoftwareModule>() {
|
spec = (root, query, cb) -> {
|
||||||
@Override
|
if (!query.getResultType().isAssignableFrom(Long.class)) {
|
||||||
public Predicate toPredicate(final Root<SoftwareModule> root, final CriteriaQuery<?> query,
|
root.fetch(SoftwareModule_.type);
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
if (!query.getResultType().isAssignableFrom(Long.class)) {
|
|
||||||
root.fetch(SoftwareModule_.type);
|
|
||||||
}
|
|
||||||
return cb.conjunction();
|
|
||||||
}
|
}
|
||||||
|
return cb.conjunction();
|
||||||
};
|
};
|
||||||
|
|
||||||
specList.add(spec);
|
specList.add(spec);
|
||||||
@@ -592,7 +570,7 @@ public class SoftwareManagement {
|
|||||||
|
|
||||||
private List<Specification<SoftwareModule>> buildSpecificationList(final String searchText,
|
private List<Specification<SoftwareModule>> buildSpecificationList(final String searchText,
|
||||||
final SoftwareModuleType type) {
|
final SoftwareModuleType type) {
|
||||||
final List<Specification<SoftwareModule>> specList = new ArrayList<Specification<SoftwareModule>>();
|
final List<Specification<SoftwareModule>> specList = new ArrayList<>();
|
||||||
if (!Strings.isNullOrEmpty(searchText)) {
|
if (!Strings.isNullOrEmpty(searchText)) {
|
||||||
specList.add(SoftwareModuleSpecification.likeNameOrVersion(searchText));
|
specList.add(SoftwareModuleSpecification.likeNameOrVersion(searchText));
|
||||||
}
|
}
|
||||||
@@ -631,7 +609,7 @@ public class SoftwareManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Long countSoftwareModuleByFilters(final String searchText, final SoftwareModuleType type) {
|
public Long countSoftwareModuleByFilters(final String searchText, final SoftwareModuleType type) {
|
||||||
|
|
||||||
final List<Specification<SoftwareModule>> specList = new ArrayList<Specification<SoftwareModule>>();
|
final List<Specification<SoftwareModule>> specList = new ArrayList<>();
|
||||||
|
|
||||||
Specification<SoftwareModule> spec = SoftwareModuleSpecification.isDeletedFalse();
|
Specification<SoftwareModule> spec = SoftwareModuleSpecification.isDeletedFalse();
|
||||||
specList.add(spec);
|
specList.add(spec);
|
||||||
@@ -900,15 +878,14 @@ public class SoftwareManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(final Long softwareModuleId,
|
public Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(final Long softwareModuleId,
|
||||||
@NotNull final Specification<SoftwareModuleMetadata> spec, @NotNull final Pageable pageable) {
|
@NotNull final Specification<SoftwareModuleMetadata> spec, @NotNull final Pageable pageable) {
|
||||||
return softwareModuleMetadataRepository.findAll(new Specification<SoftwareModuleMetadata>() {
|
return softwareModuleMetadataRepository
|
||||||
@Override
|
.findAll(
|
||||||
public Predicate toPredicate(final Root<SoftwareModuleMetadata> root, final CriteriaQuery<?> query,
|
(Specification<SoftwareModuleMetadata>) (root, query,
|
||||||
final CriteriaBuilder cb) {
|
cb) -> cb.and(
|
||||||
|
cb.equal(root.get(SoftwareModuleMetadata_.softwareModule)
|
||||||
return cb.and(cb.equal(root.get(SoftwareModuleMetadata_.softwareModule).get(SoftwareModule_.id),
|
.get(SoftwareModule_.id), softwareModuleId),
|
||||||
softwareModuleId), spec.toPredicate(root, query, cb));
|
spec.toPredicate(root, query, cb)),
|
||||||
}
|
pageable);
|
||||||
}, pageable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import javax.validation.constraints.NotNull;
|
|||||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||||
|
import org.eclipse.hawkbit.repository.specifications.SpecificationsBuilder;
|
||||||
import org.eclipse.hawkbit.repository.specifications.TargetFilterQuerySpecification;
|
import org.eclipse.hawkbit.repository.specifications.TargetFilterQuerySpecification;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -60,8 +61,7 @@ public class TargetFilterQueryManagement {
|
|||||||
if (targetFilterQueryRepository.findByName(customTargetFilter.getName()) != null) {
|
if (targetFilterQueryRepository.findByName(customTargetFilter.getName()) != null) {
|
||||||
throw new EntityAlreadyExistsException(customTargetFilter.getName());
|
throw new EntityAlreadyExistsException(customTargetFilter.getName());
|
||||||
}
|
}
|
||||||
final TargetFilterQuery filter = targetFilterQueryRepository.save(customTargetFilter);
|
return targetFilterQueryRepository.save(customTargetFilter);
|
||||||
return filter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,7 +102,7 @@ public class TargetFilterQueryManagement {
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
public Page<TargetFilterQuery> findTargetFilterQueryByFilters(@NotNull final Pageable pageable, final String name) {
|
public Page<TargetFilterQuery> findTargetFilterQueryByFilters(@NotNull final Pageable pageable, final String name) {
|
||||||
final List<Specification<TargetFilterQuery>> specList = new ArrayList<Specification<TargetFilterQuery>>();
|
final List<Specification<TargetFilterQuery>> specList = new ArrayList<>();
|
||||||
if (!Strings.isNullOrEmpty(name)) {
|
if (!Strings.isNullOrEmpty(name)) {
|
||||||
specList.add(TargetFilterQuerySpecification.likeName(name));
|
specList.add(TargetFilterQuerySpecification.likeName(name));
|
||||||
}
|
}
|
||||||
@@ -119,20 +119,12 @@ public class TargetFilterQueryManagement {
|
|||||||
*/
|
*/
|
||||||
private Page<TargetFilterQuery> findTargetFilterQueryByCriteriaAPI(@NotNull final Pageable pageable,
|
private Page<TargetFilterQuery> findTargetFilterQueryByCriteriaAPI(@NotNull final Pageable pageable,
|
||||||
final List<Specification<TargetFilterQuery>> specList) {
|
final List<Specification<TargetFilterQuery>> specList) {
|
||||||
Specifications<TargetFilterQuery> specs = null;
|
if (specList == null || specList.isEmpty()) {
|
||||||
if (!specList.isEmpty()) {
|
|
||||||
specs = Specifications.where(specList.get(0));
|
|
||||||
}
|
|
||||||
if (specList.size() > 1) {
|
|
||||||
for (final Specification<TargetFilterQuery> s : specList.subList(1, specList.size())) {
|
|
||||||
specs = specs.and(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (specs == null) {
|
|
||||||
return targetFilterQueryRepository.findAll(pageable);
|
return targetFilterQueryRepository.findAll(pageable);
|
||||||
} else {
|
|
||||||
return targetFilterQueryRepository.findAll(specs, pageable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Specifications<TargetFilterQuery> specs = SpecificationsBuilder.combineWithAnd(specList);
|
||||||
|
return targetFilterQueryRepository.findAll(specs, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult;
|
|||||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||||
import org.eclipse.hawkbit.repository.model.Target_;
|
import org.eclipse.hawkbit.repository.model.Target_;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
||||||
|
import org.eclipse.hawkbit.repository.specifications.SpecificationsBuilder;
|
||||||
import org.eclipse.hawkbit.repository.specifications.TargetSpecifications;
|
import org.eclipse.hawkbit.repository.specifications.TargetSpecifications;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -59,7 +60,6 @@ import org.springframework.data.domain.SliceImpl;
|
|||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.domain.Sort.Direction;
|
import org.springframework.data.domain.Sort.Direction;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.data.jpa.domain.Specifications;
|
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -508,39 +508,18 @@ public class TargetManagement {
|
|||||||
* @return the page with the found {@link Target}
|
* @return the page with the found {@link Target}
|
||||||
*/
|
*/
|
||||||
private Slice<Target> findByCriteriaAPI(final Pageable pageable, final List<Specification<Target>> specList) {
|
private Slice<Target> findByCriteriaAPI(final Pageable pageable, final List<Specification<Target>> specList) {
|
||||||
final Specifications<Target> specs = creatingTargetSpecifications(specList);
|
if (specList == null || specList.isEmpty()) {
|
||||||
|
|
||||||
if (specs == null) {
|
|
||||||
return criteriaNoCountDao.findAll(pageable, Target.class);
|
return criteriaNoCountDao.findAll(pageable, Target.class);
|
||||||
} else {
|
|
||||||
return criteriaNoCountDao.findAll(specs, pageable, Target.class);
|
|
||||||
}
|
}
|
||||||
|
return criteriaNoCountDao.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable, Target.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long countByCriteriaAPI(final List<Specification<Target>> specList) {
|
private Long countByCriteriaAPI(final List<Specification<Target>> specList) {
|
||||||
final Specifications<Target> specs = creatingTargetSpecifications(specList);
|
if (specList == null || specList.isEmpty()) {
|
||||||
|
|
||||||
if (specs == null) {
|
|
||||||
return targetRepository.count();
|
return targetRepository.count();
|
||||||
} else {
|
|
||||||
return targetRepository.count(specs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
return targetRepository.count(SpecificationsBuilder.combineWithAnd(specList));
|
||||||
|
|
||||||
private static Specifications<Target> creatingTargetSpecifications(final List<Specification<Target>> specList) {
|
|
||||||
Specifications<Target> specs = null;
|
|
||||||
if (!specList.isEmpty()) {
|
|
||||||
specs = Specifications.where(specList.get(0));
|
|
||||||
}
|
|
||||||
if (specList.size() > 1) {
|
|
||||||
specList.remove(0);
|
|
||||||
for (final Specification<Target> s : specList) {
|
|
||||||
specs = specs.and(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return specs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class Rollout extends NamedEntity {
|
|||||||
private int rolloutGroupsCreated = 0;
|
private int rolloutGroupsCreated = 0;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
private TotalTargetCountStatus totalTargetCountStatus;
|
private transient TotalTargetCountStatus totalTargetCountStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the distributionSet
|
* @return the distributionSet
|
||||||
@@ -234,7 +234,7 @@ public class Rollout extends NamedEntity {
|
|||||||
*/
|
*/
|
||||||
public TotalTargetCountStatus getTotalTargetCountStatus() {
|
public TotalTargetCountStatus getTotalTargetCountStatus() {
|
||||||
if (totalTargetCountStatus == null) {
|
if (totalTargetCountStatus == null) {
|
||||||
this.totalTargetCountStatus = new TotalTargetCountStatus(totalTargets);
|
totalTargetCountStatus = new TotalTargetCountStatus(totalTargets);
|
||||||
}
|
}
|
||||||
return totalTargetCountStatus;
|
return totalTargetCountStatus;
|
||||||
}
|
}
|
||||||
@@ -259,7 +259,7 @@ public class Rollout extends NamedEntity {
|
|||||||
* @author Michael Hirsch
|
* @author Michael Hirsch
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static enum RolloutStatus {
|
public enum RolloutStatus {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollouts is beeing created.
|
* Rollouts is beeing created.
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public class RolloutGroup extends NamedEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSuccessCondition(final RolloutGroupSuccessCondition finishCondition) {
|
public void setSuccessCondition(final RolloutGroupSuccessCondition finishCondition) {
|
||||||
this.successCondition = finishCondition;
|
successCondition = finishCondition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSuccessConditionExp() {
|
public String getSuccessConditionExp() {
|
||||||
@@ -124,7 +124,7 @@ public class RolloutGroup extends NamedEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSuccessConditionExp(final String finishExp) {
|
public void setSuccessConditionExp(final String finishExp) {
|
||||||
this.successConditionExp = finishExp;
|
successConditionExp = finishExp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RolloutGroupErrorCondition getErrorCondition() {
|
public RolloutGroupErrorCondition getErrorCondition() {
|
||||||
@@ -140,7 +140,7 @@ public class RolloutGroup extends NamedEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setErrorConditionExp(final String errorExp) {
|
public void setErrorConditionExp(final String errorExp) {
|
||||||
this.errorConditionExp = errorExp;
|
errorConditionExp = errorExp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RolloutGroupErrorAction getErrorAction() {
|
public RolloutGroupErrorAction getErrorAction() {
|
||||||
@@ -188,7 +188,7 @@ public class RolloutGroup extends NamedEntity {
|
|||||||
*/
|
*/
|
||||||
public TotalTargetCountStatus getTotalTargetCountStatus() {
|
public TotalTargetCountStatus getTotalTargetCountStatus() {
|
||||||
if (totalTargetCountStatus == null) {
|
if (totalTargetCountStatus == null) {
|
||||||
this.totalTargetCountStatus = new TotalTargetCountStatus(totalTargets);
|
totalTargetCountStatus = new TotalTargetCountStatus(totalTargets);
|
||||||
}
|
}
|
||||||
return totalTargetCountStatus;
|
return totalTargetCountStatus;
|
||||||
}
|
}
|
||||||
@@ -343,7 +343,7 @@ public class RolloutGroup extends NamedEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSuccessCondition(final RolloutGroupSuccessCondition finishCondition) {
|
public void setSuccessCondition(final RolloutGroupSuccessCondition finishCondition) {
|
||||||
this.successCondition = finishCondition;
|
successCondition = finishCondition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSuccessConditionExp() {
|
public String getSuccessConditionExp() {
|
||||||
@@ -351,7 +351,7 @@ public class RolloutGroup extends NamedEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSuccessConditionExp(final String finishConditionExp) {
|
public void setSuccessConditionExp(final String finishConditionExp) {
|
||||||
this.successConditionExp = finishConditionExp;
|
successConditionExp = finishConditionExp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RolloutGroupSuccessAction getSuccessAction() {
|
public RolloutGroupSuccessAction getSuccessAction() {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.model;
|
package org.eclipse.hawkbit.repository.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
@@ -30,16 +31,18 @@ import javax.persistence.Table;
|
|||||||
@IdClass(RolloutTargetGroupId.class)
|
@IdClass(RolloutTargetGroupId.class)
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_rollouttargetgroup")
|
@Table(name = "sp_rollouttargetgroup")
|
||||||
public class RolloutTargetGroup {
|
public class RolloutTargetGroup implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@ManyToOne(targetEntity = RolloutGroup.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
|
@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;
|
private RolloutGroup rolloutGroup;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@ManyToOne(targetEntity = Target.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
|
@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;
|
private Target target;
|
||||||
|
|
||||||
@OneToMany(targetEntity = Action.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
|
@OneToMany(targetEntity = Action.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
package org.eclipse.hawkbit.repository.model;
|
package org.eclipse.hawkbit.repository.model;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.EnumMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ public class TotalTargetCountStatus {
|
|||||||
SCHEDULED, RUNNING, ERROR, FINISHED, CANCELLED, NOTSTARTED
|
SCHEDULED, RUNNING, ERROR, FINISHED, CANCELLED, NOTSTARTED
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<Status, Long> statusTotalCountMap = new HashMap<>();
|
private final Map<Status, Long> statusTotalCountMap = new EnumMap<>(Status.class);
|
||||||
private final Long totalTargetCount;
|
private final Long totalTargetCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.repository.specifications;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
import org.springframework.data.jpa.domain.Specifications;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper class to easily combine {@link Specification} instances.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class SpecificationsBuilder {
|
||||||
|
|
||||||
|
private SpecificationsBuilder() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Combine all given specification with and. The first specification is the
|
||||||
|
* where clause.
|
||||||
|
*
|
||||||
|
* @param specList
|
||||||
|
* all specification wich will combine
|
||||||
|
* @return <null> if the given specification list is empty
|
||||||
|
*/
|
||||||
|
public static <T> Specifications<T> combineWithAnd(final List<Specification<T>> specList) {
|
||||||
|
if (specList.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Specifications<T> specs = Specifications.where(specList.get(0));
|
||||||
|
specList.remove(0);
|
||||||
|
for (final Specification<T> specification : specList) {
|
||||||
|
specs = specs.and(specification);
|
||||||
|
}
|
||||||
|
return specs;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -16,7 +16,19 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
|||||||
*/
|
*/
|
||||||
public interface RolloutGroupConditionEvaluator {
|
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);
|
boolean eval(Rollout rollout, RolloutGroup rolloutGroup, final String expression);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,26 +23,11 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component("thresholdRolloutGroupErrorCondition")
|
@Component("thresholdRolloutGroupErrorCondition")
|
||||||
public class ThresholdRolloutGroupErrorCondition implements RolloutGroupConditionEvaluator {
|
public class ThresholdRolloutGroupErrorCondition implements RolloutGroupConditionEvaluator {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(ThresholdRolloutGroupErrorCondition.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ThresholdRolloutGroupErrorCondition.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ActionRepository actionRepository;
|
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
|
@Override
|
||||||
public boolean eval(final Rollout rollout, final RolloutGroup rolloutGroup, final String expression) {
|
public boolean eval(final Rollout rollout, final RolloutGroup rolloutGroup, final String expression) {
|
||||||
final Long totalGroup = actionRepository.countByRolloutAndRolloutGroup(rollout, rolloutGroup);
|
final Long totalGroup = actionRepository.countByRolloutAndRolloutGroup(rollout, rolloutGroup);
|
||||||
@@ -60,7 +45,7 @@ public class ThresholdRolloutGroupErrorCondition implements RolloutGroupConditio
|
|||||||
// calculate threshold
|
// calculate threshold
|
||||||
return ((float) error / (float) totalGroup) > ((float) threshold / 100F);
|
return ((float) error / (float) totalGroup) > ((float) threshold / 100F);
|
||||||
} catch (final NumberFormatException e) {
|
} catch (final NumberFormatException e) {
|
||||||
logger.error("Cannot evaluate condition expression " + expression, e);
|
LOGGER.error("Cannot evaluate condition expression " + expression, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import org.eclipse.hawkbit.repository.ActionRepository;
|
|||||||
import org.eclipse.hawkbit.repository.model.Action;
|
import org.eclipse.hawkbit.repository.model.Action;
|
||||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -20,39 +22,31 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component("thresholdRolloutGroupSuccessCondition")
|
@Component("thresholdRolloutGroupSuccessCondition")
|
||||||
public class ThresholdRolloutGroupSuccessCondition implements RolloutGroupConditionEvaluator {
|
public class ThresholdRolloutGroupSuccessCondition implements RolloutGroupConditionEvaluator {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(ThresholdRolloutGroupSuccessCondition.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ActionRepository actionRepository;
|
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
|
@Override
|
||||||
public boolean eval(final Rollout rollout, final RolloutGroup rolloutGroup, final String expression) {
|
public boolean eval(final Rollout rollout, final RolloutGroup rolloutGroup, final String expression) {
|
||||||
final Long totalGroup = rolloutGroup.getTotalTargets();
|
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);
|
rolloutGroup.getId(), Action.Status.FINISHED);
|
||||||
final Integer threshold = Integer.valueOf(expression);
|
try {
|
||||||
|
final Integer threshold = Integer.valueOf(expression);
|
||||||
|
|
||||||
if (totalGroup == 0) {
|
if (totalGroup == 0) {
|
||||||
// in case e.g. targets has been deleted we don't have any actions
|
// in case e.g. targets has been deleted we don't have any
|
||||||
// left for this group, so the group is finished
|
// actions
|
||||||
return true;
|
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
|
|||||||
private SpringViewProvider viewProvider;
|
private SpringViewProvider viewProvider;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationContext context;
|
private transient ApplicationContext context;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private I18N i18n;
|
private I18N i18n;
|
||||||
@@ -89,7 +89,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
|
|||||||
private ErrorView errorview;
|
private ErrorView errorview;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected EventBus.SessionEventBus eventBus;
|
protected transient EventBus.SessionEventBus eventBus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link com.google.common.eventbus.EventBus} subscriber which
|
* An {@link com.google.common.eventbus.EventBus} subscriber which
|
||||||
@@ -103,21 +103,28 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
|
|||||||
@AllowConcurrentEvents
|
@AllowConcurrentEvents
|
||||||
public void dispatch(final org.eclipse.hawkbit.eventbus.event.Event event) {
|
public void dispatch(final org.eclipse.hawkbit.eventbus.event.Event event) {
|
||||||
final VaadinSession session = getSession();
|
final VaadinSession session = getSession();
|
||||||
if (session != null && session.getState() == State.OPEN) {
|
if (session == null || session.getState() != State.OPEN) {
|
||||||
final WrappedSession wrappedSession = session.getSession();
|
return;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(eventBus, session, userContext, event));
|
||||||
|
} finally {
|
||||||
|
SecurityContextHolder.setContext(oldContext);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean eventSecurityCheck(final SecurityContext userContext,
|
protected boolean eventSecurityCheck(final SecurityContext userContext,
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, ConfirmationTab> getConfimrationTabs() {
|
protected Map<String, ConfirmationTab> getConfimrationTabs() {
|
||||||
final Map<String, ConfirmationTab> tabs = new HashMap<String, ConfirmationTab>();
|
final Map<String, ConfirmationTab> tabs = new HashMap<>();
|
||||||
if (!artifactUploadState.getDeleteSofwareModules().isEmpty()) {
|
if (!artifactUploadState.getDeleteSofwareModules().isEmpty()) {
|
||||||
tabs.put(i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
|
tabs.put(i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
|
||||||
}
|
}
|
||||||
@@ -153,9 +153,8 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
|
|||||||
final IndexedContainer swcontactContainer = new IndexedContainer();
|
final IndexedContainer swcontactContainer = new IndexedContainer();
|
||||||
swcontactContainer.addContainerProperty("SWModuleId", String.class, "");
|
swcontactContainer.addContainerProperty("SWModuleId", String.class, "");
|
||||||
swcontactContainer.addContainerProperty(SW_MODULE_NAME_MSG, String.class, "");
|
swcontactContainer.addContainerProperty(SW_MODULE_NAME_MSG, String.class, "");
|
||||||
Item item = null;
|
|
||||||
for (final Long swModuleID : artifactUploadState.getDeleteSofwareModules().keySet()) {
|
for (final Long swModuleID : artifactUploadState.getDeleteSofwareModules().keySet()) {
|
||||||
item = swcontactContainer.addItem(swModuleID);
|
final Item item = swcontactContainer.addItem(swModuleID);
|
||||||
item.getItemProperty("SWModuleId").setValue(swModuleID.toString());
|
item.getItemProperty("SWModuleId").setValue(swModuleID.toString());
|
||||||
item.getItemProperty(SW_MODULE_NAME_MSG)
|
item.getItemProperty(SW_MODULE_NAME_MSG)
|
||||||
.setValue(artifactUploadState.getDeleteSofwareModules().get(swModuleID));
|
.setValue(artifactUploadState.getDeleteSofwareModules().get(swModuleID));
|
||||||
@@ -197,7 +196,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
|
|||||||
for (final CustomFile customFile : artifactUploadState.getFileSelected()) {
|
for (final CustomFile customFile : artifactUploadState.getFileSelected()) {
|
||||||
final String swNameVersion = HawkbitCommonUtil.getFormattedNameVersion(
|
final String swNameVersion = HawkbitCommonUtil.getFormattedNameVersion(
|
||||||
customFile.getBaseSoftwareModuleName(), customFile.getBaseSoftwareModuleVersion());
|
customFile.getBaseSoftwareModuleName(), customFile.getBaseSoftwareModuleVersion());
|
||||||
if (HawkbitCommonUtil.bothSame(deleteSoftwareNameVersion, swNameVersion)) {
|
if (deleteSoftwareNameVersion != null && deleteSoftwareNameVersion.equals(swNameVersion)) {
|
||||||
tobeRemoved.add(customFile);
|
tobeRemoved.add(customFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,13 +38,13 @@ public class ArtifactUploadState implements Serializable {
|
|||||||
|
|
||||||
private final Map<Long, String> deleteSofwareModules = new HashMap<>();
|
private final Map<Long, String> deleteSofwareModules = new HashMap<>();
|
||||||
|
|
||||||
private final Set<CustomFile> fileSelected = new HashSet<CustomFile>();
|
private final Set<CustomFile> fileSelected = new HashSet<>();
|
||||||
|
|
||||||
private Long selectedBaseSwModuleId;
|
private Long selectedBaseSwModuleId;
|
||||||
|
|
||||||
private SoftwareModule selectedBaseSoftwareModule;
|
private SoftwareModule selectedBaseSoftwareModule;
|
||||||
|
|
||||||
private final Map<String, SoftwareModule> baseSwModuleList = new HashMap<String, SoftwareModule>();
|
private final Map<String, SoftwareModule> baseSwModuleList = new HashMap<>();
|
||||||
|
|
||||||
private Set<Long> selectedSoftwareModules = Collections.emptySet();
|
private Set<Long> selectedSoftwareModules = Collections.emptySet();
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ public class ArtifactUploadState implements Serializable {
|
|||||||
* @return the selectedBaseSwModuleId
|
* @return the selectedBaseSwModuleId
|
||||||
*/
|
*/
|
||||||
public Optional<Long> getSelectedBaseSwModuleId() {
|
public Optional<Long> getSelectedBaseSwModuleId() {
|
||||||
return this.selectedBaseSwModuleId != null ? Optional.of(this.selectedBaseSwModuleId) : Optional.empty();
|
return selectedBaseSwModuleId != null ? Optional.of(selectedBaseSwModuleId) : Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,8 +100,7 @@ public class ArtifactUploadState implements Serializable {
|
|||||||
* @return the selectedBaseSoftwareModule
|
* @return the selectedBaseSoftwareModule
|
||||||
*/
|
*/
|
||||||
public Optional<SoftwareModule> getSelectedBaseSoftwareModule() {
|
public Optional<SoftwareModule> getSelectedBaseSoftwareModule() {
|
||||||
return this.selectedBaseSoftwareModule == null ? Optional.empty()
|
return selectedBaseSoftwareModule == null ? Optional.empty() : Optional.of(selectedBaseSoftwareModule);
|
||||||
: Optional.of(this.selectedBaseSoftwareModule);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ package org.eclipse.hawkbit.ui.artifacts.state;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom file to hold details of uploaded file.
|
* Custom file to hold details of uploaded file.
|
||||||
*
|
*
|
||||||
@@ -168,36 +166,50 @@ public class CustomFile implements Serializable {
|
|||||||
return failureReason;
|
return failureReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { // NOSONAR - as this is generated
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + (fileName == null ? 0 : fileName.hashCode());
|
result = prime * result + ((baseSoftwareModuleName == null) ? 0 : baseSoftwareModuleName.hashCode());
|
||||||
|
result = prime * result + ((baseSoftwareModuleVersion == null) ? 0 : baseSoftwareModuleVersion.hashCode());
|
||||||
|
result = prime * result + ((fileName == null) ? 0 : fileName.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof CustomFile)) {
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final CustomFile other = (CustomFile) obj;
|
final CustomFile other = (CustomFile) obj;
|
||||||
return HawkbitCommonUtil.bothSame(fileName, other.fileName)
|
if (baseSoftwareModuleName == null) {
|
||||||
&& HawkbitCommonUtil.bothSame(baseSoftwareModuleName, other.baseSoftwareModuleName)
|
if (other.baseSoftwareModuleName != null) {
|
||||||
&& HawkbitCommonUtil.bothSame(baseSoftwareModuleVersion, other.baseSoftwareModuleVersion);
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!baseSoftwareModuleName.equals(other.baseSoftwareModuleName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (baseSoftwareModuleVersion == null) {
|
||||||
|
if (other.baseSoftwareModuleVersion != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!baseSoftwareModuleVersion.equals(other.baseSoftwareModuleVersion)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (fileName == null) {
|
||||||
|
if (other.fileName != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!fileName.equals(other.fileName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.common.filterlayout;
|
package org.eclipse.hawkbit.ui.common.filterlayout;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||||
|
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
@@ -26,7 +24,7 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
|
|||||||
|
|
||||||
private static final long serialVersionUID = 478874092615793581L;
|
private static final long serialVersionUID = 478874092615793581L;
|
||||||
|
|
||||||
private Optional<Button> alreadyClickedButton = Optional.empty();
|
private Button alreadyClickedButton;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
@@ -40,18 +38,18 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
|
|||||||
if (isButtonUnClicked(clickedButton)) {
|
if (isButtonUnClicked(clickedButton)) {
|
||||||
/* If same button clicked */
|
/* If same button clicked */
|
||||||
clickedButton.removeStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
|
clickedButton.removeStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
|
||||||
alreadyClickedButton = Optional.empty();
|
alreadyClickedButton = null;
|
||||||
filterUnClicked(clickedButton);
|
filterUnClicked(clickedButton);
|
||||||
} else if (alreadyClickedButton.isPresent()) {
|
} else if (alreadyClickedButton != null) {
|
||||||
/* If button clicked and some other button is already clicked */
|
/* If button clicked and some other button is already clicked */
|
||||||
alreadyClickedButton.get().removeStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
|
alreadyClickedButton.removeStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
|
||||||
clickedButton.addStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
|
clickedButton.addStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
|
||||||
alreadyClickedButton = Optional.of(clickedButton);
|
alreadyClickedButton = clickedButton;
|
||||||
filterClicked(clickedButton);
|
filterClicked(clickedButton);
|
||||||
} else {
|
} else {
|
||||||
/* If button clicked and not other button is clicked currently */
|
/* If button clicked and not other button is clicked currently */
|
||||||
clickedButton.addStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
|
clickedButton.addStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
|
||||||
alreadyClickedButton = Optional.of(clickedButton);
|
alreadyClickedButton = clickedButton;
|
||||||
filterClicked(clickedButton);
|
filterClicked(clickedButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,7 +59,7 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean isButtonUnClicked(final Button clickedButton) {
|
private boolean isButtonUnClicked(final Button clickedButton) {
|
||||||
return alreadyClickedButton.isPresent() && alreadyClickedButton.get().equals(clickedButton);
|
return alreadyClickedButton != null && alreadyClickedButton.equals(clickedButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -72,10 +70,8 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void setDefaultClickedButton(final Button button) {
|
protected void setDefaultClickedButton(final Button button) {
|
||||||
if (button == null) {
|
alreadyClickedButton = button;
|
||||||
alreadyClickedButton = Optional.empty();
|
if (button != null) {
|
||||||
} else {
|
|
||||||
alreadyClickedButton = Optional.of(button);
|
|
||||||
button.addStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
|
button.addStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,7 +79,7 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
|
|||||||
/**
|
/**
|
||||||
* @return the alreadyClickedButton
|
* @return the alreadyClickedButton
|
||||||
*/
|
*/
|
||||||
public Optional<Button> getAlreadyClickedButton() {
|
public Button getAlreadyClickedButton() {
|
||||||
return alreadyClickedButton;
|
return alreadyClickedButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +87,7 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
|
|||||||
* @param alreadyClickedButton
|
* @param alreadyClickedButton
|
||||||
* the alreadyClickedButton to set
|
* the alreadyClickedButton to set
|
||||||
*/
|
*/
|
||||||
public void setAlreadyClickedButton(final Optional<Button> alreadyClickedButton) {
|
public void setAlreadyClickedButton(final Button alreadyClickedButton) {
|
||||||
this.alreadyClickedButton = alreadyClickedButton;
|
this.alreadyClickedButton = alreadyClickedButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ public abstract class AbstractTagToken implements Serializable {
|
|||||||
|
|
||||||
protected IndexedContainer container;
|
protected IndexedContainer container;
|
||||||
|
|
||||||
protected final Map<Long, TagData> tagDetails = new HashMap<Long, TagData>();
|
protected final Map<Long, TagData> tagDetails = new HashMap<>();
|
||||||
|
|
||||||
protected final Map<Long, TagData> tokensAdded = new HashMap<Long, TagData>();
|
protected final Map<Long, TagData> tokensAdded = new HashMap<>();
|
||||||
|
|
||||||
protected CssLayout tokenLayout = new CssLayout();
|
protected CssLayout tokenLayout = new CssLayout();
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ public abstract class AbstractTagToken implements Serializable {
|
|||||||
class CustomTokenField extends TokenField {
|
class CustomTokenField extends TokenField {
|
||||||
private static final long serialVersionUID = 694216966472937436L;
|
private static final long serialVersionUID = 694216966472937436L;
|
||||||
|
|
||||||
final Container tokenContainer;
|
Container tokenContainer;
|
||||||
|
|
||||||
CustomTokenField(final CssLayout cssLayout, final Container tokenContainer) {
|
CustomTokenField(final CssLayout cssLayout, final Container tokenContainer) {
|
||||||
super(cssLayout);
|
super(cssLayout);
|
||||||
@@ -237,7 +237,9 @@ public abstract class AbstractTagToken implements Serializable {
|
|||||||
* Tag details.
|
* Tag details.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static class TagData {
|
public static class TagData implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
package org.eclipse.hawkbit.ui.distributions.dstable;
|
package org.eclipse.hawkbit.ui.distributions.dstable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -153,12 +154,13 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void showUnsavedAssignment() {
|
private void showUnsavedAssignment() {
|
||||||
Item item;
|
Item item;
|
||||||
final Map<DistributionSetIdName, Set<SoftwareModuleIdName>> assignedList = manageDistUIState.getAssignedList();
|
final Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> assignedList = manageDistUIState
|
||||||
|
.getAssignedList();
|
||||||
final Long selectedDistId = manageDistUIState.getLastSelectedDistribution().isPresent()
|
final Long selectedDistId = manageDistUIState.getLastSelectedDistribution().isPresent()
|
||||||
? manageDistUIState.getLastSelectedDistribution().get().getId() : null;
|
? manageDistUIState.getLastSelectedDistribution().get().getId() : null;
|
||||||
Set<SoftwareModuleIdName> softwareModuleIdNameList = null;
|
Set<SoftwareModuleIdName> softwareModuleIdNameList = null;
|
||||||
|
|
||||||
for (final Map.Entry<DistributionSetIdName, Set<SoftwareModuleIdName>> entry : assignedList.entrySet()) {
|
for (final Map.Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entry : assignedList.entrySet()) {
|
||||||
if (entry.getKey().getId().equals(selectedDistId)) {
|
if (entry.getKey().getId().equals(selectedDistId)) {
|
||||||
softwareModuleIdNameList = entry.getValue();
|
softwareModuleIdNameList = entry.getValue();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
@Override
|
@Override
|
||||||
protected Container createContainer() {
|
protected Container createContainer() {
|
||||||
|
|
||||||
final Map<String, Object> queryConfiguration = new HashMap<String, Object>();
|
final Map<String, Object> queryConfiguration = new HashMap<>();
|
||||||
manageDistUIState.getManageDistFilters().getSearchText()
|
manageDistUIState.getManageDistFilters().getSearchText()
|
||||||
.ifPresent(value -> queryConfiguration.put(SPUIDefinitions.FILTER_BY_TEXT, value));
|
.ifPresent(value -> queryConfiguration.put(SPUIDefinitions.FILTER_BY_TEXT, value));
|
||||||
|
|
||||||
@@ -166,14 +166,11 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
manageDistUIState.getManageDistFilters().getClickedDistSetType());
|
manageDistUIState.getManageDistFilters().getClickedDistSetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
final BeanQueryFactory<ManageDistBeanQuery> distributionQF = new BeanQueryFactory<ManageDistBeanQuery>(
|
final BeanQueryFactory<ManageDistBeanQuery> distributionQF = new BeanQueryFactory<>(ManageDistBeanQuery.class);
|
||||||
ManageDistBeanQuery.class);
|
|
||||||
distributionQF.setQueryConfiguration(queryConfiguration);
|
distributionQF.setQueryConfiguration(queryConfiguration);
|
||||||
final LazyQueryContainer distContainer = new LazyQueryContainer(
|
return new LazyQueryContainer(
|
||||||
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME),
|
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME),
|
||||||
distributionQF);
|
distributionQF);
|
||||||
|
|
||||||
return distContainer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -317,7 +314,7 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
||||||
final Table source = transferable.getSourceComponent();
|
final Table source = transferable.getSourceComponent();
|
||||||
final Set<Long> softwareModuleSelected = (Set<Long>) source.getValue();
|
final Set<Long> softwareModuleSelected = (Set<Long>) source.getValue();
|
||||||
final Set<Long> softwareModulesIdList = new HashSet<Long>();
|
final Set<Long> softwareModulesIdList = new HashSet<>();
|
||||||
|
|
||||||
if (!softwareModuleSelected.contains(transferable.getData("itemId"))) {
|
if (!softwareModuleSelected.contains(transferable.getData("itemId"))) {
|
||||||
softwareModulesIdList.add((Long) transferable.getData("itemId"));
|
softwareModulesIdList.add((Long) transferable.getData("itemId"));
|
||||||
@@ -345,11 +342,11 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
final String distVersion = (String) item.getItemProperty("version").getValue();
|
final String distVersion = (String) item.getItemProperty("version").getValue();
|
||||||
final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distId, distName, distVersion);
|
final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distId, distName, distVersion);
|
||||||
|
|
||||||
final Map<Long, Set<SoftwareModuleIdName>> map;
|
final HashMap<Long, HashSet<SoftwareModuleIdName>> map;
|
||||||
if (manageDistUIState.getConsolidatedDistSoftwarewList().containsKey(distributionSetIdName)) {
|
if (manageDistUIState.getConsolidatedDistSoftwarewList().containsKey(distributionSetIdName)) {
|
||||||
map = manageDistUIState.getConsolidatedDistSoftwarewList().get(distributionSetIdName);
|
map = manageDistUIState.getConsolidatedDistSoftwarewList().get(distributionSetIdName);
|
||||||
} else {
|
} else {
|
||||||
map = new HashMap<Long, Set<SoftwareModuleIdName>>();
|
map = new HashMap<>();
|
||||||
manageDistUIState.getConsolidatedDistSoftwarewList().put(distributionSetIdName, map);
|
manageDistUIState.getConsolidatedDistSoftwarewList().put(distributionSetIdName, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,7 +379,8 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Set<SoftwareModuleIdName> softwareModules = new HashSet<SoftwareModuleIdName>();
|
// hashset is seriablizable
|
||||||
|
final HashSet<SoftwareModuleIdName> softwareModules = new HashSet<>();
|
||||||
map.keySet().forEach(typeId -> softwareModules.addAll(map.get(typeId)));
|
map.keySet().forEach(typeId -> softwareModules.addAll(map.get(typeId)));
|
||||||
|
|
||||||
updateDropedDetails(distributionSetIdName, softwareModules);
|
updateDropedDetails(distributionSetIdName, softwareModules);
|
||||||
@@ -405,8 +403,8 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
* @param softwareModule
|
* @param softwareModule
|
||||||
* @param softwareModuleIdName
|
* @param softwareModuleIdName
|
||||||
*/
|
*/
|
||||||
private void handleFirmwareCase(final Map<Long, Set<SoftwareModuleIdName>> map, final SoftwareModule softwareModule,
|
private void handleFirmwareCase(final Map<Long, HashSet<SoftwareModuleIdName>> map,
|
||||||
final SoftwareModuleIdName softwareModuleIdName) {
|
final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) {
|
||||||
if (softwareModule.getType().getMaxAssignments() == 1) {
|
if (softwareModule.getType().getMaxAssignments() == 1) {
|
||||||
if (!map.containsKey(softwareModule.getType().getId())) {
|
if (!map.containsKey(softwareModule.getType().getId())) {
|
||||||
map.put(softwareModule.getType().getId(), new HashSet<SoftwareModuleIdName>());
|
map.put(softwareModule.getType().getId(), new HashSet<SoftwareModuleIdName>());
|
||||||
@@ -423,8 +421,8 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
* @param softwareModule
|
* @param softwareModule
|
||||||
* @param softwareModuleIdName
|
* @param softwareModuleIdName
|
||||||
*/
|
*/
|
||||||
private void handleSoftwareCase(final Map<Long, Set<SoftwareModuleIdName>> map, final SoftwareModule softwareModule,
|
private void handleSoftwareCase(final Map<Long, HashSet<SoftwareModuleIdName>> map,
|
||||||
final SoftwareModuleIdName softwareModuleIdName) {
|
final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) {
|
||||||
if (softwareModule.getType().getMaxAssignments() == Integer.MAX_VALUE) {
|
if (softwareModule.getType().getMaxAssignments() == Integer.MAX_VALUE) {
|
||||||
if (!map.containsKey(softwareModule.getType().getId())) {
|
if (!map.containsKey(softwareModule.getType().getId())) {
|
||||||
map.put(softwareModule.getType().getId(), new HashSet<SoftwareModuleIdName>());
|
map.put(softwareModule.getType().getId(), new HashSet<SoftwareModuleIdName>());
|
||||||
@@ -434,7 +432,7 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateDropedDetails(final DistributionSetIdName distributionSetIdName,
|
private void updateDropedDetails(final DistributionSetIdName distributionSetIdName,
|
||||||
final Set<SoftwareModuleIdName> softwareModules) {
|
final HashSet<SoftwareModuleIdName> softwareModules) {
|
||||||
LOG.debug("Adding a log to check if distributionSetIdName is null : {} ", distributionSetIdName);
|
LOG.debug("Adding a log to check if distributionSetIdName is null : {} ", distributionSetIdName);
|
||||||
manageDistUIState.getAssignedList().put(distributionSetIdName, softwareModules);
|
manageDistUIState.getAssignedList().put(distributionSetIdName, softwareModules);
|
||||||
|
|
||||||
@@ -487,20 +485,20 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSoftwareModuleDragged(final Long distId, final SoftwareModule sm) {
|
private boolean isSoftwareModuleDragged(final Long distId, final SoftwareModule sm) {
|
||||||
for (final Entry<DistributionSetIdName, Set<SoftwareModuleIdName>> entry : manageDistUIState.getAssignedList()
|
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entry : manageDistUIState
|
||||||
.entrySet()) {
|
.getAssignedList().entrySet()) {
|
||||||
if (distId.equals(entry.getKey().getId())) {
|
if (!distId.equals(entry.getKey().getId())) {
|
||||||
final Set<SoftwareModuleIdName> swModuleIdNames = entry.getValue();
|
continue;
|
||||||
for (final SoftwareModuleIdName swModuleIdName : swModuleIdNames) {
|
|
||||||
|
|
||||||
if ((sm.getName().concat(":" + sm.getVersion())).equals(swModuleIdName.getName())) {
|
|
||||||
notification.displayValidationError(i18n.get("message.software.already.dragged",
|
|
||||||
HawkbitCommonUtil.concatStrings(":", sm.getName(), sm.getVersion())));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
final Set<SoftwareModuleIdName> swModuleIdNames = entry.getValue();
|
||||||
|
for (final SoftwareModuleIdName swModuleIdName : swModuleIdNames) {
|
||||||
|
if ((sm.getName().concat(":" + sm.getVersion())).equals(swModuleIdName.getName())) {
|
||||||
|
notification.displayValidationError(i18n.get("message.software.already.dragged",
|
||||||
|
HawkbitCommonUtil.concatStrings(":", sm.getName(), sm.getVersion())));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -564,21 +562,18 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addTableStyleGenerator() {
|
private void addTableStyleGenerator() {
|
||||||
setCellStyleGenerator(new Table.CellStyleGenerator() {
|
setCellStyleGenerator((source, itemId, propertyId) -> {
|
||||||
@Override
|
if (propertyId == null) {
|
||||||
public String getStyle(final Table source, final Object itemId, final Object propertyId) {
|
// Styling for row
|
||||||
if (propertyId == null) {
|
final Item item = getItem(itemId);
|
||||||
// Styling for row
|
final Boolean isComplete = (Boolean) item
|
||||||
final Item item = getItem(itemId);
|
.getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).getValue();
|
||||||
final Boolean isComplete = (Boolean) item
|
if (!isComplete) {
|
||||||
.getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).getValue();
|
return SPUIDefinitions.DISABLE_DISTRIBUTION;
|
||||||
if (!isComplete) {
|
|
||||||
return SPUIDefinitions.DISABLE_DISTRIBUTION;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
* @see
|
* @see
|
||||||
* org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#init()
|
* org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#init()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
protected void init() {
|
protected void init() {
|
||||||
super.init();
|
super.init();
|
||||||
@@ -276,7 +277,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) {
|
private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final Set<DistributionSetIdName> distSelected = (Set<DistributionSetIdName>) sourceTable.getValue();
|
final Set<DistributionSetIdName> distSelected = (Set<DistributionSetIdName>) sourceTable.getValue();
|
||||||
final Set<DistributionSetIdName> distributionIdNameSet = new HashSet<DistributionSetIdName>();
|
final Set<DistributionSetIdName> distributionIdNameSet = new HashSet<>();
|
||||||
if (!distSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) {
|
if (!distSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) {
|
||||||
distributionIdNameSet.add((DistributionSetIdName) transferable.getData(SPUIDefinitions.ITEMID));
|
distributionIdNameSet.add((DistributionSetIdName) transferable.getData(SPUIDefinitions.ITEMID));
|
||||||
} else {
|
} else {
|
||||||
@@ -314,7 +315,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final Set<Long> swModuleSelected = (Set<Long>) sourceTable.getValue();
|
final Set<Long> swModuleSelected = (Set<Long>) sourceTable.getValue();
|
||||||
final Set<Long> swModuleIdNameSet = new HashSet<Long>();
|
final Set<Long> swModuleIdNameSet = new HashSet<>();
|
||||||
if (!swModuleSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) {
|
if (!swModuleSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) {
|
||||||
swModuleIdNameSet.add((Long) transferable.getData(SPUIDefinitions.ITEMID));
|
swModuleIdNameSet.add((Long) transferable.getData(SPUIDefinitions.ITEMID));
|
||||||
} else {
|
} else {
|
||||||
@@ -336,7 +337,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
+ manageDistUIState.getDeleteSofwareModulesList().size()
|
+ manageDistUIState.getDeleteSofwareModulesList().size()
|
||||||
+ manageDistUIState.getDeletedDistributionList().size();
|
+ manageDistUIState.getDeletedDistributionList().size();
|
||||||
|
|
||||||
for (final Entry<DistributionSetIdName, Set<SoftwareModuleIdName>> mapEntry : manageDistUIState
|
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> mapEntry : manageDistUIState
|
||||||
.getAssignedList().entrySet()) {
|
.getAssignedList().entrySet()) {
|
||||||
count += manageDistUIState.getAssignedList().get(mapEntry.getKey()).size();
|
count += manageDistUIState.getAssignedList().get(mapEntry.getKey()).size();
|
||||||
}
|
}
|
||||||
@@ -357,22 +358,12 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param source
|
|
||||||
* @return true if it is distribution table
|
|
||||||
*/
|
|
||||||
private boolean isDistributionTable(final Component source) {
|
private boolean isDistributionTable(final Component source) {
|
||||||
return HawkbitCommonUtil.bothSame(source.getId(), SPUIComponetIdProvider.DIST_TABLE_ID);
|
return SPUIComponetIdProvider.DIST_TABLE_ID.equals(source.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param source
|
|
||||||
* @return true if it is SoftwareModule table
|
|
||||||
*/
|
|
||||||
private boolean isSoftwareModuleTable(final Component source) {
|
private boolean isSoftwareModuleTable(final Component source) {
|
||||||
return HawkbitCommonUtil.bothSame(source.getId(), SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE);
|
return SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE.equals(source.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.distributions.footer;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@@ -113,7 +114,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, ConfirmationTab> getConfimrationTabs() {
|
protected Map<String, ConfirmationTab> getConfimrationTabs() {
|
||||||
final Map<String, ConfirmationTab> tabs = new HashMap<String, ConfirmationTab>();
|
final Map<String, ConfirmationTab> tabs = new HashMap<>();
|
||||||
/* Create tab for SW Modules delete */
|
/* Create tab for SW Modules delete */
|
||||||
if (!manageDistUIState.getDeleteSofwareModulesList().isEmpty()) {
|
if (!manageDistUIState.getDeleteSofwareModulesList().isEmpty()) {
|
||||||
tabs.put(i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
|
tabs.put(i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
|
||||||
@@ -190,26 +191,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
|||||||
private void deleteSMAll(final ConfirmationTab tab) {
|
private void deleteSMAll(final ConfirmationTab tab) {
|
||||||
final Set<Long> swmoduleIds = manageDistUIState.getDeleteSofwareModulesList().keySet();
|
final Set<Long> swmoduleIds = manageDistUIState.getDeleteSofwareModulesList().keySet();
|
||||||
|
|
||||||
if (null != manageDistUIState.getAssignedList() && !manageDistUIState.getAssignedList().isEmpty()) {
|
if (manageDistUIState.getAssignedList() == null || manageDistUIState.getAssignedList().isEmpty()) {
|
||||||
|
removeAssignedSoftwareModules();
|
||||||
for (final Entry<DistributionSetIdName, Set<SoftwareModuleIdName>> entryAssignSM : manageDistUIState
|
|
||||||
.getAssignedList().entrySet()) {
|
|
||||||
for (final Entry<Long, String> entryDeleteSM : manageDistUIState.getDeleteSofwareModulesList()
|
|
||||||
.entrySet()) {
|
|
||||||
final SoftwareModuleIdName smIdName = new SoftwareModuleIdName(entryDeleteSM.getKey(),
|
|
||||||
entryDeleteSM.getValue());
|
|
||||||
if (entryAssignSM.getValue().contains(smIdName)) {
|
|
||||||
entryAssignSM.getValue().remove(smIdName);
|
|
||||||
assignmnetTab.getTable().removeItem(HawkbitCommonUtil.concatStrings("|||",
|
|
||||||
entryAssignSM.getKey().getId().toString(), smIdName.getId().toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entryAssignSM.getValue().isEmpty()) {
|
|
||||||
manageDistUIState.getAssignedList().remove(entryAssignSM.getKey());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
softwareManagement.deleteSoftwareModules(swmoduleIds);
|
softwareManagement.deleteSoftwareModules(swmoduleIds);
|
||||||
@@ -221,6 +204,25 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
|||||||
eventBus.publish(this, SaveActionWindowEvent.DELETE_ALL_SOFWARE);
|
eventBus.publish(this, SaveActionWindowEvent.DELETE_ALL_SOFWARE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeAssignedSoftwareModules() {
|
||||||
|
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entryAssignSM : manageDistUIState
|
||||||
|
.getAssignedList().entrySet()) {
|
||||||
|
for (final Entry<Long, String> entryDeleteSM : manageDistUIState.getDeleteSofwareModulesList().entrySet()) {
|
||||||
|
final SoftwareModuleIdName smIdName = new SoftwareModuleIdName(entryDeleteSM.getKey(),
|
||||||
|
entryDeleteSM.getValue());
|
||||||
|
if (entryAssignSM.getValue().contains(smIdName)) {
|
||||||
|
entryAssignSM.getValue().remove(smIdName);
|
||||||
|
assignmnetTab.getTable().removeItem(HawkbitCommonUtil.concatStrings("|||",
|
||||||
|
entryAssignSM.getKey().getId().toString(), smIdName.getId().toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entryAssignSM.getValue().isEmpty()) {
|
||||||
|
manageDistUIState.getAssignedList().remove(entryAssignSM.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void discardSMAll(final ConfirmationTab tab) {
|
private void discardSMAll(final ConfirmationTab tab) {
|
||||||
removeCurrentTab(tab);
|
removeCurrentTab(tab);
|
||||||
manageDistUIState.getDeleteSofwareModulesList().clear();
|
manageDistUIState.getDeleteSofwareModulesList().clear();
|
||||||
@@ -238,9 +240,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
|||||||
final IndexedContainer swcontactContainer = new IndexedContainer();
|
final IndexedContainer swcontactContainer = new IndexedContainer();
|
||||||
swcontactContainer.addContainerProperty("SWModuleId", String.class, "");
|
swcontactContainer.addContainerProperty("SWModuleId", String.class, "");
|
||||||
swcontactContainer.addContainerProperty(SW_MODULE_NAME_MSG, String.class, "");
|
swcontactContainer.addContainerProperty(SW_MODULE_NAME_MSG, String.class, "");
|
||||||
Item item = null;
|
|
||||||
for (final Long swModuleID : manageDistUIState.getDeleteSofwareModulesList().keySet()) {
|
for (final Long swModuleID : manageDistUIState.getDeleteSofwareModulesList().keySet()) {
|
||||||
item = swcontactContainer.addItem(swModuleID);
|
final Item item = swcontactContainer.addItem(swModuleID);
|
||||||
item.getItemProperty("SWModuleId").setValue(swModuleID.toString());
|
item.getItemProperty("SWModuleId").setValue(swModuleID.toString());
|
||||||
item.getItemProperty(SW_MODULE_NAME_MSG)
|
item.getItemProperty(SW_MODULE_NAME_MSG)
|
||||||
.setValue(manageDistUIState.getDeleteSofwareModulesList().get(swModuleID));
|
.setValue(manageDistUIState.getDeleteSofwareModulesList().get(swModuleID));
|
||||||
@@ -640,7 +641,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
|||||||
contactContainer.addContainerProperty(DIST_ID_NAME, DistributionSetIdName.class, "");
|
contactContainer.addContainerProperty(DIST_ID_NAME, DistributionSetIdName.class, "");
|
||||||
contactContainer.addContainerProperty(SOFTWARE_MODULE_ID_NAME, SoftwareModuleIdName.class, "");
|
contactContainer.addContainerProperty(SOFTWARE_MODULE_ID_NAME, SoftwareModuleIdName.class, "");
|
||||||
|
|
||||||
final Map<DistributionSetIdName, Set<SoftwareModuleIdName>> assignedList = manageDistUIState.getAssignedList();
|
final Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> assignedList = manageDistUIState
|
||||||
|
.getAssignedList();
|
||||||
|
|
||||||
assignedList.forEach((distIdname, softIdNameSet) -> softIdNameSet.forEach(softIdName -> {
|
assignedList.forEach((distIdname, softIdNameSet) -> softIdNameSet.forEach(softIdName -> {
|
||||||
final String itemId = HawkbitCommonUtil.concatStrings("|||", distIdname.getId().toString(),
|
final String itemId = HawkbitCommonUtil.concatStrings("|||", distIdname.getId().toString(),
|
||||||
@@ -672,8 +674,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
|||||||
|
|
||||||
});
|
});
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (final Entry<DistributionSetIdName, Set<SoftwareModuleIdName>> entry : manageDistUIState.getAssignedList()
|
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entry : manageDistUIState
|
||||||
.entrySet()) {
|
.getAssignedList().entrySet()) {
|
||||||
count += entry.getValue().size();
|
count += entry.getValue().size();
|
||||||
}
|
}
|
||||||
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
|
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
|
||||||
@@ -707,7 +709,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
|||||||
if (softIdNameSet.isEmpty()) {
|
if (softIdNameSet.isEmpty()) {
|
||||||
manageDistUIState.getAssignedList().remove(discardDistIdName);
|
manageDistUIState.getAssignedList().remove(discardDistIdName);
|
||||||
}
|
}
|
||||||
final Map<Long, Set<SoftwareModuleIdName>> map = manageDistUIState.getConsolidatedDistSoftwarewList()
|
final Map<Long, HashSet<SoftwareModuleIdName>> map = manageDistUIState.getConsolidatedDistSoftwarewList()
|
||||||
.get(discardDistIdName);
|
.get(discardDistIdName);
|
||||||
map.keySet().forEach(typeId -> map.get(typeId).remove(discardSoftIdName));
|
map.keySet().forEach(typeId -> map.get(typeId).remove(discardSoftIdName));
|
||||||
|
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ public class ManageDistUIState implements Serializable {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ManageSoftwareModuleFilters softwareModuleFilters;
|
private ManageSoftwareModuleFilters softwareModuleFilters;
|
||||||
|
|
||||||
private final Map<DistributionSetIdName, Set<SoftwareModuleIdName>> assignedList = new HashMap<DistributionSetIdName, Set<SoftwareModuleIdName>>();
|
private final Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> assignedList = new HashMap<>();
|
||||||
|
|
||||||
private final Set<DistributionSetIdName> deletedDistributionList = new HashSet<DistributionSetIdName>();
|
private final Set<DistributionSetIdName> deletedDistributionList = new HashSet<>();
|
||||||
|
|
||||||
private Set<DistributionSetIdName> selectedDistributions = new HashSet<DistributionSetIdName>();
|
private Set<DistributionSetIdName> selectedDistributions = new HashSet<>();
|
||||||
|
|
||||||
private DistributionSetIdName lastSelectedDistribution;
|
private DistributionSetIdName lastSelectedDistribution;
|
||||||
|
|
||||||
@@ -66,9 +66,9 @@ public class ManageDistUIState implements Serializable {
|
|||||||
|
|
||||||
private boolean isDsTableMaximized = Boolean.FALSE;
|
private boolean isDsTableMaximized = Boolean.FALSE;
|
||||||
|
|
||||||
private final Map<String, SoftwareModuleIdName> assignedSoftwareModuleDetails = new HashMap<String, SoftwareModuleIdName>();
|
private final Map<String, SoftwareModuleIdName> assignedSoftwareModuleDetails = new HashMap<>();
|
||||||
|
|
||||||
private final Map<DistributionSetIdName, Map<Long, Set<SoftwareModuleIdName>>> consolidatedDistSoftwarewList = new HashMap<DistributionSetIdName, Map<Long, Set<SoftwareModuleIdName>>>();
|
private final Map<DistributionSetIdName, HashMap<Long, HashSet<SoftwareModuleIdName>>> consolidatedDistSoftwarewList = new HashMap<>();
|
||||||
|
|
||||||
private boolean noDataAvilableSwModule = Boolean.FALSE;
|
private boolean noDataAvilableSwModule = Boolean.FALSE;
|
||||||
|
|
||||||
@@ -89,10 +89,11 @@ public class ManageDistUIState implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Need HashSet because the Set have to be serializable
|
||||||
*
|
*
|
||||||
* @return the assignedList
|
* @return the assignedList
|
||||||
*/
|
*/
|
||||||
public Map<DistributionSetIdName, Set<SoftwareModuleIdName>> getAssignedList() {
|
public Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> getAssignedList() {
|
||||||
return assignedList;
|
return assignedList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +120,7 @@ public class ManageDistUIState implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedDistributions(final Set<DistributionSetIdName> slectedDistributions) {
|
public void setSelectedDistributions(final Set<DistributionSetIdName> slectedDistributions) {
|
||||||
this.selectedDistributions = slectedDistributions;
|
selectedDistributions = slectedDistributions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,7 +141,7 @@ public class ManageDistUIState implements Serializable {
|
|||||||
* @return the selectedBaseSwModuleId
|
* @return the selectedBaseSwModuleId
|
||||||
*/
|
*/
|
||||||
public Optional<Long> getSelectedBaseSwModuleId() {
|
public Optional<Long> getSelectedBaseSwModuleId() {
|
||||||
return this.selectedBaseSwModuleId != null ? Optional.of(this.selectedBaseSwModuleId) : Optional.empty();
|
return selectedBaseSwModuleId != null ? Optional.of(selectedBaseSwModuleId) : Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -227,7 +228,7 @@ public class ManageDistUIState implements Serializable {
|
|||||||
* @param isDsModuleTableMaximized
|
* @param isDsModuleTableMaximized
|
||||||
*/
|
*/
|
||||||
public void setDsTableMaximized(final boolean isDsModuleTableMaximized) {
|
public void setDsTableMaximized(final boolean isDsModuleTableMaximized) {
|
||||||
this.isDsTableMaximized = isDsModuleTableMaximized;
|
isDsTableMaximized = isDsModuleTableMaximized;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, SoftwareModuleIdName> getAssignedSoftwareModuleDetails() {
|
public Map<String, SoftwareModuleIdName> getAssignedSoftwareModuleDetails() {
|
||||||
@@ -279,7 +280,12 @@ public class ManageDistUIState implements Serializable {
|
|||||||
this.noDataAvailableDist = noDataAvailableDist;
|
this.noDataAvailableDist = noDataAvailableDist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<DistributionSetIdName, Map<Long, Set<SoftwareModuleIdName>>> getConsolidatedDistSoftwarewList() {
|
/**
|
||||||
|
* Need HashSet because the Set have to be serializable
|
||||||
|
*
|
||||||
|
* @return map
|
||||||
|
*/
|
||||||
|
public Map<DistributionSetIdName, HashMap<Long, HashSet<SoftwareModuleIdName>>> getConsolidatedDistSoftwarewList() {
|
||||||
return consolidatedDistSoftwarewList;
|
return consolidatedDistSoftwarewList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.filtermanagement;
|
package org.eclipse.hawkbit.ui.filtermanagement;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.event.FocusListener;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
@@ -54,6 +56,7 @@ import com.vaadin.ui.HorizontalLayout;
|
|||||||
import com.vaadin.ui.Label;
|
import com.vaadin.ui.Label;
|
||||||
import com.vaadin.ui.Link;
|
import com.vaadin.ui.Link;
|
||||||
import com.vaadin.ui.TextField;
|
import com.vaadin.ui.TextField;
|
||||||
|
import com.vaadin.ui.UI;
|
||||||
import com.vaadin.ui.VerticalLayout;
|
import com.vaadin.ui.VerticalLayout;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
@@ -119,7 +122,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
|
|
||||||
private LayoutClickListener nameLayoutClickListner;
|
private LayoutClickListener nameLayoutClickListner;
|
||||||
|
|
||||||
boolean validationFailed = false;
|
private boolean validationFailed = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the Campaign Status History Header.
|
* Initialize the Campaign Status History Header.
|
||||||
@@ -146,18 +149,19 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
void onEvent(final CustomFilterUIEvent custFUIEvent) {
|
void onEvent(final CustomFilterUIEvent custFUIEvent) {
|
||||||
if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) {
|
if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) {
|
||||||
populateComponents();
|
populateComponents();
|
||||||
eventBus.publish(this, CustomFilterUIEvent.TARGET_DETAILS_VIEW);
|
eventBus.publish(this, CustomFilterUIEvent.TARGET_DETAILS_VIEW);
|
||||||
} else if (custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
|
} else if (custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
|
||||||
setUpCaptionLayout(true);
|
setUpCaptionLayout(true);
|
||||||
resetComponents();
|
resetComponents();
|
||||||
} else if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE) {
|
} else if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE) {
|
||||||
this.getUI().access(() -> showValidationSuccesIcon());
|
this.getUI().access(() -> updateStatusIconAfterTablePopulated());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateComponents() {
|
private void populateComponents() {
|
||||||
if (filterManagementUIState.getTfQuery().isPresent()) {
|
if (filterManagementUIState.getTfQuery().isPresent()) {
|
||||||
@@ -184,16 +188,16 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
|
|
||||||
private Label createStatusIcon() {
|
private Label createStatusIcon() {
|
||||||
final Label statusIcon = new Label();
|
final Label statusIcon = new Label();
|
||||||
|
statusIcon.setImmediate(true);
|
||||||
|
statusIcon.setContentMode(ContentMode.HTML);
|
||||||
|
statusIcon.setSizeFull();
|
||||||
setInitialStatusIconStyle(statusIcon);
|
setInitialStatusIconStyle(statusIcon);
|
||||||
return statusIcon;
|
return statusIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setInitialStatusIconStyle(final Label statusIcon) {
|
private void setInitialStatusIconStyle(final Label statusIcon) {
|
||||||
statusIcon.setContentMode(ContentMode.HTML);
|
|
||||||
statusIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
statusIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
||||||
statusIcon.setImmediate(true);
|
|
||||||
statusIcon.setStyleName("hide-status-label");
|
statusIcon.setStyleName("hide-status-label");
|
||||||
statusIcon.setSizeFull();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createComponents() {
|
private void createComponents() {
|
||||||
@@ -217,9 +221,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
closeIcon = createSearchResetIcon();
|
closeIcon = createSearchResetIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private TextField createNameTextField() {
|
private TextField createNameTextField() {
|
||||||
final TextField nameField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null,
|
final TextField nameField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null,
|
||||||
i18n.get("textfield.customfiltername"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
i18n.get("textfield.customfiltername"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
@@ -255,10 +257,6 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param event
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private void onFiterNameChange(final TextChangeEvent event) {
|
private void onFiterNameChange(final TextChangeEvent event) {
|
||||||
if (isNameAndQueryEmpty(event.getText(), queryTextField.getValue())
|
if (isNameAndQueryEmpty(event.getText(), queryTextField.getValue())
|
||||||
|| (event.getText().equals(oldFilterName) && queryTextField.getValue().equals(oldFilterQuery))) {
|
|| (event.getText().equals(oldFilterName) && queryTextField.getValue().equals(oldFilterQuery))) {
|
||||||
@@ -363,7 +361,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
}
|
}
|
||||||
enableDisableSaveButton(validationFailed, input);
|
enableDisableSaveButton(validationFailed, input);
|
||||||
} else {
|
} else {
|
||||||
removeStatusIcon();
|
setInitialStatusIconStyle(validationIcon);
|
||||||
filterManagementUIState.setFilterQueryValue(null);
|
filterManagementUIState.setFilterQueryValue(null);
|
||||||
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.TRUE);
|
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.TRUE);
|
||||||
}
|
}
|
||||||
@@ -389,17 +387,10 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeStatusIcon() {
|
|
||||||
if (searchLayout.getComponentIndex(validationIcon) != -1) {
|
|
||||||
searchLayout.removeComponent(validationIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showValidationSuccesIcon() {
|
private void showValidationSuccesIcon() {
|
||||||
if (!validationFailed) {
|
|
||||||
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
||||||
validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON);
|
validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showValidationFailureIcon() {
|
private void showValidationFailureIcon() {
|
||||||
@@ -506,9 +497,6 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean doesAlreadyExists() {
|
private boolean doesAlreadyExists() {
|
||||||
if (targetFilterQueryManagement.findTargetFilterQueryByName(nameTextField.getValue()) != null) {
|
if (targetFilterQueryManagement.findTargetFilterQueryByName(nameTextField.getValue()) != null) {
|
||||||
notification.displayValidationError(i18n.get("message.target.filter.duplicate", nameTextField.getValue()));
|
notification.displayValidationError(i18n.get("message.target.filter.duplicate", nameTextField.getValue()));
|
||||||
@@ -517,9 +505,6 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean manadatoryFieldsPresent() {
|
private boolean manadatoryFieldsPresent() {
|
||||||
if (Strings.isNullOrEmpty(nameTextField.getValue())
|
if (Strings.isNullOrEmpty(nameTextField.getValue())
|
||||||
|| Strings.isNullOrEmpty(filterManagementUIState.getFilterQueryValue())) {
|
|| Strings.isNullOrEmpty(filterManagementUIState.getFilterQueryValue())) {
|
||||||
@@ -529,4 +514,11 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateStatusIconAfterTablePopulated() {
|
||||||
|
queryTextField.focus();
|
||||||
|
if (!validationFailed && !Strings.isNullOrEmpty(queryTextField.getValue())) {
|
||||||
|
showValidationSuccesIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
|||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
|
import com.vaadin.server.Sizeable.Unit;
|
||||||
import com.vaadin.shared.ui.label.ContentMode;
|
import com.vaadin.shared.ui.label.ContentMode;
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
@@ -44,6 +45,7 @@ import com.vaadin.ui.Component;
|
|||||||
import com.vaadin.ui.Label;
|
import com.vaadin.ui.Label;
|
||||||
import com.vaadin.ui.Table;
|
import com.vaadin.ui.Table;
|
||||||
import com.vaadin.ui.UI;
|
import com.vaadin.ui.UI;
|
||||||
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -73,12 +75,16 @@ public class CreateOrUpdateFilterTable extends Table {
|
|||||||
*/
|
*/
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
|
setStyleName("sp-table");
|
||||||
setSizeFull();
|
setSizeFull();
|
||||||
|
setImmediate(true);
|
||||||
|
setHeight(100.0f, Unit.PERCENTAGE);
|
||||||
|
addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
|
||||||
|
addStyleName(ValoTheme.TABLE_SMALL);
|
||||||
setColumnCollapsingAllowed(true);
|
setColumnCollapsingAllowed(true);
|
||||||
addCustomGeneratedColumns();
|
addCustomGeneratedColumns();
|
||||||
restoreOnLoad();
|
restoreOnLoad();
|
||||||
populateTableData();
|
populateTableData();
|
||||||
setStyleName("sp-table");
|
|
||||||
setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
|
setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
|
||||||
setSelectable(false);
|
setSelectable(false);
|
||||||
eventBus.subscribe(this);
|
eventBus.subscribe(this);
|
||||||
@@ -95,12 +101,13 @@ public class CreateOrUpdateFilterTable extends Table {
|
|||||||
|| custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
|
|| custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
|
||||||
UI.getCurrent().access(() -> populateTableData());
|
UI.getCurrent().access(() -> populateTableData());
|
||||||
} else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) {
|
} else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) {
|
||||||
this.getUI().access(() -> populateTableData());
|
this.getUI().access(() -> onQuery());
|
||||||
eventBus.publish(this, CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreOnLoad() {
|
|
||||||
|
|
||||||
|
private void restoreOnLoad() {
|
||||||
if (filterManagementUIState.isCreateFilterViewDisplayed()) {
|
if (filterManagementUIState.isCreateFilterViewDisplayed()) {
|
||||||
filterManagementUIState.setFilterQueryValue(null);
|
filterManagementUIState.setFilterQueryValue(null);
|
||||||
} else {
|
} else {
|
||||||
@@ -152,9 +159,6 @@ public class CreateOrUpdateFilterTable extends Table {
|
|||||||
setCollapsibleColumns();
|
setCollapsibleColumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private void setCollapsibleColumns() {
|
private void setCollapsibleColumns() {
|
||||||
setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, true);
|
setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, true);
|
||||||
setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, true);
|
setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, true);
|
||||||
@@ -178,8 +182,8 @@ public class CreateOrUpdateFilterTable extends Table {
|
|||||||
|
|
||||||
private List<TableColumn> getVisbleColumns() {
|
private List<TableColumn> getVisbleColumns() {
|
||||||
final List<TableColumn> columnList = new ArrayList<>();
|
final List<TableColumn> columnList = new ArrayList<>();
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"), 0.15F));
|
columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"),0.15f));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F));
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"),
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"),
|
||||||
@@ -238,4 +242,8 @@ public class CreateOrUpdateFilterTable extends Table {
|
|||||||
addGeneratedColumn(SPUILabelDefinitions.STATUS_ICON, (source, itemId, columnId) -> getStatusIcon(itemId));
|
addGeneratedColumn(SPUILabelDefinitions.STATUS_ICON, (source, itemId, columnId) -> getStatusIcon(itemId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onQuery() {
|
||||||
|
populateTableData();
|
||||||
|
eventBus.publish(this, CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,6 @@ public class FilterManagementView extends VerticalLayout implements View {
|
|||||||
final HorizontalLayout messageLabelLayout = new HorizontalLayout();
|
final HorizontalLayout messageLabelLayout = new HorizontalLayout();
|
||||||
messageLabelLayout.addComponent(targetFilterCountMessageLabel);
|
messageLabelLayout.addComponent(targetFilterCountMessageLabel);
|
||||||
messageLabelLayout.addStyleName("footer-layout");
|
messageLabelLayout.addStyleName("footer-layout");
|
||||||
messageLabelLayout.setWidth("100%");
|
|
||||||
return messageLabelLayout;
|
return messageLabelLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
|||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
|
import com.vaadin.server.Sizeable.Unit;
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
@@ -83,18 +84,20 @@ public class TargetFilterTable extends Table {
|
|||||||
* Initialize the Action History Table.
|
* Initialize the Action History Table.
|
||||||
*/
|
*/
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
addCustomGeneratedColumns();
|
setStyleName("sp-table");
|
||||||
populateTableData();
|
setSizeFull();
|
||||||
setStyleName("sp-table");
|
setImmediate(true);
|
||||||
addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
|
setHeight(100.0f, Unit.PERCENTAGE);
|
||||||
addStyleName(ValoTheme.TABLE_SMALL);
|
addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
|
||||||
setColumnCollapsingAllowed(true);
|
addStyleName(ValoTheme.TABLE_SMALL);
|
||||||
setColumnProperties();
|
addCustomGeneratedColumns();
|
||||||
setId(SPUIComponetIdProvider.TAEGET_FILTER_TABLE_ID);
|
populateTableData();
|
||||||
eventBus.subscribe(this);
|
setColumnCollapsingAllowed(true);
|
||||||
setSizeFull();
|
setColumnProperties();
|
||||||
}
|
setId(SPUIComponetIdProvider.TAEGET_FILTER_TABLE_ID);
|
||||||
|
eventBus.subscribe(this);
|
||||||
|
}
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
void destroy() {
|
void destroy() {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class HawkbitLoginUI extends DefaultHawkbitUI {
|
|||||||
private SpringViewProvider viewProvider;
|
private SpringViewProvider viewProvider;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationContext context;
|
private transient ApplicationContext context;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init(final VaadinRequest request) {
|
protected void init(final VaadinRequest request) {
|
||||||
|
|||||||
@@ -79,10 +79,10 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
|||||||
private I18N i18n;
|
private I18N i18n;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeploymentManagement deploymentManagement;
|
private transient DeploymentManagement deploymentManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EventBus.SessionEventBus eventBus;
|
private transient EventBus.SessionEventBus eventBus;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UINotification notification;
|
private UINotification notification;
|
||||||
@@ -232,7 +232,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
|||||||
* reference of target
|
* reference of target
|
||||||
*/
|
*/
|
||||||
public void populateTableData(final Target selectedTarget) {
|
public void populateTableData(final Target selectedTarget) {
|
||||||
this.target = selectedTarget;
|
target = selectedTarget;
|
||||||
refreshContainer();
|
refreshContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,14 +275,14 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
|||||||
|
|
||||||
final Item item = hierarchicalContainer.addItem(actionWithStatusCount.getActionId());
|
final Item item = hierarchicalContainer.addItem(actionWithStatusCount.getActionId());
|
||||||
|
|
||||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).setValue(
|
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN)
|
||||||
actionWithStatusCount.getActionStatus());
|
.setValue(actionWithStatusCount.getActionStatus());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* add action id.
|
* add action id.
|
||||||
*/
|
*/
|
||||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID).setValue(
|
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID)
|
||||||
actionWithStatusCount.getActionId().toString());
|
.setValue(actionWithStatusCount.getActionId().toString());
|
||||||
/*
|
/*
|
||||||
* add active/inactive status to the item which will be used in
|
* add active/inactive status to the item which will be used in
|
||||||
* Column generator to generate respective icon
|
* Column generator to generate respective icon
|
||||||
@@ -294,28 +294,27 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
|||||||
* add action Id to the item which will be used for fetching child
|
* add action Id to the item which will be used for fetching child
|
||||||
* items ( previous action status ) during expand
|
* items ( previous action status ) during expand
|
||||||
*/
|
*/
|
||||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN).setValue(
|
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN)
|
||||||
actionWithStatusCount.getActionId());
|
.setValue(actionWithStatusCount.getActionId());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* add distribution name to the item which will be displayed in the
|
* add distribution name to the item which will be displayed in the
|
||||||
* table. The name should not exceed certain limit.
|
* table. The name should not exceed certain limit.
|
||||||
*/
|
*/
|
||||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).setValue(
|
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).setValue(HawkbitCommonUtil
|
||||||
HawkbitCommonUtil.getFormattedText(actionWithStatusCount.getDsName() + ":"
|
.getFormattedText(actionWithStatusCount.getDsName() + ":" + actionWithStatusCount.getDsVersion()));
|
||||||
+ actionWithStatusCount.getDsVersion()));
|
|
||||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).setValue(action);
|
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).setValue(action);
|
||||||
|
|
||||||
/* Default no child */
|
/* Default no child */
|
||||||
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), false);
|
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), false);
|
||||||
|
|
||||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME)
|
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME)
|
||||||
.setValue(
|
.setValue(SPDateTimeUtil.getFormattedDate((actionWithStatusCount.getActionLastModifiedAt() != null)
|
||||||
SPDateTimeUtil.getFormattedDate((actionWithStatusCount.getActionLastModifiedAt() != null) ? actionWithStatusCount
|
? actionWithStatusCount.getActionLastModifiedAt()
|
||||||
.getActionLastModifiedAt() : actionWithStatusCount.getActionCreatedAt()));
|
: actionWithStatusCount.getActionCreatedAt()));
|
||||||
|
|
||||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME).setValue(
|
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME)
|
||||||
actionWithStatusCount.getRolloutName());
|
.setValue(actionWithStatusCount.getRolloutName());
|
||||||
|
|
||||||
if (actionWithStatusCount.getActionStatusCount() > 0) {
|
if (actionWithStatusCount.getActionStatusCount() > 0) {
|
||||||
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), true);
|
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), true);
|
||||||
@@ -390,10 +389,10 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
|||||||
}
|
}
|
||||||
final String distName = (String) hierarchicalContainer.getItem(itemId)
|
final String distName = (String) hierarchicalContainer.getItem(itemId)
|
||||||
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).getValue();
|
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).getValue();
|
||||||
final Label activeStatusIcon = createActiveStatusLabel(
|
final Label activeStatusIcon = createActiveStatusLabel(activeValue,
|
||||||
activeValue,
|
|
||||||
(Action.Status) hierarchicalContainer.getItem(itemId)
|
(Action.Status) hierarchicalContainer.getItem(itemId)
|
||||||
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).getValue() == Action.Status.ERROR);
|
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN)
|
||||||
|
.getValue() == Action.Status.ERROR);
|
||||||
activeStatusIcon.setId(new StringJoiner(".").add(distName).add(itemId.toString())
|
activeStatusIcon.setId(new StringJoiner(".").add(distName).add(itemId.toString())
|
||||||
.add(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE).add(activeValue).toString());
|
.add(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE).add(activeValue).toString());
|
||||||
return activeStatusIcon;
|
return activeStatusIcon;
|
||||||
@@ -447,14 +446,14 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
|||||||
*/
|
*/
|
||||||
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).setValue("");
|
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).setValue("");
|
||||||
|
|
||||||
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).setValue(
|
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST)
|
||||||
HawkbitCommonUtil.getFormattedText(action.getDistributionSet().getName() + ":"
|
.setValue(HawkbitCommonUtil.getFormattedText(action.getDistributionSet().getName() + ":"
|
||||||
+ action.getDistributionSet().getVersion()));
|
+ action.getDistributionSet().getVersion()));
|
||||||
|
|
||||||
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME).setValue(
|
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME)
|
||||||
SPDateTimeUtil.getFormattedDate(actionStatus.getCreatedAt()));
|
.setValue(SPDateTimeUtil.getFormattedDate(actionStatus.getCreatedAt()));
|
||||||
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).setValue(
|
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN)
|
||||||
actionStatus.getStatus());
|
.setValue(actionStatus.getStatus());
|
||||||
showOrHideMessage(childItem, actionStatus);
|
showOrHideMessage(childItem, actionStatus);
|
||||||
/* No further child items allowed for the child items */
|
/* No further child items allowed for the child items */
|
||||||
((Hierarchical) hierarchicalContainer).setChildrenAllowed(childId, false);
|
((Hierarchical) hierarchicalContainer).setChildrenAllowed(childId, false);
|
||||||
@@ -561,13 +560,11 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
|||||||
if (actionWithActiveStatus.isHitAutoForceTime(currentTimeMillis)) {
|
if (actionWithActiveStatus.isHitAutoForceTime(currentTimeMillis)) {
|
||||||
autoForceLabel.setDescription("autoforced");
|
autoForceLabel.setDescription("autoforced");
|
||||||
autoForceLabel.setStyleName(STATUS_ICON_GREEN);
|
autoForceLabel.setStyleName(STATUS_ICON_GREEN);
|
||||||
autoForceLabel.setDescription("auto forced since "
|
autoForceLabel.setDescription("auto forced since " + SPDateTimeUtil
|
||||||
+ SPDateTimeUtil.getDurationFormattedString(actionWithActiveStatus.getForcedTime(),
|
.getDurationFormattedString(actionWithActiveStatus.getForcedTime(), currentTimeMillis, i18n));
|
||||||
currentTimeMillis, i18n));
|
|
||||||
} else {
|
} else {
|
||||||
autoForceLabel.setDescription("auto forcing in "
|
autoForceLabel.setDescription("auto forcing in " + SPDateTimeUtil
|
||||||
+ SPDateTimeUtil.getDurationFormattedString(currentTimeMillis,
|
.getDurationFormattedString(currentTimeMillis, actionWithActiveStatus.getForcedTime(), i18n));
|
||||||
actionWithActiveStatus.getForcedTime(), i18n));
|
|
||||||
autoForceLabel.setStyleName("statusIconPending");
|
autoForceLabel.setStyleName("statusIconPending");
|
||||||
autoForceLabel.setValue(FontAwesome.HISTORY.getHtml());
|
autoForceLabel.setValue(FontAwesome.HISTORY.getHtml());
|
||||||
}
|
}
|
||||||
@@ -776,9 +773,8 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
|||||||
|
|
||||||
private void confirmAndForceQuitAction(final Long actionId) {
|
private void confirmAndForceQuitAction(final Long actionId) {
|
||||||
/* Display the confirmation */
|
/* Display the confirmation */
|
||||||
final ConfirmationDialog confirmDialog = new ConfirmationDialog(
|
final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.forcequit.action.confirmbox"),
|
||||||
i18n.get("caption.forcequit.action.confirmbox"), i18n.get("message.forcequit.action.confirm"),
|
i18n.get("message.forcequit.action.confirm"), i18n.get("button.ok"), i18n.get("button.cancel"), ok -> {
|
||||||
i18n.get("button.ok"), i18n.get("button.cancel"), ok -> {
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
final boolean cancelResult = forceQuitActiveAction(actionId);
|
final boolean cancelResult = forceQuitActiveAction(actionId);
|
||||||
if (cancelResult) {
|
if (cancelResult) {
|
||||||
@@ -793,7 +789,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
|||||||
notification.displayValidationError(i18n.get("message.forcequit.action.failed"));
|
notification.displayValidationError(i18n.get("message.forcequit.action.failed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, FontAwesome.WARNING);
|
} , FontAwesome.WARNING);
|
||||||
UI.getCurrent().addWindow(confirmDialog.getWindow());
|
UI.getCurrent().addWindow(confirmDialog.getWindow());
|
||||||
confirmDialog.getWindow().bringToFront();
|
confirmDialog.getWindow().bringToFront();
|
||||||
}
|
}
|
||||||
@@ -880,8 +876,8 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
|||||||
|
|
||||||
if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()
|
if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()
|
||||||
&& null != managementUIState.getDistributionTableFilters().getPinnedTargetId().get()) {
|
&& null != managementUIState.getDistributionTableFilters().getPinnedTargetId().get()) {
|
||||||
final String alreadyPinnedControllerId = managementUIState.getDistributionTableFilters()
|
final String alreadyPinnedControllerId = managementUIState.getDistributionTableFilters().getPinnedTargetId()
|
||||||
.getPinnedTargetId().get();
|
.get();
|
||||||
// if the current target is pinned publish a pin event again
|
// if the current target is pinned publish a pin event again
|
||||||
if (null != alreadyPinnedControllerId && alreadyPinnedControllerId.equals(target.getControllerId())) {
|
if (null != alreadyPinnedControllerId && alreadyPinnedControllerId.equals(target.getControllerId())) {
|
||||||
eventBus.publish(this, PinUnpinEvent.PIN_TARGET);
|
eventBus.publish(this, PinUnpinEvent.PIN_TARGET);
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ import com.vaadin.ui.Alignment;
|
|||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
import com.vaadin.ui.CheckBox;
|
import com.vaadin.ui.CheckBox;
|
||||||
import com.vaadin.ui.ComboBox;
|
import com.vaadin.ui.ComboBox;
|
||||||
|
import com.vaadin.ui.Component;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
import com.vaadin.ui.Label;
|
import com.vaadin.ui.Label;
|
||||||
import com.vaadin.ui.TextArea;
|
import com.vaadin.ui.TextArea;
|
||||||
@@ -109,7 +110,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
private String originalDistDescription;
|
private String originalDistDescription;
|
||||||
private Boolean originalReqMigStep;
|
private Boolean originalReqMigStep;
|
||||||
private String originalDistSetType;
|
private String originalDistSetType;
|
||||||
private final List<Object> changedComponents = new ArrayList<Object>();
|
private final List<Component> changedComponents = new ArrayList<>();
|
||||||
private ValueChangeListener reqMigStepCheckboxListerner;
|
private ValueChangeListener reqMigStepCheckboxListerner;
|
||||||
private TextChangeListener descTextAreaListener;
|
private TextChangeListener descTextAreaListener;
|
||||||
private TextChangeListener distNameTextFieldListener;
|
private TextChangeListener distNameTextFieldListener;
|
||||||
@@ -201,8 +202,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private LazyQueryContainer getDistSetTypeLazyQueryContainer() {
|
private LazyQueryContainer getDistSetTypeLazyQueryContainer() {
|
||||||
final Map<String, Object> queryConfig = new HashMap<String, Object>();
|
final Map<String, Object> queryConfig = new HashMap<>();
|
||||||
final BeanQueryFactory<DistributionSetTypeBeanQuery> dtQF = new BeanQueryFactory<DistributionSetTypeBeanQuery>(
|
final BeanQueryFactory<DistributionSetTypeBeanQuery> dtQF = new BeanQueryFactory<>(
|
||||||
DistributionSetTypeBeanQuery.class);
|
DistributionSetTypeBeanQuery.class);
|
||||||
dtQF.setQueryConfiguration(queryConfig);
|
dtQF.setQueryConfiguration(queryConfig);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.management.footer;
|
package org.eclipse.hawkbit.ui.management.footer;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
|
|
||||||
@@ -69,7 +68,7 @@ public final class DeleteActionsLayoutHelper {
|
|||||||
* @return true if it component is target table
|
* @return true if it component is target table
|
||||||
*/
|
*/
|
||||||
public static boolean isTargetTable(final Component source) {
|
public static boolean isTargetTable(final Component source) {
|
||||||
return HawkbitCommonUtil.bothSame(source.getId(), SPUIComponetIdProvider.TARGET_TABLE_ID);
|
return SPUIComponetIdProvider.TARGET_TABLE_ID.equalsIgnoreCase(source.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,7 +79,7 @@ public final class DeleteActionsLayoutHelper {
|
|||||||
* @return true if it component is distribution table
|
* @return true if it component is distribution table
|
||||||
*/
|
*/
|
||||||
public static boolean isDistributionTable(final Component source) {
|
public static boolean isDistributionTable(final Component source) {
|
||||||
return HawkbitCommonUtil.bothSame(source.getId(), SPUIComponetIdProvider.DIST_TABLE_ID);
|
return SPUIComponetIdProvider.DIST_TABLE_ID.equalsIgnoreCase(source.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -35,17 +35,19 @@ public class ManagementUIState implements Serializable {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 7301409196969723794L;
|
private static final long serialVersionUID = 7301409196969723794L;
|
||||||
|
|
||||||
|
private final transient Set<Object> expandParentActionRowId = new HashSet<>();
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DistributionTableFilters distributionTableFilters;
|
private DistributionTableFilters distributionTableFilters;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TargetTableFilters targetTableFilters;
|
private TargetTableFilters targetTableFilters;
|
||||||
|
|
||||||
private final Map<TargetIdName, DistributionSetIdName> assignedList = new HashMap<TargetIdName, DistributionSetIdName>();
|
private final Map<TargetIdName, DistributionSetIdName> assignedList = new HashMap<>();
|
||||||
|
|
||||||
private final Set<DistributionSetIdName> deletedDistributionList = new HashSet<DistributionSetIdName>();
|
private final Set<DistributionSetIdName> deletedDistributionList = new HashSet<>();
|
||||||
|
|
||||||
private final Set<TargetIdName> deletedTargetList = new HashSet<TargetIdName>();
|
private final Set<TargetIdName> deletedTargetList = new HashSet<>();
|
||||||
|
|
||||||
private Boolean targetTagLayoutVisible = Boolean.TRUE;
|
private Boolean targetTagLayoutVisible = Boolean.TRUE;
|
||||||
|
|
||||||
@@ -79,9 +81,7 @@ public class ManagementUIState implements Serializable {
|
|||||||
|
|
||||||
private boolean noDataAvailableDistribution = Boolean.FALSE;
|
private boolean noDataAvailableDistribution = Boolean.FALSE;
|
||||||
|
|
||||||
private final Set<String> canceledTargetName = new HashSet<String>();
|
private final Set<String> canceledTargetName = new HashSet<>();
|
||||||
|
|
||||||
private final Set<Object> expandParentActionRowId = new HashSet<Object>();
|
|
||||||
|
|
||||||
private boolean customFilterSelected;
|
private boolean customFilterSelected;
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ public class ManagementUIState implements Serializable {
|
|||||||
* the isCustomFilterSelected to set
|
* the isCustomFilterSelected to set
|
||||||
*/
|
*/
|
||||||
public void setCustomFilterSelected(final boolean isCustomFilterSelected) {
|
public void setCustomFilterSelected(final boolean isCustomFilterSelected) {
|
||||||
this.customFilterSelected = isCustomFilterSelected;
|
customFilterSelected = isCustomFilterSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Object> getExpandParentActionRowId() {
|
public Set<Object> getExpandParentActionRowId() {
|
||||||
@@ -134,7 +134,7 @@ public class ManagementUIState implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setTargetTagLayoutVisible(final Boolean targetTagVisible) {
|
public void setTargetTagLayoutVisible(final Boolean targetTagVisible) {
|
||||||
this.targetTagLayoutVisible = targetTagVisible;
|
targetTagLayoutVisible = targetTagVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getTargetTagLayoutVisible() {
|
public Boolean getTargetTagLayoutVisible() {
|
||||||
@@ -241,16 +241,16 @@ public class ManagementUIState implements Serializable {
|
|||||||
* increments the targets all counter.
|
* increments the targets all counter.
|
||||||
*/
|
*/
|
||||||
public void incrementTargetsCountAll() {
|
public void incrementTargetsCountAll() {
|
||||||
this.targetsCountAll.incrementAndGet();
|
targetsCountAll.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* decrement the targets all counter.
|
* decrement the targets all counter.
|
||||||
*/
|
*/
|
||||||
public void decrementTargetsCountAll() {
|
public void decrementTargetsCountAll() {
|
||||||
final long decrementAndGet = this.targetsCountAll.decrementAndGet();
|
final long decrementAndGet = targetsCountAll.decrementAndGet();
|
||||||
if (decrementAndGet < 0) {
|
if (decrementAndGet < 0) {
|
||||||
this.targetsCountAll.set(0);
|
targetsCountAll.set(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,12 +56,7 @@ import com.vaadin.ui.components.colorpicker.ColorSelector;
|
|||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Abstract class for create/update target tag layout.
|
* Abstract class for create/update target tag layout.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class CreateUpdateTagLayout extends CustomComponent implements ColorChangeListener, ColorSelector {
|
public abstract class CreateUpdateTagLayout extends CustomComponent implements ColorChangeListener, ColorSelector {
|
||||||
private static final long serialVersionUID = 4229177824620576456L;
|
private static final long serialVersionUID = 4229177824620576456L;
|
||||||
@@ -78,7 +73,7 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
protected I18N i18n;
|
protected I18N i18n;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected TagManagement tagManagement;
|
protected transient TagManagement tagManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected transient EventBus.SessionEventBus eventBus;
|
protected transient EventBus.SessionEventBus eventBus;
|
||||||
@@ -202,7 +197,7 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
getPreviewButtonColor(DEFAULT_COLOR);
|
getPreviewButtonColor(DEFAULT_COLOR);
|
||||||
tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
|
tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
|
||||||
|
|
||||||
selectors = new HashSet<ColorSelector>();
|
selectors = new HashSet<>();
|
||||||
selectedColor = new Color(44, 151, 32);
|
selectedColor = new Color(44, 151, 32);
|
||||||
selPreview = new SpColorPickerPreview(selectedColor);
|
selPreview = new SpColorPickerPreview(selectedColor);
|
||||||
|
|
||||||
@@ -284,28 +279,7 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
*/
|
*/
|
||||||
private void previewButtonClicked() {
|
private void previewButtonClicked() {
|
||||||
if (!tagPreviewBtnClicked) {
|
if (!tagPreviewBtnClicked) {
|
||||||
final String selectedOption = (String) optiongroup.getValue();
|
setColor();
|
||||||
if (null != selectedOption && selectedOption.equalsIgnoreCase(updateTagNw)) {
|
|
||||||
if (null != tagNameComboBox.getValue()) {
|
|
||||||
|
|
||||||
final TargetTag targetTagSelected = tagManagement
|
|
||||||
.findTargetTag(tagNameComboBox.getValue().toString());
|
|
||||||
if (null != targetTagSelected) {
|
|
||||||
selectedColor = targetTagSelected.getColour() != null
|
|
||||||
? rgbToColorConverter(targetTagSelected.getColour())
|
|
||||||
: rgbToColorConverter(DEFAULT_COLOR);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
final DistributionSetTag distTag = tagManagement
|
|
||||||
.findDistributionSetTag(tagNameComboBox.getValue().toString());
|
|
||||||
selectedColor = distTag.getColour() != null ? rgbToColorConverter(distTag.getColour())
|
|
||||||
: rgbToColorConverter(DEFAULT_COLOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
selectedColor = rgbToColorConverter(DEFAULT_COLOR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
selPreview.setColor(selectedColor);
|
selPreview.setColor(selectedColor);
|
||||||
fieldLayout.addComponent(sliders);
|
fieldLayout.addComponent(sliders);
|
||||||
mainLayout.addComponent(colorPickerLayout);
|
mainLayout.addComponent(colorPickerLayout);
|
||||||
@@ -314,6 +288,31 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
tagPreviewBtnClicked = !tagPreviewBtnClicked;
|
tagPreviewBtnClicked = !tagPreviewBtnClicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setColor() {
|
||||||
|
final String selectedOption = (String) optiongroup.getValue();
|
||||||
|
if (selectedOption == null || !selectedOption.equalsIgnoreCase(updateTagNw)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tagNameComboBox.getValue() == null) {
|
||||||
|
selectedColor = rgbToColorConverter(DEFAULT_COLOR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final TargetTag targetTagSelected = tagManagement.findTargetTag(tagNameComboBox.getValue().toString());
|
||||||
|
|
||||||
|
if (targetTagSelected == null) {
|
||||||
|
final DistributionSetTag distTag = tagManagement
|
||||||
|
.findDistributionSetTag(tagNameComboBox.getValue().toString());
|
||||||
|
selectedColor = distTag.getColour() != null ? rgbToColorConverter(distTag.getColour())
|
||||||
|
: rgbToColorConverter(DEFAULT_COLOR);
|
||||||
|
} else {
|
||||||
|
selectedColor = targetTagSelected.getColour() != null ? rgbToColorConverter(targetTagSelected.getColour())
|
||||||
|
: rgbToColorConverter(DEFAULT_COLOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Covert RGB code to {@Color}.
|
* Covert RGB code to {@Color}.
|
||||||
*
|
*
|
||||||
@@ -322,20 +321,20 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
* @return Color
|
* @return Color
|
||||||
*/
|
*/
|
||||||
protected Color rgbToColorConverter(final String value) {
|
protected Color rgbToColorConverter(final String value) {
|
||||||
if (value.startsWith("rgb")) {
|
if (!value.startsWith("rgb")) {
|
||||||
// RGB color format rgb/rgba(255,255,255,0.1)
|
return null;
|
||||||
final String[] colors = value.substring(value.indexOf('(') + 1, value.length() - 1).split(",");
|
}
|
||||||
final int red = Integer.parseInt(colors[0]);
|
// RGB color format rgb/rgba(255,255,255,0.1)
|
||||||
final int green = Integer.parseInt(colors[1]);
|
final String[] colors = value.substring(value.indexOf('(') + 1, value.length() - 1).split(",");
|
||||||
final int blue = Integer.parseInt(colors[2]);
|
final int red = Integer.parseInt(colors[0]);
|
||||||
if (colors.length > 3) {
|
final int green = Integer.parseInt(colors[1]);
|
||||||
final int alpha = (int) (Double.parseDouble(colors[3]) * 255d);
|
final int blue = Integer.parseInt(colors[2]);
|
||||||
return new Color(red, green, blue, alpha);
|
if (colors.length > 3) {
|
||||||
} else {
|
final int alpha = (int) (Double.parseDouble(colors[3]) * 255d);
|
||||||
return new Color(red, green, blue);
|
return new Color(red, green, blue, alpha);
|
||||||
}
|
} else {
|
||||||
|
return new Color(red, green, blue);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Label getMandatoryLabel() {
|
private Label getMandatoryLabel() {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
package org.eclipse.hawkbit.ui.management.targettag;
|
package org.eclipse.hawkbit.ui.management.targettag;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||||
@@ -54,8 +53,8 @@ public class CustomTargetTagFilterButtonClick extends AbstractFilterSingleButton
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void filterUnClicked(final Button clickedButton) {
|
protected void filterUnClicked(final Button clickedButton) {
|
||||||
managementUIState.getTargetTableFilters().setTargetFilterQuery(null);
|
this.managementUIState.getTargetTableFilters().setTargetFilterQuery(null);
|
||||||
eventBus.publish(this, TargetFilterEvent.REMOVE_FILTER_BY_TARGET_FILTER_QUERY);
|
this.eventBus.publish(this, TargetFilterEvent.REMOVE_FILTER_BY_TARGET_FILTER_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -66,10 +65,10 @@ public class CustomTargetTagFilterButtonClick extends AbstractFilterSingleButton
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void filterClicked(final Button clickedButton) {
|
protected void filterClicked(final Button clickedButton) {
|
||||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
final TargetFilterQuery targetFilterQuery = this.targetFilterQueryManagement
|
||||||
.findTargetFilterQueryById((Long) clickedButton.getData());
|
.findTargetFilterQueryById((Long) clickedButton.getData());
|
||||||
managementUIState.getTargetTableFilters().setTargetFilterQuery(targetFilterQuery);
|
this.managementUIState.getTargetTableFilters().setTargetFilterQuery(targetFilterQuery);
|
||||||
eventBus.publish(this, TargetFilterEvent.FILTER_BY_TARGET_FILTER_QUERY);
|
this.eventBus.publish(this, TargetFilterEvent.FILTER_BY_TARGET_FILTER_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void processButtonClick(final ClickEvent event) {
|
protected void processButtonClick(final ClickEvent event) {
|
||||||
@@ -77,12 +76,12 @@ public class CustomTargetTagFilterButtonClick extends AbstractFilterSingleButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void clearAppliedTargetFilterQuery() {
|
protected void clearAppliedTargetFilterQuery() {
|
||||||
if (getAlreadyClickedButton().isPresent()) {
|
if (getAlreadyClickedButton() != null) {
|
||||||
getAlreadyClickedButton().get().removeStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
|
getAlreadyClickedButton().removeStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
|
||||||
setAlreadyClickedButton(Optional.empty());
|
setAlreadyClickedButton(null);
|
||||||
}
|
}
|
||||||
managementUIState.getTargetTableFilters().setTargetFilterQuery(null);
|
this.managementUIState.getTargetTableFilters().setTargetFilterQuery(null);
|
||||||
eventBus.publish(this, TargetFilterEvent.REMOVE_FILTER_BY_TARGET_FILTER_QUERY);
|
this.eventBus.publish(this, TargetFilterEvent.REMOVE_FILTER_BY_TARGET_FILTER_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setDefaultButtonClicked(final Button button) {
|
protected void setDefaultButtonClicked(final Button button) {
|
||||||
|
|||||||
@@ -197,33 +197,36 @@ public class RolloutGroupTargetsListTable extends AbstractSimpleTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setRolloutStatusIcon(final Status targetUpdateStatus, final Label statusLabel) {
|
private void setRolloutStatusIcon(final Status targetUpdateStatus, final Label statusLabel) {
|
||||||
switch (targetUpdateStatus) {
|
switch (targetUpdateStatus) {
|
||||||
case ERROR:
|
case ERROR:
|
||||||
statusLabel.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
|
statusLabel.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
|
||||||
statusLabel.addStyleName("statusIconRed");
|
statusLabel.addStyleName("statusIconRed");
|
||||||
break;
|
break;
|
||||||
case SCHEDULED:
|
case SCHEDULED:
|
||||||
statusLabel.setValue(FontAwesome.BULLSEYE.getHtml());
|
statusLabel.setValue(FontAwesome.BULLSEYE.getHtml());
|
||||||
statusLabel.addStyleName("statusIconBlue");
|
statusLabel.addStyleName("statusIconBlue");
|
||||||
break;
|
break;
|
||||||
case FINISHED:
|
case FINISHED:
|
||||||
statusLabel.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
statusLabel.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
||||||
statusLabel.addStyleName("statusIconGreen");
|
statusLabel.addStyleName("statusIconGreen");
|
||||||
break;
|
break;
|
||||||
case RUNNING:
|
case RUNNING:
|
||||||
case RETRIEVED:
|
case RETRIEVED:
|
||||||
case WARNING:
|
case WARNING:
|
||||||
case DOWNLOAD:
|
case DOWNLOAD:
|
||||||
statusLabel.setValue(FontAwesome.ADJUST.getHtml());
|
statusLabel.setValue(FontAwesome.ADJUST.getHtml());
|
||||||
statusLabel.addStyleName("statusIconYellow");
|
statusLabel.addStyleName("statusIconYellow");
|
||||||
break;
|
break;
|
||||||
case CANCELED:
|
case CANCELED:
|
||||||
case CANCELING:
|
statusLabel.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
|
||||||
statusLabel.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
|
statusLabel.addStyleName("statusIconGreen");
|
||||||
statusLabel.addStyleName("statusIconPending");
|
break;
|
||||||
break;
|
case CANCELING:
|
||||||
default:
|
statusLabel.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
|
||||||
break;
|
statusLabel.addStyleName("statusIconPending");
|
||||||
}
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.tenantconfiguration.authentication;
|
package org.eclipse.hawkbit.ui.tenantconfiguration.authentication;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import com.vaadin.ui.Component;
|
import com.vaadin.ui.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,7 +64,8 @@ public interface TenantConfigurationItem extends Component {
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
interface TenantConfigurationChangeListener {
|
@FunctionalInterface
|
||||||
|
interface TenantConfigurationChangeListener extends Serializable {
|
||||||
/**
|
/**
|
||||||
* called to notify about configuration has been changed.
|
* called to notify about configuration has been changed.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -263,14 +263,13 @@ public final class HawkbitCommonUtil {
|
|||||||
public static String concatStrings(final String delimiter, final String... texts) {
|
public static String concatStrings(final String delimiter, final String... texts) {
|
||||||
final String delim = delimiter == null ? SP_STRING_EMPTY : delimiter;
|
final String delim = delimiter == null ? SP_STRING_EMPTY : delimiter;
|
||||||
final StringBuilder conCatStrBldr = new StringBuilder();
|
final StringBuilder conCatStrBldr = new StringBuilder();
|
||||||
String conCatedStr = null;
|
|
||||||
if (null != texts) {
|
if (null != texts) {
|
||||||
for (final String text : texts) {
|
for (final String text : texts) {
|
||||||
conCatStrBldr.append(delim);
|
conCatStrBldr.append(delim);
|
||||||
conCatStrBldr.append(text);
|
conCatStrBldr.append(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conCatedStr = conCatStrBldr.toString();
|
final String conCatedStr = conCatStrBldr.toString();
|
||||||
return delim.length() > 0 && conCatedStr.startsWith(delim) ? conCatedStr.substring(1) : conCatedStr;
|
return delim.length() > 0 && conCatedStr.startsWith(delim) ? conCatedStr.substring(1) : conCatedStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,31 +342,6 @@ public final class HawkbitCommonUtil {
|
|||||||
return labelId.toString();
|
return labelId.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if two objects are same or not.
|
|
||||||
*
|
|
||||||
* @param obj1
|
|
||||||
* as reference
|
|
||||||
* @param obj2
|
|
||||||
* as reference
|
|
||||||
* @return true if both obj1 & obj2 are null (or) if the .equals() method
|
|
||||||
* return true. false if only either one of obj1 & obj2 is null (or)
|
|
||||||
* if .equals() method return false.
|
|
||||||
*/
|
|
||||||
public static boolean bothSame(final Object obj1, final Object obj2) {
|
|
||||||
boolean result = false;
|
|
||||||
if (obj1 == null && obj2 == null) {
|
|
||||||
result = true;
|
|
||||||
} else if (obj1 == null && obj2 != null) {
|
|
||||||
result = false;
|
|
||||||
} else if (obj1 != null && obj2 == null) {
|
|
||||||
result = false;
|
|
||||||
} else {
|
|
||||||
result = obj2.equals(obj1);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get label with software module name and description.
|
* Get label with software module name and description.
|
||||||
*
|
*
|
||||||
@@ -725,7 +699,7 @@ public final class HawkbitCommonUtil {
|
|||||||
final UserDetailsService idManagement = SpringContextHelper.getBean(UserDetailsService.class);
|
final UserDetailsService idManagement = SpringContextHelper.getBean(UserDetailsService.class);
|
||||||
try {
|
try {
|
||||||
imReslovedUser = HawkbitCommonUtil.getFormattedName(idManagement.loadUserByUsername(uuid));
|
imReslovedUser = HawkbitCommonUtil.getFormattedName(idManagement.loadUserByUsername(uuid));
|
||||||
} catch (final UsernameNotFoundException e) {
|
} catch (final UsernameNotFoundException e) { // NOSONAR
|
||||||
// nope not need to handle
|
// nope not need to handle
|
||||||
}
|
}
|
||||||
// If Null display the UID
|
// If Null display the UID
|
||||||
@@ -982,12 +956,10 @@ public final class HawkbitCommonUtil {
|
|||||||
* @return instance of {@link LazyQueryContainer}.
|
* @return instance of {@link LazyQueryContainer}.
|
||||||
*/
|
*/
|
||||||
public static LazyQueryContainer createLazyQueryContainer(
|
public static LazyQueryContainer createLazyQueryContainer(
|
||||||
final BeanQueryFactory<? extends AbstractBeanQuery> queryFactory) {
|
final BeanQueryFactory<? extends AbstractBeanQuery<?>> queryFactory) {
|
||||||
final Map<String, Object> queryConfig = new HashMap<String, Object>();
|
final Map<String, Object> queryConfig = new HashMap<>();
|
||||||
queryFactory.setQueryConfiguration(queryConfig);
|
queryFactory.setQueryConfiguration(queryConfig);
|
||||||
final LazyQueryContainer typeContainer = new LazyQueryContainer(
|
return new LazyQueryContainer(new LazyQueryDefinition(true, 20, SPUILabelDefinitions.VAR_NAME), queryFactory);
|
||||||
new LazyQueryDefinition(true, 20, SPUILabelDefinitions.VAR_NAME), queryFactory);
|
|
||||||
return typeContainer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -998,12 +970,10 @@ public final class HawkbitCommonUtil {
|
|||||||
* @return LazyQueryContainer
|
* @return LazyQueryContainer
|
||||||
*/
|
*/
|
||||||
public static LazyQueryContainer createDSLazyQueryContainer(
|
public static LazyQueryContainer createDSLazyQueryContainer(
|
||||||
final BeanQueryFactory<? extends AbstractBeanQuery> queryFactory) {
|
final BeanQueryFactory<? extends AbstractBeanQuery<?>> queryFactory) {
|
||||||
final Map<String, Object> queryConfig = new HashMap<String, Object>();
|
final Map<String, Object> queryConfig = new HashMap<>();
|
||||||
queryFactory.setQueryConfiguration(queryConfig);
|
queryFactory.setQueryConfiguration(queryConfig);
|
||||||
final LazyQueryContainer typeContainer = new LazyQueryContainer(new LazyQueryDefinition(true, 20, "tagIdName"),
|
return new LazyQueryContainer(new LazyQueryDefinition(true, 20, "tagIdName"), queryFactory);
|
||||||
queryFactory);
|
|
||||||
return typeContainer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1037,7 +1007,7 @@ public final class HawkbitCommonUtil {
|
|||||||
*/
|
*/
|
||||||
public static List<TableColumn> getTableVisibleColumns(final Boolean isMaximized, final Boolean isShowPinColumn,
|
public static List<TableColumn> getTableVisibleColumns(final Boolean isMaximized, final Boolean isShowPinColumn,
|
||||||
final I18N i18n) {
|
final I18N i18n) {
|
||||||
final List<TableColumn> columnList = new ArrayList<TableColumn>();
|
final List<TableColumn> columnList = new ArrayList<>();
|
||||||
if (isMaximized) {
|
if (isMaximized) {
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get(HEADER_NAME), 0.2f));
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get(HEADER_NAME), 0.2f));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get(HEADER_VERSION), 0.1f));
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get(HEADER_VERSION), 0.1f));
|
||||||
|
|||||||
Reference in New Issue
Block a user