Updated Rules

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@114362 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-04-23 11:30:29 +00:00
parent 124511bc5e
commit f7fd6729f7
4 changed files with 59 additions and 51 deletions

View File

@ -117,7 +117,7 @@ public class SessionConstants {
public static final String GEOMETRY_CREATE_POINT_SESSION = "GEOMETRY_CREATE_POINT_SESSION"; 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"; public static final String RULES_ON_COLUMN_DETACH_SESSION = "RULES_ON_COLUMN_DETACH_SESSION";

View File

@ -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.history.RollBackSession;
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession; 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.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.rule.DetachColumnRulesSession;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession; 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.sdmx.SDMXImportSession;
@ -1093,32 +1093,32 @@ public class SessionUtil {
// //
public static ApplyColumnRulesSession getRulesOnColumnApplySession( public static ApplyAndDetachColumnRulesSession getRulesOnColumnApplyAndDetachSession(
HttpSession httpSession) { HttpSession httpSession) {
ApplyColumnRulesSession applyColumnRulesSession = (ApplyColumnRulesSession) httpSession ApplyAndDetachColumnRulesSession applyColumnRulesSession = (ApplyAndDetachColumnRulesSession) httpSession
.getAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_SESSION); .getAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_AND_DETACH_SESSION);
if (applyColumnRulesSession != null) { if (applyColumnRulesSession != null) {
return applyColumnRulesSession; return applyColumnRulesSession;
} else { } else {
applyColumnRulesSession = new ApplyColumnRulesSession(); applyColumnRulesSession = new ApplyAndDetachColumnRulesSession();
httpSession.setAttribute( httpSession.setAttribute(
SessionConstants.RULES_ON_COLUMN_APPLY_SESSION, SessionConstants.RULES_ON_COLUMN_APPLY_AND_DETACH_SESSION,
applyColumnRulesSession); applyColumnRulesSession);
return applyColumnRulesSession; return applyColumnRulesSession;
} }
} }
public static void setRulesOnColumnApplySession( public static void setRulesOnColumnApplyAndDetachSession(
HttpSession httpSession, HttpSession httpSession,
ApplyColumnRulesSession applyColumnRulesSession) { ApplyAndDetachColumnRulesSession applyColumnRulesSession) {
ApplyColumnRulesSession rules = (ApplyColumnRulesSession) httpSession ApplyAndDetachColumnRulesSession rules = (ApplyAndDetachColumnRulesSession) httpSession
.getAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_SESSION); .getAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_AND_DETACH_SESSION);
if (rules != null) { if (rules != null) {
httpSession httpSession
.removeAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_SESSION); .removeAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_AND_DETACH_SESSION);
} }
httpSession.setAttribute( httpSession.setAttribute(
SessionConstants.RULES_ON_COLUMN_APPLY_SESSION, SessionConstants.RULES_ON_COLUMN_APPLY_AND_DETACH_SESSION,
applyColumnRulesSession); applyColumnRulesSession);
} }

View File

