Minor Updated

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@91799 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-02-17 17:40:04 +00:00
parent 6e9ef3b4ae
commit a38018ff3a
9 changed files with 372 additions and 108 deletions

View File

@ -30,6 +30,7 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/tabular-data-expression-widget-1.0.0-SNAPSHOT/WEB-INF/classes"/>

11
pom.xml
View File

@ -107,6 +107,16 @@
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslcore</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>custom-portal-handler</artifactId>
</dependency>
<!-- tabular-data-gwt-service -->
@ -305,4 +315,5 @@
</dependency>
</dependencies>
</dependencyManagement>
<packaging>war</packaging>
</project>

View File

@ -23,7 +23,7 @@
<!-- Specify the app entry point class. -->
<!-- <entry-point class='org.gcube.portlets.user.td.expressionwidget.client.ExpressionWidgetEntry' /> -->
<entry-point class='org.gcube.portlets.user.td.expressionwidget.client.ExpressionWidgetEntry' />
<!-- Specify the paths for translatable code -->
<source path='client' />

View File

@ -7,14 +7,12 @@ import org.gcube.portlets.user.td.widgetcommonevent.client.type.ExpressionType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_ExpressionContainer;
import com.google.web.bindery.event.shared.EventBus;
import com.allen_sauer.gwt.log.client.Log;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.button.CellButtonBase;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
@ -35,26 +33,42 @@ import com.sencha.gxt.widget.core.client.form.TextField;
*
*/
public class ColumnExpressionPanel extends FramedPanel {
private enum ColumnExpressionPanelType {
ColumnFilter, ColumnRule;
}
protected ColumnExpressionPanelType type;
protected String WIDTH = "640px";
protected String HEIGHT = "520px";
protected EventBus eventBus;
protected ColumnExpressionDialog parent;
protected ColumnExpressionDialog parentRuleDialog;
protected FilterColumnDialog parentFilterDialog;
protected ColumnData column;
protected ConditionWidget conditionWidget;
private TextButton btnApply;
private TextButton btnSearch;
private TextButton btnSave;
private TextButton btnClose;
public ColumnExpressionPanel(FilterColumnDialog parentFilterDialog, ColumnData column) {
type = ColumnExpressionPanelType.ColumnFilter;
this.parentFilterDialog=parentFilterDialog;
}
/**
*
* @param trId
* @param columnName
*/
public ColumnExpressionPanel(ColumnExpressionDialog parent, ColumnData column, EventBus eventBus) {
this.parent=parent;
public ColumnExpressionPanel(ColumnExpressionDialog parent,
ColumnData column, EventBus eventBus) {
type = ColumnExpressionPanelType.ColumnRule;
this.parentRuleDialog = parent;
this.column = column;
this.eventBus=eventBus;
this.eventBus = eventBus;
Log.debug(column.toString());
create();
@ -68,28 +82,30 @@ public class ColumnExpressionPanel extends FramedPanel {
basicLayout.setScrollMode(ScrollMode.AUTO);
basicLayout.setAdjustForScroll(true);
FieldSet properties = new FieldSet();
properties.setHeadingText("Properties");
properties.setCollapsible(false);
FieldSet properties=null;
if (type == ColumnExpressionPanelType.ColumnRule) {
properties = new FieldSet();
properties.setHeadingText("Properties");
properties.setCollapsible(false);
VerticalLayoutContainer propertiesLayout = new VerticalLayoutContainer();
properties.add(propertiesLayout);
VerticalLayoutContainer propertiesLayout = new VerticalLayoutContainer();
properties.add(propertiesLayout);
TextField columnType = new TextField();
columnType.setToolTip("The type of column");
columnType.setReadOnly(true);
columnType.setValue(column.getTypeCode());
propertiesLayout.add(new FieldLabel(columnType, "Column Type"),
new VerticalLayoutData(1, -1));
TextField columnType = new TextField();
columnType.setToolTip("The type of column");
columnType.setReadOnly(true);
columnType.setValue(column.getTypeCode());
propertiesLayout.add(new FieldLabel(columnType, "Column Type"),
new VerticalLayoutData(1, -1));
TextField dataType = new TextField();
dataType.setToolTip("The data type");
dataType.setReadOnly(true);
dataType.setValue(column.getDataTypeName());
propertiesLayout.add(new FieldLabel(dataType, "Data Type"),
new VerticalLayoutData(1, -1));
TextField dataType = new TextField();
dataType.setToolTip("The data type");
dataType.setReadOnly(true);
dataType.setValue(column.getDataTypeName());
propertiesLayout.add(new FieldLabel(dataType, "Data Type"),
new VerticalLayoutData(1, -1));
}
FieldSet conditions = new FieldSet();
conditions.setHeadingText("Conditions");
conditions.setCollapsible(false);
@ -101,7 +117,7 @@ public class ColumnExpressionPanel extends FramedPanel {
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
flowButton.setPack(BoxLayoutPack.CENTER);
TextButton btnApply = new TextButton("Apply");
btnApply = new TextButton("Apply");
btnApply.setIcon(ExpressionResources.INSTANCE.apply());
btnApply.setIconAlign(IconAlign.RIGHT);
btnApply.setTitle("Apply rule");
@ -114,7 +130,7 @@ public class ColumnExpressionPanel extends FramedPanel {
}
});
TextButton btnSearch = new TextButton("Search");
btnSearch = new TextButton("Search");
btnSearch.setIcon(ExpressionResources.INSTANCE.search());
btnSearch.setIconAlign(IconAlign.RIGHT);
btnSearch.setTitle("Search rule");
@ -127,9 +143,7 @@ public class ColumnExpressionPanel extends FramedPanel {
}
});
TextButton btnSave = new TextButton("Save");
btnSave = new TextButton("Save");
btnSave.setIcon(ExpressionResources.INSTANCE.save());
btnSave.setIconAlign(IconAlign.RIGHT);
btnSave.setTitle("Save rule");
@ -142,7 +156,7 @@ public class ColumnExpressionPanel extends FramedPanel {
}
});
CellButtonBase<?> btnClose = new TextButton("Close");
btnClose = new TextButton("Close");
btnClose.setIcon(ExpressionResources.INSTANCE.close());
btnClose.setIconAlign(IconAlign.RIGHT);
btnClose.setTitle("Cancel rule");
@ -160,55 +174,77 @@ public class ColumnExpressionPanel extends FramedPanel {
flowButton.add(btnSearch, new BoxLayoutData(new Margins(2, 4, 2, 4)));
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
basicLayout.add(properties, new VerticalLayoutData(-1, -1, new Margins(
1)));
if (type == ColumnExpressionPanelType.ColumnRule) {
basicLayout.add(properties, new VerticalLayoutData(-1, -1,
new Margins(1)));
}
basicLayout.add(conditions, new VerticalLayoutData(-1, -1, new Margins(
1)));
basicLayout.add(flowButton, new VerticalLayoutData(-1, -1, new Margins(5,2,5,
2)));
basicLayout.add(flowButton, new VerticalLayoutData(-1, -1, new Margins(
5, 2, 5, 2)));
add(basicLayout);
show();
}
protected void applyRule() {
C_Expression exp=conditionWidget.getExpression();
parent.setExpression(exp);
ExpressionEvent expressionEvent= new ExpressionEvent(ExpressionType.CREATECOLUMNEXPRESSION);
C_ExpressionContainer container=new C_ExpressionContainer();
container.setId(C_ExpressionContainer.Contains.C_Expression);
container.setExp(exp);
expressionEvent.setC_ExpressionContainer(container);
expressionEvent.setTrId(column.getTrId());
expressionEvent.setColumnId(column.getColumnId());
expressionEvent.setColumnName(column.getName());
Log.debug(expressionEvent.toString());
parent.hide();
eventBus.fireEvent(expressionEvent);
C_Expression exp = conditionWidget.getExpression();
if (type == ColumnExpressionPanelType.ColumnRule) {
parentRuleDialog.setExpression(exp);
ExpressionEvent expressionEvent = new ExpressionEvent(
ExpressionType.CREATECOLUMNEXPRESSION);
C_ExpressionContainer container = new C_ExpressionContainer();
container.setId(C_ExpressionContainer.Contains.C_Expression);
container.setExp(exp);
expressionEvent.setC_ExpressionContainer(container);
expressionEvent.setTrId(column.getTrId());
expressionEvent.setColumnId(column.getColumnId());
expressionEvent.setColumnName(column.getName());
Log.debug(expressionEvent.toString());
parentRuleDialog.hide();
eventBus.fireEvent(expressionEvent);
} else {
parentFilterDialog.setExpression(exp);
}
}
protected void saveRule() {
//Expression exp=conditionWidget.getExpression();
//parent.setExpression(exp);
}
protected void searchRule(){
protected void searchRule() {
}
protected void close() {
ExpressionEvent expressionEvent= new ExpressionEvent(ExpressionType.EXPRESSIONNULL);
Log.debug(expressionEvent.toString());
parent.hide();
eventBus.fireEvent(expressionEvent);
if (type == ColumnExpressionPanelType.ColumnRule) {
ExpressionEvent expressionEvent = new ExpressionEvent(
ExpressionType.EXPRESSIONNULL);
Log.debug(expressionEvent.toString());
parentRuleDialog.hide();
eventBus.fireEvent(expressionEvent);
} else {
parentFilterDialog.close();
}
}
public TextButton getBtnApply() {
return btnApply;
}
public TextButton getBtnSearch() {
return btnSearch;
}
public TextButton getBtnSave() {
return btnSave;
}
public TextButton getBtnClose() {
return btnClose;
}
}

