Make entities immutable and create proper update methods that state by signature what can be updated. (#342)

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-11-17 20:07:23 +01:00
committed by GitHub
parent b6834e9ee2
commit ca63106d5c
314 changed files with 7699 additions and 6914 deletions

View File

@@ -73,7 +73,7 @@ public class ArtifactBeanQuery extends AbstractBeanQuery<Artifact> {
@Override
protected Artifact constructBean() {
return getEntityFactory().generateArtifact();
return null;
}
@Override

View File

@@ -166,8 +166,8 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
}
private void populateTypeNameCombo() {
typeComboBox.setContainerDataSource(HawkbitCommonUtil.createLazyQueryContainer(
new BeanQueryFactory<SoftwareModuleTypeBeanQuery>(SoftwareModuleTypeBeanQuery.class)));
typeComboBox.setContainerDataSource(
HawkbitCommonUtil.createLazyQueryContainer(new BeanQueryFactory<>(SoftwareModuleTypeBeanQuery.class)));
typeComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
}
@@ -246,12 +246,8 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
* updates a softwareModule
*/
private void updateSwModule() {
final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
final String newVendor = HawkbitCommonUtil.trimAndNullIfEmpty(vendorTextField.getValue());
SoftwareModule newSWModule = softwareManagement.findSoftwareModuleById(baseSwModuleId);
newSWModule.setVendor(newVendor);
newSWModule.setDescription(newDesc);
newSWModule = softwareManagement.updateSoftwareModule(newSWModule);
final SoftwareModule newSWModule = softwareManagement.updateSoftwareModule(entityFactory.softwareModule()
.update(baseSwModuleId).description(descTextArea.getValue()).vendor(vendorTextField.getValue()));
if (newSWModule != null) {
uiNotifcation.displaySuccess(i18n.get("message.save.success",
new Object[] { newSWModule.getName() + ":" + newSWModule.getVersion() }));

View File

@@ -10,8 +10,8 @@ package org.eclipse.hawkbit.ui.artifacts.smtable;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout;
@@ -76,14 +76,13 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final MetadataEvent event) {
UI.getCurrent().access(() -> {
final SoftwareModuleMetadata softwareModuleMetadata = event.getSoftwareModuleMetadata();
if (softwareModuleMetadata != null
&& isSoftwareModuleSelected(softwareModuleMetadata.getSoftwareModule())) {
final MetaData softwareModuleMetadata = event.getMetaData();
if (softwareModuleMetadata != null && isSoftwareModuleSelected(event.getModule())) {
if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_SOFTWARE_MODULE_METADATA) {
swmMetadataTable.createMetadata(event.getSoftwareModuleMetadata().getKey());
swmMetadataTable.createMetadata(event.getMetaData().getKey());
} else if (event
.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_SOFTWARE_MODULE_METADATA) {
swmMetadataTable.deleteMetadata(event.getSoftwareModuleMetadata().getKey());
swmMetadataTable.deleteMetadata(event.getMetaData().getKey());
}
}
});

View File

@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.ui.artifacts.smtype;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
@@ -49,15 +48,12 @@ import com.vaadin.ui.themes.ValoTheme;
@ViewScope
public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout<SoftwareModuleType> {
private static final long serialVersionUID = -5169398523815919367L;
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(CreateUpdateSoftwareTypeLayout.class);
@Autowired
private transient SoftwareManagement swTypeManagementService;
@Autowired
private transient EntityFactory entityFactory;
private String singleAssignStr;
private String multiAssignStr;
private Label singleAssign;
@@ -242,12 +238,9 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout<Softw
}
if (null != typeNameValue && null != typeKeyValue) {
SoftwareModuleType newSWType = entityFactory.generateSoftwareModuleType(typeKeyValue, typeNameValue,
typeDescValue, assignNumber);
newSWType.setColour(colorPicked);
newSWType.setDescription(typeDescValue);
newSWType.setColour(colorPicked);
newSWType = swTypeManagementService.createSoftwareModuleType(newSWType);
final SoftwareModuleType newSWType = swTypeManagementService.createSoftwareModuleType(
entityFactory.softwareModuleType().create().key(typeKeyValue).name(typeNameValue)
.description(typeDescValue).colour(colorPicked).maxAssignments(assignNumber));
uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { newSWType.getName() }));
eventBus.publish(this,
new SoftwareModuleTypeEvent(SoftwareModuleTypeEnum.ADD_SOFTWARE_MODULE_TYPE, newSWType));
@@ -257,20 +250,12 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout<Softw
}
private void updateSWModuleType(final SoftwareModuleType existingType) {
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
if (null != typeNameValue) {
existingType.setName(typeNameValue);
existingType.setDescription(typeDescValue);
existingType.setColour(ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview()));
swTypeManagementService.updateSoftwareModuleType(existingType);
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { existingType.getName() }));
eventBus.publish(this,
new SoftwareModuleTypeEvent(SoftwareModuleTypeEnum.UPDATE_SOFTWARE_MODULE_TYPE, existingType));
} else {
uiNotification.displayValidationError(i18n.get("message.tag.update.mandatory"));
}
swTypeManagementService.updateSoftwareModuleType(
entityFactory.softwareModuleType().update(existingType.getId()).description(tagDesc.getValue())
.colour(ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview())));
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { existingType.getName() }));
eventBus.publish(this,
new SoftwareModuleTypeEvent(SoftwareModuleTypeEnum.UPDATE_SOFTWARE_MODULE_TYPE, existingType));
}
@Override
@@ -291,8 +276,8 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout<Softw
@Override
protected void populateTagNameCombo() {
tagNameComboBox.setContainerDataSource(HawkbitCommonUtil.createLazyQueryContainer(
new BeanQueryFactory<SoftwareModuleTypeBeanQuery>(SoftwareModuleTypeBeanQuery.class)));
tagNameComboBox.setContainerDataSource(
HawkbitCommonUtil.createLazyQueryContainer(new BeanQueryFactory<>(SoftwareModuleTypeBeanQuery.class)));
tagNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
}

View File

@@ -8,7 +8,6 @@
*/
package org.eclipse.hawkbit.ui.common;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -40,7 +39,7 @@ public class DistributionSetTypeBeanQuery extends AbstractBeanQuery<Distribution
private static final Logger LOG = LoggerFactory.getLogger(DistributionSetTypeBeanQuery.class);
private final Sort sort = new Sort(Direction.ASC, "name");
private transient Page<DistributionSetType> firstPageDistSetType = null;
private transient Page<DistributionSetType> firstPageDistSetType;
private transient DistributionSetManagement distributionSetManagement;
private transient EntityFactory entityFactory;
@@ -59,9 +58,7 @@ public class DistributionSetTypeBeanQuery extends AbstractBeanQuery<Distribution
@Override
protected DistributionSetType constructBean() {
final DistributionSetType result = getEntityFactory().generateDistributionSetType("", "", "");
result.setColour("");
return result;
return null;
}
@Override
@@ -93,7 +90,6 @@ public class DistributionSetTypeBeanQuery extends AbstractBeanQuery<Distribution
@Override
protected List<DistributionSetType> loadBeans(final int startIndex, final int count) {
Page<DistributionSetType> typeBeans;
final List<DistributionSetType> distSetTypeList = new ArrayList<>();
if (startIndex == 0 && firstPageDistSetType != null) {
typeBeans = firstPageDistSetType;
} else {
@@ -101,8 +97,7 @@ public class DistributionSetTypeBeanQuery extends AbstractBeanQuery<Distribution
.findDistributionSetTypesAll(new OffsetBasedPageRequest(startIndex, count, sort));
}
distSetTypeList.addAll(typeBeans.getContent());
return distSetTypeList;
return typeBeans.getContent();
}
@Override

View File

@@ -49,7 +49,7 @@ public class SoftwareModuleTypeBeanQuery extends AbstractBeanQuery<SoftwareModul
@Override
protected SoftwareModuleType constructBean() {
return getEntityFactory().generateSoftwareModuleType();
return null;
}
private EntityFactory getEntityFactory() {

View File

@@ -160,8 +160,8 @@ public class DistributionSetMetadatadetailslayout extends Table {
final DistributionSet distSet = distributionSetManagement.findDistributionSetById(selectedDistSetId);
/* display the window */
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(distSet,
entityFactory.generateDistributionSetMetadata(distSet, metadataKey, "")));
UI.getCurrent()
.addWindow(dsMetadataPopupLayout.getWindow(distSet, entityFactory.generateMetadata(metadataKey, "")));
}
}

View File

