From 3ee14bc7f9d8b8645c91f73d3c14c3889bcc2d5f Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Thu, 23 Apr 2015 14:13:15 +0000 Subject: [PATCH] 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 --- .gwt/.gwt-log | 32 ++++ .../client/RuleEditDialog.java | 161 ++++++++++++++++ .../client/RuleEditPanel.java | 176 ++++++++++++++++++ .../RuleEditDialogNotification.java | 40 ++++ .../client/resources/ExpressionResources.java | 8 + .../client/resources/rule-edit.png | Bin 0 -> 839 bytes .../client/resources/rule-edit_32.png | Bin 0 -> 1940 bytes .../client/rpc/ExpressionService.java | 3 + .../client/rpc/ExpressionServiceAsync.java | 7 +- .../server/ExpressionServiceImpl.java | 49 +++++ .../service/rule/RuleDescriptionMap.java | 139 ++++++++++---- .../client/resources/rule-edit.png | Bin 0 -> 839 bytes .../client/resources/rule-edit_32.png | Bin 0 -> 1940 bytes 13 files changed, 572 insertions(+), 43 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RuleEditDialog.java create mode 100644 src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RuleEditPanel.java create mode 100644 src/main/java/org/gcube/portlets/user/td/expressionwidget/client/notification/RuleEditDialogNotification.java create mode 100644 src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/rule-edit.png create mode 100644 src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/rule-edit_32.png create mode 100644 src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/resources/rule-edit.png create mode 100644 src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/resources/rule-edit_32.png diff --git a/.gwt/.gwt-log b/.gwt/.gwt-log index bf78f69..601337c 100644 --- a/.gwt/.gwt-log +++ b/.gwt/.gwt-log @@ -254,3 +254,35 @@ Compiling... Compilation completed in 0.00 seconds Removing invalidated units 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 diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RuleEditDialog.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RuleEditDialog.java new file mode 100644 index 0000000..8fb60f2 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RuleEditDialog.java @@ -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" g.panichi@isti.cnr.it + * + */ +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 listeners; + public RuleEditDialog(RuleDescriptionData ruleDescriptionData, EventBus eventBus) { + listeners = new ArrayList(); + 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() { + + @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(); + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RuleEditPanel.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RuleEditPanel.java new file mode 100644 index 0000000..2fe2133 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RuleEditPanel.java @@ -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" g.panichi@isti.cnr.it + * + */ +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(); + } + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/notification/RuleEditDialogNotification.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/notification/RuleEditDialogNotification.java new file mode 100644 index 0000000..f8ce56c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/notification/RuleEditDialogNotification.java @@ -0,0 +1,40 @@ +package org.gcube.portlets.user.td.expressionwidget.client.notification; + + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +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 []"; + } + + +} \ No newline at end of file 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 e6ee3db..dfb9967 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 @@ -5,6 +5,7 @@ package org.gcube.portlets.user.td.expressionwidget.client.resources; import com.google.gwt.core.client.GWT; import com.google.gwt.resources.client.ClientBundle; 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") ImageResource ruleAdd32(); + @Source("rule-edit_32.png") + ImageResource ruleEdit32(); + + @Source("rule-edit.png") + ImageResource ruleEdit(); + + @Source("rule-column-add.png") ImageResource ruleColumnAdd(); diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/rule-edit.png b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/rule-edit.png new file mode 100644 index 0000000000000000000000000000000000000000..0357292800dfc83eed99e0982fa68d4200697a97 GIT binary patch literal 839 zcmV-N1GxN&P)sX6~euOftF55VdHTXlO_Lk$|L{MNsHppk|>Ku?ta&7&9o+ zjcv)I=oEFNu7n5*Md-?nS*c*eP-BB33!$1AGmR~2$Ru;`bmrdseJ*SVu@!ycz=6Z_ zp7$J?dlD%O?;k4M_t2qO2iyMccZ)+un|s_)rBZP{&pVb(CXX9q23oDwm3qDY;MCOA z6#(TOysI?$`1Jhe7u5Mi&vRd8@0s|Rzsd8wmrJG6hr`3e17l-j^!4>gqtWQhwbk|B zYa8G8zVOr&L~@nJ=GqIBO)v;EU>z|`gJy&P0h^A6hs8QuaK9X zdvjvl-$|wOw43|mQ?rmH5~Zv-+B&HWN~f_l zHeZ6RR;vIQV~FDzfMT&|GnvdrCX;!3baXWDx^6*Ztwuxvpakq+{p92%)oS$>V+__> zj4@=hSs57_0ifM(W3AoPD91`CuVCXSeD$MC71!<@NT>@(ii3llQ;ad4R6!6BMbSwu zNg@vPLY1(z?ne$afQTrQvGA5uy=H$E<4EeWk~97VHjI6S0T-pcncHXfcU zm&<1>l?t~Q5VakYAWET}BsOfZ(}>t@#wbUT?b3v*cO77Qdiqv_#qCFX*1!3l+Wa}T zE}my6Xc2@$QVYw!`mFrcIPppO(A2Z1SGb+jkGbP71${@j`;iZ5wg>nreF`lxzic+y z+`fL|+*|j*{mkhVK7F%vdjqQyxjza=dFSLY=9?2FrN#1^&!x*j2mb6|U;wq-Xur3% z=aC&hgU%gf{c6C**7g4d1IUZ-|C|b=Xu?gquZ3Z>z2k@PCPU_M#r_uz@F$KpMqy>w RHje-R002ovPDHLkV1mZCkk9}C literal 0 HcmV?d00001 diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/rule-edit_32.png b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/resources/rule-edit_32.png new file mode 100644 index 0000000000000000000000000000000000000000..55b7db8e2b41a1317896e5dc22d9da30d29e4db4 GIT binary patch literal 1940 zcmV;F2W$9=P);L~>Z?^y(`f0$euM`0I_b;e$0e&o`uzC|&fd0LUX?Wx_%2{`J zH%~wPG~M0Z3E&~;+>cbX6_}%{s461DbI&~|<<85$HW_Z;<~Z2FVo4;PkEQ0{6QmM> z3C%g0I^rg(0qB-QC^uRrP}~3>)g|>WIhV0H`Y2Y?i*hzF7(Qw{LUodxqsf z<Bk*hkx&Afd=l=ZUskhHGEq&Ifts^oCDy@nKQ-TWg`HfK9yr<50R`{&I9+Z*!*ft zECx}0cs2(j(i)G)XMh8w(`iOWM={2eYtAf&ePlKx}xm*tC92+)l*aom;$BsqLxznl|D@}=+auYXxfXn9rLBxOv>LPFv zsCri-Q2Ly%gD?yc5w>sNzGZ6vaaD~a5(%1{n`vlh_>zDZ1ZfvVC_3$S$|*RtDqb*g zB?6Zh9zZggWWj<3sA@-NXQw*nwulIgjg2f=uz;$ns*)5qSMSFY2vVc~AVx4I5L{u- z<-mLP>|x!ybzezEX&tOyy_(U{QHFb-O z-S6t^V%@rR?B2b*HHxC5vr_Qs|MTX}qpGTE258Aj8~rWSO*rwxF@Uz$ zPrjlKT{iKT--^f)=UiA_T}@?W<*eZ4QX?V^4Gm$fecitkIIKEHjFdz`iXVy*Q)35m z8(#nPMO@(pRnfFra@Sn@X?Xqhi&?d5W!aW22R?lI_^z4I=LCWUJWxH=q$ab5UeJZAXT$~j!jL>%lJi@apT6G z&d$zRZ@`X@jxR^?q37|{c#Hf*s?25W;m6|m_B>kBo)RQAJ!H1=5!+<2gGSi^=jJ88h6lFpi=k&Ka)K zOg@W>ae;^r;!4^;Q50J!;QSQh*{G;o1Oy@G8$LXl=JXdi0?)ksW=GQtk8VA7bp*z4 ze%xFbkIBf9>K{nd?2xwSDo{4>T*_aU)7e%vESrZ6$#qFF|o#Z$^B3o(ot4)jifi|Wg7 zb~L^8=+ rules) throws TDGWTServiceException; public String startApplyAndDetachColumnRules(ApplyAndDetachColumnRulesSession applyColumnRulesSession) diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/rpc/ExpressionServiceAsync.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/rpc/ExpressionServiceAsync.java index 282963a..2275d84 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/rpc/ExpressionServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/rpc/ExpressionServiceAsync.java @@ -52,17 +52,20 @@ public interface ExpressionServiceAsync { void saveColumnRule(RuleDescriptionData ruleDescriptionData, AsyncCallback callback); + void updateColumnRule(RuleDescriptionData ruleDescriptionData, + AsyncCallback callback); + void removeRulesById(ArrayList rules, AsyncCallback callback); void startApplyAndDetachColumnRules( ApplyAndDetachColumnRulesSession ruleOnColumnApplySession, AsyncCallback callback); - + void setDetachColumnRules( DetachColumnRulesSession detachColumnRulesSession, AsyncCallback callback); - + void getActiveRulesByTabularResourceId(TRId trId, 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 1672993..65fe1e5 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 @@ -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} diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/service/rule/RuleDescriptionMap.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/service/rule/RuleDescriptionMap.java index e298856..ec3ac5b 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/service/rule/RuleDescriptionMap.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/service/rule/RuleDescriptionMap.java @@ -1,10 +1,9 @@ package org.gcube.portlets.user.td.expressionwidget.server.service.rule; - - import java.util.ArrayList; 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.expression.Expression; 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.LoggerFactory; - /** * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it * */ public class RuleDescriptionMap { @@ -30,79 +28,70 @@ public class RuleDescriptionMap { private static final String SECURITY_EXCEPTION_RIGHTS = "Security exception, you don't have the required rights!"; - - public static RuleDescriptionData map(RuleDescription ruleDescription) - throws TDGWTServiceException, ExpressionParserException { - RuleDescriptionData ruleDescriptionData=null; - if(ruleDescription==null){ + public static RuleDescriptionData map(RuleDescription ruleDescription) + throws TDGWTServiceException, ExpressionParserException { + RuleDescriptionData ruleDescriptionData = null; + if (ruleDescription == null) { logger.error("Rule description is null"); throw new TDGWTServiceException("Rule description is null"); - + } - - - if(ruleDescription.getScope()==null){ + + if (ruleDescription.getScope() == null) { logger.error("Rule description has scope null"); throw new TDGWTServiceException("Rule description has scope null"); } - - + switch (ruleDescription.getScope()) { case COLUMN: - ruleDescriptionData=createColumnRule(ruleDescription); + ruleDescriptionData = createColumnRuleDescriptionData(ruleDescription); break; case TABLE: - ruleDescriptionData=createTableRule(ruleDescription); + ruleDescriptionData = createTableRuleDescriptionData(ruleDescription); break; default: break; } - + return ruleDescriptionData; - + } - - private static RuleDescriptionData createTableRule( + private static RuleDescriptionData createTableRuleDescriptionData( RuleDescription ruleDescription) { return null; } - - private static RuleDescriptionData createColumnRule( + private static RuleDescriptionData createColumnRuleDescriptionData( RuleDescription ruleDescription) throws ExpressionParserException, TDGWTServiceException { - + Expression serviceExpression = ruleDescription.getRule(); - + C_ExpressionParser parser = new C_ExpressionParser(); - + C_Expression cexp = parser.parse(serviceExpression); TDRuleColumnType tdRuleColumnType = RuleColumnTypeMap .map(ruleDescription.getRuleColumnType()); - + Contacts owner = new Contacts("", ruleDescription.getOwner(), false); - ArrayList contacts=retrieveRuleShareInfo(ruleDescription); - + ArrayList contacts = retrieveRuleShareInfo(ruleDescription); + RuleDescriptionData ruleData = new RuleDescriptionData( ruleDescription.getId(), ruleDescription.getName(), - ruleDescription.getDescription(), - owner, contacts, - RuleScopeMap.map(ruleDescription.getScope()), - tdRuleColumnType, cexp); - + ruleDescription.getDescription(), owner, contacts, + RuleScopeMap.map(ruleDescription.getScope()), tdRuleColumnType, + cexp); + return ruleData; } - - + private static ArrayList retrieveRuleShareInfo( - RuleDescription ruleDescription) - throws TDGWTServiceException { + RuleDescription ruleDescription) throws TDGWTServiceException { try { ArrayList contacts = new ArrayList(); - List sharedWithUsers = ruleDescription - .getSharedWithUsers(); + List sharedWithUsers = ruleDescription.getSharedWithUsers(); logger.debug("Shared with Users: " + sharedWithUsers); if (sharedWithUsers != null) { for (String user : sharedWithUsers) { @@ -131,6 +120,74 @@ 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; + } + } diff --git a/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/resources/rule-edit.png b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/resources/rule-edit.png new file mode 100644 index 0000000000000000000000000000000000000000..0357292800dfc83eed99e0982fa68d4200697a97 GIT binary patch literal 839 zcmV-N1GxN&P)sX6~euOftF55VdHTXlO_Lk$|L{MNsHppk|>Ku?ta&7&9o+ zjcv)I=oEFNu7n5*Md-?nS*c*eP-BB33!$1AGmR~2$Ru;`bmrdseJ*SVu@!ycz=6Z_ zp7$J?dlD%O?;k4M_t2qO2iyMccZ)+un|s_)rBZP{&pVb(CXX9q23oDwm3qDY;MCOA z6#(TOysI?$`1Jhe7u5Mi&vRd8@0s|Rzsd8wmrJG6hr`3e17l-j^!4>gqtWQhwbk|B zYa8G8zVOr&L~@nJ=GqIBO)v;EU>z|`gJy&P0h^A6hs8QuaK9X zdvjvl-$|wOw43|mQ?rmH5~Zv-+B&HWN~f_l zHeZ6RR;vIQV~FDzfMT&|GnvdrCX;!3baXWDx^6*Ztwuxvpakq+{p92%)oS$>V+__> zj4@=hSs57_0ifM(W3AoPD91`CuVCXSeD$MC71!<@NT>@(ii3llQ;ad4R6!6BMbSwu zNg@vPLY1(z?ne$afQTrQvGA5uy=H$E<4EeWk~97VHjI6S0T-pcncHXfcU zm&<1>l?t~Q5VakYAWET}BsOfZ(}>t@#wbUT?b3v*cO77Qdiqv_#qCFX*1!3l+Wa}T zE}my6Xc2@$QVYw!`mFrcIPppO(A2Z1SGb+jkGbP71${@j`;iZ5wg>nreF`lxzic+y z+`fL|+*|j*{mkhVK7F%vdjqQyxjza=dFSLY=9?2FrN#1^&!x*j2mb6|U;wq-Xur3% z=aC&hgU%gf{c6C**7g4d1IUZ-|C|b=Xu?gquZ3Z>z2k@PCPU_M#r_uz@F$KpMqy>w RHje-R002ovPDHLkV1mZCkk9}C literal 0 HcmV?d00001 diff --git a/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/resources/rule-edit_32.png b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/client/resources/rule-edit_32.png new file mode 100644 index 0000000000000000000000000000000000000000..55b7db8e2b41a1317896e5dc22d9da30d29e4db4 GIT binary patch literal 1940 zcmV;F2W$9=P);L~>Z?^y(`f0$euM`0I_b;e$0e&o`uzC|&fd0LUX?Wx_%2{`J zH%~wPG~M0Z3E&~;+>cbX6_}%{s461DbI&~|<<85$HW_Z;<~Z2FVo4;PkEQ0{6QmM> z3C%g0I^rg(0qB-QC^uRrP}~3>)g|>WIhV0H`Y2Y?i*hzF7(Qw{LUodxqsf z<Bk*hkx&Afd=l=ZUskhHGEq&Ifts^oCDy@nKQ-TWg`HfK9yr<50R`{&I9+Z*!*ft zECx}0cs2(j(i)G)XMh8w(`iOWM={2eYtAf&ePlKx}xm*tC92+)l*aom;$BsqLxznl|D@}=+auYXxfXn9rLBxOv>LPFv zsCri-Q2Ly%gD?yc5w>sNzGZ6vaaD~a5(%1{n`vlh_>zDZ1ZfvVC_3$S$|*RtDqb*g zB?6Zh9zZggWWj<3sA@-NXQw*nwulIgjg2f=uz;$ns*)5qSMSFY2vVc~AVx4I5L{u- z<-mLP>|x!ybzezEX&tOyy_(U{QHFb-O z-S6t^V%@rR?B2b*HHxC5vr_Qs|MTX}qpGTE258Aj8~rWSO*rwxF@Uz$ zPrjlKT{iKT--^f)=UiA_T}@?W<*eZ4QX?V^4Gm$fecitkIIKEHjFdz`iXVy*Q)35m z8(#nPMO@(pRnfFra@Sn@X?Xqhi&?d5W!aW22R?lI_^z4I=LCWUJWxH=q$ab5UeJZAXT$~j!jL>%lJi@apT6G z&d$zRZ@`X@jxR^?q37|{c#Hf*s?25W;m6|m_B>kBo)RQAJ!H1=5!+<2gGSi^=jJ88h6lFpi=k&Ka)K zOg@W>ae;^r;!4^;Q50J!;QSQh*{G;o1Oy@G8$LXl=JXdi0?)ksW=GQtk8VA7bp*z4 ze%xFbkIBf9>K{nd?2xwSDo{4>T*_aU)7e%vESrZ6$#qFF|o#Z$^B3o(ot4)jifi|Wg7 zb~L^8=+