Reduce some duplicate code

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-04-04 12:59:45 +02:00
parent 861c92cb9d
commit 044f0bef03
58 changed files with 371 additions and 1248 deletions

View File

@@ -8,6 +8,7 @@
*/
package org.eclipse.hawkbit.repository;
import java.util.Collections;
import java.util.List;
import org.eclipse.hawkbit.repository.model.AssignmentResult;
@@ -19,7 +20,7 @@ import org.eclipse.hawkbit.repository.model.Target;
* how much of the assignments had already been existed.
*
*/
public class DistributionSetAssignmentResult extends AssignmentResult {
public class DistributionSetAssignmentResult extends AssignmentResult<Target> {
private final List<String> assignedTargets;
private final List<Long> actions;
@@ -45,16 +46,14 @@ public class DistributionSetAssignmentResult extends AssignmentResult {
*/
public DistributionSetAssignmentResult(final List<String> assignedTargets, final int assigned,
final int alreadyAssigned, final List<Long> actions, final TargetManagement targetManagement) {
super(assigned, alreadyAssigned);
super(assigned, alreadyAssigned, 0, Collections.emptyList(), Collections.emptyList());
this.assignedTargets = assignedTargets;
this.actions = actions;
this.targetManagement = targetManagement;
}
/**
* @return the assignedTargets
*/
public List<Target> getAssignedTargets() {
@Override
public List<Target> getAssignedEntity() {
return targetManagement.findTargetByControllerID(assignedTargets);
}

View File

@@ -8,15 +8,21 @@
*/
package org.eclipse.hawkbit.repository.model;
import java.util.List;
/**
* Generic assignment result bean.
*
*/
public class AssignmentResult {
public class AssignmentResult<T extends BaseEntity> {
private final int total;
private final int assigned;
private final int alreadyAssigned;
private final int unassigned;
private final List<T> assignedEntity;
private final List<T> unassignedEntity;
/**
* Constructor.
@@ -24,25 +30,47 @@ public class AssignmentResult {
* @param assigned
* is the number of newly assigned elements.
* @param alreadyAssigned
* is the number of already assigned elements.
* number of already assigned/ignored elements
* @param unassigned
* number of newly assigned elements
* @param assignedEntity
* {@link List} of assigned entity.
* @param unassignedEntity
* {@link List} of unassigned entity.
*/
public AssignmentResult(final int assigned, final int alreadyAssigned) {
super();
public AssignmentResult(final int assigned, final int alreadyAssigned, final int unassigned,
final List<T> assignedEntity, final List<T> unassignedEntity) {
this.assigned = assigned;
this.alreadyAssigned = alreadyAssigned;
total = assigned + alreadyAssigned;
this.unassigned = unassigned;
this.assignedEntity = assignedEntity;
this.unassignedEntity = unassignedEntity;
}
public int getAssigned() {
return assigned;
}
public int getTotal() {
return total;
}
public int getAlreadyAssigned() {
return alreadyAssigned;
}
public int getUnassigned() {
return unassigned;
}
public List<T> getAssignedEntity() {
return assignedEntity;
}
public List<T> getUnassignedEntity() {
return unassignedEntity;
}
}

View File

@@ -14,11 +14,8 @@ import java.util.List;
* Result object for {@link DistributionSetTag} assignments.
*
*/
public class DistributionSetTagAssignmentResult extends AssignmentResult {
public class DistributionSetTagAssignmentResult extends AssignmentResult<DistributionSet> {
private final int unassigned;
private final List<DistributionSet> assignedDs;
private final List<DistributionSet> unassignedDs;
private final DistributionSetTag distributionSetTag;
/**
@@ -40,27 +37,13 @@ public class DistributionSetTagAssignmentResult extends AssignmentResult {
public DistributionSetTagAssignmentResult(final int alreadyAssigned, final int assigned, final int unassigned,
final List<DistributionSet> assignedDs, final List<DistributionSet> unassignedDs,
final DistributionSetTag distributionSetTag) {
super(assigned, alreadyAssigned);
this.unassigned = unassigned;
this.assignedDs = assignedDs;
this.unassignedDs = unassignedDs;
super(assigned, alreadyAssigned,unassigned, assignedDs, unassignedDs);
this.distributionSetTag = distributionSetTag;
}
public int getUnassigned() {
return unassigned;
}
public DistributionSetTag getDistributionSetTag() {
return distributionSetTag;
}
public List<DistributionSet> getAssignedDs() {
return assignedDs;
}
public List<DistributionSet> getUnassignedDs() {
return unassignedDs;
}
}

View File

@@ -14,11 +14,8 @@ import java.util.List;
* Result object for {@link TargetTag} assignments.
*
*/
public class TargetTagAssignmentResult extends AssignmentResult {
public class TargetTagAssignmentResult extends AssignmentResult<Target> {
private final int unassigned;
private final List<Target> assignedTargets;
private final List<Target> unassignedTargets;
private final TargetTag targetTag;
/**
@@ -39,25 +36,10 @@ public class TargetTagAssignmentResult extends AssignmentResult {
*/
public TargetTagAssignmentResult(final int alreadyAssigned, final int assigned, final int unassigned,
final List<Target> assignedTargets, final List<Target> unassignedTargets, final TargetTag targetTag) {
super(assigned, alreadyAssigned);
this.unassigned = unassigned;
this.assignedTargets = assignedTargets;
this.unassignedTargets = unassignedTargets;
super(assigned, alreadyAssigned, unassigned, assignedTargets, unassignedTargets);
this.targetTag = targetTag;
}
public int getUnassigned() {
return unassigned;
}
public List<Target> getAssignedTargets() {
return assignedTargets;
}
public List<Target> getUnassignedTargets() {
return unassignedTargets;
}
public TargetTag getTargetTag() {
return targetTag;
}

View File

@@ -48,7 +48,7 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
assertThat(savedTarget.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.UNKNOWN);
savedTarget = deploymentManagement.assignDistributionSet(ds, toAssign).getAssignedTargets().iterator().next();
savedTarget = deploymentManagement.assignDistributionSet(ds, toAssign).getAssignedEntity().iterator().next();
final Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
assertThat(targetManagement.findTargetByControllerID(savedTarget.getControllerId()).getTargetInfo()
@@ -104,7 +104,7 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
Target savedTarget = targetManagement.createTarget(target);
final List<Target> toAssign = new ArrayList<>();
toAssign.add(savedTarget);
savedTarget = deploymentManagement.assignDistributionSet(ds, toAssign).getAssignedTargets().iterator().next();
savedTarget = deploymentManagement.assignDistributionSet(ds, toAssign).getAssignedEntity().iterator().next();
Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
// test and verify

View File

@@ -155,8 +155,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
List<Target> targets = targetManagement
.createTargets(TestDataUtil.generateTargets(Constants.MAX_ENTRIES_IN_STATEMENT + 10));
targets = deploymentManagement.assignDistributionSet(cancelDs, targets).getAssignedTargets();
targets = deploymentManagement.assignDistributionSet(cancelDs2, targets).getAssignedTargets();
targets = deploymentManagement.assignDistributionSet(cancelDs, targets).getAssignedEntity();
targets = deploymentManagement.assignDistributionSet(cancelDs2, targets).getAssignedEntity();
targetManagement.findAllTargetIds().forEach(targetIdName -> {
assertThat(deploymentManagement.findActiveActionsByTarget(
@@ -604,7 +604,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
// activeActions, add a corresponding cancelAction and another
// UpdateAction for dsA
final Iterable<Target> deployed2DS = deploymentManagement
.assignDistributionSet(dsA, deployResWithDsB.getDeployedTargets()).getAssignedTargets();
.assignDistributionSet(dsA, deployResWithDsB.getDeployedTargets()).getAssignedEntity();
actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(1);
// get final updated version of targets
@@ -761,7 +761,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
targs.add(targ);
// doing the assignment
targs = deploymentManagement.assignDistributionSet(dsA, targs).getAssignedTargets();
targs = deploymentManagement.assignDistributionSet(dsA, targs).getAssignedEntity();
targ = targetManagement.findTargetByControllerID(targs.iterator().next().getControllerId());
// checking the revisions of the created entities
@@ -799,7 +799,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
assertEquals("wrong installed ds", dsA, targ.getTargetInfo().getInstalledDistributionSet());
targs = deploymentManagement.assignDistributionSet(dsB.getId(), new String[] { "target-id-A" })
.getAssignedTargets();
.getAssignedEntity();
targ = targs.iterator().next();
@@ -830,7 +830,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
final List<Target> targs = new ArrayList<Target>();
targs.add(targ);
final Iterable<Target> savedTargs = deploymentManagement.assignDistributionSet(dsA, targs).getAssignedTargets();
final Iterable<Target> savedTargs = deploymentManagement.assignDistributionSet(dsA, targs).getAssignedEntity();
targ = savedTargs.iterator().next();
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong").isEqualTo(
@@ -926,7 +926,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
// assigning all DistributionSet to the Target in the list
// deployedTargets
for (final DistributionSet ds : dsList) {
deployedTargets = deploymentManagement.assignDistributionSet(ds, deployedTargets).getAssignedTargets();
deployedTargets = deploymentManagement.assignDistributionSet(ds, deployedTargets).getAssignedEntity();
}
final DeploymentResult deploymentResult = new DeploymentResult(deployedTargets, nakedTargets, dsList,

View File

@@ -495,11 +495,11 @@ public class DistributionSetManagementTest extends AbstractIntegrationTest {
distributionSetManagement.deleteDistributionSet(dsDeleted);
dsDeleted = distributionSetManagement.findDistributionSetById(dsDeleted.getId());
ds100Group1 = distributionSetManagement.toggleTagAssignment(ds100Group1, dsTagA).getAssignedDs();
ds100Group1 = distributionSetManagement.toggleTagAssignment(ds100Group1, dsTagA).getAssignedEntity();
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName());
ds100Group1 = distributionSetManagement.toggleTagAssignment(ds100Group1, dsTagB).getAssignedDs();
ds100Group1 = distributionSetManagement.toggleTagAssignment(ds100Group1, dsTagB).getAssignedEntity();
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName());
ds100Group2 = distributionSetManagement.toggleTagAssignment(ds100Group2, dsTagA).getAssignedDs();
ds100Group2 = distributionSetManagement.toggleTagAssignment(ds100Group2, dsTagA).getAssignedEntity();
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName());
// check setup

View File

@@ -179,29 +179,29 @@ public class TagManagementTest extends AbstractIntegrationTest {
DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(groupA, tag);
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
assertThat(result.getAssigned()).isEqualTo(20);
assertThat(result.getAssignedDs()).containsAll(distributionSetManagement.findDistributionSetListWithDetails(
assertThat(result.getAssignedEntity()).containsAll(distributionSetManagement.findDistributionSetListWithDetails(
groupA.stream().map(set -> set.getId()).collect(Collectors.toList())));
assertThat(result.getUnassigned()).isEqualTo(0);
assertThat(result.getUnassignedDs()).isEmpty();
assertThat(result.getUnassignedEntity()).isEmpty();
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
// toggle A+B -> A is still assigned and B is assigned as well
result = distributionSetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
assertThat(result.getAssigned()).isEqualTo(20);
assertThat(result.getAssignedDs()).containsAll(distributionSetManagement.findDistributionSetListWithDetails(
assertThat(result.getAssignedEntity()).containsAll(distributionSetManagement.findDistributionSetListWithDetails(
groupB.stream().map(set -> set.getId()).collect(Collectors.toList())));
assertThat(result.getUnassigned()).isEqualTo(0);
assertThat(result.getUnassignedDs()).isEmpty();
assertThat(result.getUnassignedEntity()).isEmpty();
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
// toggle A+B -> both unassigned
result = distributionSetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
assertThat(result.getAssigned()).isEqualTo(0);
assertThat(result.getAssignedDs()).isEmpty();
assertThat(result.getAssignedEntity()).isEmpty();
assertThat(result.getUnassigned()).isEqualTo(40);
assertThat(result.getUnassignedDs()).containsAll(distributionSetManagement.findDistributionSetListWithDetails(
assertThat(result.getUnassignedEntity()).containsAll(distributionSetManagement.findDistributionSetListWithDetails(
concat(groupB, groupA).stream().map(set -> set.getId()).collect(Collectors.toList())));
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
@@ -220,29 +220,29 @@ public class TagManagementTest extends AbstractIntegrationTest {
TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(groupA, tag);
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
assertThat(result.getAssigned()).isEqualTo(20);
assertThat(result.getAssignedTargets()).containsAll(targetManagement.findTargetsByControllerIDsWithTags(
assertThat(result.getAssignedEntity()).containsAll(targetManagement.findTargetsByControllerIDsWithTags(
groupA.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
assertThat(result.getUnassigned()).isEqualTo(0);
assertThat(result.getUnassignedTargets()).isEmpty();
assertThat(result.getUnassignedEntity()).isEmpty();
assertThat(result.getTargetTag()).isEqualTo(tag);
// toggle A+B -> A is still assigned and B is assigned as well
result = targetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
assertThat(result.getAssigned()).isEqualTo(20);
assertThat(result.getAssignedTargets()).containsAll(targetManagement.findTargetsByControllerIDsWithTags(
assertThat(result.getAssignedEntity()).containsAll(targetManagement.findTargetsByControllerIDsWithTags(
groupB.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
assertThat(result.getUnassigned()).isEqualTo(0);
assertThat(result.getUnassignedTargets()).isEmpty();
assertThat(result.getUnassignedEntity()).isEmpty();
assertThat(result.getTargetTag()).isEqualTo(tag);
// toggle A+B -> both unassigned
result = targetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
assertThat(result.getAssigned()).isEqualTo(0);
assertThat(result.getAssignedTargets()).isEmpty();
assertThat(result.getAssignedEntity()).isEmpty();
assertThat(result.getUnassigned()).isEqualTo(40);
assertThat(result.getUnassignedTargets()).containsAll(targetManagement.findTargetsByControllerIDsWithTags(
assertThat(result.getUnassignedEntity()).containsAll(targetManagement.findTargetsByControllerIDsWithTags(
concat(groupB, groupA).stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
assertThat(result.getTargetTag()).isEqualTo(tag);

View File

@@ -64,19 +64,19 @@ public class TargetManagementSearchTest extends AbstractIntegrationTest {
final String targetDsAIdPref = "targ-A";
List<Target> targAs = targetManagement.createTargets(
TestDataUtil.buildTargetFixtures(100, targetDsAIdPref, targetDsAIdPref.concat(" description")));
targAs = targetManagement.toggleTagAssignment(targAs, targTagX).getAssignedTargets();
targAs = targetManagement.toggleTagAssignment(targAs, targTagX).getAssignedEntity();
final String targetDsBIdPref = "targ-B";
List<Target> targBs = targetManagement.createTargets(
TestDataUtil.buildTargetFixtures(100, targetDsBIdPref, targetDsBIdPref.concat(" description")));
targBs = targetManagement.toggleTagAssignment(targBs, targTagY).getAssignedTargets();
targBs = targetManagement.toggleTagAssignment(targBs, targTagW).getAssignedTargets();
targBs = targetManagement.toggleTagAssignment(targBs, targTagY).getAssignedEntity();
targBs = targetManagement.toggleTagAssignment(targBs, targTagW).getAssignedEntity();
final String targetDsCIdPref = "targ-C";
List<Target> targCs = targetManagement.createTargets(
TestDataUtil.buildTargetFixtures(100, targetDsCIdPref, targetDsCIdPref.concat(" description")));
targCs = targetManagement.toggleTagAssignment(targCs, targTagZ).getAssignedTargets();
targCs = targetManagement.toggleTagAssignment(targCs, targTagW).getAssignedTargets();
targCs = targetManagement.toggleTagAssignment(targCs, targTagZ).getAssignedEntity();
targCs = targetManagement.toggleTagAssignment(targCs, targTagW).getAssignedEntity();
final String targetDsDIdPref = "targ-D";
final List<Target> targDs = targetManagement.createTargets(
@@ -688,8 +688,8 @@ public class TargetManagementSearchTest extends AbstractIntegrationTest {
final DistributionSet ds = TestDataUtil.generateDistributionSet("a", softwareManagement,
distributionSetManagement);
targAssigned = deploymentManagement.assignDistributionSet(ds, targAssigned).getAssignedTargets();
targInstalled = deploymentManagement.assignDistributionSet(ds, targInstalled).getAssignedTargets();
targAssigned = deploymentManagement.assignDistributionSet(ds, targAssigned).getAssignedEntity();
targInstalled = deploymentManagement.assignDistributionSet(ds, targInstalled).getAssignedEntity();
targInstalled = sendUpdateActionStatusToTargets(ds, targInstalled, Status.FINISHED, "installed");
final Slice<Target> result = targetManagement.findTargetsAllOrderByLinkedDistributionSet(pageReq, ds.getId(),

View File

@@ -49,7 +49,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.auditing.AuditingHandler;
import org.springframework.data.auditing.DateTimeProvider;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.security.authentication.TestingAuthenticationToken;
import org.springframework.security.core.context.SecurityContext;
@@ -132,24 +131,18 @@ public final class RepositoryDataGenerator {
final DistributionSetTag dsTag = tagManagement
.createDistributionSetTag(new DistributionSetTag("For " + group + "s"));
auditingHandler.setDateTimeProvider(new DateTimeProvider() {
@Override
public Calendar getNow() {
final Calendar instance = Calendar.getInstance();
instance.add(Calendar.MONTH, -new Random().nextInt(7));
auditingHandler.setDateTimeProvider(() -> {
final Calendar instance = Calendar.getInstance();
instance.add(Calendar.MONTH, -new Random().nextInt(7));
return instance;
}
return instance;
});
final List<Target> targets = createTargetTestGroup(group, 20 * sizeMultiplikator);
auditingHandler.setDateTimeProvider(new DateTimeProvider() {
@Override
public Calendar getNow() {
final Calendar instance = Calendar.getInstance();
return instance;
}
auditingHandler.setDateTimeProvider(() -> {
final Calendar instance = Calendar.getInstance();
return instance;
});
LOG.debug("initDemoRepo - start now real action history for group: {}", group);
@@ -290,7 +283,7 @@ public final class RepositoryDataGenerator {
LOG.debug("createTargetTestGroup: {} targets status updated including IP", group);
return targetManagement.toggleTagAssignment(targAs, targTag).getAssignedTargets();
return targetManagement.toggleTagAssignment(targAs, targTag).getAssignedEntity();
}
private List<Target> buildTargets(final int noOfTgts, final String descriptionPrefix) {
@@ -328,75 +321,70 @@ public final class RepositoryDataGenerator {
private void initDemoRepo(final int sizeMultiplikator, final int loadtestgroups) {
final LoremIpsum jlorem = new LoremIpsum();
runAsAllAuthorityContext(new Runnable() {
runAsAllAuthorityContext(() -> {
dbCleanupUtil.cleanupDB(null);
@Override
public void run() {
dbCleanupUtil.cleanupDB(null);
// generate targets and assign DS
// 5 groups - 100 targets each -> 500
final String[] targetTestGroups = { "SHC", "CCU", "Vehicle", "Vending machine", "ECU" };
// generate targets and assign DS
// 5 groups - 100 targets each -> 500
final String[] targetTestGroups = { "SHC", "CCU", "Vehicle", "Vending machine", "ECU" };
final String[] modulesTypes = { "HeadUnit_FW", "EDC17_FW", "OSGi_Bundle" };
final String[] modulesTypes = { "HeadUnit_FW", "EDC17_FW", "OSGi_Bundle" };
final DistributionSetTag depTag = tagManagement
.createDistributionSetTag(new DistributionSetTag("deprecated"));
final DistributionSetTag depTag = tagManagement
.createDistributionSetTag(new DistributionSetTag("deprecated"));
Arrays.stream(targetTestGroups).forEach(group -> {
generateTestTagetGroup(group, sizeMultiplikator);
});
Arrays.stream(targetTestGroups).forEach(group -> {
generateTestTagetGroup(group, sizeMultiplikator);
});
// garbage DS
LOG.debug("initDemoRepo - start now DS garbage");
TestDataUtil.generateDistributionSets("Generic Software Package", sizeMultiplikator,
softwareManagement, distributionSetManagement);
LOG.debug("initDemoRepo - DS garbage finished");
// garbage DS
LOG.debug("initDemoRepo - start now DS garbage");
TestDataUtil.generateDistributionSets("Generic Software Package", sizeMultiplikator,
softwareManagement, distributionSetManagement);
LOG.debug("initDemoRepo - DS garbage finished");
LOG.debug("initDemoRepo - start now Extra Software Modules and types");
Arrays.stream(modulesTypes).forEach(typeName -> {
final SoftwareModuleType smtype = softwareManagement.createSoftwareModuleType(
new SoftwareModuleType(typeName.toLowerCase().replaceAll("\\s+", ""), typeName,
jlorem.words(5), Integer.MAX_VALUE));
LOG.debug("initDemoRepo - start now Extra Software Modules and types");
Arrays.stream(modulesTypes).forEach(typeName -> {
final SoftwareModuleType smtype = softwareManagement.createSoftwareModuleType(
new SoftwareModuleType(typeName.toLowerCase().replaceAll("\\s+", ""), typeName,
jlorem.words(5), Integer.MAX_VALUE));
for (int i = 0; i < sizeMultiplikator; i++) {
softwareManagement.createSoftwareModule(new SoftwareModule(smtype, typeName + i, "1.0." + i,
jlorem.words(5), "the " + typeName + " vendor Inc."));
}
});
LOG.debug("initDemoRepo - Extra Software Modules and types finished");
LOG.debug("initDemoRepo - start now target garbage");
// garbage targets
// unknown
targetManagement
.createTargets(TestDataUtil.generateTargets(targetTestGroups.length * sizeMultiplikator));
// registered
targetManagement.createTargets(
TestDataUtil.generateTargets(targetTestGroups.length * sizeMultiplikator, "registered"),
TargetUpdateStatus.REGISTERED, System.currentTimeMillis(), generateIPAddress());
// pending
final DistributionSetTag dsTag = tagManagement
.createDistributionSetTag(new DistributionSetTag("OnlyAssignedTag"));
final DistributionSet ds = TestDataUtil.generateDistributionSet("Pending DS", "v1.0",
softwareManagement, distributionSetManagement,
Arrays.asList(new DistributionSetTag[] { dsTag }));
deploymentManagement.assignDistributionSet(ds, targetManagement.createTargets(
TestDataUtil.generateTargets(targetTestGroups.length * sizeMultiplikator, "pending")));
// Load test means additional 1_000_000 target
for (int i = 0; i < loadtestgroups; i++) {
targetManagement.createTargets(TestDataUtil.generateTargets(i * 1_000, 1_000, "loadtest-"));
for (int i1 = 0; i1 < sizeMultiplikator; i1++) {
softwareManagement.createSoftwareModule(new SoftwareModule(smtype, typeName + i1, "1.0." + i1,
jlorem.words(5), "the " + typeName + " vendor Inc."));
}
LOG.debug("initDemoRepo complete");
});
LOG.debug("initDemoRepo - Extra Software Modules and types finished");
LOG.debug("initDemoRepo - start now target garbage");
// garbage targets
// unknown
targetManagement
.createTargets(TestDataUtil.generateTargets(targetTestGroups.length * sizeMultiplikator));
// registered
targetManagement.createTargets(
TestDataUtil.generateTargets(targetTestGroups.length * sizeMultiplikator, "registered"),
TargetUpdateStatus.REGISTERED, System.currentTimeMillis(), generateIPAddress());
// pending
final DistributionSetTag dsTag = tagManagement
.createDistributionSetTag(new DistributionSetTag("OnlyAssignedTag"));
final DistributionSet ds = TestDataUtil.generateDistributionSet("Pending DS", "v1.0",
softwareManagement, distributionSetManagement,
Arrays.asList(new DistributionSetTag[] { dsTag }));
deploymentManagement.assignDistributionSet(ds, targetManagement.createTargets(
TestDataUtil.generateTargets(targetTestGroups.length * sizeMultiplikator, "pending")));
// Load test means additional 1_000_000 target
for (int i2 = 0; i2 < loadtestgroups; i2++) {
targetManagement.createTargets(TestDataUtil.generateTargets(i2 * 1_000, 1_000, "loadtest-"));
}
LOG.debug("initDemoRepo complete");
});
}
/**

View File

@@ -139,9 +139,9 @@ public class DistributionSetTagResource implements DistributionSetTagRestApi {
final DistributionSetTagAssigmentResultRest tagAssigmentResultRest = new DistributionSetTagAssigmentResultRest();
tagAssigmentResultRest.setAssignedDistributionSets(
DistributionSetMapper.toResponseDistributionSets(assigmentResult.getAssignedDs()));
DistributionSetMapper.toResponseDistributionSets(assigmentResult.getAssignedEntity()));
tagAssigmentResultRest.setUnassignedDistributionSets(
DistributionSetMapper.toResponseDistributionSets(assigmentResult.getUnassignedDs()));
DistributionSetMapper.toResponseDistributionSets(assigmentResult.getUnassignedEntity()));
LOG.debug("Toggled assignedDS {} and unassignedDS{}", assigmentResult.getAssigned(),
assigmentResult.getUnassigned());

View File

@@ -263,7 +263,7 @@ public class TargetResource implements TargetRestApi {
final ActionType type = (dsId.getType() != null)
? RestResourceConversionHelper.convertActionType(dsId.getType()) : ActionType.FORCED;
final Iterator<Target> changed = this.deploymentManagement
.assignDistributionSet(dsId.getId(), type, dsId.getForcetime(), targetId).getAssignedTargets()
.assignDistributionSet(dsId.getId(), type, dsId.getForcetime(), targetId).getAssignedEntity()
.iterator();
if (changed.hasNext()) {
return new ResponseEntity<>(HttpStatus.OK);

View File

@@ -133,8 +133,8 @@ public class TargetTagResource implements TargetTagRestApi {
.toggleTagAssignment(findTargetControllerIds(assignedTargetRequestBodies), targetTag.getName());
final TargetTagAssigmentResultRest tagAssigmentResultRest = new TargetTagAssigmentResultRest();
tagAssigmentResultRest.setAssignedTargets(TargetMapper.toResponse(assigmentResult.getAssignedTargets()));
tagAssigmentResultRest.setUnassignedTargets(TargetMapper.toResponse(assigmentResult.getUnassignedTargets()));
tagAssigmentResultRest.setAssignedTargets(TargetMapper.toResponse(assigmentResult.getAssignedEntity()));
tagAssigmentResultRest.setUnassignedTargets(TargetMapper.toResponse(assigmentResult.getUnassignedEntity()));
return new ResponseEntity<>(tagAssigmentResultRest, HttpStatus.OK);
}

View File

@@ -114,12 +114,12 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB {
assertThat(actionStatusRepository.findAll()).isEmpty();
List<Target> saved = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.FORCED,
Action.NO_FORCE_TIME, savedTarget.getControllerId()).getAssignedTargets();
Action.NO_FORCE_TIME, savedTarget.getControllerId()).getAssignedEntity();
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
assertThat(actionRepository.findAll()).hasSize(1);
saved = deploymentManagement.assignDistributionSet(ds2, saved).getAssignedTargets();
saved = deploymentManagement.assignDistributionSet(ds2, saved).getAssignedEntity();
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(2);
assertThat(actionRepository.findAll()).hasSize(2);
@@ -236,12 +236,12 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB {
List<Target> saved = deploymentManagement
.assignDistributionSet(ds.getId(), ActionType.SOFT, Action.NO_FORCE_TIME, savedTarget.getControllerId())
.getAssignedTargets();
.getAssignedEntity();
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
assertThat(actionRepository.findAll()).hasSize(1);
saved = deploymentManagement.assignDistributionSet(ds2, saved).getAssignedTargets();
saved = deploymentManagement.assignDistributionSet(ds2, saved).getAssignedEntity();
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(2);
assertThat(actionRepository.findAll()).hasSize(2);
@@ -358,12 +358,12 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB {
assertThat(actionStatusRepository.findAll()).isEmpty();
List<Target> saved = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.TIMEFORCED,
System.currentTimeMillis(), savedTarget.getControllerId()).getAssignedTargets();
System.currentTimeMillis(), savedTarget.getControllerId()).getAssignedEntity();
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
assertThat(actionRepository.findAll()).hasSize(1);
saved = deploymentManagement.assignDistributionSet(ds2, saved).getAssignedTargets();
saved = deploymentManagement.assignDistributionSet(ds2, saved).getAssignedEntity();
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(2);
assertThat(actionRepository.findAll()).hasSize(2);
@@ -887,7 +887,7 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB {
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.UNKNOWN);
savedTarget = deploymentManagement.assignDistributionSet(savedSet, toAssign).getAssignedTargets().iterator()
savedTarget = deploymentManagement.assignDistributionSet(savedSet, toAssign).getAssignedEntity().iterator()
.next();
deploymentManagement.assignDistributionSet(savedSet2, toAssign2);

View File

@@ -270,7 +270,7 @@ public class RootControllerTest extends AbstractIntegrationTestWithMongoDB {
Target savedTarget = targetManagement.createTarget(target);
final List<Target> toAssign = new ArrayList<Target>();
toAssign.add(savedTarget);
savedTarget = deploymentManagement.assignDistributionSet(ds, toAssign).getAssignedTargets().iterator().next();
savedTarget = deploymentManagement.assignDistributionSet(ds, toAssign).getAssignedEntity().iterator().next();
final Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
mvc.perform(post("/{tenant}/controller/v1/911/deploymentBase/" + savedAction.getId() + "/feedback",
tenantAware.getCurrentTenant())

View File

@@ -1029,7 +1029,7 @@ public class TargetResourceTest extends AbstractIntegrationTest {
// Update
final List<Target> updatedTargets = deploymentManagement.assignDistributionSet(one, targets)
.getAssignedTargets();
.getAssignedEntity();
// 2nd update
// sleep 10ms to ensure that we can sort by reportedAt
Thread.sleep(10);

View File

@@ -14,12 +14,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -28,8 +23,6 @@ import com.vaadin.ui.Component;
/**
* Upload UI View for Accept criteria.
*
*
*
*/
@SpringComponent
@ViewScope
@@ -41,29 +34,6 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria {
private static final Map<String, Object> DROP_HINTS_CONFIGS = createDropHintConfigurations();
@Autowired
private transient UINotification uiNotification;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Override
protected void analyseDragComponent(final Component compsource) {
final String sourceID = getComponentId(compsource);
final Object event = DROP_HINTS_CONFIGS.get(sourceID);
eventBus.publish(this, event);
}
@Override
protected void hideDropHints() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
}
@Override
protected void invalidDrop() {
uiNotification.displayValidationError(SPUILabelDefinitions.ACTION_NOT_ALLOWED);
}
@Override
protected String getComponentId(final Component component) {
String id = component.getId();
@@ -78,11 +48,6 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria {
return DROP_HINTS_CONFIGS;
}
@Override
protected void publishDragStartEvent(final Object event) {
eventBus.publish(this, event);
}
@Override
protected Map<String, List<String>> getDropConfigurations() {
return DROP_CONFIGS;

View File

@@ -11,22 +11,15 @@ package org.eclipse.hawkbit.ui.artifacts.footer;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -50,18 +43,6 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
private static final long serialVersionUID = -3273982053389866299L;
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient UINotification notification;
@Autowired
private ArtifactUploadState artifactUploadState;
@@ -71,22 +52,6 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Autowired
private UploadViewAcceptCriteria uploadViewAcceptCriteria;
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final UploadArtifactUIEvent event) {
@@ -211,26 +176,11 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
updateActionsCount(count);
}
@Override
protected String getNoActionsButtonLabel() {
return i18n.get("button.no.actions");
}
@Override
protected String getActionsButtonLabel() {
return i18n.get("button.actions");
}
@Override
protected void restoreActionCount() {
updateSWActionCount();
}
@Override
protected String getUnsavedActionsWindowCaption() {
return i18n.get("caption.save.window");
}
@Override
protected void unsavedActionsWindowClosed() {
final String message = uploadViewConfirmationWindowLayout.getConsolidatedMessage();

View File

@@ -8,10 +8,6 @@
*/
package org.eclipse.hawkbit.ui.artifacts.smtable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
@@ -19,10 +15,8 @@ import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractTableDetailsLayout;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -46,38 +40,16 @@ public class SoftwareModuleDetails extends AbstractTableDetailsLayout {
private static final long serialVersionUID = -4900381301076646366L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private SpPermissionChecker permissionChecker;
@Autowired
private SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow;
@Autowired
private ArtifactUploadState artifactUploadState;
private UI ui;
private Long swModuleId;
private SoftwareModule selectedSwModule;
/**
* Initialize the component.
*/
@Override
@PostConstruct
protected void init() {
super.init();
ui = UI.getCurrent();
eventBus.subscribe(this);
}
@Override
protected String getEditButtonId() {
return SPUIComponetIdProvider.UPLOAD_SW_MODULE_EDIT_BUTTON;
@@ -175,58 +147,24 @@ public class SoftwareModuleDetails extends AbstractTableDetailsLayout {
}
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.detailslayout.TableDetailsLayout#
* getDefaultCaption()
*/
@Override
protected String getDefaultCaption() {
return i18n.get("upload.swModuleTable.header");
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.detailslayout.TableDetailsLayout#
* onLoadIsSwModuleSelected()
*/
@Override
protected Boolean onLoadIsTableRowSelected() {
return artifactUploadState.getSelectedBaseSoftwareModule().isPresent();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.detailslayout.TableDetailsLayout#
* onLoadIsTableMaximized()
*/
@Override
protected Boolean onLoadIsTableMaximized() {
return artifactUploadState.isSwModuleTableMaximized();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.detailslayout.TableDetailsLayout#
* populateDetailsWidget()
*/
@Override
protected void populateDetailsWidget() {
populateDetailsWidget(selectedSwModule);
@@ -266,12 +204,7 @@ public class SoftwareModuleDetails extends AbstractTableDetailsLayout {
return permissionChecker.hasUpdateDistributionPermission();
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* getTabSheetId()
*/
@Override
protected String getTabSheetId() {
return null;

View File

@@ -8,20 +8,14 @@
*/
package org.eclipse.hawkbit.ui.artifacts.smtable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -44,31 +38,12 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader {
private static final long serialVersionUID = 242961845006626297L;
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private ArtifactUploadState artifactUploadState;
@Autowired
private SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow;
/**
* Initialize the components.
*/
@Override
@PostConstruct
protected void init() {
super.init();
eventbus.subscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final UploadArtifactUIEvent event) {
if (event == UploadArtifactUIEvent.HIDE_FILTER_BY_TYPE) {
@@ -76,14 +51,6 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader {
}
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventbus.unsubscribe(this);
}
@Override
protected String getHeaderCaption() {

View File

@@ -8,21 +8,17 @@
*/
package org.eclipse.hawkbit.ui.artifacts.smtype;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtonClickBehaviour;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -48,26 +44,6 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
@Autowired
private UploadViewAcceptCriteria uploadViewAcceptCriteria;
@Autowired
private transient EventBus.SessionEventBus eventBus;
/**
* Initialize component.
*
* @param filterButtonClickBehaviour
* the clickable behaviour.
*/
@Override
public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
super.init(filterButtonClickBehaviour);
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleTypeEvent event) {
if (event.getSoftwareModuleTypeEnum() == SoftwareModuleTypeEvent.SoftwareModuleTypeEnum.ADD_SOFTWARE_MODULE_TYPE

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.ui.artifacts.smtype;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
@@ -18,7 +17,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -35,12 +33,6 @@ public class SMTypeFilterHeader extends AbstractFilterHeader {
private static final long serialVersionUID = -4855810338059032342L;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private ArtifactUploadState artifactUploadState;
@@ -84,7 +76,7 @@ public class SMTypeFilterHeader extends AbstractFilterHeader {
@Override
protected void hideFilterButtonLayout() {
artifactUploadState.setSwTypeFilterClosed(true);
eventbus.publish(this, UploadArtifactUIEvent.HIDE_FILTER_BY_TYPE);
eventBus.publish(this, UploadArtifactUIEvent.HIDE_FILTER_BY_TYPE);
}
@Override

View File

@@ -13,8 +13,13 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.acceptcriteria.ServerSideCriterion;
@@ -27,9 +32,6 @@ import com.vaadin.ui.Table;
/**
* Abstract class for Accept criteria.
*
*
*
*
*/
public abstract class AbstractAcceptCriteria extends ServerSideCriterion {
@@ -37,13 +39,12 @@ public abstract class AbstractAcceptCriteria extends ServerSideCriterion {
private int previousRowCount;
/*
* (non-Javadoc)
*
* @see
* com.vaadin.event.dd.acceptcriteria.AcceptCriterion#accept(com.vaadin.
* event.dd.DragAndDropEvent )
*/
@Autowired
protected transient UINotification uiNotification;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
@Override
public boolean accept(final DragAndDropEvent dragEvent) {
final Component compsource = dragEvent.getTransferable().getSourceComponent();
@@ -129,7 +130,7 @@ public abstract class AbstractAcceptCriteria extends ServerSideCriterion {
protected void analyseDragComponent(final Component compsource) {
final String sourceID = getComponentId(compsource);
final Object event = getDropHintConfigurations().get(sourceID);
publishDragStartEvent(event);
eventBus.publish(this, event);
}
/**
@@ -159,23 +160,19 @@ public abstract class AbstractAcceptCriteria extends ServerSideCriterion {
*/
protected abstract String getComponentId(final Component component);
/**
* publish the given event into eventBus.
*
* @param event
* to be published in eventBus.
*/
protected abstract void publishDragStartEvent(Object event);
/**
* Hide the drop hints. Dragging is stopped.
*/
protected abstract void hideDropHints();
protected void hideDropHints() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
}
/**
* Display invalid drop message.
*/
protected abstract void invalidDrop();
protected void invalidDrop() {
uiNotification.displayValidationError(SPUILabelDefinitions.ACTION_NOT_ALLOWED);
}
/**
* @return

View File

@@ -10,6 +10,10 @@ package org.eclipse.hawkbit.ui.common.detailslayout;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
@@ -19,6 +23,8 @@ import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.label.ContentMode;
@@ -27,6 +33,7 @@ import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
/**
@@ -37,6 +44,17 @@ public abstract class AbstractTableDetailsLayout extends VerticalLayout {
private static final long serialVersionUID = 4862529368471627190L;
@Autowired
protected I18N i18n;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
@Autowired
protected SpPermissionChecker permissionChecker;
protected UI ui;
private Label caption;
private Button editButton;
@@ -54,7 +72,9 @@ public abstract class AbstractTableDetailsLayout extends VerticalLayout {
/**
* Initialize components.
*/
@PostConstruct
protected void init() {
ui = UI.getCurrent();
createComponents();
buildLayout();
/**
@@ -62,6 +82,12 @@ public abstract class AbstractTableDetailsLayout extends VerticalLayout {
* selected in table.
*/
restoreState();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
private void createComponents() {

View File

@@ -11,13 +11,17 @@ package org.eclipse.hawkbit.ui.common.filterlayout;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUITagButtonStyle;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus;
import com.vaadin.data.Item;
import com.vaadin.event.dd.DropHandler;
@@ -38,10 +42,13 @@ import com.vaadin.ui.themes.ValoTheme;
public abstract class AbstractFilterButtons extends Table {
private static final long serialVersionUID = 7783305719009746375L;
private static final String DEFAULT_GREEN = "rgb(44,151,32)";
protected static final String FILTER_BUTTON_COLUMN = "filterButton";
@Autowired
protected transient EventBus.SessionEventBus eventBus;
private AbstractFilterButtonClickBehaviour filterButtonClickBehaviour;
@@ -54,6 +61,12 @@ public abstract class AbstractFilterButtons extends Table {
public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
this.filterButtonClickBehaviour = filterButtonClickBehaviour;
createTable();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
private void createTable() {
@@ -88,12 +101,7 @@ public abstract class AbstractFilterButtons extends Table {
@SuppressWarnings("serial")
protected void addColumn() {
addGeneratedColumn(FILTER_BUTTON_COLUMN, new ColumnGenerator() {
@Override
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
return addGeneratedCell(itemId);
}
});
addGeneratedColumn(FILTER_BUTTON_COLUMN, (source, itemId, columnId) -> addGeneratedCell(itemId));
}
/**

View File

@@ -8,10 +8,13 @@
*/
package org.eclipse.hawkbit.ui.common.filterlayout;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.server.FontAwesome;
import com.vaadin.ui.Alignment;
@@ -31,6 +34,13 @@ public abstract class AbstractFilterHeader extends VerticalLayout {
private static final long serialVersionUID = -1388340600522323332L;
@Autowired
protected SpPermissionChecker permChecker;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
private Label title;
private Button config;

View File

@@ -8,12 +8,19 @@
*/
package org.eclipse.hawkbit.ui.common.footer;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropHandler;
@@ -42,6 +49,18 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
private static final long serialVersionUID = -6047975388519155509L;
@Autowired
protected I18N i18n;
@Autowired
protected SpPermissionChecker permChecker;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
@Autowired
protected transient UINotification notification;
private DragAndDropWrapper deleteWrapper;
private Button noActionBtn;
@@ -59,6 +78,12 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
buildLayout();
reload();
}
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
private void reload() {
@@ -311,14 +336,27 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
*
* @return the no actions label.
*/
protected abstract String getNoActionsButtonLabel();
protected String getNoActionsButtonLabel() {
return i18n.get("button.no.actions");
}
/**
* Get the pending actions button label.
*
* @return the actions label.
*/
protected abstract String getActionsButtonLabel();
protected String getActionsButtonLabel() {
return i18n.get("button.actions");
}
/**
* Get caption of unsaved actions window.
*
* @return caption of the window.
*/
protected String getUnsavedActionsWindowCaption() {
return i18n.get("caption.save.window");
}
/**
* reload the count value.
@@ -330,13 +368,6 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
*/
protected abstract void restoreBulkUploadStatusCount();
/**
* Get caption of unsaved actions window.
*
* @return caption of the window.
*/
protected abstract String getUnsavedActionsWindowCaption();
/**
* This method will be called when unsaved actions window is closed.
*/

View File

@@ -8,7 +8,13 @@
*/
package org.eclipse.hawkbit.ui.common.grid;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.data.Container;
import com.vaadin.data.Container.Indexed;
@@ -21,10 +27,18 @@ import com.vaadin.ui.Grid;
public abstract class AbstractGrid extends Grid {
private static final long serialVersionUID = 4856562746502217630L;
@Autowired
protected I18N i18n;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
/**
* Initialize the components.
*/
@PostConstruct
protected void init() {
setSizeFull();
setImmediate(true);
@@ -32,6 +46,12 @@ public abstract class AbstractGrid extends Grid {
setSelectionMode(SelectionMode.NONE);
setColumnReorderingAllowed(true);
addNewContainerDS();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
public void addNewContainerDS() {
@@ -43,13 +63,13 @@ public abstract class AbstractGrid extends Grid {
setColumnHeaderNames();
addColumnRenderes();
CellDescriptionGenerator cellDescriptionGenerator = getDescriptionGenerator();
final CellDescriptionGenerator cellDescriptionGenerator = getDescriptionGenerator();
if (getDescriptionGenerator() != null) {
setCellDescriptionGenerator(cellDescriptionGenerator);
}
// Allow column hiding
for (Column c : getColumns()) {
for (final Column c : getColumns()) {
c.setHidable(true);
}
setHiddenColumns();

View File

@@ -8,13 +8,20 @@
*/
package org.eclipse.hawkbit.ui.common.table;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.event.dd.DropHandler;
import com.vaadin.server.FontAwesome;
@@ -37,6 +44,16 @@ import com.vaadin.ui.VerticalLayout;
public abstract class AbstractTableHeader extends VerticalLayout {
private static final long serialVersionUID = 4881626370291837175L;
@Autowired
protected I18N i18n;
@Autowired
protected SpPermissionChecker permChecker;
@Autowired
protected transient EventBus.SessionEventBus eventbus;
private Label headerCaption;
@@ -59,10 +76,17 @@ public abstract class AbstractTableHeader extends VerticalLayout {
/**
* Initialze components.
*/
@PostConstruct
protected void init() {
createComponents();
buildLayout();
restoreState();
eventbus.subscribe(this);
}
@PreDestroy
void destroy() {
eventbus.unsubscribe(this);
}
private void createComponents() {

View File

@@ -114,7 +114,7 @@ public class DistributionTagToken extends AbstractTagToken {
distributionList.add(selectedDS.getId());
final DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(distributionList,
tagNameSelected);
uinotification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(tagNameSelected, result, i18n));
uinotification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(tagNameSelected, result, i18n));
return result;
}
@@ -214,7 +214,7 @@ public class DistributionTagToken extends AbstractTagToken {
protected boolean isAssign(final DistributionSetTagAssignmentResult assignmentResult) {
if (assignmentResult.getAssigned() > 0) {
final List<Long> assignedDsNames = assignmentResult.getAssignedDs().stream().map(t -> t.getId())
final List<Long> assignedDsNames = assignmentResult.getAssignedEntity().stream().map(t -> t.getId())
.collect(Collectors.toList());
if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) {
return true;
@@ -225,7 +225,7 @@ public class DistributionTagToken extends AbstractTagToken {
protected boolean isUnassign(final DistributionSetTagAssignmentResult assignmentResult) {
if (assignmentResult.getUnassigned() > 0) {
final List<Long> assignedDsNames = assignmentResult.getUnassignedDs().stream().map(t -> t.getId())
final List<Long> assignedDsNames = assignmentResult.getUnassignedEntity().stream().map(t -> t.getId())
.collect(Collectors.toList());
if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) {
return true;

View File

@@ -81,7 +81,7 @@ public class TargetTagToken extends AbstractTargetTagToken {
final Set<String> targetList = new HashSet<>();
targetList.add(selectedTarget.getControllerId());
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(targetList, tagNameSelected);
uinotification.displaySuccess(HawkbitCommonUtil.getTargetTagAssigmentMsg(tagNameSelected, result, i18n));
uinotification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(tagNameSelected, result, i18n));
return result;
}
@@ -151,7 +151,7 @@ public class TargetTagToken extends AbstractTargetTagToken {
protected boolean isAssign(final TargetTagAssignmentResult assignmentResult) {
if (assignmentResult.getAssigned() > 0) {
final List<String> assignedTargetNames = assignmentResult.getAssignedTargets().stream()
final List<String> assignedTargetNames = assignmentResult.getAssignedEntity().stream()
.map(t -> t.getControllerId()).collect(Collectors.toList());
if (assignedTargetNames.contains(managementUIState.getLastSelectedTargetIdName().getControllerId())) {
return true;
@@ -162,7 +162,7 @@ public class TargetTagToken extends AbstractTargetTagToken {
protected boolean isUnassign(final TargetTagAssignmentResult assignmentResult) {
if (assignmentResult.getUnassigned() > 0) {
final List<String> unassignedTargetNamesList = assignmentResult.getUnassignedTargets().stream()
final List<String> unassignedTargetNamesList = assignmentResult.getUnassignedEntity().stream()
.map(t -> t.getControllerId()).collect(Collectors.toList());
if (unassignedTargetNamesList.contains(managementUIState.getLastSelectedTargetIdName().getControllerId())) {
return true;

View File

@@ -8,10 +8,7 @@
*/
package org.eclipse.hawkbit.ui.distributions.disttype;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtonClickBehaviour;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
@@ -23,7 +20,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -45,27 +41,12 @@ public class DSTypeFilterButtons extends AbstractFilterButtons {
private static final long serialVersionUID = 771251569981876005L;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private ManageDistUIState manageDistUIState;
@Autowired
private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
/**
* Initialize component.
*
* @param filterButtonClickBehaviour
* the clickable behaviour.
*/
@Override
public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
super.init(filterButtonClickBehaviour);
eventBus.subscribe(this);
}
@Override
protected String getButtonsTableId() {
@@ -140,9 +121,4 @@ public class DSTypeFilterButtons extends AbstractFilterButtons {
setContainerDataSource(createButtonsLazyQueryContainer());
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
}

View File

@@ -10,14 +10,12 @@ package org.eclipse.hawkbit.ui.distributions.disttype;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -34,12 +32,6 @@ public class DSTypeFilterHeader extends AbstractFilterHeader {
private static final long serialVersionUID = 3433417459392880222L;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private ManageDistUIState manageDistUIState;
@@ -81,8 +73,7 @@ public class DSTypeFilterHeader extends AbstractFilterHeader {
@Override
protected void hideFilterButtonLayout() {
manageDistUIState.setDistTypeFilterClosed(true);
eventbus.publish(this, DistributionsUIEvent.HIDE_DIST_FILTER_BY_TYPE);
eventBus.publish(this, DistributionsUIEvent.HIDE_DIST_FILTER_BY_TYPE);
}
@Override

View File

@@ -13,12 +13,8 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
@@ -37,10 +33,8 @@ import org.eclipse.hawkbit.ui.management.dstable.DistributionAddUpdateWindowLayo
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -72,15 +66,6 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
private static final String UNASSIGN_SOFT_MODULE = "unassignSoftModule";
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private SpPermissionChecker permissionChecker;
@Autowired
private ManageDistUIState manageDistUIState;
@@ -104,21 +89,16 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
private Long dsId;
private UI ui;
Map<String, StringBuilder> assignedSWModule = new HashMap<>();
/**
* softwareLayout Initialize the component.
*/
@Override
@PostConstruct
protected void init() {
softwareModuleTable = new SoftwareModuleDetailsTable();
softwareModuleTable.init(i18n, true, permissionChecker, distributionSetManagement, eventBus, manageDistUIState);
super.init();
ui = UI.getCurrent();
eventBus.subscribe(this);
}
protected VerticalLayout createTagsLayout() {
@@ -321,12 +301,6 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
this.dsId = dsId;
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* onEdit(com.vaadin.ui .Button.ClickEvent)
*/
@Override
protected void onEdit(final ClickEvent event) {
final Window newDistWindow = distributionAddUpdateWindowLayout.getWindow();
@@ -336,68 +310,32 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
newDistWindow.setVisible(Boolean.TRUE);
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* getEditButtonId()
*/
@Override
protected String getEditButtonId() {
return SPUIComponetIdProvider.DS_EDIT_BUTTON;
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* onLoadIsSwModuleSelected ()
*/
@Override
protected Boolean onLoadIsTableRowSelected() {
return manageDistUIState.getSelectedDistributions().isPresent()
&& !manageDistUIState.getSelectedDistributions().get().isEmpty();
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* onLoadIsTableMaximized ()
*/
@Override
protected Boolean onLoadIsTableMaximized() {
return manageDistUIState.isDsTableMaximized();
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* populateDetailsWidget()
*/
@Override
protected void populateDetailsWidget() {
populateDetailsWidget(selectedDsModule);
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* getDefaultCaption()
*/
@Override
protected String getDefaultCaption() {
return i18n.get("distribution.details.header");
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* addTabs(com.vaadin. ui.TabSheet)
*/
@Override
protected void addTabs(final TabSheet detailsTab) {
detailsTab.addTab(createDetailsLayout(), i18n.get("caption.tab.details"), null);
@@ -407,23 +345,11 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
detailsTab.addTab(createLogLayout(), i18n.get("caption.logs.tab"), null);
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* clearDetails()
*/
@Override
protected void clearDetails() {
populateDetailsWidget(null);
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* hasEditSoftwareModulePermission()
*/
@Override
protected Boolean hasEditPermission() {
return permissionChecker.hasUpdateDistributionPermission();
@@ -476,7 +402,7 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
});
}
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SaveActionWindowEvent saveActionWindowEvent) {
if ((saveActionWindowEvent == SaveActionWindowEvent.SAVED_ASSIGNMENTS
@@ -498,21 +424,6 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
}
}
@PreDestroy
void destroy() {
/*
* It's good to do this, even though vaadin-spring will automatically
* unsubscribe .
*/
eventBus.unsubscribe(this);
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* getTabSheetId()
*/
@Override
protected String getTabSheetId() {
return null;

View File

@@ -8,10 +8,6 @@
*/
package org.eclipse.hawkbit.ui.distributions.dstable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
@@ -20,10 +16,8 @@ import org.eclipse.hawkbit.ui.management.dstable.DistributionAddUpdateWindowLayo
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -43,28 +37,12 @@ public class DistributionSetTableHeader extends AbstractTableHeader {
private static final long serialVersionUID = -3483238438474530748L;
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private ManageDistUIState manageDistUIstate;
@Autowired
private DistributionAddUpdateWindowLayout addUpdateWindowLayout;
@Override
@PostConstruct
protected void init() {
super.init();
eventbus.subscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DistributionsUIEvent event) {
if (event == DistributionsUIEvent.HIDE_DIST_FILTER_BY_TYPE) {
@@ -181,11 +159,6 @@ public class DistributionSetTableHeader extends AbstractTableHeader {
eventbus.publish(this, DragEvent.HIDE_DROP_HINT);
}
@PreDestroy
void destroy() {
eventbus.unsubscribe(this);
}
@Override
protected Boolean isAddNewItemAllowed() {
return Boolean.TRUE;

View File

@@ -16,10 +16,6 @@ import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -39,29 +35,6 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria {
private static final Map<String, List<String>> DROP_CONFIGS = createDropConfigurations();
@Autowired
private transient UINotification uiNotification;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Override
protected void analyseDragComponent(final Component compsource) {
final String sourceID = getComponentId(compsource);
final Object event = DROP_HINTS_CONFIGS.get(sourceID);
eventBus.publish(this, event);
}
@Override
protected void hideDropHints() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
}
@Override
protected void invalidDrop() {
uiNotification.displayValidationError(SPUILabelDefinitions.ACTION_NOT_ALLOWED);
}
@Override
protected String getComponentId(final Component component) {
String id = component.getId();
@@ -78,11 +51,6 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria {
return DROP_HINTS_CONFIGS;
}
@Override
protected void publishDragStartEvent(final Object event) {
eventBus.publish(this, event);
}
@Override
protected Map<String, List<String>> getDropConfigurations() {
return DROP_CONFIGS;

View File

@@ -15,10 +15,6 @@ import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
@@ -30,13 +26,10 @@ import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -65,21 +58,6 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
Arrays.asList(DragEvent.DISTRIBUTION_TYPE_DRAG, DragEvent.DISTRIBUTION_DRAG, DragEvent.SOFTWAREMODULE_DRAG,
DragEvent.SOFTWAREMODULE_TYPE_DRAG));
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient UINotification notification;
@Autowired
private transient UINotification uiNotification;
@Autowired
private transient SystemManagement systemManagement;
@@ -92,28 +70,6 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Autowired
private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#init()
*/
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DragEvent event) {
if (event == DragEvent.HIDE_DROP_HINT) {
@@ -139,77 +95,34 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
}
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* hasDeletePermission()
*/
@Override
protected boolean hasDeletePermission() {
return permChecker.hasDeleteDistributionPermission();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* hasUpdatePermission()
*/
@Override
protected boolean hasUpdatePermission() {
return permChecker.hasUpdateDistributionPermission();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getDeleteAreaLabel()
*/
@Override
protected String getDeleteAreaLabel() {
return i18n.get("label.components.drop.area");
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getDeleteAreaId()
*/
@Override
protected String getDeleteAreaId() {
return SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getDeleteLayoutAcceptCriteria ()
*/
@Override
protected AcceptCriterion getDeleteLayoutAcceptCriteria() {
return distributionsViewAcceptCriteria;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* processDroppedComponent(com .vaadin.event.dd.DragAndDropEvent)
*/
@Override
protected void processDroppedComponent(final DragAndDropEvent event) {
final Component sourceComponent = event.getTransferable().getSourceComponent();
@@ -298,7 +211,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* message accordingly.
*/
uiNotification.displayValidationError(i18n.get("message.targets.already.deleted"));
notification.displayValidationError(i18n.get("message.targets.already.deleted"));
} else if (newDeletedDistributionsSize - existingDeletedDistributionsSize != distributionIdNameSet.size()) {
/*
* Not the all distributions dropped now are added to the delete
@@ -306,7 +219,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* delete list. Hence display warning message accordingly.
*/
uiNotification.displayValidationError(i18n.get("message.dist.deleted.pending"));
notification.displayValidationError(i18n.get("message.dist.deleted.pending"));
}
}
@@ -366,64 +279,12 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
return SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE.equals(source.getId());
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getNoActionsButtonLabel()
*/
@Override
protected String getNoActionsButtonLabel() {
return i18n.get("button.no.actions");
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getActionsButtonLabel()
*/
@Override
protected String getActionsButtonLabel() {
return i18n.get("button.actions");
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* reloadActionCount()
*/
@Override
protected void restoreActionCount() {
updateDSActionCount();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getUnsavedActionsWindowCaption ()
*/
@Override
protected String getUnsavedActionsWindowCaption() {
return i18n.get("caption.save.window");
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* unsavedActionsWindowClosed()
*/
@Override
protected void unsavedActionsWindowClosed() {
final String message = distConfirmationWindowLayout.getConsolidatedMessage();
@@ -433,26 +294,12 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getUnsavedActionsWindowContent ()
*/
@Override
protected Component getUnsavedActionsWindowContent() {
distConfirmationWindowLayout.init();
return distConfirmationWindowLayout;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* hasUnsavedActions()
*/
@Override
protected boolean hasUnsavedActions() {
boolean unSavedActionsTypes = false;
@@ -479,23 +326,11 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout#
* hasBulkUploadPermission()
*/
@Override
protected boolean hasBulkUploadPermission() {
return false;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout#
* showBulkUploadWindow()
*/
@Override
protected void showBulkUploadWindow() {
/**
@@ -503,12 +338,6 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
*/
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout#
* restoreBulkUploadStatusCount()
*/
@Override
protected void restoreBulkUploadStatusCount() {
/**

View File

@@ -8,10 +8,6 @@
*/
package org.eclipse.hawkbit.ui.distributions.smtable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
@@ -20,10 +16,8 @@ import org.eclipse.hawkbit.ui.common.detailslayout.AbstractTableDetailsLayout;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -46,44 +40,16 @@ public class SwModuleDetails extends AbstractTableDetailsLayout {
private static final long serialVersionUID = -1052279281066089812L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private SpPermissionChecker permissionChecker;
@Autowired
private SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow;
@Autowired
private ManageDistUIState manageDistUIState;
private UI ui;
private Long swModuleId;
private SoftwareModule selectedSwModule;
@Override
@PostConstruct
protected void init() {
super.init();
ui = UI.getCurrent();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleEvent softwareModuleEvent) {
if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE

View File

@@ -8,10 +8,6 @@
*/
package org.eclipse.hawkbit.ui.distributions.smtable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
@@ -19,10 +15,8 @@ import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleAddUpdateWindow;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -43,14 +37,6 @@ public class SwModuleTableHeader extends AbstractTableHeader {
private static final long serialVersionUID = 242961845006626297L;
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private ManageDistUIState manageDistUIState;
@@ -58,18 +44,6 @@ public class SwModuleTableHeader extends AbstractTableHeader {
@Autowired
private SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow;
@Override
@PostConstruct
protected void init() {
super.init();
eventbus.subscribe(this);
}
@PreDestroy
void destroy() {
eventbus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DistributionsUIEvent event) {
if (event == DistributionsUIEvent.HIDE_SM_FILTER_BY_TYPE) {

View File

@@ -11,11 +11,8 @@ package org.eclipse.hawkbit.ui.distributions.smtype;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtonClickBehaviour;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
@@ -27,7 +24,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -47,21 +43,12 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
private static final long serialVersionUID = 6804534533362387433L;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private ManageDistUIState manageDistUIState;
@Autowired
private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
@Override
public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
super.init(filterButtonClickBehaviour);
eventBus.subscribe(this);
}
@Override
protected String getButtonsTableId() {
return SPUIComponetIdProvider.SW_MODULE_TYPE_TABLE_ID;
@@ -135,9 +122,5 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
setContainerDataSource(createButtonsLazyQueryContainer());
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
}

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.ui.distributions.smtype;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.smtype.CreateUpdateSoftwareTypeLayout;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
@@ -19,7 +18,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -36,12 +34,6 @@ public class DistSMTypeFilterHeader extends AbstractFilterHeader {
private static final long serialVersionUID = -8763788280848718344L;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private ManageDistUIState manageDistUIState;

View File

@@ -8,10 +8,6 @@
*/
package org.eclipse.hawkbit.ui.management.dstable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractTableDetailsLayout;
import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsTable;
@@ -21,10 +17,8 @@ import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -46,15 +40,7 @@ public class DistributionDetails extends AbstractTableDetailsLayout {
private static final long serialVersionUID = 350360207334118826L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private SpPermissionChecker permissionChecker;
@Autowired
private ManagementUIState managementUIState;
@@ -70,22 +56,13 @@ public class DistributionDetails extends AbstractTableDetailsLayout {
private DistributionSet selectedDsModule;
private UI ui;
@Override
@PostConstruct
protected void init() {
eventBus.subscribe(this);
softwareModuleTable = new SoftwareModuleDetailsTable();
softwareModuleTable.init(i18n, false, permissionChecker, null, null, null);
super.init();
ui = UI.getCurrent();
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DistributionTableEvent distributionTableEvent) {

View File

@@ -363,7 +363,7 @@ public class DistributionTable extends AbstractTable {
final DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(distList,
distTagName);
notification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(distTagName, result, i18n));
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(distTagName, result, i18n));
if (result.getAssigned() >= 1 && managementUIState.getDistributionTableFilters().isNoTagSelected()) {
refreshFilter();
}

View File

@@ -8,10 +8,6 @@
*/
package org.eclipse.hawkbit.ui.management.dstable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
@@ -19,10 +15,8 @@ import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -43,33 +37,12 @@ import com.vaadin.ui.Window;
public class DistributionTableHeader extends AbstractTableHeader {
private static final long serialVersionUID = 7597766804650170127L;
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private ManagementUIState managementUIState;
@Autowired
private DistributionAddUpdateWindowLayout distributionAddUpdateWindowLayout;
@Override
@PostConstruct
protected void init() {
super.init();
eventbus.subscribe(this);
}
@PreDestroy
void destroy() {
eventbus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final ManagementUIEvent event) {
if (event == ManagementUIEvent.HIDE_DISTRIBUTION_TAG_LAYOUT) {

View File

@@ -11,8 +11,6 @@ package org.eclipse.hawkbit.ui.management.dstag;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent;
@@ -31,7 +29,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -51,9 +48,6 @@ public class DistributionTagButtons extends AbstractFilterButtons {
private static final long serialVersionUID = -8151483237450892057L;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private DistributionTagDropEvent spDistTagDropEvent;
@@ -64,12 +58,6 @@ public class DistributionTagButtons extends AbstractFilterButtons {
public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
super.init(filterButtonClickBehaviour);
addNewTag(new DistributionSetTag("NO TAG"));
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)

View File

@@ -10,14 +10,12 @@ package org.eclipse.hawkbit.ui.management.dstag;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -38,12 +36,6 @@ public class DistributionTagHeader extends AbstractFilterHeader {
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private ManagementUIState managementUIState;
@@ -90,7 +82,7 @@ public class DistributionTagHeader extends AbstractFilterHeader {
@Override
protected void hideFilterButtonLayout() {
managementUIState.setDistTagFilterClosed(true);
eventbus.publish(this, ManagementUIEvent.HIDE_DISTRIBUTION_TAG_LAYOUT);
eventBus.publish(this, ManagementUIEvent.HIDE_DISTRIBUTION_TAG_LAYOUT);
}
@Override

View File

@@ -150,7 +150,7 @@ public class DistributionTagDropEvent implements DropHandler {
final DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(distributionList,
distTagName);
notification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(distTagName, result, i18n));
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(distTagName, result, i18n));
if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) {
eventBus.publish(this, TargetFilterEvent.FILTER_BY_TAG);
}

View File

@@ -16,10 +16,6 @@ import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -41,29 +37,6 @@ public class ManagementViewAcceptCriteria extends AbstractAcceptCriteria {
private static final Map<String, Object> DROP_HINTS_CONFIGS = createDropHintConfigurations();
@Autowired
private transient UINotification uiNotification;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Override
protected void analyseDragComponent(final Component compsource) {
final String sourceID = getComponentId(compsource);
final Object event = DROP_HINTS_CONFIGS.get(sourceID);
eventBus.publish(this, event);
}
@Override
protected void hideDropHints() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
}
@Override
protected void invalidDrop() {
uiNotification.displayValidationError(SPUILabelDefinitions.ACTION_NOT_ALLOWED);
}
@Override
protected String getComponentId(final Component component) {
String id = component.getId();
@@ -80,11 +53,6 @@ public class ManagementViewAcceptCriteria extends AbstractAcceptCriteria {
return DROP_HINTS_CONFIGS;
}
@Override
protected void publishDragStartEvent(final Object event) {
eventBus.publish(this, event);
}
@Override
protected Map<String, List<String>> getDropConfigurations() {
return DROP_CONFIGS;

View File

@@ -11,10 +11,6 @@ package org.eclipse.hawkbit.ui.management.footer;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.TargetIdName;
@@ -28,12 +24,9 @@ import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -56,17 +49,6 @@ import com.vaadin.ui.UI;
public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
private static final long serialVersionUID = -8112907467821886253L;
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient UINotification notification;
@Autowired
private transient TagManagement tagManagementService;
@@ -83,18 +65,6 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
@Autowired
private CountMessageLabel countMessageLabel;
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final ManagementUIEvent event) {
if (event == ManagementUIEvent.UPDATE_COUNT) {
@@ -226,26 +196,11 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
return true;
}
@Override
protected String getNoActionsButtonLabel() {
return i18n.get("button.no.actions");
}
@Override
protected String getActionsButtonLabel() {
return i18n.get("button.actions");
}
@Override
protected void restoreActionCount() {
updateActionCount();
}
@Override
protected String getUnsavedActionsWindowCaption() {
return i18n.get("caption.save.window");
}
@Override
protected void unsavedActionsWindowClosed() {
final String message = manangementConfirmationWindowLayout.getConsolidatedMessage();

View File

@@ -10,11 +10,7 @@ package org.eclipse.hawkbit.ui.management.targettable;
import java.net.URI;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
@@ -25,12 +21,10 @@ import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -60,15 +54,6 @@ public class TargetDetails extends AbstractTableDetailsLayout {
private static final long serialVersionUID = 4571732743399605843L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private ManagementUIState managementUIState;
@@ -87,11 +72,9 @@ public class TargetDetails extends AbstractTableDetailsLayout {
* Initialize the Target details.
*/
@Override
@PostConstruct
public void init() {
super.init();
targetAddUpdateWindowLayout.init();
eventBus.subscribe(this);
}
@Override
@@ -286,7 +269,7 @@ public class TargetDetails extends AbstractTableDetailsLayout {
@Override
protected Boolean hasEditPermission() {
return permChecker.hasUpdateTargetPermission();
return permissionChecker.hasUpdateTargetPermission();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -312,11 +295,6 @@ public class TargetDetails extends AbstractTableDetailsLayout {
}
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@Override
protected String getTabSheetId() {
return SPUIComponetIdProvider.TARGET_DETAILS_TABSHEET;

View File

@@ -644,7 +644,7 @@ public class TargetTable extends AbstractTable implements Handler {
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(targetList, targTagName);
final List<String> tagsClickedList = managementUIState.getTargetTableFilters().getClickedTargetTags();
notification.displaySuccess(HawkbitCommonUtil.getTargetTagAssigmentMsg(targTagName, result, i18n));
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(targTagName, result, i18n));
if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) {
refreshFilter();
}

View File

@@ -11,10 +11,6 @@ package org.eclipse.hawkbit.ui.management.targettable;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
@@ -29,7 +25,6 @@ import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUITargetDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -63,12 +58,6 @@ public class TargetTableHeader extends AbstractTableHeader {
private static final long serialVersionUID = -8647521126666320022L;
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private UINotification notification;
@@ -90,21 +79,14 @@ public class TargetTableHeader extends AbstractTableHeader {
private Boolean isComplexFilterViewDisplayed = Boolean.FALSE;
@Override
@PostConstruct
protected void init() {
super.init();
// creating add window for adding new target
targetAddUpdateWindow.init();
targetBulkUpdateWindow.init();
eventBus.subscribe(this);
onLoadRestoreState();
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final ManagementUIEvent event) {
if (event == ManagementUIEvent.HIDE_TARGET_TAG_LAYOUT) {

View File

@@ -13,8 +13,6 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent;
import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent;
import org.eclipse.hawkbit.eventbus.event.TargetTagUpdateEvent;
@@ -38,7 +36,6 @@ import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -63,9 +60,6 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
private static final long serialVersionUID = 5049554600376508073L;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private ManagementUIState managementUIState;
@@ -99,12 +93,6 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
this.filterButtonClickBehaviour = filterButtonClickBehaviour;
super.init(filterButtonClickBehaviour);
addNewTargetTag(new TargetTag("NO TAG"));
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -244,7 +232,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
final List<String> tagsClickedList = managementUIState.getTargetTableFilters().getClickedTargetTags();
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(targetList, targTagName);
notification.displaySuccess(HawkbitCommonUtil.getTargetTagAssigmentMsg(targTagName, result, i18n));
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(targTagName, result, i18n));
if (result.getAssigned() >= 1 && managementUIState.getTargetTableFilters().isNoTagSelected()) {
eventBus.publish(this, ManagementUIEvent.ASSIGN_TARGET_TAG);

View File

@@ -10,14 +10,12 @@ package org.eclipse.hawkbit.ui.management.targettag;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -32,15 +30,9 @@ public class TargetTagFilterHeader extends AbstractFilterHeader {
private static final long serialVersionUID = 3046367045669148009L;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private CreateUpdateTargetTagLayout createUpdateTargetTagLayout;
@@ -58,7 +50,6 @@ public class TargetTagFilterHeader extends AbstractFilterHeader {
@Override
protected String getHideButtonId() {
return SPUIComponetIdProvider.HIDE_TARGET_TAGS;
}
@@ -87,7 +78,7 @@ public class TargetTagFilterHeader extends AbstractFilterHeader {
@Override
protected void hideFilterButtonLayout() {
managementUIState.setTargetTagFilterClosed(true);
eventbus.publish(this, ManagementUIEvent.HIDE_TARGET_TAG_LAYOUT);
eventBus.publish(this, ManagementUIEvent.HIDE_TARGET_TAG_LAYOUT);
}
@Override

View File

@@ -15,9 +15,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.eventbus.event.RolloutChangeEvent;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
@@ -33,7 +30,6 @@ import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
@@ -46,7 +42,6 @@ import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.peter.contextmenu.ContextMenu;
import org.vaadin.peter.contextmenu.ContextMenu.ContextMenuItem;
import org.vaadin.peter.contextmenu.ContextMenu.ContextMenuItemClickEvent;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -82,11 +77,6 @@ public class RolloutListGrid extends AbstractGrid {
private static final String START_OPTION = "Start";
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient RolloutManagement rolloutManagement;
@@ -105,17 +95,6 @@ public class RolloutListGrid extends AbstractGrid {
private transient Map<RolloutStatus, StatusFontIcon> statusIconMap = new EnumMap<>(RolloutStatus.class);
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final RolloutEvent event) {
@@ -245,7 +224,7 @@ public class RolloutListGrid extends AbstractGrid {
@Override
protected void setColumnProperties() {
List<Object> columnList = new ArrayList<>();
final List<Object> columnList = new ArrayList<>();
columnList.add(SPUILabelDefinitions.VAR_NAME);
columnList.add(SPUILabelDefinitions.VAR_DIST_NAME_VERSION);
columnList.add(SPUILabelDefinitions.VAR_STATUS);
@@ -265,13 +244,13 @@ public class RolloutListGrid extends AbstractGrid {
@Override
protected void setHiddenColumns() {
List<Object> columnsToBeHidden = new ArrayList<>();
final List<Object> columnsToBeHidden = new ArrayList<>();
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC);
for (Object propertyId : columnsToBeHidden) {
for (final Object propertyId : columnsToBeHidden) {
getColumn(propertyId).setHidden(true);
}
@@ -318,7 +297,7 @@ public class RolloutListGrid extends AbstractGrid {
@Override
public String getStyle(final CellReference cellReference) {
String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS, SPUILabelDefinitions.ACTION };
final String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS, SPUILabelDefinitions.ACTION };
if (Arrays.asList(coulmnNames).contains(cellReference.getPropertyId())) {
return "centeralign";
}
@@ -327,18 +306,18 @@ public class RolloutListGrid extends AbstractGrid {
});
}
private void onClickOfRolloutName(RendererClickEvent event) {
private void onClickOfRolloutName(final RendererClickEvent event) {
rolloutUIState.setRolloutId((long) event.getItemId());
final String rolloutName = (String) getContainerDataSource().getItem(event.getItemId())
.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
rolloutUIState.setRolloutName(rolloutName);
String ds = (String) getContainerDataSource().getItem(event.getItemId())
final String ds = (String) getContainerDataSource().getItem(event.getItemId())
.getItemProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).getValue();
rolloutUIState.setRolloutDistributionSet(ds);
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUPS);
}
private void onClickOfActionBtn(RendererClickEvent event) {
private void onClickOfActionBtn(final RendererClickEvent event) {
final ContextMenu contextMenu = createContextMenu((Long) event.getItemId());
contextMenu.setAsContextMenuOf((AbstractClientConnector) event.getComponent());
contextMenu.open(event.getClientX(), event.getClientY());
@@ -388,11 +367,11 @@ public class RolloutListGrid extends AbstractGrid {
}
private String convertRolloutStatusToString(final RolloutStatus value) {
StatusFontIcon statusFontIcon = statusIconMap.get(value);
final StatusFontIcon statusFontIcon = statusIconMap.get(value);
if (statusFontIcon == null) {
return null;
}
String codePoint = statusFontIcon.getFontIcon() != null
final String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID);
@@ -441,12 +420,12 @@ public class RolloutListGrid extends AbstractGrid {
private static final long serialVersionUID = 2544026030795375748L;
private final FontAwesome fontIcon;
public FontIconGenerator(FontAwesome icon) {
public FontIconGenerator(final FontAwesome icon) {
this.fontIcon = icon;
}
@Override
public String getValue(Item item, Object itemId, Object propertyId) {
public String getValue(final Item item, final Object itemId, final Object propertyId) {
return fontIcon.getHtml();
}
@@ -456,7 +435,7 @@ public class RolloutListGrid extends AbstractGrid {
}
}
private String getDescription(CellReference cell) {
private String getDescription(final CellReference cell) {
if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
return cell.getProperty().getValue().toString().toLowerCase();
} else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) {
@@ -570,14 +549,14 @@ public class RolloutListGrid extends AbstractGrid {
private static final long serialVersionUID = -5794528427855153924L;
@Override
public TotalTargetCountStatus convertToModel(String value, Class<? extends TotalTargetCountStatus> targetType,
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
public TotalTargetCountStatus convertToModel(final String value, final Class<? extends TotalTargetCountStatus> targetType,
final Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
return null;
}
@Override
public String convertToPresentation(TotalTargetCountStatus value, Class<? extends String> targetType,
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
public String convertToPresentation(final TotalTargetCountStatus value, final Class<? extends String> targetType,
final Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
}

View File

@@ -15,9 +15,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.eventbus.event.RolloutGroupChangeEvent;
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
@@ -32,7 +29,6 @@ import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
@@ -41,7 +37,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -64,12 +59,6 @@ import com.vaadin.ui.renderers.HtmlRenderer;
public class RolloutGroupListGrid extends AbstractGrid {
private static final long serialVersionUID = 4060904914954370524L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient RolloutGroupManagement rolloutGroupManagement;
@@ -81,18 +70,6 @@ public class RolloutGroupListGrid extends AbstractGrid {
private transient Map<RolloutGroupStatus, StatusFontIcon> statusIconMap = new EnumMap<>(RolloutGroupStatus.class);
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final RolloutEvent event) {
if (RolloutEvent.SHOW_ROLLOUT_GROUPS != event) {
@@ -218,7 +195,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
@Override
protected void setColumnProperties() {
List<Object> columnList = new ArrayList<>();
final List<Object> columnList = new ArrayList<>();
columnList.add(SPUILabelDefinitions.VAR_NAME);
columnList.add(SPUILabelDefinitions.VAR_STATUS);
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
@@ -251,13 +228,13 @@ public class RolloutGroupListGrid extends AbstractGrid {
@Override
protected void setHiddenColumns() {
List<Object> columnsToBeHidden = new ArrayList<>();
final List<Object> columnsToBeHidden = new ArrayList<>();
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC);
for (Object propertyId : columnsToBeHidden) {
for (final Object propertyId : columnsToBeHidden) {
getColumn(propertyId).setHidden(true);
}
}
@@ -267,18 +244,18 @@ public class RolloutGroupListGrid extends AbstractGrid {
return cell -> getDescription(cell);
}
private void onClickOfRolloutGroupName(RendererClickEvent event) {
private void onClickOfRolloutGroupName(final RendererClickEvent event) {
rolloutUIState
.setRolloutGroup(rolloutGroupManagement.findRolloutGroupWithDetailedStatus((Long) event.getItemId()));
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS);
}
private String convertRolloutGroupStatusToString(final RolloutGroupStatus value) {
StatusFontIcon statusFontIcon = statusIconMap.get(value);
final StatusFontIcon statusFontIcon = statusIconMap.get(value);
if (statusFontIcon == null) {
return null;
}
String codePoint = statusFontIcon.getFontIcon() != null
final String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_GROUP_STATUS_LABEL_ID);
@@ -298,7 +275,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED));
}
private String getDescription(CellReference cell) {
private String getDescription(final CellReference cell) {
if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
return cell.getProperty().getValue().toString().toLowerCase();
} else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) {
@@ -318,7 +295,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
@Override
public String getStyle(final CellReference cellReference) {
String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS,
final String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS,
SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS };
if (Arrays.asList(coulmnNames).contains(cellReference.getPropertyId())) {
return "centeralign";
@@ -339,14 +316,14 @@ public class RolloutGroupListGrid extends AbstractGrid {
private static final long serialVersionUID = -9205943894818450807L;
@Override
public TotalTargetCountStatus convertToModel(String value, Class<? extends TotalTargetCountStatus> targetType,
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
public TotalTargetCountStatus convertToModel(final String value, final Class<? extends TotalTargetCountStatus> targetType,
final Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
return null;
}
@Override
public String convertToPresentation(TotalTargetCountStatus value, Class<? extends String> targetType,
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
public String convertToPresentation(final TotalTargetCountStatus value, final Class<? extends String> targetType,
final Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
}

View File

@@ -14,9 +14,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus;
@@ -26,7 +23,6 @@ import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
@@ -35,7 +31,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -55,29 +50,12 @@ import com.vaadin.spring.annotation.ViewScope;
public class RolloutGroupTargetsListGrid extends AbstractGrid {
private static final long serialVersionUID = -2244756637458984597L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient RolloutUIState rolloutUIState;
private transient Map<Status, StatusFontIcon> statusIconMap = new EnumMap<>(Status.class);
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final RolloutEvent event) {
@@ -158,7 +136,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
@Override
protected void setColumnProperties() {
List<Object> columnList = new ArrayList<>();
final List<Object> columnList = new ArrayList<>();
columnList.add(SPUILabelDefinitions.VAR_NAME);
columnList.add(SPUILabelDefinitions.VAR_CREATED_DATE);
columnList.add(SPUILabelDefinitions.VAR_CREATED_BY);
@@ -241,11 +219,11 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
}
private String processActionStatus(final Status status) {
StatusFontIcon statusFontIcon = statusIconMap.get(status);
final StatusFontIcon statusFontIcon = statusIconMap.get(status);
if (statusFontIcon == null) {
return null;
}
String codePoint = statusFontIcon.getFontIcon() != null
final String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(), null);
}
@@ -286,7 +264,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
}
}
private String getDescription(CellReference cell) {
private String getDescription(final CellReference cell) {
if (!SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
return null;
}
@@ -304,7 +282,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.READY) {
return RolloutGroupStatus.READY.toString().toLowerCase();
} else if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.FINISHED) {
String ds = rolloutUIState.getRolloutDistributionSet().isPresent()
final String ds = rolloutUIState.getRolloutDistributionSet().isPresent()
? rolloutUIState.getRolloutDistributionSet().get() : "";
return i18n.get("message.dist.already.assigned", new Object[] { ds });
}

View File

@@ -24,14 +24,14 @@ import java.util.TimeZone;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.im.authentication.UserPrincipal;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.AssignmentResult;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.TargetInfo.PollStatus;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
@@ -868,7 +868,7 @@ public final class HawkbitCommonUtil {
/**
* Display Target Tag action message.
*
* @param targTagName
* @param tagName
* as tag name
* @param result
* as TargetTagAssigmentResult
@@ -878,7 +878,7 @@ public final class HawkbitCommonUtil {
* I18N
* @return message
*/
public static String getTargetTagAssigmentMsg(final String targTagName, final TargetTagAssignmentResult result,
public static String createAssignmentMessage(final String tagName, final AssignmentResult<? extends NamedEntity> result,
final I18N i18n) {
final StringBuilder formMsg = new StringBuilder();
final int assignedCount = result.getAssigned();
@@ -887,10 +887,10 @@ public final class HawkbitCommonUtil {
if (assignedCount == 1) {
formMsg.append(i18n.get("message.target.assigned.one",
new Object[] { result.getAssignedTargets().get(0).getName(), targTagName })).append("<br>");
new Object[] { result.getAssignedEntity().get(0).getName(), tagName })).append("<br>");
} else if (assignedCount > 1) {
formMsg.append(i18n.get("message.target.assigned.many", new Object[] { assignedCount, targTagName }))
formMsg.append(i18n.get("message.target.assigned.many", new Object[] { assignedCount, tagName }))
.append("<br>");
if (alreadyAssignedCount > 0) {
@@ -902,55 +902,10 @@ public final class HawkbitCommonUtil {
if (unassignedCount == 1) {
formMsg.append(i18n.get("message.target.unassigned.one",
new Object[] { result.getUnassignedTargets().get(0).getName(), targTagName })).append("<br>");
new Object[] { result.getUnassignedEntity().get(0).getName(), tagName })).append("<br>");
} else if (unassignedCount > 1) {
formMsg.append(i18n.get("message.target.unassigned.many", new Object[] { unassignedCount, targTagName }))
.append("<br>");
}
return formMsg.toString();
}
/**
* Get message to be displayed after distribution tag assignment.
*
* @param targTagName
* tag name
* @param result
* DistributionSetTagAssigmentResult
* @param tagsClickedList
* list of clicked tags
* @param i18n
* I18N
* @return message
*/
public static String getDistributionTagAssignmentMsg(final String targTagName,
final DistributionSetTagAssignmentResult result, final I18N i18n) {
final StringBuilder formMsg = new StringBuilder();
final int assignedCount = result.getAssigned();
final int alreadyAssignedCount = result.getAlreadyAssigned();
final int unassignedCount = result.getUnassigned();
if (assignedCount == 1) {
formMsg.append(i18n.get("message.target.assigned.one",
new Object[] { result.getAssignedDs().get(0).getName(), targTagName })).append("<br>");
} else if (assignedCount > 1) {
formMsg.append(i18n.get("message.target.assigned.many", new Object[] { assignedCount, targTagName }))
.append("<br>");
if (alreadyAssignedCount > 0) {
final String alreadyAssigned = i18n.get("message.target.alreadyAssigned",
new Object[] { alreadyAssignedCount });
formMsg.append(alreadyAssigned).append("<br>");
}
}
if (unassignedCount == 1) {
formMsg.append(i18n.get("message.target.unassigned.one",
new Object[] { result.getUnassignedDs().get(0).getName(), targTagName })).append("<br>");
} else if (unassignedCount > 1) {
formMsg.append(i18n.get("message.target.unassigned.many", new Object[] { unassignedCount, targTagName }))
formMsg.append(i18n.get("message.target.unassigned.many", new Object[] { unassignedCount, tagName }))
.append("<br>");
}
return formMsg.toString();