@@ -12,7 +12,7 @@ import java.util.Set;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.exception.EntityLockedException;
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@@ -123,9 +123,9 @@ public class SoftwareModuleDetailsTable extends Table {
container.addContainerProperty(SOFT_TYPE_MANDATORY, Label.class, "");
container.addContainerProperty(SOFT_TYPE_NAME, Label.class, "");
container.addContainerProperty(SOFT_MODULE, VerticalLayout.class, "");
setColumnExpandRatio(SOFT_TYPE_MANDATORY, 0.1f);
setColumnExpandRatio(SOFT_TYPE_NAME, 0.4f);
setColumnExpandRatio(SOFT_MODULE, 0.3f);
setColumnExpandRatio(SOFT_TYPE_MANDATORY, 0.1F);
setColumnExpandRatio(SOFT_TYPE_NAME, 0.4F);
setColumnExpandRatio(SOFT_MODULE, 0.3F);
setColumnAlignment(SOFT_TYPE_MANDATORY, Align.RIGHT);
setColumnAlignment(SOFT_TYPE_NAME, Align.LEFT);
setColumnAlignment(SOFT_MODULE, Align.LEFT);
@@ -149,7 +149,7 @@ public class SoftwareModuleDetailsTable extends Table {
if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission()) {
try {
isTargetAssigned = false;
} catch (final EntityLockedException exception) {
} catch (final EntityReadOnlyException exception) {
isTargetAssigned = true;
LOG.info("Target already assigned for the distribution set: " + distributionSet.getName(),
exception);
@@ -187,10 +187,11 @@ public class SoftwareModuleDetailsTable extends Table {
final Set<SoftwareModule> alreadyAssignedSwModules) {
final SoftwareModule unAssignedSw = getSoftwareModule(event.getButton().getId(), alreadyAssignedSwModules);
if (distributionSetManagement.isDistributionSetInUse(distributionSet)) {
uiNotification.displayValidationError(i18n.get("message.error.notification.ds.target.assigned",distributionSet.getName(), distributionSet.getVersion()));
uiNotification.displayValidationError(i18n.get("message.error.notification.ds.target.assigned",
distributionSet.getName(), distributionSet.getVersion()));
} else {
final DistributionSet newDistributionSet = distributionSetManagement.unassignSoftwareModule(distributionSet,
unAssignedSw);
final DistributionSet newDistributionSet = distributionSetManagement
.unassignSoftwareModule(distributionSet.getId(), unAssignedSw.getId());
manageDistUIState.setLastSelectedEntity(DistributionSetIdName.generate(newDistributionSet));
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, newDistributionSet));
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
@@ -257,7 +258,7 @@ public class SoftwareModuleDetailsTable extends Table {
return null;
}
private Label createMandatoryLabel(final boolean mandatory) {
private static Label createMandatoryLabel(final boolean mandatory) {
final Label mandatoryLable = mandatory ? HawkbitCommonUtil.getFormatedLabel(" * ")
: HawkbitCommonUtil.getFormatedLabel(" ");
if (mandatory) {

View File

@@ -41,19 +41,19 @@ import com.vaadin.ui.themes.ValoTheme;
@ViewScope
public class SoftwareModuleMetadatadetailslayout extends Table {
private static final long serialVersionUID = 2913758299611838818L;
private static final long serialVersionUID = 2913758299611838818L;
private static final String METADATA_KEY = "Key";
private static final String METADATA_KEY = "Key";
private SpPermissionChecker permissionChecker;
private SpPermissionChecker permissionChecker;
private transient SoftwareManagement softwareManagement;
private SwMetadataPopupLayout swMetadataPopupLayout;
private SwMetadataPopupLayout swMetadataPopupLayout;
private I18N i18n;
private I18N i18n;
private Long selectedSWModuleId;
private Long selectedSWModuleId;
private transient EntityFactory entityFactory;
@@ -83,102 +83,101 @@ public class SoftwareModuleMetadatadetailslayout extends Table {
addCustomGeneratedColumns();
}
/**
* Populate software module metadata table.
*
* @param swModule
*/
public void populateSMMetadata(final SoftwareModule swModule) {
removeAllItems();
if (null == swModule) {
return;
}
selectedSWModuleId = swModule.getId();
final List<SoftwareModuleMetadata> swMetadataList = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(selectedSWModuleId);
if (null != swMetadataList && !swMetadataList.isEmpty()) {
swMetadataList.forEach(swMetadata -> setSWMetadataProperties(swMetadata));
}
}
/**
* Populate software module metadata table.
*
* @param swModule
*/
public void populateSMMetadata(final SoftwareModule swModule) {
removeAllItems();
if (null == swModule) {
return;
}
selectedSWModuleId = swModule.getId();
final List<SoftwareModuleMetadata> swMetadataList = softwareManagement
.findSoftwareModuleMetadataBySoftwareModuleId(selectedSWModuleId);
if (null != swMetadataList && !swMetadataList.isEmpty()) {
swMetadataList.forEach(this::setSWMetadataProperties);
}
}
/**
* Create metadata.
*
* @param metadataKeyName
*/
public void createMetadata(final String metadataKeyName) {
final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource();
final Item item = metadataContainer.addItem(metadataKeyName);
item.getItemProperty(METADATA_KEY).setValue(metadataKeyName);
/**
* Create metadata.
*
* @param metadataKeyName
*/
public void createMetadata(final String metadataKeyName) {
final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource();
final Item item = metadataContainer.addItem(metadataKeyName);
item.getItemProperty(METADATA_KEY).setValue(metadataKeyName);
}
}
/**
* Delete metadata.
*
* @param metadataKeyName
*/
public void deleteMetadata(final String metadataKeyName) {
final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource();
metadataContainer.removeItem(metadataKeyName);
}
/**
* Delete metadata.
*
* @param metadataKeyName
*/
public void deleteMetadata(final String metadataKeyName) {
final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource();
metadataContainer.removeItem(metadataKeyName);
}
private void createSWMMetadataTable() {
addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
addStyleName(ValoTheme.TABLE_NO_STRIPES);
addStyleName(SPUIStyleDefinitions.SW_MODULE_TABLE);
setSelectable(false);
setImmediate(true);
setContainerDataSource(getSwModuleMetadataContainer());
setColumnHeaderMode(ColumnHeaderMode.EXPLICIT);
addSMMetadataTableHeader();
setSizeFull();
//same as height of other tabs in details tabsheet
setHeight(116,Unit.PIXELS);
}
private void createSWMMetadataTable() {
addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
addStyleName(ValoTheme.TABLE_NO_STRIPES);
addStyleName(SPUIStyleDefinitions.SW_MODULE_TABLE);
setSelectable(false);
setImmediate(true);
setContainerDataSource(getSwModuleMetadataContainer());
setColumnHeaderMode(ColumnHeaderMode.EXPLICIT);
addSMMetadataTableHeader();
setSizeFull();
// same as height of other tabs in details tabsheet
setHeight(116, Unit.PIXELS);
}
private IndexedContainer getSwModuleMetadataContainer() {
final IndexedContainer container = new IndexedContainer();
container.addContainerProperty(METADATA_KEY, String.class, "");
setColumnAlignment(METADATA_KEY, Align.LEFT);
return container;
}
private IndexedContainer getSwModuleMetadataContainer() {
final IndexedContainer container = new IndexedContainer();
container.addContainerProperty(METADATA_KEY, String.class, "");
setColumnAlignment(METADATA_KEY, Align.LEFT);
return container;
}
private void addSMMetadataTableHeader() {
setColumnHeader(METADATA_KEY, i18n.get("header.key"));
}
private void addSMMetadataTableHeader() {
setColumnHeader(METADATA_KEY, i18n.get("header.key"));
}
private void setSWMetadataProperties(final SoftwareModuleMetadata swMetadata) {
final Item item = getContainerDataSource().addItem(swMetadata.getKey());
item.getItemProperty(METADATA_KEY).setValue(swMetadata.getKey());
}
private void setSWMetadataProperties(final SoftwareModuleMetadata swMetadata) {
final Item item = getContainerDataSource().addItem(swMetadata.getKey());
item.getItemProperty(METADATA_KEY).setValue(swMetadata.getKey());
}
private void addCustomGeneratedColumns() {
addGeneratedColumn(METADATA_KEY, (source, itemId, columnId) -> customMetadataDetailButton((String) itemId));
}
private void addCustomGeneratedColumns() {
addGeneratedColumn(METADATA_KEY, (source, itemId, columnId) -> customMetadataDetailButton((String) itemId));
}
private Button customMetadataDetailButton(final String metadataKey) {
final Button viewLink = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey,
"View" + metadataKey + " Metadata details", null, false, null, SPUIButtonStyleSmallNoBorder.class);
viewLink.setData(metadataKey);
if (permissionChecker.hasUpdateDistributionPermission()) {
viewLink.addStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_LINK + " " + "on-focus-no-border link"
+ " " + "text-style");
viewLink.addClickListener(event -> showMetadataDetails(selectedSWModuleId, metadataKey));
}
return viewLink;
}
private Button customMetadataDetailButton(final String metadataKey) {
final Button viewLink = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey, "View"
+ metadataKey + " Metadata details", null, false, null, SPUIButtonStyleSmallNoBorder.class);
viewLink.setData(metadataKey);
if (permissionChecker.hasUpdateDistributionPermission()) {
viewLink.addStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_LINK + " " + "on-focus-no-border link"
+ " " + "text-style");
viewLink.addClickListener(event -> showMetadataDetails(selectedSWModuleId, metadataKey));
}
return viewLink;
}
private static String getDetailLinkId(final String name) {
return new StringBuilder(UIComponentIdProvider.SW_METADATA_DETAIL_LINK).append('.').append(name).toString();
}
private static String getDetailLinkId(final String name) {
return new StringBuilder(UIComponentIdProvider.SW_METADATA_DETAIL_LINK).append('.').append(name).toString();
}
private void showMetadataDetails(final Long selectedSWModuleId, final String metadataKey) {
final SoftwareModule swmodule = softwareManagement.findSoftwareModuleById(selectedSWModuleId);
/* display the window */
UI.getCurrent().addWindow(
swMetadataPopupLayout.getWindow(swmodule,
entityFactory.generateSoftwareModuleMetadata(swmodule, metadataKey, "")));
}
private void showMetadataDetails(final Long selectedSWModuleId, final String metadataKey) {
final SoftwareModule swmodule = softwareManagement.findSoftwareModuleById(selectedSWModuleId);
/* display the window */
UI.getCurrent()
.addWindow(swMetadataPopupLayout.getWindow(swmodule, entityFactory.generateMetadata(metadataKey, "")));
}
}

View File

@@ -10,10 +10,11 @@ package org.eclipse.hawkbit.ui.distributions.disttype;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeUpdate;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
@@ -60,7 +61,7 @@ import com.vaadin.ui.themes.ValoTheme;
@ViewScope
public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<DistributionSetType> {
private static final long serialVersionUID = -5169398523815877767L;
private static final long serialVersionUID = 1L;
private static final String DIST_TYPE_NAME = "name";
private static final String DIST_TYPE_DESCRIPTION = "description";
private static final String DIST_TYPE_MANDATORY = "mandatory";
@@ -72,9 +73,6 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
@Autowired
private transient DistributionSetManagement distributionSetManagement;
@Autowired
private transient EntityFactory entityFactory;
private HorizontalLayout distTypeSelectLayout;
private Table sourceTable;
private Table selectedTable;
@@ -361,19 +359,17 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
final List<Long> itemIds = (List<Long>) selectedTable.getItemIds();
if (null != typeNameValue && null != typeKeyValue && null != itemIds && !itemIds.isEmpty()) {
DistributionSetType newDistType = entityFactory.generateDistributionSetType(typeKeyValue, typeNameValue,
typeDescValue);
for (final Long id : itemIds) {
final Item item = selectedTable.getItem(id);
final String distTypeName = (String) item.getItemProperty(DIST_TYPE_NAME).getValue();
final CheckBox mandatoryCheckBox = (CheckBox) item.getItemProperty(DIST_TYPE_MANDATORY).getValue();
final Boolean isMandatory = mandatoryCheckBox.getValue();
final SoftwareModuleType swModuleType = softwareManagement.findSoftwareModuleTypeByName(distTypeName);
checkMandatoryAndAddMandatoryModuleType(newDistType, isMandatory, swModuleType);
}
newDistType.setDescription(typeDescValue);
newDistType.setColour(colorPicked);
newDistType = distributionSetManagement.createDistributionSetType(newDistType);
final List<Long> mandatory = itemIds.stream()
.filter(itemId -> isMandatoryModuleType(selectedTable.getItem(itemId)))
.collect(Collectors.toList());
final List<Long> optional = itemIds.stream()
.filter(itemId -> isOptionalModuleType(selectedTable.getItem(itemId))).collect(Collectors.toList());
final DistributionSetType newDistType = distributionSetManagement.createDistributionSetType(
entityFactory.distributionSetType().create().key(typeKeyValue).name(typeNameValue)
.description(typeDescValue).colour(colorPicked).mandatory(mandatory).optional(optional));
uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { newDistType.getName() }));
eventBus.publish(this,
new DistributionSetTypeEvent(DistributionSetTypeEnum.ADD_DIST_SET_TYPE, newDistType));
@@ -382,6 +378,15 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
}
}
private static boolean isMandatoryModuleType(final Item item) {
final CheckBox mandatoryCheckBox = (CheckBox) item.getItemProperty(DIST_TYPE_MANDATORY).getValue();
return mandatoryCheckBox.getValue();
}
private static boolean isOptionalModuleType(final Item item) {
return !isMandatoryModuleType(item);
}
/**
* update distributionSet Type.
*/
@@ -389,63 +394,25 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
private void updateDistributionSetType(final DistributionSetType existingType) {
final List<Long> itemIds = (List<Long>) selectedTable.getItemIds();
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
final String typeKeyValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeKey.getValue());
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
/* remove all SW Module Types before update SW Module Types */
final DistributionSetType updateDistSetType = removeSWModuleTypesFromDistSetType(existingType.getName());
if (null != typeNameValue) {
updateDistSetType.setName(typeNameValue);
updateDistSetType.setKey(typeKeyValue);
updateDistSetType.setDescription(typeDescValue);
final DistributionSetTypeUpdate update = entityFactory.distributionSetType().update(existingType.getId())
.description(tagDesc.getValue())
.colour(ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview()));
if (distributionSetManagement.countDistributionSetsByType(existingType) <= 0 && null != itemIds
&& !itemIds.isEmpty()) {
if (distributionSetManagement.countDistributionSetsByType(existingType) <= 0 && null != itemIds
&& !itemIds.isEmpty()) {
for (final Long id : itemIds) {
final Item item = selectedTable.getItem(id);
final CheckBox mandatoryCheckBox = (CheckBox) item.getItemProperty(DIST_TYPE_MANDATORY).getValue();
final Boolean isMandatory = mandatoryCheckBox.getValue();
final String distTypeName = (String) item.getItemProperty(DIST_TYPE_NAME).getValue();
final SoftwareModuleType swModuleType = softwareManagement
.findSoftwareModuleTypeByName(distTypeName);
checkMandatoryAndAddMandatoryModuleType(updateDistSetType, isMandatory, swModuleType);
}
}
updateDistSetType.setColour(ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview()));
distributionSetManagement.updateDistributionSetType(updateDistSetType);
uiNotification
.displaySuccess(i18n.get("message.update.success", new Object[] { updateDistSetType.getName() }));
eventBus.publish(this,
new DistributionSetTypeEvent(DistributionSetTypeEnum.UPDATE_DIST_SET_TYPE, updateDistSetType));
} else {
uiNotification.displayValidationError(i18n.get("message.type.update.mandatory "));
update.mandatory(itemIds.stream().filter(itemId -> isMandatoryModuleType(selectedTable.getItem(itemId)))
.collect(Collectors.toList()))
.optional(itemIds.stream().filter(itemId -> isOptionalModuleType(selectedTable.getItem(itemId)))
.collect(Collectors.toList()));
}
}
private static void checkMandatoryAndAddMandatoryModuleType(final DistributionSetType updateDistSetType,
final Boolean isMandatory, final SoftwareModuleType swModuleType) {
if (isMandatory) {
updateDistSetType.addMandatoryModuleType(swModuleType);
} else {
updateDistSetType.addOptionalModuleType(swModuleType);
}
}
final DistributionSetType updateDistSetType = distributionSetManagement.updateDistributionSetType(update);
private DistributionSetType removeSWModuleTypesFromDistSetType(final String selectedDistSetType) {
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { updateDistSetType.getName() }));
eventBus.publish(this,
new DistributionSetTypeEvent(DistributionSetTypeEnum.UPDATE_DIST_SET_TYPE, updateDistSetType));
final DistributionSetType distSetType = fetchDistributionSetType(selectedDistSetType);
if (!distSetType.getMandatoryModuleTypes().isEmpty()) {
for (final SoftwareModuleType smType : distSetType.getMandatoryModuleTypes()) {
distSetType.removeModuleType(smType.getId());
}
}
if (!distSetType.getOptionalModuleTypes().isEmpty()) {
for (final SoftwareModuleType smType : distSetType.getOptionalModuleTypes()) {
distSetType.removeModuleType(smType.getId());
}
}
return distSetType;
}
/**
@@ -500,8 +467,8 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
*/
private static LazyQueryContainer getDistSetTypeLazyQueryContainer() {
final LazyQueryContainer disttypeContainer = HawkbitCommonUtil.createLazyQueryContainer(
new BeanQueryFactory<DistributionSetTypeBeanQuery>(DistributionSetTypeBeanQuery.class));
final LazyQueryContainer disttypeContainer = HawkbitCommonUtil
.createLazyQueryContainer(new BeanQueryFactory<>(DistributionSetTypeBeanQuery.class));
disttypeContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", true, true);
return disttypeContainer;

View File

@@ -8,6 +8,7 @@
*/
package org.eclipse.hawkbit.ui.distributions.dstable;
import java.util.Collections;
import java.util.List;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
@@ -15,9 +16,11 @@ import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout;
import org.springframework.beans.factory.annotation.Autowired;
import com.google.common.collect.Lists;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -26,7 +29,7 @@ import com.vaadin.spring.annotation.ViewScope;
*/
@SpringComponent
@ViewScope
public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<DistributionSet, DistributionSetMetadata> {
public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<DistributionSet, MetaData> {
private static final long serialVersionUID = -7778944849012048106L;
@@ -41,7 +44,7 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
@Override
protected void checkForDuplicate(final DistributionSet entity, final String value) {
distributionSetManagement.findOne(entity, value);
distributionSetManagement.findDistributionSetMetadata(entity.getId(), value);
}
/**
@@ -50,8 +53,8 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
@Override
protected DistributionSetMetadata createMetadata(final DistributionSet entity, final String key,
final String value) {
final DistributionSetMetadata dsMetaData = distributionSetManagement
.createDistributionSetMetadata(entityFactory.generateDistributionSetMetadata(entity, key, value));
final DistributionSetMetadata dsMetaData = distributionSetManagement.createDistributionSetMetadata(
entity.getId(), Lists.newArrayList(entityFactory.generateMetadata(key, value))).get(0);
setSelectedEntity(dsMetaData.getDistributionSet());
return dsMetaData;
}
@@ -63,14 +66,14 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
protected DistributionSetMetadata updateMetadata(final DistributionSet entity, final String key,
final String value) {
final DistributionSetMetadata dsMetaData = distributionSetManagement
.updateDistributionSetMetadata(entityFactory.generateDistributionSetMetadata(entity, key, value));
.updateDistributionSetMetadata(entity.getId(), entityFactory.generateMetadata(key, value));
setSelectedEntity(dsMetaData.getDistributionSet());
return dsMetaData;
}
@Override
protected List<DistributionSetMetadata> getMetadataList() {
return getSelectedEntity().getMetadata();
protected List<MetaData> getMetadataList() {
return Collections.unmodifiableList(getSelectedEntity().getMetadata());
}
/**
@@ -79,7 +82,7 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
@Override
protected void deleteMetadata(final DistributionSet entity, final String key, final String value) {
distributionSetManagement.deleteDistributionSetMetadata(entity, key);
distributionSetManagement.deleteDistributionSetMetadata(entity.getId(), key);
}
@Override

View File

@@ -8,8 +8,8 @@
*/
package org.eclipse.hawkbit.ui.distributions.event;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
/**
*
@@ -24,30 +24,26 @@ public class MetadataEvent {
private final MetadataUIEvent metadataUIEvent;
private DistributionSetMetadata distributionSetMetadata;
private final MetaData metadata;
private SoftwareModuleMetadata softwareModuleMetadata;
private final SoftwareModule module;
public MetadataEvent(final MetadataUIEvent metadataUIEvent, final DistributionSetMetadata distributionSetMetadata) {
public MetadataEvent(final MetadataUIEvent metadataUIEvent, final MetaData metadata, final SoftwareModule module) {
this.metadataUIEvent = metadataUIEvent;
this.distributionSetMetadata = distributionSetMetadata;
}
public MetadataEvent(final MetadataUIEvent metadataUIEvent, final SoftwareModuleMetadata softwareModuleMetadata) {
this.metadataUIEvent = metadataUIEvent;
this.softwareModuleMetadata = softwareModuleMetadata;
this.metadata = metadata;
this.module = module;
}
public MetadataUIEvent getMetadataUIEvent() {
return metadataUIEvent;
}
public DistributionSetMetadata getDistributionSetMetadata() {
return distributionSetMetadata;
public MetaData getMetaData() {
return metadata;
}
public SoftwareModuleMetadata getSoftwareModuleMetadata() {
return softwareModuleMetadata;
public SoftwareModule getModule() {
return module;
}
}

View File

@@ -17,8 +17,6 @@ import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout;
@@ -576,18 +574,12 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private void saveAllAssignments(final ConfirmationTab tab) {
manageDistUIState.getAssignedList().forEach((distIdName, softIdNameSet) -> {
final DistributionSet ds = dsManagement.findDistributionSetByIdWithDetails(distIdName.getId());
final List<Long> softIds = softIdNameSet.stream().map(softIdName -> softIdName.getId())
.collect(Collectors.toList());
final List<SoftwareModule> softwareModules = softwareManagement.findSoftwareModulesById(softIds);
softwareModules.forEach(ds::addModule);
dsManagement.updateDistributionSet(ds);
dsManagement.assignSoftwareModules(distIdName.getId(), softIds);
});
int count = 0;
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entry : manageDistUIState
.getAssignedList().entrySet()) {

View File

@@ -8,11 +8,13 @@
*/
package org.eclipse.hawkbit.ui.distributions.smtable;
import java.util.Collections;
import java.util.List;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout;
@@ -28,7 +30,7 @@ import com.vaadin.spring.annotation.ViewScope;
*/
@SpringComponent
@ViewScope
public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout<SoftwareModule, SoftwareModuleMetadata> {
public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout<SoftwareModule, MetaData> {
private static final long serialVersionUID = -1252090014161012563L;
@@ -51,10 +53,10 @@ public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout<SoftwareM
*/
@Override
protected SoftwareModuleMetadata createMetadata(final SoftwareModule entity, final String key, final String value) {
final SoftwareModuleMetadata swMetadata = softwareManagement
.createSoftwareModuleMetadata(entityFactory.generateSoftwareModuleMetadata(entity, key, value));
final SoftwareModuleMetadata swMetadata = softwareManagement.createSoftwareModuleMetadata(entity.getId(),
entityFactory.generateMetadata(key, value));
setSelectedEntity(swMetadata.getSoftwareModule());
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.CREATE_SOFTWARE_MODULE_METADATA, swMetadata));
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.CREATE_SOFTWARE_MODULE_METADATA, swMetadata, entity));
return swMetadata;
}
@@ -63,15 +65,16 @@ public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout<SoftwareM
*/
@Override
protected SoftwareModuleMetadata updateMetadata(final SoftwareModule entity, final String key, final String value) {
final SoftwareModuleMetadata swMetadata = softwareManagement
.updateSoftwareModuleMetadata(entityFactory.generateSoftwareModuleMetadata(entity, key, value));
final SoftwareModuleMetadata swMetadata = softwareManagement.updateSoftwareModuleMetadata(entity.getId(),
entityFactory.generateMetadata(key, value));
setSelectedEntity(swMetadata.getSoftwareModule());
return swMetadata;
}
@Override
protected List<SoftwareModuleMetadata> getMetadataList() {
return softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(getSelectedEntity().getId());
protected List<MetaData> getMetadataList() {
return Collections.unmodifiableList(
softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(getSelectedEntity().getId()));
}
/**
@@ -79,9 +82,9 @@ public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout<SoftwareM
*/
@Override
protected void deleteMetadata(final SoftwareModule entity, final String key, final String value) {
final SoftwareModuleMetadata swMetadata = entityFactory.generateSoftwareModuleMetadata(entity, key, value);
softwareManagement.deleteSoftwareModuleMetadata(entity.getId(), key);
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.DELETE_SOFTWARE_MODULE_METADATA, swMetadata));
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.DELETE_SOFTWARE_MODULE_METADATA,
entityFactory.generateMetadata(key, value), entity));
}
@Override

