Added Upper, Lower, Trim and MD5 expression
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@113530 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1e189b251c
commit
44f6864f49
|
@ -302,6 +302,10 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
secondArg.setEmptyText("");
|
secondArg.setEmptyText("");
|
||||||
break;
|
break;
|
||||||
case ColumnValue:
|
case ColumnValue:
|
||||||
|
case Upper:
|
||||||
|
case Lower:
|
||||||
|
case Trim:
|
||||||
|
case MD5:
|
||||||
comboColumns.clear();
|
comboColumns.clear();
|
||||||
comboColumns.setVisible(true);
|
comboColumns.setVisible(true);
|
||||||
firstArg.setVisible(false);
|
firstArg.setVisible(false);
|
||||||
|
@ -403,6 +407,10 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
removeOperation(source);
|
removeOperation(source);
|
||||||
break;
|
break;
|
||||||
case ColumnValue:
|
case ColumnValue:
|
||||||
|
case Upper:
|
||||||
|
case Lower:
|
||||||
|
case Trim:
|
||||||
|
case MD5:
|
||||||
comboReplaceElementsLeaf.setVisible(false);
|
comboReplaceElementsLeaf.setVisible(false);
|
||||||
storeColumns.clear();
|
storeColumns.clear();
|
||||||
storeColumns.addAll(columns);
|
storeColumns.addAll(columns);
|
||||||
|
@ -624,6 +632,10 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
secondArg.setEmptyText("");
|
secondArg.setEmptyText("");
|
||||||
break;
|
break;
|
||||||
case ColumnValue:
|
case ColumnValue:
|
||||||
|
case Upper:
|
||||||
|
case Lower:
|
||||||
|
case Trim:
|
||||||
|
case MD5:
|
||||||
comboColumns.clear();
|
comboColumns.clear();
|
||||||
comboColumns.setVisible(true);
|
comboColumns.setVisible(true);
|
||||||
firstArg.setVisible(false);
|
firstArg.setVisible(false);
|
||||||
|
@ -725,6 +737,10 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
removeOperation(source);
|
removeOperation(source);
|
||||||
break;
|
break;
|
||||||
case ColumnValue:
|
case ColumnValue:
|
||||||
|
case Upper:
|
||||||
|
case Lower:
|
||||||
|
case Trim:
|
||||||
|
case MD5:
|
||||||
comboReplaceElementsLeaf.setVisible(false);
|
comboReplaceElementsLeaf.setVisible(false);
|
||||||
storeColumns.clear();
|
storeColumns.clear();
|
||||||
storeColumns.addAll(columns);
|
storeColumns.addAll(columns);
|
||||||
|
|
|
@ -29,6 +29,10 @@ public class ReplaceElementStore {
|
||||||
add(new ReplaceElement(10, ReplaceType.Modulus));
|
add(new ReplaceElement(10, ReplaceType.Modulus));
|
||||||
add(new ReplaceElement(11, ReplaceType.Multiplication));
|
add(new ReplaceElement(11, ReplaceType.Multiplication));
|
||||||
add(new ReplaceElement(12, ReplaceType.Division));
|
add(new ReplaceElement(12, ReplaceType.Division));
|
||||||
|
add(new ReplaceElement(13, ReplaceType.Upper));
|
||||||
|
add(new ReplaceElement(14, ReplaceType.Lower));
|
||||||
|
add(new ReplaceElement(15, ReplaceType.Trim));
|
||||||
|
add(new ReplaceElement(16, ReplaceType.MD5));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,6 +47,10 @@ public class ReplaceElementStore {
|
||||||
add(new ReplaceElement(4, ReplaceType.SubstringByIndex));
|
add(new ReplaceElement(4, ReplaceType.SubstringByIndex));
|
||||||
add(new ReplaceElement(5, ReplaceType.SubstringByCharSeq));
|
add(new ReplaceElement(5, ReplaceType.SubstringByCharSeq));
|
||||||
add(new ReplaceElement(6, ReplaceType.TextReplaceMatchingRegex));
|
add(new ReplaceElement(6, ReplaceType.TextReplaceMatchingRegex));
|
||||||
|
add(new ReplaceElement(7, ReplaceType.Upper));
|
||||||
|
add(new ReplaceElement(8, ReplaceType.Lower));
|
||||||
|
add(new ReplaceElement(9, ReplaceType.Trim));
|
||||||
|
add(new ReplaceElement(10, ReplaceType.MD5));
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,6 +28,8 @@ import org.gcube.data.analysis.tabulardata.expression.composite.comparable.NotEq
|
||||||
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.NotGreater;
|
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.NotGreater;
|
||||||
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.NotLess;
|
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.NotLess;
|
||||||
import org.gcube.data.analysis.tabulardata.expression.composite.text.Concat;
|
import org.gcube.data.analysis.tabulardata.expression.composite.text.Concat;
|
||||||
|
import org.gcube.data.analysis.tabulardata.expression.composite.text.Lower;
|
||||||
|
import org.gcube.data.analysis.tabulardata.expression.composite.text.MD5;
|
||||||
import org.gcube.data.analysis.tabulardata.expression.composite.text.SubstringByIndex;
|
import org.gcube.data.analysis.tabulardata.expression.composite.text.SubstringByIndex;
|
||||||
import org.gcube.data.analysis.tabulardata.expression.composite.text.SubstringByRegex;
|
import org.gcube.data.analysis.tabulardata.expression.composite.text.SubstringByRegex;
|
||||||
import org.gcube.data.analysis.tabulardata.expression.composite.text.SubstringPosition;
|
import org.gcube.data.analysis.tabulardata.expression.composite.text.SubstringPosition;
|
||||||
|
@ -36,6 +38,8 @@ import org.gcube.data.analysis.tabulardata.expression.composite.text.TextContain
|
||||||
import org.gcube.data.analysis.tabulardata.expression.composite.text.TextEndsWith;
|
import org.gcube.data.analysis.tabulardata.expression.composite.text.TextEndsWith;
|
||||||
import org.gcube.data.analysis.tabulardata.expression.composite.text.TextMatchSQLRegexp;
|
import org.gcube.data.analysis.tabulardata.expression.composite.text.TextMatchSQLRegexp;
|
||||||
import org.gcube.data.analysis.tabulardata.expression.composite.text.TextReplaceMatchingRegex;
|
import org.gcube.data.analysis.tabulardata.expression.composite.text.TextReplaceMatchingRegex;
|
||||||
|
import org.gcube.data.analysis.tabulardata.expression.composite.text.Trim;
|
||||||
|
import org.gcube.data.analysis.tabulardata.expression.composite.text.Upper;
|
||||||
import org.gcube.data.analysis.tabulardata.expression.functions.Cast;
|
import org.gcube.data.analysis.tabulardata.expression.functions.Cast;
|
||||||
import org.gcube.data.analysis.tabulardata.expression.leaf.ColumnReferencePlaceholder;
|
import org.gcube.data.analysis.tabulardata.expression.leaf.ColumnReferencePlaceholder;
|
||||||
import org.gcube.data.analysis.tabulardata.expression.leaf.ConstantList;
|
import org.gcube.data.analysis.tabulardata.expression.leaf.ConstantList;
|
||||||
|
@ -87,6 +91,8 @@ import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.compar
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.comparable.C_NotLess;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.comparable.C_NotLess;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.functions.C_Cast;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.functions.C_Cast;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_Concat;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_Concat;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_Lower;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_MD5;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringByIndex;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringByIndex;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringByRegex;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringByRegex;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringPosition;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringPosition;
|
||||||
|
@ -95,6 +101,8 @@ import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_TextEndsWith;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_TextEndsWith;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_TextMatchSQLRegexp;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_TextMatchSQLRegexp;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_TextReplaceMatchingRegex;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_TextReplaceMatchingRegex;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_Trim;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_Upper;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReference;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReference;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReferencePlaceholder;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReferencePlaceholder;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ConstantList;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ConstantList;
|
||||||
|
@ -247,6 +255,18 @@ public class C_ExpressionParser {
|
||||||
case "Division":
|
case "Division":
|
||||||
ex = getDivision(exp);
|
ex = getDivision(exp);
|
||||||
break;
|
break;
|
||||||
|
case "Upper":
|
||||||
|
ex = getUpper(exp);
|
||||||
|
break;
|
||||||
|
case "Lower":
|
||||||
|
ex = getLower(exp);
|
||||||
|
break;
|
||||||
|
case "Trim":
|
||||||
|
ex = getTrim(exp);
|
||||||
|
break;
|
||||||
|
case "MD5":
|
||||||
|
ex = getMD5(exp);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -592,12 +612,44 @@ public class C_ExpressionParser {
|
||||||
TableId tableId = new TableId(Long.valueOf(tableIdS));
|
TableId tableId = new TableId(Long.valueOf(tableIdS));
|
||||||
ColumnLocalId columnId = new ColumnLocalId(c.getColumnId());
|
ColumnLocalId columnId = new ColumnLocalId(c.getColumnId());
|
||||||
|
|
||||||
|
|
||||||
ColumnReference ref = new ColumnReference(tableId, columnId,
|
ColumnReference ref = new ColumnReference(tableId, columnId,
|
||||||
mapColumnDataType(c.getDataType()));
|
mapColumnDataType(c.getDataType()));
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Expression getUpper(C_Expression exp)
|
||||||
|
throws ExpressionParserException {
|
||||||
|
C_Upper e = (C_Upper) exp;
|
||||||
|
Expression arg = parse(e.getArgument());
|
||||||
|
Upper upper = new Upper(arg);
|
||||||
|
return upper;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Expression getLower(C_Expression exp)
|
||||||
|
throws ExpressionParserException {
|
||||||
|
C_Lower e = (C_Lower) exp;
|
||||||
|
Expression arg = parse(e.getArgument());
|
||||||
|
Lower upper = new Lower(arg);
|
||||||
|
return upper;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Expression getTrim(C_Expression exp)
|
||||||
|
throws ExpressionParserException {
|
||||||
|
C_Trim e = (C_Trim) exp;
|
||||||
|
Expression arg = parse(e.getArgument());
|
||||||
|
Trim trim = new Trim(arg);
|
||||||
|
return trim;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Expression getMD5(C_Expression exp)
|
||||||
|
throws ExpressionParserException {
|
||||||
|
C_MD5 e = (C_MD5) exp;
|
||||||
|
Expression arg = parse(e.getArgument());
|
||||||
|
MD5 md5 = new MD5(arg);
|
||||||
|
return md5;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Expression getEquals(C_Expression exp)
|
protected Expression getEquals(C_Expression exp)
|
||||||
throws ExpressionParserException {
|
throws ExpressionParserException {
|
||||||
C_Equals e = (C_Equals) exp;
|
C_Equals e = (C_Equals) exp;
|
||||||
|
@ -649,9 +701,9 @@ public class C_ExpressionParser {
|
||||||
TDText tdRegexp = new TDText(textReplaceMatchingRegex.getRegexp()
|
TDText tdRegexp = new TDText(textReplaceMatchingRegex.getRegexp()
|
||||||
.getValue());
|
.getValue());
|
||||||
|
|
||||||
String replacement=textReplaceMatchingRegex.getReplacing().getValue();
|
String replacement = textReplaceMatchingRegex.getReplacing().getValue();
|
||||||
if(replacement==null){
|
if (replacement == null) {
|
||||||
replacement="";
|
replacement = "";
|
||||||
}
|
}
|
||||||
TDText tdReplacing = new TDText(replacement);
|
TDText tdReplacing = new TDText(replacement);
|
||||||
|
|
||||||
|
@ -738,7 +790,8 @@ public class C_ExpressionParser {
|
||||||
private Expression getMultiplication(C_Expression exp)
|
private Expression getMultiplication(C_Expression exp)
|
||||||
throws ExpressionParserException {
|
throws ExpressionParserException {
|
||||||
C_Multiplication multiplication = (C_Multiplication) exp;
|
C_Multiplication multiplication = (C_Multiplication) exp;
|
||||||
Multiplication multi = new Multiplication(parse(multiplication.getLeftArgument()),
|
Multiplication multi = new Multiplication(
|
||||||
|
parse(multiplication.getLeftArgument()),
|
||||||
parse(multiplication.getRightArgument()));
|
parse(multiplication.getRightArgument()));
|
||||||
return multi;
|
return multi;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,10 @@ package org.gcube.portlets.user.td.expressionwidget.shared.replace;
|
||||||
public enum ReplaceType {
|
public enum ReplaceType {
|
||||||
Value("Value"),
|
Value("Value"),
|
||||||
ColumnValue("Column Value"),
|
ColumnValue("Column Value"),
|
||||||
|
Upper("Upper"),
|
||||||
|
Lower("Lower"),
|
||||||
|
Trim("Trim"),
|
||||||
|
MD5("MD5"),
|
||||||
SubstringByRegex("Substring by Regex"),
|
SubstringByRegex("Substring by Regex"),
|
||||||
SubstringByIndex("Substring by Index"),
|
SubstringByIndex("Substring by Index"),
|
||||||
SubstringByCharSeq("Substring by Char Seq."),
|
SubstringByCharSeq("Substring by Char Seq."),
|
||||||
|
|
|
@ -8,10 +8,14 @@ import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithm
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_Subtraction;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_Subtraction;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.functions.C_Cast;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.functions.C_Cast;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_Concat;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_Concat;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_Lower;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_MD5;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringByIndex;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringByIndex;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringByRegex;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringByRegex;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringPosition;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringPosition;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_TextReplaceMatchingRegex;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_TextReplaceMatchingRegex;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_Trim;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_Upper;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReference;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReference;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReferencePlaceholder;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReferencePlaceholder;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.TD_Value;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.TD_Value;
|
||||||
|
@ -121,6 +125,18 @@ public class ReplaceTypeMap {
|
||||||
case ColumnValue:
|
case ColumnValue:
|
||||||
exp = columnValuePlaceHolder(column, targetType);
|
exp = columnValuePlaceHolder(column, targetType);
|
||||||
break;
|
break;
|
||||||
|
case Upper:
|
||||||
|
exp = upperPlaceHolder(column, targetType);
|
||||||
|
break;
|
||||||
|
case Lower:
|
||||||
|
exp = lowerPlaceHolder(column, targetType);
|
||||||
|
break;
|
||||||
|
case Trim:
|
||||||
|
exp = trimPlaceHolder(column, targetType);
|
||||||
|
break;
|
||||||
|
case MD5:
|
||||||
|
exp = md5PlaceHolder(column, targetType);
|
||||||
|
break;
|
||||||
case Concat:
|
case Concat:
|
||||||
C_Concat concat = new C_Concat(firstE, secondE);
|
C_Concat concat = new C_Concat(firstE, secondE);
|
||||||
exp= new C_Cast(concat,targetType);
|
exp= new C_Cast(concat,targetType);
|
||||||
|
@ -326,6 +342,7 @@ public class ReplaceTypeMap {
|
||||||
return exp;
|
return exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private C_Expression columnValuePlaceHolder(ColumnData column,
|
private C_Expression columnValuePlaceHolder(ColumnData column,
|
||||||
ColumnDataType targetType) {
|
ColumnDataType targetType) {
|
||||||
C_Expression exp;
|
C_Expression exp;
|
||||||
|
@ -354,6 +371,127 @@ public class ReplaceTypeMap {
|
||||||
return exp;
|
return exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private C_Expression upperPlaceHolder(ColumnData column,
|
||||||
|
ColumnDataType targetType) throws ReplaceTypeMapException {
|
||||||
|
C_Expression exp;
|
||||||
|
Log.debug("Column Data Type Name:" + column.getDataTypeName());
|
||||||
|
ColumnDataType dataType = ColumnDataType
|
||||||
|
.getColumnDataTypeFromId(column
|
||||||
|
.getDataTypeName());
|
||||||
|
Log.debug("Data Type:" + dataType);
|
||||||
|
C_ColumnReferencePlaceholder placeH = new C_ColumnReferencePlaceholder(
|
||||||
|
dataType, column.getColumnId());
|
||||||
|
C_Expression placeHolder;
|
||||||
|
String readablePlaceHolder;
|
||||||
|
if(dataType!=ColumnDataType.Text){
|
||||||
|
placeHolder=new C_Cast(placeH, ColumnDataType.Text);
|
||||||
|
readablePlaceHolder= "Cast("+column.getColumnId()+","+ColumnDataType.Text+")";
|
||||||
|
} else {
|
||||||
|
placeHolder=placeH;
|
||||||
|
readablePlaceHolder= column.getColumnId();
|
||||||
|
|
||||||
|
}
|
||||||
|
Log.debug("placeHolder:" + placeHolder);
|
||||||
|
|
||||||
|
C_Upper upper = new C_Upper(placeHolder);
|
||||||
|
exp=new C_Cast(upper, targetType);
|
||||||
|
readableExpression = "Cast(Upper(" + readablePlaceHolder
|
||||||
|
+"),"+targetType+")";
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private C_Expression lowerPlaceHolder(ColumnData column,
|
||||||
|
ColumnDataType targetType) throws ReplaceTypeMapException {
|
||||||
|
C_Expression exp;
|
||||||
|
Log.debug("Column Data Type Name:" + column.getDataTypeName());
|
||||||
|
ColumnDataType dataType = ColumnDataType
|
||||||
|
.getColumnDataTypeFromId(column
|
||||||
|
.getDataTypeName());
|
||||||
|
Log.debug("Data Type:" + dataType);
|
||||||
|
C_ColumnReferencePlaceholder placeH = new C_ColumnReferencePlaceholder(
|
||||||
|
dataType, column.getColumnId());
|
||||||
|
C_Expression placeHolder;
|
||||||
|
String readablePlaceHolder;
|
||||||
|
if(dataType!=ColumnDataType.Text){
|
||||||
|
placeHolder=new C_Cast(placeH, ColumnDataType.Text);
|
||||||
|
readablePlaceHolder= "Cast("+column.getColumnId()+","+ColumnDataType.Text+")";
|
||||||
|
} else {
|
||||||
|
placeHolder=placeH;
|
||||||
|
readablePlaceHolder= column.getColumnId();
|
||||||
|
|
||||||
|
}
|
||||||
|
Log.debug("placeHolder:" + placeHolder);
|
||||||
|
|
||||||
|
C_Lower lower = new C_Lower(placeHolder);
|
||||||
|
exp=new C_Cast(lower, targetType);
|
||||||
|
readableExpression = "Cast(Lower(" + readablePlaceHolder
|
||||||
|
+"),"+targetType+")";
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private C_Expression trimPlaceHolder(ColumnData column,
|
||||||
|
ColumnDataType targetType) throws ReplaceTypeMapException {
|
||||||
|
C_Expression exp;
|
||||||
|
Log.debug("Column Data Type Name:" + column.getDataTypeName());
|
||||||
|
ColumnDataType dataType = ColumnDataType
|
||||||
|
.getColumnDataTypeFromId(column
|
||||||
|
.getDataTypeName());
|
||||||
|
Log.debug("Data Type:" + dataType);
|
||||||
|
C_ColumnReferencePlaceholder placeH = new C_ColumnReferencePlaceholder(
|
||||||
|
dataType, column.getColumnId());
|
||||||
|
C_Expression placeHolder;
|
||||||
|
String readablePlaceHolder;
|
||||||
|
if(dataType!=ColumnDataType.Text){
|
||||||
|
placeHolder=new C_Cast(placeH, ColumnDataType.Text);
|
||||||
|
readablePlaceHolder= "Cast("+column.getColumnId()+","+ColumnDataType.Text+")";
|
||||||
|
} else {
|
||||||
|
placeHolder=placeH;
|
||||||
|
readablePlaceHolder= column.getColumnId();
|
||||||
|
|
||||||
|
}
|
||||||
|
Log.debug("placeHolder:" + placeHolder);
|
||||||
|
|
||||||
|
C_Trim trim = new C_Trim(placeHolder);
|
||||||
|
exp=new C_Cast(trim, targetType);
|
||||||
|
readableExpression = "Cast(Trim(" + readablePlaceHolder
|
||||||
|
+"),"+targetType+")";
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private C_Expression md5PlaceHolder(ColumnData column,
|
||||||
|
ColumnDataType targetType) throws ReplaceTypeMapException {
|
||||||
|
C_Expression exp;
|
||||||
|
Log.debug("Column Data Type Name:" + column.getDataTypeName());
|
||||||
|
ColumnDataType dataType = ColumnDataType
|
||||||
|
.getColumnDataTypeFromId(column
|
||||||
|
.getDataTypeName());
|
||||||
|
Log.debug("Data Type:" + dataType);
|
||||||
|
C_ColumnReferencePlaceholder placeH = new C_ColumnReferencePlaceholder(
|
||||||
|
dataType, column.getColumnId());
|
||||||
|
C_Expression placeHolder;
|
||||||
|
String readablePlaceHolder;
|
||||||
|
if(dataType!=ColumnDataType.Text){
|
||||||
|
placeHolder=new C_Cast(placeH, ColumnDataType.Text);
|
||||||
|
readablePlaceHolder= "Cast("+column.getColumnId()+","+ColumnDataType.Text+")";
|
||||||
|
} else {
|
||||||
|
placeHolder=placeH;
|
||||||
|
readablePlaceHolder= column.getColumnId();
|
||||||
|
|
||||||
|
}
|
||||||
|
Log.debug("placeHolder:" + placeHolder);
|
||||||
|
|
||||||
|
C_MD5 md5 = new C_MD5(placeHolder);
|
||||||
|
exp=new C_Cast(md5, targetType);
|
||||||
|
readableExpression = "Cast(MD5(" + readablePlaceHolder
|
||||||
|
+"),"+targetType+")";
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public C_Expression mapColumnReference(ColumnData column,ColumnDataType targetType,
|
public C_Expression mapColumnReference(ColumnData column,ColumnDataType targetType,
|
||||||
ReplaceType replaceType, String firstArg, String secondArg,
|
ReplaceType replaceType, String firstArg, String secondArg,
|
||||||
C_Expression firstE, C_Expression secondE, String readableFirstE, String readableSecondE) throws ReplaceTypeMapException {
|
C_Expression firstE, C_Expression secondE, String readableFirstE, String readableSecondE) throws ReplaceTypeMapException {
|
||||||
|
@ -420,6 +558,18 @@ public class ReplaceTypeMap {
|
||||||
case ColumnValue:
|
case ColumnValue:
|
||||||
exp = columnValueReference(column, targetType);
|
exp = columnValueReference(column, targetType);
|
||||||
break;
|
break;
|
||||||
|
case Upper:
|
||||||
|
exp = upperReference(column, targetType);
|
||||||
|
break;
|
||||||
|
case Lower:
|
||||||
|
exp = lowerReference(column, targetType);
|
||||||
|
break;
|
||||||
|
case Trim:
|
||||||
|
exp = trimReference(column, targetType);
|
||||||
|
break;
|
||||||
|
case MD5:
|
||||||
|
exp = md5Reference(column, targetType);
|
||||||
|
break;
|
||||||
case Concat:
|
case Concat:
|
||||||
C_Concat concat = new C_Concat(firstE, secondE);
|
C_Concat concat = new C_Concat(firstE, secondE);
|
||||||
exp= new C_Cast(concat,targetType);
|
exp= new C_Cast(concat,targetType);
|
||||||
|
@ -660,6 +810,138 @@ public class ReplaceTypeMap {
|
||||||
return exp;
|
return exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private C_Expression upperReference(ColumnData column,
|
||||||
|
ColumnDataType targetType) {
|
||||||
|
C_Expression exp;
|
||||||
|
Log.debug("Column Data Type Name:" + column.getDataTypeName());
|
||||||
|
ColumnDataType dataType = ColumnDataType
|
||||||
|
.getColumnDataTypeFromId(column
|
||||||
|
.getDataTypeName());
|
||||||
|
Log.debug("Data Type:" + dataType);
|
||||||
|
|
||||||
|
C_ColumnReference columnRef = new C_ColumnReference(
|
||||||
|
column.getTrId(), dataType, column.getColumnId());
|
||||||
|
|
||||||
|
C_Expression columnReference;
|
||||||
|
String readableColumnReference;
|
||||||
|
if(dataType!=ColumnDataType.Text){
|
||||||
|
columnReference=new C_Cast(columnRef,ColumnDataType.Text);
|
||||||
|
readableColumnReference= "Cast("+column.getColumnId()+","+ColumnDataType.Text+")";
|
||||||
|
} else {
|
||||||
|
columnReference=columnRef;
|
||||||
|
readableColumnReference= column.getColumnId();
|
||||||
|
|
||||||
|
}
|
||||||
|
Log.debug("Typed Column Reference:" + columnReference);
|
||||||
|
|
||||||
|
|
||||||
|
C_Upper upper= new C_Upper(columnReference);
|
||||||
|
exp=new C_Cast(upper, targetType);
|
||||||
|
readableExpression = "Cast(Upper(" + readableColumnReference
|
||||||
|
+ "),"+targetType+")";
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private C_Expression lowerReference(ColumnData column,
|
||||||
|
ColumnDataType targetType) {
|
||||||
|
C_Expression exp;
|
||||||
|
Log.debug("Column Data Type Name:" + column.getDataTypeName());
|
||||||
|
ColumnDataType dataType = ColumnDataType
|
||||||
|
.getColumnDataTypeFromId(column
|
||||||
|
.getDataTypeName());
|
||||||
|
Log.debug("Data Type:" + dataType);
|
||||||
|
|
||||||
|
C_ColumnReference columnRef = new C_ColumnReference(
|
||||||
|
column.getTrId(), dataType, column.getColumnId());
|
||||||
|
|
||||||
|
C_Expression columnReference;
|
||||||
|
String readableColumnReference;
|
||||||
|
if(dataType!=ColumnDataType.Text){
|
||||||
|
columnReference=new C_Cast(columnRef,ColumnDataType.Text);
|
||||||
|
readableColumnReference= "Cast("+column.getColumnId()+","+ColumnDataType.Text+")";
|
||||||
|
} else {
|
||||||
|
columnReference=columnRef;
|
||||||
|
readableColumnReference= column.getColumnId();
|
||||||
|
|
||||||
|
}
|
||||||
|
Log.debug("Typed Column Reference:" + columnReference);
|
||||||
|
|
||||||
|
|
||||||
|
C_Lower lower= new C_Lower(columnReference);
|
||||||
|
exp=new C_Cast(lower, targetType);
|
||||||
|
readableExpression = "Cast(Lower(" + readableColumnReference
|
||||||
|
+ "),"+targetType+")";
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private C_Expression trimReference(ColumnData column,
|
||||||
|
ColumnDataType targetType) {
|
||||||
|
C_Expression exp;
|
||||||
|
Log.debug("Column Data Type Name:" + column.getDataTypeName());
|
||||||
|
ColumnDataType dataType = ColumnDataType
|
||||||
|
.getColumnDataTypeFromId(column
|
||||||
|
.getDataTypeName());
|
||||||
|
Log.debug("Data Type:" + dataType);
|
||||||
|
|
||||||
|
C_ColumnReference columnRef = new C_ColumnReference(
|
||||||
|
column.getTrId(), dataType, column.getColumnId());
|
||||||
|
|
||||||
|
C_Expression columnReference;
|
||||||
|
String readableColumnReference;
|
||||||
|
if(dataType!=ColumnDataType.Text){
|
||||||
|
columnReference=new C_Cast(columnRef,ColumnDataType.Text);
|
||||||
|
readableColumnReference= "Cast("+column.getColumnId()+","+ColumnDataType.Text+")";
|
||||||
|
} else {
|
||||||
|
columnReference=columnRef;
|
||||||
|
readableColumnReference= column.getColumnId();
|
||||||
|
|
||||||
|
}
|
||||||
|
Log.debug("Typed Column Reference:" + columnReference);
|
||||||
|
|
||||||
|
|
||||||
|
C_Trim trim= new C_Trim(columnReference);
|
||||||
|
exp=new C_Cast(trim, targetType);
|
||||||
|
readableExpression = "Cast(Trim(" + readableColumnReference
|
||||||
|
+ "),"+targetType+")";
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private C_Expression md5Reference(ColumnData column,
|
||||||
|
ColumnDataType targetType) {
|
||||||
|
C_Expression exp;
|
||||||
|
Log.debug("Column Data Type Name:" + column.getDataTypeName());
|
||||||
|
ColumnDataType dataType = ColumnDataType
|
||||||
|
.getColumnDataTypeFromId(column
|
||||||
|
.getDataTypeName());
|
||||||
|
Log.debug("Data Type:" + dataType);
|
||||||
|
|
||||||
|
C_ColumnReference columnRef = new C_ColumnReference(
|
||||||
|
column.getTrId(), dataType, column.getColumnId());
|
||||||
|
|
||||||
|
C_Expression columnReference;
|
||||||
|
String readableColumnReference;
|
||||||
|
if(dataType!=ColumnDataType.Text){
|
||||||
|
columnReference=new C_Cast(columnRef,ColumnDataType.Text);
|
||||||
|
readableColumnReference= "Cast("+column.getColumnId()+","+ColumnDataType.Text+")";
|
||||||
|
} else {
|
||||||
|
columnReference=columnRef;
|
||||||
|
readableColumnReference= column.getColumnId();
|
||||||
|
|
||||||
|
}
|
||||||
|
Log.debug("Typed Column Reference:" + columnReference);
|
||||||
|
|
||||||
|
|
||||||
|
C_MD5 md5= new C_MD5(columnReference);
|
||||||
|
exp=new C_Cast(md5, targetType);
|
||||||
|
readableExpression = "Cast(MD5(" + readableColumnReference
|
||||||
|
+ "),"+targetType+")";
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getReadableExpression() {
|
public String getReadableExpression() {
|
||||||
return readableExpression;
|
return readableExpression;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue