Remove unnecessary DB calls from UI
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -63,7 +63,8 @@ public interface TargetManagement {
|
|||||||
*
|
*
|
||||||
* @return number of found {@link Target}s.
|
* @return number of found {@link Target}s.
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||||
|
+ SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Long countTargetByAssignedDistributionSet(@NotNull Long distId);
|
Long countTargetByAssignedDistributionSet(@NotNull Long distId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +105,8 @@ public interface TargetManagement {
|
|||||||
* to search for
|
* to search for
|
||||||
* @return number of found {@link Target}s.
|
* @return number of found {@link Target}s.
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||||
|
+ SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Long countTargetByInstalledDistributionSet(@NotNull Long distId);
|
Long countTargetByInstalledDistributionSet(@NotNull Long distId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ package org.eclipse.hawkbit.repository.model;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link DistributionSet} defines a meta package that combines a set of
|
* A {@link DistributionSet} defines a meta package that combines a set of
|
||||||
* {@link SoftwareModule}s which have to be or are provisioned to a
|
* {@link SoftwareModule}s which have to be or are provisioned to a
|
||||||
@@ -36,12 +34,6 @@ public interface DistributionSet extends NamedVersionedEntity {
|
|||||||
*/
|
*/
|
||||||
boolean isDeleted();
|
boolean isDeleted();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return immutable {@link List} of {@link DistributionSetMetadata}
|
|
||||||
* elements. See {@link DistributionSetManagement} to alter.
|
|
||||||
*/
|
|
||||||
List<DistributionSetMetadata> getMetadata();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return <code>true</code> if {@link DistributionSet} contains a mandatory
|
* @return <code>true</code> if {@link DistributionSet} contains a mandatory
|
||||||
* migration step, i.e. unfinished {@link Action}s will kept active
|
* migration step, i.e. unfinished {@link Action}s will kept active
|
||||||
@@ -49,21 +41,11 @@ public interface DistributionSet extends NamedVersionedEntity {
|
|||||||
*/
|
*/
|
||||||
boolean isRequiredMigrationStep();
|
boolean isRequiredMigrationStep();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the assignedTargets
|
|
||||||
*/
|
|
||||||
List<Target> getAssignedTargets();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the auto assign target filters
|
* @return the auto assign target filters
|
||||||
*/
|
*/
|
||||||
List<TargetFilterQuery> getAutoAssignFilters();
|
List<TargetFilterQuery> getAutoAssignFilters();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the installedTargets
|
|
||||||
*/
|
|
||||||
List<TargetInfo> getInstalledTargets();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return unmodifiableSet of {@link SoftwareModule}.
|
* @return unmodifiableSet of {@link SoftwareModule}.
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private JpaDistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) {
|
private JpaDistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) {
|
||||||
final JpaDistributionSet set = (JpaDistributionSet) findDistributionSetByIdWithDetails(setId);
|
final JpaDistributionSet set = (JpaDistributionSet) findDistributionSetById(setId);
|
||||||
|
|
||||||
if (set == null) {
|
if (set == null) {
|
||||||
throw new EntityNotFoundException("Distribution set cannot be updated as it does not exixt" + setId);
|
throw new EntityNotFoundException("Distribution set cannot be updated as it does not exixt" + setId);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public interface TargetTagRepository
|
|||||||
*/
|
*/
|
||||||
@Modifying
|
@Modifying
|
||||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||||
Long deleteByName(final String tagName);
|
Long deleteByName(String tagName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find {@link TargetTag} by its name.
|
* find {@link TargetTag} by its name.
|
||||||
@@ -43,7 +43,7 @@ public interface TargetTagRepository
|
|||||||
* to filter on
|
* to filter on
|
||||||
* @return the {@link TargetTag} if found, otherwise null
|
* @return the {@link TargetTag} if found, otherwise null
|
||||||
*/
|
*/
|
||||||
JpaTargetTag findByNameEquals(final String tagName);
|
JpaTargetTag findByNameEquals(String tagName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all instances of the type.
|
* Returns all instances of the type.
|
||||||
|
|||||||
@@ -209,7 +209,6 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<DistributionSetMetadata> getMetadata() {
|
public List<DistributionSetMetadata> getMetadata() {
|
||||||
if (metadata == null) {
|
if (metadata == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
@@ -241,29 +240,11 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Target> getAssignedTargets() {
|
|
||||||
if (assignedToTargets == null) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.unmodifiableList(assignedToTargets);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TargetFilterQuery> getAutoAssignFilters() {
|
public List<TargetFilterQuery> getAutoAssignFilters() {
|
||||||
return autoAssignFilters;
|
return autoAssignFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<TargetInfo> getInstalledTargets() {
|
|
||||||
if (installedAtTargets == null) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.unmodifiableList(installedAtTargets);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DistributionSet [getName()=" + getName() + ", getOptLockRevision()=" + getOptLockRevision()
|
return "DistributionSet [getName()=" + getName() + ", getOptLockRevision()=" + getOptLockRevision()
|
||||||
|
|||||||
@@ -176,14 +176,6 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SoftwareModuleMetadata> getMetadata() {
|
|
||||||
if (metadata == null) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.unmodifiableList(metadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SoftwareModule [deleted=" + deleted + ", name=" + getName() + ", version=" + getVersion()
|
return "SoftwareModule [deleted=" + deleted + ", name=" + getName() + ", version=" + getVersion()
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ public final class DistributionSetSpecification {
|
|||||||
targetRoot.fetch(JpaDistributionSet_.modules, JoinType.LEFT);
|
targetRoot.fetch(JpaDistributionSet_.modules, JoinType.LEFT);
|
||||||
targetRoot.fetch(JpaDistributionSet_.tags, JoinType.LEFT);
|
targetRoot.fetch(JpaDistributionSet_.tags, JoinType.LEFT);
|
||||||
targetRoot.fetch(JpaDistributionSet_.type, JoinType.LEFT);
|
targetRoot.fetch(JpaDistributionSet_.type, JoinType.LEFT);
|
||||||
targetRoot.fetch(JpaDistributionSet_.metadata, JoinType.LEFT);
|
|
||||||
query.distinct(true);
|
query.distinct(true);
|
||||||
|
|
||||||
return predicate;
|
return predicate;
|
||||||
@@ -110,8 +109,8 @@ public final class DistributionSetSpecification {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link Specification} for retrieving {@link DistributionSet}s by
|
* {@link Specification} for retrieving {@link DistributionSet}s by "like
|
||||||
* "like name or like description or like version".
|
* name or like description or like version".
|
||||||
*
|
*
|
||||||
* @param subString
|
* @param subString
|
||||||
* to be filtered on
|
* to be filtered on
|
||||||
@@ -125,8 +124,8 @@ public final class DistributionSetSpecification {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link Specification} for retrieving {@link DistributionSet}s by
|
* {@link Specification} for retrieving {@link DistributionSet}s by "has at
|
||||||
* "has at least one of the given tag names".
|
* least one of the given tag names".
|
||||||
*
|
*
|
||||||
* @param tagNames
|
* @param tagNames
|
||||||
* to be filtered on
|
* to be filtered on
|
||||||
|
|||||||
@@ -77,8 +77,6 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
|
|||||||
|
|
||||||
private TextArea descTextArea;
|
private TextArea descTextArea;
|
||||||
|
|
||||||
private CommonDialogWindow window;
|
|
||||||
|
|
||||||
private Boolean editSwModule = Boolean.FALSE;
|
private Boolean editSwModule = Boolean.FALSE;
|
||||||
|
|
||||||
private Long baseSwModuleId;
|
private Long baseSwModuleId;
|
||||||
@@ -133,9 +131,9 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
|
|||||||
public CommonDialogWindow createUpdateSoftwareModuleWindow(final Long baseSwModuleId) {
|
public CommonDialogWindow createUpdateSoftwareModuleWindow(final Long baseSwModuleId) {
|
||||||
this.baseSwModuleId = baseSwModuleId;
|
this.baseSwModuleId = baseSwModuleId;
|
||||||
resetComponents();
|
resetComponents();
|
||||||
|
populateTypeNameCombo();
|
||||||
populateValuesOfSwModule();
|
populateValuesOfSwModule();
|
||||||
createWindow();
|
return createWindow();
|
||||||
return window;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createRequiredComponents() {
|
private void createRequiredComponents() {
|
||||||
@@ -157,7 +155,6 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
|
|||||||
typeComboBox.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + " " + ValoTheme.COMBOBOX_TINY);
|
typeComboBox.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + " " + ValoTheme.COMBOBOX_TINY);
|
||||||
typeComboBox.setNewItemsAllowed(Boolean.FALSE);
|
typeComboBox.setNewItemsAllowed(Boolean.FALSE);
|
||||||
typeComboBox.setImmediate(Boolean.TRUE);
|
typeComboBox.setImmediate(Boolean.TRUE);
|
||||||
populateTypeNameCombo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextField createTextField(final String in18Key, final String id) {
|
private TextField createTextField(final String in18Key, final String id) {
|
||||||
@@ -181,7 +178,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
|
|||||||
editSwModule = Boolean.FALSE;
|
editSwModule = Boolean.FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createWindow() {
|
private CommonDialogWindow createWindow() {
|
||||||
final Label madatoryStarLabel = new Label("*");
|
final Label madatoryStarLabel = new Label("*");
|
||||||
madatoryStarLabel.setStyleName("v-caption v-required-field-indicator");
|
madatoryStarLabel.setStyleName("v-caption v-required-field-indicator");
|
||||||
madatoryStarLabel.setWidth(null);
|
madatoryStarLabel.setWidth(null);
|
||||||
@@ -198,7 +195,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
|
|||||||
|
|
||||||
setCompositionRoot(formLayout);
|
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)
|
.caption(i18n.get("upload.caption.add.new.swmodule")).content(this).layout(formLayout).i18n(i18n)
|
||||||
.saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
|
.saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
|
||||||
nameTextField.setEnabled(!editSwModule);
|
nameTextField.setEnabled(!editSwModule);
|
||||||
@@ -206,6 +203,8 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
|
|||||||
typeComboBox.setEnabled(!editSwModule);
|
typeComboBox.setEnabled(!editSwModule);
|
||||||
|
|
||||||
typeComboBox.focus();
|
typeComboBox.focus();
|
||||||
|
|
||||||
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addNewBaseSoftware() {
|
private void addNewBaseSoftware() {
|
||||||
@@ -271,6 +270,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
|
|||||||
: HawkbitCommonUtil.trimAndNullIfEmpty(swModle.getVendor()));
|
: HawkbitCommonUtil.trimAndNullIfEmpty(swModle.getVendor()));
|
||||||
descTextArea.setValue(swModle.getDescription() == null ? HawkbitCommonUtil.SP_STRING_EMPTY
|
descTextArea.setValue(swModle.getDescription() == null ? HawkbitCommonUtil.SP_STRING_EMPTY
|
||||||
: HawkbitCommonUtil.trimAndNullIfEmpty(swModle.getDescription()));
|
: HawkbitCommonUtil.trimAndNullIfEmpty(swModle.getDescription()));
|
||||||
|
|
||||||
if (swModle.getType().isDeleted()) {
|
if (swModle.getType().isDeleted()) {
|
||||||
typeComboBox.addItem(swModle.getType().getName());
|
typeComboBox.addItem(swModle.getType().getName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import java.util.Set;
|
|||||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
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.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
|
||||||
@@ -81,6 +82,9 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
|||||||
@Autowired
|
@Autowired
|
||||||
private transient DistributionSetManagement distributionSetManagement;
|
private transient DistributionSetManagement distributionSetManagement;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private transient TargetManagement targetManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DsMetadataPopupLayout dsMetadataPopupLayout;
|
private DsMetadataPopupLayout dsMetadataPopupLayout;
|
||||||
|
|
||||||
@@ -183,9 +187,8 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
|||||||
private Button assignSoftModuleButton(final String softwareModuleName) {
|
private Button assignSoftModuleButton(final String softwareModuleName) {
|
||||||
if (getPermissionChecker().hasUpdateDistributionPermission()
|
if (getPermissionChecker().hasUpdateDistributionPermission()
|
||||||
&& manageDistUIState.getLastSelectedDistribution().isPresent()
|
&& manageDistUIState.getLastSelectedDistribution().isPresent()
|
||||||
&& distributionSetManagement
|
&& targetManagement.countTargetByAssignedDistributionSet(
|
||||||
.findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId())
|
manageDistUIState.getLastSelectedDistribution().get().getId()) <= 0) {
|
||||||
.getAssignedTargets().isEmpty()) {
|
|
||||||
final Button reassignSoftModule = SPUIComponentProvider.getButton(softwareModuleName, "", "", "", true,
|
final Button reassignSoftModule = SPUIComponentProvider.getButton(softwareModuleName, "", "", "", true,
|
||||||
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
||||||
reassignSoftModule.setEnabled(false);
|
reassignSoftModule.setEnabled(false);
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<MetaData> getMetadataList() {
|
protected List<MetaData> getMetadataList() {
|
||||||
return Collections.unmodifiableList(getSelectedEntity().getMetadata());
|
return Collections.unmodifiableList(
|
||||||
|
distributionSetManagement.findDistributionSetMetadataByDistributionSetId(getSelectedEntity().getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -149,7 +149,6 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
|||||||
distsetTypeNameComboBox.setImmediate(true);
|
distsetTypeNameComboBox.setImmediate(true);
|
||||||
distsetTypeNameComboBox.setNullSelectionAllowed(false);
|
distsetTypeNameComboBox.setNullSelectionAllowed(false);
|
||||||
distsetTypeNameComboBox.setId(UIComponentIdProvider.DIST_ADD_DISTSETTYPE);
|
distsetTypeNameComboBox.setId(UIComponentIdProvider.DIST_ADD_DISTSETTYPE);
|
||||||
populateDistSetTypeNameCombo();
|
|
||||||
|
|
||||||
descTextArea = new TextAreaBuilder().caption(i18n.get("textfield.description")).style("text-area-style")
|
descTextArea = new TextAreaBuilder().caption(i18n.get("textfield.description")).style("text-area-style")
|
||||||
.prompt(i18n.get("textfield.description")).immediate(true).id(UIComponentIdProvider.DIST_ADD_DESC)
|
.prompt(i18n.get("textfield.description")).immediate(true).id(UIComponentIdProvider.DIST_ADD_DESC)
|
||||||
|
|||||||
@@ -202,8 +202,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void showMetadata(final ClickEvent event) {
|
protected void showMetadata(final ClickEvent event) {
|
||||||
final DistributionSet ds = distributionSetManagement
|
final DistributionSet ds = distributionSetManagement.findDistributionSetById(getSelectedBaseEntityId());
|
||||||
.findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
|
|
||||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
|
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -767,7 +767,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
|||||||
private void showMetadataDetails(final Object itemId) {
|
private void showMetadataDetails(final Object itemId) {
|
||||||
final DistributionSetIdName distIdName = (DistributionSetIdName) getContainerDataSource().getItem(itemId)
|
final DistributionSetIdName distIdName = (DistributionSetIdName) getContainerDataSource().getItem(itemId)
|
||||||
.getItemProperty(SPUILabelDefinitions.VAR_DIST_ID_NAME).getValue();
|
.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));
|
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user