View File

@ -0,0 +1,124 @@
package org.gcube.portlets.user.td.expressionwidget.client;
import org.gcube.portlets.user.td.expressionwidget.client.resource.ExpressionResources;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
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 org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.widget.core.client.Window;
public class FilterColumnDialog extends Window {
protected String WIDTH = "650px";
protected String HEIGHT = "426px";
protected ColumnExpressionPanel columnExpressionPanel;
protected C_Expression exp = null;
protected ColumnData column = null;
protected TRId trId;
protected String columnName = null;
protected EventBus eventBus;
public FilterColumnDialog(String columnId,
ColumnTypeCode columnTypeCode, ColumnDataType dataTypeName,
EventBus eventBus) {
initWindow();
this.eventBus = eventBus;
column = new ColumnData();
column.setColumnId(columnId);
column.setDataTypeName(dataTypeName.toString());
column.setTypeCode(columnTypeCode.toString());
create();
}
public FilterColumnDialog(TRId trId, String columnName,
EventBus eventBus) {
initWindow();
this.eventBus = eventBus;
this.trId = trId;
this.columnName = columnName;
load(trId, columnName);
}
protected void initWindow(){
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(false);
setHeadingText("New Rule");
setClosable(false);
getHeader().setIcon(ExpressionResources.INSTANCE.rule());
}
protected void create() {
if (column.getTypeCode()
.compareTo(ColumnTypeCode.ANNOTATION.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.ATTRIBUTE.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.CODE.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.CODEDESCRIPTION.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.CODENAME.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.MEASURE.toString()) == 0) {
columnExpressionPanel = new ColumnExpressionPanel(this, column);
add(columnExpressionPanel);
} else {
HTML errorMessage = new HTML(
"This type of column is not supported for now!");
add(errorMessage);
}
}
public C_Expression getExpression() {
return exp;
}
protected void setExpression(C_Expression exp) {
Log.debug("New Expression set:" + exp.toString());
this.exp = exp;
}
protected void close(){
}
protected void load(TRId trId, String columnName) {
TDGWTServiceAsync.INSTANCE.getColumn(trId, columnName,
new AsyncCallback<ColumnData>() {
public void onFailure(Throwable caught) {
Log.error("Error retrieving column: "
+ caught.getMessage());
}
public void onSuccess(ColumnData result) {
Log.debug("Retrived column: " + result);
column = result;
create();
}
});
}
}

