Remove unnecessary DB calls from UI

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
kaizimmerm
2016-11-23 22:34:37 +01:00
parent 54ba35966e
commit a951137d4f
13 changed files with 28 additions and 70 deletions

View File

@@ -77,8 +77,6 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
private TextArea descTextArea;
private CommonDialogWindow window;
private Boolean editSwModule = Boolean.FALSE;
private Long baseSwModuleId;
@@ -133,9 +131,9 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
public CommonDialogWindow createUpdateSoftwareModuleWindow(final Long baseSwModuleId) {
this.baseSwModuleId = baseSwModuleId;
resetComponents();
populateTypeNameCombo();
populateValuesOfSwModule();
createWindow();
return window;
return createWindow();
}
private void createRequiredComponents() {
@@ -157,7 +155,6 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
typeComboBox.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + " " + ValoTheme.COMBOBOX_TINY);
typeComboBox.setNewItemsAllowed(Boolean.FALSE);
typeComboBox.setImmediate(Boolean.TRUE);
populateTypeNameCombo();
}
private TextField createTextField(final String in18Key, final String id) {
@@ -181,7 +178,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
editSwModule = Boolean.FALSE;
}
private void createWindow() {
private CommonDialogWindow createWindow() {
final Label madatoryStarLabel = new Label("*");
madatoryStarLabel.setStyleName("v-caption v-required-field-indicator");
madatoryStarLabel.setWidth(null);
@@ -198,7 +195,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
setCompositionRoot(formLayout);
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
final CommonDialogWindow window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
.caption(i18n.get("upload.caption.add.new.swmodule")).content(this).layout(formLayout).i18n(i18n)
.saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
nameTextField.setEnabled(!editSwModule);
@@ -206,6 +203,8 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
typeComboBox.setEnabled(!editSwModule);
typeComboBox.focus();
return window;
}
private void addNewBaseSoftware() {
@@ -271,6 +270,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
: HawkbitCommonUtil.trimAndNullIfEmpty(swModle.getVendor()));
descTextArea.setValue(swModle.getDescription() == null ? HawkbitCommonUtil.SP_STRING_EMPTY
: HawkbitCommonUtil.trimAndNullIfEmpty(swModle.getDescription()));
if (swModle.getType().isDeleted()) {
typeComboBox.addItem(swModle.getType().getName());
}

View File

@@ -16,6 +16,7 @@ import java.util.Set;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
@@ -81,6 +82,9 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
@Autowired
private transient DistributionSetManagement distributionSetManagement;
@Autowired
private transient TargetManagement targetManagement;
@Autowired
private DsMetadataPopupLayout dsMetadataPopupLayout;
@@ -183,9 +187,8 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
private Button assignSoftModuleButton(final String softwareModuleName) {
if (getPermissionChecker().hasUpdateDistributionPermission()
&& manageDistUIState.getLastSelectedDistribution().isPresent()
&& distributionSetManagement
.findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId())
.getAssignedTargets().isEmpty()) {
&& targetManagement.countTargetByAssignedDistributionSet(
manageDistUIState.getLastSelectedDistribution().get().getId()) <= 0) {
final Button reassignSoftModule = SPUIComponentProvider.getButton(softwareModuleName, "", "", "", true,
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
reassignSoftModule.setEnabled(false);

View File

@@ -73,7 +73,8 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
@Override
protected List<MetaData> getMetadataList() {
return Collections.unmodifiableList(getSelectedEntity().getMetadata());
return Collections.unmodifiableList(
distributionSetManagement.findDistributionSetMetadataByDistributionSetId(getSelectedEntity().getId()));
}
/**

View File

@@ -149,7 +149,6 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
distsetTypeNameComboBox.setImmediate(true);
distsetTypeNameComboBox.setNullSelectionAllowed(false);
distsetTypeNameComboBox.setId(UIComponentIdProvider.DIST_ADD_DISTSETTYPE);
populateDistSetTypeNameCombo();
descTextArea = new TextAreaBuilder().caption(i18n.get("textfield.description")).style("text-area-style")
.prompt(i18n.get("textfield.description")).immediate(true).id(UIComponentIdProvider.DIST_ADD_DESC)

View File

@@ -202,8 +202,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
@Override
protected void showMetadata(final ClickEvent event) {
final DistributionSet ds = distributionSetManagement
.findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
final DistributionSet ds = distributionSetManagement.findDistributionSetById(getSelectedBaseEntityId());
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
}

View File

@@ -767,7 +767,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
private void showMetadataDetails(final Object itemId) {
final DistributionSetIdName distIdName = (DistributionSetIdName) getContainerDataSource().getItem(itemId)
.getItemProperty(SPUILabelDefinitions.VAR_DIST_ID_NAME).getValue();
final DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(distIdName.getId());
final DistributionSet ds = distributionSetManagement.findDistributionSetById(distIdName.getId());
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
}