Updated C_ExpressionParser

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@113948 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-04-10 17:07:27 +00:00
parent 1315884dfd
commit aa855309eb
49 changed files with 1285 additions and 65 deletions

View File

@ -62,3 +62,67 @@ Compiling...
Compilation completed in 0.00 seconds Compilation completed in 0.00 seconds
Removing invalidated units Removing invalidated units
Finding entry point classes Finding entry point classes
Public resources found in...
Translatable source found in...
Found 0 cached/archived units. Used 0 / 2737 units from cache.
Compiling...
10% complete (ETR: 24 seconds)
10% complete (ETR: 24 seconds)
20% complete (ETR: 22 seconds)
30% complete (ETR: 17 seconds)
40% complete (ETR: 12 seconds)
50% complete (ETR: 9 seconds)
60% complete (ETR: 6 seconds)
70% complete (ETR: 4 seconds)
80% complete (ETR: 3 seconds)
90% complete (ETR: 1 seconds)
100% complete (ETR: 0 seconds)
Compilation completed in 27.69 seconds
Removing invalidated units
Finding entry point classes
Public resources found in...
Translatable source found in...
Found 2737 cached/archived units. Used 2737 / 2737 units from cache.
Compiling...
Compilation completed in 0.00 seconds
Removing invalidated units
Finding entry point classes
Public resources found in...
Translatable source found in...
Found 2737 cached/archived units. Used 2737 / 2737 units from cache.
Compiling...
Compilation completed in 0.00 seconds
Removing invalidated units
Finding entry point classes
Public resources found in...
Translatable source found in...
Found 0 cached/archived units. Used 0 / 2737 units from cache.
Compiling...
40% complete (ETR: 7 seconds)
40% complete (ETR: 7 seconds)
40% complete (ETR: 7 seconds)
40% complete (ETR: 7 seconds)
40% complete (ETR: 7 seconds)
50% complete (ETR: 6 seconds)
60% complete (ETR: 4 seconds)
70% complete (ETR: 3 seconds)
80% complete (ETR: 2 seconds)
90% complete (ETR: 1 seconds)
100% complete (ETR: 0 seconds)
Compilation completed in 20.49 seconds
Removing invalidated units
Finding entry point classes
Public resources found in...
Translatable source found in...
Found 2737 cached/archived units. Used 2737 / 2737 units from cache.
Compiling...
Compilation completed in 0.00 seconds
Removing invalidated units
Finding entry point classes
Public resources found in...
Translatable source found in...
Found 2737 cached/archived units. Used 2737 / 2737 units from cache.
Compiling...
Compilation completed in 0.00 seconds
Removing invalidated units
Finding entry point classes

View File