View File

@@ -10,8 +10,8 @@ package org.eclipse.hawkbit.ui.distributions.smtable;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleAddUpdateWindow;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout;
@@ -82,14 +82,13 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final MetadataEvent event) {
UI.getCurrent().access(() -> {
final SoftwareModuleMetadata softwareModuleMetadata = event.getSoftwareModuleMetadata();
if (softwareModuleMetadata != null
&& isSoftwareModuleSelected(softwareModuleMetadata.getSoftwareModule())) {
final MetaData softwareModuleMetadata = event.getMetaData();
if (softwareModuleMetadata != null && isSoftwareModuleSelected(event.getModule())) {
if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_SOFTWARE_MODULE_METADATA) {
swmMetadataTable.createMetadata(event.getSoftwareModuleMetadata().getKey());
swmMetadataTable.createMetadata(event.getMetaData().getKey());
} else if (event
.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_SOFTWARE_MODULE_METADATA) {
swmMetadataTable.deleteMetadata(event.getSoftwareModuleMetadata().getKey());
swmMetadataTable.deleteMetadata(event.getMetaData().getKey());
}
}
});

View File

@@ -91,8 +91,6 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
@Autowired
private AutoCompleteTextFieldComponent queryTextField;
private HorizontalLayout breadcrumbLayout;
private Button breadcrumbButton;
private Label breadcrumbName;
@@ -238,6 +236,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
};
queryTextField.addTextChangeListener((valid, query) -> enableDisableSaveButton(!valid, query));
}
private void onFilterNameChange(final TextChangeEvent event) {
@@ -260,7 +259,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
titleFilterIconsLayout.addComponents(headerCaption, captionLayout);
titleFilterIconsLayout.setSpacing(true);
breadcrumbLayout = new HorizontalLayout();
final HorizontalLayout breadcrumbLayout = new HorizontalLayout();
breadcrumbLayout.addComponent(breadcrumbButton);
breadcrumbLayout.addComponent(new Label(">"));
breadcrumbName = new LabelBuilder().buildCaptionLabel();
@@ -319,10 +318,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
}
private static boolean isNameAndQueryEmpty(final String name, final String query) {
if (Strings.isNullOrEmpty(name) && Strings.isNullOrEmpty(query)) {
return true;
}
return false;
return Strings.isNullOrEmpty(name) && Strings.isNullOrEmpty(query);
}
private SPUIButton createSearchResetIcon() {
@@ -383,10 +379,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
}
private void createTargetFilterQuery() {
final TargetFilterQuery targetFilterQuery = entityFactory.generateTargetFilterQuery();
targetFilterQuery.setName(nameTextField.getValue());
targetFilterQuery.setQuery(queryTextField.getValue());
targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery);
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(entityFactory
.targetFilterQuery().create().name(nameTextField.getValue()).query(queryTextField.getValue()));
notification.displaySuccess(
i18n.get("message.create.filter.success", new Object[] { targetFilterQuery.getName() }));
eventBus.publish(this, CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY);
@@ -398,10 +392,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
return;
}
final TargetFilterQuery targetFilterQuery = tfQuery.get();
targetFilterQuery.setName(nameTextField.getValue());
targetFilterQuery.setQuery(queryTextField.getValue());
final TargetFilterQuery updatedTargetFilter = targetFilterQueryManagement
.updateTargetFilterQuery(targetFilterQuery);
.updateTargetFilterQuery(entityFactory.targetFilterQuery().update(targetFilterQuery.getId())
.name(nameTextField.getValue()).query(queryTextField.getValue()));
filterManagementUIState.setTfQuery(updatedTargetFilter);
oldFilterName = nameTextField.getValue();
oldFilterQuery = queryTextField.getValue();

