Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
hmiguim committed Nov 21, 2023
1 parent 37afb4e commit 4265c68
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ public PluginParameter(PluginParameterBuilder builder) {
* @param readonly
* @param description
*/

/**
* @deprecated It will be removed in the next major version. Due to
* maintainability, a constructor shouldn't have to many arguments.
* Use instead the builder
* {@link #PluginParameter(PluginParameterBuilder)}
*/
public PluginParameter(String id, String name, PluginParameterType type, String defaultValue, boolean mandatory,
boolean readonly, String description) {
setId(id);
Expand All @@ -87,6 +94,12 @@ public PluginParameter(String id, String name, PluginParameterType type, String
* @param readonly
* @param description
*/
/**
* @deprecated It will be removed in the next major version. Due to
* maintainability, a constructor shouldn't have to many arguments.
* Use instead the builder
* {@link #PluginParameter(PluginParameterBuilder)}
*/
public PluginParameter(String id, String name, PluginParameterType type, String value, List<String> possibleValues,
boolean mandatory, boolean readonly, String description) {
setId(id);
Expand All @@ -107,9 +120,10 @@ public PluginParameter(String id, String name, PluginParameterType type, String
* the {@link PluginParameter} to clone.
*/
public PluginParameter(PluginParameter parameter) {
this(parameter.getId(), parameter.getName(), parameter.getType(), parameter.getDefaultValue(),
new ArrayList<>(parameter.getPossibleValues()), parameter.isMandatory(), parameter.isReadonly(),
parameter.getDescription());
this(new PluginParameterBuilder(parameter.getId(), parameter.getName(), parameter.getType())
.withDescription(parameter.getDescription()).withDefaultValue(parameter.getDefaultValue())
.withPossibleValues(parameter.getPossibleValues()).isReadOnly(parameter.isReadonly())
.isMandatory(parameter.isMandatory()));
}

/**
Expand Down Expand Up @@ -402,7 +416,7 @@ public enum PluginParameterType {
/**
* Interface to users profiles
*/
USER_PROFILE,
CONVERSION_PROFILE,

/**
* Interface to conversion plugins
Expand All @@ -423,7 +437,6 @@ public static class PluginParameterBuilder {
private boolean mandatory = true;
private boolean readOnly = false;
private String description = null;
private RenderingHints renderingHints = null;

public PluginParameterBuilder(String id, String name, PluginParameter.PluginParameterType type) {
this.id = id;
Expand Down Expand Up @@ -459,11 +472,6 @@ public PluginParameterBuilder withDescription(String description) {
this.description = description;
return this;
}

public PluginParameterBuilder withRenderingHints(RenderingHints renderingHints) {
this.renderingHints = renderingHints;
return this;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ public abstract class AbstractConvertPlugin<T extends IsRODAObject> extends Abst
"Do not process files that have a different format from the indicated."));

pluginParameters.put(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_OR_DIP,
new PluginParameter.PluginParameterBuilder(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_OR_DIP, "",
PluginParameterType.CONVERSION).build());
new PluginParameter.PluginParameterBuilder(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_OR_DIP,
"Outcome", PluginParameterType.CONVERSION)
.withDescription(
"A conversion can create a representation or a dissemination. Please choose which option to output")
.build());
}

private String inputFormat;
Expand All @@ -113,7 +116,7 @@ protected AbstractConvertPlugin() {

protected Map<String, PluginParameter> getDefaultParameters() {
return pluginParameters.entrySet().stream()
.collect(Collectors.toMap(e -> e.getKey(), e -> new PluginParameter(e.getValue())));
.collect(Collectors.toMap(Map.Entry::getKey, e -> new PluginParameter(e.getValue())));
}

protected List<PluginParameter> orderParameters(Map<String, PluginParameter> params) {
Expand Down Expand Up @@ -194,19 +197,25 @@ public void setParameterValues(Map<String, String> parameters) throws InvalidPar
}

if (parameters.containsKey(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_OR_DIP)) {
createDIP = Boolean.parseBoolean(parameters.get(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_OR_DIP));
}

if (parameters.containsKey(RodaConstants.PLUGIN_PARAMS_DISSEMINATION_TITLE)) {
dipTitle = parameters.get(RodaConstants.PLUGIN_PARAMS_DISSEMINATION_TITLE);
}

if (parameters.containsKey(RodaConstants.PLUGIN_PARAMS_DISSEMINATION_DESCRIPTION)) {
dipDescription = parameters.get(RodaConstants.PLUGIN_PARAMS_DISSEMINATION_DESCRIPTION);
}
String value = parameters.get(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_OR_DIP);

Map<String, String> 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 (parameters.containsKey(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_TYPE)) {
representationType = parameters.get(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_TYPE);
if (map.get("type").equals(RodaConstants.PLUGIN_PARAMS_CONVERSION_REPRESENTATION)) {
createDIP = false;
representationType = map.get("value");
} else {
createDIP = true;
dipTitle = map.get("title");
dipDescription = map.get("description");
}
}

hasPartialSuccessOnOutcome = Boolean.parseBoolean(RodaCoreFactory.getRodaConfigurationAsString("core", "tools",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public String getDescription() {
public List<PluginParameter> getParameters() {
ArrayList<PluginParameter> parameters = new ArrayList<>();
parameters.add(pluginParameters.get(RodaConstants.PLUGIN_PARAMS_DELETE_OLDER_THAN_X_DAYS));
parameters.add(pluginParameters.get("test"));
return parameters;
}

Expand Down
10 changes: 6 additions & 4 deletions roda-ui/roda-wui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@
<environmentVariables>
<SIEGFRIED_MODE>server</SIEGFRIED_MODE>
<SIEGFRIED_SERVER_URL>http://localhost:5138</SIEGFRIED_SERVER_URL>
<JDK_JAVA_OPTIONS>--add-opens java.base/java.util=ALL-UNNAMED</JDK_JAVA_OPTIONS>
</environmentVariables>
<skip>false</skip>
<directories>
Expand All @@ -273,7 +274,6 @@
<!-- Remove -->
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=*:5005
-Droda.environment.collect.version=false
--add-opens java.base/java.util=ALL-UNNAMED
</jvmArguments>
</configuration>
</plugin>
Expand All @@ -289,9 +289,11 @@
<skipCompilation>false</skipCompilation>
<draftCompile>true</draftCompile>
<style>PRETTY</style>
<jvmArgs>
--add-opens java.base/java.util=ALL-UNNAMED
</jvmArgs>
<environmentVariables>
<JDK_JAVA_OPTIONS>
--add-opens java.base/java.util=ALL-UNNAMED
</JDK_JAVA_OPTIONS>
</environmentVariables>
</configuration>
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7866,3 +7866,15 @@ span.code {
.ingest-tab-panel a {
font-weight: bold;
}

.conversion-profile {
display: flex;
align-items: center;
margin-bottom: 5px;
}

.conversion-profile select {
margin-right: 10px
}


Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
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;
Expand Down Expand Up @@ -44,9 +42,11 @@
import org.roda.wui.common.client.tools.StringUtils;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.DomEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.i18n.client.LocaleInfo;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
Expand Down Expand Up @@ -91,6 +91,7 @@ public PluginParameterPanel(PluginParameter parameter) {
this.parameter = parameter;

layout = new FlowPanel();

initWidget(layout);

updateLayout();
Expand Down Expand Up @@ -127,8 +128,8 @@ private void updateLayout() {
createPermissionTypesLayout();
} else if (PluginParameterType.DROPDOWN.equals(parameter.getType())) {
createDropdownLayout();
} else if (PluginParameterType.USER_PROFILE.equals(parameter.getType())) {
createUserProfileLayout();
} else if (PluginParameterType.CONVERSION_PROFILE.equals(parameter.getType())) {
createConversionProfileLayout();
} else if (PluginParameterType.CONVERSION.equals(parameter.getType())) {
createConversionLayout();
} else {
Expand Down Expand Up @@ -186,8 +187,8 @@ private void createConversionLayout() {
dropdown.setTitle(OBJECT_BOX);
layout.add(parameterName);
layout.add(dropdown);
layout.add(innerPanel);
addHelp();
layout.add(innerPanel);
}

private void setSelectedIndexAndFireEvent(final ListBox listBox, final int index) {
Expand Down Expand Up @@ -469,14 +470,16 @@ public void onSuccess(Set<Pair<String, String>> result) {
addHelp();
}

private void createUserProfileLayout() {
private void createConversionProfileLayout() {
Set<UserProfile> treeSet = new HashSet<>();
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);

FlowPanel panel = new FlowPanel();

BrowserService.Util.getInstance().retrieveUserProfilePluginItems(parameter.getId(),
LocaleInfo.getCurrentLocale().getLocaleName(), new AsyncCallback<Set<UserProfile>>() {

Expand Down Expand Up @@ -514,12 +517,14 @@ public void onSuccess(Set<UserProfile> result) {
}
});

panel.add(dropdown);
panel.add(description);
panel.addStyleName("conversion-profile");

dropdown.setTitle(OBJECT_BOX);
layout.add(parameterName);
layout.add(description);
layout.add(dropdown);

addHelp();
layout.add(panel);
}

private void createPluginObjectFieldsLayout(final String className) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.roda.core.data.common.RodaConstants;
import org.roda.core.data.exceptions.NotFoundException;
import org.roda.core.data.v2.common.UserProfile;
import org.roda.core.data.v2.index.facet.Facets;
import org.roda.core.data.v2.index.filter.Filter;
import org.roda.core.data.v2.index.filter.FilterParameter;
Expand All @@ -46,7 +43,6 @@
import org.roda.core.data.v2.jobs.PluginType;
import org.roda.core.data.v2.synchronization.central.DistributedInstance;
import org.roda.core.data.v2.synchronization.local.LocalInstance;
import org.roda.core.data.v2.user.User;
import org.roda.wui.client.browse.BrowserService;
import org.roda.wui.client.common.NoAsyncCallback;
import org.roda.wui.client.common.UserLogin;
Expand All @@ -65,7 +61,6 @@
import org.roda.wui.client.common.utils.HtmlSnippetUtils;
import org.roda.wui.client.common.utils.JavascriptUtils;
import org.roda.wui.client.common.utils.SidebarUtils;
import org.roda.wui.client.management.Statistics;
import org.roda.wui.client.management.distributed.ShowDistributedInstance;
import org.roda.wui.client.process.Process;
import org.roda.wui.common.client.HistoryResolver;
Expand Down Expand Up @@ -353,8 +348,8 @@ public void onSuccess(DistributedInstance distributedInstance) {
createPluginSipToAipLayout(parameter);
} else if (PluginParameterType.AIP_ID.equals(parameter.getType())) {
createSelectAipLayout(parameter);
} else if (PluginParameterType.USER_PROFILE.equals(parameter.getType())) {
createUserProfileLayout(parameter);
} else if (PluginParameterType.CONVERSION_PROFILE.equals(parameter.getType())) {
createConvertProfileLayout(parameter);
} else if (PluginParameterType.CONVERSION.equals(parameter.getType())) {
createConversionLayout(parameter);
} else {
Expand Down Expand Up @@ -858,7 +853,7 @@ private void createPluginSipToAipLayout(PluginParameter parameter) {
}
}

private void createUserProfileLayout(PluginParameter parameter) {
private void createConvertProfileLayout(PluginParameter parameter) {
String value = job.getPluginParameters().get(parameter.getId());
if (value == null) {
value = parameter.getDefaultValue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.roda.wui.client.ingest.process.model;

public class DisseminationParameter implements PrintableParameter{
public class DisseminationParameter implements PrintableParameter {

private String title = "Dissemination title";
private String description = "Dissemination description";
Expand Down

0 comments on commit 4265c68

Please sign in to comment.