Update the entity before call the super method

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-04-12 13:37:07 +02:00
parent 85ec59b04e
commit d91922dc04
4 changed files with 47 additions and 46 deletions

View File

@@ -9,7 +9,6 @@
package org.eclipse.hawkbit.ui.artifacts.smtable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.repository.SoftwareManagement;
@@ -25,7 +24,6 @@ import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
@@ -44,6 +42,8 @@ import com.vaadin.ui.UI;
/**
* Header of Software module table.
*
*
*
*/
@SpringComponent
@@ -129,22 +129,6 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
return artifactUploadState.isSwModuleTableMaximized();
}
@Override
protected SoftwareModule findEntityByTableValue(final Long entityTableId) {
return softwareManagement.findSoftwareModuleById(entityTableId);
}
@Override
protected ArtifactUploadState getManagmentEntityState() {
return artifactUploadState;
}
@Override
protected void publishEntityAfterValueChange(final SoftwareModule lastSoftwareModule) {
artifactUploadState.setSelectedBaseSoftwareModule(lastSoftwareModule);
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.SELECTED_ENTITY, lastSoftwareModule));
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleEvent event) {
onBaseEntityEvent(event);
@@ -157,32 +141,25 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
}
}
@SuppressWarnings("unchecked")
@Override
protected Item addEntity(final SoftwareModule baseEntity) {
final Item item = super.addEntity(baseEntity);
final String swNameVersion = HawkbitCommonUtil.concatStrings(":", baseEntity.getName(),
baseEntity.getVersion());
item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(swNameVersion);
item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(baseEntity.getVendor());
if (!artifactUploadState.getSelectedSoftwareModules().isEmpty()) {
artifactUploadState.getSelectedSoftwareModules().stream().forEach(this::unselect);
}
select(baseEntity.getId());
return item;
}
@SuppressWarnings("unchecked")
@Override
protected List<TableColumn> getTableVisibleColumns() {
final List<TableColumn> columnList = super.getTableVisibleColumns();
if (!isMaximized()) {
return columnList;
}
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VENDOR, i18n.get("header.vendor"), 0.1F));
return columnList;
protected void updateEntity(final SoftwareModule baseEntity, final Item item) {
final String swNameVersion = HawkbitCommonUtil.concatStrings(":", baseEntity.getName(),
baseEntity.getVersion());
item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(swNameVersion);
item.getItemProperty("swId").setValue(baseEntity.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(baseEntity.getVendor());
super.updateEntity(baseEntity, item);
}
@Override
@@ -203,6 +180,22 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
};
}
@Override
protected SoftwareModule findEntityByTableValue(final Long entityTableId) {
return softwareManagement.findSoftwareModuleById(entityTableId);
}
@Override
protected ArtifactUploadState getManagmentEntityState() {
return artifactUploadState;
}
@Override
protected void publishEntityAfterValueChange(final SoftwareModule lastSoftwareModule) {
artifactUploadState.setSelectedBaseSoftwareModule(lastSoftwareModule);
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.SELECTED_ENTITY, lastSoftwareModule));
}
@Override
protected void setDataAvailable(final boolean available) {
artifactUploadState.setNoDataAvilableSoftwareModule(!available);

View File

@@ -40,8 +40,8 @@ public abstract class AbstractNamedVersionTable<E extends NamedVersionedEntity,
@SuppressWarnings("unchecked")
@Override
protected void updateEntity(final E baseEntity, final Item item) {
super.updateEntity(baseEntity, item);
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(baseEntity.getVersion());
super.updateEntity(baseEntity, item);
}
}

View File

@@ -459,12 +459,8 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
}
@Override
@SuppressWarnings("unchecked")
protected Item addEntity(final DistributionSet baseEntity) {
final Item item = super.addEntity(baseEntity);
item.getItemProperty(SPUILabelDefinitions.DIST_ID).setValue(baseEntity.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).setValue(baseEntity.isComplete());
if (manageDistUIState.getSelectedDistributions().isPresent()) {
manageDistUIState.getSelectedDistributions().get().stream().forEach(this::unselect);
}
@@ -472,6 +468,14 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
return item;
}
@Override
@SuppressWarnings("unchecked")
protected void updateEntity(final DistributionSet baseEntity, final Item item) {
item.getItemProperty(SPUILabelDefinitions.DIST_ID).setValue(baseEntity.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).setValue(baseEntity.isComplete());
super.updateEntity(baseEntity, item);
}
@Override
protected void setDataAvailable(final boolean available) {
manageDistUIState.setNoDataAvailableDist(!available);

View File

@@ -324,17 +324,9 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
}
@Override
@SuppressWarnings("unchecked")
protected Item addEntity(final SoftwareModule baseEntity) {
final Item item = super.addEntity(baseEntity);
final String swNameVersion = HawkbitCommonUtil.concatStrings(":", baseEntity.getName(),
baseEntity.getVersion());
item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(swNameVersion);
item.getItemProperty("swId").setValue(baseEntity.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(baseEntity.getVendor());
item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).setValue(baseEntity.getType().getColour());
if (!manageDistUIState.getSelectedSoftwareModules().isEmpty()) {
manageDistUIState.getSelectedSoftwareModules().stream().forEach(this::unselect);
}
@@ -342,6 +334,18 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
return item;
}
@Override
@SuppressWarnings("unchecked")
protected void updateEntity(final SoftwareModule baseEntity, final Item item) {
final String swNameVersion = HawkbitCommonUtil.concatStrings(":", baseEntity.getName(),
baseEntity.getVersion());
item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(swNameVersion);
item.getItemProperty("swId").setValue(baseEntity.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(baseEntity.getVendor());
item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).setValue(baseEntity.getType().getColour());
super.updateEntity(baseEntity, item);
}
private void showArtifactDetailsWindow(final Long itemId, final String nameVersionStr) {
final Window atrifactDtlsWindow = new Window();
atrifactDtlsWindow.setCaption(HawkbitCommonUtil.getArtifactoryDetailsLabelId(nameVersionStr));