Merge branch 'master' into feature_target_filtering_supports_overdue

Conflicts:
	hawkbit-repository\hawkbit-repository-jpa\src\main\java\org\eclipse\hawkbit\repository\jpa\JpaDeploymentManagement.java
	hawkbit-repository\hawkbit-repository-jpa\src\main\java\org\eclipse\hawkbit\repository\jpa\JpaTargetManagement.java
	hawkbit-ui\src\main\java\org\eclipse\hawkbit\ui\management\targettable\TargetBeanQuery.java
	hawkbit-ui\src\main\java\org\eclipse\hawkbit\ui\management\targettable\TargetTable.java


Signed-off-by: Marcel Mager (INST-IOT/ESB) <Marcel.Mager@bosch-si.com>
This commit is contained in:
Marcel Mager (INST-IOT/ESB)
2016-10-18 12:57:10 +02:00
114 changed files with 1741 additions and 1133 deletions

View File

@@ -1,68 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.hawkbit.eventbus.event.Event;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetUpdateEvent;
import org.eclipse.hawkbit.repository.eventbus.event.RolloutChangeEvent;
import org.eclipse.hawkbit.repository.eventbus.event.RolloutGroupChangeEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetUpdatedEvent;
/**
* The default hawkbit event provider.
*/
public class HawkbitEventProvider implements UIEventProvider {
private static final Set<Class<? extends Event>> SINGLE_EVENTS = new HashSet<>(9);
private static final Set<Class<? extends Event>> BULK_EVENTS = new HashSet<>(5);
static {
SINGLE_EVENTS.add(TargetTagCreatedBulkEvent.class);
SINGLE_EVENTS.add(DistributionSetTagCreatedBulkEvent.class);
SINGLE_EVENTS.add(DistributionSetTagDeletedEvent.class);
SINGLE_EVENTS.add(TargetTagDeletedEvent.class);
SINGLE_EVENTS.add(DistributionSetTagUpdateEvent.class);
SINGLE_EVENTS.add(RolloutGroupChangeEvent.class);
SINGLE_EVENTS.add(RolloutChangeEvent.class);
SINGLE_EVENTS.add(TargetTagUpdateEvent.class);
SINGLE_EVENTS.add(DistributionSetUpdateEvent.class);
BULK_EVENTS.add(TargetCreatedEvent.class);
BULK_EVENTS.add(TargetInfoUpdateEvent.class);
BULK_EVENTS.add(TargetDeletedEvent.class);
BULK_EVENTS.add(DistributionDeletedEvent.class);
BULK_EVENTS.add(DistributionCreatedEvent.class);
BULK_EVENTS.add(TargetUpdatedEvent.class);
}
@Override
public Set<Class<? extends Event>> getSingleEvents() {
return SINGLE_EVENTS;
}
@Override
public Set<Class<? extends Event>> getBulkEvents() {
return BULK_EVENTS;
}
}

View File

@@ -1,60 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.eventbus.event.Event;
/**
* The UI event provider hold all supported repository events which will
* delegated to the UI. A event type can delegated as single event or bulk
* event. Bulk event means, that all events from one type is collected by the
* provider. The delegater and delegated as a list of this events.
*/
public interface UIEventProvider {
/**
* Return all supported repository single event types. All events which this
* type are delegated to the UI as single event.
*
* @return list of provided event types. Should not be null
*/
default Set<Class<? extends Event>> getSingleEvents() {
return Collections.emptySet();
}
/**
* Return all supported repository bulk event types. All events which this
* type are delegated to the UI as a list. This list contains all collected
* events from one type.
*
* @return list of provided bulk event types. Should not be null
*/
default Set<Class<? extends Event>> getBulkEvents() {
return Collections.emptySet();
}
/**
* Return all filtered bulk event types by the given events. The default
* maps the events by class.
*
* @param allEvents
* the events
* @return list of provided bulk event types which are filtered. Should not
* be null
*/
default Set<Class<?>> getFilteredBulkEventsType(final List<Event> allEvents) {
return allEvents.stream().map(Event::getClass).filter(getBulkEvents()::contains).collect(Collectors.toSet());
}
}

View File

