Skip to content

Commit

Permalink
Joined profile with the conversion parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioG70 authored and hmiguim committed Jan 22, 2024
1 parent 71d5333 commit ca3a912
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ public enum OrchestratorType {
public static final String PLUGIN_PARAMS_OUTPUT_FORMAT = "parameter.output_format";
public static final String PLUGIN_PARAMS_COMMAND_ARGUMENTS = "parameter.command_arguments";
public static final String PLUGIN_PARAMS_OUTPUT_ARGUMENTS = "parameter.output_arguments";

public static final String PLUGIN_PARAMS_CONVERSION_PROFILE = "parameter.conversion_profile";
public static final String PLUGIN_PARAMS_DO_REPORT = "parameter.do_report";
public static final String PLUGIN_PARAMS_REPORTING_CLASS = "parameter.reporting_class";
public static final String PLUGIN_PARAMS_HAS_COMPRESSION = "parameter.has_compression";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class UserProfile implements Serializable {
private String i18nProperty;
private String profile;
private String description;
private boolean dissemination;
private boolean representation;
private Map<String, String> options;

public UserProfile() {
Expand All @@ -41,6 +43,22 @@ public void setOptions(Map<String, String> options) {
this.options = options;
}

public void setHasRepresentation(boolean representation) {
this.representation = representation;
}

public void setHasDissemination(boolean dissemination) {
this.dissemination = dissemination;
}

public boolean isDissemination() {
return dissemination;
}

public boolean isRepresentation() {
return representation;
}

public String getI18nProperty() {
return i18nProperty;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void rejectJob(SelectedItems<Job> jobs, String details) throws RequestNotValidEx

Set<Pair<String, String>> retrieveDropdownPluginItems(String parameterId, String localeString);

Set<UserProfile> retrieveUserProfilePluginItems(String parameterId, String localeString);
Set<UserProfile> retrieveUserProfilePluginItems(String pluginId, String repOrDip, String localeString);

CreateIngestJobBundle retrieveCreateIngestProcessBundle();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void createTransferredResourcesFolder(String parent, String folderName, boolean
void retrieveDropdownPluginItems(String parameterId, String localeString,
AsyncCallback<Set<Pair<String, String>>> asyncCallback);

void retrieveUserProfilePluginItems(String parameterId, String localeString,
void retrieveUserProfilePluginItems(String pluginId, String repOrDip, String localeString,
AsyncCallback<Set<UserProfile>> asyncCallback);

void retrieveCreateIngestProcessBundle(AsyncCallback<CreateIngestJobBundle> callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ private void update() {
layout.clear();

if (pluginInfo != null) {

for (PluginParameter parameter : pluginInfo.getParameters()) {
PluginParameterPanel panel = new PluginParameterPanel(parameter);
PluginParameterPanel panel = new PluginParameterPanel(parameter, pluginInfo.getId());
panels.add(panel);
layout.add(panel);
}
Expand Down Expand Up @@ -71,6 +70,7 @@ public Map<String, String> getValue() {
ret.put(key,
panel.getRepresentationParameter().printAsParameter(RodaConstants.PLUGIN_PARAMS_CONVERSION_REPRESENTATION));
}
ret.put(RodaConstants.PLUGIN_PARAMS_CONVERSION_PROFILE, panel.getProfile());
} else {
String value = panel.getValue();
if (value != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,29 @@
import java.util.Set;
import java.util.TreeSet;

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;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.IntegerBox;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.TextBox;
import config.i18n.client.ClientMessages;
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 @@ -41,31 +64,6 @@
import org.roda.wui.common.client.tools.DescriptionLevelUtils;
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;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.IntegerBox;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.TextBox;

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";
Expand All @@ -83,13 +81,32 @@ public class PluginParameterPanel extends Composite {
private final RepresentationParameter representationParameter = new RepresentationParameter();
private final DisseminationParameter disseminationParameter = new DisseminationParameter();
private String value;
private String profile;
private final String pluginId;
private String aipTitle;
private boolean conversionPanel = false;

public PluginParameterPanel(PluginParameter parameter) {
super();
this.parameter = parameter;

this.pluginId = null;

layout = new FlowPanel();

initWidget(layout);

updateLayout();

layout.addStyleName("plugin-options-parameter");
}

public PluginParameterPanel(PluginParameter parameter, String pluginId) {
super();
this.parameter = parameter;

this.pluginId = pluginId;

layout = new FlowPanel();

initWidget(layout);
Expand Down Expand Up @@ -128,8 +145,6 @@ private void updateLayout() {
createPermissionTypesLayout();
} else if (PluginParameterType.DROPDOWN.equals(parameter.getType())) {
createDropdownLayout();
} else if (PluginParameterType.CONVERSION_PROFILE.equals(parameter.getType())) {
createConversionProfileLayout();
} else if (PluginParameterType.CONVERSION.equals(parameter.getType())) {
createConversionLayout();
} else {
Expand All @@ -153,9 +168,11 @@ private void createConversionLayout() {
FlowPanel innerPanel = new FlowPanel();
dropdown.addChangeHandler(event -> {
value = dropdown.getSelectedValue();
innerPanel.clear();
FlowPanel profiles = createConversionProfileLayout(value, pluginId);
innerPanel.add(profiles);

if (value.equals(RodaConstants.PLUGIN_PARAMS_CONVERSION_REPRESENTATION)) {
// Clear the layout
innerPanel.clear();
// Add fields
ValueChangeHandler<String> typeChanged = typeChangedEvent -> representationParameter
.setValue(typeChangedEvent.getValue());
Expand All @@ -165,8 +182,6 @@ private void createConversionLayout() {

value = RodaConstants.PLUGIN_PARAMS_CONVERSION_REPRESENTATION;
} else {
// Clear the layout
innerPanel.clear();
// Add fields
ValueChangeHandler<String> titleChanged = titleChangedEvent -> disseminationParameter
.setTitle(titleChangedEvent.getValue());
Expand Down Expand Up @@ -470,17 +485,18 @@ public void onSuccess(Set<Pair<String, String>> result) {
addHelp();
}

private void createConversionProfileLayout() {
private FlowPanel createConversionProfileLayout(String repOrDip, String pluginId) {
Set<UserProfile> treeSet = new HashSet<>();
Label parameterName = new Label(parameter.getName());
Label parameterName = new Label("Conversion Profile");
final Label description = new Label();
final ListBox dropdown = new ListBox();
dropdown.addStyleName(FORM_SELECTBOX);
dropdown.addStyleName(FORM_TEXTBOX_SMALL);

FlowPanel result = new FlowPanel();
FlowPanel panel = new FlowPanel();

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

@Override
Expand All @@ -497,9 +513,9 @@ public void onSuccess(Set<UserProfile> result) {
description.addStyleName(FORM_HELP);
}

value = dropdown.getSelectedValue();
profile = dropdown.getSelectedValue();
for (UserProfile userProfile : treeSet) {
if (userProfile.getProfile().equals(value)) {
if (userProfile.getProfile().equals(profile)) {
description.setText(userProfile.getDescription());
break;
}
Expand All @@ -508,9 +524,9 @@ public void onSuccess(Set<UserProfile> result) {
});

dropdown.addChangeHandler(event -> {
value = dropdown.getSelectedValue();
profile = dropdown.getSelectedValue();
for (UserProfile userProfile : treeSet) {
if (userProfile.getProfile().equals(value)) {
if (userProfile.getProfile().equals(profile)) {
description.setText(userProfile.getDescription());
break;
}
Expand All @@ -522,9 +538,10 @@ public void onSuccess(Set<UserProfile> result) {
panel.addStyleName("conversion-profile");

dropdown.setTitle(OBJECT_BOX);
layout.add(parameterName);
addHelp();
layout.add(panel);
result.add(parameterName);
addHelp(result, "User profile options");
result.add(panel);
return result;
}

private void createPluginObjectFieldsLayout(final String className) {
Expand Down Expand Up @@ -763,6 +780,10 @@ private void addHelp(FlowPanel panel, String description) {
}
}

public String getProfile() {
return profile;
}

public String getValue() {
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,18 +617,23 @@ public Set<Pair<String, String>> retrieveDropdownPluginItems(String parameterId,
}

@Override
public Set<UserProfile> retrieveUserProfilePluginItems(String parameterId, String localeString) {
public Set<UserProfile> retrieveUserProfilePluginItems(String pluginId, String repOrDip, String localeString) {
Set<UserProfile> items = new HashSet<>();

List<String> dropdownItems = RodaUtils
.copyList(RodaCoreFactory.getRodaConfiguration().getList("core.plugins.user_profile." + parameterId + "[]"));
.copyList(RodaCoreFactory.getRodaConfiguration().getList("core.plugins.user_profile." + pluginId + "[]"));
Locale locale = ServerTools.parseLocale(localeString);
Messages messages = RodaCoreFactory.getI18NMessages(locale);

String pluginName = RodaCoreFactory.getRodaConfiguration().getString("core.plugins.user_profile." + parameterId);
String pluginName = RodaCoreFactory.getRodaConfiguration().getString("core.plugins.user_profile." + pluginId);

for (String item : dropdownItems) {
items.add(retrieveUserProfileItem(item, pluginName, items, messages));
UserProfile userProfile = retrieveUserProfileItem(item, pluginName, items, messages);
if (repOrDip.equals(RodaConstants.PLUGIN_PARAMS_CONVERSION_REPRESENTATION) && userProfile.isRepresentation()) {
items.add(userProfile);
} else if (repOrDip.equals(RodaConstants.PLUGIN_PARAMS_CONVERSION_DISSEMINATION) && userProfile.isDissemination()) {
items.add(userProfile);
}
}

return items;
Expand All @@ -642,6 +647,10 @@ private UserProfile retrieveUserProfileItem(String item, String pluginName, Set<
.getString("core.plugins." + pluginName + "." + item + ".title"));
userProfile.setDescription(RodaCoreFactory.getRodaConfiguration()
.getString("core.plugins." + pluginName + "." + item + ".description"));
userProfile.setHasRepresentation(RodaCoreFactory.getRodaConfiguration()
.getBoolean("core.plugins." + pluginName + "." + item + ".representation"));
userProfile.setHasDissemination(RodaCoreFactory.getRodaConfiguration()
.getBoolean("core.plugins." + pluginName + "." + item + ".dissemination"));
userProfile.setProfile(item);

String[] options = RodaCoreFactory.getRodaConfiguration().getStringArray("core.plugins." + pluginName + "." + item + ".options[]");
Expand Down

0 comments on commit ca3a912

Please sign in to comment.