81: Allow the creation and use of expressions on multi column in TDM portlet

Task-Url: https://support.d4science.org/issues/81

Updated apply rule on table

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-rule-widget@115087 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-05-28 10:43:57 +00:00 committed by Giancarlo Panichi
parent 58e85407cb
commit 5958104137
2 changed files with 50 additions and 25 deletions

View File

@ -17,6 +17,7 @@ import org.gcube.portlets.user.td.rulewidget.client.multicolumn.data.MapPlaceHol
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.tr.column.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
@ -49,6 +50,7 @@ import com.sencha.gxt.widget.core.client.form.FormPanel;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
import com.sencha.gxt.widget.core.client.grid.Grid.GridCell;
import com.sencha.gxt.widget.core.client.grid.GridSelectionModel;
import com.sencha.gxt.widget.core.client.grid.editing.GridRowEditing;
@ -66,6 +68,7 @@ public class RuleOnTableApplyMapColumnCard extends WizardCard {
private ListStore<MapPlaceHolderToColumnRow> store;
private ArrayList<MapPlaceHolderToColumnRow> rows;
private ArrayList<ColumnData> columns;
private ListStore<ColumnData> storeComboColumnData;
public RuleOnTableApplyMapColumnCard(
ApplyTableRuleSession applyTableRuleSession) {
@ -177,9 +180,9 @@ public class RuleOnTableApplyMapColumnCard extends WizardCard {
ColumnDataPropertiesCombo columnDataPropertiesCombo = GWT
.create(ColumnDataPropertiesCombo.class);
ListStore<ColumnData> storeComboColumnData = new ListStore<ColumnData>(
storeComboColumnData = new ListStore<ColumnData>(
columnDataPropertiesCombo.id());
storeComboColumnData.addAll(columns);
ComboBox<ColumnData> comboColumnData = new ComboBox<ColumnData>(
storeComboColumnData, columnDataPropertiesCombo.label());
@ -198,6 +201,25 @@ public class RuleOnTableApplyMapColumnCard extends WizardCard {
public void onBeforeStartEdit(
BeforeStartEditEvent<MapPlaceHolderToColumnRow> event) {
setEnableNextButton(false);
GridCell cell=event.getEditCell();
int rowIndex=cell.getRow();
MapPlaceHolderToColumnRow row=store.get(rowIndex);
RuleColumnPlaceHolderDescriptor descriptor=row.getRuleColumnPlaceHolderDescriptor();
ColumnDataType columnDataType=descriptor.getColumnDataType();
ArrayList<ColumnData> usableColumns=new ArrayList<ColumnData>();
for(ColumnData column:columns){
ColumnDataType cdt=ColumnDataType.getColumnDataTypeFromId(column.getDataTypeName());
if(column.getDataTypeName()!=null && cdt.compareTo(columnDataType)==0){
usableColumns.add(column);
}
}
storeComboColumnData.clear();
storeComboColumnData.commitChanges();
storeComboColumnData.addAll(usableColumns);
storeComboColumnData.commitChanges();
}
});
@ -207,7 +229,7 @@ public class RuleOnTableApplyMapColumnCard extends WizardCard {
public void onCancelEdit(
CancelEditEvent<MapPlaceHolderToColumnRow> event) {
store.rejectChanges();
setEnableNextButton(true);
checkAllFill();
}
@ -221,19 +243,7 @@ public class RuleOnTableApplyMapColumnCard extends WizardCard {
try {
store.commitChanges();
boolean fillAll = true;
for (MapPlaceHolderToColumnRow row : store.getAll()) {
if (row.getColumn() == null) {
fillAll = false;
break;
}
}
if (fillAll) {
setEnableNextButton(true);
} else {
setEnableNextButton(false);
}
checkAllFill();
} catch (Throwable e) {
Log.error("Error in RuleOnTableNewDefinitionCard: "
@ -241,6 +251,8 @@ public class RuleOnTableApplyMapColumnCard extends WizardCard {
e.printStackTrace();
}
}
});
//
@ -249,6 +261,23 @@ public class RuleOnTableApplyMapColumnCard extends WizardCard {
forceLayout();
return;
}
protected void checkAllFill() {
boolean fillAll = true;
for (MapPlaceHolderToColumnRow row : store.getAll()) {
if (row.getColumn() == null) {
fillAll = false;
break;
}
}
if (fillAll) {
setEnableNextButton(true);
} else {
setEnableNextButton(false);
}
}
protected void retrieveColumns() {
TDGWTServiceAsync.INSTANCE.getColumns(applyTableRuleSession.getTrId(),

View File

@ -7,17 +7,12 @@ import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceA
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyTableRuleSession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleColumnPlaceHolderDescriptor;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleScopeType;
import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData;
import org.gcube.portlets.user.td.gwtservice.shared.rule.type.TDRuleTableType;
import org.gcube.portlets.user.td.gwtservice.shared.rule.type.TDRuleType;
import org.gcube.portlets.user.td.rulewidget.client.RuleInfoDialog;
import org.gcube.portlets.user.td.rulewidget.client.resources.ResourceBundle;
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.expression.C_Expression;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
@ -381,9 +376,10 @@ public class RuleOnTableApplySelectRuleCard extends WizardCard {
};
//TODO
//ruleDescriptionData = getSelectedItem();
ArrayList<RuleColumnPlaceHolderDescriptor> ruleColumnPlaceHolderDescriptors=new ArrayList<RuleColumnPlaceHolderDescriptor>();
ruleDescriptionData = getSelectedItem();
//TODO x Test
/*ArrayList<RuleColumnPlaceHolderDescriptor> ruleColumnPlaceHolderDescriptors=new ArrayList<RuleColumnPlaceHolderDescriptor>();
RuleColumnPlaceHolderDescriptor r1=new RuleColumnPlaceHolderDescriptor("Test1", "Test1", ColumnDataType.Text);
RuleColumnPlaceHolderDescriptor r2=new RuleColumnPlaceHolderDescriptor("Test2", "Test2", ColumnDataType.Integer);
ruleColumnPlaceHolderDescriptors.add(r1);
@ -392,7 +388,7 @@ public class RuleOnTableApplySelectRuleCard extends WizardCard {
ruleDescriptionData =new RuleDescriptionData(1, "Test", "Test Description", "2015-01-01 18:45", null, null, RuleScopeType.TABLE, new C_Expression(),
tdRuleType);
*/
if (ruleDescriptionData == null) {
AlertMessageBox d = new AlertMessageBox("Attention",
"Select one rule!");