@@ -32,10 +32,10 @@ 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.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
@@ -146,11 +146,10 @@ public class ArtifactDetailsLayout extends VerticalLayout {
}
private void createComponents() {
String labelStr = "";
if (artifactUploadState.getSelectedBaseSoftwareModule().isPresent()) {
final SoftwareModule softwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get();
labelStr = HawkbitCommonUtil.getFormattedNameVersion(softwareModule.getName(), softwareModule.getVersion());
}
final String labelStr = artifactUploadState.getSelectedBaseSoftwareModule()
.map(softwareModule -> HawkbitCommonUtil.getFormattedNameVersion(softwareModule.getName(),
softwareModule.getVersion()))
.orElse("");
titleOfArtifactDetails = new LabelBuilder().name(HawkbitCommonUtil.getArtifactoryDetailsLabelId(labelStr))
.buildCaptionLabel();
titleOfArtifactDetails.setContentMode(ContentMode.HTML);

View File

@@ -19,13 +19,13 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.dstable.DsMetadataPopupLayout;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.VaadinSessionScope;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
@@ -39,7 +39,7 @@ import com.vaadin.ui.themes.ValoTheme;
*/
@SpringComponent
@VaadinSessionScope
@ViewScope
public class DistributionSetMetadatadetailslayout extends Table {
private static final long serialVersionUID = 2913758299611837718L;

View File

@@ -13,6 +13,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@@ -112,7 +113,7 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
if (values == null) {
values = Collections.emptySet();
}
return values;
return values.stream().filter(item -> item != null).collect(Collectors.toSet());
}
private void onValueChange() {

View File

@@ -50,6 +50,8 @@ import com.vaadin.ui.themes.ValoTheme;
*/
public abstract class AbstractTagToken<T extends BaseEntity> implements Serializable {
private static final String ID_PROPERTY = "id";
private static final String NAME_PROPERTY = "name";
private static final String COLOR_PROPERTY = "color";
private static final long serialVersionUID = 6599386705285184783L;
@@ -120,7 +122,7 @@ public abstract class AbstractTagToken<T extends BaseEntity> implements Serializ
tokenField.setImmediate(true);
tokenField.addStyleName(ValoTheme.COMBOBOX_TINY);
tokenField.setSizeFull();
tokenField.setTokenCaptionPropertyId("name");
tokenField.setTokenCaptionPropertyId(NAME_PROPERTY);
}
protected void repopulateToken() {
@@ -130,8 +132,8 @@ public abstract class AbstractTagToken<T extends BaseEntity> implements Serializ
private Container createContainer() {
container = new IndexedContainer();
container.addContainerProperty("name", String.class, "");
container.addContainerProperty("id", Long.class, "");
container.addContainerProperty(NAME_PROPERTY, String.class, "");
container.addContainerProperty(ID_PROPERTY, Long.class, "");
container.addContainerProperty(COLOR_PROPERTY, String.class, "");
return container;
}
@@ -142,7 +144,13 @@ public abstract class AbstractTagToken<T extends BaseEntity> implements Serializ
}
private void removeTagAssignedFromCombo(final Long tagId) {
tokensAdded.put(tagId, new TagData(tagId, getTagName(tagId), getColor(tagId)));
// might not yet exist or not anymore due to unprocessed events
final Item item = tokenField.getContainerDataSource().getItem(tagId);
if (item == null) {
return;
}
tokensAdded.put(tagId, new TagData(tagId, getTagName(item), getColor(item)));
container.removeItem(tagId);
}
@@ -150,13 +158,17 @@ public abstract class AbstractTagToken<T extends BaseEntity> implements Serializ
final TagData tagData = tagDetails.putIfAbsent(tagId, new TagData(tagId, tagName, tagColor));
if (tagData == null) {
final Item item = container.addItem(tagId);
item.getItemProperty("id").setValue(tagId);
if (item == null) {
return;
}
item.getItemProperty(ID_PROPERTY).setValue(tagId);
updateItem(tagName, tagColor, item);
}
}
protected void updateItem(final String tagName, final String tagColor, final Item item) {
item.getItemProperty("name").setValue(tagName);
item.getItemProperty(NAME_PROPERTY).setValue(tagName);
item.getItemProperty(COLOR_PROPERTY).setValue(tagColor);
}
@@ -202,7 +214,12 @@ public abstract class AbstractTagToken<T extends BaseEntity> implements Serializ
}
private void updateTokenStyle(final Object tokenId, final Button button) {
final String color = getColor(tokenId);
final Item item = tokenField.getContainerDataSource().getItem(tokenId);
if (item == null) {
return;
}
final String color = getColor(item);
button.setCaption("<span style=\"color:" + color + " !important;\">" + FontAwesome.CIRCLE.getHtml()
+ "</span>" + " " + getItemNameProperty(tokenId).getValue().toString().concat(" ×"));
button.setCaptionAsHtml(true);
@@ -215,20 +232,19 @@ public abstract class AbstractTagToken<T extends BaseEntity> implements Serializ
private void tokenClick(final Object tokenId) {
final Item item = tokenField.getContainerDataSource().addItem(tokenId);
item.getItemProperty("name").setValue(tagDetails.get(tokenId).getName());
item.getItemProperty(NAME_PROPERTY).setValue(tagDetails.get(tokenId).getName());
item.getItemProperty(COLOR_PROPERTY).setValue(tagDetails.get(tokenId).getColor());
unassignTag(tagDetails.get(tokenId).getName());
}
private Property getItemNameProperty(final Object tokenId) {
final Item item = tokenField.getContainerDataSource().getItem(tokenId);
return item.getItemProperty("name");
return item.getItemProperty(NAME_PROPERTY);
}
}
private String getColor(final Object tokenId) {
final Item item = tokenField.getContainerDataSource().getItem(tokenId);
private static String getColor(final Item item) {
if (item.getItemProperty(COLOR_PROPERTY).getValue() != null) {
return (String) item.getItemProperty(COLOR_PROPERTY).getValue();
} else {
@@ -236,9 +252,8 @@ public abstract class AbstractTagToken<T extends BaseEntity> implements Serializ
}
}
private String getTagName(final Object tokenId) {
final Item item = tokenField.getContainerDataSource().getItem(tokenId);
return (String) item.getItemProperty("name").getValue();
private static String getTagName(final Item item) {
return (String) item.getItemProperty(NAME_PROPERTY).getValue();
}
protected void removePreviouslyAddedTokens() {

View File

@@ -8,15 +8,19 @@
*/
package org.eclipse.hawkbit.ui.common.tagdetails;
import java.util.List;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.ui.push.TargetTagCreatedEventContainer;
import org.eclipse.hawkbit.ui.push.TargetTagDeletedEventContainer;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.data.Item;
/**
* /** Abstract class for target tag token layout.
*
@@ -31,16 +35,25 @@ public abstract class AbstractTargetTagToken<T extends BaseEntity> extends Abstr
protected transient TagManagement tagManagement;
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEventTargetTagCreated(final TargetTagCreatedBulkEvent event) {
for (final TargetTag tag : event.getEntities()) {
setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour());
}
void onEventTargetTagCreated(final TargetTagCreatedEventContainer container) {
container.getEvents().stream().map(event -> event.getEntity())
.forEach(tag -> setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour()));
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onTargetDeletedEvent(final TargetTagDeletedEvent event) {
final Long deletedTagId = getTagIdByTagName(event.getEntity().getName());
removeTagFromCombo(deletedTagId);
void onTargetTagDeletedEvent(final TargetTagDeletedEventContainer container) {
container.getEvents().stream().map(event -> getTagIdByTagName(event.getEntity().getName()))
.forEach(this::removeTagFromCombo);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onTargetTagUpdateEvent(final List<TargetTagUpdateEvent> events) {
events.stream().map(event -> event.getEntity()).forEach(entity -> {
final Item item = container.getItem(entity.getId());
if (item != null) {
updateItem(entity.getName(), entity.getColour(), item);
}
});
}
}

View File

@@ -8,27 +8,26 @@
*/
package org.eclipse.hawkbit.ui.common.tagdetails;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagAssigmentResultEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.push.DistributionSetTagAssignmentResultEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionSetTagCreatedEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionSetTagDeletedEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionSetTagUpdatedEventContainer;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.google.common.collect.Sets;
import com.vaadin.data.Item;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -74,10 +73,8 @@ public class DistributionTagToken extends AbstractTagToken<DistributionSet> {
}
private DistributionSetTagAssignmentResult toggleAssignment(final String tagNameSelected) {
final Set<Long> distributionList = new HashSet<>();
distributionList.add(selectedEntity.getId());
final DistributionSetTagAssignmentResult result = distributionSetManagement
.toggleTagAssignment(distributionList, tagNameSelected);
.toggleTagAssignment(Sets.newHashSet(selectedEntity.getId()), tagNameSelected);
uinotification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(tagNameSelected, result, i18n));
return result;
}
@@ -120,42 +117,42 @@ public class DistributionTagToken extends AbstractTagToken<DistributionSet> {
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedBulkEvent event) {
for (final DistributionSetTag distributionSetTag : event.getEntities()) {
setContainerPropertValues(distributionSetTag.getId(), distributionSetTag.getName(),
distributionSetTag.getColour());
}
void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedEventContainer eventContainer) {
eventContainer.getEvents().stream().map(event -> event.getEntity())
.forEach(distributionSetTag -> setContainerPropertValues(distributionSetTag.getId(),
distributionSetTag.getName(), distributionSetTag.getColour()));
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onDistributionSetTagDeletedEventBulkEvent(final DistributionSetTagDeletedEvent event) {
final Long deletedTagId = getTagIdByTagName(event.getEntity().getName());
removeTagFromCombo(deletedTagId);
void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEventContainer eventContainer) {
eventContainer.getEvents().stream().map(event -> getTagIdByTagName(event.getEntity().getName()))
.forEach(this::removeTagFromCombo);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdateEvent event) {
final DistributionSetTag entity = event.getEntity();
final Item item = container.getItem(entity.getId());
if (item != null) {
updateItem(entity.getName(), entity.getColour(), item);
}
void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdatedEventContainer eventContainer) {
eventContainer.getEvents().stream().map(event -> event.getEntity()).forEach(entity -> {
final Item item = container.getItem(entity.getId());
if (item != null) {
updateItem(entity.getName(), entity.getColour(), item);
}
});
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onTargetTagAssigmentResultEvent(final DistributionSetTagAssigmentResultEvent event) {
final DistributionSetTagAssignmentResult assignmentResult = event.getAssigmentResult();
final DistributionSetTag tag = assignmentResult.getDistributionSetTag();
if (isAssign(assignmentResult)) {
addNewToken(tag.getId());
} else if (isUnassign(assignmentResult)) {
removeTokenItem(tag.getId(), tag.getName());
}
void onTargetTagAssigmentResultEvent(final DistributionSetTagAssignmentResultEventContainer eventContainer) {
eventContainer.getEvents().stream().map(event -> event.getAssigmentResult()).forEach(assignmentResult -> {
final DistributionSetTag tag = assignmentResult.getDistributionSetTag();
if (isAssign(assignmentResult)) {
addNewToken(tag.getId());
} else if (isUnassign(assignmentResult)) {
removeTokenItem(tag.getId(), tag.getName());
}
});
}
protected boolean isAssign(final DistributionSetTagAssignmentResult assignmentResult) {
if (assignmentResult.getAssigned() > 0) {
if (assignmentResult.getAssigned() > 0 && managementUIState.getLastSelectedDsIdName() != null) {
final List<Long> assignedDsNames = assignmentResult.getAssignedEntity().stream().map(t -> t.getId())
.collect(Collectors.toList());
if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) {
@@ -166,7 +163,7 @@ public class DistributionTagToken extends AbstractTagToken<DistributionSet> {
}
protected boolean isUnassign(final DistributionSetTagAssignmentResult assignmentResult) {
if (assignmentResult.getUnassigned() > 0) {
if (assignmentResult.getUnassigned() > 0 && managementUIState.getLastSelectedDsIdName() != null) {
final List<Long> assignedDsNames = assignmentResult.getUnassignedEntity().stream().map(t -> t.getId())
.collect(Collectors.toList());
if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) {

View File

@@ -9,24 +9,20 @@
package org.eclipse.hawkbit.ui.common.tagdetails;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagAssigmentResultEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.push.TargetTagAssigmentResultEventContainer;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.data.Item;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -110,44 +106,32 @@ public class TargetTagToken extends AbstractTargetTagToken<Target> {
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onTargetTagUpdateEvent(final TargetTagUpdateEvent event) {
final TargetTag entity = event.getEntity();
final Item item = container.getItem(entity.getId());
if (item != null) {
updateItem(entity.getName(), entity.getColour(), item);
}
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onTargetTagAssigmentResultEvent(final TargetTagAssigmentResultEvent event) {
final TargetTagAssignmentResult assignmentResult = event.getAssigmentResult();
final TargetTag targetTag = assignmentResult.getTargetTag();
if (isAssign(assignmentResult)) {
addNewToken(targetTag.getId());
} else if (isUnassign(assignmentResult)) {
removeTokenItem(targetTag.getId(), targetTag.getName());
}
void onTargetTagAssigmentResultEvent(final TargetTagAssigmentResultEventContainer holder) {
holder.getEvents().stream().map(event -> event.getAssigmentResult()).forEach(assignmentResult -> {
final TargetTag targetTag = assignmentResult.getTargetTag();
if (isAssign(assignmentResult)) {
addNewToken(targetTag.getId());
} else if (isUnassign(assignmentResult)) {
removeTokenItem(targetTag.getId(), targetTag.getName());
}
});
}
protected boolean isAssign(final TargetTagAssignmentResult assignmentResult) {
if (assignmentResult.getAssigned() > 0) {
final List<String> assignedTargetNames = assignmentResult.getAssignedEntity().stream()
.map(t -> t.getControllerId()).collect(Collectors.toList());
if (assignedTargetNames.contains(managementUIState.getLastSelectedTargetIdName().getControllerId())) {
return true;
}
if (assignmentResult.getAssigned() > 0 && managementUIState.getLastSelectedTargetIdName() != null) {
return assignmentResult.getAssignedEntity().stream().map(t -> t.getControllerId())
.anyMatch(controllerId -> controllerId
.equals(managementUIState.getLastSelectedTargetIdName().getControllerId()));
}
return false;
}
protected boolean isUnassign(final TargetTagAssignmentResult assignmentResult) {
if (assignmentResult.getUnassigned() > 0) {
final List<String> unassignedTargetNamesList = assignmentResult.getUnassignedEntity().stream()
.map(t -> t.getControllerId()).collect(Collectors.toList());
if (unassignedTargetNamesList.contains(managementUIState.getLastSelectedTargetIdName().getControllerId())) {
return true;
}
if (assignmentResult.getUnassigned() > 0 && managementUIState.getLastSelectedTargetIdName() != null) {
return assignmentResult.getUnassignedEntity().stream().map(t -> t.getControllerId())
.anyMatch(controllerId -> controllerId
.equals(managementUIState.getLastSelectedTargetIdName().getControllerId()));
}
return false;
}

View File

@@ -26,9 +26,9 @@ import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent;
import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent.DistributionSetTypeEnum;
import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
@@ -405,7 +405,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
eventBus.publish(this,
new DistributionSetTypeEvent(DistributionSetTypeEnum.UPDATE_DIST_SET_TYPE, updateDistSetType));
} else {
uiNotification.displayValidationError(i18n.get("message.tag.update.mandatory"));
uiNotification.displayValidationError(i18n.get("message.type.update.mandatory "));
}
}

View File

@@ -21,7 +21,6 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetUpdateEvent;
import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -42,12 +41,15 @@ import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.push.DistributionCreatedEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionDeletedEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionSetUpdatedEventContainer;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -124,30 +126,56 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvents(final DistributionSetUpdateEvent event) {
final DistributionSet ds = event.getEntity();
final DistributionSetIdName lastSelectedDsIdName = manageDistUIState.getLastSelectedDistribution().isPresent()
? manageDistUIState.getLastSelectedDistribution().get() : null;
void onDistributionSetUpdateEvents(final DistributionSetUpdatedEventContainer eventContainer) {
final List<DistributionSetIdName> visibleItemIds = (List<DistributionSetIdName>) getVisibleItemIds();
// refresh the details tabs only if selected ds is updated
if (lastSelectedDsIdName != null && lastSelectedDsIdName.getId().equals(ds.getId())) {
// update table row+details layout
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, ds));
} else if (visibleItemIds.stream().filter(e -> e.getId().equals(ds.getId())).findFirst().isPresent()) {
// update the name/version details visible in table
UI.getCurrent().access(() -> updateDistributionInTable(event.getEntity()));
}
handleSelectedAndUpdatedDs(eventContainer.getEvents());
updateVisableTableEntries(eventContainer.getEvents(), visibleItemIds);
}
private void handleSelectedAndUpdatedDs(final List<DistributionSetUpdateEvent> events) {
manageDistUIState.getLastSelectedDistribution()
.ifPresent(lastSelectedDsIdName -> events.stream().map(event -> event.getEntity())
.filter(set -> set.getId().equals(lastSelectedDsIdName.getId())).findFirst()
.ifPresent(selectedSetUpdated -> eventBus.publish(this,
new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, selectedSetUpdated))));
}
private void updateVisableTableEntries(final List<DistributionSetUpdateEvent> events,
final List<DistributionSetIdName> visibleItemIds) {
events.stream().filter(event -> event.getEntity().isComplete())
.filter(event -> visibleItemIds.contains(DistributionSetIdName.generate(event.getEntity())))
.forEach(event -> updateDistributionInTable(event.getEntity()));
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvents(final List<?> events) {
final Object firstEvent = events.get(0);
if (DistributionCreatedEvent.class.isInstance(firstEvent)) {
refreshDistributions();
} else if (DistributionDeletedEvent.class.isInstance(firstEvent)) {
onDistributionDeleteEvent((List<DistributionDeletedEvent>) events);
void onDistributionCreatedEvents(final DistributionCreatedEventContainer eventContainer) {
refreshDistributions();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onDistributionDeletedEvents(final DistributionDeletedEventContainer eventContainer) {
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
boolean shouldRefreshDs = false;
for (final DistributionDeletedEvent deletedEvent : eventContainer.getEvents()) {
final Long distributionSetId = deletedEvent.getDistributionSetId();
final DistributionSetIdName targetIdName = new DistributionSetIdName(distributionSetId, null, null);
if (visibleItemIds.contains(targetIdName)) {
dsContainer.removeItem(targetIdName);
} else {
shouldRefreshDs = true;
}
}
if (shouldRefreshDs) {
refreshOnDelete();
} else {
dsContainer.commit();
}
reSelectItemsAfterDeletionEvent();
}
@Override
@@ -454,7 +482,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SaveActionWindowEvent event) {
if (event == SaveActionWindowEvent.DELETED_DISTRIBUTIONS || event == SaveActionWindowEvent.SAVED_ASSIGNMENTS) {
UI.getCurrent().access(() -> refreshFilter());
UI.getCurrent().access(this::refreshFilter);
}
}
@@ -469,7 +497,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
if (event == DistributionTableFilterEvent.FILTER_BY_TEXT
|| event == DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT
|| event == DistributionTableFilterEvent.FILTER_BY_TAG) {
UI.getCurrent().access(() -> refreshFilter());
UI.getCurrent().access(this::refreshFilter);
}
}
@@ -566,28 +594,6 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
updateEntity(editedDs, item);
}
private void onDistributionDeleteEvent(final List<DistributionDeletedEvent> events) {
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
boolean shouldRefreshDs = false;
for (final DistributionDeletedEvent deletedEvent : events) {
final Long distributionSetId = deletedEvent.getDistributionSetId();
final DistributionSetIdName targetIdName = new DistributionSetIdName(distributionSetId, null, null);
if (visibleItemIds.contains(targetIdName)) {
dsContainer.removeItem(targetIdName);
} else {
shouldRefreshDs = true;
}
}
if (shouldRefreshDs) {
refreshOnDelete();
} else {
dsContainer.commit();
}
reSelectItemsAfterDeletionEvent();
}
private void refreshOnDelete() {
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
final int size = dsContainer.size();

View File

@@ -15,9 +15,9 @@ import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
@@ -100,13 +100,11 @@ public class TargetFilterCountMessageLabel extends Label {
setDescription(null);
}
targetMessage.append(totalTargets);
targetMessage.append(HawkbitCommonUtil.SP_STRING_SPACE);
targetMessage.append(i18n.get("label.filter.shown"));
if (totalTargets > SPUIDefinitions.MAX_TABLE_ENTRIES) {
targetMessage.append(HawkbitCommonUtil.SP_STRING_PIPE);
targetMessage.append(i18n.get("label.filter.shown"));
targetMessage.append(SPUIDefinitions.MAX_TABLE_ENTRIES);
} else {
targetMessage.append(HawkbitCommonUtil.SP_STRING_SPACE);
targetMessage.append(totalTargets);
}
setCaption(targetMessage.toString());

View File

@@ -12,6 +12,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
@@ -19,7 +20,6 @@ import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetUpdateEvent;
import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -41,6 +41,9 @@ import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent;
import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.push.DistributionCreatedEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionDeletedEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionSetUpdatedEventContainer;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
@@ -113,44 +116,95 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvents(final List<?> events) {
final Object firstEvent = events.get(0);
if (DistributionDeletedEvent.class.isInstance(firstEvent)) {
onDistributionDeleteEvent((List<DistributionDeletedEvent>) events);
} else if (DistributionCreatedEvent.class.isInstance(firstEvent)
&& ((DistributionCreatedEvent) firstEvent).getEntity().isComplete()) {
void onDistributionCreatedEvents(final DistributionCreatedEventContainer eventContainer) {
if (eventContainer.getEvents().stream().anyMatch(event -> event.getEntity().isComplete())) {
refreshDistributions();
}
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvents(final DistributionSetUpdateEvent event) {
final DistributionSet ds = event.getEntity();
void onDistributionDeleteEvents(final DistributionDeletedEventContainer eventContainer) {
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
boolean shouldRefreshDs = false;
for (final DistributionDeletedEvent deletedEvent : eventContainer.getEvents()) {
final Long distributionSetId = deletedEvent.getDistributionSetId();
final DistributionSetIdName targetIdName = new DistributionSetIdName(distributionSetId, null, null);
if (visibleItemIds.contains(targetIdName)) {
dsContainer.removeItem(targetIdName);
} else {
shouldRefreshDs = true;
}
}
if (shouldRefreshDs) {
refreshOnDelete();
} else {
dsContainer.commit();
}
reSelectItemsAfterDeletionEvent();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onDistributionSetUpdateEvents(final DistributionSetUpdatedEventContainer eventContainer) {
final List<DistributionSetIdName> visibleItemIds = (List<DistributionSetIdName>) getVisibleItemIds();
final Boolean dsVisible = visibleItemIds.stream().filter(e -> e.getId().equals(ds.getId())).findFirst()
.isPresent();
if (allOfThemAffectCompletedSetsThatAreNotVisible(eventContainer.getEvents(), visibleItemIds)) {
refreshDistributions();
} else if (!checkAndHandleIfVisibleDsSwitchesFromCompleteToIncomplete(eventContainer.getEvents(),
visibleItemIds)) {
updateVisableTableEntries(eventContainer.getEvents(), visibleItemIds);
}
if (ds.isComplete() && !dsVisible) {
final DistributionSetIdName lastSelectedDsIdName = managementUIState.getLastSelectedDsIdName();
// refresh the details tabs only if selected ds is updated
if (lastSelectedDsIdName != null) {
final Optional<DistributionSet> selectedSetUpdated = eventContainer.getEvents().stream()
.map(event -> event.getEntity()).filter(set -> set.getId().equals(lastSelectedDsIdName.getId()))
.findFirst();
if (selectedSetUpdated.isPresent()) {
// update table row+details layout
eventBus.publish(this,
new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, selectedSetUpdated.get()));
}
}
}
private static boolean allOfThemAffectCompletedSetsThatAreNotVisible(final List<DistributionSetUpdateEvent> events,
final List<DistributionSetIdName> visibleItemIds) {
return events.stream().map(event -> event.getEntity())
.allMatch(set -> set.isComplete() && !visibleItemIds.contains(DistributionSetIdName.generate(set)));
}
private void updateVisableTableEntries(final List<DistributionSetUpdateEvent> events,
final List<DistributionSetIdName> visibleItemIds) {
events.stream().filter(event -> event.getEntity().isComplete())
.filter(event -> visibleItemIds.contains(DistributionSetIdName.generate(event.getEntity())))
.forEach(event -> updateDistributionInTable(event.getEntity()));
}
private boolean checkAndHandleIfVisibleDsSwitchesFromCompleteToIncomplete(
final List<DistributionSetUpdateEvent> events, final List<DistributionSetIdName> visibleItemIds) {
final List<DistributionSet> setsThatAreVisibleButNotCompleteAnymore = events.stream()
.map(event -> event.getEntity()).filter(set -> !set.isComplete())
.filter(set -> visibleItemIds.contains(DistributionSetIdName.generate(set)))
.collect(Collectors.toList());
if (!setsThatAreVisibleButNotCompleteAnymore.isEmpty()) {
refreshDistributions();
} else if (!ds.isComplete() && dsVisible) {
refreshDistributions();
if (ds.getId().equals(managementUIState.getLastSelectedDsIdName().getId())) {
if (setsThatAreVisibleButNotCompleteAnymore.stream()
.anyMatch(set -> set.getId().equals(managementUIState.getLastSelectedDsIdName().getId()))) {
managementUIState.setLastSelectedDistribution(null);
managementUIState.setLastSelectedEntity(null);
}
} else if (dsVisible) {
UI.getCurrent().access(() -> updateDistributionInTable(event.getEntity()));
}
final DistributionSetIdName lastSelectedDsIdName = managementUIState.getLastSelectedDsIdName();
// refresh the details tabs only if selected ds is updated
if (lastSelectedDsIdName != null && lastSelectedDsIdName.getId().equals(ds.getId())) {
// update table row+details layout
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, ds));
return true;
}
return false;
}
/**
@@ -717,28 +771,6 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
}
private void onDistributionDeleteEvent(final List<DistributionDeletedEvent> events) {
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
boolean shouldRefreshDs = false;
for (final DistributionDeletedEvent deletedEvent : events) {
final Long distributionSetId = deletedEvent.getDistributionSetId();
final DistributionSetIdName targetIdName = new DistributionSetIdName(distributionSetId, null, null);
if (visibleItemIds.contains(targetIdName)) {
dsContainer.removeItem(targetIdName);
} else {
shouldRefreshDs = true;
}
}
if (shouldRefreshDs) {
refreshOnDelete();
} else {
dsContainer.commit();
}
reSelectItemsAfterDeletionEvent();
}
private void reSelectItemsAfterDeletionEvent() {
Set<Object> values = new HashSet<>();
if (isMultiSelect()) {

View File

@@ -13,13 +13,13 @@ import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import java.util.List;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
import org.eclipse.hawkbit.ui.layouts.AbstractCreateUpdateTagLayout;
import org.eclipse.hawkbit.ui.push.DistributionSetTagCreatedEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionSetTagDeletedEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionSetTagUpdatedEventContainer;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -28,7 +28,6 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.UI;
/**
@@ -49,21 +48,21 @@ public class CreateUpdateDistributionTagLayoutWindow extends AbstractCreateUpdat
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedBulkEvent event) {
void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedEventContainer eventContainer) {
populateTagNameCombo();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEvent event) {
void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEventContainer eventContainer) {
populateTagNameCombo();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdateEvent event) {
void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdatedEventContainer eventContainer) {
populateTagNameCombo();
}

View File

@@ -11,9 +11,6 @@ package org.eclipse.hawkbit.ui.management.dstag;
import java.util.Collections;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtonClickBehaviour;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
@@ -21,11 +18,14 @@ import org.eclipse.hawkbit.ui.management.event.DistributionTagDropEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.management.tag.TagIdName;
import org.eclipse.hawkbit.ui.push.DistributionSetTagCreatedEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionSetTagDeletedEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionSetTagUpdatedEventContainer;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
@@ -66,21 +66,21 @@ public class DistributionTagButtons extends AbstractFilterButtons {
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedBulkEvent event) {
void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedEventContainer eventContainer) {
refreshTagTable();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEvent event) {
void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEventContainer eventContainer) {
refreshTagTable();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdateEvent event) {
void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdatedEventContainer eventContainer) {
refreshTagTable();
}

View File

@@ -14,9 +14,7 @@ import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
@@ -26,15 +24,15 @@ import org.eclipse.hawkbit.ui.management.state.TargetTableFilters;
import org.eclipse.hawkbit.ui.management.targettable.TargetTable;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
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;
import com.google.common.base.Strings;
import com.google.common.base.Optional;
import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.spring.annotation.SpringComponent;
@@ -131,17 +129,17 @@ public class CountMessageLabel extends Label {
private void displayTargetCountStatus() {
final TargetTableFilters targFilParams = managementUIState.getTargetTableFilters();
final StringBuilder message = getTotalTargetMessage(targFilParams);
final String filteredTargets = i18n.get("label.filter.targets");
final StringBuilder message = getTotalTargetMessage();
if (targFilParams.hasFilter()) {
message.append(filteredTargets);
message.append(HawkbitCommonUtil.SP_STRING_PIPE);
message.append(i18n.get("label.filter.targets"));
if (managementUIState.getTargetsTruncated() != null) {
message.append(targetTable.size() + managementUIState.getTargetsTruncated());
} else {
message.append(targetTable.size());
}
message.append(HawkbitCommonUtil.SP_STRING_SPACE);
message.append(HawkbitCommonUtil.SP_STRING_PIPE);
final String status = i18n.get("label.filter.status");
final String overdue = i18n.get("label.filter.overdue");
final String tags = i18n.get("label.filter.tags");
@@ -154,13 +152,12 @@ public class CountMessageLabel extends Label {
filterMesgBuf.append(getOverdueStateMsg(targFilParams.isOverdueFilterEnabled(), overdue));
filterMesgBuf
.append(getTagsMsg(targFilParams.isNoTagSelected(), targFilParams.getClickedTargetTags(), tags));
filterMesgBuf.append(getSerachMsg(
targFilParams.getSearchText().isPresent() ? targFilParams.getSearchText().get() : null, text));
filterMesgBuf.append(getDistMsg(
targFilParams.getDistributionSet().isPresent() ? targFilParams.getDistributionSet().get() : null,
dists));
filterMesgBuf.append(getCustomFilterMsg(targFilParams.getTargetFilterQuery().isPresent()
? targFilParams.getTargetFilterQuery().get() : null, custom));
filterMesgBuf.append(
targFilParams.getSearchText().map(search -> text).orElse(HawkbitCommonUtil.SP_STRING_SPACE));
filterMesgBuf.append(
targFilParams.getDistributionSet().map(set -> dists).orElse(HawkbitCommonUtil.SP_STRING_SPACE));
filterMesgBuf.append(targFilParams.getTargetFilterQuery().map(query -> custom)
.orElse(HawkbitCommonUtil.SP_STRING_SPACE));
final String filterMesageChk = filterMesgBuf.toString().trim();
String filterMesage = filterMesageChk;
if (filterMesage.endsWith(",")) {
@@ -168,17 +165,23 @@ public class CountMessageLabel extends Label {
}
message.append(filterMesage);
}
if ((targetTable.size() + Optional.fromNullable(managementUIState.getTargetsTruncated())
.or(0L)) > SPUIDefinitions.MAX_TABLE_ENTRIES) {
message.append(HawkbitCommonUtil.SP_STRING_PIPE);
message.append(i18n.get("label.filter.shown"));
message.append(SPUIDefinitions.MAX_TABLE_ENTRIES);
}
setCaption(message.toString());
}
private StringBuilder getTotalTargetMessage(final TargetTableFilters targFilParams) {
long totalTargetTableEnteries = targetTable.size();
private StringBuilder getTotalTargetMessage() {
if (managementUIState.getTargetsTruncated() != null) {
// set the icon
setIcon(FontAwesome.INFO_CIRCLE);
setDescription(i18n.get("label.target.filter.truncated", managementUIState.getTargetsTruncated(),
SPUIDefinitions.MAX_TABLE_ENTRIES));
totalTargetTableEnteries += managementUIState.getTargetsTruncated();
} else {
setIcon(null);
setDescription(null);
@@ -186,20 +189,7 @@ public class CountMessageLabel extends Label {
final StringBuilder message = new StringBuilder(i18n.get("label.target.filter.count"));
message.append(managementUIState.getTargetsCountAll());
message.append(HawkbitCommonUtil.SP_STRING_SPACE);
if (totalTargetTableEnteries > SPUIDefinitions.MAX_TABLE_ENTRIES) {
message.append(i18n.get("label.filter.shown"));
message.append(SPUIDefinitions.MAX_TABLE_ENTRIES);
} else {
if (!targFilParams.hasFilter()) {
message.append(i18n.get("label.filter.shown"));
message.append(targetTable.size());
}
message.append(HawkbitCommonUtil.SP_STRING_SPACE);
}
message.append(HawkbitCommonUtil.SP_STRING_SPACE);
return message;
}
@@ -255,37 +245,4 @@ public class CountMessageLabel extends Label {
return tags.isEmpty() && (noTargetTagSelected == null || !noTargetTagSelected.booleanValue())
? HawkbitCommonUtil.SP_STRING_SPACE : param;
}
/**
* Get Search Text Message.
*
* @param searchTxt
* as search text
* @return String as msg.
*/
private static String getSerachMsg(final String searchTxt, final String param) {
return Strings.isNullOrEmpty(searchTxt) ? HawkbitCommonUtil.SP_STRING_SPACE : param;
}
/**
* Get Dist set Message.
*
* @param distId
* as serach
* @return String as msg.
*/
private static String getDistMsg(final DistributionSetIdName distributionSetIdName, final String param) {
return distributionSetIdName != null ? param : HawkbitCommonUtil.SP_STRING_SPACE;
}
/**
* Get the custom target filter message.
*
* @param targetFilterQuery
* @param param
* @return
*/
private static String getCustomFilterMsg(final TargetFilterQuery targetFilterQuery, final String param) {
return targetFilterQuery != null ? param : HawkbitCommonUtil.SP_STRING_SPACE;
}
}

View File

@@ -25,16 +25,17 @@ import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
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.VaadinSessionScope;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.TextArea;
@@ -45,7 +46,7 @@ import com.vaadin.ui.Window;
* Add and Update Target.
*/
@SpringComponent
@VaadinSessionScope
@ViewScope
public class TargetAddUpdateWindowLayout extends CustomComponent {
private static final long serialVersionUID = -6659290471705262389L;

View File

@@ -21,6 +21,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.repository.FilterParams;
import org.apache.commons.collections4.CollectionUtils;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -52,15 +53,15 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
private static final long serialVersionUID = -5645680058303167558L;
private Sort sort = new Sort(TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt");
private transient Collection<TargetUpdateStatus> status = null;
private transient Collection<TargetUpdateStatus> status;
private transient Boolean overdueState;
private String[] targetTags = null;
private Long distributionId = null;
private String searchText = null;
private Boolean noTagClicked = Boolean.FALSE;
private String[] targetTags;
private Long distributionId;
private String searchText;
private Boolean noTagClicked;
private transient TargetManagement targetManagement;
private transient I18N i18N;
private Long pinnedDistId = null;
private Long pinnedDistId;
private TargetFilterQuery targetFilterQuery;
private ManagementUIState managementUIState;
@@ -210,7 +211,7 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
private boolean isAnyFilterSelected() {
final boolean isFilterSelected = isTagSelected() || isOverdueFilterEnabled();
return isFilterSelected || status != null || distributionId != null || !isNullOrEmpty(searchText);
return isFilterSelected || CollectionUtils.isNotEmpty(status) || distributionId != null || !isNullOrEmpty(searchText);
}
private TargetManagement getTargetManagement() {

View File

@@ -22,17 +22,16 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.collections4.CollectionUtils;
import org.eclipse.hawkbit.repository.FilterParams;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetUpdatedEvent;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetIdName;
@@ -55,6 +54,11 @@ 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.management.state.TargetTableFilters;
import org.eclipse.hawkbit.ui.push.CancelTargetAssignmentEventContainer;
import org.eclipse.hawkbit.ui.push.TargetCreatedEventContainer;
import org.eclipse.hawkbit.ui.push.TargetDeletedEventContainer;
import org.eclipse.hawkbit.ui.push.TargetInfoUpdateEventContainer;
import org.eclipse.hawkbit.ui.push.TargetUpdatedEventContainer;
import org.eclipse.hawkbit.ui.utils.AssignInstalledDSTooltipGenerator;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -74,6 +78,7 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.event.dd.DragAndDropEvent;
@@ -123,28 +128,86 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
setItemDescriptionGenerator(new AssignInstalledDSTooltipGenerator());
}
/**
* EventListener method which is called when a list of events is published.
* Event types should not be mixed up.
*
* @param events
* list of events
*/
@EventBusListenerMethod(scope = EventScope.SESSION)
public void onEvents(final List<?> events) {
final Object firstEvent = events.get(0);
if (TargetCreatedEvent.class.isInstance(firstEvent)) {
onTargetCreatedEvents();
} else if (TargetInfoUpdateEvent.class.isInstance(firstEvent)) {
onTargetUpdateEvents(((List<TargetInfoUpdateEvent>) events).stream()
.map(targetInfoUpdateEvent -> targetInfoUpdateEvent.getEntity().getTarget())
.collect(Collectors.toList()));
} else if (TargetDeletedEvent.class.isInstance(firstEvent)) {
onTargetDeletedEvent((List<TargetDeletedEvent>) events);
} else if (TargetUpdatedEvent.class.isInstance(firstEvent)) {
onTargetUpdateEvents(((List<TargetUpdatedEvent>) events).stream()
.map(targetInfoUpdateEvent -> targetInfoUpdateEvent.getEntity()).collect(Collectors.toList()));
void onTargetDeletedEvents(final TargetDeletedEventContainer eventContainer) {
final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource();
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
boolean shouldRefreshTargets = false;
for (final TargetDeletedEvent deletedEvent : eventContainer.getEvents()) {
final TargetIdName targetIdName = new TargetIdName(deletedEvent.getTargetId(), null, null);
if (visibleItemIds.contains(targetIdName)) {
targetContainer.removeItem(targetIdName);
} else {
shouldRefreshTargets = true;
break;
}
}
if (shouldRefreshTargets) {
refreshOnDelete();
} else {
targetContainer.commit();
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.REFRESH_TARGETS));
}
reSelectItemsAfterDeletionEvent();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onCancelTargetAssignmentEvents(final CancelTargetAssignmentEventContainer eventContainer) {
// workaround until push is available for action
// history, re-select
// the updated target so the action history gets
// refreshed.
reselectTargetIfSelectedInStream(eventContainer.getEvents().stream().map(event -> event.getTarget()));
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onTargetUpdatedEvents(final TargetUpdatedEventContainer eventContainer) {
onTargetUpdateEvents(eventContainer.getEvents().stream()
.map(targetInfoUpdateEvent -> targetInfoUpdateEvent.getEntity()).collect(Collectors.toList()));
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onTargetInfoUpdateEvents(final TargetInfoUpdateEventContainer eventContainer) {
onTargetUpdateEvents(eventContainer.getEvents().stream()
.map(targetInfoUpdateEvent -> targetInfoUpdateEvent.getEntity().getTarget())
.collect(Collectors.toList()));
}
/**
* EventListener method which is called by the event bus to notify about a
* list of {@link TargetInfoUpdateEvent}.
*
* @param updatedTargets
* list of updated targets
*/
private void onTargetUpdateEvents(final List<Target> updatedTargets) {
final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource();
@SuppressWarnings("unchecked")
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
if (isFilterEnabled()) {
refreshTargets();
} else {
updatedTargets.stream().filter(target -> visibleItemIds.contains(target.getTargetIdName()))
.forEach(target -> updateVisibleItemOnEvent(target.getTargetInfo()));
targetContainer.commit();
}
// workaround until push is available for action
// history, re-select
// the updated target so the action history gets
// refreshed.
reselectTargetIfSelectedInStream(updatedTargets.stream());
}
private void reselectTargetIfSelectedInStream(final Stream<Target> targets) {
targets.filter(target -> isLastSelectedTarget(target.getTargetIdName())).findAny().ifPresent(
target -> eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.SELECTED_ENTITY, target)));
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onTargetCreatedEvents(final TargetCreatedEventContainer holder) {
refreshTargets();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -300,31 +363,12 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
return managementViewAcceptCriteria;
}
private void onTargetDeletedEvent(final List<TargetDeletedEvent> events) {
final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource();
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
boolean shouldRefreshTargets = false;
for (final TargetDeletedEvent deletedEvent : events) {
final TargetIdName targetIdName = new TargetIdName(deletedEvent.getTargetId(), null, null);
if (visibleItemIds.contains(targetIdName)) {
targetContainer.removeItem(targetIdName);
} else {
shouldRefreshTargets = true;
}
}
if (shouldRefreshTargets) {
refreshOnDelete();
} else {
targetContainer.commit();
}
reSelectItemsAfterDeletionEvent();
}
private void reSelectItemsAfterDeletionEvent() {
Set<Object> values = new HashSet<>();
Set<Object> values;
if (isMultiSelect()) {
values = new HashSet<>((Set<?>) getValue());
} else {
values = Sets.newHashSetWithExpectedSize(1);
values.add(getValue());
}
unSelectAll();
@@ -766,41 +810,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
&& managementUIState.getLastSelectedTargetIdName().equals(targetIdName);
}
/**
* EventListener method which is called by the event bus to notify about a
* list of {@link TargetInfoUpdateEvent}.
*
* @param updatedTargets
* list of updated targets
*/
private void onTargetUpdateEvents(final List<Target> updatedTargets) {
@SuppressWarnings("unchecked")
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
if (isFilterEnabled()) {
LOG.debug("Filter enabled on UI {}. Refresh targets from database.", getUI().getUIId());
refreshTargets();
} else {
updatedTargets.stream().filter(target -> visibleItemIds.contains(target.getTargetIdName()))
.forEach(target -> updateVisibleItemOnEvent(target.getTargetInfo()));
}
// workaround until push is available for action
// history, re-select
// the updated target so the action history gets
// refreshed.
final Optional<Target> selected = updatedTargets.stream()
.filter(target -> isLastSelectedTarget(target.getTargetIdName())).findAny();
if (selected.isPresent()) {
LOG.debug("Selected element has changed on UI {}. Reselect to update action history.", getUI().getUIId());
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.SELECTED_ENTITY, selected.get()));
}
}
private void onTargetCreatedEvents() {
refreshTargets();
}
private boolean isFilterEnabled() {
final TargetTableFilters targetTableFilters = managementUIState.getTargetTableFilters();
return targetTableFilters.getSearchText().isPresent() || !targetTableFilters.getClickedTargetTags().isEmpty()
@@ -873,16 +882,12 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
}
private long getTargetsCountWithFilter(final long totalTargetsCount,
// final Collection<TargetUpdateStatus> status,
// final Boolean overdueState, final String[] targetTags, final Long
// distributionId, final String searchText,
// final Boolean noTagClicked
final Long pinnedDistId, final FilterParams filterParams) {
final long size;
if (managementUIState.getTargetTableFilters().getTargetFilterQuery().isPresent()) {
size = targetManagement.countTargetByTargetFilterQuery(
managementUIState.getTargetTableFilters().getTargetFilterQuery().get());
} else if (!anyFilterSelected(filterParams.getFilterByStatus(), pinnedDistId,
} else if (noFilterSelected(filterParams.getFilterByStatus(), pinnedDistId,
filterParams.getSelectTargetWithNoTag(), filterParams.getFilterByTagNames(),
filterParams.getFilterBySearchText())) {
size = totalTargetsCount;
@@ -900,9 +905,9 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
&& !Strings.isNullOrEmpty(managementUIState.getTargetTableFilters().getSearchText().get());
}
private static Boolean anyFilterSelected(final Collection<TargetUpdateStatus> status, final Long distributionId,
private static boolean noFilterSelected(final Collection<TargetUpdateStatus> status, final Long distributionId,
final Boolean noTagClicked, final String[] targetTags, final String searchText) {
return status == null && distributionId == null && Strings.isNullOrEmpty(searchText)
return CollectionUtils.isEmpty(status) && distributionId == null && Strings.isNullOrEmpty(searchText)
&& !isTagSelected(targetTags, noTagClicked);
}

View File

@@ -13,13 +13,13 @@ import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import java.util.List;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
import org.eclipse.hawkbit.ui.layouts.AbstractCreateUpdateTagLayout;
import org.eclipse.hawkbit.ui.push.TargetTagCreatedEventContainer;
import org.eclipse.hawkbit.ui.push.TargetTagDeletedEventContainer;
import org.eclipse.hawkbit.ui.push.TargetTagUpdatedEventContainer;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -43,21 +43,21 @@ public class CreateUpdateTargetTagLayoutWindow extends AbstractCreateUpdateTagLa
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onEventTargetTagCreated(final TargetTagCreatedBulkEvent event) {
void onEventTargetTagCreated(final TargetTagCreatedEventContainer eventContainer) {
populateTagNameCombo();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onEventTargetDeletedEvent(final TargetTagDeletedEvent event) {
void onEventTargetDeletedEvent(final TargetTagDeletedEventContainer eventContainer) {
populateTagNameCombo();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onEventTargetTagUpdateEvent(final TargetTagUpdateEvent event) {
void onEventTargetTagUpdateEvent(final TargetTagUpdatedEventContainer eventContainer) {
populateTagNameCombo();
}

View File

@@ -28,7 +28,7 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.VaadinSessionScope;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
@@ -41,7 +41,7 @@ import com.vaadin.ui.VerticalLayout;
*
*/
@SpringComponent
@VaadinSessionScope
@ViewScope
public class FilterByStatusLayout extends VerticalLayout implements Button.ClickListener {
private static final long serialVersionUID = -6930348859189929850L;

View File

@@ -15,9 +15,6 @@ import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
@@ -28,11 +25,14 @@ import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.management.tag.TagIdName;
import org.eclipse.hawkbit.ui.push.TargetTagCreatedEventContainer;
import org.eclipse.hawkbit.ui.push.TargetTagDeletedEventContainer;
import org.eclipse.hawkbit.ui.push.TargetTagUpdatedEventContainer;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
@@ -286,21 +286,21 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onEvent(final TargetTagUpdateEvent event) {
void onEvent(final TargetTagUpdatedEventContainer eventContainer) {
refreshContainer();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onEventTargetTagCreated(final TargetTagCreatedBulkEvent event) {
void onEventTargetTagCreated(final TargetTagCreatedEventContainer eventContainer) {
refreshContainer();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onEventTargetDeletedEvent(final TargetTagDeletedEvent event) {
void onEventTargetDeletedEvent(final TargetTagDeletedEventContainer eventContainer) {
refreshContainer();
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.CancelTargetAssignmentEvent;
/**
* EventHolder for {@link CancelTargetAssignmentEvent}s.
*
*/
public class CancelTargetAssignmentEventContainer implements EventContainer<CancelTargetAssignmentEvent> {
private final List<CancelTargetAssignmentEvent> events;
CancelTargetAssignmentEventContainer(final List<CancelTargetAssignmentEvent> events) {
this.events = events;
}
@Override
public List<CancelTargetAssignmentEvent> getEvents() {
return events;
}
}

View File

@@ -8,9 +8,9 @@
*/
package org.eclipse.hawkbit.ui.push;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.LinkedBlockingDeque;
@@ -22,7 +22,6 @@ import java.util.stream.Collectors;
import org.eclipse.hawkbit.eventbus.event.EntityEvent;
import org.eclipse.hawkbit.eventbus.event.Event;
import org.eclipse.hawkbit.im.authentication.TenantAwareAuthenticationDetails;
import org.eclipse.hawkbit.ui.UIEventProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.context.SecurityContext;
@@ -113,8 +112,7 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
}
private boolean isEventProvided(final Event event) {
return eventProvider.getSingleEvents().contains(event.getClass())
|| eventProvider.getBulkEvents().contains(event.getClass());
return eventProvider.getEvents().containsKey(event.getClass());
}
@Override
@@ -125,8 +123,8 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
LOG.error("Vaadin session of UI {} is null! Event push disabled!", uiid);
}
jobHandle = executorService.scheduleWithFixedDelay(new DispatchRunnable(vaadinUI, vaadinUI.getSession()), 500,
2000, TimeUnit.MILLISECONDS);
jobHandle = executorService.scheduleWithFixedDelay(new DispatchRunnable(vaadinUI, vaadinUI.getSession()),
10_000, 1_000, TimeUnit.MILLISECONDS);
systemEventBus.register(this);
}
@@ -212,13 +210,13 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
try {
SecurityContextHolder.setContext(userContext);
final List<EventContainer<Event>> groupedEvents = groupEvents(events, userContext, eventProvider);
vaadinUI.access(() -> {
if (vaadinSession.getState() != State.OPEN) {
return;
}
LOG.debug("UI EventBus aggregator of UI {} got lock on session.", vaadinUI.getUIId());
fowardSingleEvents(events, userContext);
fowardBulkEvents(events, userContext);
groupedEvents.forEach(holder -> eventBus.publish(vaadinUI, holder));
LOG.debug("UI EventBus aggregator of UI {} left lock on session.", vaadinUI.getUIId());
}).get();
} catch (InterruptedException | ExecutionException e) {
@@ -228,25 +226,25 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
}
}
private void fowardBulkEvents(final List<Event> events, final SecurityContext userContext) {
final Set<Class<?>> filterBulkEvenTypes = eventProvider.getFilteredBulkEventsType(events);
@SuppressWarnings("unchecked")
private List<EventContainer<Event>> groupEvents(final List<Event> events, final SecurityContext userContext,
final UIEventProvider eventProvider) {
for (final Class<?> bulkType : filterBulkEvenTypes) {
final List<Event> listBulkEvents = events.stream()
.filter(event -> DelayedEventBusPushStrategy.eventSecurityCheck(userContext, event)
&& bulkType.isInstance(event))
.collect(Collectors.toList());
if (!listBulkEvents.isEmpty()) {
eventBus.publish(vaadinUI, listBulkEvents);
}
}
}
return events.stream().filter(event -> eventSecurityCheck(userContext, event))
.collect(Collectors.groupingBy(Event::getClass)).entrySet().stream().map(entry -> {
EventContainer<Event> holder = null;
try {
final Constructor<Event> declaredConstructor = (Constructor<Event>) eventProvider
.getEvents().get(entry.getKey()).getDeclaredConstructor(List.class);
declaredConstructor.setAccessible(true);
private void fowardSingleEvents(final List<Event> events, final SecurityContext userContext) {
events.stream()
.filter(event -> DelayedEventBusPushStrategy.eventSecurityCheck(userContext, event)
&& eventProvider.getSingleEvents().contains(event.getClass()))
.forEach(event -> eventBus.publish(vaadinUI, event));
holder = (EventContainer<Event>) declaredConstructor.newInstance(entry.getValue());
} catch (final ReflectiveOperationException e) {
LOG.error("Failed to create EventHolder!", e);
}
return holder;
}).collect(Collectors.toList());
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent;
/**
* EventHolder for {@link DistributionCreatedEvent}s.
*
*/
public class DistributionCreatedEventContainer implements EventContainer<DistributionCreatedEvent> {
private final List<DistributionCreatedEvent> events;
DistributionCreatedEventContainer(final List<DistributionCreatedEvent> events) {
this.events = events;
}
@Override
public List<DistributionCreatedEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionDeletedEvent;
/**
* EventHolder for {@link DistributionDeletedEvent}s.
*
*/
public class DistributionDeletedEventContainer implements EventContainer<DistributionDeletedEvent> {
private final List<DistributionDeletedEvent> events;
DistributionDeletedEventContainer(final List<DistributionDeletedEvent> events) {
this.events = events;
}
@Override
public List<DistributionDeletedEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,32 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagAssigmentResultEvent;
/**
* EventHolder for {@link DistributionSetTagAssigmentResultEvent}s.
*
*/
public class DistributionSetTagAssignmentResultEventContainer
implements EventContainer<DistributionSetTagAssigmentResultEvent> {
private final List<DistributionSetTagAssigmentResultEvent> events;
DistributionSetTagAssignmentResultEventContainer(final List<DistributionSetTagAssigmentResultEvent> events) {
this.events = events;
}
@Override
public List<DistributionSetTagAssigmentResultEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedEvent;
/**
* EventHolder for {@link DistributionSetTagCreatedEvent}s.
*
*/
public class DistributionSetTagCreatedEventContainer implements EventContainer<DistributionSetTagCreatedEvent> {
private final List<DistributionSetTagCreatedEvent> events;
DistributionSetTagCreatedEventContainer(final List<DistributionSetTagCreatedEvent> events) {
this.events = events;
}
@Override
public List<DistributionSetTagCreatedEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
/**
* EventHolder for {@link DistributionSetTagDeletedEvent}s.
*
*/
public class DistributionSetTagDeletedEventContainer implements EventContainer<DistributionSetTagDeletedEvent> {
private final List<DistributionSetTagDeletedEvent> events;
DistributionSetTagDeletedEventContainer(final List<DistributionSetTagDeletedEvent> events) {
this.events = events;
}
@Override
public List<DistributionSetTagDeletedEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
/**
* EventHolder for {@link DistributionSetTagUpdateEvent}s.
*
*/
public class DistributionSetTagUpdatedEventContainer implements EventContainer<DistributionSetTagUpdateEvent> {
private final List<DistributionSetTagUpdateEvent> events;
DistributionSetTagUpdatedEventContainer(final List<DistributionSetTagUpdateEvent> events) {
this.events = events;
}
@Override
public List<DistributionSetTagUpdateEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetUpdateEvent;
/**
* EventHolder for {@link DistributionSetUpdateEvent}s.
*
*/
public class DistributionSetUpdatedEventContainer implements EventContainer<DistributionSetUpdateEvent> {
private final List<DistributionSetUpdateEvent> events;
DistributionSetUpdatedEventContainer(final List<DistributionSetUpdateEvent> events) {
this.events = events;
}
@Override
public List<DistributionSetUpdateEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.eventbus.event.Event;
/**
* EventHolder beans contains a list of events that can be process by the UI in
* batch like fashion.
*
* @param <T>
* event type
*
*/
@FunctionalInterface
public interface EventContainer<T extends Event> {
/**
* @return list of contained events
*/
List<T> getEvents();
}

View File

@@ -0,0 +1,75 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.Map;
import org.eclipse.hawkbit.eventbus.event.Event;
import org.eclipse.hawkbit.repository.eventbus.event.CancelTargetAssignmentEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagAssigmentResultEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetUpdateEvent;
import org.eclipse.hawkbit.repository.eventbus.event.RolloutChangeEvent;
import org.eclipse.hawkbit.repository.eventbus.event.RolloutGroupChangeEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagAssigmentResultEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetUpdatedEvent;
import com.google.common.collect.Maps;
/**
* The default hawkbit event provider.
*/
public class HawkbitEventProvider implements UIEventProvider {
private static final Map<Class<? extends Event>, Class<?>> EVENTS = Maps.newHashMapWithExpectedSize(18);
static {
EVENTS.put(TargetTagDeletedEvent.class, TargetTagDeletedEventContainer.class);
EVENTS.put(TargetTagCreatedEvent.class, TargetTagCreatedEventContainer.class);
EVENTS.put(TargetTagUpdateEvent.class, TargetTagUpdatedEventContainer.class);
EVENTS.put(TargetTagAssigmentResultEvent.class, TargetTagAssigmentResultEventContainer.class);
EVENTS.put(DistributionSetTagCreatedEvent.class, DistributionSetTagCreatedEventContainer.class);
EVENTS.put(DistributionSetTagDeletedEvent.class, DistributionSetTagDeletedEventContainer.class);
EVENTS.put(DistributionSetTagUpdateEvent.class, DistributionSetTagUpdatedEventContainer.class);
EVENTS.put(DistributionSetTagAssigmentResultEvent.class,
DistributionSetTagAssignmentResultEventContainer.class);
EVENTS.put(TargetCreatedEvent.class, TargetCreatedEventContainer.class);
EVENTS.put(TargetInfoUpdateEvent.class, TargetInfoUpdateEventContainer.class);
EVENTS.put(TargetDeletedEvent.class, TargetDeletedEventContainer.class);
EVENTS.put(TargetUpdatedEvent.class, TargetUpdatedEventContainer.class);
EVENTS.put(CancelTargetAssignmentEvent.class, CancelTargetAssignmentEventContainer.class);
EVENTS.put(DistributionSetUpdateEvent.class, DistributionSetUpdatedEventContainer.class);
EVENTS.put(DistributionDeletedEvent.class, DistributionDeletedEventContainer.class);
EVENTS.put(DistributionCreatedEvent.class, DistributionCreatedEventContainer.class);
EVENTS.put(RolloutGroupChangeEvent.class, RolloutGroupChangeEventContainer.class);
EVENTS.put(RolloutChangeEvent.class, RolloutChangeEventContainer.class);
}
@Override
public Map<Class<? extends Event>, Class<?>> getEvents() {
return EVENTS;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.RolloutChangeEvent;
/**
* EventHolder for {@link RolloutChangeEvent}s.
*
*/
public class RolloutChangeEventContainer implements EventContainer<RolloutChangeEvent> {
private final List<RolloutChangeEvent> events;
RolloutChangeEventContainer(final List<RolloutChangeEvent> events) {
this.events = events;
}
@Override
public List<RolloutChangeEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.RolloutGroupChangeEvent;
/**
* EventHolder for {@link RolloutGroupChangeEvent}s.
*
*/
public class RolloutGroupChangeEventContainer implements EventContainer<RolloutGroupChangeEvent> {
private final List<RolloutGroupChangeEvent> events;
RolloutGroupChangeEventContainer(final List<RolloutGroupChangeEvent> events) {
this.events = events;
}
@Override
public List<RolloutGroupChangeEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
/**
* EventHolder for {@link TargetCreatedEvent}s.
*
*/
public class TargetCreatedEventContainer implements EventContainer<TargetCreatedEvent> {
private final List<TargetCreatedEvent> events;
TargetCreatedEventContainer(final List<TargetCreatedEvent> events) {
this.events = events;
}
@Override
public List<TargetCreatedEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.TargetDeletedEvent;
/**
* EventHolder for {@link TargetDeletedEvent}s.
*
*/
public class TargetDeletedEventContainer implements EventContainer<TargetDeletedEvent> {
private final List<TargetDeletedEvent> events;
TargetDeletedEventContainer(final List<TargetDeletedEvent> events) {
this.events = events;
}
@Override
public List<TargetDeletedEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
/**
* EventHolder for {@link TargetInfoUpdateEvent}s.
*
*/
public class TargetInfoUpdateEventContainer implements EventContainer<TargetInfoUpdateEvent> {
private final List<TargetInfoUpdateEvent> events;
TargetInfoUpdateEventContainer(final List<TargetInfoUpdateEvent> events) {
this.events = events;
}
@Override
public List<TargetInfoUpdateEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagAssigmentResultEvent;
/**
* EventHolder for {@link TargetTagAssigmentResultEvent}s.
*
*/
public class TargetTagAssigmentResultEventContainer implements EventContainer<TargetTagAssigmentResultEvent> {
private final List<TargetTagAssigmentResultEvent> events;
TargetTagAssigmentResultEventContainer(final List<TargetTagAssigmentResultEvent> events) {
this.events = events;
}
@Override
public List<TargetTagAssigmentResultEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedEvent;
/**
* EventHolder for {@link TargetTagCreatedEvent}s.
*
*/
public class TargetTagCreatedEventContainer implements EventContainer<TargetTagCreatedEvent> {
private final List<TargetTagCreatedEvent> events;
TargetTagCreatedEventContainer(final List<TargetTagCreatedEvent> events) {
this.events = events;
}
@Override
public List<TargetTagCreatedEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
/**
* EventHolder for {@link TargetTagDeletedEvent}s.
*
*/
public class TargetTagDeletedEventContainer implements EventContainer<TargetTagDeletedEvent> {
private final List<TargetTagDeletedEvent> events;
TargetTagDeletedEventContainer(final List<TargetTagDeletedEvent> events) {
this.events = events;
}
@Override
public List<TargetTagDeletedEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
/**
* EventHolder for {@link TargetTagUpdateEvent}s.
*
*/
public class TargetTagUpdatedEventContainer implements EventContainer<TargetTagUpdateEvent> {
private final List<TargetTagUpdateEvent> events;
TargetTagUpdatedEventContainer(final List<TargetTagUpdateEvent> events) {
this.events = events;
}
@Override
public List<TargetTagUpdateEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.List;
import org.eclipse.hawkbit.repository.eventbus.event.TargetUpdatedEvent;
/**
* EventHolder for {@link TargetUpdatedEvent}s.
*
*/
public class TargetUpdatedEventContainer implements EventContainer<TargetUpdatedEvent> {
private final List<TargetUpdatedEvent> events;
TargetUpdatedEventContainer(final List<TargetUpdatedEvent> events) {
this.events = events;
}
@Override
public List<TargetUpdatedEvent> getEvents() {
return events;
}
}

View File

@@ -0,0 +1,32 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.push;
import java.util.Collections;
import java.util.Map;
import org.eclipse.hawkbit.eventbus.event.Event;
/**
* The UI event provider hold all supported repository events which will
* delegated to the UI.
*/
public interface UIEventProvider {
/**
* Return all supported repository event types. All events which this type
* are delegated to the UI as list of events.
*
* @return list of provided event types. Should not be null
*/
default Map<Class<? extends Event>, Class<?>> getEvents() {
return Collections.emptyMap();
}
}

View File

@@ -39,15 +39,16 @@ import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererDa
import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlButtonRenderer;
import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlLabelRenderer;
import org.eclipse.hawkbit.ui.customrenderers.renderers.RolloutRenderer;
import org.eclipse.hawkbit.ui.push.RolloutChangeEventContainer;
import org.eclipse.hawkbit.ui.rollout.DistributionBarHelper;
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.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
@@ -133,7 +134,11 @@ public class RolloutListGrid extends AbstractGrid {
*/
@SuppressWarnings("unchecked")
@EventBusListenerMethod(scope = EventScope.SESSION)
public void onEvent(final RolloutChangeEvent rolloutChangeEvent) {
public void onRolloutChangeEvent(final RolloutChangeEventContainer eventContainer) {
eventContainer.getEvents().forEach(this::handleEvent);
}
private void handleEvent(final RolloutChangeEvent rolloutChangeEvent) {
if (!rolloutUIState.isShowRollOuts()) {
return;
}

View File

@@ -18,7 +18,6 @@ import java.util.Map;
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.eventbus.event.RolloutGroupChangeEvent;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
@@ -26,15 +25,16 @@ import org.eclipse.hawkbit.ui.common.grid.AbstractGrid;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlLabelRenderer;
import org.eclipse.hawkbit.ui.customrenderers.renderers.RolloutRenderer;
import org.eclipse.hawkbit.ui.push.RolloutGroupChangeEventContainer;
import org.eclipse.hawkbit.ui.rollout.DistributionBarHelper;
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.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
@@ -43,7 +43,6 @@ import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.data.util.converter.Converter;
import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringComponent;
@@ -97,22 +96,12 @@ public class RolloutGroupListGrid extends AbstractGrid {
*/
@SuppressWarnings("unchecked")
@EventBusListenerMethod(scope = EventScope.SESSION)
public void onEvent(final RolloutGroupChangeEvent rolloutGroupChangeEvent) {
public void onRolloutGroupChangeEvent(final RolloutGroupChangeEventContainer eventContainer) {
if (!rolloutUIState.isShowRolloutGroups()) {
return;
}
final RolloutGroup rolloutGroup = rolloutGroupManagement
.findRolloutGroupWithDetailedStatus(rolloutGroupChangeEvent.getRolloutGroupId());
final LazyQueryContainer rolloutContainer = (LazyQueryContainer) getContainerDataSource();
final Item item = rolloutContainer.getItem(rolloutGroup.getId());
if (item == null) {
return;
}
item.getItemProperty(SPUILabelDefinitions.VAR_STATUS).setValue(rolloutGroup.getStatus());
item.getItemProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS)
.setValue(rolloutGroup.getTotalTargetCountStatus());
item.getItemProperty(SPUILabelDefinitions.ROLLOUT_GROUP_INSTALLED_PERCENTAGE)
.setValue(calculateFinishedPercentage(rolloutGroup));
((LazyQueryContainer) getContainerDataSource()).refresh();
}
private String calculateFinishedPercentage(final RolloutGroup rolloutGroup) {

View File

@@ -15,9 +15,9 @@ 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.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
@@ -103,15 +103,13 @@ public class RolloutGroupTargetsCountLabelMessage extends Label {
final StringBuilder message = new StringBuilder(i18n.get("label.target.filter.count"));
message.append(rolloutUIState.getRolloutGroupTargetsTotalCount());
message.append(HawkbitCommonUtil.SP_STRING_SPACE);
if (totalTargetTableEnteries > SPUIDefinitions.MAX_TABLE_ENTRIES) {
message.append(HawkbitCommonUtil.SP_STRING_PIPE);
message.append(i18n.get("label.filter.shown"));
message.append(SPUIDefinitions.MAX_TABLE_ENTRIES);
} else {
message.append(i18n.get("label.filter.shown"));
message.append(rolloutGroupTargetsListGrid.getContainerDataSource().size());
}
message.append(HawkbitCommonUtil.SP_STRING_SPACE);
setCaption(message.toString());
}
}

View File

@@ -45,6 +45,7 @@ import com.vaadin.ui.UI;
* Common util class.
*/
public final class HawkbitCommonUtil {
public static final String SP_STRING_PIPE = " | ";
/**
* Define spaced string.
*/

View File

@@ -141,12 +141,12 @@ label.combobox.type = Select Type
label.combobox.tag = Select Tag
label.choose.tag = Choose Tag to update
label.choose.tag.color = Choose Tag Color
label.target.filtered.total = Total filtered targets :
label.target.filtered.total = Total Filtered Targets :
label.filter = Filter :
label.target.filter.count = Total Targets :
label.filter.selected = Selected :
label.filter.shown = Shown :
label.filter.targets = Filtered targets :
label.filter.targets = Filtered Targets :
label.filter.status = Status,
label.filter.overdue = Overdue,
label.filter.tags = Tags,
@@ -241,7 +241,7 @@ message.tag.delete = Please unclick the tag {0}, then try to delete
message.dist.type.check.delete = Please unclick the distribution type {0}, then try to delete
message.cannot.delete.default.dstype = Default distribution set type cannot be deleted
message.swmodule.type.check.delete = Please unclick the Software Module type {0}, then try to delete
message.targets.already.deleted = Few Target(s) are already deleted.Pending for action
message.targets.already.deleted = Few Target(s) are already deleted. Pending for action
message.dists.already.deleted = Few distribution(s) are already deleted.Pending for action
message.target.deleted.pending = Target(s) already deleted.Pending for action
message.dist.deleted.pending = Distribution(s) already deleted.Pending for action
@@ -266,6 +266,7 @@ message.dist.deleted = {0} Distribution set(s) deleted
message.tag.update.mandatory = Please select the Tag to update
message.tag.duplicate.check = {0} already exists, please enter another value
message.type.key.duplicate.check = Distribution type with key {0} already exists, please give another value
message.type.update.mandatory = Please select the Distribution Set type to update
message.type.key.swmodule.duplicate.check = Software Module type with key {0} already exists, please give another value
message.no.action.history = No action history is available for the target : {0}
message.no.available = --No messages available--
@@ -309,7 +310,7 @@ message.tag.cannot.be.assigned = Target/DS cannot be assigned to {0}
message.no.targets.assiged.fortag = No targets are assigned to tag {0}
message.error.missing.tagname = Please select tag name
message.type.delete = Please unclick the distribution type {0}, then try to delete
message.error.dist.set.type.update= Distribution Set Type is already assigned to targets and cannot be changed
message.error.dist.set.type.update= Distribution Set Type is already assigned to set(s) and cannot be changed
message.no.directory.upload = Directory upload is not supported
message.delete.filter.confirm = Are you sure that you want to delete custom filter?
message.delete.filter.success = Custom filter {0} deleted Successfully!