@ -1,12 +1,15 @@
package org.gcube.portlets.user.td.expressionwidget.server; package org.gcube.portlets.user.td.expressionwidget.server;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider; import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken; import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.RuleDescription;
import org.gcube.data.analysis.tabulardata.expression.Expression; import org.gcube.data.analysis.tabulardata.expression.Expression;
import org.gcube.data.analysis.tabulardata.model.metadata.table.DatasetViewTableMetadata; import org.gcube.data.analysis.tabulardata.model.metadata.table.DatasetViewTableMetadata;
import org.gcube.data.analysis.tabulardata.model.table.Table; import org.gcube.data.analysis.tabulardata.model.table.Table;
@ -15,8 +18,11 @@ import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactor
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource; import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId; import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId;
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionService; import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionService;
import org.gcube.portlets.user.td.expressionwidget.server.service.RuleScopeMap;
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ExpressionParserException; import org.gcube.portlets.user.td.expressionwidget.shared.exception.ExpressionParserException;
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ExpressionServiceException; import org.gcube.portlets.user.td.expressionwidget.shared.exception.ExpressionServiceException;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
import org.gcube.portlets.user.td.gwtservice.server.SessionUtil; import org.gcube.portlets.user.td.gwtservice.server.SessionUtil;
import org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl; import org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TabularResourceTypeMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.TabularResourceTypeMap;
@ -26,6 +32,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnByExpressionSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnByExpressionSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -206,6 +213,57 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
} }
} }
//TODO
public ArrayList<RuleDescriptionData> getRule(RuleScopeType scope) throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("GetRule()");
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
service.getRules();
List<RuleDescription> rules=service.getRulesByScope(RuleScopeMap.map(scope));
ArrayList<RuleDescriptionData> rulesDes=new ArrayList<RuleDescriptionData>();
C_ExpressionParser parser = new C_ExpressionParser();
for(RuleDescription ruleDescription: rules){
Expression serviceExpression=ruleDescription.getRule();
C_Expression cexp=parser.parse(serviceExpression);
RuleDescriptionData ruleData=new RuleDescriptionData(ruleDescription.getId(),
ruleDescription.getName(), ruleDescription.getDescription(),
RuleScopeMap.map(ruleDescription.getScope()),
cexp);
rulesDes.add(ruleData);
}
return rulesDes;
} catch (TDGWTServiceException e) {
logger.error(e.getLocalizedMessage(),e);
throw e;
} catch (SecurityException e) {
logger.error(e.getLocalizedMessage(),e);
throw e;
} catch (Throwable e) {
logger.error(
"Error in getRule(): " + e.getLocalizedMessage(),
e);
throw new TDGWTServiceException("Error retrieving the rules: "
+ e.getLocalizedMessage());
}
}
/** /**
* Retrieve and set Tabular Resource Type * Retrieve and set Tabular Resource Type
* *

View File

@ -0,0 +1,46 @@
package org.gcube.portlets.user.td.expressionwidget.server.service;
import org.gcube.data.analysis.tabulardata.commons.rules.RuleScope;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class RuleScopeMap {
public static RuleScopeType map(RuleScope ruleScope) {
if(ruleScope==null){
return null;
}
switch (ruleScope) {
case COLUMN:
return RuleScopeType.COLUMN;
case TABLE:
return RuleScopeType.TABLE;
default:
return null;
}
}
public static RuleScope map(RuleScopeType ruleScopeType) {
if(ruleScopeType==null){
return null;
}
switch (ruleScopeType) {
case COLUMN:
return RuleScope.COLUMN;
case TABLE:
return RuleScope.TABLE;
default:
return null;
}
}
}

View File

@ -1,29 +1,31 @@
package org.gcube.portlets.user.td.expressionwidget.shared.model.composite; package org.gcube.portlets.user.td.expressionwidget.shared.model.composite;
import org.gcube.portlets.user.td.expressionwidget.shared.expression.C_MultivaluedExpression; import org.gcube.portlets.user.td.expressionwidget.shared.expression.C_MultivaluedExpression;
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_Leaf; import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_Leaf;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression; import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
public class C_ExternalReferenceExpression extends C_Expression implements C_MultivaluedExpression{ public class C_ExternalReferenceExpression extends C_Expression implements
C_MultivaluedExpression {
private static final long serialVersionUID = 1260894239836974010L; private static final long serialVersionUID = 1260894239836974010L;
protected C_Leaf leftArgument; protected C_Leaf leftArgument;
protected C_Expression rightArgument; protected C_Expression rightArgument;
protected String id="ExternalReferenceExpression"; protected String id = "ExternalReferenceExpression";
public C_ExternalReferenceExpression() { public C_ExternalReferenceExpression() {
} }
public C_ExternalReferenceExpression(C_Leaf leftArgument, C_Expression rightArgument) { public C_ExternalReferenceExpression(C_Leaf leftArgument,
C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "ExternalReferenceExpression("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
@Override @Override
public String getId() { public String getId() {
return id; return id;
@ -52,12 +54,8 @@ public class C_ExternalReferenceExpression extends C_Expression implements C_Mul
@Override @Override
public String toString() { public String toString() {
return "ExternalReferenceExpression [ id=" + id+", leftArgument=" + leftArgument return "ExternalReferenceExpression [ id=" + id + ", leftArgument="
+ ", rightArgument=" + rightArgument + "]"; + leftArgument + ", rightArgument=" + rightArgument + "]";
} }
} }

View File

@ -22,6 +22,9 @@ public class C_AggregationExpression extends C_Expression {
public C_AggregationExpression(C_Expression argument) { public C_AggregationExpression(C_Expression argument) {
this.argument = argument; this.argument = argument;
this.readableExpression = "AggregationExpression("
+ argument.getReadableExpression() + ")";
} }
@Override @Override

View File

@ -24,6 +24,8 @@ public class C_Avg extends C_AggregationExpression {
*/ */
public C_Avg(C_Expression argument) { public C_Avg(C_Expression argument) {
this.argument = argument; this.argument = argument;
this.readableExpression = "AVG("
+ argument.getReadableExpression() + ")";
} }

