Updated Column Change Type
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@101656 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
93b75461b3
commit
a2797d2c70
|
@ -27,6 +27,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalExcept
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.RefColumn;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.mapping.ColumnMappingList;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeSession;
|
||||
|
@ -72,7 +73,6 @@ import com.sencha.gxt.widget.core.client.event.TriggerClickEvent;
|
|||
import com.sencha.gxt.widget.core.client.event.TriggerClickEvent.TriggerClickHandler;
|
||||
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||
import com.sencha.gxt.widget.core.client.info.Info;
|
||||
|
||||
/**
|
||||
|
@ -86,47 +86,51 @@ import com.sencha.gxt.widget.core.client.info.Info;
|
|||
*/
|
||||
public class ChangeColumnTypePanel extends FramedPanel implements
|
||||
CodelistSelectionListener, ColumnMappingListener, MonitorDialogListener {
|
||||
protected String WIDTH = "640px";
|
||||
protected String HEIGHT = "520px";
|
||||
protected EventBus eventBus;
|
||||
protected ChangeColumnTypeDialog parent;
|
||||
protected TextField label = null;
|
||||
protected TRId trId;
|
||||
protected String columnName;
|
||||
protected ColumnData column;
|
||||
protected ComboBox<ColumnData> comboColumn = null;
|
||||
protected ComboBox<ColumnTypeCodeElement> comboColumnTypeCode = null;
|
||||
private String WIDTH = "640px";
|
||||
private String HEIGHT = "520px";
|
||||
private EventBus eventBus;
|
||||
private ChangeColumnTypeDialog parent;
|
||||
// private TextField label = null;
|
||||
private TRId trId;
|
||||
private String columnName;
|
||||
// private ColumnData column;
|
||||
private ColumnData columnRequested;
|
||||
private ColumnData connectionColumn;
|
||||
private ComboBox<ColumnData> comboColumn = null;
|
||||
private ComboBox<ColumnTypeCodeElement> comboColumnTypeCode = null;
|
||||
|
||||
protected ComboBox<ColumnDataTypeElement> comboMeasureType = null;
|
||||
protected FieldLabel comboMeasureTypeLabel;
|
||||
private ComboBox<ColumnDataTypeElement> comboMeasureType = null;
|
||||
private FieldLabel comboMeasureTypeLabel;
|
||||
|
||||
protected ComboBox<ColumnDataTypeElement> comboAttributeType = null;
|
||||
protected FieldLabel comboAttributeTypeLabel;
|
||||
private ComboBox<ColumnDataTypeElement> comboAttributeType = null;
|
||||
private FieldLabel comboAttributeTypeLabel;
|
||||
|
||||
protected ComboBox<TabResource> comboDimensionType = null;
|
||||
protected FieldLabel comboDimensionTypeLabel;
|
||||
protected ListStore<TabResource> storeComboDimensionType;
|
||||
private ComboBox<TabResource> comboDimensionType = null;
|
||||
private FieldLabel comboDimensionTypeLabel;
|
||||
private ListStore<TabResource> storeComboDimensionType;
|
||||
|
||||
protected ComboBox<ColumnData> comboColumnReferenceType = null;
|
||||
protected FieldLabel comboColumnReferenceTypeLabel;
|
||||
protected ListStore<ColumnData> storeComboColumnReferenceType;
|
||||
private ComboBox<ColumnData> comboColumnReferenceType = null;
|
||||
private FieldLabel comboColumnReferenceTypeLabel;
|
||||
private ListStore<ColumnData> storeComboColumnReferenceType;
|
||||
|
||||
protected ComboBox<ColumnMappingList> comboColumnMapping = null;
|
||||
protected FieldLabel comboColumnMappingLabel;
|
||||
protected ListStore<ColumnMappingList> storeComboColumnMapping;
|
||||
private ComboBox<ColumnMappingList> comboColumnMapping = null;
|
||||
private FieldLabel comboColumnMappingLabel;
|
||||
private ListStore<ColumnMappingList> storeComboColumnMapping;
|
||||
|
||||
protected ComboBox<TimeDimensionTypeElement> comboTimeDimensionType = null;
|
||||
protected FieldLabel comboTimeDimensionTypeLabel;
|
||||
private ComboBox<TimeDimensionTypeElement> comboTimeDimensionType = null;
|
||||
private FieldLabel comboTimeDimensionTypeLabel;
|
||||
|
||||
protected ComboBox<LocaleTypeElement> comboLocaleType = null;
|
||||
protected FieldLabel comboLocaleTypeLabel;
|
||||
protected ListStore<LocaleTypeElement> storeComboLocaleType;
|
||||
private ComboBox<LocaleTypeElement> comboLocaleType = null;
|
||||
private FieldLabel comboLocaleTypeLabel;
|
||||
private ListStore<LocaleTypeElement> storeComboLocaleType;
|
||||
|
||||
protected ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader;
|
||||
private ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader;
|
||||
|
||||
protected TextButton change;
|
||||
private TextButton change;
|
||||
|
||||
protected ChangeColumnTypeSession changeColumnTypeSession;
|
||||
private ChangeColumnTypeSession changeColumnTypeSession;
|
||||
private boolean panelCreated;
|
||||
private ColumnData columnChangeType;
|
||||
|
||||
public ChangeColumnTypePanel(TRId trId, String columnName, EventBus eventBus) {
|
||||
setWidth(WIDTH);
|
||||
|
@ -136,8 +140,60 @@ public class ChangeColumnTypePanel extends FramedPanel implements
|
|||
this.trId = trId;
|
||||
this.columnName = columnName;
|
||||
this.eventBus = eventBus;
|
||||
panelCreated = false;
|
||||
retrieveColumnRequested();
|
||||
}
|
||||
|
||||
protected void retrieveColumnRequested() {
|
||||
|
||||
TDGWTServiceAsync.INSTANCE.getColumn(trId, columnName,
|
||||
new AsyncCallback<ColumnData>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsLockedException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsFinalException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Final",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
Log.debug("Error retrieving column: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3
|
||||
.alert("Error retrieving column",
|
||||
"Error retrieving column on server!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ColumnData result) {
|
||||
Log.debug("Retrieved Column: " + result);
|
||||
if (result == null) {
|
||||
UtilsGXT3.alert("Error",
|
||||
"The requested column is null");
|
||||
}
|
||||
columnRequested = result;
|
||||
if (panelCreated) {
|
||||
loader.load();
|
||||
} else {
|
||||
panelCreated = true;
|
||||
create();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void create() {
|
||||
|
||||
|
@ -325,7 +381,6 @@ public class ChangeColumnTypePanel extends FramedPanel implements
|
|||
comboColumnReferenceTypeLabel = new FieldLabel(
|
||||
comboColumnReferenceType, "Column");
|
||||
|
||||
// TODO
|
||||
// ColumnMapping
|
||||
ColumnMappingListProperties propsColumnMapping = GWT
|
||||
.create(ColumnMappingListProperties.class);
|
||||
|
@ -749,20 +804,29 @@ public class ChangeColumnTypePanel extends FramedPanel implements
|
|||
}
|
||||
|
||||
protected void setComboStatus(ArrayList<ColumnData> result) {
|
||||
Log.debug("ColumnName:" + columnName);
|
||||
if (columnName != null) {
|
||||
for (ColumnData cd : result) {
|
||||
Log.debug("ColumnData name:" + cd.getName());
|
||||
if (cd.getName().compareTo(columnName) == 0) {
|
||||
Log.debug("ColumnRequested: " + columnRequested);
|
||||
String columnId;
|
||||
|
||||
if (columnRequested.isViewColumn()) {
|
||||
columnId = columnRequested.getColumnViewData()
|
||||
.getSourceTableDimensionColumnId();
|
||||
} else {
|
||||
columnId = columnRequested.getColumnId();
|
||||
}
|
||||
if (columnRequested != null) {
|
||||
for (ColumnData cd : result) {
|
||||
Log.debug("Column:" + cd.getColumnId());
|
||||
if (cd.getColumnId().compareTo(columnId) == 0) {
|
||||
columnChangeType=cd;
|
||||
updateComboStatus(cd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateComboStatus(ColumnData cd) {
|
||||
Log.debug("ColumnData: " + cd.toString());
|
||||
Log.debug("Update Combos ColumnData: " + cd.toString());
|
||||
changeColumnTypeSession = new ChangeColumnTypeSession();
|
||||
changeColumnTypeSession.setColumnData(cd);
|
||||
comboColumn.setValue(cd);
|
||||
|
@ -787,19 +851,32 @@ public class ChangeColumnTypePanel extends FramedPanel implements
|
|||
if (type == ColumnTypeCode.CODENAME) {
|
||||
setLocale(cd.getLocale());
|
||||
} else {
|
||||
// TODO Add TimeDimension and Dimension information to
|
||||
// ColumnData
|
||||
/*
|
||||
* if (type == ColumnTypeCode.TIMEDIMENSION) {
|
||||
* changeColumnTypeSession
|
||||
* .setColumnDataType(ColumnDataTypeStore
|
||||
* .selectedAttribute(cd.getDataTypeName()));
|
||||
* comboTimeDimensionType.setValue(TimeDimensionTypeStore
|
||||
* .selectedAttributeElement(cd.getDataTypeName())); } else
|
||||
* {
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
if (type == ColumnTypeCode.TIMEDIMENSION) {
|
||||
changeColumnTypeSession
|
||||
.setTimeDimensionType(TimeDimensionTypeStore
|
||||
.selectedTimeDimension(cd
|
||||
.getPeriodDataType()
|
||||
.getPeriodDataTypeLabel()));
|
||||
comboTimeDimensionType.setValue(TimeDimensionTypeStore
|
||||
.selectedTimeDimensionElement(cd
|
||||
.getPeriodDataType()
|
||||
.getPeriodDataTypeLabel()));
|
||||
} else {
|
||||
// TODO
|
||||
if (type == ColumnTypeCode.DIMENSION) {
|
||||
RefColumn refColumn = new RefColumn(
|
||||
String.valueOf(cd.getRelationship()
|
||||
.getTargetTableId()), cd
|
||||
.getRelationship()
|
||||
.getTargetColumnId());
|
||||
retrieveConnectionForViewColumn(refColumn);
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -809,7 +886,47 @@ public class ChangeColumnTypePanel extends FramedPanel implements
|
|||
public void update(TRId trId, String columnName) {
|
||||
this.trId = trId;
|
||||
this.columnName = columnName;
|
||||
loader.load();
|
||||
retrieveColumnRequested();
|
||||
}
|
||||
|
||||
protected void retrieveConnectionForViewColumn(RefColumn refCol) {
|
||||
Log.debug("Retrieve Connection For View Column: " + refCol);
|
||||
TDGWTServiceAsync.INSTANCE.getConnection(refCol,
|
||||
new AsyncCallback<ColumnData>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsLockedException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsFinalException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Final",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
Log.error("load column failure:"
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3
|
||||
.alert("Error retrieving connection",
|
||||
"Error retrieving connection column");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onSuccess(ColumnData result) {
|
||||
Log.debug("Column: " + result);
|
||||
connectionColumn = result;
|
||||
retrieveTabularResource(result.getTrId());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void onChangeTypeColumn() {
|
||||
|
@ -988,7 +1105,7 @@ public class ChangeColumnTypePanel extends FramedPanel implements
|
|||
Log.debug("Selected Codelist: " + tabResource);
|
||||
comboDimensionType.setValue(tabResource, true);
|
||||
|
||||
retrieveColumnData(tabResource);
|
||||
retrieveColumnsForDimension(tabResource.getTrId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1004,9 +1121,8 @@ public class ChangeColumnTypePanel extends FramedPanel implements
|
|||
|
||||
}
|
||||
|
||||
protected void retrieveColumnData(TabResource tabResource) {
|
||||
TDGWTServiceAsync.INSTANCE.getColumnsForDimension(
|
||||
tabResource.getTrId(),
|
||||
protected void retrieveColumnsForDimension(TRId trId) {
|
||||
TDGWTServiceAsync.INSTANCE.getColumnsForDimension(trId,
|
||||
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
||||
@Override
|
||||
|
@ -1048,6 +1164,93 @@ public class ChangeColumnTypePanel extends FramedPanel implements
|
|||
|
||||
}
|
||||
|
||||
protected void retrieveColumnsForSelectedDimension(TRId trId) {
|
||||
TDGWTServiceAsync.INSTANCE.getColumnsForDimension(trId,
|
||||
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsLockedException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsFinalException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Final",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
Log.debug("Error retrieving columns: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3
|
||||
.alert("Error retrieving columns",
|
||||
"Error retrieving columns on server!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<ColumnData> result) {
|
||||
comboColumnReferenceType.reset();
|
||||
storeComboColumnReferenceType.clear();
|
||||
storeComboColumnReferenceType.addAll(result);
|
||||
storeComboColumnReferenceType.commitChanges();
|
||||
comboColumnReferenceTypeLabel.setVisible(true);
|
||||
comboColumnReferenceType.setValue(connectionColumn,
|
||||
true);
|
||||
forceLayout();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void retrieveTabularResource(TRId trId) {
|
||||
TDGWTServiceAsync.INSTANCE.getTabResourceInformation(trId,
|
||||
new AsyncCallback<TabResource>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsLockedException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsFinalException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Final",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
Log.debug("Error retrieving tabular resource: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3
|
||||
.alert("Error retrieving tabular resource",
|
||||
caught.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(TabResource result) {
|
||||
comboDimensionType.setValue(result, true);
|
||||
retrieveColumnsForSelectedDimension(result.getTrId());
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void retriveLocales() {
|
||||
TDGWTServiceAsync.INSTANCE
|
||||
.getLocales(new AsyncCallback<ArrayList<String>>() {
|
||||
|
|
Loading…
Reference in New Issue