diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java index 7c52d51..4b0d80c 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java @@ -117,7 +117,7 @@ public class SessionConstants { public static final String GEOMETRY_CREATE_POINT_SESSION = "GEOMETRY_CREATE_POINT_SESSION"; - public static final String RULES_ON_COLUMN_APPLY_SESSION = "RULES_ON_COLUMN_APPLY_SESSION"; + public static final String RULES_ON_COLUMN_APPLY_AND_DETACH_SESSION = "RULES_ON_COLUMN_APPLY_AND_DETACH_SESSION"; public static final String RULES_ON_COLUMN_DETACH_SESSION = "RULES_ON_COLUMN_DETACH_SESSION"; diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java index d796c48..2b9104d 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java @@ -30,7 +30,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.geospatial.GeospatialDownsca import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession; import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession; import org.gcube.portlets.user.td.gwtservice.shared.map.MapCreationSession; -import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyColumnRulesSession; +import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyAndDetachColumnRulesSession; import org.gcube.portlets.user.td.gwtservice.shared.rule.DetachColumnRulesSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession; @@ -1093,32 +1093,32 @@ public class SessionUtil { // - public static ApplyColumnRulesSession getRulesOnColumnApplySession( + public static ApplyAndDetachColumnRulesSession getRulesOnColumnApplyAndDetachSession( HttpSession httpSession) { - ApplyColumnRulesSession applyColumnRulesSession = (ApplyColumnRulesSession) httpSession - .getAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_SESSION); + ApplyAndDetachColumnRulesSession applyColumnRulesSession = (ApplyAndDetachColumnRulesSession) httpSession + .getAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_AND_DETACH_SESSION); if (applyColumnRulesSession != null) { return applyColumnRulesSession; } else { - applyColumnRulesSession = new ApplyColumnRulesSession(); + applyColumnRulesSession = new ApplyAndDetachColumnRulesSession(); httpSession.setAttribute( - SessionConstants.RULES_ON_COLUMN_APPLY_SESSION, + SessionConstants.RULES_ON_COLUMN_APPLY_AND_DETACH_SESSION, applyColumnRulesSession); return applyColumnRulesSession; } } - public static void setRulesOnColumnApplySession( + public static void setRulesOnColumnApplyAndDetachSession( HttpSession httpSession, - ApplyColumnRulesSession applyColumnRulesSession) { - ApplyColumnRulesSession rules = (ApplyColumnRulesSession) httpSession - .getAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_SESSION); + ApplyAndDetachColumnRulesSession applyColumnRulesSession) { + ApplyAndDetachColumnRulesSession rules = (ApplyAndDetachColumnRulesSession) httpSession + .getAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_AND_DETACH_SESSION); if (rules != null) { httpSession - .removeAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_SESSION); + .removeAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_AND_DETACH_SESSION); } httpSession.setAttribute( - SessionConstants.RULES_ON_COLUMN_APPLY_SESSION, + SessionConstants.RULES_ON_COLUMN_APPLY_AND_DETACH_SESSION, applyColumnRulesSession); } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java index 45d5c7b..fb0f3eb 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java @@ -195,7 +195,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitorCrea import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitorSession; import org.gcube.portlets.user.td.gwtservice.shared.rule.DetachColumnRulesSession; import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData; -import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyColumnRulesSession; +import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyAndDetachColumnRulesSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession; import org.gcube.portlets.user.td.gwtservice.shared.share.Contacts; @@ -9434,35 +9434,36 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements /** * - * @param applyColumnRulesSession + * @param applyAndDetachColumnRulesSession * @param session * @return * @throws TDGWTServiceException */ - public String startApplyColumnnRules( - ApplyColumnRulesSession applyColumnRulesSession, HttpSession session) - throws TDGWTServiceException { + public String startApplyAndDetachColumnnRules( + ApplyAndDetachColumnRulesSession applyAndDetachColumnRulesSession, + HttpSession session) throws TDGWTServiceException { try { // HttpSession session = this.getThreadLocalRequest().getSession(); ASLSession aslSession = SessionUtil.getAslSession(session); - SessionUtil.setRulesOnColumnApplySession(session, - applyColumnRulesSession); + SessionUtil.setRulesOnColumnApplyAndDetachSession(session, + applyAndDetachColumnRulesSession); - if (applyColumnRulesSession == null) { - logger.error("ApplyColumnRulesSession is null"); + if (applyAndDetachColumnRulesSession == null) { + logger.error("ApplyAndDetachColumnRulesSession is null"); throw new TDGWTServiceException( - "Error in apply rules on column: ApplyColumnRulesSession is null"); + "Error in apply rules on column: ApplyAndDetachColumnRulesSession is null"); } AuthorizationProvider.instance.set(new AuthorizationToken( aslSession.getUsername(), aslSession.getScope())); TabularDataService service = TabularDataServiceFactory.getService(); - checkTRId(applyColumnRulesSession.getTrId()); + checkTRId(applyAndDetachColumnRulesSession.getTrId()); TabularResourceId tabularResourceId = new TabularResourceId( - Long.valueOf(applyColumnRulesSession.getTrId().getId())); + Long.valueOf(applyAndDetachColumnRulesSession.getTrId() + .getId())); TabularResource tabularResource = service .getTabularResource(tabularResourceId); @@ -9470,9 +9471,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements checkTabularResourceLocked(tabularResource); checkTabularResourceIsFinal(tabularResource); - ColumnData column = applyColumnRulesSession.getColumn(); + ColumnData column = applyAndDetachColumnRulesSession.getColumn(); if (column == null) { - logger.error("Error in apply rules on column: No column selected."); + logger.error("Error in apply and detach rules on column: No column selected."); throw new TDGWTServiceException( "Error in apply rules on column: No column selected."); } @@ -9480,7 +9481,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements ColumnLocalId columnLocalId = new ColumnLocalId( column.getColumnId()); - ArrayList rulesThatWillBeDetach = applyColumnRulesSession + ArrayList rulesThatWillBeDetach = applyAndDetachColumnRulesSession .getRulesThatWillBeDetached(); if (rulesThatWillBeDetach != null && rulesThatWillBeDetach.size() > 0) { @@ -9493,23 +9494,27 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements ruleIdsDetach); } - ArrayList rulesThatWillBeApplied = applyColumnRulesSession + ArrayList rulesThatWillBeApplied = applyAndDetachColumnRulesSession .getRulesThatWillBeApplied(); - ArrayList ruleIdsApplied = new ArrayList(); - for (RuleDescriptionData r : rulesThatWillBeApplied) { - RuleId ruleAppliedId = new RuleId(r.getId()); - ruleIdsApplied.add(ruleAppliedId); + if (rulesThatWillBeApplied != null + && rulesThatWillBeApplied.size() > 0) { + ArrayList ruleIdsApplied = new ArrayList(); + for (RuleDescriptionData r : rulesThatWillBeApplied) { + RuleId ruleAppliedId = new RuleId(r.getId()); + ruleIdsApplied.add(ruleAppliedId); + } + Task trTask = service.applyColumnRule(tabularResourceId, + columnLocalId, ruleIdsApplied); + logger.debug("Rules On Column Apply: TaskId " + trTask.getId()); + + TaskWrapper taskWrapper = new TaskWrapper(trTask, + UIOperationsId.RuleOnColumnApply, + applyAndDetachColumnRulesSession.getTrId()); + SessionUtil.setStartedTask(session, taskWrapper); + return trTask.getId().getValue(); + } else { + return null; } - Task trTask = service.applyColumnRule(tabularResourceId, - columnLocalId, ruleIdsApplied); - logger.debug("Rules On Column Apply: TaskId " + trTask.getId()); - - TaskWrapper taskWrapper = new TaskWrapper(trTask, - UIOperationsId.RuleOnColumnApply, - applyColumnRulesSession.getTrId()); - SessionUtil.setStartedTask(session, taskWrapper); - return trTask.getId().getValue(); - } catch (TDGWTServiceException e) { throw e; } catch (SecurityException e) { @@ -9567,10 +9572,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements throw new TDGWTServiceException( "Error in detach rules on column: No column selected."); } - + ColumnLocalId columnLocalId = new ColumnLocalId( column.getColumnId()); - + ArrayList rules = detachColumnRulesSession .getRules(); ArrayList ruleIds = new ArrayList(); @@ -9579,7 +9584,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements RuleId ruleId = new RuleId(r.getId()); ruleIds.add(ruleId); } - service.detachColumnRules(tabularResourceId, columnLocalId, ruleIds); + service.detachColumnRules(tabularResourceId, columnLocalId, + ruleIds); } return; diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/ApplyColumnRulesSession.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/ApplyAndDetachColumnRulesSession.java similarity index 85% rename from src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/ApplyColumnRulesSession.java rename to src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/ApplyAndDetachColumnRulesSession.java index 31edf9b..083fc6a 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/ApplyColumnRulesSession.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/ApplyAndDetachColumnRulesSession.java @@ -12,7 +12,7 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData; * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it * */ -public class ApplyColumnRulesSession implements Serializable { +public class ApplyAndDetachColumnRulesSession implements Serializable { private static final long serialVersionUID = -7746819321348425711L; private TRId trId; @@ -20,7 +20,7 @@ public class ApplyColumnRulesSession implements Serializable { private ArrayList rulesThatWillBeApplied; private ArrayList rulesThatWillBeDetached; - public ApplyColumnRulesSession() { + public ApplyAndDetachColumnRulesSession() { super(); } @@ -31,7 +31,7 @@ public class ApplyColumnRulesSession implements Serializable { * @param rulesThatWillBeApplied * @param rulesThatWillBeDetached */ - public ApplyColumnRulesSession(TRId trId, ColumnData column, + public ApplyAndDetachColumnRulesSession(TRId trId, ColumnData column, ArrayList rulesThatWillBeApplied, ArrayList rulesThatWillBeDetached) { super(); @@ -77,9 +77,11 @@ public class ApplyColumnRulesSession implements Serializable { @Override public String toString() { - return "ApplyColumnRulesSession [trId=" + trId + ", column=" + column - + ", rulesThatWillBeApplied=" + rulesThatWillBeApplied + return "ApplyAndDetachColumnRulesSession [trId=" + trId + ", column=" + + column + ", rulesThatWillBeApplied=" + rulesThatWillBeApplied + ", rulesThatWillBeDetached=" + rulesThatWillBeDetached + "]"; } + + }