Fixed the issue for metadata not getting updated and also the refresh of
page not displaying the distribution details in deployment and distribution view. Signed-off-by: Gaurav <gaurav.sahay@in.bosch.com>
This commit is contained in:
@@ -222,7 +222,6 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
|
||||
populateLog();
|
||||
populateDescription();
|
||||
populateDetailsWidget();
|
||||
populateMetadataDetails();
|
||||
}
|
||||
|
||||
protected void populateLog() {
|
||||
|
||||
@@ -40,38 +40,36 @@ import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
@SpringComponent
|
||||
@VaadinSessionScope
|
||||
public class DistributionSetMetadatadetailslayout extends Table{
|
||||
|
||||
public class DistributionSetMetadatadetailslayout extends Table {
|
||||
|
||||
private static final long serialVersionUID = 2913758299611837718L;
|
||||
|
||||
|
||||
private DistributionSetManagement distributionSetManagement;
|
||||
|
||||
|
||||
private DistributionSetManagement distributionSetManagement;
|
||||
|
||||
private DsMetadataPopupLayout dsMetadataPopupLayout;
|
||||
|
||||
private static final String METADATA_KEY = "Key";
|
||||
|
||||
private static final String VIEW ="view";
|
||||
|
||||
private static final String VIEW = "view";
|
||||
|
||||
private SpPermissionChecker permissionChecker;
|
||||
|
||||
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
private I18N i18n;
|
||||
|
||||
private Long selectedDistSetId;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i18n
|
||||
* @param permissionChecker
|
||||
* @param distributionSetManagement
|
||||
* @param dsMetadataPopupLayout
|
||||
*/
|
||||
|
||||
private Long selectedDistSetId;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i18n
|
||||
* @param permissionChecker
|
||||
* @param distributionSetManagement
|
||||
* @param dsMetadataPopupLayout
|
||||
*/
|
||||
public void init(final I18N i18n, final SpPermissionChecker permissionChecker,
|
||||
final DistributionSetManagement distributionSetManagement,
|
||||
final DsMetadataPopupLayout dsMetadataPopupLayout,
|
||||
final EntityFactory entityFactory) {
|
||||
final DistributionSetManagement distributionSetManagement,
|
||||
final DsMetadataPopupLayout dsMetadataPopupLayout, final EntityFactory entityFactory) {
|
||||
this.i18n = i18n;
|
||||
this.permissionChecker = permissionChecker;
|
||||
this.distributionSetManagement = distributionSetManagement;
|
||||
@@ -80,7 +78,6 @@ public class DistributionSetMetadatadetailslayout extends Table{
|
||||
createDSMetadataTable();
|
||||
addCustomGeneratedColumns();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Populate software module metadata.
|
||||
@@ -90,35 +87,15 @@ public class DistributionSetMetadatadetailslayout extends Table{
|
||||
public void populateDSMetadata(final DistributionSet distributionSet) {
|
||||
removeAllItems();
|
||||
if (null == distributionSet) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
selectedDistSetId = distributionSet.getId();
|
||||
final List<DistributionSetMetadata> dsMetadataList = distributionSet.getMetadata();
|
||||
final List<DistributionSetMetadata> dsMetadataList = distributionSetManagement
|
||||
.findDistributionSetMetadataByDistributionSetId(selectedDistSetId);
|
||||
if (null != dsMetadataList && !dsMetadataList.isEmpty()) {
|
||||
dsMetadataList.forEach(dsMetadata -> setDSMetadataProperties(dsMetadata));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
|
||||
private void createDSMetadataTable() {
|
||||
@@ -131,9 +108,9 @@ public class DistributionSetMetadatadetailslayout extends Table{
|
||||
setContainerDataSource(getDistSetContainer());
|
||||
setColumnHeaderMode(ColumnHeaderMode.EXPLICIT);
|
||||
addDSMetadataTableHeader();
|
||||
setSizeFull();
|
||||
//same as height of other tabs in details tabsheet
|
||||
setHeight(116,Unit.PIXELS);
|
||||
setSizeFull();
|
||||
// same as height of other tabs in details tabsheet
|
||||
setHeight(116, Unit.PIXELS);
|
||||
}
|
||||
|
||||
private IndexedContainer getDistSetContainer() {
|
||||
@@ -141,7 +118,7 @@ public class DistributionSetMetadatadetailslayout extends Table{
|
||||
container.addContainerProperty(METADATA_KEY, String.class, "");
|
||||
setColumnExpandRatio(METADATA_KEY, 0.7f);
|
||||
setColumnAlignment(METADATA_KEY, Align.LEFT);
|
||||
|
||||
|
||||
if (permissionChecker.hasUpdateDistributionPermission()) {
|
||||
container.addContainerProperty(VIEW, Label.class, "");
|
||||
setColumnExpandRatio(VIEW, 0.2F);
|
||||
@@ -154,39 +131,36 @@ public class DistributionSetMetadatadetailslayout extends Table{
|
||||
setColumnHeader(METADATA_KEY, i18n.get("header.key"));
|
||||
}
|
||||
|
||||
|
||||
private void setDSMetadataProperties(final DistributionSetMetadata dsMetadata){
|
||||
private void setDSMetadataProperties(final DistributionSetMetadata dsMetadata) {
|
||||
final Item item = getContainerDataSource().addItem(dsMetadata.getKey());
|
||||
item.getItemProperty(METADATA_KEY).setValue(dsMetadata.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 viewIcon = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey, "View "
|
||||
+ metadataKey + " Metadata details", null, false, null, SPUIButtonStyleSmallNoBorder.class);
|
||||
final Button viewIcon = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey,
|
||||
"View " + metadataKey + " Metadata details", null, false, null, SPUIButtonStyleSmallNoBorder.class);
|
||||
viewIcon.setData(metadataKey);
|
||||
viewIcon.addStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_LINK + " " + "on-focus-no-border link"
|
||||
+ " " + "text-style");
|
||||
viewIcon.addClickListener(event -> showMetadataDetails(selectedDistSetId, metadataKey));
|
||||
return viewIcon;
|
||||
}
|
||||
|
||||
|
||||
private static String getDetailLinkId(final String name) {
|
||||
return new StringBuilder(SPUIComponentIdProvider.DS_METADATA_DETAIL_LINK).append('.').append(name)
|
||||
.toString();
|
||||
return new StringBuilder(SPUIComponentIdProvider.DS_METADATA_DETAIL_LINK).append('.').append(name).toString();
|
||||
}
|
||||
|
||||
private void showMetadataDetails(final Long selectedDistSetId , final String metadataKey) {
|
||||
DistributionSet distSet = distributionSetManagement.findDistributionSetById(selectedDistSetId);
|
||||
|
||||
|
||||
private void showMetadataDetails(final Long selectedDistSetId, final String metadataKey) {
|
||||
final DistributionSet distSet = distributionSetManagement.findDistributionSetById(selectedDistSetId);
|
||||
|
||||
/* display the window */
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(distSet,
|
||||
entityFactory.generateDistributionSetMetadata(distSet, metadataKey, "") ));
|
||||
entityFactory.generateDistributionSetMetadata(distSet, metadataKey, "")));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class SoftwareModuleMetadatadetailslayout extends Table {
|
||||
return;
|
||||
}
|
||||
selectedSWModuleId = swModule.getId();
|
||||
final List<SoftwareModuleMetadata> swMetadataList = swModule.getMetadata();
|
||||
final List<SoftwareModuleMetadata> swMetadataList = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(selectedSWModuleId);
|
||||
if (null != swMetadataList && !swMetadataList.isEmpty()) {
|
||||
swMetadataList.forEach(swMetadata -> setSWMetadataProperties(swMetadata));
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public class SoftwareModuleMetadatadetailslayout extends Table {
|
||||
}
|
||||
|
||||
private void showMetadataDetails(final Long selectedSWModuleId, final String metadataKey) {
|
||||
SoftwareModule swmodule = softwareManagement.findSoftwareModuleById(selectedSWModuleId);
|
||||
final SoftwareModule swmodule = softwareManagement.findSoftwareModuleById(selectedSWModuleId);
|
||||
/* display the window */
|
||||
UI.getCurrent().addWindow(
|
||||
swMetadataPopupLayout.getWindow(swmodule,
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
|
||||
@@ -29,7 +28,6 @@ import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsTable;
|
||||
import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.SoftwareModuleAssignmentDiscardEvent;
|
||||
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
|
||||
@@ -68,7 +66,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
private static final String SOFT_MODULE = "softwareModule";
|
||||
|
||||
private static final String UNASSIGN_SOFT_MODULE = "unassignSoftModule";
|
||||
|
||||
|
||||
@Autowired
|
||||
private ManageDistUIState manageDistUIState;
|
||||
|
||||
@@ -83,37 +81,20 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
|
||||
@Autowired
|
||||
private transient DistributionSetManagement distributionSetManagement;
|
||||
|
||||
|
||||
@Autowired
|
||||
private DsMetadataPopupLayout dsMetadataPopupLayout;
|
||||
|
||||
|
||||
@Autowired
|
||||
private EntityFactory entityFactory;
|
||||
|
||||
private SoftwareModuleDetailsTable softwareModuleTable;
|
||||
|
||||
|
||||
private DistributionSetMetadatadetailslayout dsMetadataTable;
|
||||
|
||||
private VerticalLayout tagsLayout;
|
||||
|
||||
|
||||
private final Map<String, StringBuilder> assignedSWModule = new HashMap<>();
|
||||
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final MetadataEvent event) {
|
||||
UI.getCurrent()
|
||||
.access(() -> {
|
||||
DistributionSetMetadata dsMetadata = event.getDistributionSetMetadata();
|
||||
if (dsMetadata != null && isDistributionSetSelected(dsMetadata.getDistributionSet())) {
|
||||
if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_DISTRIBUTION_SET_METADATA) {
|
||||
dsMetadataTable.createMetadata(event.getDistributionSetMetadata().getKey());
|
||||
} else if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_DISTRIBUTION_SET_METADATA) {
|
||||
dsMetadataTable.deleteMetadata(event.getDistributionSetMetadata().getKey());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* softwareLayout Initialize the component.
|
||||
@@ -124,8 +105,8 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
softwareModuleTable.init(getI18n(), true, getPermissionChecker(), distributionSetManagement, getEventBus(),
|
||||
manageDistUIState);
|
||||
dsMetadataTable = new DistributionSetMetadatadetailslayout();
|
||||
dsMetadataTable.init(getI18n(), getPermissionChecker(),distributionSetManagement,
|
||||
dsMetadataPopupLayout,entityFactory);
|
||||
dsMetadataTable.init(getI18n(), getPermissionChecker(), distributionSetManagement, dsMetadataPopupLayout,
|
||||
entityFactory);
|
||||
super.init();
|
||||
}
|
||||
|
||||
@@ -141,7 +122,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
populateTags();
|
||||
populateMetadataDetails();
|
||||
}
|
||||
|
||||
|
||||
private void populateModule() {
|
||||
softwareModuleTable.populateModule(getSelectedBaseEntity());
|
||||
showUnsavedAssignment();
|
||||
@@ -271,12 +252,12 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
updateDistributionSetDetailsLayout(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void populateMetadataDetails(){
|
||||
protected void populateMetadataDetails() {
|
||||
dsMetadataTable.populateDSMetadata(getSelectedBaseEntity());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateDistributionSetDetailsLayout(final String type, final Boolean isMigrationRequired) {
|
||||
final VerticalLayout detailsTabLayout = getDetailsLayout();
|
||||
detailsTabLayout.removeAllComponents();
|
||||
@@ -403,26 +384,26 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
protected Boolean isMetadataIconToBeDisplayed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getShowMetadataButtonId() {
|
||||
DistributionSetIdName lastselectedDistDS = manageDistUIState.getLastSelectedDistribution().isPresent() ? manageDistUIState
|
||||
.getLastSelectedDistribution().get() : null;
|
||||
final DistributionSetIdName lastselectedDistDS = manageDistUIState.getLastSelectedDistribution().isPresent()
|
||||
? manageDistUIState.getLastSelectedDistribution().get() : null;
|
||||
return SPUIComponentIdProvider.DS_TABLE_MANAGE_METADATA_ID + "." + lastselectedDistDS.getName() + "."
|
||||
+ lastselectedDistDS.getVersion();
|
||||
}
|
||||
|
||||
private boolean isDistributionSetSelected(DistributionSet ds) {
|
||||
DistributionSetIdName lastselectedDistDS = manageDistUIState.getLastSelectedDistribution().isPresent() ? manageDistUIState
|
||||
.getLastSelectedDistribution().get() : null;
|
||||
|
||||
private boolean isDistributionSetSelected(final DistributionSet ds) {
|
||||
final DistributionSetIdName lastselectedDistDS = manageDistUIState.getLastSelectedDistribution().isPresent()
|
||||
? manageDistUIState.getLastSelectedDistribution().get() : null;
|
||||
return ds != null && lastselectedDistDS != null && lastselectedDistDS.getName().equals(ds.getName())
|
||||
&& lastselectedDistDS.getVersion().endsWith(ds.getVersion());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void showMetadata(ClickEvent event) {
|
||||
DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds,null));
|
||||
protected void showMetadata(final ClickEvent event) {
|
||||
final DistributionSet ds = distributionSetManagement
|
||||
.findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent.MetadataUIEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
@@ -42,19 +40,19 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
|
||||
protected SpPermissionChecker permChecker;
|
||||
|
||||
@Override
|
||||
protected void checkForDuplicate(DistributionSet entity, String value) {
|
||||
protected void checkForDuplicate(final DistributionSet entity, final String value) {
|
||||
distributionSetManagement.findOne(entity, value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create metadata for DistributionSet.
|
||||
*/
|
||||
@Override
|
||||
protected DistributionSetMetadata createMetadata(DistributionSet entity, String key, String value) {
|
||||
DistributionSetMetadata dsMetaData = distributionSetManagement.createDistributionSetMetadata(entityFactory
|
||||
.generateDistributionSetMetadata(entity, key, value));
|
||||
protected DistributionSetMetadata createMetadata(final DistributionSet entity, final String key,
|
||||
final String value) {
|
||||
final DistributionSetMetadata dsMetaData = distributionSetManagement
|
||||
.createDistributionSetMetadata(entityFactory.generateDistributionSetMetadata(entity, key, value));
|
||||
setSelectedEntity(dsMetaData.getDistributionSet());
|
||||
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.CREATE_DISTRIBUTION_SET_METADATA, dsMetaData));
|
||||
return dsMetaData;
|
||||
}
|
||||
|
||||
@@ -62,9 +60,10 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
|
||||
* Update metadata for DistributionSet.
|
||||
*/
|
||||
@Override
|
||||
protected DistributionSetMetadata updateMetadata(DistributionSet entity, String key, String value) {
|
||||
DistributionSetMetadata dsMetaData = distributionSetManagement.updateDistributionSetMetadata(entityFactory
|
||||
.generateDistributionSetMetadata(entity, key, value));
|
||||
protected DistributionSetMetadata updateMetadata(final DistributionSet entity, final String key,
|
||||
final String value) {
|
||||
final DistributionSetMetadata dsMetaData = distributionSetManagement
|
||||
.updateDistributionSetMetadata(entityFactory.generateDistributionSetMetadata(entity, key, value));
|
||||
setSelectedEntity(dsMetaData.getDistributionSet());
|
||||
return dsMetaData;
|
||||
}
|
||||
@@ -73,23 +72,22 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
|
||||
protected List<DistributionSetMetadata> getMetadataList() {
|
||||
return getSelectedEntity().getMetadata();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update metadata for DistributionSet.
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected void deleteMetadata(DistributionSet entity, String key, String value) {
|
||||
DistributionSetMetadata dsMetaData = entityFactory.generateDistributionSetMetadata(entity, key, value);
|
||||
protected void deleteMetadata(final DistributionSet entity, final String key, final String value) {
|
||||
final DistributionSetMetadata dsMetaData = entityFactory.generateDistributionSetMetadata(entity, key, value);
|
||||
distributionSetManagement.deleteDistributionSetMetadata(entity, key);
|
||||
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.DELETE_DISTRIBUTION_SET_METADATA, dsMetaData));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean hasCreatePermission() {
|
||||
return permChecker.hasCreateDistributionPermission();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean hasUpdatePermission() {
|
||||
return permChecker.hasUpdateDistributionPermission();
|
||||
|
||||
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.distributions.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
|
||||
/**
|
||||
*
|
||||
* Metadata Events.
|
||||
@@ -18,21 +19,21 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
public class MetadataEvent {
|
||||
|
||||
public enum MetadataUIEvent {
|
||||
CREATE_DISTRIBUTION_SET_METADATA, DELETE_DISTRIBUTION_SET_METADATA, DELETE_SOFTWARE_MODULE_METADATA, CREATE_SOFTWARE_MODULE_METADATA;
|
||||
DELETE_SOFTWARE_MODULE_METADATA, CREATE_SOFTWARE_MODULE_METADATA;
|
||||
}
|
||||
|
||||
private MetadataUIEvent metadataUIEvent;
|
||||
private final MetadataUIEvent metadataUIEvent;
|
||||
|
||||
private DistributionSetMetadata distributionSetMetadata;
|
||||
|
||||
private SoftwareModuleMetadata softwareModuleMetadata;
|
||||
|
||||
public MetadataEvent(MetadataUIEvent metadataUIEvent, final DistributionSetMetadata distributionSetMetadata) {
|
||||
public MetadataEvent(final MetadataUIEvent metadataUIEvent, final DistributionSetMetadata distributionSetMetadata) {
|
||||
this.metadataUIEvent = metadataUIEvent;
|
||||
this.distributionSetMetadata = distributionSetMetadata;
|
||||
}
|
||||
|
||||
public MetadataEvent(MetadataUIEvent metadataUIEvent, final SoftwareModuleMetadata softwareModuleMetadata) {
|
||||
public MetadataEvent(final MetadataUIEvent metadataUIEvent, final SoftwareModuleMetadata softwareModuleMetadata) {
|
||||
this.metadataUIEvent = metadataUIEvent;
|
||||
this.softwareModuleMetadata = softwareModuleMetadata;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
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.SpringContextHelper;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -84,10 +85,6 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
||||
|
||||
@Autowired
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
@Autowired
|
||||
private transient DistributionSetTable distributionSetTable;
|
||||
|
||||
private TextField distNameTextField;
|
||||
private TextField distVersionTextField;
|
||||
private TextArea descTextArea;
|
||||
@@ -239,9 +236,10 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
||||
|
||||
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()));
|
||||
s.add(new DistributionSetIdName(newDist.getId(), newDist.getName(), newDist.getVersion()));
|
||||
final DistributionSetTable distributionSetTable = SpringContextHelper.getBean(DistributionSetTable.class);
|
||||
distributionSetTable.setValue(s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.ui.management.dstable;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.DistributionSetMetadatadetailslayout;
|
||||
@@ -19,7 +18,6 @@ import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsTable;
|
||||
import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.distributions.dstable.DsMetadataPopupLayout;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
|
||||
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
|
||||
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
@@ -53,48 +51,32 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
|
||||
|
||||
@Autowired
|
||||
private DistributionTagToken distributionTagToken;
|
||||
|
||||
|
||||
@Autowired
|
||||
private transient DistributionSetManagement distributionSetManagement;
|
||||
|
||||
private transient DistributionSetManagement distributionSetManagement;
|
||||
|
||||
@Autowired
|
||||
private DsMetadataPopupLayout dsMetadataPopupLayout;
|
||||
|
||||
|
||||
@Autowired
|
||||
private EntityFactory entityFactory;
|
||||
|
||||
private SoftwareModuleDetailsTable softwareModuleTable;
|
||||
|
||||
private DistributionSetMetadatadetailslayout dsMetadataTable;
|
||||
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
softwareModuleTable = new SoftwareModuleDetailsTable();
|
||||
softwareModuleTable.init(getI18n(), false, getPermissionChecker(), null, null, null);
|
||||
|
||||
|
||||
dsMetadataTable = new DistributionSetMetadatadetailslayout();
|
||||
dsMetadataTable.init(getI18n(), getPermissionChecker(),distributionSetManagement,
|
||||
dsMetadataPopupLayout,entityFactory);
|
||||
|
||||
dsMetadataTable.init(getI18n(), getPermissionChecker(), distributionSetManagement, dsMetadataPopupLayout,
|
||||
entityFactory);
|
||||
|
||||
super.init();
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final MetadataEvent event) {
|
||||
UI.getCurrent()
|
||||
.access(() -> {
|
||||
DistributionSetMetadata dsMetadata = event.getDistributionSetMetadata();
|
||||
if (dsMetadata != null && isDistributionSetSelected(dsMetadata.getDistributionSet())) {
|
||||
if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_DISTRIBUTION_SET_METADATA) {
|
||||
dsMetadataTable.createMetadata(event.getDistributionSetMetadata().getKey());
|
||||
} else if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_DISTRIBUTION_SET_METADATA) {
|
||||
dsMetadataTable.deleteMetadata(event.getDistributionSetMetadata().getKey());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final DistributionTableEvent distributionTableEvent) {
|
||||
onBaseEntityEvent(distributionTableEvent);
|
||||
@@ -156,12 +138,11 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
|
||||
populateMetadataDetails();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void populateMetadataDetails(){
|
||||
protected void populateMetadataDetails() {
|
||||
dsMetadataTable.populateDSMetadata(getSelectedBaseEntity());
|
||||
}
|
||||
}
|
||||
|
||||
private void populateDetails(final DistributionSet ds) {
|
||||
if (ds != null) {
|
||||
@@ -206,30 +187,32 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
|
||||
protected String getDetailsHeaderCaptionId() {
|
||||
return SPUIComponentIdProvider.DISTRIBUTION_DETAILS_HEADER_LABEL_ID;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Boolean isMetadataIconToBeDisplayed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getShowMetadataButtonId() {
|
||||
DistributionSetIdName lastselectedDistDS = managementUIState.getLastSelectedDistribution().isPresent() ? managementUIState
|
||||
.getLastSelectedDistribution().get() : null;
|
||||
final DistributionSetIdName lastselectedDistDS = managementUIState.getLastSelectedDistribution().isPresent()
|
||||
? managementUIState.getLastSelectedDistribution().get() : null;
|
||||
return SPUIComponentIdProvider.DS_TABLE_MANAGE_METADATA_ID + "." + lastselectedDistDS.getName() + "."
|
||||
+ lastselectedDistDS.getVersion();
|
||||
}
|
||||
private boolean isDistributionSetSelected(DistributionSet ds) {
|
||||
DistributionSetIdName lastselectedManageDS = managementUIState.getLastSelectedDistribution().isPresent() ? managementUIState
|
||||
.getLastSelectedDistribution().get() : null;
|
||||
return ds!=null && lastselectedManageDS != null && lastselectedManageDS.getName().equals(ds.getName())
|
||||
|
||||
private boolean isDistributionSetSelected(final DistributionSet ds) {
|
||||
final DistributionSetIdName lastselectedManageDS = managementUIState.getLastSelectedDistribution().isPresent()
|
||||
? managementUIState.getLastSelectedDistribution().get() : null;
|
||||
return ds != null && lastselectedManageDS != null && lastselectedManageDS.getName().equals(ds.getName())
|
||||
&& lastselectedManageDS.getVersion().endsWith(ds.getVersion());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showMetadata(ClickEvent event) {
|
||||
DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds,null));
|
||||
protected void showMetadata(final ClickEvent event) {
|
||||
final DistributionSet ds = distributionSetManagement
|
||||
.findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user