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

View File

@@ -40,8 +40,8 @@ public abstract class AbstractNamedVersionTable<E extends NamedVersionedEntity,
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
protected void updateEntity(final E baseEntity, final Item item) { protected void updateEntity(final E baseEntity, final Item item) {
super.updateEntity(baseEntity, item);
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(baseEntity.getVersion()); 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 @Override
@SuppressWarnings("unchecked")
protected Item addEntity(final DistributionSet baseEntity) { protected Item addEntity(final DistributionSet baseEntity) {
final Item item = super.addEntity(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()) { if (manageDistUIState.getSelectedDistributions().isPresent()) {
manageDistUIState.getSelectedDistributions().get().stream().forEach(this::unselect); manageDistUIState.getSelectedDistributions().get().stream().forEach(this::unselect);
} }
@@ -472,6 +468,14 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
return item; 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 @Override
protected void setDataAvailable(final boolean available) { protected void setDataAvailable(final boolean available) {
manageDistUIState.setNoDataAvailableDist(!available); manageDistUIState.setNoDataAvailableDist(!available);

View File

@@ -324,17 +324,9 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
} }
@Override @Override
@SuppressWarnings("unchecked")
protected Item addEntity(final SoftwareModule baseEntity) { protected Item addEntity(final SoftwareModule baseEntity) {
final Item item = super.addEntity(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()) { if (!manageDistUIState.getSelectedSoftwareModules().isEmpty()) {
manageDistUIState.getSelectedSoftwareModules().stream().forEach(this::unselect); manageDistUIState.getSelectedSoftwareModules().stream().forEach(this::unselect);
} }
@@ -342,6 +334,18 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
return item; 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) { private void showArtifactDetailsWindow(final Long itemId, final String nameVersionStr) {
final Window atrifactDtlsWindow = new Window(); final Window atrifactDtlsWindow = new Window();
atrifactDtlsWindow.setCaption(HawkbitCommonUtil.getArtifactoryDetailsLabelId(nameVersionStr)); atrifactDtlsWindow.setCaption(HawkbitCommonUtil.getArtifactoryDetailsLabelId(nameVersionStr));