View File

@ -6,6 +6,7 @@ package org.gcube.portlets.user.td.expressionwidget.client.rpc;
import org.gcube.portlets.user.td.expressionwidget.shared.expression.ExpressionServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
import com.google.gwt.user.client.rpc.RemoteService;
@ -29,7 +30,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("ExpressionService")
public interface ExpressionService extends RemoteService {
public Void submitExpression(C_Expression expression) throws ExpressionServiceException;
public void submitColumnFilter(ColumnData column, C_Expression expression) throws ExpressionServiceException;

View File

@ -3,6 +3,7 @@
*/
package org.gcube.portlets.user.td.expressionwidget.client.rpc;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
import com.google.gwt.core.client.GWT;
@ -20,6 +21,6 @@ public interface ExpressionServiceAsync {
public static ExpressionServiceAsync INSTANCE = (ExpressionServiceAsync) GWT
.create(ExpressionService.class);
void submitExpression(C_Expression expression,AsyncCallback<Void> callback);
void submitColumnFilter(ColumnData column, C_Expression expression,AsyncCallback<Void> callback);
}

View File

@ -0,0 +1,90 @@
package org.gcube.portlets.user.td.expressionwidget.server;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionService;
import org.gcube.portlets.user.td.expressionwidget.shared.expression.ExpressionServiceException;
import org.gcube.portlets.user.td.gwtservice.server.SessionUtil;
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationsId;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
public class ExpressionServiceImpl extends RemoteServiceServlet implements
ExpressionService {
private static final long serialVersionUID = -5707400086333186368L;
protected static Logger logger = LoggerFactory
.getLogger(ExpressionServiceImpl.class);
protected static SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy/MM/dd HH:mm");
/**
*
* {@inheritDoc}
*/
@Override
public void submitColumnFilter(ColumnData column, C_Expression expression)
throws ExpressionServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
List<OperationDefinition> capabilities = service.getCapabilities();
OperationDefinition importSDMXCodelistOperation = OperationDefinitionMap.map(
OperationsId.FilterByExpression.toString(), capabilities);
Map<String, Object> parameterInstance=null;// = retrieveOperationParameters(sdmxImportSession);
OperationExecution invocation = new OperationExecution(
importSDMXCodelistOperation.getOperationId(),
parameterInstance);
logger.debug("OperationInvocation: \n" + invocation.toString());
//Task trTask = service.execute(invocation, serviceTR.getId());
//logger.debug("Start Task on service: TaskId " + trTask.getId());
//SessionUtil.setSDMXImportTask(session, trTask);
return;
} catch (Exception e) {
e.printStackTrace();
throw new ExpressionServiceException("Error in Client Library Request: "
+ e.getLocalizedMessage());
}
}
}

View File

@ -23,7 +23,7 @@
<!-- Specify the app entry point class. -->
<!-- <entry-point class='org.gcube.portlets.user.td.expressionwidget.client.ExpressionWidgetEntry' /> -->
<entry-point class='org.gcube.portlets.user.td.expressionwidget.client.ExpressionWidgetEntry' />
<!-- Specify the paths for translatable code -->
<source path='client' />