@ -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.monitor.OperationMonitorSession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.DetachColumnRulesSession; 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.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.SDMXExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.share.Contacts; 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 * @param session
* @return * @return
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public String startApplyColumnnRules( public String startApplyAndDetachColumnnRules(
ApplyColumnRulesSession applyColumnRulesSession, HttpSession session) ApplyAndDetachColumnRulesSession applyAndDetachColumnRulesSession,
throws TDGWTServiceException { HttpSession session) throws TDGWTServiceException {
try { try {
// HttpSession session = this.getThreadLocalRequest().getSession(); // HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session); ASLSession aslSession = SessionUtil.getAslSession(session);
SessionUtil.setRulesOnColumnApplySession(session, SessionUtil.setRulesOnColumnApplyAndDetachSession(session,
applyColumnRulesSession); applyAndDetachColumnRulesSession);
if (applyColumnRulesSession == null) { if (applyAndDetachColumnRulesSession == null) {
logger.error("ApplyColumnRulesSession is null"); logger.error("ApplyAndDetachColumnRulesSession is null");
throw new TDGWTServiceException( 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( AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope())); aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService(); TabularDataService service = TabularDataServiceFactory.getService();
checkTRId(applyColumnRulesSession.getTrId()); checkTRId(applyAndDetachColumnRulesSession.getTrId());
TabularResourceId tabularResourceId = new TabularResourceId( TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(applyColumnRulesSession.getTrId().getId())); Long.valueOf(applyAndDetachColumnRulesSession.getTrId()
.getId()));
TabularResource tabularResource = service TabularResource tabularResource = service
.getTabularResource(tabularResourceId); .getTabularResource(tabularResourceId);
@ -9470,9 +9471,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
checkTabularResourceLocked(tabularResource); checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource); checkTabularResourceIsFinal(tabularResource);
ColumnData column = applyColumnRulesSession.getColumn(); ColumnData column = applyAndDetachColumnRulesSession.getColumn();
if (column == null) { 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( throw new TDGWTServiceException(
"Error in apply rules on column: No column selected."); "Error in apply rules on column: No column selected.");
} }
@ -9480,7 +9481,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
ColumnLocalId columnLocalId = new ColumnLocalId( ColumnLocalId columnLocalId = new ColumnLocalId(
column.getColumnId()); column.getColumnId());
ArrayList<RuleDescriptionData> rulesThatWillBeDetach = applyColumnRulesSession ArrayList<RuleDescriptionData> rulesThatWillBeDetach = applyAndDetachColumnRulesSession
.getRulesThatWillBeDetached(); .getRulesThatWillBeDetached();
if (rulesThatWillBeDetach != null if (rulesThatWillBeDetach != null
&& rulesThatWillBeDetach.size() > 0) { && rulesThatWillBeDetach.size() > 0) {
@ -9493,23 +9494,27 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
ruleIdsDetach); ruleIdsDetach);
} }
ArrayList<RuleDescriptionData> rulesThatWillBeApplied = applyColumnRulesSession ArrayList<RuleDescriptionData> rulesThatWillBeApplied = applyAndDetachColumnRulesSession
.getRulesThatWillBeApplied(); .getRulesThatWillBeApplied();
ArrayList<RuleId> ruleIdsApplied = new ArrayList<RuleId>(); if (rulesThatWillBeApplied != null
for (RuleDescriptionData r : rulesThatWillBeApplied) { && rulesThatWillBeApplied.size() > 0) {
RuleId ruleAppliedId = new RuleId(r.getId()); ArrayList<RuleId> ruleIdsApplied = new ArrayList<RuleId>();
ruleIdsApplied.add(ruleAppliedId); 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) { } catch (TDGWTServiceException e) {
throw e; throw e;
} catch (SecurityException e) { } catch (SecurityException e) {
@ -9567,10 +9572,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException( throw new TDGWTServiceException(
"Error in detach rules on column: No column selected."); "Error in detach rules on column: No column selected.");
} }
ColumnLocalId columnLocalId = new ColumnLocalId( ColumnLocalId columnLocalId = new ColumnLocalId(
column.getColumnId()); column.getColumnId());
ArrayList<RuleDescriptionData> rules = detachColumnRulesSession ArrayList<RuleDescriptionData> rules = detachColumnRulesSession
.getRules(); .getRules();
ArrayList<RuleId> ruleIds = new ArrayList<RuleId>(); ArrayList<RuleId> ruleIds = new ArrayList<RuleId>();
@ -9579,7 +9584,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
RuleId ruleId = new RuleId(r.getId()); RuleId ruleId = new RuleId(r.getId());
ruleIds.add(ruleId); ruleIds.add(ruleId);
} }
service.detachColumnRules(tabularResourceId, columnLocalId, ruleIds); service.detachColumnRules(tabularResourceId, columnLocalId,
ruleIds);
} }
return; return;

View File

@ -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</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class ApplyColumnRulesSession implements Serializable { public class ApplyAndDetachColumnRulesSession implements Serializable {
private static final long serialVersionUID = -7746819321348425711L; private static final long serialVersionUID = -7746819321348425711L;
private TRId trId; private TRId trId;
@ -20,7 +20,7 @@ public class ApplyColumnRulesSession implements Serializable {
private ArrayList<RuleDescriptionData> rulesThatWillBeApplied; private ArrayList<RuleDescriptionData> rulesThatWillBeApplied;
private ArrayList<RuleDescriptionData> rulesThatWillBeDetached; private ArrayList<RuleDescriptionData> rulesThatWillBeDetached;
public ApplyColumnRulesSession() { public ApplyAndDetachColumnRulesSession() {
super(); super();
} }
@ -31,7 +31,7 @@ public class ApplyColumnRulesSession implements Serializable {
* @param rulesThatWillBeApplied * @param rulesThatWillBeApplied
* @param rulesThatWillBeDetached * @param rulesThatWillBeDetached
*/ */
public ApplyColumnRulesSession(TRId trId, ColumnData column, public ApplyAndDetachColumnRulesSession(TRId trId, ColumnData column,
ArrayList<RuleDescriptionData> rulesThatWillBeApplied, ArrayList<RuleDescriptionData> rulesThatWillBeApplied,
ArrayList<RuleDescriptionData> rulesThatWillBeDetached) { ArrayList<RuleDescriptionData> rulesThatWillBeDetached) {
super(); super();
@ -77,9 +77,11 @@ public class ApplyColumnRulesSession implements Serializable {
@Override @Override
public String toString() { public String toString() {
return "ApplyColumnRulesSession [trId=" + trId + ", column=" + column return "ApplyAndDetachColumnRulesSession [trId=" + trId + ", column="
+ ", rulesThatWillBeApplied=" + rulesThatWillBeApplied + column + ", rulesThatWillBeApplied=" + rulesThatWillBeApplied
+ ", rulesThatWillBeDetached=" + rulesThatWillBeDetached + "]"; + ", rulesThatWillBeDetached=" + rulesThatWillBeDetached + "]";
} }
} }