Updated Rules
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@114370 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
28897293e4
commit
3ee14bc7f9
|
@ -254,3 +254,35 @@ Compiling...
|
||||||
Compilation completed in 0.00 seconds
|
Compilation completed in 0.00 seconds
|
||||||
Removing invalidated units
|
Removing invalidated units
|
||||||
Finding entry point classes
|
Finding entry point classes
|
||||||
|
Public resources found in...
|
||||||
|
Translatable source found in...
|
||||||
|
Found 0 cached/archived units. Used 0 / 2737 units from cache.
|
||||||
|
Compiling...
|
||||||
|
40% complete (ETR: 6 seconds)
|
||||||
|
40% complete (ETR: 6 seconds)
|
||||||
|
40% complete (ETR: 6 seconds)
|
||||||
|
40% complete (ETR: 6 seconds)
|
||||||
|
40% complete (ETR: 6 seconds)
|
||||||
|
50% complete (ETR: 5 seconds)
|
||||||
|
60% complete (ETR: 4 seconds)
|
||||||
|
70% complete (ETR: 3 seconds)
|
||||||
|
80% complete (ETR: 2 seconds)
|
||||||
|
90% complete (ETR: 1 seconds)
|
||||||
|
100% complete (ETR: 0 seconds)
|
||||||
|
Compilation completed in 15.84 seconds
|
||||||
|
Removing invalidated units
|
||||||
|
Finding entry point classes
|
||||||
|
Public resources found in...
|
||||||
|
Translatable source found in...
|
||||||
|
Found 2737 cached/archived units. Used 2737 / 2737 units from cache.
|
||||||
|
Compiling...
|
||||||
|
Compilation completed in 0.00 seconds
|
||||||
|
Removing invalidated units
|
||||||
|
Finding entry point classes
|
||||||
|
Public resources found in...
|
||||||
|
Translatable source found in...
|
||||||
|
Found 2737 cached/archived units. Used 2737 / 2737 units from cache.
|
||||||
|
Compiling...
|
||||||
|
Compilation completed in 0.00 seconds
|
||||||
|
Removing invalidated units
|
||||||
|
Finding entry point classes
|
||||||
|
|
|
@ -0,0 +1,161 @@
|
||||||
|
package org.gcube.portlets.user.td.expressionwidget.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.notification.RuleEditDialogNotification;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.notification.RuleEditDialogNotification.HasRuleEditDialogNotificationListener;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.notification.RuleEditDialogNotification.RuleEditDialogNotificationListener;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
import com.sencha.gxt.widget.core.client.Window;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class RuleEditDialog extends Window implements
|
||||||
|
HasRuleEditDialogNotificationListener {
|
||||||
|
private static final String WIDTH = "660px";
|
||||||
|
private static final String HEIGHT = "200px";
|
||||||
|
private RuleEditPanel ruleEditPanel;
|
||||||
|
private EventBus eventBus;
|
||||||
|
private ArrayList<RuleEditDialogNotificationListener> listeners;
|
||||||
|
public RuleEditDialog(RuleDescriptionData ruleDescriptionData, EventBus eventBus) {
|
||||||
|
listeners = new ArrayList<RuleEditDialogNotificationListener>();
|
||||||
|
initWindow();
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
ruleEditPanel = new RuleEditPanel(this,
|
||||||
|
ruleDescriptionData, eventBus);
|
||||||
|
add(ruleEditPanel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initWindow() {
|
||||||
|
setWidth(WIDTH);
|
||||||
|
setHeight(HEIGHT);
|
||||||
|
setBodyBorder(false);
|
||||||
|
setResizable(false);
|
||||||
|
setHeadingText("Edit Rule On Column");
|
||||||
|
setClosable(true);
|
||||||
|
setModal(true);
|
||||||
|
forceLayoutOnResize = true;
|
||||||
|
getHeader().setIcon(ExpressionResources.INSTANCE.ruleEdit());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void initTools() {
|
||||||
|
super.initTools();
|
||||||
|
|
||||||
|
closeBtn.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void close() {
|
||||||
|
fireAborted();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateColumnRule(RuleDescriptionData ruleDescriptionData) {
|
||||||
|
Log.debug("RuleDescriptionData: " + ruleDescriptionData);
|
||||||
|
updateColumnRuleCall(ruleDescriptionData);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateColumnRuleCall(RuleDescriptionData ruleDescriptionData) {
|
||||||
|
|
||||||
|
ExpressionServiceAsync.INSTANCE.updateColumnRule(ruleDescriptionData,
|
||||||
|
new AsyncCallback<Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Void v) {
|
||||||
|
Log.debug("Updated Rule: ");
|
||||||
|
UtilsGXT3.info("Update Rule", "The rule is updated!");
|
||||||
|
fireNotification();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
if (caught instanceof TDGWTSessionExpiredException) {
|
||||||
|
eventBus.fireEvent(new SessionExpiredEvent(
|
||||||
|
SessionExpiredType.EXPIREDONSERVER));
|
||||||
|
} else {
|
||||||
|
Log.error("Error updating column rule: "
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
|
caught.printStackTrace();
|
||||||
|
UtilsGXT3.alert("Error updating column rule",
|
||||||
|
caught.getLocalizedMessage());
|
||||||
|
|
||||||
|
fireFailed(caught);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addRuleEditDialogNotificationListener(
|
||||||
|
RuleEditDialogNotificationListener handler) {
|
||||||
|
listeners.add(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeRuleEditDialogNotificationListener(
|
||||||
|
RuleEditDialogNotificationListener handler) {
|
||||||
|
listeners.remove(handler);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fireNotification() {
|
||||||
|
if (listeners != null) {
|
||||||
|
for (RuleEditDialogNotificationListener listener : listeners) {
|
||||||
|
listener.onNotification(new RuleEditDialogNotification());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fireAborted() {
|
||||||
|
if (listeners != null) {
|
||||||
|
for (RuleEditDialogNotificationListener listener : listeners) {
|
||||||
|
listener.aborted();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fireFailed(Throwable caught) {
|
||||||
|
if (listeners != null) {
|
||||||
|
for (RuleEditDialogNotificationListener listener : listeners) {
|
||||||
|
listener.failed(caught);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hide();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,176 @@
|
||||||
|
package org.gcube.portlets.user.td.expressionwidget.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
||||||
|
import com.sencha.gxt.core.client.util.Margins;
|
||||||
|
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||||
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.FieldSet;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.TextArea;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class RuleEditPanel extends FramedPanel {
|
||||||
|
private static final String RULE_DESCRIPTION_HEIGHT = "44px";
|
||||||
|
private static final String WIDTH = "648px";
|
||||||
|
private static final String HEIGHT = "104px";
|
||||||
|
|
||||||
|
private TextButton btnUpdate;
|
||||||
|
private TextButton btnClose;
|
||||||
|
|
||||||
|
private RuleEditDialog parentRuleEditDialog;
|
||||||
|
|
||||||
|
private RuleDescriptionData initialRuleDescriptionData;
|
||||||
|
|
||||||
|
private TextField ruleName;
|
||||||
|
private TextArea ruleDescription;
|
||||||
|
|
||||||
|
public RuleEditPanel(RuleEditDialog ruleEditDialog,
|
||||||
|
RuleDescriptionData ruleDescriptionData, EventBus eventBus) {
|
||||||
|
super();
|
||||||
|
setWidth(WIDTH);
|
||||||
|
setHeight(HEIGHT);
|
||||||
|
this.parentRuleEditDialog = ruleEditDialog;
|
||||||
|
this.initialRuleDescriptionData = ruleDescriptionData;
|
||||||
|
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void create() {
|
||||||
|
forceLayoutOnResize = true;
|
||||||
|
|
||||||
|
setBodyBorder(false);
|
||||||
|
setHeaderVisible(false);
|
||||||
|
|
||||||
|
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
|
||||||
|
basicLayout.setAdjustForScroll(true);
|
||||||
|
|
||||||
|
FieldSet properties = null;
|
||||||
|
VerticalLayoutContainer propertiesLayout;
|
||||||
|
|
||||||
|
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
|
||||||
|
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||||
|
flowButton.setPack(BoxLayoutPack.CENTER);
|
||||||
|
|
||||||
|
properties = new FieldSet();
|
||||||
|
properties.setHeadingText("Properties");
|
||||||
|
properties.setCollapsible(false);
|
||||||
|
|
||||||
|
propertiesLayout = new VerticalLayoutContainer();
|
||||||
|
properties.add(propertiesLayout);
|
||||||
|
|
||||||
|
createColumnMockUp(propertiesLayout);
|
||||||
|
|
||||||
|
btnUpdate = new TextButton("Save");
|
||||||
|
btnUpdate.setIcon(ExpressionResources.INSTANCE.ruleEdit());
|
||||||
|
btnUpdate.setIconAlign(IconAlign.RIGHT);
|
||||||
|
btnUpdate.setToolTip("Save rule decription");
|
||||||
|
btnUpdate.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
Log.debug("Pressed Update");
|
||||||
|
updateRuleDescription();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnClose = new TextButton("Close");
|
||||||
|
btnClose.setIcon(ExpressionResources.INSTANCE.close());
|
||||||
|
btnClose.setIconAlign(IconAlign.RIGHT);
|
||||||
|
btnClose.setToolTip("Cancel rule");
|
||||||
|
btnClose.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
Log.debug("Pressed Close");
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
flowButton.add(btnUpdate, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||||
|
|
||||||
|
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||||
|
|
||||||
|
basicLayout.add(properties, new VerticalLayoutData(1, -1,
|
||||||
|
new Margins(1)));
|
||||||
|
basicLayout.add(flowButton, new VerticalLayoutData(1, 36, new Margins(
|
||||||
|
5, 2, 5, 2)));
|
||||||
|
add(basicLayout);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateRuleDescription() {
|
||||||
|
String name=ruleName.getCurrentValue();
|
||||||
|
if(name==null|| name.isEmpty()){
|
||||||
|
Log.debug("Attention, enter a valid name for the rule!");
|
||||||
|
UtilsGXT3.alert("Attention",
|
||||||
|
"Enter a valid name for the rule!");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
String description=ruleDescription.getCurrentValue();
|
||||||
|
if(description==null|| description.isEmpty()){
|
||||||
|
Log.debug("Attention, enter a valid description for the rule!");
|
||||||
|
UtilsGXT3.alert("Attention",
|
||||||
|
"Enter a valid description for the rule!");
|
||||||
|
} else {
|
||||||
|
initialRuleDescriptionData.setName(name);
|
||||||
|
initialRuleDescriptionData.setDescription(description);
|
||||||
|
parentRuleEditDialog.updateColumnRule(initialRuleDescriptionData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void createColumnMockUp(VerticalLayoutContainer propertiesLayout) {
|
||||||
|
ruleName = new TextField();
|
||||||
|
ruleName.setToolTip("Rule Name");
|
||||||
|
if (initialRuleDescriptionData != null) {
|
||||||
|
ruleName.setValue(initialRuleDescriptionData.getName());
|
||||||
|
}
|
||||||
|
FieldLabel ruleNameLabel = new FieldLabel(ruleName, "Rule Name");
|
||||||
|
|
||||||
|
ruleDescription = new TextArea();
|
||||||
|
ruleDescription.setHeight(RULE_DESCRIPTION_HEIGHT);
|
||||||
|
ruleDescription.setToolTip("Rule Description");
|
||||||
|
if (initialRuleDescriptionData != null) {
|
||||||
|
ruleDescription.setValue(initialRuleDescriptionData
|
||||||
|
.getDescription());
|
||||||
|
}
|
||||||
|
FieldLabel ruleDescriptionLabel = new FieldLabel(ruleDescription,
|
||||||
|
"Rule Description");
|
||||||
|
|
||||||
|
propertiesLayout.add(ruleNameLabel, new VerticalLayoutData(1, -1,
|
||||||
|
new Margins(0)));
|
||||||
|
propertiesLayout.add(ruleDescriptionLabel, new VerticalLayoutData(1,
|
||||||
|
-1, new Margins(0)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void close() {
|
||||||
|
if (parentRuleEditDialog != null) {
|
||||||
|
parentRuleEditDialog.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package org.gcube.portlets.user.td.expressionwidget.client.notification;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class RuleEditDialogNotification {
|
||||||
|
|
||||||
|
|
||||||
|
public interface RuleEditDialogNotificationListener {
|
||||||
|
void onNotification(RuleEditDialogNotification ruleEditDialogNotification);
|
||||||
|
|
||||||
|
void aborted();
|
||||||
|
|
||||||
|
void failed(Throwable throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface HasRuleEditDialogNotificationListener {
|
||||||
|
public void addRuleEditDialogNotificationListener(
|
||||||
|
RuleEditDialogNotificationListener handler);
|
||||||
|
|
||||||
|
public void removeRuleEditDialogNotificationListener(
|
||||||
|
RuleEditDialogNotificationListener handler);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public RuleEditDialogNotification() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "RuleEditDialogNotification []";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ package org.gcube.portlets.user.td.expressionwidget.client.resources;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.resources.client.ClientBundle;
|
import com.google.gwt.resources.client.ClientBundle;
|
||||||
import com.google.gwt.resources.client.ImageResource;
|
import com.google.gwt.resources.client.ImageResource;
|
||||||
|
import com.google.gwt.resources.client.ClientBundle.Source;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,6 +36,13 @@ public interface ExpressionResources extends ClientBundle {
|
||||||
@Source("rule-add_32.png")
|
@Source("rule-add_32.png")
|
||||||
ImageResource ruleAdd32();
|
ImageResource ruleAdd32();
|
||||||
|
|
||||||
|
@Source("rule-edit_32.png")
|
||||||
|
ImageResource ruleEdit32();
|
||||||
|
|
||||||
|
@Source("rule-edit.png")
|
||||||
|
ImageResource ruleEdit();
|
||||||
|
|
||||||
|
|
||||||
@Source("rule-column-add.png")
|
@Source("rule-column-add.png")
|
||||||
ImageResource ruleColumnAdd();
|
ImageResource ruleColumnAdd();
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 839 B |
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
|
@ -66,6 +66,9 @@ public interface ExpressionService extends RemoteService {
|
||||||
public String saveColumnRule(RuleDescriptionData ruleDescriptionData)
|
public String saveColumnRule(RuleDescriptionData ruleDescriptionData)
|
||||||
throws TDGWTServiceException;
|
throws TDGWTServiceException;
|
||||||
|
|
||||||
|
public void updateColumnRule(RuleDescriptionData ruleDescriptionData)
|
||||||
|
throws TDGWTServiceException;
|
||||||
|
|
||||||
public void removeRulesById(ArrayList<RuleDescriptionData> rules) throws TDGWTServiceException;
|
public void removeRulesById(ArrayList<RuleDescriptionData> rules) throws TDGWTServiceException;
|
||||||
|
|
||||||
public String startApplyAndDetachColumnRules(ApplyAndDetachColumnRulesSession applyColumnRulesSession)
|
public String startApplyAndDetachColumnRules(ApplyAndDetachColumnRulesSession applyColumnRulesSession)
|
||||||
|
|
|
@ -52,6 +52,9 @@ public interface ExpressionServiceAsync {
|
||||||
void saveColumnRule(RuleDescriptionData ruleDescriptionData,
|
void saveColumnRule(RuleDescriptionData ruleDescriptionData,
|
||||||
AsyncCallback<String> callback);
|
AsyncCallback<String> callback);
|
||||||
|
|
||||||
|
void updateColumnRule(RuleDescriptionData ruleDescriptionData,
|
||||||
|
AsyncCallback<Void> callback);
|
||||||
|
|
||||||
void removeRulesById(ArrayList<RuleDescriptionData> rules,
|
void removeRulesById(ArrayList<RuleDescriptionData> rules,
|
||||||
AsyncCallback<Void> callback);
|
AsyncCallback<Void> callback);
|
||||||
|
|
||||||
|
|
|
@ -507,6 +507,55 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateColumnRule(RuleDescriptionData ruleDescriptionData)
|
||||||
|
throws TDGWTServiceException {
|
||||||
|
try {
|
||||||
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
|
||||||
|
logger.debug("UpdateColumnRule() :" + ruleDescriptionData);
|
||||||
|
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||||
|
aslSession.getUsername(), aslSession.getScope()));
|
||||||
|
TabularDataService service = TabularDataServiceFactory.getService();
|
||||||
|
|
||||||
|
RuleDescription ruleDescription=RuleDescriptionMap.map(ruleDescriptionData);
|
||||||
|
|
||||||
|
if(ruleDescription==null){
|
||||||
|
logger.error("Error in rule description: null!");
|
||||||
|
throw new TDGWTServiceException("Error in rule description: null!");
|
||||||
|
}
|
||||||
|
|
||||||
|
service.updateColumnRule(
|
||||||
|
ruleDescription);
|
||||||
|
|
||||||
|
logger.debug("Rule updated");
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
} catch (TDGWTServiceException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
throw e;
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
|
} catch (Throwable e) {
|
||||||
|
logger.error("Error in getRule(): " + e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new TDGWTServiceException("Error retrieving the rules: "
|
||||||
|
+ e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package org.gcube.portlets.user.td.expressionwidget.server.service.rule;
|
package org.gcube.portlets.user.td.expressionwidget.server.service.rule;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.data.analysis.tabulardata.commons.rules.types.RuleColumnType;
|
||||||
import org.gcube.data.analysis.tabulardata.commons.webservice.types.RuleDescription;
|
import org.gcube.data.analysis.tabulardata.commons.webservice.types.RuleDescription;
|
||||||
import org.gcube.data.analysis.tabulardata.expression.Expression;
|
import org.gcube.data.analysis.tabulardata.expression.Expression;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.server.C_ExpressionParser;
|
import org.gcube.portlets.user.td.expressionwidget.server.C_ExpressionParser;
|
||||||
|
@ -17,11 +16,10 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expressi
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author "Giancarlo Panichi"
|
* @author "Giancarlo Panichi" <a
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RuleDescriptionMap {
|
public class RuleDescriptionMap {
|
||||||
|
@ -30,7 +28,6 @@ public class RuleDescriptionMap {
|
||||||
|
|
||||||
private static final String SECURITY_EXCEPTION_RIGHTS = "Security exception, you don't have the required rights!";
|
private static final String SECURITY_EXCEPTION_RIGHTS = "Security exception, you don't have the required rights!";
|
||||||
|
|
||||||
|
|
||||||
public static RuleDescriptionData map(RuleDescription ruleDescription)
|
public static RuleDescriptionData map(RuleDescription ruleDescription)
|
||||||
throws TDGWTServiceException, ExpressionParserException {
|
throws TDGWTServiceException, ExpressionParserException {
|
||||||
RuleDescriptionData ruleDescriptionData = null;
|
RuleDescriptionData ruleDescriptionData = null;
|
||||||
|
@ -40,19 +37,17 @@ public class RuleDescriptionMap {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (ruleDescription.getScope() == null) {
|
if (ruleDescription.getScope() == null) {
|
||||||
logger.error("Rule description has scope null");
|
logger.error("Rule description has scope null");
|
||||||
throw new TDGWTServiceException("Rule description has scope null");
|
throw new TDGWTServiceException("Rule description has scope null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch (ruleDescription.getScope()) {
|
switch (ruleDescription.getScope()) {
|
||||||
case COLUMN:
|
case COLUMN:
|
||||||
ruleDescriptionData=createColumnRule(ruleDescription);
|
ruleDescriptionData = createColumnRuleDescriptionData(ruleDescription);
|
||||||
break;
|
break;
|
||||||
case TABLE:
|
case TABLE:
|
||||||
ruleDescriptionData=createTableRule(ruleDescription);
|
ruleDescriptionData = createTableRuleDescriptionData(ruleDescription);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -62,14 +57,12 @@ public class RuleDescriptionMap {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static RuleDescriptionData createTableRuleDescriptionData(
|
||||||
private static RuleDescriptionData createTableRule(
|
|
||||||
RuleDescription ruleDescription) {
|
RuleDescription ruleDescription) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static RuleDescriptionData createColumnRuleDescriptionData(
|
||||||
private static RuleDescriptionData createColumnRule(
|
|
||||||
RuleDescription ruleDescription) throws ExpressionParserException,
|
RuleDescription ruleDescription) throws ExpressionParserException,
|
||||||
TDGWTServiceException {
|
TDGWTServiceException {
|
||||||
|
|
||||||
|
@ -86,23 +79,19 @@ public class RuleDescriptionMap {
|
||||||
|
|
||||||
RuleDescriptionData ruleData = new RuleDescriptionData(
|
RuleDescriptionData ruleData = new RuleDescriptionData(
|
||||||
ruleDescription.getId(), ruleDescription.getName(),
|
ruleDescription.getId(), ruleDescription.getName(),
|
||||||
ruleDescription.getDescription(),
|
ruleDescription.getDescription(), owner, contacts,
|
||||||
owner, contacts,
|
RuleScopeMap.map(ruleDescription.getScope()), tdRuleColumnType,
|
||||||
RuleScopeMap.map(ruleDescription.getScope()),
|
cexp);
|
||||||
tdRuleColumnType, cexp);
|
|
||||||
|
|
||||||
return ruleData;
|
return ruleData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static ArrayList<Contacts> retrieveRuleShareInfo(
|
private static ArrayList<Contacts> retrieveRuleShareInfo(
|
||||||
RuleDescription ruleDescription)
|
RuleDescription ruleDescription) throws TDGWTServiceException {
|
||||||
throws TDGWTServiceException {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ArrayList<Contacts> contacts = new ArrayList<Contacts>();
|
ArrayList<Contacts> contacts = new ArrayList<Contacts>();
|
||||||
List<String> sharedWithUsers = ruleDescription
|
List<String> sharedWithUsers = ruleDescription.getSharedWithUsers();
|
||||||
.getSharedWithUsers();
|
|
||||||
logger.debug("Shared with Users: " + sharedWithUsers);
|
logger.debug("Shared with Users: " + sharedWithUsers);
|
||||||
if (sharedWithUsers != null) {
|
if (sharedWithUsers != null) {
|
||||||
for (String user : sharedWithUsers) {
|
for (String user : sharedWithUsers) {
|
||||||
|
@ -132,5 +121,73 @@ public class RuleDescriptionMap {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RuleDescription map(RuleDescriptionData ruleDescriptionData)
|
||||||
|
throws TDGWTServiceException {
|
||||||
|
RuleDescription ruleDescription = null;
|
||||||
|
if (ruleDescriptionData == null) {
|
||||||
|
logger.error("Rule description data is null");
|
||||||
|
throw new TDGWTServiceException("Rule description is null");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ruleDescriptionData.getScope() == null) {
|
||||||
|
logger.error("Rule description data has scope null");
|
||||||
|
throw new TDGWTServiceException("Rule description has scope null");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (ruleDescriptionData.getScope()) {
|
||||||
|
case COLUMN:
|
||||||
|
ruleDescription = createColumnRuleDescription(ruleDescriptionData);
|
||||||
|
break;
|
||||||
|
case TABLE:
|
||||||
|
ruleDescription = createTableRuleDescription(ruleDescriptionData);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ruleDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static RuleDescription createColumnRuleDescription(
|
||||||
|
RuleDescriptionData ruleDescriptionData)
|
||||||
|
throws TDGWTServiceException {
|
||||||
|
|
||||||
|
C_ExpressionParser parser = new C_ExpressionParser();
|
||||||
|
|
||||||
|
Expression conditionExpression = null;
|
||||||
|
try {
|
||||||
|
conditionExpression = parser.parse(ruleDescriptionData
|
||||||
|
.getExpression());
|
||||||
|
} catch (ExpressionParserException e) {
|
||||||
|
logger.debug(e.getLocalizedMessage());
|
||||||
|
throw new TDGWTServiceException(e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("Service Condition Expression:" + conditionExpression);
|
||||||
|
|
||||||
|
RuleColumnType ruleColumnType = RuleColumnTypeMap
|
||||||
|
.map(ruleDescriptionData.getTdRuleColumnType());
|
||||||
|
if (ruleColumnType == null) {
|
||||||
|
logger.debug("Error saving rule: rule column type is null!");
|
||||||
|
throw new TDGWTServiceException(
|
||||||
|
"Error saving rule: rule column type is null!");
|
||||||
|
}
|
||||||
|
|
||||||
|
RuleDescription ruleDescription=new RuleDescription(ruleDescriptionData.getId(),
|
||||||
|
ruleDescriptionData.getName(),
|
||||||
|
ruleDescriptionData.getDescription(), conditionExpression,RuleScopeMap.map(ruleDescriptionData.getScope()),
|
||||||
|
ruleDescriptionData.getOwnerLogin(),
|
||||||
|
ruleColumnType,
|
||||||
|
ruleDescriptionData.getContactsAsStringList());
|
||||||
|
|
||||||
|
return ruleDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static RuleDescription createTableRuleDescription(
|
||||||
|
RuleDescriptionData ruleDescriptionData) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 839 B |
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in New Issue