Updated Rules

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@114343 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-04-22 16:55:56 +00:00
parent d2231d440f
commit 24f61b503c
5 changed files with 190 additions and 12 deletions

View File

@ -119,5 +119,6 @@ public class SessionConstants {
public static final String RULES_ON_COLUMN_APPLY_SESSION = "RULES_ON_COLUMN_APPLY_SESSION";
public static final String RULES_ON_COLUMN_DETACH_SESSION = "RULES_ON_COLUMN_DETACH_SESSION";
}

View File

@ -31,6 +31,7 @@ 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.DetachColumnRulesSession;
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.source.SDMXRegistrySource;
@ -1094,22 +1095,22 @@ public class SessionUtil {
//
public static ApplyColumnRulesSession getRulesOnColumnApplySession(
HttpSession httpSession) {
ApplyColumnRulesSession rulesOnColumnApplySession = (ApplyColumnRulesSession) httpSession
ApplyColumnRulesSession applyColumnRulesSession = (ApplyColumnRulesSession) httpSession
.getAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_SESSION);
if (rulesOnColumnApplySession != null) {
return rulesOnColumnApplySession;
if (applyColumnRulesSession != null) {
return applyColumnRulesSession;
} else {
rulesOnColumnApplySession = new ApplyColumnRulesSession();
applyColumnRulesSession = new ApplyColumnRulesSession();
httpSession.setAttribute(
SessionConstants.RULES_ON_COLUMN_APPLY_SESSION,
rulesOnColumnApplySession);
return rulesOnColumnApplySession;
applyColumnRulesSession);
return applyColumnRulesSession;
}
}
public static void setRulesOnColumnApplySession(
HttpSession httpSession,
ApplyColumnRulesSession rulesOnColumnApplySession) {
ApplyColumnRulesSession applyColumnRulesSession) {
ApplyColumnRulesSession rules = (ApplyColumnRulesSession) httpSession
.getAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_SESSION);
if (rules != null) {
@ -1118,9 +1119,41 @@ public class SessionUtil {
}
httpSession.setAttribute(
SessionConstants.RULES_ON_COLUMN_APPLY_SESSION,
rulesOnColumnApplySession);
applyColumnRulesSession);
}
//
public static DetachColumnRulesSession getDetachColumnRulesSession(
HttpSession httpSession) {
DetachColumnRulesSession detachColumnRulesSession = (DetachColumnRulesSession) httpSession
.getAttribute(SessionConstants.RULES_ON_COLUMN_DETACH_SESSION);
if (detachColumnRulesSession != null) {
return detachColumnRulesSession;
} else {
detachColumnRulesSession = new DetachColumnRulesSession();
httpSession.setAttribute(
SessionConstants.RULES_ON_COLUMN_DETACH_SESSION,
detachColumnRulesSession);
return detachColumnRulesSession;
}
}
public static void setDetachColumnRulesSession(
HttpSession httpSession,
DetachColumnRulesSession detachColumnRulesSession) {
DetachColumnRulesSession rules = (DetachColumnRulesSession) httpSession
.getAttribute(SessionConstants.RULES_ON_COLUMN_DETACH_SESSION);
if (rules != null) {
httpSession
.removeAttribute(SessionConstants.RULES_ON_COLUMN_DETACH_SESSION);
}
httpSession.setAttribute(
SessionConstants.RULES_ON_COLUMN_DETACH_SESSION,
detachColumnRulesSession);
}
//
public static TaskResubmitSession getTaskResubmitSession(

View File

@ -193,6 +193,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.monitor.BackgroundOperationM
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitorCreator;
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.sdmx.SDMXExportSession;
@ -9490,7 +9491,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
ruleIds.add(ruleId);
}
Task trTask = service.applyColumnRule(tabularResourceId, column.getColumnId(),ruleIds );
ColumnLocalId columnLocalId=new ColumnLocalId(column.getColumnId());
Task trTask = service.applyColumnRule(tabularResourceId, columnLocalId,ruleIds );
logger.debug("Rules On Column Apply: TaskId "
+ trTask.getId());
@ -9512,7 +9515,78 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
+ e.getLocalizedMessage());
}
}
/**
*
* @param detachColumnRulesSession
* @param session
* @return
* @throws TDGWTServiceException
*/
public void setDetachColumnnRules(
DetachColumnRulesSession detachColumnRulesSession,
HttpSession session) throws TDGWTServiceException {
try {
// HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
SessionUtil.setDetachColumnRulesSession(session, detachColumnRulesSession);
if (detachColumnRulesSession == null) {
logger.error("DetachColumnRulesSession is null");
throw new TDGWTServiceException(
"Error in detach rules on column: DetachColumnRulesSession is null");
}
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTRId(detachColumnRulesSession.getTrId());
TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(detachColumnRulesSession
.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
ColumnData column=detachColumnRulesSession.getColumn();
if(column==null){
logger.error("Error in detach rules on column: No column selected.");
throw new TDGWTServiceException(
"Error in detach rules on column: No column selected.");
}
ArrayList<RuleDescriptionData> rules=detachColumnRulesSession.getRules();
ArrayList<RuleId> ruleIds=new ArrayList<RuleId>();
for(RuleDescriptionData r:rules){
RuleId ruleId=new RuleId(r.getId());
ruleIds.add(ruleId);
}
ColumnLocalId columnLocalId=new ColumnLocalId(column.getColumnId());
service.detachColumnRules(tabularResourceId, columnLocalId,ruleIds );
return;
} catch (TDGWTServiceException e) {
throw e;
} catch (SecurityException e) {
e.printStackTrace();
throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS);
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Error in detach rules on column: "
+ e.getLocalizedMessage());
}
}
}

View File

@ -57,11 +57,12 @@ public class ApplyColumnRulesSession implements Serializable {
@Override
public String toString() {
return "RulesOnColumnApplySession [trId=" + trId + ", column=" + column
return "ApplyColumnRulesSession [trId=" + trId + ", column=" + column
+ ", rules=" + rules + "]";
}
}

View File

@ -0,0 +1,69 @@
package org.gcube.portlets.user.td.gwtservice.shared.rule;
import java.io.Serializable;
import java.util.ArrayList;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DetachColumnRulesSession implements Serializable {
private static final long serialVersionUID = -7746819321348425711L;
private TRId trId;
private ColumnData column;
private ArrayList<RuleDescriptionData> rules;
public DetachColumnRulesSession() {
super();
}
public DetachColumnRulesSession(TRId trId, ColumnData column,
ArrayList<RuleDescriptionData> rules) {
super();
this.trId = trId;
this.column = column;
this.rules = rules;
}
public TRId getTrId() {
return trId;
}
public void setTrId(TRId trId) {
this.trId = trId;
}
public ColumnData getColumn() {
return column;
}
public void setColumn(ColumnData column) {
this.column = column;
}
public ArrayList<RuleDescriptionData> getRules() {
return rules;
}
public void setRules(ArrayList<RuleDescriptionData> rules) {
this.rules = rules;
}
@Override
public String toString() {
return "DetachColumnRulesSession [trId=" + trId + ", column=" + column
+ ", rules=" + rules + "]";
}
}