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"/>

51
pom.xml
View File

@ -14,15 +14,15 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-expression-widget</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>tabular-data-expression-widget</name>
<description>tabular-data-expression-widget allows to create expression on tabular resource</description>
<scm>
<url>https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget</url>
</scm>
<developers>
<developer>
<name>Giancarlo Panichi</name>
@ -34,7 +34,7 @@
</roles>
</developer>
</developers>
<properties>
<distroDirectory>${project.basedir}/distro</distroDirectory>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
@ -42,7 +42,7 @@
<templatesDirectory>templates</templatesDirectory>
<distroDirectory>distro</distroDirectory>
<configDirectory>config</configDirectory>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.5.1</gwtVersion>
<!-- To make this work on gwt-run you need to set up global env vars. on
@ -53,9 +53,9 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<profiles>
<profile>
<id>localRun</id>
@ -74,8 +74,8 @@
</dependencies>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
@ -85,8 +85,8 @@
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
@ -107,8 +107,18 @@
<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 -->
<dependency>
<groupId>org.gcube.portlets.user</groupId>
@ -137,7 +147,7 @@
<artifactId>slf4j-api</artifactId>
<!-- <scope>compile</scope> -->
</dependency>
<!-- JUNIT -->
<dependency>
<groupId>junit</groupId>
@ -145,8 +155,8 @@
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
@ -163,8 +173,8 @@
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -182,7 +192,7 @@
</dependency>
</dependencies>
</plugin>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
@ -201,7 +211,7 @@
<module>org.gcube.portlets.user.td.expressionwidget.ExpressionWidget</module>
</configuration>
</plugin>
<!-- Maven -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
@ -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,61 +33,79 @@ 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();
}
protected void create() {
setBodyBorder(false);
setHeaderVisible(false);
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
basicLayout.setScrollMode(ScrollMode.AUTO);
basicLayout.setAdjustForScroll(true);
FieldSet properties = new FieldSet();
properties.setHeadingText("Properties");
properties.setCollapsible(false);
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));
FieldSet properties=null;
if (type == ColumnExpressionPanelType.ColumnRule) {
properties = new FieldSet();
properties.setHeadingText("Properties");
properties.setCollapsible(false);
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));
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 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,114 +117,134 @@ 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");
btnApply.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
Log.debug("Pressed Apply");
applyRule();
}
});
TextButton btnSearch = new TextButton("Search");
btnSearch = new TextButton("Search");
btnSearch.setIcon(ExpressionResources.INSTANCE.search());
btnSearch.setIconAlign(IconAlign.RIGHT);
btnSearch.setTitle("Search rule");
btnSearch.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
Log.debug("Pressed Search");
searchRule();
}
});
TextButton btnSave = new TextButton("Save");
btnSave = new TextButton("Save");
btnSave.setIcon(ExpressionResources.INSTANCE.save());
btnSave.setIconAlign(IconAlign.RIGHT);
btnSave.setTitle("Save rule");
btnSave.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
Log.debug("Pressed Save");
saveRule();
}
});
CellButtonBase<?> btnClose = new TextButton("Close");
btnClose = new TextButton("Close");
btnClose.setIcon(ExpressionResources.INSTANCE.close());
btnClose.setIconAlign(IconAlign.RIGHT);
btnClose.setTitle("Cancel rule");
btnClose.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
Log.debug("Pressed Close");
close();
}
});
flowButton.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4)));
flowButton.add(btnSave, new BoxLayoutData(new Margins(2, 4, 2, 4)));
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' />