View File

@@ -182,8 +182,7 @@ public class DistributionSetSelectWindow
if (dsId != null) {
confirmWithConsequencesDialog(tfq, dsId);
} else {
tfq.setAutoAssignDistributionSet(null);
targetFilterQueryManagement.updateTargetFilterQuery(tfq);
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(targetFilterQueryId, null);
eventBus.publish(this, CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY);
}
@@ -195,8 +194,7 @@ public class DistributionSetSelectWindow
@Override
public void onConfirmResult(final boolean accepted) {
if (accepted) {
tfq.setAutoAssignDistributionSet(distributionSetManagement.findDistributionSetById(dsId));
targetFilterQueryManagement.updateTargetFilterQuery(tfq);
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(tfq.getId(), dsId);
eventBus.publish(this, CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY);
}
}

View File

@@ -10,8 +10,10 @@ package org.eclipse.hawkbit.ui.layouts;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.builder.TagUpdate;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.Tag;
@@ -77,6 +79,9 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
@Autowired
protected transient TagManagement tagManagement;
@Autowired
protected transient EntityFactory entityFactory;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
@@ -550,22 +555,16 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
* update tag.
*/
protected void updateExistingTag(final Tag targetObj) {
final String nameUpdateValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
final String descUpdateValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
if (null != nameUpdateValue) {
targetObj.setName(nameUpdateValue);
targetObj.setDescription(null != descUpdateValue ? descUpdateValue : null);
targetObj.setColour(ColorPickerHelper.getColorPickedString(colorPickerLayout.getSelPreview()));
if (targetObj instanceof TargetTag) {
tagManagement.updateTargetTag((TargetTag) targetObj);
} else if (targetObj instanceof DistributionSetTag) {
tagManagement.updateDistributionSetTag((DistributionSetTag) targetObj);
}
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { targetObj.getName() }));
} else {
uiNotification.displayValidationError(i18n.get("message.tag.update.mandatory"));
final TagUpdate update = entityFactory.tag().update(targetObj.getId()).name(tagName.getValue())
.description(tagDesc.getValue())
.colour(ColorPickerHelper.getColorPickedString(colorPickerLayout.getSelPreview()));
if (targetObj instanceof TargetTag) {
tagManagement.updateTargetTag(update);
} else if (targetObj instanceof DistributionSetTag) {
tagManagement.updateDistributionSetTag(update);
}
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { targetObj.getName() }));
}
protected void displaySuccess(final String tagName) {

View File

@@ -9,8 +9,6 @@
package org.eclipse.hawkbit.ui.management.dstable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.PostConstruct;
@@ -46,6 +44,7 @@ import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus;
import com.google.common.collect.Sets;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.CheckBox;
@@ -88,9 +87,8 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
private TextArea descTextArea;
private CheckBox reqMigStepCheckbox;
private ComboBox distsetTypeNameComboBox;
private boolean editDistribution = Boolean.FALSE;
private boolean editDistribution;
private Long editDistId;
private CommonDialogWindow window;
private FormLayout formLayout;
@@ -182,7 +180,7 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
dtQF.setQueryConfiguration(Collections.emptyMap());
final LazyQueryContainer disttypeContainer = new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.DIST_TYPE_SIZE, SPUILabelDefinitions.VAR_NAME), dtQF);
new LazyQueryDefinition(true, SPUIDefinitions.DIST_TYPE_SIZE, SPUILabelDefinitions.VAR_ID), dtQF);
disttypeContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", true, true);
@@ -202,17 +200,14 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
if (isDuplicate()) {
return;
}
final String name = HawkbitCommonUtil.trimAndNullIfEmpty(distNameTextField.getValue());
final String version = HawkbitCommonUtil.trimAndNullIfEmpty(distVersionTextField.getValue());
final String distSetTypeName = HawkbitCommonUtil
.trimAndNullIfEmpty((String) distsetTypeNameComboBox.getValue());
final DistributionSet currentDS = distributionSetManagement.findDistributionSetByIdWithDetails(editDistId);
final String desc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
final boolean isMigStepReq = reqMigStepCheckbox.getValue();
final Long distSetTypeId = (Long) distsetTypeNameComboBox.getValue();
/* identify the changes */
setDistributionValues(currentDS, name, version, distSetTypeName, desc, isMigStepReq);
distributionSetManagement.updateDistributionSet(currentDS);
final DistributionSet currentDS = distributionSetManagement
.updateDistributionSet(entityFactory.distributionSet().update(editDistId)
.name(distNameTextField.getValue()).description(descTextArea.getValue())
.version(distVersionTextField.getValue()).requiredMigrationStep(isMigStepReq)
.type(distributionSetManagement.findDistributionSetTypeById(distSetTypeId)));
notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success",
new Object[] { currentDS.getName(), currentDS.getVersion() }));
// update table row+details layout
@@ -228,46 +223,21 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
final String name = HawkbitCommonUtil.trimAndNullIfEmpty(distNameTextField.getValue());
final String version = HawkbitCommonUtil.trimAndNullIfEmpty(distVersionTextField.getValue());
final String distSetTypeName = HawkbitCommonUtil
.trimAndNullIfEmpty((String) distsetTypeNameComboBox.getValue());
final Long distSetTypeId = (Long) distsetTypeNameComboBox.getValue();
final String desc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
final boolean isMigStepReq = reqMigStepCheckbox.getValue();
DistributionSet newDist = entityFactory.generateDistributionSet();
setDistributionValues(newDist, name, version, distSetTypeName, desc, isMigStepReq);
newDist = distributionSetManagement.createDistributionSet(newDist);
final DistributionSet newDist = distributionSetManagement
.createDistributionSet(entityFactory.distributionSet().create().name(name).version(version)
.description(desc).type(distributionSetManagement.findDistributionSetTypeById(distSetTypeId))
.requiredMigrationStep(isMigStepReq));
notificationMessage.displaySuccess(
i18n.get("message.new.dist.save.success", new Object[] { newDist.getName(), newDist.getVersion() }));
final Set<DistributionSetIdName> s = new HashSet<>();
s.add(new DistributionSetIdName(newDist.getId(), newDist.getName(), newDist.getVersion()));
final DistributionSetTable distributionSetTable = SpringContextHelper.getBean(DistributionSetTable.class);
distributionSetTable.setValue(s);
}
/**
* Set Values for Distribution set.
*
* @param distributionSet
* as reference
* @param name
* as string
* @param version
* as string
* @param desc
* as string
* @param isMigStepReq
* as string
*/
private void setDistributionValues(final DistributionSet distributionSet, final String name, final String version,
final String distSetTypeName, final String desc, final boolean isMigStepReq) {
distributionSet.setName(name);
distributionSet.setVersion(version);
distributionSet.setType(distributionSetManagement.findDistributionSetTypeByName(distSetTypeName));
distributionSet.setDescription(desc != null ? desc : "");
distributionSet.setRequiredMigrationStep(isMigStepReq);
distributionSetTable.setValue(
Sets.newHashSet(new DistributionSetIdName(newDist.getId(), newDist.getName(), newDist.getVersion())));
}
private boolean isDuplicate() {
@@ -324,9 +294,10 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
distNameTextField.setValue(distSet.getName());
distVersionTextField.setValue(distSet.getVersion());
if (distSet.getType().isDeleted()) {
distsetTypeNameComboBox.addItem(distSet.getType().getName());
distsetTypeNameComboBox.addItem(distSet.getType().getId());
}
distsetTypeNameComboBox.setValue(distSet.getType().getName());
distsetTypeNameComboBox.setValue(distSet.getType().getId());
reqMigStepCheckbox.setValue(distSet.isRequiredMigrationStep());
if (distSet.getDescription() != null) {
descTextArea.setValue(distSet.getDescription());
@@ -344,11 +315,9 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
resetComponents();
populateDistSetTypeNameCombo();
populateValuesOfDistribution(editDistId);
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(i18n.get("caption.add.new.dist"))
return new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(i18n.get("caption.add.new.dist"))
.content(this).layout(formLayout).i18n(i18n).saveDialogCloseListener(new SaveOnCloseDialogListener())
.buildCommonDialogWindow();
return window;
}
/**
@@ -357,7 +326,7 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
private void populateDistSetTypeNameCombo() {
distsetTypeNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer());
distsetTypeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getName());
distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getId());
}
}

View File

@@ -12,7 +12,6 @@ import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import java.util.List;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
@@ -22,7 +21,6 @@ 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;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -39,9 +37,6 @@ public class CreateUpdateDistributionTagLayoutWindow extends AbstractCreateUpdat
private static final long serialVersionUID = 444276149954167545L;
@Autowired
private transient EntityFactory entityFactory;
private static final String TARGET_TAG_NAME_DYNAMIC_STYLE = "new-target-tag-name";
private static final String MSG_TEXTFIELD_NAME = "textfield.name";
@@ -103,13 +98,14 @@ public class CreateUpdateDistributionTagLayoutWindow extends AbstractCreateUpdat
protected void createNewTag() {
super.createNewTag();
if (isNotEmpty(getTagNameValue())) {
DistributionSetTag newDistTag = entityFactory.generateDistributionSetTag(tagNameValue, tagDescValue,
ColorPickerConstants.START_COLOR.getCSS());
String colour = ColorPickerConstants.START_COLOR.getCSS();
if (isNotEmpty(getColorPicked())) {
newDistTag.setColour(getColorPicked());
colour = getColorPicked();
}
newDistTag = tagManagement.createDistributionSetTag(newDistTag);
final DistributionSetTag newDistTag = tagManagement.createDistributionSetTag(
entityFactory.tag().create().name(tagNameValue).description(tagDescValue).colour(colour));
displaySuccess(newDistTag.getName());
resetDistTagValues();
} else {

View File

@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.ui.management.dstag;
import java.util.Collections;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.Tag;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtonClickBehaviour;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.management.event.DistributionTagDropEvent;
@@ -46,7 +46,9 @@ import com.vaadin.ui.UI;
@ViewScope
public class DistributionTagButtons extends AbstractFilterButtons {
private static final long serialVersionUID = -8151483237450892057L;
private static final String NO_TAG = "NO TAG";
private static final long serialVersionUID = 1L;
@Autowired
private DistributionTagDropEvent spDistTagDropEvent;
@@ -60,7 +62,7 @@ public class DistributionTagButtons extends AbstractFilterButtons {
@Override
public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
super.init(filterButtonClickBehaviour);
addNewTag(entityFactory.generateDistributionSetTag("NO TAG"));
addNewTag(entityFactory.tag().create().name(NO_TAG).build());
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -102,8 +104,7 @@ public class DistributionTagButtons extends AbstractFilterButtons {
protected LazyQueryContainer createButtonsLazyQueryContainer() {
final BeanQueryFactory<DistributionTagBeanQuery> tagQF = new BeanQueryFactory<>(DistributionTagBeanQuery.class);
tagQF.setQueryConfiguration(Collections.emptyMap());
return HawkbitCommonUtil.createDSLazyQueryContainer(
new BeanQueryFactory<DistributionTagBeanQuery>(DistributionTagBeanQuery.class));
return HawkbitCommonUtil.createDSLazyQueryContainer(new BeanQueryFactory<>(DistributionTagBeanQuery.class));
}
@@ -141,11 +142,11 @@ public class DistributionTagButtons extends AbstractFilterButtons {
private void refreshTagTable() {
((LazyQueryContainer) getContainerDataSource()).refresh();
removeGeneratedColumn(FILTER_BUTTON_COLUMN);
addNewTag(entityFactory.generateDistributionSetTag("NO TAG"));
addNewTag(entityFactory.tag().create().name(NO_TAG).build());
addColumn();
}
private void addNewTag(final DistributionSetTag daTag) {
private void addNewTag(final Tag daTag) {
final LazyQueryContainer targetTagContainer = (LazyQueryContainer) getContainerDataSource();
final Object addItem = targetTagContainer.addItem();
final Item item = targetTagContainer.getItem(addItem);

View File

@@ -217,12 +217,9 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override
protected boolean hasUnsavedActions() {
if (!managementUIState.getDeletedDistributionList().isEmpty()
return !managementUIState.getDeletedDistributionList().isEmpty()
|| !managementUIState.getDeletedTargetList().isEmpty()
|| !managementUIState.getAssignedList().isEmpty()) {
return true;
}
return false;
|| !managementUIState.getAssignedList().isEmpty();
}
@Override

View File

@@ -169,9 +169,9 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
for (final Map.Entry<Long, ArrayList<TargetIdName>> mapEntry : saveAssignedList.entrySet()) {
tempIdList = saveAssignedList.get(mapEntry.getKey());
final String[] ids = tempIdList.stream().map(t -> t.getControllerId()).toArray(size -> new String[size]);
final DistributionSetAssignmentResult distributionSetAssignmentResult = deploymentManagement
.assignDistributionSet(mapEntry.getKey(), actionType, forcedTimeStamp, ids);
.assignDistributionSet(mapEntry.getKey(), actionType, forcedTimeStamp,
tempIdList.stream().map(t -> t.getControllerId()).collect(Collectors.toList()));
if (distributionSetAssignmentResult.getAssigned() > 0) {
successAssignmentCount += distributionSetAssignmentResult.getAssigned();

View File

@@ -327,7 +327,7 @@ public class BulkUploadHandler extends CustomComponent
return i18n.get("message.bulk.upload.assignment.failed");
}
deploymentManagement.assignDistributionSet(targetBulkUpload.getDsNameAndVersion().getId(), actionType,
forcedTimeStamp, targetsList.toArray(new String[targetsList.size()]));
forcedTimeStamp, targetsList);
return null;
}
@@ -398,9 +398,8 @@ public class BulkUploadHandler extends CustomComponent
final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
/* create new target entity */
final Target newTarget = entityFactory.generateTarget(newControllerId);
setTargetValues(newTarget, newName, newDesc);
targetManagement.createTarget(newTarget);
targetManagement.createTarget(entityFactory.target().create().controllerId(newControllerId)
.name(newName).description(newDesc));
managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated().add(newControllerId);
successfullTargetCount++;
}
@@ -408,16 +407,6 @@ public class BulkUploadHandler extends CustomComponent
}
}
private static void setTargetValues(final Target target, final String name, final String description) {
if (null == name) {
target.setName(target.getControllerId());
} else {
target.setName(name);
}
target.setName(name == null ? target.getControllerId() : name);
target.setDescription(description);
}
private boolean mandatoryCheck(final String newControlllerId) {
if (newControlllerId == null) {
failedTargetCount++;

View File

@@ -132,32 +132,23 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
* Update the Target if modified.
*/
public void updateTarget() {
final String newName = HawkbitCommonUtil.trimAndNullIfEmpty(nameTextField.getValue());
final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
/* get latest entity */
final Target latestTarget = targetManagement.findTargetByControllerIDWithDetails(controllerId);
/* update new name & desc */
setTargetValues(latestTarget, newName, newDesc);
/* save updated entity */
targetManagement.updateTarget(latestTarget);
final Target target = targetManagement.updateTarget(entityFactory.target().update(controllerId)
.name(nameTextField.getValue()).description(descTextArea.getValue()));
/* display success msg */
uINotification.displaySuccess(i18n.get("message.update.success", new Object[] { latestTarget.getName() }));
uINotification.displaySuccess(i18n.get("message.update.success", new Object[] { target.getName() }));
// publishing through event bus
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.UPDATED_ENTITY, latestTarget));
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.UPDATED_ENTITY, target));
}
private void addNewTarget() {
final String newControlllerId = HawkbitCommonUtil.trimAndNullIfEmpty(controllerIDTextField.getValue());
final String newControllerId = HawkbitCommonUtil.trimAndNullIfEmpty(controllerIDTextField.getValue());
final String newName = HawkbitCommonUtil.trimAndNullIfEmpty(nameTextField.getValue());
final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
/* create new target entity */
Target newTarget = entityFactory.generateTarget(newControlllerId);
/* set values to the new target entity */
setTargetValues(newTarget, newName, newDesc);
/* save new target */
newTarget = targetManagement.createTarget(newTarget);
final Target newTarget = targetManagement.createTarget(
entityFactory.target().create().controllerId(newControllerId).name(newName).description(newDesc));
final TargetTable targetTable = SpringContextHelper.getBean(TargetTable.class);
final Set<TargetIdName> s = new HashSet<>();
s.add(newTarget.getTargetIdName());
@@ -203,11 +194,6 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
editTarget = Boolean.FALSE;
}
private void setTargetValues(final Target target, final String name, final String description) {
target.setName(name == null ? target.getControllerId() : name);
target.setDescription(description);
}
private boolean isDuplicate() {
final String newControlllerId = controllerIDTextField.getValue();
final Target existingTarget = targetManagement.findTargetByControllerID(newControlllerId.trim());

View File

@@ -12,7 +12,6 @@ import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import java.util.List;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
@@ -20,7 +19,6 @@ 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;
@@ -37,9 +35,6 @@ public class CreateUpdateTargetTagLayoutWindow extends AbstractCreateUpdateTagLa
private static final long serialVersionUID = 2446682350481560235L;
@Autowired
private transient EntityFactory entityFactory;
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
@@ -121,15 +116,13 @@ public class CreateUpdateTargetTagLayoutWindow extends AbstractCreateUpdateTagLa
protected void createNewTag() {
super.createNewTag();
if (isNotEmpty(getTagNameValue())) {
TargetTag newTargetTag = entityFactory.generateTargetTag(getTagNameValue());
if (isNotEmpty(getTagDescValue())) {
newTargetTag.setDescription(getTagDescValue());
}
newTargetTag.setColour(ColorPickerConstants.START_COLOR.getCSS());
String colour = ColorPickerConstants.START_COLOR.getCSS();
if (isNotEmpty(getColorPicked())) {
newTargetTag.setColour(getColorPicked());
colour = getColorPicked();
}
newTargetTag = tagManagement.createTargetTag(newTargetTag);
final TargetTag newTargetTag = tagManagement.createTargetTag(
entityFactory.tag().create().name(getTagNameValue()).description(getTagDescValue()).colour(colour));
displaySuccess(newTargetTag.getName());
} else {
displayValidationError(i18n.get(MESSAGE_ERROR_MISSING_TAGNAME));

View File

@@ -168,9 +168,9 @@ public class FilterByStatusLayout extends VerticalLayout implements Button.Click
registered = SPUIComponentProvider.getButton(UIComponentIdProvider.REGISTERED_STATUS_ICON,
TargetUpdateStatus.REGISTERED.toString(), i18n.get("tooltip.status.registered"),
SPUIButtonDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class);
overdue = SPUIComponentProvider.getButton(UIComponentIdProvider.OVERDUE_STATUS_ICON,
OVERDUE_CAPTION, i18n.get("tooltip.status.overdue"),
SPUIButtonDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class);
overdue = SPUIComponentProvider.getButton(UIComponentIdProvider.OVERDUE_STATUS_ICON, OVERDUE_CAPTION,
i18n.get("tooltip.status.overdue"), SPUIButtonDefinitions.SP_BUTTON_STATUS_STYLE, false,
FontAwesome.SQUARE, SPUIButtonStyleSmall.class);
applyStatusBtnStyle();
unknown.setData("filterStatusOne");
inSync.setData("filterStatusTwo");
@@ -320,24 +320,15 @@ public class FilterByStatusLayout extends VerticalLayout implements Button.Click
* @return
*/
private boolean isStatusFilterApplied() {
if (isPendingOrUnknownBtnClicked() || isErrorOrRegisteredBtnClicked() || inSyncBtnClicked) {
return true;
}
return false;
return isPendingOrUnknownBtnClicked() || isErrorOrRegisteredBtnClicked() || inSyncBtnClicked;
}
private boolean isPendingOrUnknownBtnClicked() {
if (unknownBtnClicked || pendingBtnClicked) {
return true;
}
return false;
return unknownBtnClicked || pendingBtnClicked;
}
private boolean isErrorOrRegisteredBtnClicked() {
if (errorBtnClicked || registeredBtnClicked) {
return true;
}
return false;
return errorBtnClicked || registeredBtnClicked;
}
@PreDestroy

View File

@@ -38,17 +38,11 @@ import com.vaadin.ui.Table;
import com.vaadin.ui.themes.ValoTheme;
/**
* Target filter query{#link {@link TargetFilterQuery} buttons layout .
*
*
*
* Target filter query{#link {@link TargetFilterQuery} buttons layout.
*/
@SpringComponent
@ViewScope
public class TargetFilterQueryButtons extends Table {
/**
*
*/
private static final long serialVersionUID = 9188095103191937850L;
protected static final String FILTER_BUTTON_COLUMN = "filterButton";
@@ -115,10 +109,6 @@ public class TargetFilterQueryButtons extends Table {
addGeneratedColumn(FILTER_BUTTON_COLUMN, (source, itemId, columnId) -> addGeneratedCell(itemId));
}
/**
* @param itemId
* @return
*/
private Button addGeneratedCell(final Object itemId) {
final Item item = getItem(itemId);
final Long id = (Long) item.getItemProperty(SPUILabelDefinitions.VAR_ID).getValue();
@@ -131,16 +121,9 @@ public class TargetFilterQueryButtons extends Table {
return typeButton;
}
/**
* @param id
* @return
*/
private boolean isClickedByDefault(final Long id) {
if (managementUIState.getTargetTableFilters().getTargetFilterQuery().isPresent()
&& (managementUIState.getTargetTableFilters().getTargetFilterQuery().get().getId().equals(id))) {
return true;
}
return false;
return managementUIState.getTargetTableFilters().getTargetFilterQuery().map(q -> q.getId().equals(id))
.orElse(false);
}
private Button createFilterButton(final Long id, final String name, final Object itemId) {

View File

@@ -15,8 +15,8 @@ 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.model.Tag;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
@@ -59,8 +59,9 @@ import com.vaadin.ui.UI;
@SpringComponent
@ViewScope
public class TargetTagFilterButtons extends AbstractFilterButtons {
private static final String NO_TAG = "NO TAG";
private static final long serialVersionUID = 5049554600376508073L;
private static final long serialVersionUID = 1L;
@Autowired
private ManagementUIState managementUIState;
@@ -95,7 +96,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
public void init(final TargetTagFilterButtonClick filterButtonClickBehaviour) {
this.filterButtonClickBehaviour = filterButtonClickBehaviour;
super.init(filterButtonClickBehaviour);
addNewTargetTag(entityFactory.generateTargetTag("NO TAG"));
addNewTargetTag(entityFactory.tag().create().name(NO_TAG).build());
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -120,8 +121,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
@Override
protected LazyQueryContainer createButtonsLazyQueryContainer() {
return HawkbitCommonUtil
.createDSLazyQueryContainer(new BeanQueryFactory<TargetTagBeanQuery>(TargetTagBeanQuery.class));
return HawkbitCommonUtil.createDSLazyQueryContainer(new BeanQueryFactory<>(TargetTagBeanQuery.class));
}
@@ -307,7 +307,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
private void refreshContainer() {
removeGeneratedColumn(FILTER_BUTTON_COLUMN);
((LazyQueryContainer) getContainerDataSource()).refresh();
addNewTargetTag(entityFactory.generateTargetTag("NO TAG"));
addNewTargetTag(entityFactory.tag().create().name(NO_TAG).build());
addColumn();
}
@@ -320,7 +320,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
}
@SuppressWarnings("unchecked")
private void addNewTargetTag(final TargetTag newTargetTag) {
private void addNewTargetTag(final Tag newTargetTag) {
final LazyQueryContainer targetTagContainer = (LazyQueryContainer) getContainerDataSource();
final Object addItem = targetTagContainer.addItem();
final Item item = targetTagContainer.getItem(addItem);

View File

@@ -12,14 +12,12 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.RepositoryModelConstants;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorAction;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondition;
@@ -92,9 +90,6 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
@Autowired
private transient RolloutManagement rolloutManagement;
@Autowired
private transient DistributionSetManagement distributionSetManagement;
@Autowired
private transient TargetManagement targetManagement;
@@ -191,11 +186,10 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
public CommonDialogWindow getWindow() {
resetComponents();
final CommonDialogWindow commonDialogWindow = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
.caption(i18n.get("caption.configure.rollout")).content(this).layout(this).i18n(i18n)
return new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(i18n.get("caption.configure.rollout"))
.content(this).layout(this).i18n(i18n)
.helpLink(uiProperties.getLinks().getDocumentation().getRolloutView())
.saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
return commonDialogWindow;
}
/**
@@ -424,21 +418,9 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
if (rolloutForEdit == null) {
return;
}
rolloutForEdit.setName(rolloutName.getValue());
rolloutForEdit.setDescription(description.getValue());
final DistributionSetIdName distributionSetIdName = (DistributionSetIdName) distributionSet.getValue();
rolloutForEdit
.setDistributionSet(distributionSetManagement.findDistributionSetById(distributionSetIdName.getId()));
rolloutForEdit.setActionType(getActionType());
rolloutForEdit.setForcedTime(getForcedTimeStamp());
final int amountGroup = Integer.parseInt(noOfGroups.getValue());
final int errorThresoldPercent = getErrorThresoldPercentage(amountGroup);
for (final RolloutGroup rolloutGroup : rolloutForEdit.getRolloutGroups()) {
rolloutGroup.setErrorConditionExp(triggerThreshold.getValue());
rolloutGroup.setSuccessConditionExp(String.valueOf(errorThresoldPercent));
}
final Rollout updatedRollout = rolloutManagement.updateRollout(rolloutForEdit);
final Rollout updatedRollout = rolloutManagement.updateRollout(entityFactory.rollout()
.update(rolloutForEdit.getId()).name(rolloutName.getValue()).description(description.getValue()));
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { updatedRollout.getName() }));
eventBus.publish(this, RolloutEvent.UPDATE_ROLLOUT);
}
@@ -471,28 +453,22 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
}
private Rollout saveRollout() {
Rollout rolloutToCreate = entityFactory.generateRollout();
final int amountGroup = Integer.parseInt(noOfGroups.getValue());
final String targetFilter = getTargetFilterQuery();
final int errorThresoldPercent = getErrorThresoldPercentage(amountGroup);
final RolloutGroupConditions conditions = new RolloutGroupConditionBuilder()
final RolloutGroupConditions conditions = new RolloutGroupConditionBuilder().withDefaults()
.successAction(RolloutGroupSuccessAction.NEXTGROUP, null)
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, triggerThreshold.getValue())
.errorCondition(RolloutGroupErrorCondition.THRESHOLD, String.valueOf(errorThresoldPercent))
.errorAction(RolloutGroupErrorAction.PAUSE, null).build();
final DistributionSetIdName distributionSetIdName = (DistributionSetIdName) distributionSet.getValue();
rolloutToCreate.setName(rolloutName.getValue());
rolloutToCreate.setDescription(description.getValue());
rolloutToCreate.setTargetFilterQuery(targetFilter);
rolloutToCreate
.setDistributionSet(distributionSetManagement.findDistributionSetById(distributionSetIdName.getId()));
rolloutToCreate.setActionType(getActionType());
rolloutToCreate.setForcedTime(getForcedTimeStamp());
rolloutToCreate = rolloutManagement.createRollout(rolloutToCreate, amountGroup, conditions);
return rolloutToCreate;
return rolloutManagement.createRollout(entityFactory.rollout().create().name(rolloutName.getValue())
.description(description.getValue()).set(distributionSetIdName.getId())
.targetFilterQuery(getTargetFilterQuery()).actionType(getActionType()).forcedTime(getForcedTimeStamp()),
amountGroup, conditions);
}
private String getTargetFilterQuery() {
@@ -676,11 +652,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
final List<RolloutGroup> rolloutGroups = rolloutForEdit.getRolloutGroups();
setThresholdValues(rolloutGroups);
setActionType(rolloutForEdit);
if (rolloutForEdit.getStatus() != RolloutStatus.READY) {
disableRequiredFieldsOnEdit();
}
noOfGroups.setEnabled(false);
disableRequiredFieldsOnEdit();
targetFilterQuery.setValue(rolloutForEdit.getTargetFilterQuery());
removeComponent(1, 2);
targetFilterQueryCombo.removeValidator(nullValidator);
@@ -695,6 +667,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
}
private void disableRequiredFieldsOnEdit() {
noOfGroups.setEnabled(false);
distributionSet.setEnabled(false);
errorThreshold.setEnabled(false);
triggerThreshold.setEnabled(false);
@@ -747,7 +720,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
String value;
private SAVESTARTOPTIONS(final String val) {
SAVESTARTOPTIONS(final String val) {
this.value = val;
}
@@ -764,7 +737,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
String value;
private ERRORTHRESOLDOPTIONS(final String val) {
ERRORTHRESOLDOPTIONS(final String val) {
this.value = val;
}

View File

@@ -14,8 +14,17 @@ import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_OPEN_TAG;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_CLOSE_TAG;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.ACTION;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_CREATED_DATE;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_CREATED_USER;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_DESC;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_DIST_NAME_VERSION;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_ID;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_MODIFIED_BY;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_MODIFIED_DATE;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_NAME;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_STATUS;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_TOTAL_TARGETS;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS;
import java.util.ArrayList;
@@ -46,7 +55,6 @@ 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.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;
@@ -150,15 +158,14 @@ public class RolloutListGrid extends AbstractGrid {
refreshGrid();
return;
}
item.getItemProperty(SPUILabelDefinitions.VAR_STATUS).setValue(rollout.getStatus());
item.getItemProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setValue(totalTargetCountStatus);
final Long groupCount = (Long) item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).getValue();
item.getItemProperty(VAR_STATUS).setValue(rollout.getStatus());
item.getItemProperty(VAR_TOTAL_TARGETS_COUNT_STATUS).setValue(totalTargetCountStatus);
final Long groupCount = (Long) item.getItemProperty(VAR_NUMBER_OF_GROUPS).getValue();
final int groupsCreated = rollout.getRolloutGroupsCreated();
if (groupsCreated != 0) {
item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setValue(Long.valueOf(groupsCreated));
item.getItemProperty(VAR_NUMBER_OF_GROUPS).setValue(Long.valueOf(groupsCreated));
} else if (rollout.getRolloutGroups() != null && groupCount != rollout.getRolloutGroups().size()) {
item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS)
.setValue(Long.valueOf(rollout.getRolloutGroups().size()));
item.getItemProperty(VAR_NUMBER_OF_GROUPS).setValue(Long.valueOf(rollout.getRolloutGroups().size()));
}
item.getItemProperty(ROLLOUT_RENDERER_DATA)
.setValue(new RolloutRendererData(rollout.getName(), rollout.getStatus().toString()));
@@ -167,38 +174,29 @@ public class RolloutListGrid extends AbstractGrid {
@Override
protected Container createContainer() {
final BeanQueryFactory<RolloutBeanQuery> rolloutQf = new BeanQueryFactory<>(RolloutBeanQuery.class);
return new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), rolloutQf);
return new LazyQueryContainer(new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, VAR_ID), rolloutQf);
}
@Override
protected void addContainerProperties() {
final LazyQueryContainer rolloutGridContainer = (LazyQueryContainer) getContainerDataSource();
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false);
rolloutGridContainer.addContainerProperty(VAR_NAME, String.class, "", false, false);
rolloutGridContainer.addContainerProperty(DS_TYPE, String.class, null, false, false);
rolloutGridContainer.addContainerProperty(SW_MODULES, Set.class, null, false, false);
rolloutGridContainer.addContainerProperty(ROLLOUT_RENDERER_DATA, RolloutRendererData.class, null, false, false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, null, false, false);
rolloutGridContainer.addContainerProperty(VAR_DESC, String.class, null, false, false);
rolloutGridContainer.addContainerProperty(IS_REQUIRED_MIGRATION_STEP, boolean.class, null, false, false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutStatus.class, null, false,
false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION, String.class, null, false,
false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false,
false);
rolloutGridContainer.addContainerProperty(VAR_STATUS, RolloutStatus.class, null, false, false);
rolloutGridContainer.addContainerProperty(VAR_DIST_NAME_VERSION, String.class, null, false, false);
rolloutGridContainer.addContainerProperty(VAR_CREATED_DATE, String.class, null, false, false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_DATE, String.class, null, false,
false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_USER, String.class, null, false,
false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_BY, String.class, null, false,
false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS, Long.class, 0, false,
false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS, String.class, "0", false,
false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS,
TotalTargetCountStatus.class, null, false, false);
rolloutGridContainer.addContainerProperty(VAR_MODIFIED_DATE, String.class, null, false, false);
rolloutGridContainer.addContainerProperty(VAR_CREATED_USER, String.class, null, false, false);
rolloutGridContainer.addContainerProperty(VAR_MODIFIED_BY, String.class, null, false, false);
rolloutGridContainer.addContainerProperty(VAR_NUMBER_OF_GROUPS, Long.class, 0, false, false);
rolloutGridContainer.addContainerProperty(VAR_TOTAL_TARGETS, String.class, "0", false, false);
rolloutGridContainer.addContainerProperty(VAR_TOTAL_TARGETS_COUNT_STATUS, TotalTargetCountStatus.class, null,
false, false);
rolloutGridContainer.addContainerProperty(RUN_OPTION, String.class, FontAwesome.PLAY.getHtml(), false, false);
@@ -217,17 +215,17 @@ public class RolloutListGrid extends AbstractGrid {
getColumn(ROLLOUT_RENDERER_DATA).setMinimumWidth(40);
getColumn(ROLLOUT_RENDERER_DATA).setMaximumWidth(150);
getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMinimumWidth(40);
getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMaximumWidth(150);
getColumn(VAR_DIST_NAME_VERSION).setMinimumWidth(40);
getColumn(VAR_DIST_NAME_VERSION).setMaximumWidth(150);
getColumn(SPUILabelDefinitions.VAR_STATUS).setMinimumWidth(75);
getColumn(SPUILabelDefinitions.VAR_STATUS).setMaximumWidth(75);
getColumn(VAR_STATUS).setMinimumWidth(75);
getColumn(VAR_STATUS).setMaximumWidth(75);
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMinimumWidth(40);
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMaximumWidth(100);
getColumn(VAR_TOTAL_TARGETS).setMinimumWidth(40);
getColumn(VAR_TOTAL_TARGETS).setMaximumWidth(100);
getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMinimumWidth(40);
getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMaximumWidth(100);
getColumn(VAR_NUMBER_OF_GROUPS).setMinimumWidth(40);
getColumn(VAR_NUMBER_OF_GROUPS).setMaximumWidth(100);
getColumn(RUN_OPTION).setMinimumWidth(25);
getColumn(RUN_OPTION).setMaximumWidth(25);
@@ -240,7 +238,7 @@ public class RolloutListGrid extends AbstractGrid {
getColumn(UPDATE_OPTION).setMaximumWidth(25);
}
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setMinimumWidth(280);
getColumn(VAR_TOTAL_TARGETS_COUNT_STATUS).setMinimumWidth(280);
setFrozenColumnCount(getColumns().size());
}
@@ -251,17 +249,16 @@ public class RolloutListGrid extends AbstractGrid {
getColumn(DS_TYPE).setHeaderCaption(i18n.get("header.type"));
getColumn(SW_MODULES).setHeaderCaption(i18n.get("header.swmodules"));
getColumn(IS_REQUIRED_MIGRATION_STEP).setHeaderCaption(i18n.get("header.migrations.step"));
getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setHeaderCaption(i18n.get("header.distributionset"));
getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setHeaderCaption(i18n.get("header.numberofgroups"));
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setHeaderCaption(i18n.get("header.total.targets"));
getColumn(SPUILabelDefinitions.VAR_CREATED_DATE).setHeaderCaption(i18n.get("header.createdDate"));
getColumn(SPUILabelDefinitions.VAR_CREATED_USER).setHeaderCaption(i18n.get("header.createdBy"));
getColumn(SPUILabelDefinitions.VAR_MODIFIED_DATE).setHeaderCaption(i18n.get("header.modifiedDate"));
getColumn(SPUILabelDefinitions.VAR_MODIFIED_BY).setHeaderCaption(i18n.get("header.modifiedBy"));
getColumn(SPUILabelDefinitions.VAR_DESC).setHeaderCaption(i18n.get("header.description"));
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS)
.setHeaderCaption(i18n.get("header.detail.status"));
getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.get("header.status"));
getColumn(VAR_DIST_NAME_VERSION).setHeaderCaption(i18n.get("header.distributionset"));
getColumn(VAR_NUMBER_OF_GROUPS).setHeaderCaption(i18n.get("header.numberofgroups"));
getColumn(VAR_TOTAL_TARGETS).setHeaderCaption(i18n.get("header.total.targets"));
getColumn(VAR_CREATED_DATE).setHeaderCaption(i18n.get("header.createdDate"));
getColumn(VAR_CREATED_USER).setHeaderCaption(i18n.get("header.createdBy"));
getColumn(VAR_MODIFIED_DATE).setHeaderCaption(i18n.get("header.modifiedDate"));
getColumn(VAR_MODIFIED_BY).setHeaderCaption(i18n.get("header.modifiedBy"));
getColumn(VAR_DESC).setHeaderCaption(i18n.get("header.description"));
getColumn(VAR_TOTAL_TARGETS_COUNT_STATUS).setHeaderCaption(i18n.get("header.detail.status"));
getColumn(VAR_STATUS).setHeaderCaption(i18n.get("header.status"));
getColumn(RUN_OPTION).setHeaderCaption(i18n.get("header.action.run"));
getColumn(PAUSE_OPTION).setHeaderCaption(i18n.get("header.action.pause"));
@@ -283,14 +280,14 @@ public class RolloutListGrid extends AbstractGrid {
protected void setColumnProperties() {
final List<Object> columnList = new ArrayList<>();
columnList.add(ROLLOUT_RENDERER_DATA);
columnList.add(SPUILabelDefinitions.VAR_DIST_NAME_VERSION);
columnList.add(VAR_DIST_NAME_VERSION);
columnList.add(DS_TYPE);
columnList.add(SW_MODULES);
columnList.add(IS_REQUIRED_MIGRATION_STEP);
columnList.add(SPUILabelDefinitions.VAR_STATUS);
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
columnList.add(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS);
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS);
columnList.add(VAR_STATUS);
columnList.add(VAR_TOTAL_TARGETS_COUNT_STATUS);
columnList.add(VAR_NUMBER_OF_GROUPS);
columnList.add(VAR_TOTAL_TARGETS);
columnList.add(RUN_OPTION);
columnList.add(PAUSE_OPTION);
@@ -299,11 +296,11 @@ public class RolloutListGrid extends AbstractGrid {
columnList.add(UPDATE_OPTION);
}
columnList.add(SPUILabelDefinitions.VAR_CREATED_DATE);
columnList.add(SPUILabelDefinitions.VAR_CREATED_USER);
columnList.add(SPUILabelDefinitions.VAR_MODIFIED_DATE);
columnList.add(SPUILabelDefinitions.VAR_MODIFIED_BY);
columnList.add(SPUILabelDefinitions.VAR_DESC);
columnList.add(VAR_CREATED_DATE);
columnList.add(VAR_CREATED_USER);
columnList.add(VAR_MODIFIED_DATE);
columnList.add(VAR_MODIFIED_BY);
columnList.add(VAR_DESC);
setColumnOrder(columnList.toArray());
alignColumns();
}
@@ -311,12 +308,12 @@ public class RolloutListGrid extends AbstractGrid {
@Override
protected void setHiddenColumns() {
final List<Object> columnsToBeHidden = new ArrayList<>();
columnsToBeHidden.add(SPUILabelDefinitions.VAR_NAME);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC);
columnsToBeHidden.add(VAR_NAME);
columnsToBeHidden.add(VAR_CREATED_DATE);
columnsToBeHidden.add(VAR_CREATED_USER);
columnsToBeHidden.add(VAR_MODIFIED_DATE);
columnsToBeHidden.add(VAR_MODIFIED_BY);
columnsToBeHidden.add(VAR_DESC);
columnsToBeHidden.add(IS_REQUIRED_MIGRATION_STEP);
columnsToBeHidden.add(DS_TYPE);
columnsToBeHidden.add(SW_MODULES);
@@ -332,13 +329,12 @@ public class RolloutListGrid extends AbstractGrid {
@Override
protected void addColumnRenderes() {
getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setRenderer(new HtmlRenderer(),
new TotalTargetGroupsConverter());
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(),
getColumn(VAR_NUMBER_OF_GROUPS).setRenderer(new HtmlRenderer(), new TotalTargetGroupsConverter());
getColumn(VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(),
new TotalTargetCountStatusConverter());
createRolloutStatusToFontMap();
getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(), new RolloutStatusConverter());
getColumn(VAR_STATUS).setRenderer(new HtmlLabelRenderer(), new RolloutStatusConverter());
final RolloutRenderer customObjectRenderer = new RolloutRenderer(RolloutRendererData.class);
customObjectRenderer.addClickListener(this::onClickOfRolloutName);
@@ -382,10 +378,10 @@ public class RolloutListGrid extends AbstractGrid {
private void onClickOfRolloutName(final RendererClickEvent event) {
rolloutUIState.setRolloutId((long) event.getItemId());
final String rolloutName = (String) getContainerDataSource().getItem(event.getItemId())
.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
.getItemProperty(VAR_NAME).getValue();
rolloutUIState.setRolloutName(rolloutName);
final String ds = (String) getContainerDataSource().getItem(event.getItemId())
.getItemProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).getValue();
.getItemProperty(VAR_DIST_NAME_VERSION).getValue();
rolloutUIState.setRolloutDistributionSet(ds);
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUPS);
}
@@ -393,14 +389,13 @@ public class RolloutListGrid extends AbstractGrid {
private void pauseRollout(final Long rolloutId) {
final Item row = getContainerDataSource().getItem(rolloutId);
final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS)
.getValue();
final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(VAR_STATUS).getValue();
if (!RolloutStatus.RUNNING.equals(rolloutStatus)) {
return;
}
final String rolloutName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
final String rolloutName = (String) row.getItemProperty(VAR_NAME).getValue();
rolloutManagement.pauseRollout(rolloutManagement.findRolloutById(rolloutId));
uiNotification.displaySuccess(i18n.get("message.rollout.paused", rolloutName));
@@ -409,9 +404,8 @@ public class RolloutListGrid extends AbstractGrid {
private void startOrResumeRollout(final Long rolloutId) {
final Item row = getContainerDataSource().getItem(rolloutId);
final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS)
.getValue();
final String rolloutName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(VAR_STATUS).getValue();
final String rolloutName = (String) row.getItemProperty(VAR_NAME).getValue();
if (RolloutStatus.READY.equals(rolloutStatus)) {
rolloutManagement.startRollout(rolloutManagement.findRolloutByName(rolloutName));
@@ -470,7 +464,7 @@ public class RolloutListGrid extends AbstractGrid {
stringBuilder.append(HTML_UL_OPEN_TAG);
stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append(" DistributionSet Description : ")
.append((String) rolloutItem.getItemProperty(SPUILabelDefinitions.VAR_DESC).getValue());
.append((String) rolloutItem.getItemProperty(VAR_DESC).getValue());
stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append(" DistributionSet Type : ")
@@ -521,7 +515,7 @@ public class RolloutListGrid extends AbstractGrid {
@Override
public String getStyle(final CellReference cellReference) {
if (SPUILabelDefinitions.VAR_STATUS.equals(cellReference.getPropertyId())) {
if (VAR_STATUS.equals(cellReference.getPropertyId())) {
return "centeralign";
}
return convertRolloutStatusToString(cellReference);
@@ -557,7 +551,7 @@ public class RolloutListGrid extends AbstractGrid {
private RolloutStatus getRolloutStatus(final Object itemId) {
final Item row = containerDataSource.getItem(itemId);
return (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS).getValue();
return (RolloutStatus) row.getItemProperty(VAR_STATUS).getValue();
}
}

View File

@@ -126,10 +126,7 @@ public class DefaultDistributionSetTypeLayout extends BaseConfigurationView impl
@Override
public void save() {
if (!currentDefaultDisSetType.equals(selectedDefaultDisSetType) && selectedDefaultDisSetType != null) {
final DistributionSetType defaultDistributionSetType = distributionSetManagement
.findDistributionSetTypeById(selectedDefaultDisSetType);
tenantMetaData.setDefaultDsType(defaultDistributionSetType);
tenantMetaData = systemManagement.updateTenantMetadata(tenantMetaData);
tenantMetaData = systemManagement.updateTenantMetadata(selectedDefaultDisSetType);
currentDefaultDisSetType = selectedDefaultDisSetType;
}
changeIcon.setVisible(false);

View File

@@ -366,14 +366,9 @@ public final class HawkbitCommonUtil {
public static SoftwareModule addNewBaseSoftware(final EntityFactory entityFactory, final String bsname,
final String bsversion, final String bsvendor, final SoftwareModuleType bstype, final String description) {
final SoftwareManagement swMgmtService = SpringContextHelper.getBean(SoftwareManagement.class);
SoftwareModule newSWModule = entityFactory.generateSoftwareModule();
newSWModule.setType(bstype);
newSWModule.setName(bsname);
newSWModule.setVersion(bsversion);
newSWModule.setVendor(bsvendor);
newSWModule.setDescription(description);
newSWModule = swMgmtService.createSoftwareModule(newSWModule);
return newSWModule;
return swMgmtService.createSoftwareModule(entityFactory.softwareModule().create().type(bstype).name(bsname)
.version(bsversion).description(description).vendor(bsvendor));
}
/**