improve code quality
Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
@@ -53,42 +53,42 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
|
||||
|
||||
@Autowired
|
||||
private transient SoftwareManagement softwareManagement;
|
||||
|
||||
|
||||
@Autowired
|
||||
private SwMetadataPopupLayout swMetadataPopupLayout;
|
||||
|
||||
|
||||
@Autowired
|
||||
private EntityFactory entityFactory;
|
||||
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
private SoftwareModuleMetadatadetailslayout swmMetadataTable;
|
||||
|
||||
|
||||
/**
|
||||
* softwareLayout Initialize the component.
|
||||
*/
|
||||
@Override
|
||||
protected void init() {
|
||||
swmMetadataTable = new SoftwareModuleMetadatadetailslayout();
|
||||
swmMetadataTable.init(getI18n(), getPermissionChecker(),softwareManagement,swMetadataPopupLayout,entityFactory);
|
||||
swmMetadataTable.init(getI18n(), getPermissionChecker(), softwareManagement, swMetadataPopupLayout,
|
||||
entityFactory);
|
||||
super.init();
|
||||
}
|
||||
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final MetadataEvent event) {
|
||||
UI.getCurrent()
|
||||
.access(() -> {
|
||||
SoftwareModuleMetadata softwareModuleMetadata = event.getSoftwareModuleMetadata();
|
||||
if (softwareModuleMetadata != null
|
||||
&& isSoftwareModuleSelected(softwareModuleMetadata.getSoftwareModule())) {
|
||||
if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_SOFTWARE_MODULE_METADATA) {
|
||||
swmMetadataTable.createMetadata(event.getSoftwareModuleMetadata().getKey());
|
||||
} else if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_SOFTWARE_MODULE_METADATA) {
|
||||
swmMetadataTable.deleteMetadata(event.getSoftwareModuleMetadata().getKey());
|
||||
}
|
||||
}
|
||||
});
|
||||
UI.getCurrent().access(() -> {
|
||||
final SoftwareModuleMetadata softwareModuleMetadata = event.getSoftwareModuleMetadata();
|
||||
if (softwareModuleMetadata != null
|
||||
&& isSoftwareModuleSelected(softwareModuleMetadata.getSoftwareModule())) {
|
||||
if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_SOFTWARE_MODULE_METADATA) {
|
||||
swmMetadataTable.createMetadata(event.getSoftwareModuleMetadata().getKey());
|
||||
} else if (event
|
||||
.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_SOFTWARE_MODULE_METADATA) {
|
||||
swmMetadataTable.deleteMetadata(event.getSoftwareModuleMetadata().getKey());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected String getEditButtonId() {
|
||||
return SPUIComponentIdProvider.UPLOAD_SW_MODULE_EDIT_BUTTON;
|
||||
@@ -101,7 +101,7 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
|
||||
detailsTab.addTab(createLogLayout(), getI18n().get("caption.logs.tab"), null);
|
||||
detailsTab.addTab(swmMetadataTable, getI18n().get("caption.metadata"), null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onEdit(final ClickEvent event) {
|
||||
final Window addSoftwareModule = softwareModuleAddUpdateWindow
|
||||
@@ -126,7 +126,7 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
|
||||
updateSoftwareModuleDetailsLayout(HawkbitCommonUtil.SP_STRING_EMPTY, HawkbitCommonUtil.SP_STRING_EMPTY,
|
||||
maxAssign);
|
||||
}
|
||||
|
||||
|
||||
populateMetadataDetails();
|
||||
}
|
||||
|
||||
@@ -188,38 +188,30 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
|
||||
protected String getDetailsHeaderCaptionId() {
|
||||
return SPUIComponentIdProvider.TARGET_DETAILS_HEADER_LABEL_ID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void populateMetadataDetails(){
|
||||
protected void populateMetadataDetails() {
|
||||
swmMetadataTable.populateSMMetadata(getSelectedBaseEntity());
|
||||
}
|
||||
|
||||
private boolean isSoftwareModuleSelected(SoftwareModule softwareModule) {
|
||||
final SoftwareModule selectedUploadSWModule = artifactUploadState.getSelectedBaseSoftwareModule().isPresent() ? artifactUploadState
|
||||
.getSelectedBaseSoftwareModule().get() : null;
|
||||
}
|
||||
|
||||
private boolean isSoftwareModuleSelected(final SoftwareModule softwareModule) {
|
||||
final SoftwareModule selectedUploadSWModule = artifactUploadState.getSelectedBaseSoftwareModule().isPresent()
|
||||
? artifactUploadState.getSelectedBaseSoftwareModule().get() : null;
|
||||
return softwareModule != null && selectedUploadSWModule != null
|
||||
&& selectedUploadSWModule.getName().equals(softwareModule.getName())
|
||||
&& selectedUploadSWModule.getVersion().equals(softwareModule.getVersion());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Boolean isMetadataIconToBeDisplayed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getShowMetadataButtonId() {
|
||||
SoftwareModule selectedBaseEntity = getSelectedBaseEntity();
|
||||
return SPUIComponentIdProvider.SW_TABLE_MANAGE_METADATA_ID + "." + selectedBaseEntity.getName() + "."
|
||||
+ selectedBaseEntity.getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showMetadata(ClickEvent event) {
|
||||
SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(getSelectedBaseEntityId());
|
||||
/* display the window */
|
||||
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule,null));
|
||||
protected void showMetadata(final ClickEvent event) {
|
||||
final SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(getSelectedBaseEntityId());
|
||||
/* display the window */
|
||||
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule, null));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
|
||||
import com.vaadin.ui.Alignment;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.Button.ClickEvent;
|
||||
import com.vaadin.ui.CustomComponent;
|
||||
import com.vaadin.ui.Grid;
|
||||
import com.vaadin.ui.Grid.SelectionMode;
|
||||
@@ -98,7 +97,7 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
|
||||
private HorizontalLayout mainLayout;
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
void init() {
|
||||
createComponents();
|
||||
buildLayout();
|
||||
|
||||
@@ -170,7 +169,6 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
|
||||
headerLayout.setComponentAlignment(addIcon, Alignment.MIDDLE_RIGHT);
|
||||
}
|
||||
headerLayout.setExpandRatio(headerCaption, 1.0F);
|
||||
|
||||
|
||||
final HorizontalLayout headerWrapperLayout = new HorizontalLayout();
|
||||
headerWrapperLayout.addStyleName("bordered-layout" + " " + "no-border-bottom" + " " + "metadata-table-margin");
|
||||
@@ -257,50 +255,56 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
|
||||
i18n.get("caption.metadata.delete.action.confirmbox"), i18n.get("message.confirm.delete.metadata", key),
|
||||
i18n.get("button.ok"), i18n.get("button.cancel"), ok -> {
|
||||
if (ok) {
|
||||
deleteMetadata(getSelectedEntity(), key, value);
|
||||
uiNotification.displaySuccess(i18n.get("message.metadata.deleted.successfully", key));
|
||||
final Object selectedRow = metaDataGrid.getSelectedRow();
|
||||
metaDataGrid.getContainerDataSource().removeItem(event.getItemId());
|
||||
// force grid to refresh
|
||||
metaDataGrid.clearSortOrder();
|
||||
if (!metaDataGrid.getContainerDataSource().getItemIds().isEmpty()) {
|
||||
if (selectedRow != null) {
|
||||
if (selectedRow.equals(event.getItemId())) {
|
||||
metaDataGrid.select(metaDataGrid.getContainerDataSource().getIdByIndex(0));
|
||||
} else {
|
||||
metaDataGrid.select(selectedRow);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
keyTextField.clear();
|
||||
valueTextArea.clear();
|
||||
metaDataGrid.select(null);
|
||||
if (hasCreatePermission()) {
|
||||
keyTextField.setEnabled(true);
|
||||
valueTextArea.setEnabled(true);
|
||||
addIcon.setEnabled(false);
|
||||
}
|
||||
}
|
||||
handleOkDeleteMetadata(event, key, value);
|
||||
}
|
||||
});
|
||||
UI.getCurrent().addWindow(confirmDialog.getWindow());
|
||||
confirmDialog.getWindow().bringToFront();
|
||||
}
|
||||
|
||||
private void handleOkDeleteMetadata(final RendererClickEvent event, final String key, final String value) {
|
||||
deleteMetadata(getSelectedEntity(), key, value);
|
||||
uiNotification.displaySuccess(i18n.get("message.metadata.deleted.successfully", key));
|
||||
final Object selectedRow = metaDataGrid.getSelectedRow();
|
||||
metaDataGrid.getContainerDataSource().removeItem(event.getItemId());
|
||||
// force grid to refresh
|
||||
metaDataGrid.clearSortOrder();
|
||||
if (!metaDataGrid.getContainerDataSource().getItemIds().isEmpty()) {
|
||||
if (selectedRow != null) {
|
||||
if (selectedRow.equals(event.getItemId())) {
|
||||
metaDataGrid.select(metaDataGrid.getContainerDataSource().getIdByIndex(0));
|
||||
} else {
|
||||
metaDataGrid.select(selectedRow);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
clearTextFields();
|
||||
}
|
||||
}
|
||||
|
||||
private void clearTextFields() {
|
||||
keyTextField.clear();
|
||||
valueTextArea.clear();
|
||||
metaDataGrid.select(null);
|
||||
if (hasCreatePermission()) {
|
||||
keyTextField.setEnabled(true);
|
||||
valueTextArea.setEnabled(true);
|
||||
addIcon.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
private Button createAddIcon() {
|
||||
addIcon = SPUIComponentProvider.getButton(SPUIComponentIdProvider.METADTA_ADD_ICON_ID, i18n.get("button.save"),
|
||||
null, null, false, FontAwesome.PLUS, SPUIButtonStyleSmallNoBorder.class);
|
||||
addIcon.addClickListener(event -> onAdd(event));
|
||||
addIcon.addClickListener(event -> onAdd());
|
||||
return addIcon;
|
||||
}
|
||||
|
||||
private Label createHeaderCaption() {
|
||||
final Label captionLabel = SPUIComponentProvider.getLabel(i18n.get("caption.metadata"),
|
||||
SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
||||
return captionLabel;
|
||||
return SPUIComponentProvider.getLabel(i18n.get("caption.metadata"), SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
||||
}
|
||||
|
||||
private IndexedContainer getMetadataContainer() {
|
||||
private static IndexedContainer getMetadataContainer() {
|
||||
final IndexedContainer swcontactContainer = new IndexedContainer();
|
||||
swcontactContainer.addContainerProperty(KEY, String.class, "");
|
||||
swcontactContainer.addContainerProperty(VALUE, String.class, "");
|
||||
@@ -340,7 +344,7 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
|
||||
item.getItemProperty(VALUE).setValue(valueTextArea.getValue());
|
||||
}
|
||||
|
||||
private void onAdd(final ClickEvent event) {
|
||||
private void onAdd() {
|
||||
metaDataGrid.deselect(metaDataGrid.getSelectedRow());
|
||||
valueTextArea.clear();
|
||||
keyTextField.clear();
|
||||
@@ -393,7 +397,8 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
|
||||
private boolean duplicateCheck(final E entity) {
|
||||
try {
|
||||
checkForDuplicate(entity, keyTextField.getValue());
|
||||
} catch (final EntityNotFoundException exception) {
|
||||
// we do not want to log the exception here, does not make sense
|
||||
} catch (@SuppressWarnings("squid:S1166") final EntityNotFoundException exception) {
|
||||
return false;
|
||||
}
|
||||
uiNotification.displayValidationError(i18n.get("message.metadata.duplicate.check", keyTextField.getValue()));
|
||||
@@ -484,4 +489,4 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
|
||||
addIcon.setEnabled(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class CommonDialogWindow extends Window implements Serializable {
|
||||
|
||||
private final ClickListener cancelButtonClickListener;
|
||||
|
||||
private final ClickListener close = event -> close();
|
||||
private final ClickListener closeClickListener = event -> close();
|
||||
|
||||
private final transient Map<Component, Object> orginalValues;
|
||||
|
||||
@@ -115,6 +115,10 @@ public class CommonDialogWindow extends Window implements Serializable {
|
||||
* the saveButtonClickListener
|
||||
* @param cancelButtonClickListener
|
||||
* the cancelButtonClickListener
|
||||
* @param layout
|
||||
* the abstract layout
|
||||
* @param i18n
|
||||
* the i18n service
|
||||
*/
|
||||
public CommonDialogWindow(final String caption, final Component content, final String helpLink,
|
||||
final ClickListener saveButtonClickListener, final ClickListener cancelButtonClickListener,
|
||||
@@ -233,11 +237,11 @@ public class CommonDialogWindow extends Window implements Serializable {
|
||||
}
|
||||
|
||||
protected void addCloseListenerForSaveButton() {
|
||||
saveButton.addClickListener(close);
|
||||
saveButton.addClickListener(closeClickListener);
|
||||
}
|
||||
|
||||
protected void addCloseListenerForCancelButton() {
|
||||
cancelButton.addClickListener(close);
|
||||
cancelButton.addClickListener(closeClickListener);
|
||||
}
|
||||
|
||||
protected void addComponenetListeners() {
|
||||
@@ -275,7 +279,8 @@ public class CommonDialogWindow extends Window implements Serializable {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isValueEquals(final AbstractField<?> field, final Object orginalValue, final Object currentValue) {
|
||||
private static boolean isValueEquals(final AbstractField<?> field, final Object orginalValue,
|
||||
final Object currentValue) {
|
||||
if (Set.class.equals(field.getType())) {
|
||||
return CollectionUtils.isEqualCollection(CollectionUtils.emptyIfNull((Collection<?>) orginalValue),
|
||||
CollectionUtils.emptyIfNull((Collection<?>) currentValue));
|
||||
@@ -289,7 +294,7 @@ public class CommonDialogWindow extends Window implements Serializable {
|
||||
return Objects.equals(orginalValue, currentValue);
|
||||
}
|
||||
|
||||
private Object getCurrentVaue(final Component currentChangedComponent, final Object newValue,
|
||||
private static Object getCurrentVaue(final Component currentChangedComponent, final Object newValue,
|
||||
final AbstractField<?> field) {
|
||||
Object currentValue = field.getValue();
|
||||
if (field instanceof Table) {
|
||||
@@ -365,7 +370,7 @@ public class CommonDialogWindow extends Window implements Serializable {
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<AbstractField<?>> getAllComponents(final AbstractLayout abstractLayout) {
|
||||
private static List<AbstractField<?>> getAllComponents(final AbstractLayout abstractLayout) {
|
||||
final List<AbstractField<?>> components = new ArrayList<>();
|
||||
|
||||
final Iterator<Component> iterate = abstractLayout.iterator();
|
||||
@@ -464,6 +469,7 @@ public class CommonDialogWindow extends Window implements Serializable {
|
||||
|
||||
private class ChangeListener implements ValueChangeListener, TextChangeListener, ItemSetChangeListener {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final Field<?> field;
|
||||
|
||||
public ChangeListener(final Field<?> field) {
|
||||
|
||||
@@ -64,7 +64,7 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
|
||||
private Button editButton;
|
||||
|
||||
private Button manageMetadataBtn;
|
||||
|
||||
|
||||
private TabSheet detailsTab;
|
||||
|
||||
private VerticalLayout detailsLayout;
|
||||
@@ -140,11 +140,11 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
|
||||
editButton.addClickListener(this::onEdit);
|
||||
editButton.setEnabled(false);
|
||||
|
||||
manageMetadataBtn = SPUIComponentProvider.getButton("", "", "", null, false,
|
||||
FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class);
|
||||
manageMetadataBtn = SPUIComponentProvider.getButton("", "", "", null, false, FontAwesome.LIST_ALT,
|
||||
SPUIButtonStyleSmallNoBorder.class);
|
||||
manageMetadataBtn.setId(getEditButtonId());
|
||||
manageMetadataBtn.setDescription(i18n.get("tooltip.metadata.icon"));
|
||||
manageMetadataBtn.addClickListener(this::showMetadata);
|
||||
manageMetadataBtn.addClickListener(this::showMetadata);
|
||||
manageMetadataBtn.setEnabled(false);
|
||||
|
||||
detailsTab = SPUIComponentProvider.getDetailsTabSheet();
|
||||
@@ -295,8 +295,8 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
|
||||
descriptionLayout = getTabLayout();
|
||||
return descriptionLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Default caption of header to be displayed when no data row selected in
|
||||
* table.
|
||||
*
|
||||
@@ -341,7 +341,7 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
|
||||
}
|
||||
|
||||
protected abstract void populateDetailsWidget();
|
||||
|
||||
|
||||
protected abstract void populateMetadataDetails();
|
||||
|
||||
protected Long getSelectedBaseEntityId() {
|
||||
@@ -352,10 +352,8 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
|
||||
|
||||
protected abstract String getName();
|
||||
|
||||
protected abstract String getShowMetadataButtonId();
|
||||
|
||||
protected abstract Boolean isMetadataIconToBeDisplayed();
|
||||
|
||||
|
||||
protected abstract void showMetadata(Button.ClickEvent event);
|
||||
|
||||
}
|
||||
|
||||
@@ -41,130 +41,142 @@ import com.vaadin.ui.themes.ValoTheme;
|
||||
@ViewScope
|
||||
public class SoftwareModuleMetadatadetailslayout extends Table {
|
||||
|
||||
private static final long serialVersionUID = 2913758299611838818L;
|
||||
private static final long serialVersionUID = 2913758299611838818L;
|
||||
|
||||
private static final String METADATA_KEY = "Key";
|
||||
private static final String METADATA_KEY = "Key";
|
||||
|
||||
private SpPermissionChecker permissionChecker;
|
||||
private SpPermissionChecker permissionChecker;
|
||||
|
||||
private SoftwareManagement softwareManagement;
|
||||
private transient SoftwareManagement softwareManagement;
|
||||
|
||||
private SwMetadataPopupLayout swMetadataPopupLayout;
|
||||
private SwMetadataPopupLayout swMetadataPopupLayout;
|
||||
|
||||
private I18N i18n;
|
||||
private I18N i18n;
|
||||
|
||||
private Long selectedSWModuleId;
|
||||
private Long selectedSWModuleId;
|
||||
|
||||
private transient EntityFactory entityFactory;
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
public void init(final I18N i18n, final SpPermissionChecker permissionChecker,
|
||||
final SoftwareManagement softwareManagement, final SwMetadataPopupLayout swMetadataPopupLayout,
|
||||
final EntityFactory entityFactory) {
|
||||
this.i18n = i18n;
|
||||
this.permissionChecker = permissionChecker;
|
||||
this.softwareManagement = softwareManagement;
|
||||
this.swMetadataPopupLayout = swMetadataPopupLayout;
|
||||
this.entityFactory = entityFactory;
|
||||
createSWMMetadataTable();
|
||||
addCustomGeneratedColumns();
|
||||
}
|
||||
/**
|
||||
* Initialize the layout.
|
||||
*
|
||||
* @param i18n
|
||||
* the i18n service
|
||||
* @param permissionChecker
|
||||
* the permission checker service
|
||||
* @param softwareManagement
|
||||
* the software management service
|
||||
* @param swMetadataPopupLayout
|
||||
* the software module metadata popup layout
|
||||
* @param entityFactory
|
||||
* the entity factory service
|
||||
*/
|
||||
public void init(final I18N i18n, final SpPermissionChecker permissionChecker,
|
||||
final SoftwareManagement softwareManagement, final SwMetadataPopupLayout swMetadataPopupLayout,
|
||||
final EntityFactory entityFactory) {
|
||||
this.i18n = i18n;
|
||||
this.permissionChecker = permissionChecker;
|
||||
this.softwareManagement = softwareManagement;
|
||||
this.swMetadataPopupLayout = swMetadataPopupLayout;
|
||||
this.entityFactory = entityFactory;
|
||||
createSWMMetadataTable();
|
||||
addCustomGeneratedColumns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate software module metadata table.
|
||||
*
|
||||
* @param swModule
|
||||
*/
|
||||
public void populateSMMetadata(final SoftwareModule swModule) {
|
||||
removeAllItems();
|
||||
if (null == swModule) {
|
||||
return;
|
||||
}
|
||||
selectedSWModuleId = swModule.getId();
|
||||
final List<SoftwareModuleMetadata> swMetadataList = swModule.getMetadata();
|
||||
if (null != swMetadataList && !swMetadataList.isEmpty()) {
|
||||
swMetadataList.forEach(swMetadata -> setSWMetadataProperties(swMetadata));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Populate software module metadata table.
|
||||
*
|
||||
* @param swModule
|
||||
*/
|
||||
public void populateSMMetadata(final SoftwareModule swModule) {
|
||||
removeAllItems();
|
||||
if (null == swModule) {
|
||||
return;
|
||||
}
|
||||
selectedSWModuleId = swModule.getId();
|
||||
final List<SoftwareModuleMetadata> swMetadataList = swModule.getMetadata();
|
||||
if (null != swMetadataList && !swMetadataList.isEmpty()) {
|
||||
swMetadataList.forEach(swMetadata -> setSWMetadataProperties(swMetadata));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
/**
|
||||
* Delete metadata.
|
||||
*
|
||||
* @param metadataKeyName
|
||||
*/
|
||||
public void deleteMetadata(final String metadataKeyName) {
|
||||
final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource();
|
||||
metadataContainer.removeItem(metadataKeyName);
|
||||
}
|
||||
|
||||
private void createSWMMetadataTable() {
|
||||
addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
|
||||
addStyleName(ValoTheme.TABLE_NO_STRIPES);
|
||||
addStyleName(SPUIStyleDefinitions.SW_MODULE_TABLE);
|
||||
setSelectable(false);
|
||||
setImmediate(true);
|
||||
setContainerDataSource(getSwModuleMetadataContainer());
|
||||
setColumnHeaderMode(ColumnHeaderMode.EXPLICIT);
|
||||
addSMMetadataTableHeader();
|
||||
setSizeFull();
|
||||
//same as height of other tabs in details tabsheet
|
||||
setHeight(116,Unit.PIXELS);
|
||||
}
|
||||
private void createSWMMetadataTable() {
|
||||
addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
|
||||
addStyleName(ValoTheme.TABLE_NO_STRIPES);
|
||||
addStyleName(SPUIStyleDefinitions.SW_MODULE_TABLE);
|
||||
setSelectable(false);
|
||||
setImmediate(true);
|
||||
setContainerDataSource(getSwModuleMetadataContainer());
|
||||
setColumnHeaderMode(ColumnHeaderMode.EXPLICIT);
|
||||
addSMMetadataTableHeader();
|
||||
setSizeFull();
|
||||
// same as height of other tabs in details tabsheet
|
||||
setHeight(116, Unit.PIXELS);
|
||||
}
|
||||
|
||||
private IndexedContainer getSwModuleMetadataContainer() {
|
||||
final IndexedContainer container = new IndexedContainer();
|
||||
container.addContainerProperty(METADATA_KEY, String.class, "");
|
||||
setColumnAlignment(METADATA_KEY, Align.LEFT);
|
||||
return container;
|
||||
}
|
||||
private IndexedContainer getSwModuleMetadataContainer() {
|
||||
final IndexedContainer container = new IndexedContainer();
|
||||
container.addContainerProperty(METADATA_KEY, String.class, "");
|
||||
setColumnAlignment(METADATA_KEY, Align.LEFT);
|
||||
return container;
|
||||
}
|
||||
|
||||
private void addSMMetadataTableHeader() {
|
||||
setColumnHeader(METADATA_KEY, i18n.get("header.key"));
|
||||
}
|
||||
private void addSMMetadataTableHeader() {
|
||||
setColumnHeader(METADATA_KEY, i18n.get("header.key"));
|
||||
}
|
||||
|
||||
private void setSWMetadataProperties(final SoftwareModuleMetadata swMetadata) {
|
||||
final Item item = getContainerDataSource().addItem(swMetadata.getKey());
|
||||
item.getItemProperty(METADATA_KEY).setValue(swMetadata.getKey());
|
||||
}
|
||||
|
||||
private void setSWMetadataProperties(final SoftwareModuleMetadata swMetadata) {
|
||||
final Item item = getContainerDataSource().addItem(swMetadata.getKey());
|
||||
item.getItemProperty(METADATA_KEY).setValue(swMetadata.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 viewLink = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey,
|
||||
"View" + metadataKey + " Metadata details", null, false, null, SPUIButtonStyleSmallNoBorder.class);
|
||||
viewLink.setData(metadataKey);
|
||||
if (permissionChecker.hasUpdateDistributionPermission()) {
|
||||
viewLink.addStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_LINK + " " + "on-focus-no-border link"
|
||||
+ " " + "text-style");
|
||||
viewLink.addClickListener(event -> showMetadataDetails(selectedSWModuleId, metadataKey));
|
||||
}
|
||||
return viewLink;
|
||||
}
|
||||
|
||||
private Button customMetadataDetailButton(final String metadataKey) {
|
||||
final Button viewLink = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey, "View"
|
||||
+ metadataKey + " Metadata details", null, false, null, SPUIButtonStyleSmallNoBorder.class);
|
||||
viewLink.setData(metadataKey);
|
||||
if (permissionChecker.hasUpdateDistributionPermission()) {
|
||||
viewLink.addStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_LINK + " " + "on-focus-no-border link"
|
||||
+ " " + "text-style");
|
||||
viewLink.addClickListener(event -> showMetadataDetails(selectedSWModuleId, metadataKey));
|
||||
}
|
||||
return viewLink;
|
||||
}
|
||||
private static String getDetailLinkId(final String name) {
|
||||
return new StringBuilder(SPUIComponentIdProvider.SW_METADATA_DETAIL_LINK).append('.').append(name).toString();
|
||||
}
|
||||
|
||||
private static String getDetailLinkId(final String name) {
|
||||
return new StringBuilder(SPUIComponentIdProvider.SW_METADATA_DETAIL_LINK).append('.').append(name).toString();
|
||||
}
|
||||
|
||||
private void showMetadataDetails(final Long selectedSWModuleId, final String metadataKey) {
|
||||
SoftwareModule swmodule = softwareManagement.findSoftwareModuleById(selectedSWModuleId);
|
||||
/* display the window */
|
||||
UI.getCurrent().addWindow(
|
||||
swMetadataPopupLayout.getWindow(swmodule,
|
||||
entityFactory.generateSoftwareModuleMetadata(swmodule, metadataKey, "")));
|
||||
}
|
||||
private void showMetadataDetails(final Long selectedSWModuleId, final String metadataKey) {
|
||||
final SoftwareModule swmodule = softwareManagement.findSoftwareModuleById(selectedSWModuleId);
|
||||
/* display the window */
|
||||
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule,
|
||||
entityFactory.generateSoftwareModuleMetadata(swmodule, metadataKey, "")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -68,7 +68,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 +83,35 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
|
||||
@Autowired
|
||||
private transient DistributionSetManagement distributionSetManagement;
|
||||
|
||||
|
||||
@Autowired
|
||||
private DsMetadataPopupLayout dsMetadataPopupLayout;
|
||||
|
||||
|
||||
@Autowired
|
||||
private EntityFactory entityFactory;
|
||||
private transient 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());
|
||||
}
|
||||
}
|
||||
});
|
||||
UI.getCurrent().access(() -> {
|
||||
final 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 +122,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 +139,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
populateTags();
|
||||
populateMetadataDetails();
|
||||
}
|
||||
|
||||
|
||||
private void populateModule() {
|
||||
softwareModuleTable.populateModule(getSelectedBaseEntity());
|
||||
showUnsavedAssignment();
|
||||
@@ -271,12 +269,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 +401,18 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
protected Boolean isMetadataIconToBeDisplayed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getShowMetadataButtonId() {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,23 +36,24 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
|
||||
private transient DistributionSetManagement distributionSetManagement;
|
||||
|
||||
@Autowired
|
||||
private EntityFactory entityFactory;
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
@Autowired
|
||||
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 +63,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 +75,23 @@ 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();
|
||||
|
||||
@@ -49,49 +49,50 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
|
||||
|
||||
@Autowired
|
||||
private ManageDistUIState manageDistUIState;
|
||||
|
||||
|
||||
@Autowired
|
||||
private transient SoftwareManagement softwareManagement;
|
||||
|
||||
|
||||
@Autowired
|
||||
private SwMetadataPopupLayout swMetadataPopupLayout;
|
||||
|
||||
|
||||
@Autowired
|
||||
private EntityFactory entityFactory;
|
||||
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
private SoftwareModuleMetadatadetailslayout swmMetadataTable;
|
||||
|
||||
/**
|
||||
/**
|
||||
* softwareLayout Initialize the component.
|
||||
*/
|
||||
@Override
|
||||
protected void init() {
|
||||
swmMetadataTable = new SoftwareModuleMetadatadetailslayout();
|
||||
swmMetadataTable.init(getI18n(), getPermissionChecker(),softwareManagement,swMetadataPopupLayout,entityFactory);
|
||||
swmMetadataTable.init(getI18n(), getPermissionChecker(), softwareManagement, swMetadataPopupLayout,
|
||||
entityFactory);
|
||||
super.init();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MetadataEvent.
|
||||
*
|
||||
* @param event
|
||||
* as instance of {@link MetadataEvent}
|
||||
*/
|
||||
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final MetadataEvent event) {
|
||||
UI.getCurrent()
|
||||
.access(() -> {
|
||||
SoftwareModuleMetadata softwareModuleMetadata = event.getSoftwareModuleMetadata();
|
||||
if (softwareModuleMetadata != null
|
||||
&& isSoftwareModuleSelected(softwareModuleMetadata.getSoftwareModule())) {
|
||||
if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_SOFTWARE_MODULE_METADATA) {
|
||||
swmMetadataTable.createMetadata(event.getSoftwareModuleMetadata().getKey());
|
||||
} else if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_SOFTWARE_MODULE_METADATA) {
|
||||
swmMetadataTable.deleteMetadata(event.getSoftwareModuleMetadata().getKey());
|
||||
}
|
||||
}
|
||||
});
|
||||
UI.getCurrent().access(() -> {
|
||||
final SoftwareModuleMetadata softwareModuleMetadata = event.getSoftwareModuleMetadata();
|
||||
if (softwareModuleMetadata != null
|
||||
&& isSoftwareModuleSelected(softwareModuleMetadata.getSoftwareModule())) {
|
||||
if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_SOFTWARE_MODULE_METADATA) {
|
||||
swmMetadataTable.createMetadata(event.getSoftwareModuleMetadata().getKey());
|
||||
} else if (event
|
||||
.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_SOFTWARE_MODULE_METADATA) {
|
||||
swmMetadataTable.deleteMetadata(event.getSoftwareModuleMetadata().getKey());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
@@ -119,7 +120,7 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
|
||||
detailsTab.addTab(createDescriptionLayout(), getI18n().get("caption.tab.description"), null);
|
||||
detailsTab.addTab(createLogLayout(), getI18n().get("caption.logs.tab"), null);
|
||||
detailsTab.addTab(swmMetadataTable, getI18n().get("caption.metadata"), null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultCaption() {
|
||||
@@ -196,15 +197,15 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
|
||||
protected String getDetailsHeaderCaptionId() {
|
||||
return SPUIComponentIdProvider.TARGET_DETAILS_HEADER_LABEL_ID;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void populateMetadataDetails() {
|
||||
swmMetadataTable.populateSMMetadata(getSelectedBaseEntity());
|
||||
}
|
||||
|
||||
private boolean isSoftwareModuleSelected(SoftwareModule softwareModule) {
|
||||
final Long selectedDistSWModuleId = manageDistUIState.getSelectedBaseSwModuleId().isPresent() ? manageDistUIState
|
||||
.getSelectedBaseSwModuleId().get() : null;
|
||||
private boolean isSoftwareModuleSelected(final SoftwareModule softwareModule) {
|
||||
final Long selectedDistSWModuleId = manageDistUIState.getSelectedBaseSwModuleId().isPresent()
|
||||
? manageDistUIState.getSelectedBaseSwModuleId().get() : null;
|
||||
return softwareModule != null && selectedDistSWModuleId != null
|
||||
&& selectedDistSWModuleId.equals(softwareModule.getId());
|
||||
}
|
||||
@@ -213,17 +214,10 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
|
||||
protected Boolean isMetadataIconToBeDisplayed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getShowMetadataButtonId() {
|
||||
SoftwareModule selectedBaseEntity = getSelectedBaseEntity();
|
||||
return SPUIComponentIdProvider.SW_TABLE_MANAGE_METADATA_ID + "." + selectedBaseEntity.getName() + "."
|
||||
+ selectedBaseEntity.getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showMetadata(ClickEvent event) {
|
||||
SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(getSelectedBaseEntityId());
|
||||
protected void showMetadata(final ClickEvent event) {
|
||||
final SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(getSelectedBaseEntityId());
|
||||
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule, null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,8 +60,7 @@ import com.vaadin.ui.VerticalLayout;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* A Vaadin layout for create or update the target filter.
|
||||
*/
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
@@ -494,11 +493,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
if (filterManagementUIState.isCreateFilterViewDisplayed() && !doesAlreadyExists()) {
|
||||
createTargetFilterQuery();
|
||||
} else {
|
||||
if (!nameTextField.getValue().equals(oldFilterName) && !doesAlreadyExists()) {
|
||||
updateCustomFilter();
|
||||
} else {
|
||||
updateCustomFilter();
|
||||
}
|
||||
updateCustomFilter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,48 +53,47 @@ 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 transient 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());
|
||||
}
|
||||
}
|
||||
});
|
||||
UI.getCurrent().access(() -> {
|
||||
final 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 +155,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 +204,24 @@ 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;
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -107,7 +107,6 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
|
||||
return;
|
||||
}
|
||||
targetAddUpdateWindowLayout.getWindow(getSelectedBaseEntity().getControllerId());
|
||||
// targetAddUpdateWindowLayout.populateValuesOfTarget(getSelectedBaseEntity().getControllerId());
|
||||
openWindow();
|
||||
}
|
||||
|
||||
@@ -229,7 +228,7 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
|
||||
* as Module (JVM|OS|AH)
|
||||
* @return Label as UI
|
||||
*/
|
||||
private Label getSWModlabel(final String labelName, final SoftwareModule swModule) {
|
||||
private static Label getSWModlabel(final String labelName, final SoftwareModule swModule) {
|
||||
return SPUIComponentProvider.createNameValueLabel(labelName + " : ", swModule.getName(), swModule.getVersion());
|
||||
}
|
||||
|
||||
@@ -253,24 +252,19 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
|
||||
return SPUIComponentIdProvider.TARGET_DETAILS_HEADER_LABEL_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getShowMetadataButtonId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean isMetadataIconToBeDisplayed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showMetadata(ClickEvent event) {
|
||||
//No implementation required
|
||||
protected void showMetadata(final ClickEvent event) {
|
||||
// No implementation required
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateMetadataDetails() {
|
||||
//No implementation required
|
||||
// No implementation required
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ public class RolloutListGrid extends AbstractGrid {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getDSDetails(final Item rolloutItem) {
|
||||
private static String getDSDetails(final Item rolloutItem) {
|
||||
final StringBuilder swModuleNames = new StringBuilder();
|
||||
final StringBuilder swModuleVendors = new StringBuilder();
|
||||
final Set<SoftwareModule> swModules = (Set<SoftwareModule>) rolloutItem.getItemProperty(SW_MODULES).getValue();
|
||||
|
||||
Reference in New Issue
Block a user