Updated Rule
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@114026 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
96443d5629
commit
b4e626cfc4
|
@ -14,6 +14,8 @@ import org.gcube.portlets.user.td.expressionwidget.client.store.ColumnTypeCodeSt
|
|||
import org.gcube.portlets.user.td.expressionwidget.client.store.LocaleTypeElement;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ConditionTypeMapException;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.logical.C_Not;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
|
||||
|
@ -36,8 +38,6 @@ import com.google.gwt.core.client.Scheduler;
|
|||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
@ -69,6 +69,8 @@ import com.sencha.gxt.widget.core.client.info.Info;
|
|||
*
|
||||
*/
|
||||
public class ColumnExpressionPanel extends FramedPanel {
|
||||
private static final String RULE_PLACE_HOLDER_ID = "RulePlaceHolderId";
|
||||
|
||||
private enum ColumnExpressionPanelType {
|
||||
MultiColumnFilter, ColumnFilter, RowDeleteByExpression, Template, Rule;
|
||||
}
|
||||
|
@ -98,7 +100,9 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
private ComboBox<ColumnData> comboCols;
|
||||
private RuleDialog parentRuleDialog;
|
||||
|
||||
private TextField columnTag;
|
||||
private TextField ruleName;
|
||||
private TextField ruleDescription;
|
||||
|
||||
private ComboBox<ColumnTypeCodeElement> comboColumnTypeCode;
|
||||
private ComboBox<ColumnDataTypeElement> comboMeasureType;
|
||||
private ComboBox<ColumnDataTypeElement> comboAttributeType;
|
||||
|
@ -108,7 +112,6 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
private FieldLabel comboLocaleTypeLabel;
|
||||
private FieldLabel comboAttributeTypeLabel;
|
||||
private FieldLabel comboMeasureTypeLabel;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -291,20 +294,14 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
|
||||
// TODO
|
||||
private void createColumnMockUp(VerticalLayoutContainer propertiesLayout) {
|
||||
columnTag = new TextField();
|
||||
columnTag.setToolTip("Column Label");
|
||||
columnTag.addValueChangeHandler(new ValueChangeHandler<String>() {
|
||||
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<String> event) {
|
||||
updateColumnTag(event.getValue());
|
||||
|
||||
}
|
||||
ruleName = new TextField();
|
||||
ruleName.setToolTip("Rule Name");
|
||||
FieldLabel ruleNameLabel = new FieldLabel(ruleName, "Rule Name");
|
||||
|
||||
|
||||
});
|
||||
|
||||
FieldLabel columnLabel = new FieldLabel(columnTag, "Column Label");
|
||||
ruleDescription = new TextField();
|
||||
ruleDescription.setToolTip("Rule Description");
|
||||
FieldLabel ruleDescriptionLabel = new FieldLabel(ruleDescription,
|
||||
"Rule Description");
|
||||
|
||||
// combo TypeCode
|
||||
ColumnTypeCodeProperties propsColumnTypeCode = GWT
|
||||
|
@ -324,9 +321,10 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
comboColumnTypeCode.setWidth(191);
|
||||
comboColumnTypeCode.setTypeAhead(true);
|
||||
comboColumnTypeCode.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
comboColumnTypeCodeLabel=new FieldLabel(comboColumnTypeCode, "Column Type");
|
||||
|
||||
|
||||
comboColumnTypeCodeLabel = new FieldLabel(comboColumnTypeCode,
|
||||
"Column Type");
|
||||
|
||||
// comboMeasureType
|
||||
ColumnDataTypeProperties propsMeasureType = GWT
|
||||
.create(ColumnDataTypeProperties.class);
|
||||
|
@ -397,11 +395,12 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
|
||||
comboLocaleTypeLabel = new FieldLabel(comboLocaleType, "Locale");
|
||||
|
||||
propertiesLayout.add(columnLabel, new VerticalLayoutData(1, -1,
|
||||
propertiesLayout.add(ruleNameLabel, new VerticalLayoutData(1, -1,
|
||||
new Margins(0)));
|
||||
propertiesLayout.add(
|
||||
comboColumnTypeCodeLabel,
|
||||
new VerticalLayoutData(1, -1, new Margins(0)));
|
||||
propertiesLayout.add(ruleDescriptionLabel, new VerticalLayoutData(1,
|
||||
-1, new Margins(0)));
|
||||
propertiesLayout.add(comboColumnTypeCodeLabel, new VerticalLayoutData(
|
||||
1, -1, new Margins(0)));
|
||||
propertiesLayout.add(comboLocaleTypeLabel, new VerticalLayoutData(1,
|
||||
-1, new Margins(0)));
|
||||
propertiesLayout.add(comboMeasureTypeLabel, new VerticalLayoutData(1,
|
||||
|
@ -409,7 +408,6 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
propertiesLayout.add(comboAttributeTypeLabel, new VerticalLayoutData(1,
|
||||
-1, new Margins(0)));
|
||||
|
||||
comboColumnTypeCodeLabel.setVisible(false);
|
||||
comboMeasureTypeLabel.setVisible(false);
|
||||
comboAttributeTypeLabel.setVisible(false);
|
||||
comboLocaleTypeLabel.setVisible(false);
|
||||
|
@ -506,31 +504,6 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
|
||||
});
|
||||
}
|
||||
|
||||
protected void updateColumnTag(String value) {
|
||||
if(value==null|| value.isEmpty()){
|
||||
comboColumnTypeCodeLabel.setVisible(false);
|
||||
comboMeasureTypeLabel.setVisible(false);
|
||||
comboAttributeTypeLabel.setVisible(false);
|
||||
comboLocaleTypeLabel.setVisible(false);
|
||||
|
||||
} else {
|
||||
comboColumnTypeCodeLabel.setVisible(true);
|
||||
comboMeasureTypeLabel.setVisible(false);
|
||||
comboAttributeTypeLabel.setVisible(false);
|
||||
comboLocaleTypeLabel.setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
comboColumnTypeCode.reset();
|
||||
comboMeasureType.reset();
|
||||
comboAttributeType.reset();
|
||||
comboLocaleType.reset();
|
||||
updateCondition();
|
||||
forceLayout();
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void updateColumnType(ColumnTypeCode type) {
|
||||
Log.debug("Update ColumnTypeCode " + type.toString());
|
||||
|
@ -558,7 +531,7 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
comboAttributeTypeLabel.setVisible(false);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
updateCondition();
|
||||
forceLayout();
|
||||
}
|
||||
|
@ -582,88 +555,197 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
protected ColumnMockUp retrieveColumnMockUp() {
|
||||
ColumnMockUp columnMockUp = null;
|
||||
|
||||
String labelS = columnTag.getCurrentValue();
|
||||
|
||||
if (labelS != null && !labelS.isEmpty()) {
|
||||
ColumnTypeCodeElement columnTypeCodeElement = comboColumnTypeCode
|
||||
.getCurrentValue();
|
||||
if (columnTypeCodeElement != null) {
|
||||
ColumnTypeCode type = columnTypeCodeElement.getCode();
|
||||
ColumnDataTypeElement columnDataTypeElement;
|
||||
switch (type) {
|
||||
case MEASURE:
|
||||
columnDataTypeElement = comboMeasureType.getCurrentValue();
|
||||
if (columnDataTypeElement != null) {
|
||||
ColumnDataType dataType = columnDataTypeElement
|
||||
.getType();
|
||||
if (dataType != null) {
|
||||
columnMockUp = new ColumnMockUp(null, labelS,
|
||||
labelS, type, dataType, "");
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
ColumnTypeCodeElement columnTypeCodeElement = comboColumnTypeCode
|
||||
.getCurrentValue();
|
||||
if (columnTypeCodeElement != null) {
|
||||
ColumnTypeCode type = columnTypeCodeElement.getCode();
|
||||
ColumnDataTypeElement columnDataTypeElement;
|
||||
switch (type) {
|
||||
case MEASURE:
|
||||
columnDataTypeElement = comboMeasureType.getCurrentValue();
|
||||
if (columnDataTypeElement != null) {
|
||||
ColumnDataType dataType = columnDataTypeElement.getType();
|
||||
if (dataType != null) {
|
||||
columnMockUp = new ColumnMockUp(null,
|
||||
RULE_PLACE_HOLDER_ID, RULE_PLACE_HOLDER_ID,
|
||||
type, dataType, "");
|
||||
} else {
|
||||
|
||||
}
|
||||
break;
|
||||
case ATTRIBUTE:
|
||||
columnDataTypeElement = comboAttributeType
|
||||
.getCurrentValue();
|
||||
if (columnDataTypeElement != null) {
|
||||
ColumnDataType dataType = columnDataTypeElement
|
||||
.getType();
|
||||
if (dataType != null) {
|
||||
columnMockUp = new ColumnMockUp(null, labelS,
|
||||
labelS, type, dataType, "");
|
||||
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
break;
|
||||
case CODE:
|
||||
case CODEDESCRIPTION:
|
||||
case ANNOTATION:
|
||||
columnMockUp = new ColumnMockUp(null, labelS, labelS, type,
|
||||
"");
|
||||
break;
|
||||
|
||||
case CODENAME:
|
||||
LocaleTypeElement locale = comboLocaleType
|
||||
.getCurrentValue();
|
||||
if (locale != null) {
|
||||
columnMockUp = new ColumnMockUp(null, labelS, labelS,
|
||||
type, locale.getLocaleName(), "");
|
||||
} else {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
break;
|
||||
case ATTRIBUTE:
|
||||
columnDataTypeElement = comboAttributeType.getCurrentValue();
|
||||
if (columnDataTypeElement != null) {
|
||||
ColumnDataType dataType = columnDataTypeElement.getType();
|
||||
if (dataType != null) {
|
||||
columnMockUp = new ColumnMockUp(null,
|
||||
RULE_PLACE_HOLDER_ID, RULE_PLACE_HOLDER_ID,
|
||||
type, dataType, "");
|
||||
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
break;
|
||||
case CODE:
|
||||
case CODEDESCRIPTION:
|
||||
case ANNOTATION:
|
||||
columnMockUp = new ColumnMockUp(null, RULE_PLACE_HOLDER_ID,
|
||||
RULE_PLACE_HOLDER_ID, type, "");
|
||||
break;
|
||||
|
||||
case CODENAME:
|
||||
LocaleTypeElement locale = comboLocaleType.getCurrentValue();
|
||||
if (locale != null) {
|
||||
columnMockUp = new ColumnMockUp(null, RULE_PLACE_HOLDER_ID,
|
||||
RULE_PLACE_HOLDER_ID, type, locale.getLocaleName(),
|
||||
"");
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
}
|
||||
return columnMockUp;
|
||||
|
||||
}
|
||||
|
||||
protected ColumnMockUp checkEnterData() {
|
||||
ColumnMockUp columnMockUp = null;
|
||||
|
||||
String ruleNameS = ruleName.getCurrentValue();
|
||||
|
||||
if (ruleNameS != null && !ruleNameS.isEmpty()) {
|
||||
|
||||
String ruleDescriptionS = ruleDescription.getCurrentValue();
|
||||
|
||||
if (ruleDescriptionS != null && !ruleDescriptionS.isEmpty()) {
|
||||
ColumnTypeCodeElement columnTypeCodeElement = comboColumnTypeCode
|
||||
.getCurrentValue();
|
||||
if (columnTypeCodeElement != null) {
|
||||
ColumnTypeCode type = columnTypeCodeElement.getCode();
|
||||
ColumnDataTypeElement columnDataTypeElement;
|
||||
switch (type) {
|
||||
case MEASURE:
|
||||
columnDataTypeElement = comboMeasureType
|
||||
.getCurrentValue();
|
||||
if (columnDataTypeElement != null) {
|
||||
ColumnDataType dataType = columnDataTypeElement
|
||||
.getType();
|
||||
if (dataType != null) {
|
||||
columnMockUp = new ColumnMockUp(null,
|
||||
RULE_PLACE_HOLDER_ID,
|
||||
RULE_PLACE_HOLDER_ID, type, dataType,
|
||||
"");
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Column data type not selected!");
|
||||
}
|
||||
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Column data type not selected!");
|
||||
}
|
||||
break;
|
||||
case ATTRIBUTE:
|
||||
columnDataTypeElement = comboAttributeType
|
||||
.getCurrentValue();
|
||||
if (columnDataTypeElement != null) {
|
||||
ColumnDataType dataType = columnDataTypeElement
|
||||
.getType();
|
||||
if (dataType != null) {
|
||||
columnMockUp = new ColumnMockUp(null,
|
||||
RULE_PLACE_HOLDER_ID,
|
||||
RULE_PLACE_HOLDER_ID, type, dataType,
|
||||
"");
|
||||
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Column data type not selected!");
|
||||
}
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Column data type not selected!");
|
||||
}
|
||||
break;
|
||||
case CODE:
|
||||
case CODEDESCRIPTION:
|
||||
case ANNOTATION:
|
||||
columnMockUp = new ColumnMockUp(null,
|
||||
RULE_PLACE_HOLDER_ID, RULE_PLACE_HOLDER_ID,
|
||||
type, "");
|
||||
break;
|
||||
|
||||
case CODENAME:
|
||||
LocaleTypeElement locale = comboLocaleType
|
||||
.getCurrentValue();
|
||||
if (locale != null) {
|
||||
columnMockUp = new ColumnMockUp(null,
|
||||
RULE_PLACE_HOLDER_ID, RULE_PLACE_HOLDER_ID,
|
||||
type, locale.getLocaleName(), "");
|
||||
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention", "No locale selected!");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
UtilsGXT3.alert("Attention",
|
||||
"This column type is not supported now!");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention", "Select a column type!");
|
||||
}
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Enter a valid description for the rule!");
|
||||
}
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention", "Enter a valid name for the rule!");
|
||||
}
|
||||
return columnMockUp;
|
||||
|
||||
}
|
||||
|
||||
protected RuleDescriptionData retrieveRuleDescriptionData(C_Expression exp) {
|
||||
ColumnMockUp columnMockUp = checkEnterData();
|
||||
if (columnMockUp != null) {
|
||||
if(exp!=null){
|
||||
|
||||
String ruleNameS = ruleName.getCurrentValue();
|
||||
String ruleDescriptionS = ruleDescription.getCurrentValue();
|
||||
RuleDescriptionData ruleDescriptionData = new RuleDescriptionData(
|
||||
0, ruleNameS, ruleDescriptionS, RuleScopeType.COLUMN, exp);
|
||||
return ruleDescriptionData;
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention", "Enter a valid condition!");
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateMeasureType(ColumnDataType type) {
|
||||
Log.debug("Update ColumnTypeCode " + type);
|
||||
updateCondition();
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void updateAttributeType(ColumnDataType type) {
|
||||
Log.debug("Update ColumnTypeCode " + type);
|
||||
updateCondition();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -1164,25 +1246,15 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
parentTemplateDialog.hide();
|
||||
eventBus.fireEvent(expressionEvent);
|
||||
break;
|
||||
case Rule:
|
||||
RuleDescriptionData ruleDescriptionData = retrieveRuleDescriptionData(exp);
|
||||
if (ruleDescriptionData != null) {
|
||||
parentRuleDialog.addRule(ruleDescriptionData);
|
||||
}
|
||||
break;
|
||||
case ColumnFilter:
|
||||
parentFilterDialog.applyFilter(column, exp);
|
||||
break;
|
||||
|
||||
case Rule:
|
||||
ColumnMockUp columnMockUp = new ColumnMockUp();
|
||||
column = new ColumnData();
|
||||
column.setColumnId(columnMockUp.getColumnId());
|
||||
column.setLabel(columnMockUp.getLabel());
|
||||
column.setDataTypeName(columnMockUp.getColumnDataType().toString());
|
||||
column.setTypeCode(columnMockUp.getColumnType().toString());
|
||||
condContainer = new C_ExpressionContainer();
|
||||
condContainer.setId(C_ExpressionContainer.Contains.C_Expression);
|
||||
condContainer.setExp(exp);
|
||||
condContainer.setReadableExpression(conditionWidget
|
||||
.getReadableExpression());
|
||||
exWrapper = new ExpressionWrapper(null, column, condContainer);
|
||||
parentRuleDialog.addRule(exWrapper);
|
||||
break;
|
||||
case RowDeleteByExpression:
|
||||
C_Expression notExp = new C_Not(exp);
|
||||
parentRowsDeleteByExpressionDialog.deleteRowsByExpression(column,
|
||||
|
@ -1208,12 +1280,15 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
parentTemplateDialog.hide();
|
||||
eventBus.fireEvent(expressionEvent);
|
||||
break;
|
||||
case Rule:
|
||||
parentRuleDialog.close();
|
||||
case ColumnFilter:
|
||||
parentFilterDialog.close();
|
||||
break;
|
||||
case RowDeleteByExpression:
|
||||
parentRowsDeleteByExpressionDialog.close();
|
||||
break;
|
||||
|
||||
case MultiColumnFilter:
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.portlets.user.td.expressionwidget.client;
|
|||
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.expression.ExpressionWrapper;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
@ -87,8 +87,8 @@ public class RuleDialog extends Window {
|
|||
}
|
||||
|
||||
|
||||
public void addRule(ExpressionWrapper exWrapper) {
|
||||
Log.debug("ExpressionWrapper: "+exWrapper);
|
||||
public void addRule(RuleDescriptionData ruleDescriptionData) {
|
||||
Log.debug("RuleDescriptionData: "+ruleDescriptionData);
|
||||
close();
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.td.expressionwidget.client.rpc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
|
||||
|
@ -44,5 +48,10 @@ public interface ExpressionService extends RemoteService {
|
|||
|
||||
public String startAddColumn(AddColumnSession addColumnSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
public ArrayList<RuleDescriptionData> getRules()
|
||||
throws TDGWTServiceException;
|
||||
|
||||
public ArrayList<RuleDescriptionData> getRules(RuleScopeType scope)
|
||||
throws TDGWTServiceException;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.td.expressionwidget.client.rpc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnByExpressionSession;
|
||||
|
@ -32,4 +36,9 @@ public interface ExpressionServiceAsync {
|
|||
void startAddColumn(AddColumnSession addColumnSession,
|
||||
AsyncCallback<String> callback);
|
||||
|
||||
void getRules(AsyncCallback<ArrayList<RuleDescriptionData>> callback);
|
||||
|
||||
void getRules(RuleScopeType scope,
|
||||
AsyncCallback<ArrayList<RuleDescriptionData>> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -213,54 +213,110 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
public ArrayList<RuleDescriptionData> getRule(RuleScopeType scope) throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<RuleDescriptionData> getRules(RuleScopeType scope)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
logger.debug("GetRule()");
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
service.getRules();
|
||||
|
||||
List<RuleDescription> rules=service.getRulesByScope(RuleScopeMap.map(scope));
|
||||
|
||||
ArrayList<RuleDescriptionData> rulesDes=new ArrayList<RuleDescriptionData>();
|
||||
|
||||
C_ExpressionParser parser = new C_ExpressionParser();
|
||||
|
||||
for(RuleDescription ruleDescription: rules){
|
||||
Expression serviceExpression=ruleDescription.getRule();
|
||||
C_Expression cexp=parser.parse(serviceExpression);
|
||||
RuleDescriptionData ruleData=new RuleDescriptionData(ruleDescription.getId(),
|
||||
ruleDescription.getName(), ruleDescription.getDescription(),
|
||||
RuleScopeMap.map(ruleDescription.getScope()),
|
||||
cexp);
|
||||
rulesDes.add(ruleData);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return rulesDes;
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(e.getLocalizedMessage(),e);
|
||||
throw e;
|
||||
} catch (SecurityException e) {
|
||||
logger.error(e.getLocalizedMessage(),e);
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error(
|
||||
"Error in getRule(): " + e.getLocalizedMessage(),
|
||||
e);
|
||||
throw new TDGWTServiceException("Error retrieving the rules: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
logger.debug("GetRule()");
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
List<RuleDescription> rules = service.getRulesByScope(RuleScopeMap
|
||||
.map(scope));
|
||||
|
||||
ArrayList<RuleDescriptionData> rulesDes = new ArrayList<RuleDescriptionData>();
|
||||
|
||||
C_ExpressionParser parser = new C_ExpressionParser();
|
||||
|
||||
for (RuleDescription ruleDescription : rules) {
|
||||
Expression serviceExpression = ruleDescription.getRule();
|
||||
C_Expression cexp = parser.parse(serviceExpression);
|
||||
RuleDescriptionData ruleData = new RuleDescriptionData(
|
||||
ruleDescription.getId(), ruleDescription.getName(),
|
||||
ruleDescription.getDescription(),
|
||||
RuleScopeMap.map(ruleDescription.getScope()), cexp);
|
||||
rulesDes.add(ruleData);
|
||||
|
||||
}
|
||||
|
||||
return rulesDes;
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
throw e;
|
||||
} catch (SecurityException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error in getRule(): " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error retrieving the rules: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<RuleDescriptionData> getRules()
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
logger.debug("GetRule()");
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
List<RuleDescription> rules = service.getRules();
|
||||
|
||||
ArrayList<RuleDescriptionData> rulesDes = new ArrayList<RuleDescriptionData>();
|
||||
|
||||
C_ExpressionParser parser = new C_ExpressionParser();
|
||||
|
||||
for (RuleDescription ruleDescription : rules) {
|
||||
Expression serviceExpression = ruleDescription.getRule();
|
||||
C_Expression cexp = parser.parse(serviceExpression);
|
||||
RuleDescriptionData ruleData = new RuleDescriptionData(
|
||||
ruleDescription.getId(), ruleDescription.getName(),
|
||||
ruleDescription.getDescription(),
|
||||
RuleScopeMap.map(ruleDescription.getScope()), cexp);
|
||||
rulesDes.add(ruleData);
|
||||
|
||||
}
|
||||
|
||||
return rulesDes;
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
throw e;
|
||||
} catch (SecurityException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error in getRule(): " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error retrieving the rules: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -72,6 +72,15 @@ public class RuleDescriptionData implements Serializable {
|
|||
public void setExpression(C_Expression expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public String getReadableExpression(){
|
||||
if(expression!=null){
|
||||
return expression.getReadableExpression();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.shared.rule;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.google.gwt.editor.client.Editor.Path;
|
||||
import com.sencha.gxt.core.client.ValueProvider;
|
||||
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||
import com.sencha.gxt.data.shared.PropertyAccess;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface RuleDescriptionDataProperties extends PropertyAccess<RuleDescriptionData> {
|
||||
|
||||
@Path("id")
|
||||
ModelKeyProvider<RuleDescriptionData> id();
|
||||
|
||||
ValueProvider<RuleDescriptionData, String> name();
|
||||
ValueProvider<RuleDescriptionData, String> description();
|
||||
ValueProvider<RuleDescriptionData, String> readableExpression();
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue