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 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";

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.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);
}

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.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<RuleDescriptionData> rulesThatWillBeDetach = applyColumnRulesSession
ArrayList<RuleDescriptionData> rulesThatWillBeDetach = applyAndDetachColumnRulesSession
.getRulesThatWillBeDetached();
if (rulesThatWillBeDetach != null
&& rulesThatWillBeDetach.size() > 0) {
@ -9493,23 +9494,27 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
ruleIdsDetach);
}
ArrayList<RuleDescriptionData> rulesThatWillBeApplied = applyColumnRulesSession
ArrayList<RuleDescriptionData> rulesThatWillBeApplied = applyAndDetachColumnRulesSession
.getRulesThatWillBeApplied();
ArrayList<RuleId> ruleIdsApplied = new ArrayList<RuleId>();
for (RuleDescriptionData r : rulesThatWillBeApplied) {
RuleId ruleAppliedId = new RuleId(r.getId());
ruleIdsApplied.add(ruleAppliedId);
if (rulesThatWillBeApplied != null
&& rulesThatWillBeApplied.size() > 0) {
ArrayList<RuleId> ruleIdsApplied = new ArrayList<RuleId>();
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<RuleDescriptionData> rules = detachColumnRulesSession
.getRules();
ArrayList<RuleId> ruleIds = new ArrayList<RuleId>();
@ -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;

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>
*
*/
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<RuleDescriptionData> rulesThatWillBeApplied;
private ArrayList<RuleDescriptionData> 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<RuleDescriptionData> rulesThatWillBeApplied,
ArrayList<RuleDescriptionData> 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 + "]";
}
}