View File

@ -24,7 +24,8 @@ public class C_Count extends C_AggregationExpression {
*/ */
public C_Count(C_Expression argument) { public C_Count(C_Expression argument) {
this.argument = argument; this.argument = argument;
this.readableExpression = "Count("
+ argument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -24,7 +24,8 @@ public class C_Max extends C_AggregationExpression {
*/ */
public C_Max(C_Expression argument) { public C_Max(C_Expression argument) {
this.argument = argument; this.argument = argument;
this.readableExpression = "Max("
+ argument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -24,7 +24,8 @@ public class C_Min extends C_AggregationExpression {
*/ */
public C_Min(C_Expression argument) { public C_Min(C_Expression argument) {
this.argument = argument; this.argument = argument;
this.readableExpression = "Min("
+ argument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -23,6 +23,8 @@ public class C_ST_Extent extends C_AggregationExpression {
*/ */
public C_ST_Extent(C_Expression argument) { public C_ST_Extent(C_Expression argument) {
this.argument = argument; this.argument = argument;
this.readableExpression = "ST_Extent("
+ argument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -24,7 +24,8 @@ public class C_Sum extends C_AggregationExpression {
*/ */
public C_Sum(C_Expression argument) { public C_Sum(C_Expression argument) {
this.argument = argument; this.argument = argument;
this.readableExpression = "Sum("
+ argument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -23,6 +23,9 @@ public class C_Addition extends C_ArithmeticExpression {
public C_Addition(C_Expression leftArgument, C_Expression rightArgument) { public C_Addition(C_Expression leftArgument, C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "Addition("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -30,6 +30,9 @@ public class C_ArithmeticExpression extends C_Expression {
C_Expression rightArgument) { C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "ArithmeticExpression("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
static { static {

View File

@ -22,6 +22,9 @@ public class C_Division extends C_ArithmeticExpression {
public C_Division(C_Expression leftArgument, C_Expression rightArgument) { public C_Division(C_Expression leftArgument, C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "Division("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -27,6 +27,9 @@ public class C_Exponentiation extends C_ArithmeticExpression {
public C_Exponentiation(C_Expression leftArgument, C_Expression rightArgument) { public C_Exponentiation(C_Expression leftArgument, C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "Exponentiation("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }

View File

@ -22,6 +22,9 @@ public class C_Modulus extends C_ArithmeticExpression {
public C_Modulus(C_Expression leftArgument, C_Expression rightArgument) { public C_Modulus(C_Expression leftArgument, C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "Modulus("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -22,6 +22,9 @@ public class C_Multiplication extends C_ArithmeticExpression {
public C_Multiplication(C_Expression leftArgument, C_Expression rightArgument) { public C_Multiplication(C_Expression leftArgument, C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "Multiplication("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -23,6 +23,9 @@ public class C_Subtraction extends C_ArithmeticExpression {
public C_Subtraction(C_Expression leftArgument, C_Expression rightArgument) { public C_Subtraction(C_Expression leftArgument, C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "Subtraction("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -23,6 +23,9 @@ public class C_Equals extends C_Expression {
public C_Equals(C_Expression leftArgument, C_Expression rightArgument) { public C_Equals(C_Expression leftArgument, C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "Equals("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -24,6 +24,9 @@ public class C_GreaterOrEquals extends C_Expression {
C_Expression rightArgument) { C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "GreaterOrEquals("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -22,6 +22,9 @@ public class C_GreaterThan extends C_Expression {
public C_GreaterThan(C_Expression leftArgument, C_Expression rightArgument) { public C_GreaterThan(C_Expression leftArgument, C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "GreaterThan("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -22,6 +22,9 @@ public class C_LessOrEquals extends C_Expression {
public C_LessOrEquals(C_Expression leftArgument, C_Expression rightArgument) { public C_LessOrEquals(C_Expression leftArgument, C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "LessOrEquals("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -22,6 +22,9 @@ public class C_LessThan extends C_Expression {
public C_LessThan(C_Expression leftArgument, C_Expression rightArgument) { public C_LessThan(C_Expression leftArgument, C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "LessThan("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -22,6 +22,9 @@ public class C_NotEquals extends C_Expression {
public C_NotEquals(C_Expression leftArgument, C_Expression rightArgument) { public C_NotEquals(C_Expression leftArgument, C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "NotEquals("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -22,6 +22,9 @@ public class C_NotGreater extends C_Expression {
public C_NotGreater(C_Expression leftArgument, C_Expression rightArgument) { public C_NotGreater(C_Expression leftArgument, C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "NotGreater("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -22,6 +22,9 @@ public class C_NotLess extends C_Expression {
public C_NotLess(C_Expression leftArgument, C_Expression rightArgument) { public C_NotLess(C_Expression leftArgument, C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "NotLess("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -27,6 +27,9 @@ public class C_Cast extends C_Expression {
super(); super();
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "Cast("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getColumnDataTypeLabel() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -26,6 +26,9 @@ public class C_Concat extends C_Expression {
super(); super();
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "Concat("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -20,6 +20,8 @@ public class C_Lenght extends C_Expression {
public C_Lenght(C_Expression argument) { public C_Lenght(C_Expression argument) {
this.argument=argument; this.argument=argument;
this.readableExpression = "Lenght("
+ argument.getReadableExpression() + ")";
} }

View File

@ -25,6 +25,9 @@ public class C_Levenshtein extends C_Expression {
C_Expression rightArgument) { C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "Levenshtein("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -20,6 +20,8 @@ public class C_Lower extends C_Expression {
public C_Lower(C_Expression argument) { public C_Lower(C_Expression argument) {
this.argument=argument; this.argument=argument;
this.readableExpression = "Lower("
+ argument.getReadableExpression() + ")";
} }

View File

@ -20,6 +20,8 @@ public class C_MD5 extends C_Expression {
public C_MD5(C_Expression argument) { public C_MD5(C_Expression argument) {
this.argument=argument; this.argument=argument;
this.readableExpression = "MD5("
+ argument.getReadableExpression() + ")";
} }

View File

@ -25,6 +25,9 @@ public class C_Similarity extends C_Expression {
C_Expression rightArgument) { C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "Similarity("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -20,6 +20,8 @@ public class C_Soundex extends C_Expression {
public C_Soundex(C_Expression argument) { public C_Soundex(C_Expression argument) {
this.argument=argument; this.argument=argument;
this.readableExpression = "Soundex("
+ argument.getReadableExpression() + ")";
} }

View File

@ -28,6 +28,13 @@ public class C_SubstringByIndex extends C_Expression {
this.sourceString = sourceString; this.sourceString = sourceString;
this.fromIndex=fromIndex; this.fromIndex=fromIndex;
this.toIndex=toIndex; this.toIndex=toIndex;
this.readableExpression = "SubstringByIndex("
+ sourceString.getReadableExpression() + ","
+ fromIndex.getReadableExpression() + ","
+ toIndex.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -26,6 +26,10 @@ public class C_SubstringByRegex extends C_Expression {
super(); super();
this.sourceString = sourceString; this.sourceString = sourceString;
this.regex = regex; this.regex = regex;
this.readableExpression = "SubstringByRegex("
+ sourceString.getReadableExpression() + ","
+ regex.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -27,6 +27,9 @@ public class C_SubstringPosition extends C_Expression {
super(); super();
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "SubstringPosition("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }

View File

@ -25,6 +25,9 @@ public class C_TextBeginsWith extends C_Expression {
C_Expression rightArgument) { C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "TextBeginsWith("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -22,6 +22,9 @@ public class C_TextContains extends C_Expression {
public C_TextContains(C_Expression leftArgument, C_Expression rightArgument) { public C_TextContains(C_Expression leftArgument, C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "TextContains("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -22,6 +22,9 @@ public class C_TextEndsWith extends C_Expression {
public C_TextEndsWith(C_Expression leftArgument, C_Expression rightArgument) { public C_TextEndsWith(C_Expression leftArgument, C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "TextEndsWith("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -23,6 +23,9 @@ public class C_TextMatchSQLRegexp extends C_Expression {
C_Expression rightArgument) { C_Expression rightArgument) {
this.leftArgument = leftArgument; this.leftArgument = leftArgument;
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
this.readableExpression = "TextMatchSQLRegexp("
+ leftArgument.getReadableExpression() + ","
+ rightArgument.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -30,6 +30,11 @@ public class C_TextReplaceMatchingRegex extends C_Expression {
this.toCheckText = toCheckText; this.toCheckText = toCheckText;
this.regexp = regexp; this.regexp = regexp;
this.replacing = replacing; this.replacing = replacing;
this.readableExpression = "TextReplaceMatchingRegex("
+ toCheckText.getReadableExpression() + ","
+ regexp.getReadableExpression() + ","
+ replacing.getReadableExpression() + ")";
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {

View File

@ -20,6 +20,8 @@ public class C_Trim extends C_Expression {
public C_Trim(C_Expression argument) { public C_Trim(C_Expression argument) {
this.argument=argument; this.argument=argument;
this.readableExpression = "Trim("
+ argument.getReadableExpression() + ")";
} }

View File

@ -20,6 +20,8 @@ public class C_Upper extends C_Expression {
public C_Upper(C_Expression argument) { public C_Upper(C_Expression argument) {
this.argument=argument; this.argument=argument;
this.readableExpression = "Upper("
+ argument.getReadableExpression() + ")";
} }

View File

@ -12,14 +12,26 @@ public class C_ColumnReference extends C_Leaf {
protected String columnId; protected String columnId;
protected ColumnDataType dataType; protected ColumnDataType dataType;
public C_ColumnReference(){ public C_ColumnReference() {
} }
public C_ColumnReference(TRId trId, ColumnDataType dataType, String columnId) { public C_ColumnReference(TRId trId, ColumnDataType dataType, String columnId) {
this.trId=trId; this.trId = trId;
this.dataType=dataType; this.dataType = dataType;
this.columnId=columnId; this.columnId = columnId;
String tableId = "";
if (trId != null) {
if (trId.isViewTable()) {
tableId = trId.getReferenceTargetTableId();
} else {
tableId = trId.getTableId();
}
}
this.readableExpression = "ColumnReference(" + tableId + ","
+ dataType.getColumnDataTypeLabel() + "," + columnId + ")";
} }
@Override @Override
@ -27,7 +39,6 @@ public class C_ColumnReference extends C_Leaf {
return id; return id;
} }
public TRId getTrId() { public TRId getTrId() {
return trId; return trId;
} }
@ -58,7 +69,4 @@ public class C_ColumnReference extends C_Leaf {
+ ", columnId=" + columnId + ", dataType=" + dataType + "]"; + ", columnId=" + columnId + ", dataType=" + dataType + "]";
} }
} }

View File

@ -26,6 +26,8 @@ public class C_Between extends C_Expression {
this.rightArgument = rightArgument; this.rightArgument = rightArgument;
} }
public C_OperatorType getOperator() { public C_OperatorType getOperator() {
return C_OperatorType.BETWEEN; return C_OperatorType.BETWEEN;
} }

View File

@ -0,0 +1,83 @@
package org.gcube.portlets.user.td.expressionwidget.shared.rule;
import java.io.Serializable;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class RuleDescriptionData implements Serializable {
private static final long serialVersionUID = 2238695825091799598L;
private long id;
private String name;
private String description;
private RuleScopeType scope;
private C_Expression expression;
public RuleDescriptionData() {
super();
}
public RuleDescriptionData(long id, String name, String description,
RuleScopeType scope, C_Expression expression) {
super();
this.id = id;
this.name = name;
this.description = description;
this.scope = scope;
this.expression = expression;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public RuleScopeType getScope() {
return scope;
}
public void setScope(RuleScopeType scope) {
this.scope = scope;
}
public C_Expression getExpression() {
return expression;
}
public void setExpression(C_Expression expression) {
this.expression = expression;
}
@Override
public String toString() {
return "RuleDescriptionData [id=" + id + ", name=" + name
+ ", description=" + description + ", scope=" + scope
+ ", expression=" + expression + "]";
}
}

View File

@ -0,0 +1,37 @@
package org.gcube.portlets.user.td.expressionwidget.shared.rule;
/**
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public enum RuleScopeType {
TABLE("Table"), COLUMN("Column");
/**
* @param text
*/
private RuleScopeType(final String id) {
this.id = id;
}
private final String id;
@Override
public String toString() {
return id;
}
public static RuleScopeType get(String ruleScopeType) {
for(RuleScopeType ws:values()){
if(ws.id.compareTo(ruleScopeType)==0){
return ws;
}
}
return null;
}
}