From 37afb4e7cde6402710d49975113a68dc5751984c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Guimar=C3=A3es?= Date: Mon, 20 Nov 2023 17:49:49 +0000 Subject: [PATCH] wip --- .../roda/core/data/common/RodaConstants.java | 4 + .../conversion/AbstractConvertPlugin.java | 22 +- .../maintenance/ActionLogCleanerPlugin.java | 11 +- .../ingest/process/PluginOptionsPanel.java | 16 +- .../ingest/process/PluginParameterPanel.java | 443 +++++++++--------- .../wui/client/ingest/process/ShowJob.java | 99 ++-- .../process/model/DisseminationParameter.java | 30 +- .../process/model/PrintableParameter.java | 9 + .../model/RepresentationParameter.java | 12 +- 9 files changed, 332 insertions(+), 314 deletions(-) create mode 100644 roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/model/PrintableParameter.java diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/common/RodaConstants.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/common/RodaConstants.java index 3a1e74cdac..68b493d8ef 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/common/RodaConstants.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/common/RodaConstants.java @@ -2075,6 +2075,10 @@ public enum RODA_TYPE { public static final String SYNCHRONIZATION_ENTITY_SUMMARY_TYPE_UPDATED = "updated"; public static final String SYNCHRONIZATION_ENTITY_SUMMARY_TYPE_ISSUE = "issue"; + public static final String PLUGIN_PARAMS_CONVERSION_REPRESENTATION = "rep"; + + public static final String PLUGIN_PARAMS_CONVERSION_DISSEMINATION = "dip"; + /** Private empty constructor */ private RodaConstants() { // do nothing diff --git a/roda-core/roda-core/src/main/java/org/roda/core/plugins/base/conversion/AbstractConvertPlugin.java b/roda-core/roda-core/src/main/java/org/roda/core/plugins/base/conversion/AbstractConvertPlugin.java index bd9b91b359..f25983f52a 100644 --- a/roda-core/roda-core/src/main/java/org/roda/core/plugins/base/conversion/AbstractConvertPlugin.java +++ b/roda-core/roda-core/src/main/java/org/roda/core/plugins/base/conversion/AbstractConvertPlugin.java @@ -91,25 +91,9 @@ public abstract class AbstractConvertPlugin extends Abst PluginParameterType.BOOLEAN, "true", false, false, "Do not process files that have a different format from the indicated.")); - pluginParameters.put(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_OR_DIP, new PluginParameter( - RodaConstants.PLUGIN_PARAMS_REPRESENTATION_OR_DIP, "Create dissemination", PluginParameterType.BOOLEAN, "true", - false, false, - "If this is selected then the plugin will convert the files and create a new dissemination. If not, a new representation will be created.")); - - pluginParameters.put(RodaConstants.PLUGIN_PARAMS_DISSEMINATION_TITLE, - new PluginParameter(RodaConstants.PLUGIN_PARAMS_DISSEMINATION_TITLE, "Dissemination title", - PluginParameterType.STRING, "Dissemination title", false, false, - "If the 'create dissemination' option is checked, then this will be the respective dissemination title.")); - - pluginParameters.put(RodaConstants.PLUGIN_PARAMS_DISSEMINATION_DESCRIPTION, new PluginParameter( - RodaConstants.PLUGIN_PARAMS_DISSEMINATION_DESCRIPTION, "Dissemination description", PluginParameterType.STRING, - "Dissemination description", false, false, - "If the 'create dissemination' option is checked, then this will be the respective dissemination description.")); - - pluginParameters.put(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_TYPE, - new PluginParameter(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_TYPE, "Representation type", - PluginParameterType.REPRESENTATION_TYPE, "", false, false, - "Attribute a type when creating a new representation")); + pluginParameters.put(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_OR_DIP, + new PluginParameter.PluginParameterBuilder(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_OR_DIP, "", + PluginParameterType.CONVERSION).build()); } private String inputFormat; diff --git a/roda-core/roda-core/src/main/java/org/roda/core/plugins/base/maintenance/ActionLogCleanerPlugin.java b/roda-core/roda-core/src/main/java/org/roda/core/plugins/base/maintenance/ActionLogCleanerPlugin.java index 1bfaf36021..1cd27da860 100644 --- a/roda-core/roda-core/src/main/java/org/roda/core/plugins/base/maintenance/ActionLogCleanerPlugin.java +++ b/roda-core/roda-core/src/main/java/org/roda/core/plugins/base/maintenance/ActionLogCleanerPlugin.java @@ -42,12 +42,11 @@ public class ActionLogCleanerPlugin extends AbstractPlugin { private static final Map pluginParameters = new HashMap<>(); static { - pluginParameters.put(RodaConstants.PLUGIN_PARAMS_DELETE_OLDER_THAN_X_DAYS, new PluginParameter.PluginParameterBuilder( - RodaConstants.PLUGIN_PARAMS_DELETE_OLDER_THAN_X_DAYS, "Delete older than X days", PluginParameterType.INTEGER) - .withDefaultValue("90").isMandatory(false).isReadOnly(false) - .withDescription("The plugin will delete all logs older than the specified number of days.").build()); - - pluginParameters.put("test", new PluginParameter.PluginParameterBuilder("test", "rep or diss test", PluginParameterType.CONVERSION).build()); + pluginParameters.put(RodaConstants.PLUGIN_PARAMS_DELETE_OLDER_THAN_X_DAYS, + new PluginParameter.PluginParameterBuilder(RodaConstants.PLUGIN_PARAMS_DELETE_OLDER_THAN_X_DAYS, + "Delete older than X days", PluginParameterType.INTEGER).withDefaultValue("90").isMandatory(false) + .isReadOnly(false).withDescription("The plugin will delete all logs older than the specified number of days.") + .build()); } private int deleteOlderThanXDays = 90; diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/PluginOptionsPanel.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/PluginOptionsPanel.java index afb0fac35a..6b8fc0f8a0 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/PluginOptionsPanel.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/PluginOptionsPanel.java @@ -12,6 +12,7 @@ import java.util.List; import java.util.Map; +import org.roda.core.data.common.RodaConstants; import org.roda.core.data.v2.jobs.PluginInfo; import org.roda.core.data.v2.jobs.PluginParameter; @@ -63,9 +64,18 @@ public Map getValue() { for (PluginParameterPanel panel : panels) { String key = panel.getParameter().getId(); - String value = panel.getValue(); - if (value != null) { - ret.put(key, value); + if (panel.isConversionPanel()) { + if (panel.getValue().equals(RodaConstants.PLUGIN_PARAMS_CONVERSION_DISSEMINATION)) { + ret.put(key, panel.getDisseminationParameter().printAsParameter(panel.getValue())); + } else { + ret.put(key, + panel.getRepresentationParameter().printAsParameter(RodaConstants.PLUGIN_PARAMS_CONVERSION_REPRESENTATION)); + } + } else { + String value = panel.getValue(); + if (value != null) { + ret.put(key, value); + } } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/PluginParameterPanel.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/PluginParameterPanel.java index fb313b862b..15a82dffa1 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/PluginParameterPanel.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/PluginParameterPanel.java @@ -14,6 +14,8 @@ import java.util.Set; import java.util.TreeSet; +import com.google.gwt.dom.client.Document; +import com.google.gwt.event.dom.client.DomEvent; import org.roda.core.data.common.RodaConstants; import org.roda.core.data.utils.RepresentationInformationUtils; import org.roda.core.data.v2.common.Pair; @@ -44,9 +46,7 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; -import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.i18n.client.LocaleInfo; import com.google.gwt.safehtml.shared.SafeHtmlUtils; @@ -67,20 +67,23 @@ import config.i18n.client.ClientMessages; public class PluginParameterPanel extends Composite { + public static final String FORM_SELECTBOX = "form-selectbox"; + public static final String FORM_TEXTBOX_SMALL = "form-textbox-small"; + public static final String FORM_RADIOBUTTON = "form-radiobutton"; + public static final String FORM_RADIOGROUP = "form-radiogroup"; + public static final String FORM_LABEL = "form-label"; + public static final String FORM_TEXTBOX = "form-textbox"; + public static final String OBJECT_BOX = "object box"; + public static final String FORM_HELP = "form-help"; private static final ClientMessages messages = GWT.create(ClientMessages.class); private static final ClientLogger LOGGER = new ClientLogger(PluginParameterPanel.class.getName()); private static final String ADD_TYPE = "#__ADDNEW__#"; - private final PluginParameter parameter; private final FlowPanel layout; - + private final RepresentationParameter representationParameter = new RepresentationParameter(); + private final DisseminationParameter disseminationParameter = new DisseminationParameter(); private String value; private String aipTitle; - - private final RepresentationParameter representationParameter = new RepresentationParameter(); - - private DisseminationParameter disseminationParameter; - private boolean conversionPanel = false; public PluginParameterPanel(PluginParameter parameter) { @@ -99,7 +102,7 @@ private void updateLayout() { if (PluginParameterType.BOOLEAN.equals(parameter.getType())) { createBooleanLayout(); } else if (PluginParameterType.STRING.equals(parameter.getType())) { - createStringLayout(); + createStringLayout(parameter); } else if (PluginParameterType.PLUGIN_SIP_TO_AIP.equals(parameter.getType())) { createPluginSipToAipLayout(); } else if (PluginParameterType.AIP_ID.equals(parameter.getType())) { @@ -109,7 +112,7 @@ private void updateLayout() { } else if (PluginParameterType.SEVERITY.equals(parameter.getType())) { createSelectSeverityLayout(); } else if (PluginParameterType.REPRESENTATION_TYPE.equals(parameter.getType())) { - createRepresentationTypeLayout(); + createRepresentationTypeLayout(parameter); } else if (PluginParameterType.RODA_OBJECT.equals(parameter.getType())) { createSelectRodaObjectLayout(); } else if (PluginParameterType.INTEGER.equals(parameter.getType())) { @@ -131,7 +134,7 @@ private void updateLayout() { } else { LOGGER .warn("Unsupported plugin parameter type: " + parameter.getType() + ". Reverting to default parameter editor."); - createStringLayout(); + createStringLayout(parameter); } } @@ -139,74 +142,71 @@ private void createConversionLayout() { conversionPanel = true; Label parameterName = new Label(parameter.getName()); final ListBox dropdown = new ListBox(); - dropdown.addStyleName("form-selectbox"); - dropdown.addStyleName("form-textbox-small"); + dropdown.addStyleName(FORM_SELECTBOX); + dropdown.addStyleName(FORM_TEXTBOX_SMALL); - dropdown.addItem("Representation", "rep"); - dropdown.addItem("Dissemination", "dip"); + dropdown.addItem("Representation", RodaConstants.PLUGIN_PARAMS_CONVERSION_REPRESENTATION); + dropdown.addItem("Dissemination", RodaConstants.PLUGIN_PARAMS_CONVERSION_DISSEMINATION); value = dropdown.getSelectedValue(); FlowPanel innerPanel = new FlowPanel(); dropdown.addChangeHandler(event -> { value = dropdown.getSelectedValue(); - if (value.equals("rep")) { + if (value.equals(RodaConstants.PLUGIN_PARAMS_CONVERSION_REPRESENTATION)) { + // Clear the layout innerPanel.clear(); - // Clean layout // Add fields - Label label = new Label(parameter.getName()); - TextBox parameterBox = new TextBox(); - if (parameter.getDefaultValue() != null) { - parameterBox.setText(parameter.getDefaultValue()); - value = parameter.getDefaultValue(); - } - - parameterBox.setEnabled(!parameter.isReadonly()); - parameterBox.setTitle("parameter box"); - - label.addStyleName("form-label"); - parameterBox.addStyleName("form-textbox"); + ValueChangeHandler typeChanged = typeChangedEvent -> representationParameter + .setValue(typeChangedEvent.getValue()); - // binding change - parameterBox.addValueChangeHandler(new ValueChangeHandler() { - - @Override - public void onValueChange(ValueChangeEvent event) { - representationParameter.setValue(event.getValue()); - } - }); + innerPanel.add(createRepresentationType("Representation type", + "Assign a type when creating a new representation", typeChanged)); - innerPanel.add(label); - innerPanel.add(parameterBox); + value = RodaConstants.PLUGIN_PARAMS_CONVERSION_REPRESENTATION; } else { + // Clear the layout innerPanel.clear(); - // Clean layout // Add fields + ValueChangeHandler titleChanged = titleChangedEvent -> disseminationParameter + .setTitle(titleChangedEvent.getValue()); + ValueChangeHandler descriptionChanged = descriptionChangedEvent -> disseminationParameter + .setDescription(descriptionChangedEvent.getValue()); + + innerPanel.add(createTextBoxLayout("Dissemination title", disseminationParameter.getTitle(), + "This will be the respective dissemination title.", false, titleChanged)); + innerPanel.add(createTextBoxLayout("Dissemination description", disseminationParameter.getDescription(), + "This will be the respective dissemination description.", false, descriptionChanged)); + + value = RodaConstants.PLUGIN_PARAMS_CONVERSION_DISSEMINATION; } }); - dropdown.setTitle("object box"); + setSelectedIndexAndFireEvent(dropdown, 0); + + dropdown.setTitle(OBJECT_BOX); layout.add(parameterName); layout.add(dropdown); layout.add(innerPanel); addHelp(); } - private void createRepresentationTypeLayout() { - Label parameterName = new Label(parameter.getName()); + private void setSelectedIndexAndFireEvent(final ListBox listBox, final int index) { + // Set the selected index + listBox.setSelectedIndex(index); - final ListBox selectBox = new ListBox(); - selectBox.addStyleName("form-selectbox"); - selectBox.addStyleName("form-textbox-small"); - - final TextBox newTypeBox = new TextBox(); - final Label newTypeLabel = new Label(messages.entityTypeNewLabel() + ": "); + // Manually trigger a ValueChangeEvent + DomEvent.fireNativeEvent(Document.get().createChangeEvent(), listBox); + } - newTypeBox.getElement().setPropertyString("placeholder", messages.entityTypeNewLabel()); - newTypeBox.addStyleName("form-textbox wui-dialog-message plugin-representation-type-box"); - newTypeLabel.addStyleName("plugin-representation-type-label"); + private FlowPanel createRepresentationType(String name, String description, + ValueChangeHandler changeHandler) { + FlowPanel panel = new FlowPanel(); + Label parameterName = new Label(name); - newTypeLabel.setVisible(false); - newTypeBox.setVisible(false); + final ListBox selectBox = new ListBox(); + selectBox.addStyleName(FORM_SELECTBOX); + selectBox.addStyleName(FORM_TEXTBOX_SMALL); + selectBox.setTitle("representation type box"); BrowserService.Util.getInstance().retrieveRepresentationTypeOptions(LocaleInfo.getCurrentLocale().getLocaleName(), new AsyncCallback>>() { @@ -225,40 +225,49 @@ public void onSuccess(Pair> result) { if (Boolean.FALSE.equals(result.getFirst())) { selectBox.addItem(messages.entityTypeAddNew(), ADD_TYPE); } - - selectBox.addChangeHandler(new ChangeHandler() { - @Override - public void onChange(ChangeEvent event) { - value = selectBox.getSelectedValue(); - newTypeLabel.setVisible(value.equals(ADD_TYPE)); - newTypeBox.setVisible(value.equals(ADD_TYPE)); - } - }); - - newTypeBox.addChangeHandler(new ChangeHandler() { - @Override - public void onChange(ChangeEvent event) { - value = newTypeBox.getText(); - } - }); + selectBox.setSelectedIndex(0); + value = selectBox.getSelectedValue(); + representationParameter.setValue(selectBox.getSelectedValue()); } }); - value = selectBox.getSelectedValue(); - selectBox.setTitle("representation type box"); + final TextBox newTypeBox = new TextBox(); + final Label newTypeLabel = new Label(messages.entityTypeNewLabel() + ": "); + newTypeBox.getElement().setPropertyString("placeholder", messages.entityTypeNewLabel()); + newTypeBox.addStyleName("form-textbox wui-dialog-message plugin-representation-type-box"); + newTypeLabel.addStyleName("plugin-representation-type-label"); + newTypeLabel.setVisible(false); + newTypeBox.setVisible(false); + newTypeBox.addValueChangeHandler(changeHandler); - layout.add(parameterName); - layout.add(selectBox); - layout.add(newTypeLabel); - layout.add(newTypeBox); - addHelp(); + selectBox.addChangeHandler(event -> { + value = selectBox.getSelectedValue(); + representationParameter.setValue(value); + newTypeLabel.setVisible(value.equals(ADD_TYPE)); + newTypeBox.setVisible(value.equals(ADD_TYPE)); + }); + + panel.add(parameterName); + panel.add(selectBox); + panel.add(newTypeLabel); + panel.add(newTypeBox); + addHelp(panel, description); + + return panel; + } + + private void createRepresentationTypeLayout(PluginParameter parameter) { + ValueChangeHandler handler = event -> value = event.getValue(); + + FlowPanel panel = createRepresentationType(parameter.getName(), parameter.getDescription(), handler); + layout.add(panel); } private void createSelectSeverityLayout() { Label parameterName = new Label(parameter.getName()); final ListBox severityBox = new ListBox(); - severityBox.addStyleName("form-selectbox"); - severityBox.addStyleName("form-textbox-small"); + severityBox.addStyleName(FORM_SELECTBOX); + severityBox.addStyleName(FORM_TEXTBOX_SMALL); for (SeverityLevel severity : SeverityLevel.values()) { severityBox.addItem(messages.severityLevel(severity), severity.toString()); @@ -266,12 +275,7 @@ private void createSelectSeverityLayout() { value = severityBox.getSelectedValue(); - severityBox.addChangeHandler(new ChangeHandler() { - @Override - public void onChange(ChangeEvent event) { - value = severityBox.getSelectedValue(); - } - }); + severityBox.addChangeHandler(event -> value = severityBox.getSelectedValue()); severityBox.setTitle("severity box"); layout.add(parameterName); @@ -314,8 +318,7 @@ private String getValuesString(List values) { private void createSelectAipLayout() { AipIdPluginParameterRenderingHints renderingHints = null; - if (parameter.getRenderingHings() != null - && parameter.getRenderingHings() instanceof AipIdPluginParameterRenderingHints) { + if (parameter.getRenderingHings() instanceof AipIdPluginParameterRenderingHints) { renderingHints = (AipIdPluginParameterRenderingHints) parameter.getRenderingHings(); } Label parameterName = new Label(parameter.getName()); @@ -332,64 +335,52 @@ private void createSelectAipLayout() { buttonsPanel.add(removeButton); final AipIdPluginParameterRenderingHints finalRenderingHints = renderingHints; - ClickHandler editClickHandler = new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - SelectAipDialog selectAipDialog; - if (finalRenderingHints != null) { + ClickHandler editClickHandler = event -> { + SelectAipDialog selectAipDialog; + if (finalRenderingHints != null) { - selectAipDialog = new SelectAipDialog(parameter.getName(), finalRenderingHints.getFilter(), - finalRenderingHints.isJustActive(), finalRenderingHints.isExportCsvVisible()); - - } else { - selectAipDialog = new SelectAipDialog(parameter.getName()); - } - selectAipDialog.showAndCenter(); - // default behaviour of selectAipDialog enabled - if (finalRenderingHints == null || !finalRenderingHints.isDisableSelection()) { - selectAipDialog.setSingleSelectionMode(); - selectAipDialog.addValueChangeHandler(new ValueChangeHandler() { + selectAipDialog = new SelectAipDialog(parameter.getName(), finalRenderingHints.getFilter(), + finalRenderingHints.isJustActive(), finalRenderingHints.isExportCsvVisible()); - @Override - public void onValueChange(ValueChangeEvent event) { - IndexedAIP aip = event.getValue(); + } else { + selectAipDialog = new SelectAipDialog(parameter.getName()); + } + selectAipDialog.showAndCenter(); + // default behaviour of selectAipDialog enabled + if (finalRenderingHints == null || !finalRenderingHints.isDisableSelection()) { + selectAipDialog.setSingleSelectionMode(); + selectAipDialog.addValueChangeHandler(event1 -> { + IndexedAIP aip = event1.getValue(); - Label itemTitle = new Label(); - HTMLPanel itemIconHtmlPanel = DescriptionLevelUtils.getElementLevelIconHTMLPanel(aip.getLevel()); - itemIconHtmlPanel.addStyleName("itemIcon"); - itemTitle.setText(aip.getTitle() != null ? aip.getTitle() : aip.getId()); - itemTitle.addStyleName("itemText"); + Label itemTitle = new Label(); + HTMLPanel itemIconHtmlPanel = DescriptionLevelUtils.getElementLevelIconHTMLPanel(aip.getLevel()); + itemIconHtmlPanel.addStyleName("itemIcon"); + itemTitle.setText(aip.getTitle() != null ? aip.getTitle() : aip.getId()); + itemTitle.addStyleName("itemText"); - aipPanel.clear(); - aipPanel.add(itemIconHtmlPanel); - aipPanel.add(itemTitle); + aipPanel.clear(); + aipPanel.add(itemIconHtmlPanel); + aipPanel.add(itemTitle); - editPanel.add(aipPanel); - editPanel.add(buttonsPanel); + editPanel.add(aipPanel); + editPanel.add(buttonsPanel); - editPanel.setCellWidth(aipPanel, "100%"); + editPanel.setCellWidth(aipPanel, "100%"); - editPanel.setVisible(true); - button.setVisible(false); + editPanel.setVisible(true); + button.setVisible(false); - value = aip.getId(); - aipTitle = aip.getTitle(); - } - }); - } + value = aip.getId(); + aipTitle = aip.getTitle(); + }); } }; if (finalRenderingHints == null || !finalRenderingHints.isDisableSelection()) { - ClickHandler removeClickHandler = new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - editPanel.setVisible(false); - button.setVisible(true); + ClickHandler removeClickHandler = event -> { + editPanel.setVisible(false); + button.setVisible(true); - value = null; - } + value = null; }; removeButton.addClickHandler(removeClickHandler); } @@ -400,7 +391,7 @@ public void onClick(ClickEvent event) { layout.add(button); layout.add(editPanel); - parameterName.addStyleName("form-label"); + parameterName.addStyleName(FORM_LABEL); aipPanel.addStyleName("itemPanel"); button.addStyleName("form-button btn btn-play"); buttonsPanel.addStyleName("itemButtonsPanel"); @@ -411,8 +402,8 @@ public void onClick(ClickEvent event) { private void createSelectRodaObjectLayout() { Label parameterName = new Label(parameter.getName()); final ListBox objectBox = new ListBox(); - objectBox.addStyleName("form-selectbox"); - objectBox.addStyleName("form-textbox-small"); + objectBox.addStyleName(FORM_SELECTBOX); + objectBox.addStyleName(FORM_TEXTBOX_SMALL); BrowserService.Util.getInstance() .retrieveReindexPluginObjectClasses(new AsyncCallback>>() { @@ -434,14 +425,9 @@ public void onSuccess(Set> result) { } }); - objectBox.addChangeHandler(new ChangeHandler() { - @Override - public void onChange(ChangeEvent event) { - value = objectBox.getSelectedValue(); - } - }); + objectBox.addChangeHandler(event -> value = objectBox.getSelectedValue()); - objectBox.setTitle("object box"); + objectBox.setTitle(OBJECT_BOX); layout.add(parameterName); layout.add(objectBox); addHelp(); @@ -450,8 +436,8 @@ public void onChange(ChangeEvent event) { private void createDropdownLayout() { Label parameterName = new Label(parameter.getName()); final ListBox dropdown = new ListBox(); - dropdown.addStyleName("form-selectbox"); - dropdown.addStyleName("form-textbox-small"); + dropdown.addStyleName(FORM_SELECTBOX); + dropdown.addStyleName(FORM_TEXTBOX_SMALL); BrowserService.Util.getInstance().retrieveDropdownPluginItems(parameter.getId(), LocaleInfo.getCurrentLocale().getLocaleName(), new AsyncCallback>>() { @@ -477,7 +463,7 @@ public void onSuccess(Set> result) { dropdown.addChangeHandler(event -> value = dropdown.getSelectedValue()); - dropdown.setTitle("object box"); + dropdown.setTitle(OBJECT_BOX); layout.add(parameterName); layout.add(dropdown); addHelp(); @@ -488,14 +474,15 @@ private void createUserProfileLayout() { Label parameterName = new Label(parameter.getName()); final Label description = new Label(); final ListBox dropdown = new ListBox(); - dropdown.addStyleName("form-selectbox"); - dropdown.addStyleName("form-textbox-small"); + dropdown.addStyleName(FORM_SELECTBOX); + dropdown.addStyleName(FORM_TEXTBOX_SMALL); BrowserService.Util.getInstance().retrieveUserProfilePluginItems(parameter.getId(), LocaleInfo.getCurrentLocale().getLocaleName(), new AsyncCallback>() { @Override public void onFailure(Throwable caught) { + // do nothing } @Override @@ -504,7 +491,7 @@ public void onSuccess(Set result) { for (UserProfile item : treeSet) { dropdown.addItem(item.getI18nProperty(), item.getProfile()); description.setText(item.getDescription()); - description.addStyleName("form-help"); + description.addStyleName(FORM_HELP); } value = dropdown.getSelectedValue(); @@ -527,7 +514,7 @@ public void onSuccess(Set result) { } }); - dropdown.setTitle("object box"); + dropdown.setTitle(OBJECT_BOX); layout.add(parameterName); layout.add(description); layout.add(dropdown); @@ -565,48 +552,42 @@ public void onSuccess(RepresentationInformationFilterBundle bundle) { } group.add(box); - box.addStyleName("form-radiobutton"); - - box.addValueChangeHandler(new ValueChangeHandler() { - @Override - public void onValueChange(ValueChangeEvent event) { - if (event.getValue()) { - selectedFields.add(field); - } else { - selectedFields.remove(field); - } - value = StringUtils.join(selectedFields, ","); + box.addStyleName(FORM_RADIOBUTTON); + + box.addValueChangeHandler(event -> { + if (Boolean.TRUE.equals(event.getValue())) { + selectedFields.add(field); + } else { + selectedFields.remove(field); } + value = StringUtils.join(selectedFields, ","); }); } if (File.class.getSimpleName().equals(className)) { CheckBox box = new CheckBox(messages.atLeastOneOfAbove()); group.add(box); - box.addStyleName("form-radiobutton"); + box.addStyleName(FORM_RADIOBUTTON); if (defaultValues.contains(RodaConstants.ONE_OF_FORMAT_FIELDS)) { box.setValue(true); selectedFields.add(RodaConstants.ONE_OF_FORMAT_FIELDS); } - box.addValueChangeHandler(new ValueChangeHandler() { - @Override - public void onValueChange(ValueChangeEvent event) { - if (event.getValue()) { - selectedFields.add(RodaConstants.ONE_OF_FORMAT_FIELDS); - } else { - selectedFields.remove(RodaConstants.ONE_OF_FORMAT_FIELDS); - } - value = StringUtils.join(selectedFields, ","); + box.addValueChangeHandler(event -> { + if (Boolean.TRUE.equals(event.getValue())) { + selectedFields.add(RodaConstants.ONE_OF_FORMAT_FIELDS); + } else { + selectedFields.remove(RodaConstants.ONE_OF_FORMAT_FIELDS); } + value = StringUtils.join(selectedFields, ","); }); } value = StringUtils.join(selectedFields, ","); layout.add(group); - group.addStyleName("form-radiogroup"); - parameterName.addStyleName("form-label"); + group.addStyleName(FORM_RADIOGROUP); + parameterName.addStyleName(FORM_LABEL); } }); } @@ -624,25 +605,22 @@ private void createPermissionTypesLayout() { selectedTypes.add(permissionType.toString()); group.add(box); - box.addStyleName("form-radiobutton"); + box.addStyleName(FORM_RADIOBUTTON); - box.addValueChangeHandler(new ValueChangeHandler() { - @Override - public void onValueChange(ValueChangeEvent event) { - if (event.getValue()) { - selectedTypes.add(permissionType.toString()); - } else { - selectedTypes.remove(permissionType.toString()); - } - value = StringUtils.join(selectedTypes, ","); + box.addValueChangeHandler(event -> { + if (Boolean.TRUE.equals(event.getValue())) { + selectedTypes.add(permissionType.toString()); + } else { + selectedTypes.remove(permissionType.toString()); } + value = StringUtils.join(selectedTypes, ","); }); } value = StringUtils.join(selectedTypes, ","); layout.add(group); - group.addStyleName("form-radiogroup"); - parameterName.addStyleName("form-label"); + group.addStyleName(FORM_RADIOGROUP); + parameterName.addStyleName(FORM_LABEL); } private void createPluginSipToAipLayout() { @@ -679,16 +657,12 @@ public void onSuccess(List pluginsInfo) { radioGroup.add(pRadio); radioGroup.add(pHelp); - pRadio.addStyleName("form-radiobutton"); - pHelp.addStyleName("form-help"); - - pRadio.addValueChangeHandler(new ValueChangeHandler() { + pRadio.addStyleName(FORM_RADIOBUTTON); + pHelp.addStyleName(FORM_HELP); - @Override - public void onValueChange(ValueChangeEvent event) { - if (Boolean.TRUE.equals(event.getValue())) { - value = pluginInfo.getId(); - } + pRadio.addValueChangeHandler(event -> { + if (Boolean.TRUE.equals(event.getValue())) { + value = pluginInfo.getId(); } }); } @@ -696,8 +670,8 @@ public void onValueChange(ValueChangeEvent event) { layout.add(radioGroup); - radioGroup.addStyleName("form-radiogroup"); - parameterName.addStyleName("form-label"); + radioGroup.addStyleName(FORM_RADIOGROUP); + parameterName.addStyleName(FORM_LABEL); } }); } @@ -715,44 +689,47 @@ private void createIntegerLayout() { layout.add(parameterBox); addHelp(); - parameterName.addStyleName("form-label"); - parameterBox.addStyleName("form-textbox"); + parameterName.addStyleName(FORM_LABEL); + parameterBox.addStyleName(FORM_TEXTBOX); // binding change - parameterBox.addChangeHandler(new ChangeHandler() { + parameterBox.addChangeHandler(event -> value = ((IntegerBox) event.getSource()).getValue().toString()); + } - @Override - public void onChange(ChangeEvent event) { - value = ((IntegerBox) event.getSource()).getValue().toString(); - } - }); + private void createStringLayout(PluginParameter parameter) { + ValueChangeHandler changeHandler = event -> value = event.getValue(); + + FlowPanel textBoxLayout = createTextBoxLayout(parameter.getName(), parameter.getDefaultValue(), + parameter.getDescription(), parameter.isReadonly(), changeHandler); + layout.add(textBoxLayout); } - private void createStringLayout() { - Label parameterName = new Label(parameter.getName()); + private FlowPanel createTextBoxLayout(String name, String defaultValue, String description, boolean isReadOnly, + ValueChangeHandler valueChangeEvent) { + + FlowPanel panel = new FlowPanel(); + + Label parameterName = new Label(name); TextBox parameterBox = new TextBox(); - if (parameter.getDefaultValue() != null) { - parameterBox.setText(parameter.getDefaultValue()); - value = parameter.getDefaultValue(); + + if (defaultValue != null) { + parameterBox.setText(defaultValue); + value = defaultValue; } - parameterBox.setEnabled(!parameter.isReadonly()); + parameterName.addStyleName(FORM_LABEL); + parameterBox.addStyleName(FORM_TEXTBOX); + + parameterBox.setEnabled(!isReadOnly); parameterBox.setTitle("parameter box"); - layout.add(parameterName); - layout.add(parameterBox); - addHelp(); - parameterName.addStyleName("form-label"); - parameterBox.addStyleName("form-textbox"); + panel.add(parameterName); + panel.add(parameterBox); + addHelp(panel, description); - // binding change - parameterBox.addValueChangeHandler(new ValueChangeHandler() { + parameterBox.addValueChangeHandler(valueChangeEvent); - @Override - public void onValueChange(ValueChangeEvent event) { - value = event.getValue(); - } - }); + return panel; } private void createBooleanLayout() { @@ -766,20 +743,18 @@ private void createBooleanLayout() { addHelp(); checkBox.addStyleName("form-checkbox"); - checkBox.addValueChangeHandler(new ValueChangeHandler() { - @Override - public void onValueChange(ValueChangeEvent event) { - value = Boolean.TRUE.equals(event.getValue()) ? "true" : "false"; - } - }); + checkBox.addValueChangeHandler(event -> value = Boolean.TRUE.equals(event.getValue()) ? "true" : "false"); } private void addHelp() { - String pDescription = parameter.getDescription(); - if (pDescription != null && !pDescription.isEmpty()) { - Label pHelp = new Label(pDescription); - layout.add(pHelp); - pHelp.addStyleName("form-help"); + addHelp(layout, parameter.getDescription()); + } + + private void addHelp(FlowPanel panel, String description) { + if (StringUtils.isNotBlank(description)) { + Label pHelp = new Label(description); + panel.add(pHelp); + pHelp.addStyleName(FORM_HELP); } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/ShowJob.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/ShowJob.java index adc4acddb1..f110a1de87 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/ShowJob.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/ShowJob.java @@ -113,7 +113,7 @@ public class ShowJob extends Composite { private static final int PERIOD_MILLIS = 10000; private static final int PERIOD_MILLIS_FAST = 2000; - + private static final ClientMessages messages = GWT.create(ClientMessages.class); public static final HistoryResolver RESOLVER = new HistoryResolver() { @Override @@ -175,104 +175,72 @@ public String getHistoryToken() { return "job"; } }; - - interface MyUiBinder extends UiBinder { - } - - private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); - private static final ClientMessages messages = GWT.create(ClientMessages.class); - // empty to get all job information private static final List fieldsToReturn = new ArrayList<>(); - private static final List aipFieldsToReturn = Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.AIP_LEVEL, RodaConstants.AIP_TITLE); - - private Job job; - private Map pluginsInfo; - + private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); @UiField FlowPanel instancePanel; @UiField Label instanceLabel; - @UiField Label name; - @UiField Label creator; - @UiField HTML jobPriority; - @UiField HTML jobParallelism; - @UiField Label dateStarted; - @UiField Label dateEndedLabel, dateEnded; - @UiField Label duration; - @UiField HTML progress; - @UiField HTML status; - @UiField Label scheduleInfoLabel; - @UiField Label scheduleInfo; - @UiField Label stateDetailsLabel, stateDetailsValue; - @UiField FlowPanel selectedListPanel; - @UiField FlowPanel selectedList; - @UiField FlowPanel attachmentsPanel; - @UiField FlowPanel attachmentsList; - @UiField Label plugin; - @UiField FlowPanel pluginPanel; - @UiField FlowPanel pluginOptions; - @UiField FlowPanel reportListPanel; - @UiField Label reportsLabel; - @UiField(provided = true) SearchWrapper searchWrapper; - - // SIDEBAR - @UiField SimplePanel actionsSidebar; - @UiField FlowPanel sidebar; - @UiField FlowPanel content; + // SIDEBAR + private Job job; + private Map pluginsInfo; + private Timer autoUpdateTimer = null; + private int autoUpdateTimerPeriod = 0; + public ShowJob(Job job, Map pluginsInfo, List extraReportFilterParameters) { this.job = job; this.pluginsInfo = pluginsInfo; @@ -387,6 +355,8 @@ public void onSuccess(DistributedInstance distributedInstance) { createSelectAipLayout(parameter); } else if (PluginParameterType.USER_PROFILE.equals(parameter.getType())) { createUserProfileLayout(parameter); + } else if (PluginParameterType.CONVERSION.equals(parameter.getType())) { + createConversionLayout(parameter); } else { createStringLayout(parameter); } @@ -742,9 +712,6 @@ public void onSuccess(JobBundle jobBundle) { }); } - private Timer autoUpdateTimer = null; - private int autoUpdateTimerPeriod = 0; - private void scheduleUpdateStatus() { if (isJobRunning() || isJobRecent()) { if (autoUpdateTimer == null) { @@ -890,7 +857,8 @@ private void createPluginSipToAipLayout(PluginParameter parameter) { pluginValue.addStyleName("form-radiobutton"); } } - private void createUserProfileLayout(PluginParameter parameter){ + + private void createUserProfileLayout(PluginParameter parameter) { String value = job.getPluginParameters().get(parameter.getId()); if (value == null) { value = parameter.getDefaultValue(); @@ -924,11 +892,52 @@ private void createUserProfileLayout(PluginParameter parameter){ } } } + + private void createConversionLayout(PluginParameter parameter) { + String value = job.getPluginParameters().get(parameter.getId()); + Map map = new HashMap<>(); + String[] keyValuePairs = value.split(";"); + for (String pair : keyValuePairs) { + String[] parts = pair.split("="); + if (parts.length == 2) { + map.put(parts[0].trim(), parts[1].trim()); + } + } + + if (map.get("type").equals(RodaConstants.PLUGIN_PARAMS_CONVERSION_DISSEMINATION)) { + String title = map.get("title"); + String description = map.get("description"); + + Label titleLabel = new Label("Dissemination title"); + Label titleValue = new Label(title); + pluginOptions.add(titleLabel); + pluginOptions.add(titleValue); + titleLabel.addStyleName("label"); + + Label descriptionLabel = new Label("Dissemination description"); + Label descriptionTitle = new Label(description); + pluginOptions.add(descriptionLabel); + pluginOptions.add(descriptionTitle); + descriptionLabel.addStyleName("label"); + } else { + String representationType = map.get("value"); + Label parameterLabel = new Label("Representation type"); + Label parameterValue = new Label(representationType); + + pluginOptions.add(parameterLabel); + pluginOptions.add(parameterValue); + parameterLabel.addStyleName("label"); + } + } + private void addHelp(String description) { - if (description != null && description.length() > 0) { + if (description != null && !description.isEmpty()) { Label pHelp = new Label(description); pluginOptions.add(pHelp); pHelp.addStyleName("form-help"); } } + + interface MyUiBinder extends UiBinder { + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/model/DisseminationParameter.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/model/DisseminationParameter.java index 47d2c11081..19b76676f9 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/model/DisseminationParameter.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/model/DisseminationParameter.java @@ -1,6 +1,32 @@ package org.roda.wui.client.ingest.process.model; -public class DisseminationParameter { +public class DisseminationParameter implements PrintableParameter{ - public DisseminationParameter() {} + private String title = "Dissemination title"; + private String description = "Dissemination description"; + + public DisseminationParameter() { + // empty constructor + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String printAsParameter(String type) { + return "type=" + type + ";title=" + getTitle() + ";description=" + getDescription(); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/model/PrintableParameter.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/model/PrintableParameter.java new file mode 100644 index 0000000000..379d97b069 --- /dev/null +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/model/PrintableParameter.java @@ -0,0 +1,9 @@ +package org.roda.wui.client.ingest.process.model; + +/** + * @author Miguel GuimarĂ£es + */ +public interface PrintableParameter { + + String printAsParameter(String type); +} diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/model/RepresentationParameter.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/model/RepresentationParameter.java index 11af34f34e..d4c8a9512c 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/model/RepresentationParameter.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/model/RepresentationParameter.java @@ -1,14 +1,11 @@ package org.roda.wui.client.ingest.process.model; -public class RepresentationParameter { +public class RepresentationParameter implements PrintableParameter { private String value; public RepresentationParameter() { - } - - public RepresentationParameter(String value) { - this.value = value; + // empty constructor } public String getValue() { @@ -18,4 +15,9 @@ public String getValue() { public void setValue(String value) { this.value = value; } + + @Override + public String printAsParameter(String type) { + return "type=" + type + ";value=" + getValue(); + } }