From c78f094b765d0e8d55f15f44d6f21a51cc71417b Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 12 Sep 2014 16:54:37 +0000 Subject: [PATCH] Added Replace Column By Expression git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@99819 82a268e6-3cf1-43bd-a215-b396298e98cf --- .settings/com.google.gdt.eclipse.core.prefs | 2 +- .settings/org.eclipse.wst.validation.prefs | 2 + pom.xml | 17 +- .../client/ExpressionWidgetEntry.java | 16 +- .../ReplaceColumnByExpressionDialog.java | 247 ++++++++++++++++++ .../ReplaceColumnByExpressionPanel.java | 174 ++++++++++++ .../client/resources/ExpressionResources.java | 6 + .../column-replace-by-expression.png | Bin 0 -> 799 bytes .../column-replace-by-expression_32.png | Bin 0 -> 1499 bytes .../client/rpc/ExpressionService.java | 5 +- .../client/rpc/ExpressionServiceAsync.java | 3 + .../server/ExpressionServiceImpl.java | 149 +++-------- .../server/ExpressionSession.java | 29 ++ .../td/expressionwidget/shared/Constants.java | 8 +- .../expressionwidget/ExpressionWidget.gwt.xml | 2 +- .../column-replace-by-expression.png | Bin 0 -> 799 bytes .../column-replace-by-expression_32.png | Bin 0 -> 1499 bytes 17 files changed, 538 insertions(+), 122 deletions(-) create mode 100644 .settings/org.eclipse.wst.validation.prefs create mode 100644 src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionDialog.java create mode 100644 src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionPanel.java create mode 100644 src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/column-replace-by-expression.png create mode 100644 src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/column-replace-by-expression_32.png create mode 100644 src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/resources/column-replace-by-expression.png create mode 100644 src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/resources/column-replace-by-expression_32.png diff --git a/.settings/com.google.gdt.eclipse.core.prefs b/.settings/com.google.gdt.eclipse.core.prefs index 3e27203..03a47ff 100644 --- a/.settings/com.google.gdt.eclipse.core.prefs +++ b/.settings/com.google.gdt.eclipse.core.prefs @@ -1,5 +1,5 @@ eclipse.preferences.version=1 jarsExcludedFromWebInfLib= -lastWarOutDir=/home/giancarlo/workspace/tabular-data-expression-widget/target/tabular-data-expression-widget-1.0.0-SNAPSHOT +lastWarOutDir=/home/giancarlo/workspace/tabular-data-expression-widget/target/tabular-data-expression-widget-1.3.0-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 0000000..04cad8c --- /dev/null +++ b/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,2 @@ +disabled=06target +eclipse.preferences.version=1 diff --git a/pom.xml b/pom.xml index 76662e8..ac1d9a0 100644 --- a/pom.xml +++ b/pom.xml @@ -45,9 +45,9 @@ 2.5.1 - + ${env.KEYS} - + UTF-8 UTF-8 @@ -70,6 +70,17 @@ 1.0.1 runtime + + org.gcube.common + home-library + compile + + + org.gcube.core + common-scope-maps + [1.0.2-SNAPSHOT,2.0.0-SNAPSHOT) + compile + @@ -133,7 +144,7 @@ [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) provided - + org.gcube.portlets.user diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ExpressionWidgetEntry.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ExpressionWidgetEntry.java index 7ed248f..0cc38e6 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ExpressionWidgetEntry.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ExpressionWidgetEntry.java @@ -21,6 +21,8 @@ public class ExpressionWidgetEntry implements EntryPoint { public void onModuleLoad() { EventBus eventBus= new SimpleEventBus(); + TRId trId=new TRId("154","1610"); + String columnName="zwqvvx"; //Column Expression Dialog //ColumnExpressionDialog expressionDialog=new ColumnExpressionDialog("1", ColumnTypeCode.ATTRIBUTE, ColumnDataType.Integer, eventBus); @@ -29,14 +31,16 @@ public class ExpressionWidgetEntry implements EntryPoint { //Column Filter Dialog //id=2, tableId=8, tableType=Generic - TRId trId=new TRId("2","8"); - String columnName="twkvwc"; - ColumnFilterDialog columnFilterDialog=new ColumnFilterDialog(trId, columnName, eventBus); - columnFilterDialog.show(); + //ColumnFilterDialog columnFilterDialog=new ColumnFilterDialog(trId, columnName, eventBus); + //columnFilterDialog.show(); //Multi Column Filter Dialog - MultiColumnFilterDialog multiColumnFilterDialog= new MultiColumnFilterDialog(trId, eventBus); - multiColumnFilterDialog.show(); + //MultiColumnFilterDialog multiColumnFilterDialog= new MultiColumnFilterDialog(trId, eventBus); + //multiColumnFilterDialog.show(); + + //Replace Column By Expression Dialog + ReplaceColumnByExpressionDialog replaceColumnByExpression= new ReplaceColumnByExpressionDialog(trId, columnName, eventBus); + replaceColumnByExpression.show(); Log.info("Hello!"); } diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionDialog.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionDialog.java new file mode 100644 index 0000000..b569221 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionDialog.java @@ -0,0 +1,247 @@ +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.rpc.ExpressionServiceAsync; +import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3; +import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; +import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; +import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnByExpressionSession; +import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog; +import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener; +import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent; +import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; +import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType; +import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy; +import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; +import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression; +import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType; +import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.HTML; +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" g.panichi@isti.cnr.it + * + */ +public class ReplaceColumnByExpressionDialog extends Window implements MonitorDialogListener { + protected String WIDTH = "660px"; + protected String HEIGHT = "400px"; + protected ReplaceColumnByExpressionPanel replaceColumnByExpressionPanel; + protected C_Expression exp = null; + protected String replaceValue; + protected ColumnData column = null; + protected TRId trId; + protected String columnName = null; + protected EventBus eventBus; + private ReplaceColumnByExpressionSession replaceColumnByExpressionSession; + + public ReplaceColumnByExpressionDialog(String columnId, ColumnTypeCode columnTypeCode, + ColumnDataType dataTypeName, EventBus eventBus) { + initWindow(); + this.eventBus = eventBus; + column = new ColumnData(); + column.setColumnId(columnId); + column.setDataTypeName(dataTypeName.toString()); + column.setTypeCode(columnTypeCode.toString()); + create(); + + } + + public ReplaceColumnByExpressionDialog(TRId trId, String columnName, EventBus eventBus) { + initWindow(); + this.eventBus = eventBus; + this.trId = trId; + this.columnName = columnName; + load(trId, columnName); + + } + + protected void initWindow() { + setWidth(WIDTH); + setHeight(HEIGHT); + setBodyBorder(false); + setResizable(false); + setHeadingText("Replace Column By Expression"); + setClosable(true); + getHeader().setIcon(ExpressionResources.INSTANCE.columnReplaceByExpression()); + + } + + /** + * {@inheritDoc} + */ + @Override + protected void initTools() { + super.initTools(); + + closeBtn.addSelectHandler(new SelectHandler() { + + public void onSelect(SelectEvent event) { + close(); + } + }); + + } + + protected void create() { + if (column.getTypeCode() + .compareTo(ColumnTypeCode.ANNOTATION.toString()) == 0 + || column.getTypeCode().compareTo( + ColumnTypeCode.ATTRIBUTE.toString()) == 0 + || column.getTypeCode().compareTo( + ColumnTypeCode.CODE.toString()) == 0 + || column.getTypeCode().compareTo( + ColumnTypeCode.CODEDESCRIPTION.toString()) == 0 + || column.getTypeCode().compareTo( + ColumnTypeCode.CODENAME.toString()) == 0 + || column.getTypeCode().compareTo( + ColumnTypeCode.MEASURE.toString()) == 0) { + replaceColumnByExpressionPanel = new ReplaceColumnByExpressionPanel(this, column, + eventBus); + add(replaceColumnByExpressionPanel); + + } else { + HTML errorMessage = new HTML( + "This type of column is not supported for now!"); + add(errorMessage); + UtilsGXT3.alert("Error", + "This type of column is not supported for now!"); + } + } + + public C_Expression getExpression() { + return exp; + } + + protected void setExpression(C_Expression exp) { + Log.debug("New Expression set:" + exp.toString()); + this.exp = exp; + } + + protected void applyReplaceColumnByExpression(C_Expression exp, String replaceValue) { + this.exp = exp; + this.replaceValue=replaceValue; + callApplyReplaceByExpression(); + } + + protected void load(TRId trId, String columnName) { + TDGWTServiceAsync.INSTANCE.getColumn(trId, columnName, + new AsyncCallback() { + + public void onFailure(Throwable caught) { + Log.error("Error retrieving column: " + + caught.getMessage()); + UtilsGXT3.alert("Error retrieving column", + caught.getMessage()); + } + + public void onSuccess(ColumnData result) { + Log.debug("Retrived column: " + result); + if (result.isViewColumn()) { + UtilsGXT3 + .info("View Column", + "You can not make expressions on view column for now"); + hide(); + } else { + column = result; + create(); + } + } + + }); + + } + + protected void callApplyReplaceByExpression() { + replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(column, exp,replaceValue); + Log.debug(replaceColumnByExpressionSession.toString()); + + ExpressionServiceAsync.INSTANCE.startReplaceColumnByExpression(replaceColumnByExpressionSession, + new AsyncCallback() { + + @Override + public void onSuccess(String taskId) { + Log.debug("Submitted replace column by expression"); + openMonitorDialog(taskId); + + } + + @Override + public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.error("Error submitting replace column by expression: " + + caught.getLocalizedMessage()); + caught.printStackTrace(); + UtilsGXT3.alert( + "Error submitting replace column by expression", + caught.getLocalizedMessage()); + } + + } + }); + + } + + protected void close() { + hide(); + } + + // / + protected void openMonitorDialog(String taskId) { + MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus); + monitorDialog.addProgressDialogListener(this); + monitorDialog.show(); + } + + @Override + public void operationComplete(TRId trId) { + ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED; + ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent( + ChangeTableRequestType.COLUMNFILTER, trId, why); + eventBus.fireEvent(changeTableRequestEvent); + close(); + } + + @Override + public void operationFailed(Throwable caught, String reason, String details) { + UtilsGXT3.alert(reason, details); + close(); + + } + + @Override + public void operationStopped(TRId trId, String reason, String details) { + ChangeTableWhy why = ChangeTableWhy.TABLECURATION; + ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent( + ChangeTableRequestType.COLUMNFILTER, trId, why); + eventBus.fireEvent(changeTableRequestEvent); + close(); + + } + + @Override + public void operationAborted() { + close(); + + } + + @Override + public void operationPutInBackground() { + close(); + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionPanel.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionPanel.java new file mode 100644 index 0000000..9b75f09 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionPanel.java @@ -0,0 +1,174 @@ +package org.gcube.portlets.user.td.expressionwidget.client; + +import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources; +import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; +import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression; + +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.dom.ScrollSupport.ScrollMode; +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.TextField; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class ReplaceColumnByExpressionPanel extends FramedPanel { + protected static final String WIDTH = "648px"; + protected static final String HEIGHT = "364px"; + + protected static final String CONDITIONWIDTH = "612px"; + protected static final String CONDITIONHEIGHT = "150px"; + + protected EventBus eventBus; + + protected ReplaceColumnByExpressionDialog parent; + + protected ColumnData column; + + private TextButton btnApply; + private TextButton btnClose; + + private FieldSet conditionsFieldSet; + private ConditionWidget conditionWidget; + private TextField replaceValue; + + public ReplaceColumnByExpressionPanel( + ReplaceColumnByExpressionDialog parent, ColumnData column, + EventBus eventBus) { + super(); + this.parent = parent; + this.column = column; + this.eventBus = eventBus; + Log.debug(column.toString()); + init(); + create(); + } + + protected void init() { + setWidth(WIDTH); + setHeight(HEIGHT); + setBodyBorder(false); + setHeaderVisible(false); + // Important: fixed rendering of widgets + forceLayoutOnResize = true; + + } + + protected void create() { + VerticalLayoutContainer basicLayout = new VerticalLayoutContainer(); + basicLayout.setAdjustForScroll(true); + basicLayout.setScrollMode(ScrollMode.AUTO); + + HBoxLayoutContainer flowButton = new HBoxLayoutContainer(); + flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); + flowButton.setPack(BoxLayoutPack.CENTER); + + // Properties + FieldSet properties = new FieldSet(); + properties.setHeadingText("Properties"); + properties.setCollapsible(false); + + VerticalLayoutContainer propertiesLayout = new VerticalLayoutContainer(); + properties.add(propertiesLayout); + + TextField columnName = new TextField(); + columnName.setToolTip("Column"); + columnName.setReadOnly(true); + columnName.setValue(column.getLabel()); + propertiesLayout.add(new FieldLabel(columnName, "Column"), + new VerticalLayoutData(1, -1)); + + // Conditions + conditionsFieldSet = new FieldSet(); + conditionsFieldSet.setHeadingText("Conditions"); + conditionsFieldSet.setCollapsible(false); + + conditionWidget = new ConditionWidget(column,CONDITIONWIDTH, CONDITIONHEIGHT); + Log.debug("ConditionWidget" + conditionWidget); + conditionsFieldSet.add(conditionWidget); + + // Value + FieldSet replaceValueFieldSet = new FieldSet(); + replaceValueFieldSet.setHeadingText("Replace Value"); + replaceValueFieldSet.setCollapsible(false); + + VerticalLayoutContainer replaceValueFieldSetLayout = new VerticalLayoutContainer(); + replaceValueFieldSet.add(replaceValueFieldSetLayout); + + replaceValue = new TextField(); + replaceValue.setToolTip("Replace Value"); + replaceValue.setValue(""); + replaceValueFieldSetLayout.add(new FieldLabel(replaceValue, + "Replace Value"), new VerticalLayoutData(1, -1)); + + + // + btnApply = new TextButton("Apply"); + btnApply.setIcon(ExpressionResources.INSTANCE.columnReplaceByExpression()); + btnApply.setIconAlign(IconAlign.RIGHT); + btnApply.setTitle("Apply replace by expression"); + btnApply.addSelectHandler(new SelectHandler() { + + public void onSelect(SelectEvent event) { + Log.debug("Pressed Apply"); + applyReplaceColumnByExpression(); + + } + }); + + btnClose = new TextButton("Close"); + btnClose.setIcon(ExpressionResources.INSTANCE.close()); + btnClose.setIconAlign(IconAlign.RIGHT); + btnClose.setTitle("Close"); + btnClose.addSelectHandler(new SelectHandler() { + + public void onSelect(SelectEvent event) { + Log.debug("Pressed Close"); + close(); + } + }); + flowButton.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4))); + flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4))); + + //Add to basic layout + basicLayout.add(properties, new VerticalLayoutData(-1, -1, new Margins( + 1))); + basicLayout.add(conditionsFieldSet, new VerticalLayoutData(-1, -1, + new Margins(1))); + basicLayout.add(replaceValueFieldSet, new VerticalLayoutData(-1, -1, new Margins( + 1))); + + basicLayout.add(flowButton, new VerticalLayoutData(-1, 36, new Margins( + 5, 2, 5, 2))); + add(basicLayout); + + } + + protected void applyReplaceColumnByExpression() { + C_Expression exp = conditionWidget.getExpression(); + String value = replaceValue.getCurrentValue(); + parent.applyReplaceColumnByExpression(exp,value); + + } + + protected void close() { + parent.close(); + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/ExpressionResources.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/ExpressionResources.java index c27b2a2..740e027 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/ExpressionResources.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/ExpressionResources.java @@ -44,6 +44,12 @@ public interface ExpressionResources extends ClientBundle { @Source("column-filter-go.png") ImageResource applyFilter(); + @Source("column-replace-by-expression_32.png") + ImageResource columnReplaceByExpression32(); + + @Source("column-replace-by-expression.png") + ImageResource columnReplaceByExpression(); + } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/column-replace-by-expression.png b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/column-replace-by-expression.png new file mode 100644 index 0000000000000000000000000000000000000000..f1222ae3a1c5d9c945c846f313017412171854d0 GIT binary patch literal 799 zcmV+)1K|9LP)Ac&=3Fs0<1|y zK~y-)ZIexCTy+%1fA_sN$z+_ViiswT!HJCvg(6k_pdc1nh}m{y_9ETXrGl*+H!g~G zA&9z=tg~<-BHf5B*@PkzK}<0YNYzOxPSujmdz1I>hl`hKDR|(&yXXGzIrm%vSi3yv z2+=Z)&@jvbHOInHb<7-f$33Vt2uzAX^NVjD-IKM;gH9rGseh|na`#XR)C~2Stak9U zZlY%FmnI9-&0fA=u4F>A`nSrZcTXRF6t94gK!^wkK%lCWMxz0MJCQXSoc`c@x--pI zW*Xt{fmi%?y)RBc1Ofy?BErwx+bk|Fa$|RwW^+njeBt?k2(ySx!%zzdm%PXccg7Gv zl7#(HL6HyH+4+U;;*%hVsZqI+*@0#c7!^5c4gn%TAf!oxs*+|Y?RJ~PbF;OnR-2mX z*x?9A2 z%^%siafNiVO=b6!J)C2&Jj?p}I-h+0EstrB_rL60JwXH!LT|85k^R8tpOdxt10<5L zJJ@ArFb}}T@4dmygA+_WcV5+k%-m56CbJ1%e&#q2G~4(6o~9{Rw>R0jmIH9^!Ww1& zDxYmR?oOr}RF%?755+g%eI>IGPu01&iy%oejxNmdH83olldqnLcRoCG=<(Ojkp(Vy zMk6`#^a?L^PepSwm59LOE}uYHUOt70u>R3mF8=Ym&^{J!F7oylKXoKYF8$gcE+G-7 z#yA_QPG$80sT%G`WO)_~`sL6!gj002ovPDHLkV1m45aHjwO literal 0 HcmV?d00001 diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/column-replace-by-expression_32.png b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/column-replace-by-expression_32.png new file mode 100644 index 0000000000000000000000000000000000000000..50581d0a9315855bbcd575f2c912747c61028931 GIT binary patch literal 1499 zcmV<11tj{3P)KMpZD?a#74MfK-cdmmts;U|&{WVT@kxqUF9_m8pHxu6 zH$l`EeQG0W1uH6~A_!F!q}mpXl_=EKG;NZmF*!4{*YaV{%sD5?v0gyjaG0|%v)4as z{p$w*hp~OH{pT__Z{G`mlnZZte*6Znw!_r=RSmW9Gc!~TGw`aI(X_7BzTwp{>hrJ< zYQ=kD{g`6wUw-J4F96~afcLh;O#5e3!_-jf0!$ab+!uS=2xk5o#auyEX-{0gSA8E? z-UPtR`e#$)k=stEmKzjSF~WbV&XwyF>sGDR_v>rb9O!6^*!22-+7q{|JYNA&4M=Ob zk!A+YVP;^`B&-56Pq<-3Q9_ob6+km7z!+FKYX;twg#aw53j>^E{O~9uuAqq_1Rz3P z8;vA#P8iv>i*@VPk>`1}XMm}a^sK}P!eetS0BBurdF~Nch%7%@%7P%mSqhZsH~0@GNnNkCg7Y4$^+6gB~61V zk|ZgP8D>&>P)iO3D+pPd;i9NgI}I>o5x*9ZaIpwWmoDYVks|=~^z`5gB?fb})BuI6 zg^}hdk&hds)y-iNI1&DX7>ElTsnt?etzO09!-p|5)~s1gEzPQTOIKY0z^h_)-y_R1 zG_pq1S0*U+Zc>m|1W_rtlj2nw92{hJb{6wS=JU#Hys|iedZY^TEX@Oe`Kqq7p}`|F4FmQ=3pwM8VfBH@&Np61GfH?H_s zY4@Go$BAPhNfP3y^fXyq13Hf&@(%=V*sy_#i3xgpd--{EltW{am>Jz2F-h!Lal=Li z&bhKR2LvH<5s}12xcz%$+qP{C4Gl3oJd6M@y){C6XAeE;FKpWQFr8zgEME+OFEnsy z>K9%ad4ZX^!27R$O`1aIsm9p@=Wz2)H#0mu%$aLeaq;EXb8`9w*I%%fXE#638$0*4 zhyw%wwXDX$qdzdvH-MQjHuKlNe){)mqB!P!w|0JVRdx!34*W`ZG`_{R@fZS)? zdiAYjS@xHOJLeerW&{D^!p&>7lmp*?&D6v=TR+;$qnn<@XC6&l>ugxEP*u@}!r_#o zIC^Y41^{F4X;!w)r!Kx zH#I6sS9cFiqUwxqx%Hpx?TK4fmd?#BRy|j!x_YaIpk7e~ zRmkUN>aAK+Yge^u<6w6$+9>{) callback); + void startReplaceColumnByExpression(ReplaceColumnByExpressionSession replaceColumnByExpressionSession,AsyncCallback callback); + } diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java index 84adfcf..433207d 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java @@ -21,6 +21,7 @@ import org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession; +import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnByExpressionSession; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -79,113 +80,49 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements + e.getLocalizedMessage()); } } + + /** + * + * {@inheritDoc} + */ + @Override + public String startReplaceColumnByExpression(ReplaceColumnByExpressionSession replaceColumnByExpressionSession) + throws TDGWTServiceException { + + try { + logger.debug("ExpressionService submitReplaceColumnByExpression"); + HttpSession session = this.getThreadLocalRequest().getSession(); + logger.debug("Session: "+session); + + if(replaceColumnByExpressionSession==null){ + logger.error("ReplaceColumnByExpressionSession is null"); + new ExpressionServiceException("ReplaceColumnByExpressionSession is null"); + } + ExpressionSession.setReplaceColumnByExpressionSession(session, replaceColumnByExpressionSession); + + C_ExpressionParser parser=new C_ExpressionParser(); + Expression expression=parser.parse(replaceColumnByExpressionSession.getCexpression()); + logger.debug("Service Expression:"+expression); + + + TDGWTServiceImpl gwtService = new TDGWTServiceImpl(); + + String taskId= gwtService.startReplaceColumnByExpression(replaceColumnByExpressionSession, expression, session); + + return taskId; + + } catch (TDGWTSessionExpiredException e){ + throw e; + } catch (Throwable e) { + e.printStackTrace(); + throw new TDGWTServiceException( + "Error in startReplaceColumnByExpression:" + + e.getLocalizedMessage()); + } + } + + -// /** -// * {@inheritDoc} -// */ -// public ColumnFilterMonitor getColumnFilterMonitor() -// throws ExpressionServiceException { -// try { -// HttpSession session = this.getThreadLocalRequest().getSession(); -// FilterColumnSession columnFilterSession = ExpressionSession -// .getColumnFilterSession(session); -// -// Task task = ExpressionSession.getColumnFilterTask(session); -// ColumnFilterMonitor columnFilterMonitor = new ColumnFilterMonitor(); -// -// if (task == null) { -// logger.debug("Task null"); -// throw new ExpressionServiceException( -// "Error in ColumnFilter task null"); -// } else { -// TaskStatus status = task.getStatus(); -// if (status == null) { -// logger.debug("Services TaskStatus : null"); -// throw new ExpressionServiceException( -// "Error in ColumnFilter Status null"); -// } else { -// logger.debug("Services TaskStatus: " + task.getStatus()); -// -// columnFilterMonitor.setStatus(TaskStateMap.map(task -// .getStatus())); -// switch (columnFilterMonitor.getStatus()) { -// case FAILED: -// if (task.getResult() != null) { -// logger.debug("Task exception:" -// + task.getErrorCause()); -// task.getErrorCause().printStackTrace(); -// columnFilterMonitor.setError(new Throwable(task -// .getErrorCause())); -// } else { -// logger.debug("Task exception: Error In Column Filter"); -// columnFilterMonitor.setError(new Throwable( -// "Error In Column Filter")); -// } -// columnFilterMonitor.setProgress(task.getProgress()); -// break; -// case SUCCEDED: -// logger.debug("Task Result:" + task.getResult()); -// columnFilterMonitor.setProgress(task.getProgress()); -// Table table = task.getResult().getPrimaryTable(); -// logger.debug("Table retrived: " + table.toString()); -// TRId trId = new TRId(); -// trId.setId(columnFilterSession.getColumn().getTrId() -// .getId()); -// -// trId = retrieveTabularResourceBasicData(trId); -// -// columnFilterMonitor.setTrId(trId); -// TabResource tabResource = SessionUtil -// .getTabResource(session); -// tabResource.setTrId(trId); -// SessionUtil.setTabResource(session, tabResource); -// SessionUtil.setTRId(session, trId); -// break; -// case IN_PROGRESS: -// columnFilterMonitor.setProgress(task.getProgress()); -// break; -// case VALIDATING_RULES: -// columnFilterMonitor.setProgress(task.getProgress()); -// break; -// case GENERATING_VIEW: -// break; -// case ABORTED: -// break; -// case STOPPED: -// logger.debug("Task Result:" + task.getResult()); -// columnFilterMonitor.setProgress(task.getProgress()); -// trId = new TRId(); -// trId.setId(columnFilterSession.getColumn().getTrId() -// .getId()); -// trId = retrieveTabularResourceBasicData(trId); -// -// columnFilterMonitor.setTrId(trId); -// tabResource = SessionUtil.getTabResource(session); -// tabResource.setTrId(trId); -// SessionUtil.setTabResource(session, tabResource); -// SessionUtil.setTRId(session, trId); -// break; -// case INITIALIZING: -// break; -// default: -// break; -// } -// } -// ExpressionSession.setColumnFilterTask(session, task); -// } -// -// logger.info("ColumnFilterMonitor(): " + columnFilterMonitor); -// return columnFilterMonitor; -// } catch (TDGWTSessionExpiredException e){ -// throw new ExpressionServiceException(e.getLocalizedMessage()); -// } catch (Throwable e) { -// e.printStackTrace(); -// throw new ExpressionServiceException( -// "Error applying column filter: " + e.getLocalizedMessage()); -// -// } -// -// } /** diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionSession.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionSession.java index de0796e..266f2fd 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionSession.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionSession.java @@ -7,6 +7,7 @@ import javax.servlet.http.HttpSession; import org.gcube.data.analysis.tabulardata.service.operation.Task; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession; +import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnByExpressionSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,6 +23,7 @@ public class ExpressionSession { protected static final String COLUMN_FILTER_SESSION = "COLUMN_FILTER_SESSION"; protected static final String COLUMN_FILTER_SESSION_TASK = "COLUMN_FILTER_SESSION_TASK"; + protected static final String REPLACE_COLUMN_BY_EXPRESSION_SESSION = "REPLACE_COLUMN_BY_EXPRESSION_SESSION"; protected static Logger logger = LoggerFactory.getLogger(ExpressionSession.class); @@ -51,6 +53,33 @@ public class ExpressionSession { columnFilterSession); } + + public static ReplaceColumnByExpressionSession getReplaceColumnByExpressionSession( + HttpSession httpSession) { + ReplaceColumnByExpressionSession replaceColumnByExpressionSession = (ReplaceColumnByExpressionSession) httpSession + .getAttribute(REPLACE_COLUMN_BY_EXPRESSION_SESSION); + if (replaceColumnByExpressionSession != null) { + return replaceColumnByExpressionSession; + } else { + replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(); + httpSession.setAttribute(REPLACE_COLUMN_BY_EXPRESSION_SESSION, + replaceColumnByExpressionSession); + return replaceColumnByExpressionSession; + } + } + + public static void setReplaceColumnByExpressionSession(HttpSession httpSession, + ReplaceColumnByExpressionSession replaceColumnByExpressionSession) { + ReplaceColumnByExpressionSession rce = (ReplaceColumnByExpressionSession) httpSession + .getAttribute(REPLACE_COLUMN_BY_EXPRESSION_SESSION); + if (rce != null) { + httpSession.removeAttribute(REPLACE_COLUMN_BY_EXPRESSION_SESSION); + } + httpSession.setAttribute(REPLACE_COLUMN_BY_EXPRESSION_SESSION, + replaceColumnByExpressionSession); + + } + diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/Constants.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/Constants.java index 22df2c4..1d878f1 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/Constants.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/Constants.java @@ -8,10 +8,10 @@ package org.gcube.portlets.user.td.expressionwidget.shared; */ public class Constants { - public final static String VERSION = "1.0.0"; - public final static String DEFAULT_USER = "giancarlo.panichi"; - public final static String DEFAULT_SCOPE = "/gcube/devsec"; - + public final static String VERSION = "2.4.0"; + public final static String DEFAULT_USER = "test.user"; + public final static String DEFAULT_SCOPE = "/gcube/devsec/devVRE"; + public static final String PARAMETER_ENCODING = "encoding"; public static final String PARAMETER_HASHEADER = "hasHeader"; public static final String PARAMETER_SEPARATOR = "separator"; diff --git a/src/main/resources/org/gcube/portlets/user/td/expressionwidget/ExpressionWidget.gwt.xml b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/ExpressionWidget.gwt.xml index c3fd016..ebaa59a 100644 --- a/src/main/resources/org/gcube/portlets/user/td/expressionwidget/ExpressionWidget.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/ExpressionWidget.gwt.xml @@ -23,7 +23,7 @@ - + diff --git a/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/resources/column-replace-by-expression.png b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/resources/column-replace-by-expression.png new file mode 100644 index 0000000000000000000000000000000000000000..f1222ae3a1c5d9c945c846f313017412171854d0 GIT binary patch literal 799 zcmV+)1K|9LP)Ac&=3Fs0<1|y zK~y-)ZIexCTy+%1fA_sN$z+_ViiswT!HJCvg(6k_pdc1nh}m{y_9ETXrGl*+H!g~G zA&9z=tg~<-BHf5B*@PkzK}<0YNYzOxPSujmdz1I>hl`hKDR|(&yXXGzIrm%vSi3yv z2+=Z)&@jvbHOInHb<7-f$33Vt2uzAX^NVjD-IKM;gH9rGseh|na`#XR)C~2Stak9U zZlY%FmnI9-&0fA=u4F>A`nSrZcTXRF6t94gK!^wkK%lCWMxz0MJCQXSoc`c@x--pI zW*Xt{fmi%?y)RBc1Ofy?BErwx+bk|Fa$|RwW^+njeBt?k2(ySx!%zzdm%PXccg7Gv zl7#(HL6HyH+4+U;;*%hVsZqI+*@0#c7!^5c4gn%TAf!oxs*+|Y?RJ~PbF;OnR-2mX z*x?9A2 z%^%siafNiVO=b6!J)C2&Jj?p}I-h+0EstrB_rL60JwXH!LT|85k^R8tpOdxt10<5L zJJ@ArFb}}T@4dmygA+_WcV5+k%-m56CbJ1%e&#q2G~4(6o~9{Rw>R0jmIH9^!Ww1& zDxYmR?oOr}RF%?755+g%eI>IGPu01&iy%oejxNmdH83olldqnLcRoCG=<(Ojkp(Vy zMk6`#^a?L^PepSwm59LOE}uYHUOt70u>R3mF8=Ym&^{J!F7oylKXoKYF8$gcE+G-7 z#yA_QPG$80sT%G`WO)_~`sL6!gj002ovPDHLkV1m45aHjwO literal 0 HcmV?d00001 diff --git a/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/resources/column-replace-by-expression_32.png b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/resources/column-replace-by-expression_32.png new file mode 100644 index 0000000000000000000000000000000000000000..50581d0a9315855bbcd575f2c912747c61028931 GIT binary patch literal 1499 zcmV<11tj{3P)KMpZD?a#74MfK-cdmmts;U|&{WVT@kxqUF9_m8pHxu6 zH$l`EeQG0W1uH6~A_!F!q}mpXl_=EKG;NZmF*!4{*YaV{%sD5?v0gyjaG0|%v)4as z{p$w*hp~OH{pT__Z{G`mlnZZte*6Znw!_r=RSmW9Gc!~TGw`aI(X_7BzTwp{>hrJ< zYQ=kD{g`6wUw-J4F96~afcLh;O#5e3!_-jf0!$ab+!uS=2xk5o#auyEX-{0gSA8E? z-UPtR`e#$)k=stEmKzjSF~WbV&XwyF>sGDR_v>rb9O!6^*!22-+7q{|JYNA&4M=Ob zk!A+YVP;^`B&-56Pq<-3Q9_ob6+km7z!+FKYX;twg#aw53j>^E{O~9uuAqq_1Rz3P z8;vA#P8iv>i*@VPk>`1}XMm}a^sK}P!eetS0BBurdF~Nch%7%@%7P%mSqhZsH~0@GNnNkCg7Y4$^+6gB~61V zk|ZgP8D>&>P)iO3D+pPd;i9NgI}I>o5x*9ZaIpwWmoDYVks|=~^z`5gB?fb})BuI6 zg^}hdk&hds)y-iNI1&DX7>ElTsnt?etzO09!-p|5)~s1gEzPQTOIKY0z^h_)-y_R1 zG_pq1S0*U+Zc>m|1W_rtlj2nw92{hJb{6wS=JU#Hys|iedZY^TEX@Oe`Kqq7p}`|F4FmQ=3pwM8VfBH@&Np61GfH?H_s zY4@Go$BAPhNfP3y^fXyq13Hf&@(%=V*sy_#i3xgpd--{EltW{am>Jz2F-h!Lal=Li z&bhKR2LvH<5s}12xcz%$+qP{C4Gl3oJd6M@y){C6XAeE;FKpWQFr8zgEME+OFEnsy z>K9%ad4ZX^!27R$O`1aIsm9p@=Wz2)H#0mu%$aLeaq;EXb8`9w*I%%fXE#638$0*4 zhyw%wwXDX$qdzdvH-MQjHuKlNe){)mqB!P!w|0JVRdx!34*W`ZG`_{R@fZS)? zdiAYjS@xHOJLeerW&{D^!p&>7lmp*?&D6v=TR+;$qnn<@XC6&l>ugxEP*u@}!r_#o zIC^Y41^{F4X;!w)r!Kx zH#I6sS9cFiqUwxqx%Hpx?TK4fmd?#BRy|j!x_YaIpk7e~ zRmkUN>aAK+Yge^u<6w6$+9>{)