Updated Replace By Expression
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@111786 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4612e0e2ba
commit
ba8e135c1e
File diff suppressed because it is too large
Load Diff
|
@ -137,7 +137,7 @@ public class ReplaceColumnByExpressionDialog extends Window implements
|
|||
||column.getDataTypeName().compareTo(ColumnDataType.Integer.toString()) == 0
|
||||
||column.getDataTypeName().compareTo(ColumnDataType.Numeric.toString()) == 0
|
||||
||column.getDataTypeName().compareTo(ColumnDataType.Geometry.toString()) == 0
|
||||
||column.getDataTypeName().compareTo(ColumnDataType.Date.toString()) == 0) {
|
||||
) {
|
||||
setHeight(HEIGHT);
|
||||
} else {
|
||||
setHeight(HEIGHT_REDUCE);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceColumnByExpressionType;
|
||||
|
@ -18,6 +19,7 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataT
|
|||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
import com.google.gwt.regexp.shared.MatchResult;
|
||||
import com.google.gwt.regexp.shared.RegExp;
|
||||
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
||||
|
@ -37,6 +39,7 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
|||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||
import com.sencha.gxt.widget.core.client.form.DateField;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldSet;
|
||||
import com.sencha.gxt.widget.core.client.form.Radio;
|
||||
|
@ -75,7 +78,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
|||
|
||||
private ReplaceColumnByExpressionType replaceColumnByExpressionType;
|
||||
|
||||
// private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
||||
private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
||||
|
||||
private TextButton btnApply;
|
||||
private TextButton btnClose;
|
||||
|
@ -84,9 +87,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
|||
private ConditionWidget conditionWidget;
|
||||
|
||||
private ReplaceWidget replaceWidget;
|
||||
private ReplaceArithmeticWidget replaceArithmeticWidget;
|
||||
private TextField replaceValue;
|
||||
// private DateField replaceValueDate;
|
||||
private DateField replaceValueDate;
|
||||
|
||||
private VerticalLayoutContainer conditionsVerticalLayout;
|
||||
private FieldLabel allRowsField;
|
||||
|
@ -130,9 +132,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
|||
|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Numeric.toString()) == 0
|
||||
|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Geometry.toString()) == 0 || column
|
||||
.getDataTypeName().compareTo(
|
||||
ColumnDataType.Date.toString()) == 0)) {
|
||||
ColumnDataType.Geometry.toString()) == 0)) {
|
||||
setHeight(HEIGHT);
|
||||
} else {
|
||||
setHeight(HEIGHT_REDUCE);
|
||||
|
@ -229,46 +229,21 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
|||
VerticalLayoutContainer replaceValueFieldSetLayout = new VerticalLayoutContainer();
|
||||
replaceValueFieldSet.add(replaceValueFieldSetLayout);
|
||||
|
||||
if (column.getDataTypeName().compareTo(ColumnDataType.Date.toString()) == 0) {
|
||||
replaceValueDate = new DateField();
|
||||
replaceValueDate.setToolTip("Replace Value");
|
||||
replaceValueFieldSetLayout.add(new FieldLabel(replaceValueDate,
|
||||
"Replace Value"), new VerticalLayoutData(1, -1));
|
||||
|
||||
} else {
|
||||
if (column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Text.toString()) == 0
|
||||
|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Integer.toString()) == 0
|
||||
|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Numeric.toString()) == 0
|
||||
|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Geometry.toString()) == 0
|
||||
|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Date.toString()) == 0) {
|
||||
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
replaceArithmeticWidget = new ReplaceArithmeticWidget(column,
|
||||
REPLACEWIDTH, REPLACEHEIGHT, eventBus);
|
||||
break;
|
||||
case Template:
|
||||
replaceArithmeticWidget = new ReplaceArithmeticWidget(column,
|
||||
columns, REPLACEWIDTH, REPLACEHEIGHT, eventBus);
|
||||
break;
|
||||
default:
|
||||
Log.debug("Attention Replace Widget have not a valid type");
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Attention Replace Widget have not a valid type");
|
||||
if (parent != null) {
|
||||
parent.hide();
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
replaceValueFieldSetLayout.add(replaceArithmeticWidget,
|
||||
new VerticalLayoutData(1, -1));
|
||||
/*
|
||||
* replaceValueDate = new DateField();
|
||||
* replaceValueDate.setToolTip("Replace Value");
|
||||
* replaceValueFieldSetLayout.add(new FieldLabel(replaceValueDate,
|
||||
* "Replace Value"), new VerticalLayoutData(1, -1));
|
||||
*/
|
||||
|
||||
} else {
|
||||
if (column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Text.toString()) == 0) {
|
||||
ColumnDataType.Geometry.toString()) == 0) {
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
replaceWidget = new ReplaceWidget(column, REPLACEWIDTH,
|
||||
|
@ -371,44 +346,33 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
|||
|
||||
}
|
||||
String value = null;
|
||||
if (column.getDataTypeName().compareTo(ColumnDataType.Date.toString()) == 0) {
|
||||
|
||||
Date valueDate = replaceValueDate.getCurrentValue();
|
||||
if (valueDate == null) {
|
||||
UtilsGXT3.alert("Error replace value",
|
||||
"Select a valid date as replace value!");
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
value = sdf.format(valueDate);
|
||||
} catch (Throwable e) {
|
||||
UtilsGXT3.alert("Error replace value",
|
||||
"Select a valid date as replace value!");
|
||||
return;
|
||||
}
|
||||
callApplyReplaceColumnByExpression(cConditionExpression, value);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
if (column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Text.toString()) == 0|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Integer.toString()) == 0
|
||||
|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Numeric.toString()) == 0
|
||||
|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Geometry.toString()) == 0
|
||||
|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Date.toString()) == 0) {
|
||||
|
||||
C_Expression cReplaceExpression = null;
|
||||
try {
|
||||
cReplaceExpression = replaceArithmeticWidget.getExpression();
|
||||
if (cReplaceExpression == null) {
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Replace expression is not valid!");
|
||||
return;
|
||||
}
|
||||
} catch (ReplaceTypeMapException e) {
|
||||
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
|
||||
return;
|
||||
}
|
||||
callApplyReplaceColumnByExpression(cConditionExpression,
|
||||
cReplaceExpression);
|
||||
/*
|
||||
* Date valueDate = replaceValueDate.getCurrentValue(); if
|
||||
* (valueDate == null) { UtilsGXT3.alert("Error replace value",
|
||||
* "Select a valid date as replace value!"); return; } else { try {
|
||||
* value = sdf.format(valueDate); } catch (Throwable e) {
|
||||
* UtilsGXT3.alert("Error replace value",
|
||||
* "Select a valid date as replace value!"); return; }
|
||||
* callApplyReplaceColumnByExpression(cConditionExpression, value);
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
} else {
|
||||
if (column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Text.toString()) == 0) {
|
||||
ColumnDataType.Geometry.toString()) == 0) {
|
||||
C_Expression cReplaceExpression = null;
|
||||
try {
|
||||
cReplaceExpression = replaceWidget.getExpression();
|
||||
|
@ -484,7 +448,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
|||
cReplaceExpression, replaceWidget.getReadableExpression());
|
||||
expressionEvent
|
||||
.setC_ReplaceExpressionContainer(replaceExpressionContainer);
|
||||
;
|
||||
|
||||
expressionEvent.setTrId(column.getTrId());
|
||||
expressionEvent.setColumnId(column.getColumnId());
|
||||
expressionEvent.setColumnName(column.getName());
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.gcube.portlets.user.td.expressionwidget.client.properties.ReplaceElem
|
|||
import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceColumnByExpressionType;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ReplaceTypeMapException;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_ArithmeticExpression;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.replace.ReplaceType;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.replace.ReplaceTypeMap;
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
|
@ -20,6 +21,7 @@ import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredE
|
|||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -66,6 +68,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
private EventBus eventBus;
|
||||
private TRId trId;
|
||||
private ArrayList<ColumnData> columns;
|
||||
private ArrayList<ColumnData> arithmeticColumns;
|
||||
|
||||
// private FieldLabel matchLabel;
|
||||
// private ToggleGroup groupMatch;
|
||||
|
@ -81,6 +84,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
private String itemIdSecondArg;
|
||||
private String itemIdHoriz;
|
||||
private ReplaceColumnByExpressionType replaceColumnByExpressionType;
|
||||
private ColumnDataType targetColumnType;
|
||||
|
||||
protected class ExpressionContainer {
|
||||
private C_Expression expression;
|
||||
|
@ -114,7 +118,9 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
public ReplaceWidget(ColumnData column, EventBus eventBus) {
|
||||
super();
|
||||
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Replace;
|
||||
create(column.getTrId(), WIDTH, HEIGHT, eventBus);
|
||||
ColumnDataType targetType = ColumnDataType
|
||||
.getColumnDataTypeFromId(column.getDataTypeName());
|
||||
create(column.getTrId(), targetType, WIDTH, HEIGHT, eventBus);
|
||||
retrieveColumns();
|
||||
}
|
||||
|
||||
|
@ -122,7 +128,9 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
EventBus eventBus) {
|
||||
super();
|
||||
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Replace;
|
||||
create(column.getTrId(), width, height, eventBus);
|
||||
ColumnDataType targetType = ColumnDataType
|
||||
.getColumnDataTypeFromId(column.getDataTypeName());
|
||||
create(column.getTrId(), targetType, width, height, eventBus);
|
||||
retrieveColumns();
|
||||
}
|
||||
|
||||
|
@ -131,7 +139,9 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
super();
|
||||
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Template;
|
||||
this.columns = columns;
|
||||
create(column.getTrId(), WIDTH, HEIGHT, eventBus);
|
||||
ColumnDataType targetType = ColumnDataType
|
||||
.getColumnDataTypeFromId(column.getDataTypeName());
|
||||
create(column.getTrId(), targetType, WIDTH, HEIGHT, eventBus);
|
||||
setup();
|
||||
}
|
||||
|
||||
|
@ -140,13 +150,16 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
super();
|
||||
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Template;
|
||||
this.columns = columns;
|
||||
create(column.getTrId(), width, height, eventBus);
|
||||
ColumnDataType targetType = ColumnDataType
|
||||
.getColumnDataTypeFromId(column.getDataTypeName());
|
||||
create(column.getTrId(), targetType, width, height, eventBus);
|
||||
setup();
|
||||
}
|
||||
|
||||
protected void create(TRId trId, String width, String height,
|
||||
EventBus eventBus) {
|
||||
protected void create(TRId trId, ColumnDataType targetColumnType,
|
||||
String width, String height, EventBus eventBus) {
|
||||
this.trId = trId;
|
||||
this.targetColumnType = targetColumnType;
|
||||
setBorders(true);
|
||||
setWidth(width);
|
||||
setHeight(height);
|
||||
|
@ -196,6 +209,16 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
public void onSuccess(ArrayList<ColumnData> result) {
|
||||
Log.trace("loaded " + result.size() + " ColumnData");
|
||||
columns = result;
|
||||
arithmeticColumns = new ArrayList<ColumnData>();
|
||||
for (ColumnData col : result) {
|
||||
ColumnDataType colDataType = ColumnDataType
|
||||
.getColumnDataTypeFromId(col
|
||||
.getDataTypeName());
|
||||
if (C_ArithmeticExpression.isAccepted(colDataType)) {
|
||||
arithmeticColumns.add(col);
|
||||
}
|
||||
|
||||
}
|
||||
setup();
|
||||
}
|
||||
|
||||
|
@ -244,7 +267,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
comboColumns.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
// Replace Elemet Store
|
||||
ReplaceElementStore factory = new ReplaceElementStore();
|
||||
final ReplaceElementStore factory = new ReplaceElementStore();
|
||||
|
||||
ReplaceElementProperties props = GWT
|
||||
.create(ReplaceElementProperties.class);
|
||||
|
@ -287,6 +310,11 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
secondArg.setEmptyText("");
|
||||
break;
|
||||
case Concat:
|
||||
case Addition:
|
||||
case Subtraction:
|
||||
case Modulus:
|
||||
case Multiplication:
|
||||
case Division:
|
||||
break;
|
||||
case SubstringByRegex:
|
||||
comboColumns.clear();
|
||||
|
@ -340,19 +368,20 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
|
||||
comboReplaceElementsLeaf.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
// ComboConcat
|
||||
ListStore<ReplaceElement> storeReplaceElementsConcat = new ListStore<ReplaceElement>(
|
||||
// ComboOperations
|
||||
ListStore<ReplaceElement> storeReplaceElementsOperations = new ListStore<ReplaceElement>(
|
||||
props.id());
|
||||
Log.debug("Store Concat: " + storeReplaceElementsConcat);
|
||||
storeReplaceElementsConcat.addAll(factory.replaceElementsConcat);
|
||||
Log.debug("Store Operations: " + storeReplaceElementsOperations);
|
||||
storeReplaceElementsOperations
|
||||
.addAll(factory.replaceElementsOperations);
|
||||
|
||||
Log.debug("Store created");
|
||||
final ComboBox<ReplaceElement> comboReplaceElementsConcat = new ComboBox<ReplaceElement>(
|
||||
storeReplaceElementsConcat, props.label());
|
||||
final ComboBox<ReplaceElement> comboReplaceElementsOperations = new ComboBox<ReplaceElement>(
|
||||
storeReplaceElementsOperations, props.label());
|
||||
|
||||
Log.debug("Combo created");
|
||||
|
||||
comboReplaceElementsConcat
|
||||
comboReplaceElementsOperations
|
||||
.addSelectionHandler(new SelectionHandler<ReplaceElement>() {
|
||||
|
||||
public void onSelection(SelectionEvent<ReplaceElement> event) {
|
||||
|
@ -371,7 +400,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
firstArg.setVisible(true);
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
removeConcat(source);
|
||||
removeOperation(source);
|
||||
break;
|
||||
case ColumnValue:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
|
@ -381,19 +410,49 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
firstArg.setEmptyText("");
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
removeConcat(source);
|
||||
removeOperation(source);
|
||||
break;
|
||||
case Concat:
|
||||
if (!existConcat(source)) {
|
||||
comboReplaceElementsLeaf.clear();
|
||||
comboReplaceElementsLeaf.reset();
|
||||
comboReplaceElementsLeaf.getStore().clear();
|
||||
comboReplaceElementsLeaf.getStore()
|
||||
.addAll(factory.replaceElements);
|
||||
comboReplaceElementsLeaf.getStore().commitChanges();
|
||||
comboReplaceElementsLeaf.setVisible(true);
|
||||
comboReplaceElementsLeaf.redraw();
|
||||
if (!existOperation(source)) {
|
||||
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(false);
|
||||
firstArg.setVisible(false);
|
||||
firstArg.setEmptyText("");
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
addConcat();
|
||||
addOperation();
|
||||
}
|
||||
break;
|
||||
case Addition:
|
||||
case Subtraction:
|
||||
case Modulus:
|
||||
case Multiplication:
|
||||
case Division:
|
||||
comboReplaceElementsLeaf.clear();
|
||||
comboReplaceElementsLeaf.reset();
|
||||
comboReplaceElementsLeaf.getStore().clear();
|
||||
comboReplaceElementsLeaf.getStore()
|
||||
.addAll(factory.replaceElementsArithmetic);
|
||||
comboReplaceElementsLeaf.getStore().commitChanges();
|
||||
comboReplaceElementsLeaf.setVisible(true);
|
||||
comboReplaceElementsLeaf.redraw();
|
||||
if (!existOperation(source)) {
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(false);
|
||||
firstArg.setVisible(false);
|
||||
firstArg.setEmptyText("");
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
addOperation();
|
||||
}
|
||||
break;
|
||||
case SubstringByRegex:
|
||||
|
@ -404,7 +463,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
firstArg.setEmptyText(EMPTY_TEXT_REGEXP);
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
removeConcat(source);
|
||||
removeOperation(source);
|
||||
break;
|
||||
case SubstringByIndex:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
|
@ -414,7 +473,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
firstArg.setEmptyText(EMPTY_TEXT_FROM_INDEX);
|
||||
secondArg.setVisible(true);
|
||||
secondArg.setEmptyText(EMPTY_TEXT_TO_INDEX);
|
||||
removeConcat(source);
|
||||
removeOperation(source);
|
||||
break;
|
||||
case SubstringByCharSeq:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
|
@ -424,7 +483,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
firstArg.setEmptyText(EMPTY_TEXT_FROM_STRING);
|
||||
secondArg.setVisible(true);
|
||||
secondArg.setEmptyText(EMPTY_TEXT_TO_STRING);
|
||||
removeConcat(source);
|
||||
removeOperation(source);
|
||||
break;
|
||||
case TextReplaceMatchingRegex:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
|
@ -435,7 +494,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
secondArg.setVisible(true);
|
||||
secondArg
|
||||
.setEmptyText(EMPTY_TEXT_REPLACE_REPLACING);
|
||||
removeConcat(source);
|
||||
removeOperation(source);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -448,17 +507,18 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
|
||||
});
|
||||
|
||||
comboReplaceElementsConcat.setEmptyText("Select...");
|
||||
comboReplaceElementsConcat.setItemId(itemIdComboConcat);
|
||||
comboReplaceElementsConcat.setWidth(COMBO_WIDTH);
|
||||
comboReplaceElementsConcat.setEditable(false);
|
||||
comboReplaceElementsConcat.setTriggerAction(TriggerAction.ALL);
|
||||
comboReplaceElementsOperations.setEmptyText("Select...");
|
||||
comboReplaceElementsOperations.setItemId(itemIdComboConcat);
|
||||
comboReplaceElementsOperations.setWidth(COMBO_WIDTH);
|
||||
comboReplaceElementsOperations.setEditable(false);
|
||||
comboReplaceElementsOperations.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
comboReplaceElementsConcat.setValue(storeReplaceElementsConcat.get(0),
|
||||
true);
|
||||
comboReplaceElementsOperations.setValue(
|
||||
storeReplaceElementsOperations.get(0), true);
|
||||
|
||||
//
|
||||
horiz.add(comboReplaceElementsConcat, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(comboReplaceElementsOperations, new BoxLayoutData(
|
||||
new Margins(0)));
|
||||
horiz.add(comboReplaceElementsLeaf, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(comboColumns, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(firstArg, new BoxLayoutData(new Margins(0)));
|
||||
|
@ -472,11 +532,11 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
secondArg.setVisible(false);
|
||||
comboColumns.setVisible(false);
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceElementsConcat.setVisible(true);
|
||||
comboReplaceElementsOperations.setVisible(true);
|
||||
forceLayout();
|
||||
}
|
||||
|
||||
protected void addConcat() {
|
||||
protected void addOperation() {
|
||||
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
||||
|
||||
final TextField firstArg = new TextField();
|
||||
|
@ -506,7 +566,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
comboColumns.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
//
|
||||
ReplaceElementStore factory = new ReplaceElementStore();
|
||||
final ReplaceElementStore factory = new ReplaceElementStore();
|
||||
|
||||
ReplaceElementProperties props = GWT
|
||||
.create(ReplaceElementProperties.class);
|
||||
|
@ -549,6 +609,11 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
secondArg.setEmptyText("");
|
||||
break;
|
||||
case Concat:
|
||||
case Addition:
|
||||
case Subtraction:
|
||||
case Modulus:
|
||||
case Multiplication:
|
||||
case Division:
|
||||
break;
|
||||
case SubstringByRegex:
|
||||
comboColumns.clear();
|
||||
|
@ -601,19 +666,20 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
|
||||
comboReplaceElementsLeaf.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
// ComboConcat
|
||||
ListStore<ReplaceElement> storeReplaceElementsConcat = new ListStore<ReplaceElement>(
|
||||
// ComboOperations
|
||||
ListStore<ReplaceElement> storeReplaceElementsOperations = new ListStore<ReplaceElement>(
|
||||
props.id());
|
||||
Log.debug("Store Concat: " + storeReplaceElementsConcat);
|
||||
storeReplaceElementsConcat.addAll(factory.replaceElementsConcat);
|
||||
Log.debug("Store Concat: " + storeReplaceElementsOperations);
|
||||
storeReplaceElementsOperations
|
||||
.addAll(factory.replaceElementsOperations);
|
||||
|
||||
Log.debug("Store created");
|
||||
final ComboBox<ReplaceElement> comboReplaceElementsConcat = new ComboBox<ReplaceElement>(
|
||||
storeReplaceElementsConcat, props.label());
|
||||
final ComboBox<ReplaceElement> comboReplaceElementsOperations = new ComboBox<ReplaceElement>(
|
||||
storeReplaceElementsOperations, props.label());
|
||||
|
||||
Log.debug("Combo created");
|
||||
|
||||
comboReplaceElementsConcat
|
||||
comboReplaceElementsOperations
|
||||
.addSelectionHandler(new SelectionHandler<ReplaceElement>() {
|
||||
|
||||
public void onSelection(SelectionEvent<ReplaceElement> event) {
|
||||
|
@ -633,7 +699,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
firstArg.setVisible(true);
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
removeConcat(source);
|
||||
removeOperation(source);
|
||||
break;
|
||||
case ColumnValue:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
|
@ -643,19 +709,48 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
firstArg.setEmptyText("");
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
removeConcat(source);
|
||||
removeOperation(source);
|
||||
break;
|
||||
case Concat:
|
||||
if (!existConcat(source)) {
|
||||
comboReplaceElementsLeaf.clear();
|
||||
comboReplaceElementsLeaf.reset();
|
||||
comboReplaceElementsLeaf.getStore().clear();
|
||||
comboReplaceElementsLeaf.getStore()
|
||||
.addAll(factory.replaceElements);
|
||||
comboReplaceElementsLeaf.getStore().commitChanges();
|
||||
comboReplaceElementsLeaf.setVisible(true);
|
||||
comboReplaceElementsLeaf.redraw();
|
||||
if (!existOperation(source)) {
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(false);
|
||||
firstArg.setVisible(false);
|
||||
firstArg.setEmptyText("");
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
addConcat();
|
||||
addOperation();
|
||||
}
|
||||
break;
|
||||
case Addition:
|
||||
case Subtraction:
|
||||
case Modulus:
|
||||
case Multiplication:
|
||||
case Division:
|
||||
comboReplaceElementsLeaf.clear();
|
||||
comboReplaceElementsLeaf.reset();
|
||||
comboReplaceElementsLeaf.getStore().clear();
|
||||
comboReplaceElementsLeaf.getStore()
|
||||
.addAll(factory.replaceElementsArithmetic);
|
||||
comboReplaceElementsLeaf.getStore().commitChanges();
|
||||
comboReplaceElementsLeaf.setVisible(true);
|
||||
comboReplaceElementsLeaf.redraw();
|
||||
if (!existOperation(source)) {
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(false);
|
||||
firstArg.setVisible(false);
|
||||
firstArg.setEmptyText("");
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
addOperation();
|
||||
}
|
||||
break;
|
||||
case SubstringByRegex:
|
||||
|
@ -666,7 +761,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
firstArg.setEmptyText(EMPTY_TEXT_REGEXP);
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
removeConcat(source);
|
||||
removeOperation(source);
|
||||
break;
|
||||
case SubstringByIndex:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
|
@ -676,7 +771,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
firstArg.setEmptyText(EMPTY_TEXT_FROM_INDEX);
|
||||
secondArg.setVisible(true);
|
||||
secondArg.setEmptyText(EMPTY_TEXT_TO_INDEX);
|
||||
removeConcat(source);
|
||||
removeOperation(source);
|
||||
break;
|
||||
case SubstringByCharSeq:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
|
@ -686,7 +781,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
firstArg.setEmptyText(EMPTY_TEXT_FROM_STRING);
|
||||
secondArg.setVisible(true);
|
||||
secondArg.setEmptyText(EMPTY_TEXT_TO_STRING);
|
||||
removeConcat(source);
|
||||
removeOperation(source);
|
||||
break;
|
||||
case TextReplaceMatchingRegex:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
|
@ -697,7 +792,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
secondArg.setVisible(true);
|
||||
secondArg
|
||||
.setEmptyText(EMPTY_TEXT_REPLACE_REPLACING);
|
||||
removeConcat(source);
|
||||
removeOperation(source);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -711,17 +806,18 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
|
||||
});
|
||||
|
||||
comboReplaceElementsConcat.setEmptyText("Select...");
|
||||
comboReplaceElementsConcat.setItemId(itemIdComboConcat);
|
||||
comboReplaceElementsConcat.setWidth(COMBO_WIDTH);
|
||||
comboReplaceElementsConcat.setEditable(false);
|
||||
comboReplaceElementsConcat.setTriggerAction(TriggerAction.ALL);
|
||||
comboReplaceElementsOperations.setEmptyText("Select...");
|
||||
comboReplaceElementsOperations.setItemId(itemIdComboConcat);
|
||||
comboReplaceElementsOperations.setWidth(COMBO_WIDTH);
|
||||
comboReplaceElementsOperations.setEditable(false);
|
||||
comboReplaceElementsOperations.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
comboReplaceElementsConcat.setValue(storeReplaceElementsConcat.get(0),
|
||||
true);
|
||||
comboReplaceElementsOperations.setValue(
|
||||
storeReplaceElementsOperations.get(0), true);
|
||||
|
||||
//
|
||||
horiz.add(comboReplaceElementsConcat, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(comboReplaceElementsOperations, new BoxLayoutData(
|
||||
new Margins(0)));
|
||||
horiz.add(comboReplaceElementsLeaf, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(comboColumns, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(firstArg, new BoxLayoutData(new Margins(0)));
|
||||
|
@ -733,11 +829,11 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
secondArg.setVisible(false);
|
||||
comboColumns.setVisible(false);
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceElementsConcat.setVisible(true);
|
||||
comboReplaceElementsOperations.setVisible(true);
|
||||
forceLayout();
|
||||
}
|
||||
|
||||
private void removeConcat(ComboBox<ReplaceElement> source) {
|
||||
private void removeOperation(ComboBox<ReplaceElement> source) {
|
||||
HBoxLayoutContainer horiz = (HBoxLayoutContainer) source.getParent();
|
||||
int index = vert.getWidgetIndex(horiz);
|
||||
Log.debug("No concat for index: " + index);
|
||||
|
@ -748,7 +844,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean existConcat(ComboBox<ReplaceElement> source) {
|
||||
private boolean existOperation(ComboBox<ReplaceElement> source) {
|
||||
boolean exist = false;
|
||||
HBoxLayoutContainer horiz = (HBoxLayoutContainer) source.getParent();
|
||||
int index = vert.getWidgetIndex(horiz);
|
||||
|
@ -769,7 +865,8 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
|
||||
if (vert.getWidgetCount() > 0) {
|
||||
int index = 0;
|
||||
expressionContainer = calcCExpression(index);
|
||||
ColumnDataType targetType = targetColumnType;
|
||||
expressionContainer = calcCExpression(index, targetType);
|
||||
if (expressionContainer != null) {
|
||||
readableExpression = expressionContainer
|
||||
.getReadableExpression();
|
||||
|
@ -788,10 +885,10 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
return readableExpression;
|
||||
}
|
||||
|
||||
protected ExpressionContainer calcCExpression(int index)
|
||||
throws ReplaceTypeMapException {
|
||||
protected ExpressionContainer calcCExpression(int index,
|
||||
ColumnDataType targetType) throws ReplaceTypeMapException {
|
||||
ExpressionContainer expressionContainer = null;
|
||||
ExpressionContainer expContainerConcat = null;
|
||||
ExpressionContainer expContainerOperation = null;
|
||||
C_Expression exp = null;
|
||||
C_Expression expLeaf = null;
|
||||
String readableExp = "";
|
||||
|
@ -803,9 +900,9 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
|
||||
horiz = (HBoxLayoutContainer) vert.getWidget(index);
|
||||
@SuppressWarnings("unchecked")
|
||||
ComboBox<ReplaceElement> comboConcat = (ComboBox<ReplaceElement>) horiz
|
||||
ComboBox<ReplaceElement> comboOperations = (ComboBox<ReplaceElement>) horiz
|
||||
.getItemByItemId(itemIdComboConcat);
|
||||
Log.debug("combo Concat: " + comboConcat.getCurrentValue());
|
||||
Log.debug("combo Concat: " + comboOperations.getCurrentValue());
|
||||
@SuppressWarnings("unchecked")
|
||||
ComboBox<ReplaceElement> comboLeaf = (ComboBox<ReplaceElement>) horiz
|
||||
.getItemByItemId(itemIdComboLeaf);
|
||||
|
@ -823,93 +920,29 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
+ firstArg.getCurrentValue() + ", secondArg: "
|
||||
+ secondArg.getCurrentValue() + "]");
|
||||
|
||||
ReplaceType comboConcatReplaceType = null;
|
||||
ReplaceType comboOperationsReplaceType = null;
|
||||
ReplaceType comboLeafReplaceType = null;
|
||||
|
||||
if (comboConcat.getCurrentValue() == null) {
|
||||
if (index == vert.getWidgetCount() - 1) {
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
exp = mapReplace.map(
|
||||
column,
|
||||
ReplaceType.Null,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false);
|
||||
break;
|
||||
case Template:
|
||||
exp = mapReplace.map(
|
||||
column,
|
||||
ReplaceType.Null,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), true);
|
||||
break;
|
||||
default:
|
||||
exp = mapReplace.map(
|
||||
column,
|
||||
ReplaceType.Null,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false);
|
||||
break;
|
||||
|
||||
}
|
||||
readableExp = mapReplace.getReadableExpression();
|
||||
expressionContainer = new ExpressionContainer(exp, readableExp);
|
||||
|
||||
} else {
|
||||
if (comboOperations.getCurrentValue() == null) {
|
||||
throw new ReplaceTypeMapException("Fill all field!");
|
||||
}
|
||||
} else {
|
||||
comboConcatReplaceType = comboConcat.getCurrentValue()
|
||||
comboOperationsReplaceType = comboOperations.getCurrentValue()
|
||||
.getReplaceType();
|
||||
if (comboConcatReplaceType.compareTo(ReplaceType.Concat) == 0) {
|
||||
|
||||
if (comboOperationsReplaceType.compareTo(ReplaceType.Concat) == 0) {
|
||||
if (comboLeaf.getCurrentValue() == null) {
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
expLeaf = mapReplace.map(
|
||||
column,
|
||||
ReplaceType.Null,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false);
|
||||
break;
|
||||
case Template:
|
||||
expLeaf = mapReplace.map(
|
||||
column,
|
||||
ReplaceType.Null,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), true);
|
||||
break;
|
||||
default:
|
||||
expLeaf = mapReplace.map(
|
||||
column,
|
||||
ReplaceType.Null,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
readableExpLeaf = mapReplace.getReadableExpression();
|
||||
|
||||
throw new ReplaceTypeMapException("Fill all field!");
|
||||
} else {
|
||||
comboLeafReplaceType = comboLeaf.getCurrentValue()
|
||||
.getReplaceType();
|
||||
/*
|
||||
* ColumnDataType cType = ColumnDataType
|
||||
* .getColumnDataTypeFromId(column.getDataTypeName());
|
||||
*/
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
expLeaf = mapReplace.map(
|
||||
column,
|
||||
ColumnDataType.Text,
|
||||
comboLeafReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
|
@ -919,6 +952,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
case Template:
|
||||
expLeaf = mapReplace.map(
|
||||
column,
|
||||
ColumnDataType.Text,
|
||||
comboLeafReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
|
@ -928,6 +962,7 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
default:
|
||||
expLeaf = mapReplace.map(
|
||||
column,
|
||||
ColumnDataType.Text,
|
||||
comboLeafReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
|
@ -942,45 +977,167 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
|
||||
index++;
|
||||
if (index < vert.getWidgetCount()) {
|
||||
expContainerConcat = calcCExpression(index);
|
||||
if (expContainerConcat == null) {
|
||||
expContainerOperation = calcCExpression(index,
|
||||
ColumnDataType.Text);
|
||||
if (expContainerOperation == null) {
|
||||
return null;
|
||||
} else {
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
exp = mapReplace.map(
|
||||
column,
|
||||
comboConcatReplaceType,
|
||||
targetType,
|
||||
comboOperationsReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false, expLeaf,
|
||||
expContainerConcat.getExpression(),
|
||||
readableExpLeaf, expContainerConcat
|
||||
expContainerOperation.getExpression(),
|
||||
readableExpLeaf, expContainerOperation
|
||||
.getReadableExpression());
|
||||
break;
|
||||
case Template:
|
||||
exp = mapReplace.map(
|
||||
column,
|
||||
comboConcatReplaceType,
|
||||
targetType,
|
||||
comboOperationsReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), true, expLeaf,
|
||||
expContainerConcat.getExpression(),
|
||||
readableExpLeaf, expContainerConcat
|
||||
expContainerOperation.getExpression(),
|
||||
readableExpLeaf, expContainerOperation
|
||||
.getReadableExpression());
|
||||
break;
|
||||
default:
|
||||
exp = mapReplace.map(
|
||||
column,
|
||||
comboConcatReplaceType,
|
||||
targetType,
|
||||
comboOperationsReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false, expLeaf,
|
||||
expContainerConcat.getExpression(),
|
||||
readableExpLeaf, expContainerConcat
|
||||
expContainerOperation.getExpression(),
|
||||
readableExpLeaf, expContainerOperation
|
||||
.getReadableExpression());
|
||||
break;
|
||||
|
||||
}
|
||||
readableExp = mapReplace.getReadableExpression();
|
||||
expressionContainer = new ExpressionContainer(exp,
|
||||
readableExp);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (comboOperationsReplaceType.compareTo(ReplaceType.Addition) == 0
|
||||
|| comboOperationsReplaceType
|
||||
.compareTo(ReplaceType.Subtraction) == 0
|
||||
|| comboOperationsReplaceType
|
||||
.compareTo(ReplaceType.Modulus) == 0
|
||||
|| comboOperationsReplaceType
|
||||
.compareTo(ReplaceType.Multiplication) == 0
|
||||
|| comboOperationsReplaceType
|
||||
.compareTo(ReplaceType.Division) == 0) {
|
||||
ColumnDataType cType;
|
||||
if (comboLeaf.getCurrentValue() == null) {
|
||||
throw new ReplaceTypeMapException("Fill all field!");
|
||||
} else {
|
||||
|
||||
comboLeafReplaceType = comboLeaf.getCurrentValue()
|
||||
.getReplaceType();
|
||||
cType = ColumnDataType
|
||||
.getColumnDataTypeFromId(column
|
||||
.getDataTypeName());
|
||||
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
expLeaf = mapReplace.map(
|
||||
column,
|
||||
cType,
|
||||
comboLeafReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false);
|
||||
break;
|
||||
case Template:
|
||||
expLeaf = mapReplace.map(
|
||||
column,
|
||||
cType,
|
||||
comboLeafReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), true);
|
||||
break;
|
||||
default:
|
||||
expLeaf = mapReplace.map(
|
||||
column,
|
||||
cType,
|
||||
comboLeafReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
readableExpLeaf = mapReplace.getReadableExpression();
|
||||
}
|
||||
|
||||
index++;
|
||||
if (index < vert.getWidgetCount()) {
|
||||
expContainerOperation = calcCExpression(index,
|
||||
cType);
|
||||
if (expContainerOperation == null) {
|
||||
return null;
|
||||
} else {
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
exp = mapReplace.map(
|
||||
column,
|
||||
targetType,
|
||||
comboOperationsReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false,
|
||||
expLeaf, expContainerOperation
|
||||
.getExpression(),
|
||||
readableExpLeaf, expContainerOperation
|
||||
.getReadableExpression());
|
||||
break;
|
||||
case Template:
|
||||
exp = mapReplace.map(
|
||||
column,
|
||||
targetType,
|
||||
comboOperationsReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), true,
|
||||
expLeaf, expContainerOperation
|
||||
.getExpression(),
|
||||
readableExpLeaf, expContainerOperation
|
||||
.getReadableExpression());
|
||||
break;
|
||||
default:
|
||||
exp = mapReplace.map(
|
||||
column,
|
||||
targetType,
|
||||
comboOperationsReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false,
|
||||
expLeaf, expContainerOperation
|
||||
.getExpression(),
|
||||
readableExpLeaf, expContainerOperation
|
||||
.getReadableExpression());
|
||||
break;
|
||||
|
||||
|
@ -996,28 +1153,41 @@ public class ReplaceWidget extends SimpleContainer {
|
|||
} else {
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
exp = mapReplace.map(column, comboConcatReplaceType,
|
||||
firstArg == null ? null : firstArg.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg.getCurrentValue(),
|
||||
false);
|
||||
exp = mapReplace.map(
|
||||
column,
|
||||
targetType,
|
||||
comboOperationsReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false);
|
||||
break;
|
||||
case Template:
|
||||
exp = mapReplace.map(column, comboConcatReplaceType,
|
||||
firstArg == null ? null : firstArg.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg.getCurrentValue(),
|
||||
true);
|
||||
exp = mapReplace.map(
|
||||
column,
|
||||
targetType,
|
||||
comboOperationsReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), true);
|
||||
break;
|
||||
default:
|
||||
exp = mapReplace.map(column, comboConcatReplaceType,
|
||||
firstArg == null ? null : firstArg.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg.getCurrentValue(),
|
||||
false);
|
||||
exp = mapReplace.map(
|
||||
column,
|
||||
targetType,
|
||||
comboOperationsReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false);
|
||||
break;
|
||||
|
||||
}
|
||||
readableExp = mapReplace.getReadableExpression();
|
||||
expressionContainer = new ExpressionContainer(exp, readableExp);
|
||||
|
||||
expressionContainer = new ExpressionContainer(exp,
|
||||
readableExp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return expressionContainer;
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.client.properties;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.replace.ReplaceArithmeticType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ReplaceArithmeticElement implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3187480746998044539L;
|
||||
private Integer id;
|
||||
private ReplaceArithmeticType replaceArithmeticType;
|
||||
|
||||
public ReplaceArithmeticElement() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ReplaceArithmeticElement(Integer id, ReplaceArithmeticType replaceArithmeticType) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.replaceArithmeticType = replaceArithmeticType;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return replaceArithmeticType.toString();
|
||||
}
|
||||
|
||||
public ReplaceArithmeticType getReplaceArithmeticType() {
|
||||
return replaceArithmeticType;
|
||||
}
|
||||
|
||||
public void setReplaceArithmeticType(ReplaceArithmeticType replaceArithmeticType) {
|
||||
this.replaceArithmeticType = replaceArithmeticType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReplaceArithmeticElement [id=" + id
|
||||
+ ", replaceArithmeticType=" + replaceArithmeticType + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.client.properties;
|
||||
|
||||
import com.google.gwt.editor.client.Editor.Path;
|
||||
import com.sencha.gxt.data.shared.LabelProvider;
|
||||
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||
import com.sencha.gxt.data.shared.PropertyAccess;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface ReplaceArithmeticElementProperties extends PropertyAccess<ReplaceArithmeticElement> {
|
||||
|
||||
@Path("id")
|
||||
ModelKeyProvider<ReplaceArithmeticElement> id();
|
||||
|
||||
LabelProvider<ReplaceArithmeticElement> label();
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.client.properties;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.replace.ReplaceArithmeticType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ReplaceArithmeticElementStore {
|
||||
|
||||
public ArrayList<ReplaceArithmeticElement> replaceArithmeticElementsOperators = new ArrayList<ReplaceArithmeticElement>() {
|
||||
|
||||
private static final long serialVersionUID = 7803379977670393398L;
|
||||
|
||||
{
|
||||
add(new ReplaceArithmeticElement(1, ReplaceArithmeticType.Value));
|
||||
add(new ReplaceArithmeticElement(2, ReplaceArithmeticType.ColumnValue));
|
||||
add(new ReplaceArithmeticElement(3, ReplaceArithmeticType.SubstringByRegex));
|
||||
add(new ReplaceArithmeticElement(4, ReplaceArithmeticType.SubstringByIndex));
|
||||
add(new ReplaceArithmeticElement(5, ReplaceArithmeticType.SubstringByCharSeq));
|
||||
add(new ReplaceArithmeticElement(6, ReplaceArithmeticType.TextReplaceMatchingRegex));
|
||||
add(new ReplaceArithmeticElement(7, ReplaceArithmeticType.Addition));
|
||||
add(new ReplaceArithmeticElement(8, ReplaceArithmeticType.Subtraction));
|
||||
add(new ReplaceArithmeticElement(9, ReplaceArithmeticType.Modulus));
|
||||
add(new ReplaceArithmeticElement(10, ReplaceArithmeticType.Multiplication));
|
||||
add(new ReplaceArithmeticElement(11, ReplaceArithmeticType.Division));
|
||||
}
|
||||
};
|
||||
|
||||
public ArrayList<ReplaceArithmeticElement> replaceArithmeticElements = new ArrayList<ReplaceArithmeticElement>() {
|
||||
private static final long serialVersionUID = 7803379977670393398L;
|
||||
|
||||
{
|
||||
add(new ReplaceArithmeticElement(1, ReplaceArithmeticType.Value));
|
||||
add(new ReplaceArithmeticElement(2, ReplaceArithmeticType.ColumnValue));
|
||||
add(new ReplaceArithmeticElement(3, ReplaceArithmeticType.SubstringByRegex));
|
||||
add(new ReplaceArithmeticElement(4, ReplaceArithmeticType.SubstringByIndex));
|
||||
add(new ReplaceArithmeticElement(5, ReplaceArithmeticType.SubstringByCharSeq));
|
||||
add(new ReplaceArithmeticElement(6, ReplaceArithmeticType.TextReplaceMatchingRegex));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}
|
|
@ -12,7 +12,7 @@ import org.gcube.portlets.user.td.expressionwidget.shared.replace.ReplaceType;
|
|||
*/
|
||||
public class ReplaceElementStore {
|
||||
|
||||
public ArrayList<ReplaceElement> replaceElementsConcat = new ArrayList<ReplaceElement>() {
|
||||
public ArrayList<ReplaceElement> replaceElementsOperations = new ArrayList<ReplaceElement>() {
|
||||
|
||||
private static final long serialVersionUID = 1690916203781730778L;
|
||||
|
||||
|
@ -24,6 +24,11 @@ public class ReplaceElementStore {
|
|||
add(new ReplaceElement(5, ReplaceType.SubstringByCharSeq));
|
||||
add(new ReplaceElement(6, ReplaceType.TextReplaceMatchingRegex));
|
||||
add(new ReplaceElement(7, ReplaceType.Concat));
|
||||
add(new ReplaceElement(8, ReplaceType.Addition));
|
||||
add(new ReplaceElement(9, ReplaceType.Subtraction));
|
||||
add(new ReplaceElement(10, ReplaceType.Modulus));
|
||||
add(new ReplaceElement(11, ReplaceType.Multiplication));
|
||||
add(new ReplaceElement(12, ReplaceType.Division));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -42,4 +47,15 @@ public class ReplaceElementStore {
|
|||
}
|
||||
};
|
||||
|
||||
public ArrayList<ReplaceElement> replaceElementsArithmetic = new ArrayList<ReplaceElement>() {
|
||||
|
||||
private static final long serialVersionUID = 1690916203781730778L;
|
||||
|
||||
{
|
||||
add(new ReplaceElement(1, ReplaceType.ColumnValue));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -7,15 +7,14 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataT
|
|||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class C_ArithmeticExpression extends C_Expression {
|
||||
|
||||
private static final long serialVersionUID = 897961910530874376L;
|
||||
|
||||
|
||||
private String id = "ArithmeticExpression";
|
||||
|
||||
public static final ArrayList<ColumnDataType> acceptedDataTypes = new ArrayList<ColumnDataType>();
|
||||
|
@ -27,12 +26,12 @@ public class C_ArithmeticExpression extends C_Expression {
|
|||
|
||||
}
|
||||
|
||||
public C_ArithmeticExpression(C_Expression leftArgument, C_Expression rightArgument) {
|
||||
public C_ArithmeticExpression(C_Expression leftArgument,
|
||||
C_Expression rightArgument) {
|
||||
this.leftArgument = leftArgument;
|
||||
this.rightArgument = rightArgument;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
acceptedDataTypes.add(ColumnDataType.Numeric);
|
||||
acceptedDataTypes.add(ColumnDataType.Integer);
|
||||
|
@ -40,7 +39,6 @@ public class C_ArithmeticExpression extends C_Expression {
|
|||
acceptedDataTypes.add(ColumnDataType.Geometry);
|
||||
}
|
||||
|
||||
|
||||
public String getReturnedDataType() {
|
||||
return "DataType";
|
||||
}
|
||||
|
@ -53,13 +51,20 @@ public class C_ArithmeticExpression extends C_Expression {
|
|||
return acceptedDataTypes;
|
||||
}
|
||||
|
||||
public static boolean isAccepted(ColumnDataType columnDataType) {
|
||||
for (ColumnDataType c : acceptedDataTypes) {
|
||||
if (c.compareTo(columnDataType) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public C_Expression getLeftArgument() {
|
||||
return leftArgument;
|
||||
}
|
||||
|
@ -82,7 +87,4 @@ public class C_ArithmeticExpression extends C_Expression {
|
|||
+ leftArgument + ", rightArgument=" + rightArgument + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.shared.replace;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public enum ReplaceArithmeticType {
|
||||
Value("Value"),
|
||||
ColumnValue("Column Value"),
|
||||
SubstringByRegex("Substring by Regex"),
|
||||
SubstringByIndex("Substring by Index"),
|
||||
SubstringByCharSeq("Substring by Char Seq."),
|
||||
TextReplaceMatchingRegex("Replace Matching Regex"),
|
||||
Addition("Addition"),
|
||||
Subtraction("Subtraction"),
|
||||
Modulus("Modulus"),
|
||||
Multiplication("Multiplication"),
|
||||
Division("Division");
|
||||
|
||||
/**
|
||||
* @param text
|
||||
*/
|
||||
private ReplaceArithmeticType(final String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
private final String id;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,537 +0,0 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.shared.replace;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ReplaceTypeMapException;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_Addition;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_ArithmeticExpression;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_Division;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_Modulus;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_Multiplication;
|
||||
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.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_SubstringPosition;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_TextReplaceMatchingRegex;
|
||||
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.TD_Value;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
||||
/**
|
||||
* ReplaceArithmeticTypeMap creates a C_Expression usable client-side
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ReplaceArithmeticTypeMap {
|
||||
private String readableExpression;
|
||||
|
||||
public ReplaceArithmeticTypeMap() {
|
||||
|
||||
}
|
||||
|
||||
public C_Expression map(ColumnData column,
|
||||
ColumnDataType targetColumnDataType,
|
||||
ReplaceArithmeticType replaceType, String firstArg,
|
||||
String secondArg, boolean template) throws ReplaceTypeMapException {
|
||||
return map(column, targetColumnDataType, replaceType, firstArg,
|
||||
secondArg, template, null, null, null, null);
|
||||
}
|
||||
|
||||
public C_Expression map(ColumnData column,
|
||||
ColumnDataType targetColumnDataType,
|
||||
ReplaceArithmeticType replaceType, String firstArg,
|
||||
String secondArg, boolean template, C_Expression firstE,
|
||||
C_Expression secondE, String readableFirstE, String readableSecondE)
|
||||
throws ReplaceTypeMapException {
|
||||
Log.debug("ReplaceArithmeticTypeMap Map");
|
||||
C_Expression exp = null;
|
||||
readableExpression = new String();
|
||||
if (template) {
|
||||
exp = mapPlaceHolder(column, targetColumnDataType, replaceType,
|
||||
firstArg, secondArg, firstE, secondE, readableFirstE,
|
||||
readableSecondE);
|
||||
} else {
|
||||
exp = mapColumnReference(column, targetColumnDataType, replaceType,
|
||||
firstArg, secondArg, firstE, secondE, readableFirstE,
|
||||
readableSecondE);
|
||||
}
|
||||
return exp;
|
||||
}
|
||||
|
||||
public C_Expression mapPlaceHolder(ColumnData column,
|
||||
ColumnDataType targetColumnDataType,
|
||||
ReplaceArithmeticType replaceType, String firstArg,
|
||||
String secondArg, C_Expression firstE, C_Expression secondE,
|
||||
String readableFirstE, String readableSecondE)
|
||||
throws ReplaceTypeMapException {
|
||||
Log.debug("ReplaceArithmeticTypeMap Map Place Holder");
|
||||
C_Expression exp = null;
|
||||
|
||||
if (column == null) {
|
||||
switch (replaceType) {
|
||||
case Value:
|
||||
checkArithmeticTypeArgument(targetColumnDataType, firstArg);
|
||||
exp = new TD_Value(targetColumnDataType, firstArg);
|
||||
readableExpression = "Value(" + firstArg + ")";
|
||||
break;
|
||||
case Addition:
|
||||
exp = new C_Addition(firstE, secondE);
|
||||
readableExpression = "Addition(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Subtraction:
|
||||
exp = new C_Subtraction(firstE, secondE);
|
||||
readableExpression = "Subtraction(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Modulus:
|
||||
exp = new C_Modulus(firstE, secondE);
|
||||
readableExpression = "Modulus(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Multiplication:
|
||||
exp = new C_Multiplication(firstE, secondE);
|
||||
readableExpression = "Multiplication(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Division:
|
||||
exp = new C_Division(firstE, secondE);
|
||||
readableExpression = "Division(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
default:
|
||||
throw new ReplaceTypeMapException("No valid column selected");
|
||||
}
|
||||
return 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 != targetColumnDataType) {
|
||||
placeHolder = new C_Cast(placeH, targetColumnDataType);
|
||||
readablePlaceHolder = "Cast(" + column.getColumnId() + ","
|
||||
+ targetColumnDataType + ")";
|
||||
} else {
|
||||
placeHolder = placeH;
|
||||
readablePlaceHolder = column.getColumnId();
|
||||
|
||||
}
|
||||
|
||||
C_Expression placeHolderForStringExp;
|
||||
String readablePlaceHolderForStringExp;
|
||||
if (dataType != ColumnDataType.Text) {
|
||||
placeHolderForStringExp = new C_Cast(placeH, ColumnDataType.Text);
|
||||
readablePlaceHolderForStringExp = "Cast(" + column.getColumnId()
|
||||
+ "," + ColumnDataType.Text + ")";
|
||||
} else {
|
||||
placeHolderForStringExp = placeH;
|
||||
readablePlaceHolderForStringExp = column.getColumnId();
|
||||
|
||||
}
|
||||
|
||||
Log.debug("placeHolder:" + placeHolder);
|
||||
|
||||
TD_Value fArg, sArg;
|
||||
C_Expression posFrom, posTo;
|
||||
|
||||
switch (replaceType) {
|
||||
case Value:
|
||||
checkArithmeticTypeArgument(targetColumnDataType, firstArg);
|
||||
exp = new TD_Value(targetColumnDataType, firstArg);
|
||||
readableExpression = "Value(" + firstArg + ")";
|
||||
break;
|
||||
case ColumnValue:
|
||||
exp = placeHolder;
|
||||
readableExpression = "ColumnValue(" + readablePlaceHolder + ")";
|
||||
break;
|
||||
case Addition:
|
||||
exp = new C_Addition(firstE, secondE);
|
||||
readableExpression = "Addition(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Subtraction:
|
||||
exp = new C_Subtraction(firstE, secondE);
|
||||
readableExpression = "Subtraction(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Modulus:
|
||||
exp = new C_Modulus(firstE, secondE);
|
||||
readableExpression = "Modulus(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Multiplication:
|
||||
exp = new C_Multiplication(firstE, secondE);
|
||||
readableExpression = "Multiplication(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Division:
|
||||
exp = new C_Division(firstE, secondE);
|
||||
readableExpression = "Division(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case SubstringByRegex:
|
||||
checkTypeArgument(ColumnDataType.Text, firstArg);
|
||||
fArg = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
C_SubstringByRegex substringByRegex = new C_SubstringByRegex(
|
||||
placeHolderForStringExp, fArg);
|
||||
exp = new C_Cast(substringByRegex, targetColumnDataType);
|
||||
readableExpression = "Cast(SubstringByRegex("
|
||||
+ readablePlaceHolderForStringExp + ", " + firstArg + "),"
|
||||
+ targetColumnDataType + ")";
|
||||
break;
|
||||
case SubstringByIndex:
|
||||
checkTypeArgument(ColumnDataType.Integer, firstArg);
|
||||
checkTypeArgument(ColumnDataType.Integer, secondArg);
|
||||
fArg = new TD_Value(ColumnDataType.Integer, firstArg);
|
||||
sArg = new TD_Value(ColumnDataType.Integer, secondArg);
|
||||
C_SubstringByIndex substringByIndex = new C_SubstringByIndex(
|
||||
placeHolderForStringExp, fArg, sArg);
|
||||
exp = new C_Cast(substringByIndex, targetColumnDataType);
|
||||
readableExpression = "Cast(SubstringByIndex("
|
||||
+ readablePlaceHolderForStringExp + ", " + firstArg + ", "
|
||||
+ secondArg + ")," + targetColumnDataType + ")";
|
||||
break;
|
||||
case SubstringByCharSeq:
|
||||
checkTypeArgument(ColumnDataType.Text, firstArg);
|
||||
fArg = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
posFrom = new C_SubstringPosition(placeHolderForStringExp, fArg);
|
||||
checkTypeArgument(ColumnDataType.Text, secondArg);
|
||||
sArg = new TD_Value(ColumnDataType.Text, secondArg);
|
||||
posTo = new C_SubstringPosition(placeHolderForStringExp, fArg);
|
||||
C_SubstringByIndex substringByCharSeq = new C_SubstringByIndex(
|
||||
placeHolderForStringExp, posFrom, posTo);
|
||||
exp = new C_Cast(substringByCharSeq, targetColumnDataType);
|
||||
readableExpression = "Cast(SubstringByCharSeq("
|
||||
+ readablePlaceHolderForStringExp + ", " + firstArg + ", "
|
||||
+ secondArg + ")," + targetColumnDataType + ")";
|
||||
break;
|
||||
case TextReplaceMatchingRegex:
|
||||
checkTypeArgument(ColumnDataType.Text, firstArg);
|
||||
checkTypeArgument(ColumnDataType.Text, secondArg);
|
||||
fArg = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
sArg = new TD_Value(ColumnDataType.Text, secondArg);
|
||||
C_TextReplaceMatchingRegex textReplaceMatchingRegex = new C_TextReplaceMatchingRegex(
|
||||
placeHolderForStringExp, fArg, sArg);
|
||||
exp = new C_Cast(textReplaceMatchingRegex, targetColumnDataType);
|
||||
readableExpression = "Cast(TextReplaceMatchingRegex("
|
||||
+ readablePlaceHolderForStringExp + ", " + firstArg + ", "
|
||||
+ secondArg + ")," + targetColumnDataType + ")";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return exp;
|
||||
}
|
||||
|
||||
public C_Expression mapColumnReference(ColumnData column,
|
||||
ColumnDataType targetColumnDataType,
|
||||
ReplaceArithmeticType replaceType, String firstArg,
|
||||
String secondArg, C_Expression firstE, C_Expression secondE,
|
||||
String readableFirstE, String readableSecondE)
|
||||
throws ReplaceTypeMapException {
|
||||
Log.debug("ReplaceArithmeticTypeMap Map Typed Column Reference");
|
||||
C_Expression exp = null;
|
||||
|
||||
if (column == null) {
|
||||
switch (replaceType) {
|
||||
case Value:
|
||||
checkArithmeticTypeArgument(targetColumnDataType, firstArg);
|
||||
exp = new TD_Value(targetColumnDataType, firstArg);
|
||||
readableExpression = "Value(" + firstArg + ")";
|
||||
break;
|
||||
case Addition:
|
||||
exp = new C_Addition(firstE, secondE);
|
||||
readableExpression = "Addition(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Subtraction:
|
||||
exp = new C_Subtraction(firstE, secondE);
|
||||
readableExpression = "Subtraction(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Modulus:
|
||||
exp = new C_Modulus(firstE, secondE);
|
||||
readableExpression = "Modulus(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Multiplication:
|
||||
exp = new C_Multiplication(firstE, secondE);
|
||||
readableExpression = "Multiplication(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Division:
|
||||
exp = new C_Division(firstE, secondE);
|
||||
readableExpression = "Division(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
default:
|
||||
throw new ReplaceTypeMapException("No valid column selected");
|
||||
}
|
||||
return 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 != targetColumnDataType) {
|
||||
columnReference = new C_Cast(columnRef, targetColumnDataType);
|
||||
readableColumnReference = "Cast(" + column.getColumnId() + ","
|
||||
+ targetColumnDataType + ")";
|
||||
} else {
|
||||
columnReference = columnRef;
|
||||
readableColumnReference = column.getColumnId();
|
||||
|
||||
}
|
||||
|
||||
C_Expression columnReferenceForStringExp;
|
||||
String readableColumnReferenceForStringExp;
|
||||
if (dataType != ColumnDataType.Text) {
|
||||
columnReferenceForStringExp = new C_Cast(columnRef,
|
||||
ColumnDataType.Text);
|
||||
readableColumnReferenceForStringExp = "Cast("
|
||||
+ column.getColumnId() + "," + ColumnDataType.Text + ")";
|
||||
} else {
|
||||
columnReferenceForStringExp = columnRef;
|
||||
readableColumnReferenceForStringExp = column.getColumnId();
|
||||
|
||||
}
|
||||
|
||||
Log.debug("Typed Column Reference:" + columnReference);
|
||||
|
||||
TD_Value fArg, sArg;
|
||||
C_Expression posFrom, posTo;
|
||||
|
||||
switch (replaceType) {
|
||||
case Value:
|
||||
checkArithmeticTypeArgument(targetColumnDataType, firstArg);
|
||||
exp = new TD_Value(targetColumnDataType, firstArg);
|
||||
readableExpression = "Value(" + firstArg + ")";
|
||||
break;
|
||||
case ColumnValue:
|
||||
exp = columnReference;
|
||||
readableExpression = "ColumnValue(" + readableColumnReference + ")";
|
||||
break;
|
||||
case Addition:
|
||||
exp = new C_Addition(firstE, secondE);
|
||||
readableExpression = "Addition(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Subtraction:
|
||||
exp = new C_Subtraction(firstE, secondE);
|
||||
readableExpression = "Subtraction(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Modulus:
|
||||
exp = new C_Modulus(firstE, secondE);
|
||||
readableExpression = "Modulus(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Multiplication:
|
||||
exp = new C_Multiplication(firstE, secondE);
|
||||
readableExpression = "Multiplication(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case Division:
|
||||
exp = new C_Division(firstE, secondE);
|
||||
readableExpression = "Division(" + readableFirstE + ", "
|
||||
+ readableSecondE + ")";
|
||||
break;
|
||||
case SubstringByRegex:
|
||||
checkTypeArgument(ColumnDataType.Text, firstArg);
|
||||
fArg = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
C_SubstringByRegex substringByRegex = new C_SubstringByRegex(
|
||||
columnReferenceForStringExp, fArg);
|
||||
exp = new C_Cast(substringByRegex, targetColumnDataType);
|
||||
readableExpression = "Cast(SubStringByRegex("
|
||||
+ readableColumnReferenceForStringExp + ", " + firstArg
|
||||
+ ")," + targetColumnDataType + ")";
|
||||
break;
|
||||
case SubstringByIndex:
|
||||
checkTypeArgument(ColumnDataType.Integer, firstArg);
|
||||
checkTypeArgument(ColumnDataType.Integer, secondArg);
|
||||
fArg = new TD_Value(ColumnDataType.Integer, firstArg);
|
||||
sArg = new TD_Value(ColumnDataType.Integer, secondArg);
|
||||
C_SubstringByIndex substringByIndex = new C_SubstringByIndex(
|
||||
columnReferenceForStringExp, fArg, sArg);
|
||||
exp = new C_Cast(substringByIndex, targetColumnDataType);
|
||||
readableExpression = "Cast(SubstringByIndex("
|
||||
+ readableColumnReferenceForStringExp + ", " + firstArg
|
||||
+ ", " + secondArg + ")," + targetColumnDataType + ")";
|
||||
break;
|
||||
case SubstringByCharSeq:
|
||||
checkTypeArgument(ColumnDataType.Text, firstArg);
|
||||
fArg = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
posFrom = new C_SubstringPosition(columnReferenceForStringExp, fArg);
|
||||
checkTypeArgument(ColumnDataType.Text, secondArg);
|
||||
sArg = new TD_Value(ColumnDataType.Text, secondArg);
|
||||
posTo = new C_SubstringPosition(columnReferenceForStringExp, fArg);
|
||||
C_SubstringByIndex substringByCharSeq = new C_SubstringByIndex(
|
||||
columnReferenceForStringExp, posFrom, posTo);
|
||||
exp = new C_Cast(substringByCharSeq, targetColumnDataType);
|
||||
readableExpression = "Cast(SubstringByCharSeq("
|
||||
+ readableColumnReferenceForStringExp + ", " + firstArg
|
||||
+ ", " + secondArg + ")," + targetColumnDataType + ")";
|
||||
break;
|
||||
case TextReplaceMatchingRegex:
|
||||
checkTypeArgument(ColumnDataType.Text, firstArg);
|
||||
checkTypeArgument(ColumnDataType.Text, secondArg);
|
||||
fArg = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
sArg = new TD_Value(ColumnDataType.Text, secondArg);
|
||||
C_TextReplaceMatchingRegex textReplaceMatchingRegex = new C_TextReplaceMatchingRegex(
|
||||
columnReferenceForStringExp, fArg, sArg);
|
||||
exp = new C_Cast(textReplaceMatchingRegex, targetColumnDataType);
|
||||
readableExpression = "Cast(TextReplaceMatchingRegex("
|
||||
+ readableColumnReferenceForStringExp + ", " + firstArg
|
||||
+ ", " + secondArg + ")," + targetColumnDataType + ")";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return exp;
|
||||
}
|
||||
|
||||
public String getReadableExpression() {
|
||||
return readableExpression;
|
||||
}
|
||||
|
||||
protected void checkArithmeticTypeArgument(ColumnDataType columnDataType,
|
||||
String arg) throws ReplaceTypeMapException {
|
||||
boolean accepted = false;
|
||||
for (ColumnDataType acceptedColumnDataType : C_ArithmeticExpression.acceptedDataTypes) {
|
||||
if (acceptedColumnDataType.compareTo(columnDataType) == 0) {
|
||||
accepted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!accepted) {
|
||||
throw new ReplaceTypeMapException("Attention, " + columnDataType
|
||||
+ " is not a valid arithmetic type!");
|
||||
}
|
||||
|
||||
if (columnDataType == ColumnDataType.Date) {
|
||||
if (arg == null || arg.isEmpty()) {
|
||||
throw new ReplaceTypeMapException(
|
||||
"Insert a valid Date (ex: 2015-01-10)!");
|
||||
}
|
||||
} else {
|
||||
if (columnDataType == ColumnDataType.Geometry) {
|
||||
if (arg == null || arg.isEmpty()) {
|
||||
throw new ReplaceTypeMapException(
|
||||
"Insert a valid Geometry (ex: POINT(10 10))!");
|
||||
}
|
||||
} else {
|
||||
if (columnDataType == ColumnDataType.Integer) {
|
||||
if (arg == null) {
|
||||
throw new ReplaceTypeMapException(
|
||||
"Insert a valid Integer(ex: -1, 0, 1, 2)!");
|
||||
}
|
||||
|
||||
try {
|
||||
Integer.parseInt(arg);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new ReplaceTypeMapException(arg
|
||||
+ " is not valid Integer(ex: -1, 0, 1, 2)!");
|
||||
}
|
||||
} else {
|
||||
if (columnDataType == ColumnDataType.Numeric) {
|
||||
if (arg == null) {
|
||||
throw new ReplaceTypeMapException(
|
||||
"Insert a valid Numeric(ex: -1.2, 0, 1, 2.4)!");
|
||||
}
|
||||
try {
|
||||
Float.parseFloat(arg);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new ReplaceTypeMapException(
|
||||
arg
|
||||
+ " is not valid Numeric(ex: -1.2, 0, 1, 2.4)!");
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void checkTypeArgument(ColumnDataType columnDataType, String arg)
|
||||
throws ReplaceTypeMapException {
|
||||
if (columnDataType == ColumnDataType.Text) {
|
||||
if (arg == null) {
|
||||
arg = "";
|
||||
}
|
||||
} else {
|
||||
if (columnDataType == ColumnDataType.Boolean) {
|
||||
if (arg == null) {
|
||||
throw new ReplaceTypeMapException(
|
||||
"Insert a valid Boolean(ex: true, false)!");
|
||||
}
|
||||
} else {
|
||||
if (columnDataType == ColumnDataType.Date) {
|
||||
|
||||
} else {
|
||||
if (columnDataType == ColumnDataType.Geometry) {
|
||||
|
||||
} else {
|
||||
if (columnDataType == ColumnDataType.Integer) {
|
||||
if (arg == null) {
|
||||
throw new ReplaceTypeMapException(
|
||||
"Insert a valid Integer(ex: -1, 0, 1, 2)!");
|
||||
}
|
||||
|
||||
try {
|
||||
Integer.parseInt(arg);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new ReplaceTypeMapException(
|
||||
arg
|
||||
+ " is not valid Integer(ex: -1, 0, 1, 2)!");
|
||||
}
|
||||
} else {
|
||||
if (columnDataType == ColumnDataType.Numeric) {
|
||||
if (arg == null) {
|
||||
throw new ReplaceTypeMapException(
|
||||
"Insert a valid Numeric(ex: -1.2, 0, 1, 2.4)!");
|
||||
}
|
||||
try {
|
||||
Float.parseFloat(arg);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new ReplaceTypeMapException(
|
||||
arg
|
||||
+ " is not valid Numeric(ex: -1.2, 0, 1, 2.4)!");
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -7,14 +7,20 @@ package org.gcube.portlets.user.td.expressionwidget.shared.replace;
|
|||
*
|
||||
*/
|
||||
public enum ReplaceType {
|
||||
Null("Null"),
|
||||
Value("Value"),
|
||||
ColumnValue("Column Value"),
|
||||
SubstringByRegex("Substring by Regex"),
|
||||
SubstringByIndex("Substring by Index"),
|
||||
SubstringByCharSeq("Substring by Char Seq."),
|
||||
TextReplaceMatchingRegex("Replace Matching Regex"),
|
||||
Concat("Concat");
|
||||
Concat("Concat"),
|
||||
Addition("Addition"),
|
||||
Subtraction("Subtraction"),
|
||||
Modulus("Modulus"),
|
||||
Multiplication("Multiplication"),
|
||||
Division("Division");
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param text
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.shared.replace;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ReplaceTypeMapException;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_Addition;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_Division;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_Modulus;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_Multiplication;
|
||||
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.text.C_Concat;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringByIndex;
|
||||
|
@ -30,28 +35,28 @@ public class ReplaceTypeMap {
|
|||
|
||||
}
|
||||
|
||||
public C_Expression map(ColumnData column, ReplaceType replaceType,
|
||||
public C_Expression map(ColumnData column, ColumnDataType targetType, ReplaceType replaceType,
|
||||
String firstArg, String secondArg,boolean template) throws ReplaceTypeMapException {
|
||||
return map(column, replaceType,firstArg, secondArg, template, null, null, null, null);
|
||||
return map(column, targetType, replaceType,firstArg, secondArg, template, null, null, null, null);
|
||||
}
|
||||
|
||||
public C_Expression map(ColumnData column, ReplaceType replaceType,
|
||||
public C_Expression map(ColumnData column, ColumnDataType targetType, ReplaceType replaceType,
|
||||
String firstArg, String secondArg, boolean template, C_Expression firstE,
|
||||
C_Expression secondE, String readableFirstE, String readableSecondE) throws ReplaceTypeMapException {
|
||||
Log.debug("ReplaceTypeMap Map");
|
||||
C_Expression exp = null;
|
||||
readableExpression = new String();
|
||||
if (template) {
|
||||
exp = mapPlaceHolder(column, replaceType, firstArg, secondArg,
|
||||
exp = mapPlaceHolder(column, targetType, replaceType, firstArg, secondArg,
|
||||
firstE, secondE, readableFirstE,readableSecondE);
|
||||
} else {
|
||||
exp = mapColumnReference(column, replaceType, firstArg,
|
||||
exp = mapColumnReference(column, targetType, replaceType, firstArg,
|
||||
secondArg, firstE, secondE,readableFirstE,readableSecondE);
|
||||
}
|
||||
return exp;
|
||||
}
|
||||
|
||||
public C_Expression mapPlaceHolder(ColumnData column,
|
||||
public C_Expression mapPlaceHolder(ColumnData column,ColumnDataType targetType,
|
||||
ReplaceType replaceType, String firstArg, String secondArg,
|
||||
C_Expression firstE, C_Expression secondE,String readableFirstE, String readableSecondE) throws ReplaceTypeMapException {
|
||||
Log.debug("ReplaceTypeMap Map Place Holder");
|
||||
|
@ -59,19 +64,47 @@ public class ReplaceTypeMap {
|
|||
|
||||
if(column==null){
|
||||
switch (replaceType) {
|
||||
case Null:
|
||||
exp = new TD_Value(ColumnDataType.Text, "");
|
||||
readableExpression = "Null()";
|
||||
break;
|
||||
case Value:
|
||||
checkTypeArgument(ColumnDataType.Text,firstArg);
|
||||
exp = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
checkTypeArgument(targetType,firstArg);
|
||||
exp = new TD_Value(targetType, firstArg);
|
||||
readableExpression = "Value(" + firstArg + ")";
|
||||
break;
|
||||
case Concat:
|
||||
exp = new C_Concat(firstE, secondE);
|
||||
readableExpression = "Concat(" + readableFirstE
|
||||
+ ", " + readableSecondE + ")";
|
||||
C_Concat concat = new C_Concat(firstE, secondE);
|
||||
exp= new C_Cast(concat,targetType);
|
||||
readableExpression = "Cast(Concat(" + readableFirstE
|
||||
+ ", " + readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Addition:
|
||||
C_Addition add = new C_Addition(firstE, secondE);
|
||||
exp= new C_Cast(add, targetType);
|
||||
readableExpression = "Cast(Addition(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Subtraction:
|
||||
C_Subtraction sub = new C_Subtraction(firstE, secondE);
|
||||
exp= new C_Cast(sub,targetType);
|
||||
readableExpression = "Cast(Subtraction(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Modulus:
|
||||
C_Modulus modu = new C_Modulus(firstE, secondE);
|
||||
exp=new C_Cast(modu,targetType);
|
||||
readableExpression = "Cast(Modulus(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Multiplication:
|
||||
C_Multiplication multi = new C_Multiplication(firstE, secondE);
|
||||
exp=new C_Cast(multi,targetType);
|
||||
|
||||
readableExpression = "Cast(Multiplication(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Division:
|
||||
C_Division divi = new C_Division(firstE, secondE);
|
||||
exp=new C_Cast(divi,targetType);
|
||||
readableExpression = "Cast(Division(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
default:
|
||||
throw new ReplaceTypeMapException("No valid column selected");
|
||||
|
@ -79,7 +112,79 @@ public class ReplaceTypeMap {
|
|||
return exp;
|
||||
}
|
||||
|
||||
switch (replaceType) {
|
||||
case Value:
|
||||
checkTypeArgument(targetType,firstArg);
|
||||
exp = new TD_Value(targetType, firstArg);
|
||||
readableExpression = "Value(" + firstArg + ")";
|
||||
break;
|
||||
case ColumnValue:
|
||||
exp = columnValuePlaceHolder(column, targetType);
|
||||
break;
|
||||
case Concat:
|
||||
C_Concat concat = new C_Concat(firstE, secondE);
|
||||
exp= new C_Cast(concat,targetType);
|
||||
readableExpression = "Cast(Concat(" + readableFirstE
|
||||
+ ", " + readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Addition:
|
||||
C_Addition add = new C_Addition(firstE, secondE);
|
||||
exp= new C_Cast(add, targetType);
|
||||
readableExpression = "Cast(Addition(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Subtraction:
|
||||
C_Subtraction sub = new C_Subtraction(firstE, secondE);
|
||||
exp= new C_Cast(sub,targetType);
|
||||
readableExpression = "Cast(Subtraction(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Modulus:
|
||||
C_Modulus modu = new C_Modulus(firstE, secondE);
|
||||
exp=new C_Cast(modu,targetType);
|
||||
readableExpression = "Cast(Modulus(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Multiplication:
|
||||
C_Multiplication multi = new C_Multiplication(firstE, secondE);
|
||||
exp=new C_Cast(multi,targetType);
|
||||
|
||||
readableExpression = "Cast(Multiplication(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Division:
|
||||
C_Division divi = new C_Division(firstE, secondE);
|
||||
exp=new C_Cast(divi,targetType);
|
||||
readableExpression = "Cast(Division(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case SubstringByRegex:
|
||||
exp = substringByRegexPlaceHolder(column, targetType, firstArg);
|
||||
break;
|
||||
case SubstringByIndex:
|
||||
exp = substringByIndexPlaceHolder(column, targetType, firstArg,
|
||||
secondArg);
|
||||
break;
|
||||
case SubstringByCharSeq:
|
||||
exp = substringByCharSeqPlaceHolder(column, targetType, firstArg,
|
||||
secondArg);
|
||||
break;
|
||||
case TextReplaceMatchingRegex:
|
||||
exp = textReplaceMatchingRegexPlaceHolder(column, targetType,
|
||||
firstArg, secondArg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return exp;
|
||||
}
|
||||
|
||||
private C_Expression textReplaceMatchingRegexPlaceHolder(ColumnData column,
|
||||
ColumnDataType targetType, String firstArg, String secondArg)
|
||||
throws ReplaceTypeMapException {
|
||||
C_Expression exp;
|
||||
TD_Value fArg;
|
||||
TD_Value sArg;
|
||||
Log.debug("Column Data Type Name:" + column.getDataTypeName());
|
||||
ColumnDataType dataType = ColumnDataType
|
||||
.getColumnDataTypeFromId(column
|
||||
|
@ -91,7 +196,7 @@ public class ReplaceTypeMap {
|
|||
String readablePlaceHolder;
|
||||
if(dataType!=ColumnDataType.Text){
|
||||
placeHolder=new C_Cast(placeH, ColumnDataType.Text);
|
||||
readablePlaceHolder= "Cast("+column.getColumnId()+")";
|
||||
readablePlaceHolder= "Cast("+column.getColumnId()+","+ColumnDataType.Text+")";
|
||||
} else {
|
||||
placeHolder=placeH;
|
||||
readablePlaceHolder= column.getColumnId();
|
||||
|
@ -99,71 +204,157 @@ public class ReplaceTypeMap {
|
|||
}
|
||||
Log.debug("placeHolder:" + placeHolder);
|
||||
|
||||
TD_Value fArg, sArg;
|
||||
C_Expression posFrom, posTo;
|
||||
|
||||
switch (replaceType) {
|
||||
case Null:
|
||||
exp = new TD_Value(ColumnDataType.Text, "");
|
||||
readableExpression = "Null()";
|
||||
break;
|
||||
case Value:
|
||||
checkTypeArgument(ColumnDataType.Text,firstArg);
|
||||
exp = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
readableExpression = "Value(" + firstArg + ")";
|
||||
break;
|
||||
case ColumnValue:
|
||||
exp = placeHolder;
|
||||
readableExpression = "ColumnValue(" + readablePlaceHolder + ")";
|
||||
break;
|
||||
case Concat:
|
||||
exp = new C_Concat(firstE, secondE);
|
||||
readableExpression = "Concat(" + readableFirstE
|
||||
+ ", " + readableSecondE + ")";
|
||||
break;
|
||||
case SubstringByRegex:
|
||||
checkTypeArgument(ColumnDataType.Text,firstArg);
|
||||
checkTypeArgument(ColumnDataType.Text,secondArg);
|
||||
fArg = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
exp = new C_SubstringByRegex(placeHolder, fArg);
|
||||
readableExpression = "SubStringByRegex(" + readablePlaceHolder
|
||||
+ ", " + firstArg + ")";
|
||||
break;
|
||||
case SubstringByIndex:
|
||||
checkTypeArgument(ColumnDataType.Integer,firstArg);
|
||||
checkTypeArgument(ColumnDataType.Integer,secondArg);
|
||||
fArg = new TD_Value(ColumnDataType.Integer, firstArg);
|
||||
sArg = new TD_Value(ColumnDataType.Integer, secondArg);
|
||||
exp = new C_SubstringByIndex(placeHolder, fArg, sArg);
|
||||
readableExpression = "SubstringByIndex(" + readablePlaceHolder
|
||||
+ ", " + firstArg + ", " + secondArg + ")";
|
||||
break;
|
||||
case SubstringByCharSeq:
|
||||
sArg = new TD_Value(ColumnDataType.Text, secondArg);
|
||||
C_TextReplaceMatchingRegex substring = new C_TextReplaceMatchingRegex(placeHolder, fArg, sArg);
|
||||
exp=new C_Cast(substring, targetType);
|
||||
readableExpression = "Cast(TextReplaceMatchingRegex(" + readablePlaceHolder
|
||||
+ ", " + firstArg + ", " + secondArg + "),"+targetType+")";
|
||||
return exp;
|
||||
}
|
||||
|
||||
private C_Expression substringByCharSeqPlaceHolder(ColumnData column,
|
||||
ColumnDataType targetType, String firstArg, String secondArg)
|
||||
throws ReplaceTypeMapException {
|
||||
C_Expression exp;
|
||||
TD_Value fArg;
|
||||
//TD_Value sArg;
|
||||
C_Expression posFrom;
|
||||
C_Expression posTo;
|
||||
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);
|
||||
|
||||
|
||||
checkTypeArgument(ColumnDataType.Text,firstArg);
|
||||
fArg = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
posFrom = new C_SubstringPosition(placeHolder, fArg);
|
||||
checkTypeArgument(ColumnDataType.Text,secondArg);
|
||||
sArg = new TD_Value(ColumnDataType.Text, secondArg);
|
||||
//sArg = new TD_Value(ColumnDataType.Text, secondArg);
|
||||
posTo = new C_SubstringPosition(placeHolder, fArg);
|
||||
exp = new C_SubstringByIndex(placeHolder, posFrom, posTo);
|
||||
readableExpression = "SubstringByCharSeq(" + readablePlaceHolder
|
||||
+ ", " + firstArg + ", " + secondArg + ")";
|
||||
break;
|
||||
case TextReplaceMatchingRegex:
|
||||
checkTypeArgument(ColumnDataType.Text,firstArg);
|
||||
checkTypeArgument(ColumnDataType.Text,secondArg);
|
||||
fArg = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
sArg = new TD_Value(ColumnDataType.Text, secondArg);
|
||||
exp = new C_TextReplaceMatchingRegex(placeHolder, fArg, sArg);
|
||||
readableExpression = "TextReplaceMatchingRegex(" + readablePlaceHolder
|
||||
+ ", " + firstArg + ", " + secondArg + ")";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
C_SubstringByIndex substring = new C_SubstringByIndex(placeHolder, posFrom, posTo);
|
||||
exp=new C_Cast(substring, targetType);
|
||||
readableExpression = "Cast(SubstringByCharSeq(" + readablePlaceHolder
|
||||
+ ", " + firstArg + ", " + secondArg + "),"+targetType+")";
|
||||
return exp;
|
||||
}
|
||||
|
||||
public C_Expression mapColumnReference(ColumnData column,
|
||||
private C_Expression substringByIndexPlaceHolder(ColumnData column,
|
||||
ColumnDataType targetType, String firstArg, String secondArg)
|
||||
throws ReplaceTypeMapException {
|
||||
C_Expression exp;
|
||||
TD_Value fArg;
|
||||
TD_Value sArg;
|
||||
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);
|
||||
|
||||
|
||||
checkTypeArgument(ColumnDataType.Integer,firstArg);
|
||||
checkTypeArgument(ColumnDataType.Integer,secondArg);
|
||||
fArg = new TD_Value(ColumnDataType.Integer, firstArg);
|
||||
sArg = new TD_Value(ColumnDataType.Integer, secondArg);
|
||||
C_SubstringByIndex substring = new C_SubstringByIndex(placeHolder, fArg, sArg);
|
||||
exp=new C_Cast(substring, targetType);
|
||||
readableExpression = "Cast(SubstringByIndex(" + readablePlaceHolder
|
||||
+ ", " + firstArg + ", " + secondArg + "),"+targetType+")";
|
||||
return exp;
|
||||
}
|
||||
|
||||
private C_Expression substringByRegexPlaceHolder(ColumnData column,
|
||||
ColumnDataType targetType, String firstArg)
|
||||
throws ReplaceTypeMapException {
|
||||
C_Expression exp;
|
||||
TD_Value fArg;
|
||||
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);
|
||||
|
||||
checkTypeArgument(ColumnDataType.Text,firstArg);
|
||||
fArg = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
C_SubstringByRegex substring = new C_SubstringByRegex(placeHolder, fArg);
|
||||
exp=new C_Cast(substring, targetType);
|
||||
readableExpression = "Cast(SubStringByRegex(" + readablePlaceHolder
|
||||
+ ", " + firstArg + "),"+targetType+")";
|
||||
return exp;
|
||||
}
|
||||
|
||||
private C_Expression columnValuePlaceHolder(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_ColumnReferencePlaceholder placeH = new C_ColumnReferencePlaceholder(
|
||||
dataType, column.getColumnId());
|
||||
C_Expression placeHolder;
|
||||
String readablePlaceHolder;
|
||||
if(dataType!=targetType){
|
||||
placeHolder=new C_Cast(placeH, targetType);
|
||||
readablePlaceHolder= "Cast("+column.getColumnId()+","+targetType+")";
|
||||
} else {
|
||||
placeHolder=placeH;
|
||||
readablePlaceHolder= column.getColumnId();
|
||||
|
||||
}
|
||||
Log.debug("placeHolder:" + placeHolder);
|
||||
|
||||
|
||||
exp = placeHolder;
|
||||
readableExpression = "ColumnValue(" + readablePlaceHolder + ")";
|
||||
return exp;
|
||||
}
|
||||
|
||||
public C_Expression mapColumnReference(ColumnData column,ColumnDataType targetType,
|
||||
ReplaceType replaceType, String firstArg, String secondArg,
|
||||
C_Expression firstE, C_Expression secondE, String readableFirstE, String readableSecondE) throws ReplaceTypeMapException {
|
||||
Log.debug("ReplaceTypeMap Map Typed Column Reference");
|
||||
|
@ -171,19 +362,47 @@ public class ReplaceTypeMap {
|
|||
|
||||
if(column==null){
|
||||
switch (replaceType) {
|
||||
case Null:
|
||||
exp = new TD_Value(ColumnDataType.Text, "");
|
||||
readableExpression = "Null()";
|
||||
break;
|
||||
case Value:
|
||||
checkTypeArgument(ColumnDataType.Text,firstArg);
|
||||
exp = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
checkTypeArgument(targetType,firstArg);
|
||||
exp = new TD_Value(targetType, firstArg);
|
||||
readableExpression = "Value(" + firstArg + ")";
|
||||
break;
|
||||
case Concat:
|
||||
exp = new C_Concat(firstE, secondE);
|
||||
readableExpression = "Concat(" + readableFirstE
|
||||
+ ", " + readableSecondE + ")";
|
||||
C_Concat concat = new C_Concat(firstE, secondE);
|
||||
exp= new C_Cast(concat,targetType);
|
||||
readableExpression = "Cast(Concat(" + readableFirstE
|
||||
+ ", " + readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Addition:
|
||||
C_Addition add = new C_Addition(firstE, secondE);
|
||||
exp= new C_Cast(add, targetType);
|
||||
readableExpression = "Cast(Addition(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Subtraction:
|
||||
C_Subtraction sub = new C_Subtraction(firstE, secondE);
|
||||
exp= new C_Cast(sub,targetType);
|
||||
readableExpression = "Cast(Subtraction(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Modulus:
|
||||
C_Modulus modu = new C_Modulus(firstE, secondE);
|
||||
exp=new C_Cast(modu,targetType);
|
||||
readableExpression = "Cast(Modulus(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Multiplication:
|
||||
C_Multiplication multi = new C_Multiplication(firstE, secondE);
|
||||
exp=new C_Cast(multi,targetType);
|
||||
|
||||
readableExpression = "Cast(Multiplication(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Division:
|
||||
C_Division divi = new C_Division(firstE, secondE);
|
||||
exp=new C_Cast(divi,targetType);
|
||||
readableExpression = "Cast(Division(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
default:
|
||||
throw new ReplaceTypeMapException("No valid column selected");
|
||||
|
@ -192,6 +411,79 @@ public class ReplaceTypeMap {
|
|||
}
|
||||
|
||||
|
||||
switch (replaceType) {
|
||||
case Value:
|
||||
checkTypeArgument(targetType, firstArg);
|
||||
exp = new TD_Value(targetType, firstArg);
|
||||
readableExpression = "Value(" + firstArg + ")";
|
||||
break;
|
||||
case ColumnValue:
|
||||
exp = columnValueReference(column, targetType);
|
||||
break;
|
||||
case Concat:
|
||||
C_Concat concat = new C_Concat(firstE, secondE);
|
||||
exp= new C_Cast(concat,targetType);
|
||||
readableExpression = "Cast(Concat(" + readableFirstE
|
||||
+ ", " + readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Addition:
|
||||
C_Addition add = new C_Addition(firstE, secondE);
|
||||
exp= new C_Cast(add, targetType);
|
||||
readableExpression = "Cast(Addition(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Subtraction:
|
||||
C_Subtraction sub = new C_Subtraction(firstE, secondE);
|
||||
exp= new C_Cast(sub,targetType);
|
||||
readableExpression = "Cast(Subtraction(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Modulus:
|
||||
C_Modulus modu = new C_Modulus(firstE, secondE);
|
||||
exp=new C_Cast(modu,targetType);
|
||||
readableExpression = "Cast(Modulus(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Multiplication:
|
||||
C_Multiplication multi = new C_Multiplication(firstE, secondE);
|
||||
exp=new C_Cast(multi,targetType);
|
||||
|
||||
readableExpression = "Cast(Multiplication(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case Division:
|
||||
C_Division divi = new C_Division(firstE, secondE);
|
||||
exp=new C_Cast(divi,targetType);
|
||||
readableExpression = "Cast(Division(" + readableFirstE + ", "
|
||||
+ readableSecondE + "),"+targetType+")";
|
||||
break;
|
||||
case SubstringByRegex:
|
||||
exp = SubstringByRegexReference(column, targetType, firstArg);
|
||||
break;
|
||||
case SubstringByIndex:
|
||||
exp = substringByIndexReference(column, targetType, firstArg,
|
||||
secondArg);
|
||||
break;
|
||||
case SubstringByCharSeq:
|
||||
exp = substringByCharSeq(column, targetType, firstArg, secondArg);
|
||||
break;
|
||||
case TextReplaceMatchingRegex:
|
||||
exp = textReplaceMatchingRegexReference(column, targetType,
|
||||
firstArg, secondArg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return exp;
|
||||
}
|
||||
|
||||
private C_Expression textReplaceMatchingRegexReference(ColumnData column,
|
||||
ColumnDataType targetType, String firstArg, String secondArg)
|
||||
throws ReplaceTypeMapException {
|
||||
C_Expression exp;
|
||||
TD_Value fArg;
|
||||
TD_Value sArg;
|
||||
Log.debug("Column Data Type Name:" + column.getDataTypeName());
|
||||
ColumnDataType dataType = ColumnDataType
|
||||
.getColumnDataTypeFromId(column
|
||||
|
@ -205,7 +497,7 @@ public class ReplaceTypeMap {
|
|||
String readableColumnReference;
|
||||
if(dataType!=ColumnDataType.Text){
|
||||
columnReference=new C_Cast(columnRef,ColumnDataType.Text);
|
||||
readableColumnReference= "Cast("+column.getColumnId()+")";
|
||||
readableColumnReference= "Cast("+column.getColumnId()+","+ColumnDataType.Text+")";
|
||||
} else {
|
||||
columnReference=columnRef;
|
||||
readableColumnReference= column.getColumnId();
|
||||
|
@ -213,69 +505,158 @@ public class ReplaceTypeMap {
|
|||
}
|
||||
Log.debug("Typed Column Reference:" + columnReference);
|
||||
|
||||
TD_Value fArg, sArg;
|
||||
C_Expression posFrom, posTo;
|
||||
|
||||
switch (replaceType) {
|
||||
case Null:
|
||||
exp = new TD_Value(ColumnDataType.Text, "");
|
||||
readableExpression = "Null()";
|
||||
break;
|
||||
case Value:
|
||||
checkTypeArgument(ColumnDataType.Text, firstArg);
|
||||
exp = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
readableExpression = "Value(" + firstArg + ")";
|
||||
break;
|
||||
case ColumnValue:
|
||||
exp = columnReference;
|
||||
readableExpression = "ColumnValue(" + readableColumnReference + ")";
|
||||
break;
|
||||
case Concat:
|
||||
exp = new C_Concat(firstE, secondE);
|
||||
readableExpression = "Concat(" + readableFirstE
|
||||
+ ", " + readableSecondE + ")";
|
||||
break;
|
||||
case SubstringByRegex:
|
||||
checkTypeArgument(ColumnDataType.Text, firstArg);
|
||||
checkTypeArgument(ColumnDataType.Text, secondArg);
|
||||
fArg = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
exp = new C_SubstringByRegex(columnReference, fArg);
|
||||
readableExpression = "SubStringByRegex(" + readableColumnReference
|
||||
+ ", " + firstArg + ")";
|
||||
break;
|
||||
case SubstringByIndex:
|
||||
checkTypeArgument(ColumnDataType.Integer, firstArg);
|
||||
checkTypeArgument(ColumnDataType.Integer, secondArg);
|
||||
fArg = new TD_Value(ColumnDataType.Integer, firstArg);
|
||||
sArg = new TD_Value(ColumnDataType.Integer, secondArg);
|
||||
exp = new C_SubstringByIndex(columnReference, fArg, sArg);
|
||||
readableExpression = "SubstringByIndex(" + readableColumnReference
|
||||
+ ", " + firstArg + ", " + secondArg + ")";
|
||||
break;
|
||||
case SubstringByCharSeq:
|
||||
sArg = new TD_Value(ColumnDataType.Text, secondArg);
|
||||
C_TextReplaceMatchingRegex substring = new C_TextReplaceMatchingRegex(columnReference, fArg, sArg);
|
||||
exp=new C_Cast(substring, targetType);
|
||||
readableExpression = "Cast(TextReplaceMatchingRegex(" + readableColumnReference
|
||||
+ ", " + firstArg + ", " + secondArg + "),"+targetType+")";
|
||||
return exp;
|
||||
}
|
||||
|
||||
private C_Expression substringByCharSeq(ColumnData column,
|
||||
ColumnDataType targetType, String firstArg, String secondArg)
|
||||
throws ReplaceTypeMapException {
|
||||
C_Expression exp;
|
||||
TD_Value fArg;
|
||||
C_Expression posFrom;
|
||||
C_Expression posTo;
|
||||
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);
|
||||
|
||||
checkTypeArgument(ColumnDataType.Text, firstArg);
|
||||
fArg = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
posFrom = new C_SubstringPosition(columnReference, fArg);
|
||||
checkTypeArgument(ColumnDataType.Text, secondArg);
|
||||
sArg = new TD_Value(ColumnDataType.Text, secondArg);
|
||||
//sArg = new TD_Value(ColumnDataType.Text, secondArg);
|
||||
posTo = new C_SubstringPosition(columnReference, fArg);
|
||||
exp = new C_SubstringByIndex(columnReference, posFrom, posTo);
|
||||
readableExpression = "SubstringByCharSeq("
|
||||
C_SubstringByIndex substring = new C_SubstringByIndex(columnReference, posFrom, posTo);
|
||||
exp=new C_Cast(substring, targetType);
|
||||
readableExpression = "Cast(SubstringByCharSeq("
|
||||
+ readableColumnReference + ", " + firstArg + ", "
|
||||
+ secondArg + ")";
|
||||
break;
|
||||
case TextReplaceMatchingRegex:
|
||||
checkTypeArgument(ColumnDataType.Text, firstArg);
|
||||
checkTypeArgument(ColumnDataType.Text, secondArg);
|
||||
fArg = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
sArg = new TD_Value(ColumnDataType.Text, secondArg);
|
||||
exp = new C_TextReplaceMatchingRegex(columnReference, fArg, sArg);
|
||||
readableExpression = "TextReplaceMatchingRegex(" + readableColumnReference
|
||||
+ ", " + firstArg + ", " + secondArg + ")";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
+ secondArg + "),"+targetType+")";
|
||||
return exp;
|
||||
}
|
||||
|
||||
private C_Expression substringByIndexReference(ColumnData column,
|
||||
ColumnDataType targetType, String firstArg, String secondArg)
|
||||
throws ReplaceTypeMapException {
|
||||
C_Expression exp;
|
||||
TD_Value fArg;
|
||||
TD_Value sArg;
|
||||
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);
|
||||
|
||||
checkTypeArgument(ColumnDataType.Integer, firstArg);
|
||||
checkTypeArgument(ColumnDataType.Integer, secondArg);
|
||||
fArg = new TD_Value(ColumnDataType.Integer, firstArg);
|
||||
sArg = new TD_Value(ColumnDataType.Integer, secondArg);
|
||||
C_SubstringByIndex substring = new C_SubstringByIndex(columnReference, fArg, sArg);
|
||||
exp=new C_Cast(substring,targetType);
|
||||
readableExpression = "Cast(SubstringByIndex(" + readableColumnReference
|
||||
+ ", " + firstArg + ", " + secondArg + "),"+targetType+")";
|
||||
return exp;
|
||||
}
|
||||
|
||||
private C_Expression SubstringByRegexReference(ColumnData column,
|
||||
ColumnDataType targetType, String firstArg)
|
||||
throws ReplaceTypeMapException {
|
||||
C_Expression exp;
|
||||
TD_Value fArg;
|
||||
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);
|
||||
|
||||
|
||||
checkTypeArgument(ColumnDataType.Text, firstArg);
|
||||
fArg = new TD_Value(ColumnDataType.Text, firstArg);
|
||||
C_SubstringByRegex substring= new C_SubstringByRegex(columnReference, fArg);
|
||||
exp=new C_Cast(substring, targetType);
|
||||
readableExpression = "Cast(SubStringByRegex(" + readableColumnReference
|
||||
+ ", " + firstArg + "),"+targetType+")";
|
||||
return exp;
|
||||
}
|
||||
|
||||
private C_Expression columnValueReference(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!=targetType){
|
||||
columnReference=new C_Cast(columnRef,targetType);
|
||||
readableColumnReference= "Cast("+column.getColumnId()+","+targetType+")";
|
||||
} else {
|
||||
columnReference=columnRef;
|
||||
readableColumnReference= column.getColumnId();
|
||||
|
||||
}
|
||||
Log.debug("Typed Column Reference:" + columnReference);
|
||||
exp = columnReference;
|
||||
readableExpression = "ColumnValue(" + readableColumnReference + ")";
|
||||
return exp;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue