81: Allow the creation and use of expressions on multi column in TDM portlet
Task-Url: https://support.d4science.org/issues/81 Updated apply rule on table git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@115078 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
162662e6ee
commit
37e88a0598
|
@ -120,5 +120,8 @@ public class SessionConstants {
|
|||
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_TABLE_APPLY_SESSION = "RULES_ON_TABLE_APPLY_SESSION";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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.ApplyAndDetachColumnRulesSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyTableRuleSession;
|
||||
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;
|
||||
|
@ -90,6 +91,7 @@ public class SessionUtil {
|
|||
if (username == null) {
|
||||
logger.warn("no user found in session, use test user");
|
||||
throw new TDGWTSessionExpiredException("Session Expired!");
|
||||
|
||||
/*
|
||||
// Remove comment for Test
|
||||
username = Constants.DEFAULT_USER;
|
||||
|
@ -1123,6 +1125,38 @@ public class SessionUtil {
|
|||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
public static ApplyTableRuleSession getApplyTableRuleSession(
|
||||
HttpSession httpSession) {
|
||||
ApplyTableRuleSession applyTableRuleSession = (ApplyTableRuleSession) httpSession
|
||||
.getAttribute(SessionConstants.RULES_ON_TABLE_APPLY_SESSION);
|
||||
if (applyTableRuleSession != null) {
|
||||
return applyTableRuleSession;
|
||||
} else {
|
||||
applyTableRuleSession = new ApplyTableRuleSession();
|
||||
httpSession.setAttribute(
|
||||
SessionConstants.RULES_ON_TABLE_APPLY_SESSION,
|
||||
applyTableRuleSession);
|
||||
return applyTableRuleSession;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setApplyTableRuleSession(
|
||||
HttpSession httpSession,
|
||||
ApplyTableRuleSession applyTableRuleSession) {
|
||||
ApplyTableRuleSession atrs = (ApplyTableRuleSession) httpSession
|
||||
.getAttribute(SessionConstants.RULES_ON_TABLE_APPLY_SESSION);
|
||||
if (atrs != null) {
|
||||
httpSession
|
||||
.removeAttribute(SessionConstants.RULES_ON_TABLE_APPLY_SESSION);
|
||||
}
|
||||
httpSession.setAttribute(
|
||||
SessionConstants.RULES_ON_TABLE_APPLY_SESSION,
|
||||
applyTableRuleSession);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
public static DetachColumnRulesSession getDetachColumnRulesSession(
|
||||
HttpSession httpSession) {
|
||||
|
|
|
@ -196,6 +196,7 @@ 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.ApplyAndDetachColumnRulesSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyTableRuleSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.DetachColumnRulesSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
||||
|
@ -9559,6 +9560,72 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param applyTableRuleSession
|
||||
* @param session
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public String startApplyTableRule(
|
||||
ApplyTableRuleSession applyTableRuleSession,
|
||||
HttpSession session) throws TDGWTServiceException {
|
||||
try {
|
||||
// HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
SessionUtil.setApplyTableRuleSession(session,
|
||||
applyTableRuleSession);
|
||||
|
||||
if (applyTableRuleSession == null) {
|
||||
logger.error("Apply Table Rule Session is null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in apply rule on table: ApplyTableRuleSession is null");
|
||||
}
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
checkTRId(applyTableRuleSession.getTrId());
|
||||
|
||||
TabularResourceId tabularResourceId = new TabularResourceId(
|
||||
Long.valueOf(applyTableRuleSession.getTrId()
|
||||
.getId()));
|
||||
TabularResource tabularResource = service
|
||||
.getTabularResource(tabularResourceId);
|
||||
|
||||
checkTabularResourceIsFlow(tabularResource);
|
||||
checkTabularResourceLocked(tabularResource);
|
||||
checkTabularResourceIsFinal(tabularResource);
|
||||
|
||||
//TODO
|
||||
Task trTask = null;
|
||||
//service.applyTableRule(tabularResourceId,....);
|
||||
//logger.debug("Rules On Table Apply: TaskId " + trTask.getId());
|
||||
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.RuleOnColumnApply,
|
||||
applyTableRuleSession.getTrId());
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
return null;
|
||||
//return trTask.getId().getValue();
|
||||
|
||||
} 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 apply rules on table: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.shared.rule;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ApplyTableRuleSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1922171869337643740L;
|
||||
private TRId trId;
|
||||
private RuleDescriptionData ruleDescriptionData;
|
||||
private HashMap<String, String> placeHolderToColumnMap;
|
||||
|
||||
public ApplyTableRuleSession() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ApplyTableRuleSession(TRId trId,
|
||||
RuleDescriptionData ruleDescriptionData,
|
||||
HashMap<String, String> placeHolderToColumnMap) {
|
||||
super();
|
||||
this.trId = trId;
|
||||
this.ruleDescriptionData = ruleDescriptionData;
|
||||
this.placeHolderToColumnMap = placeHolderToColumnMap;
|
||||
}
|
||||
|
||||
public TRId getTrId() {
|
||||
return trId;
|
||||
}
|
||||
|
||||
public void setTrId(TRId trId) {
|
||||
this.trId = trId;
|
||||
}
|
||||
|
||||
public RuleDescriptionData getRuleDescriptionData() {
|
||||
return ruleDescriptionData;
|
||||
}
|
||||
|
||||
public void setRuleDescriptionData(RuleDescriptionData ruleDescriptionData) {
|
||||
this.ruleDescriptionData = ruleDescriptionData;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getPlaceHolderToColumnMap() {
|
||||
return placeHolderToColumnMap;
|
||||
}
|
||||
|
||||
public void setPlaceHolderToColumnMap(
|
||||
HashMap<String, String> placeHolderToColumnMap) {
|
||||
this.placeHolderToColumnMap = placeHolderToColumnMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ApplyTableRuleSession [trId=" + trId + ", ruleDescriptionData="
|
||||
+ ruleDescriptionData + ", placeHolderToColumnMap="
|
||||
+ placeHolderToColumnMap + "]";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue