diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/ColumnMappingPanel.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/ColumnMappingPanel.java index 0493391..efe76f7 100644 --- a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/ColumnMappingPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/ColumnMappingPanel.java @@ -14,6 +14,7 @@ import org.gcube.portlets.user.td.unionwizardwidget.client.utils.UtilsGXT3; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; 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.tr.column.ColumnDataType; import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle; import com.allen_sauer.gwt.log.client.Log; @@ -48,7 +49,7 @@ import com.sencha.gxt.widget.core.client.form.FieldLabel; public class ColumnMappingPanel extends ContentPanel { private static final String COMBOWIDTH = "200px"; - //private static final String COLUMNLABELWIDTH = "120px"; + // private static final String COLUMNLABELWIDTH = "120px"; protected ResourceBundle res; protected ColumnMappingCard parent; protected VerticalLayoutContainer vert; @@ -75,8 +76,7 @@ public class ColumnMappingPanel extends ContentPanel { this.res = res; this.parent = parent; thisPanel = this; - - + Log.debug("ColumnMappingPanel"); init(); retrieveSourceColumns(); @@ -84,60 +84,62 @@ public class ColumnMappingPanel extends ContentPanel { protected void init() { setHeaderVisible(false); - //setBodyBorder(false); + // setBodyBorder(false); setBodyStyle("backgroundColor:#DFE8F6;"); - //new Resizable(this, Dir.E, Dir.SE, Dir.S); - //Important: fixed rendering of widgets + // new Resizable(this, Dir.E, Dir.SE, Dir.S); + // Important: fixed rendering of widgets forceLayoutOnResize = true; } protected void create() { SimpleContainer container = new SimpleContainer(); - + vert = new VerticalLayoutContainer(); vert.setScrollMode(ScrollMode.AUTO); vert.setAdjustForScroll(true); container.add(vert); - + setColumnMap(); - - /*FieldLabel columnLabel = new FieldLabel(null, "Column Label"); - columnLabel.getElement().applyStyles("font-weight:bold"); - columnLabel.setWidth(COLUMNLABELWIDTH); - columnLabel.setLabelSeparator("");*/ - - String currentTRLabel=parent.unionSession.getCurrentTabularResource().getName(); + + /* + * FieldLabel columnLabel = new FieldLabel(null, "Column Label"); + * columnLabel.getElement().applyStyles("font-weight:bold"); + * columnLabel.setWidth(COLUMNLABELWIDTH); + * columnLabel.setLabelSeparator(""); + */ + + String currentTRLabel = parent.unionSession.getCurrentTabularResource() + .getName(); FieldLabel sourceColumnLabel = new FieldLabel(null, currentTRLabel); sourceColumnLabel.getElement().applyStyles("font-weight:bold"); sourceColumnLabel.setWidth(COMBOWIDTH); sourceColumnLabel.setLabelSeparator(""); - - String unionTRLabel=parent.unionSession.getUnionTabularResource().getName(); + + String unionTRLabel = parent.unionSession.getUnionTabularResource() + .getName(); FieldLabel unionColumnLabel = new FieldLabel(null, unionTRLabel); unionColumnLabel.getElement().applyStyles("font-weight:bold"); unionColumnLabel.setWidth(COMBOWIDTH); unionColumnLabel.setLabelSeparator(""); - + final HBoxLayoutContainer horiz = new HBoxLayoutContainer(); horiz.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); horiz.setPack(BoxLayoutPack.START); - //horiz.add(columnLabel, new BoxLayoutData(new Margins(2, 1, 2, 1))); + // horiz.add(columnLabel, new BoxLayoutData(new Margins(2, 1, 2, 1))); horiz.add(sourceColumnLabel, new BoxLayoutData(new Margins(2, 1, 2, 1))); horiz.add(unionColumnLabel, new BoxLayoutData(new Margins(2, 1, 2, 1))); - - - + VerticalLayoutContainer vPanel = new VerticalLayoutContainer(); vPanel.setScrollMode(ScrollMode.AUTO); vPanel.setAdjustForScroll(true); - - - vPanel.add(horiz, new VerticalLayoutData(1, -1, new Margins(1,1,1,10))); - vPanel.add(container, new VerticalLayoutData(1, -1, new Margins(1,1,1,10))); - - + + vPanel.add(horiz, new VerticalLayoutData(1, -1, + new Margins(1, 1, 1, 10))); + vPanel.add(container, new VerticalLayoutData(1, -1, new Margins(1, 1, + 1, 10))); + add(vPanel); forceLayout(); @@ -210,10 +212,12 @@ public class ColumnMappingPanel extends ContentPanel { final HBoxLayoutContainer horiz = new HBoxLayoutContainer(); // Column Label - /*TextField columnLabel = new TextField(); - columnLabel.setItemId(itemIdLabelColumn); - columnLabel.setAllowBlank(false); - columnLabel.setWidth(COLUMNLABELWIDTH);*/ + /* + * TextField columnLabel = new TextField(); + * columnLabel.setItemId(itemIdLabelColumn); + * columnLabel.setAllowBlank(false); + * columnLabel.setWidth(COLUMNLABELWIDTH); + */ // Source Combo ColumnDataProperties propsSourceColumn = GWT @@ -298,11 +302,32 @@ public class ColumnMappingPanel extends ContentPanel { .getSelectedItem(); storeComboUnionColumn.clear(); for (ColumnData col : unionColumns) { - if (col.getDataTypeName() == selectedSourceColumn - .getDataTypeName() - && col.getTypeCode() == selectedSourceColumn - .getTypeCode()) { + if (selectedSourceColumn.getDataTypeName() + .compareTo(ColumnDataType.Text.toString()) == 0 + || col.getDataTypeName().compareTo( + ColumnDataType.Text.toString()) == 0) { storeComboUnionColumn.add(col); + } else { + if ((col.getDataTypeName().compareTo( + ColumnDataType.Integer.toString()) == 0 && selectedSourceColumn + .getDataTypeName().compareTo( + ColumnDataType.Numeric + .toString()) == 0) + || (col.getDataTypeName().compareTo( + ColumnDataType.Numeric + .toString()) == 0 && selectedSourceColumn + .getDataTypeName().compareTo( + ColumnDataType.Integer + .toString()) == 0)) { + storeComboUnionColumn.add(col); + } else { + if (col.getDataTypeName().compareTo(selectedSourceColumn + .getDataTypeName())==0) { + storeComboUnionColumn.add(col); + } else { + + } + } } } storeComboUnionColumn.commitChanges(); @@ -314,7 +339,7 @@ public class ColumnMappingPanel extends ContentPanel { horiz.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); horiz.setPack(BoxLayoutPack.START); - //horiz.add(columnLabel, new BoxLayoutData(new Margins(2, 1, 2, 1))); + // horiz.add(columnLabel, new BoxLayoutData(new Margins(2, 1, 2, 1))); horiz.add(comboSourceColumn, new BoxLayoutData(new Margins(2, 1, 2, 1))); horiz.add(comboUnionColumn, new BoxLayoutData(new Margins(2, 1, 2, 1))); horiz.add(btnAdd, new BoxLayoutData(new Margins(2, 1, 2, 1))); @@ -328,10 +353,12 @@ public class ColumnMappingPanel extends ContentPanel { final HBoxLayoutContainer horiz = new HBoxLayoutContainer(); // Column Label - /*TextField columnLabel = new TextField(); - columnLabel.setItemId(itemIdLabelColumn); - columnLabel.setAllowBlank(false); - columnLabel.setWidth(COLUMNLABELWIDTH);*/ + /* + * TextField columnLabel = new TextField(); + * columnLabel.setItemId(itemIdLabelColumn); + * columnLabel.setAllowBlank(false); + * columnLabel.setWidth(COLUMNLABELWIDTH); + */ // Source Combo ColumnDataProperties propsSourceColumn = GWT @@ -416,11 +443,32 @@ public class ColumnMappingPanel extends ContentPanel { .getSelectedItem(); storeComboUnionColumn.clear(); for (ColumnData col : unionColumns) { - if (col.getDataTypeName() == selectedSourceColumn - .getDataTypeName() - && col.getTypeCode() == selectedSourceColumn - .getTypeCode()) { + if (selectedSourceColumn.getDataTypeName() + .compareTo(ColumnDataType.Text.toString()) == 0 + || col.getDataTypeName().compareTo( + ColumnDataType.Text.toString()) == 0) { storeComboUnionColumn.add(col); + } else { + if ((col.getDataTypeName().compareTo( + ColumnDataType.Integer.toString()) == 0 && selectedSourceColumn + .getDataTypeName().compareTo( + ColumnDataType.Numeric + .toString()) == 0) + || (col.getDataTypeName().compareTo( + ColumnDataType.Numeric + .toString()) == 0 && selectedSourceColumn + .getDataTypeName().compareTo( + ColumnDataType.Integer + .toString()) == 0)) { + storeComboUnionColumn.add(col); + } else { + if (col.getDataTypeName().compareTo(selectedSourceColumn + .getDataTypeName())==0) { + storeComboUnionColumn.add(col); + } else { + + } + } } } storeComboUnionColumn.commitChanges(); @@ -432,7 +480,7 @@ public class ColumnMappingPanel extends ContentPanel { horiz.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); horiz.setPack(BoxLayoutPack.START); - //horiz.add(columnLabel, new BoxLayoutData(new Margins(2, 1, 2, 1))); + // horiz.add(columnLabel, new BoxLayoutData(new Margins(2, 1, 2, 1))); horiz.add(comboSourceColumn, new BoxLayoutData(new Margins(2, 1, 2, 1))); horiz.add(comboUnionColumn, new BoxLayoutData(new Margins(2, 1, 2, 1))); horiz.add(btnAdd, new BoxLayoutData(new Margins(2, 1, 2, 1))); @@ -453,40 +501,36 @@ public class ColumnMappingPanel extends ContentPanel { for (; i < lenght; i++) { HBoxLayoutContainer h = (HBoxLayoutContainer) vert.getWidget(i); if (h != null) { - /*TextField columnLabelField = (TextField) h - .getItemByItemId(itemIdLabelColumn); - if (columnLabelField != null) { - String columnLabel = columnLabelField.getCurrentValue(); - if (columnLabel != null && !columnLabel.isEmpty()) { - */ - @SuppressWarnings("unchecked") - ComboBox comboSourceColumn = (ComboBox) h - .getItemByItemId(itemIdSourceColumn); - ColumnData sourceColumn = comboSourceColumn - .getCurrentValue(); - if (sourceColumn != null) { - @SuppressWarnings("unchecked") - ComboBox comboUnionColumn = (ComboBox) h - .getItemByItemId(itemIdUnionColumn); - ColumnData unionColumn = comboUnionColumn - .getCurrentValue(); - if (unionColumn != null) { - UnionColumnsMapping colMatch = new UnionColumnsMapping( - "default", sourceColumn, unionColumn); - listUnionColumnsMapping.add(colMatch); - } else { - Log.debug("Union Column is null"); - } - } else { - Log.debug("Source Column is null"); - } - /* + /* + * TextField columnLabelField = (TextField) h + * .getItemByItemId(itemIdLabelColumn); if (columnLabelField != + * null) { String columnLabel = + * columnLabelField.getCurrentValue(); if (columnLabel != null + * && !columnLabel.isEmpty()) { + */ + @SuppressWarnings("unchecked") + ComboBox comboSourceColumn = (ComboBox) h + .getItemByItemId(itemIdSourceColumn); + ColumnData sourceColumn = comboSourceColumn.getCurrentValue(); + if (sourceColumn != null) { + @SuppressWarnings("unchecked") + ComboBox comboUnionColumn = (ComboBox) h + .getItemByItemId(itemIdUnionColumn); + ColumnData unionColumn = comboUnionColumn.getCurrentValue(); + if (unionColumn != null) { + UnionColumnsMapping colMatch = new UnionColumnsMapping( + "default", sourceColumn, unionColumn); + listUnionColumnsMapping.add(colMatch); } else { - Log.debug("Column Label is null"); + Log.debug("Union Column is null"); } } else { - Log.debug("Column Label Field is null"); - }*/ + Log.debug("Source Column is null"); + } + /* + * } else { Log.debug("Column Label is null"); } } else { + * Log.debug("Column Label Field is null"); } + */ } else { Log.debug("HorizontalContainer is null"); }