Change Component Name on SVN
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@83962 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
commit
4c4beffdf1
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="com.google.gwt.eclipse.core.launch.gwtJUnit">
|
||||
<stringAttribute key="com.google.gwt.eclipse.core.LOG_LEVEL" value="INFO"/>
|
||||
<booleanAttribute key="com.google.gwt.eclipse.core.NOT_HEADLESS" value="false"/>
|
||||
<stringAttribute key="com.google.gwt.eclipse.core.OUT_DIR" value="www-test"/>
|
||||
<booleanAttribute key="com.google.gwt.eclipse.core.STANDARDS_MODE" value="false"/>
|
||||
<stringAttribute key="com.google.gwt.eclipse.core.STYLE" value="OBFUSCATED"/>
|
||||
<stringAttribute key="com.google.gwt.eclipse.core.WEB_MODE" value="false"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/tabular-data-gxtservice/src/test/java/org/gcube/portlets/user/td/gxtservice/client/GwtTestGXTService.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.gcube.portlets.user.td.gxtservice.client.GwtTestGXTService"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="tabular-data-gxtservice"/>
|
||||
</launchConfiguration>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="com.google.gwt.eclipse.core.launch.gwtJUnit">
|
||||
<stringAttribute key="com.google.gwt.eclipse.core.LOG_LEVEL" value="INFO"/>
|
||||
<booleanAttribute key="com.google.gwt.eclipse.core.NOT_HEADLESS" value="false"/>
|
||||
<stringAttribute key="com.google.gwt.eclipse.core.OUT_DIR" value="www-test"/>
|
||||
<booleanAttribute key="com.google.gwt.eclipse.core.STANDARDS_MODE" value="false"/>
|
||||
<stringAttribute key="com.google.gwt.eclipse.core.STYLE" value="OBFUSCATED"/>
|
||||
<stringAttribute key="com.google.gwt.eclipse.core.WEB_MODE" value="true"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/tabular-data-information/src/test/java/org/gcube/portlets/user/td/gxtservice/client/GwtTestGXTService.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.gcube.portlets.user.td.information.client.GwtTestGXTService"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="tabular-data-gxtservice"/>
|
||||
</launchConfiguration>
|
|
@ -0,0 +1,354 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<version>1.0.0</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
|
||||
<!-- POM file generated with GWT webAppCreator -->
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>tabular-data-gwt-service</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<name>tabular-data-gwt-service</name>
|
||||
<description>tabular-data-gwt-service allows communication between the GUI and services</description>
|
||||
|
||||
<scm>
|
||||
<url>https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gxtservice</url>
|
||||
</scm>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Giancarlo Panichi</name>
|
||||
<email>g.panichi@isti.cnr.it</email>
|
||||
<organization>CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"</organization>
|
||||
<roles>
|
||||
<role>architect</role>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<properties>
|
||||
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
||||
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
||||
<release.date>2013-10-18</release.date>
|
||||
<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
|
||||
MacOSX edit this file /etc/launchd.conf and put "setenv GLOBUS_LOCATION /Users/massi/portal/Portal-Bundle/gCore"
|
||||
on Linux? -->
|
||||
<GLOBUS_LOCATION>${env.GLOBUS_LOCATION}</GLOBUS_LOCATION>
|
||||
<!-- GWT needs at least java 1.5 -->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>localRun</id>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-servlet</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-user</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>1.0.0.GA</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>1.0.0.GA</version>
|
||||
<classifier>sources</classifier>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sencha.gxt</groupId>
|
||||
<artifactId>gxt</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.data.publishing</groupId>
|
||||
<artifactId>sdmx-registry-client-gcube</artifactId>
|
||||
<version>[3.0.0-SNAPSHOT,4.0.0-SNAPSHOT)</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>
|
||||
|
||||
|
||||
<!-- Apache Common Library -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.googlecode.juniversalchardet</groupId>
|
||||
<artifactId>juniversalchardet</artifactId>
|
||||
<version>1.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- csv4j -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>csv4j</artifactId>
|
||||
<version>[1.2.0-SNAPSHOT, 2.0.0-common)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Service Client -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.data.analysis.tabulardata</groupId>
|
||||
<artifactId>service-client-mock</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Home Library
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-jcr</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
<!-- Storage for CSV temp -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-core</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-wrapper</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- LOGGING -->
|
||||
<dependency>
|
||||
<groupId>com.allen-sauer.gwt.log</groupId>
|
||||
<artifactId>gwt-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- JUnit TEST -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
<build>
|
||||
<!-- Generate compiled stuff in the folder used for developing mode -->
|
||||
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.16</version>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
<!-- TODO check if needed -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.surefire</groupId>
|
||||
<artifactId>surefire-junit47</artifactId>
|
||||
<version>2.16</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
|
||||
<!-- GWT Maven Plugin -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>gwt-maven-plugin</artifactId>
|
||||
<version>${gwtVersion}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>resources</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<runTarget>GXTService.html</runTarget>
|
||||
<hostedWebapp>${webappDirectory}</hostedWebapp>
|
||||
<module>org.gcube.portlets.user.td.gxtservice.GXTService</module>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Maven -->
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-profile</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${configDirectory}</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${templatesDirectory}</directory>
|
||||
<includes>
|
||||
<include>profile.xml</include>
|
||||
</includes>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-distro-resources</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${distroDirectory}</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${templatesDirectory}</directory>
|
||||
<excludes>
|
||||
<exclude>profile.xml</exclude>
|
||||
<exclude>descriptor.xml</exclude>
|
||||
</excludes>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
<configuration>
|
||||
<filesets>
|
||||
<fileset>
|
||||
<directory>${distroDirectory}</directory>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
<fileset>
|
||||
<directory>${configDirectory}</directory>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
</filesets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>${templatesDirectory}/descriptor.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>servicearchive</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>maven-portal-bom</artifactId>
|
||||
<version>LATEST</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.client;
|
||||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
|
||||
public class GXTServiceEntry implements EntryPoint {
|
||||
|
||||
@Override
|
||||
public void onModuleLoad() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.client.rpc;
|
||||
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Agencies;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Codelist;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Dataset;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.AvailableCharsetList;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportMonitor;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportSession;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVRowError;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadMonitor;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.file.HeaderPresence;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.sdmx.SDMXImportMonitor;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.sdmx.SDMXImportSession;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TDGXTServiceException;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TDOpenSession;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TabResource;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
@RemoteServiceRelativePath("TDGXTService")
|
||||
public interface TDGXTService extends RemoteService {
|
||||
|
||||
public TabResource getTabResource() throws TDGXTServiceException;
|
||||
|
||||
public void setTabResource(TabResource tr) throws TDGXTServiceException;
|
||||
|
||||
public List<TabResource> getTabularResources() throws TDGXTServiceException;
|
||||
|
||||
public TabResource createTabularResource(TabResource tabResource) throws TDGXTServiceException;
|
||||
|
||||
//Open
|
||||
public void setTDOpenSession(TDOpenSession s) throws TDGXTServiceException;
|
||||
|
||||
//Import SDMX
|
||||
public ArrayList<Codelist> getCodelists() throws TDGXTServiceException;
|
||||
|
||||
public ArrayList<Dataset> getDatasets() throws TDGXTServiceException;
|
||||
|
||||
public ArrayList<Agencies> getAgencies() throws TDGXTServiceException;
|
||||
|
||||
public void setSDMXSession(SDMXImportSession s) throws TDGXTServiceException;
|
||||
|
||||
public SDMXImportMonitor getSDMXImportMonitor() throws TDGXTServiceException;
|
||||
|
||||
public void importSDMXClientLibraryRequest(SDMXImportSession s) throws TDGXTServiceException;
|
||||
|
||||
//Import CSV
|
||||
public FileUploadMonitor getFileUploadMonitor() throws TDGXTServiceException;
|
||||
|
||||
public CSVImportMonitor getCSVImportMonitor() throws TDGXTServiceException;
|
||||
|
||||
public void setCSVSession(CSVImportSession s) throws TDGXTServiceException;
|
||||
|
||||
|
||||
public AvailableCharsetList getAvailableCharset() throws TDGXTServiceException;
|
||||
|
||||
public ArrayList<String> configureCSVParser(String encoding, HeaderPresence headerPresence, char delimiter, char comment) throws TDGXTServiceException;
|
||||
|
||||
public ArrayList<CSVRowError> checkCSV(long errorsLimit) throws TDGXTServiceException;
|
||||
|
||||
public void startCSVImport(boolean[] columnToImportMask) throws TDGXTServiceException;
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.client.rpc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Agencies;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Codelist;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Dataset;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TDOpenSession;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TabResource;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.AvailableCharsetList;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportMonitor;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportSession;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVRowError;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadMonitor;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.file.HeaderPresence;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.sdmx.SDMXImportMonitor;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.sdmx.SDMXImportSession;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
|
||||
public interface TDGXTServiceAsync {
|
||||
|
||||
public TDGXTServiceAsync INSTANCE = GWT
|
||||
.create(TDGXTService.class);
|
||||
|
||||
void createTabularResource(TabResource tabResource,AsyncCallback<TabResource> callback);
|
||||
|
||||
void getTabResource(AsyncCallback<TabResource> callback);
|
||||
|
||||
void setTabResource(TabResource tabResource, AsyncCallback<Void> callback);
|
||||
|
||||
void getTabularResources(AsyncCallback<List<TabResource>> callback);
|
||||
|
||||
//Open
|
||||
void setTDOpenSession(TDOpenSession s, AsyncCallback<Void> callback);
|
||||
|
||||
//Import SDMX
|
||||
void getCodelists(AsyncCallback<ArrayList<Codelist>> callback);
|
||||
|
||||
void getDatasets(AsyncCallback<ArrayList<Dataset>> callback);
|
||||
|
||||
void getAgencies(AsyncCallback<ArrayList<Agencies>> callback);
|
||||
|
||||
void setSDMXSession(SDMXImportSession s, AsyncCallback<Void> callback);
|
||||
|
||||
void getSDMXImportMonitor(AsyncCallback<SDMXImportMonitor> callback);
|
||||
|
||||
void importSDMXClientLibraryRequest(SDMXImportSession s,AsyncCallback<Void> callback);
|
||||
|
||||
//Import CSV
|
||||
void getFileUploadMonitor(AsyncCallback<FileUploadMonitor> callback);
|
||||
|
||||
void getCSVImportMonitor(AsyncCallback<CSVImportMonitor> callback);
|
||||
|
||||
void setCSVSession(CSVImportSession s, AsyncCallback<Void> callback);
|
||||
|
||||
|
||||
void getAvailableCharset(AsyncCallback<AvailableCharsetList> callback);
|
||||
|
||||
void configureCSVParser(String encoding, HeaderPresence headerPresence, char delimiter, char comment, AsyncCallback<ArrayList<String>> callback);
|
||||
|
||||
void checkCSV(long errorsLimit, AsyncCallback<ArrayList<CSVRowError> > callback);
|
||||
|
||||
void startCSVImport(boolean[] columnToImportMask, AsyncCallback<Void> callback);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.server;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.gxtservice.server.file.FileUploadSession;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVFileUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVImportFileServlet extends HttpServlet {
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(CSVImportFileServlet.class);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4197748678713054285L;
|
||||
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
handleRequest(req, resp);
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
handleRequest(req, resp);
|
||||
}
|
||||
|
||||
protected void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
logger.info("CSVImportFileServlet");
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
|
||||
if(session==null){
|
||||
logger.error("Error getting the upload session, no session valid found: "+session);
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "ERROR-Error getting the user session, no session found"+session);
|
||||
return ;
|
||||
}
|
||||
logger.info("CSVImportFileServlet import session id: "+session.getId());
|
||||
|
||||
FileUploadSession fileUploadSession=SessionUtil.getFileUploadSession(session);
|
||||
|
||||
if (fileUploadSession == null)
|
||||
{
|
||||
logger.error("Error getting the upload session, no fileUploadSession found: "+fileUploadSession);
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "ERROR-Error getting the user session, no fileUploadSession found: "+fileUploadSession);
|
||||
return ;
|
||||
}
|
||||
|
||||
response.setContentType("application/json; charset=utf-8");
|
||||
Charset outputCharset = Charset.forName("Utf-8");
|
||||
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
CSVFileUtil.toJson(new FileInputStream(fileUploadSession.getCsvFile()), os, outputCharset, fileUploadSession.getParserConfiguration(), 100);
|
||||
|
||||
logger.trace("json: "+os.toString());
|
||||
System.out.println("json: "+os.toString());
|
||||
response.getOutputStream().write(os.toByteArray());
|
||||
|
||||
//CSVFileUtil.toJson(new FileInputStream(importSession.getCsvFile()), response.getOutputStream(), outputCharset, importSession.getParserConfiguration(), 100);
|
||||
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
logger.trace("Response in "+(System.currentTimeMillis()-startTime));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.FileItemFactory;
|
||||
import org.apache.commons.fileupload.FileUploadException;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.gcube.portlets.user.td.gxtservice.server.file.FileUploadListener;
|
||||
import org.gcube.portlets.user.td.gxtservice.server.file.FileUploadSession;
|
||||
import org.gcube.portlets.user.td.gxtservice.server.file.FileUtil;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportMonitor;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVParserConfiguration;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadMonitor;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadState;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class LocalUploadServlet extends HttpServlet {
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(LocalUploadServlet.class);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4197748678713054285L;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
logger.trace("Post");
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
|
||||
if(session==null){
|
||||
logger.error("Error getting the upload session, no session valid found: "+session);
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "ERROR-Error getting the user session, no session found"+session);
|
||||
return ;
|
||||
}
|
||||
logger.info("CSV Import session id: "+session.getId());
|
||||
|
||||
FileUploadSession fileUploadSession=new FileUploadSession();
|
||||
CSVImportMonitor csvImportMonitor=new CSVImportMonitor();
|
||||
FileUploadMonitor fileUploadMonitor=new FileUploadMonitor();
|
||||
|
||||
fileUploadSession.setId(session.getId());
|
||||
fileUploadSession.setFileUploadState(FileUploadState.STARTED);
|
||||
fileUploadSession.setCsvImportMonitor(csvImportMonitor);
|
||||
fileUploadSession.setFileUploadMonitor(fileUploadMonitor);
|
||||
|
||||
SessionUtil.setFileUploadSession(session,fileUploadSession);
|
||||
|
||||
|
||||
FileItemFactory factory = new DiskFileItemFactory();
|
||||
ServletFileUpload upload = new ServletFileUpload(factory);
|
||||
|
||||
|
||||
FileUploadListener uploadListener = new FileUploadListener(fileUploadSession.getFileUploadMonitor());
|
||||
upload.setProgressListener(uploadListener);
|
||||
|
||||
FileItem uploadItem = null;
|
||||
Log.info("Start upload file ");
|
||||
try {
|
||||
List items = upload.parseRequest(request);
|
||||
Iterator it = items.iterator();
|
||||
while (it.hasNext()) {
|
||||
FileItem item = (FileItem) it.next();
|
||||
if (!item.isFormField() && "uploadFormElement".equals(item.getFieldName())) {
|
||||
uploadItem = item;
|
||||
}
|
||||
}
|
||||
} catch (FileUploadException e) {
|
||||
fileUploadSession.getFileUploadMonitor().setFailed("An error occured elaborating the HTTP request", FileUtil.exceptionDetailMessage(e));
|
||||
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||
SessionUtil.setFileUploadSession(session, fileUploadSession);
|
||||
logger.error("Error processing request in upload servlet", e);
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "ERROR-Error during request processing: "+e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (uploadItem == null) {
|
||||
fileUploadSession.getFileUploadMonitor().setFailed("An error occured elaborating the HTTP request: No file found", "Upload request without file");
|
||||
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||
SessionUtil.setFileUploadSession(session, fileUploadSession);
|
||||
logger.error("Error processing request in upload servlet: No file to upload");
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "No file to upload");
|
||||
return;
|
||||
}
|
||||
|
||||
String contentType = uploadItem.getContentType();
|
||||
|
||||
logger.trace("ContentType: "+contentType);
|
||||
|
||||
/* TODO is necessary?
|
||||
if (contentType.equals("application/octet-stream")){
|
||||
|
||||
logger.trace("We try to guess the content using the extension");
|
||||
String name = uploadItem.getName();
|
||||
|
||||
int lastIndex = name.lastIndexOf('.');
|
||||
if (lastIndex>=0){
|
||||
String extension = name.substring(lastIndex+1);
|
||||
logger.trace("extension "+extension);
|
||||
contentType = MimeTypeUtil.getMimeType(extension);
|
||||
logger.trace("new contenttype: "+contentType);
|
||||
} else logger.trace("No extensions found");
|
||||
}
|
||||
*/
|
||||
|
||||
try {
|
||||
FileUtil.setImportFile(fileUploadSession, uploadItem.getInputStream(), uploadItem.getName(), contentType);
|
||||
} catch (Exception e) {
|
||||
fileUploadSession.getFileUploadMonitor().setFailed("An error occured elaborating the file", FileUtil.exceptionDetailMessage(e));
|
||||
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||
SessionUtil.setFileUploadSession(session, fileUploadSession);
|
||||
logger.error("Error elaborating the stream", e);
|
||||
uploadItem.delete();
|
||||
response.getWriter().write("ERROR-"+e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
uploadItem.delete();
|
||||
|
||||
logger.trace("changing state");
|
||||
fileUploadSession.getFileUploadMonitor().setState(FileUploadState.COMPLETED);
|
||||
SessionUtil.setFileUploadSession(session, fileUploadSession);
|
||||
response.getWriter().write("OK");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.datapublishing.sdmx.api.model.SDMXRegistryDescriptor;
|
||||
import org.gcube.datapublishing.sdmx.api.model.SDMXRegistryInterfaceType;
|
||||
import org.gcube.datapublishing.sdmx.api.registry.SDMXRegistryClient;
|
||||
import org.gcube.datapublishing.sdmx.api.registry.SDMXRegistryClient.Detail;
|
||||
import org.gcube.datapublishing.sdmx.api.registry.SDMXRegistryClient.References;
|
||||
import org.gcube.datapublishing.sdmx.impl.model.GCubeSDMXRegistryDescriptor;
|
||||
import org.gcube.datapublishing.sdmx.impl.model.SDMXRegistryDescriptorImpl;
|
||||
import org.gcube.datapublishing.sdmx.impl.registry.FusionRegistryClient;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Agencies;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Codelist;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Dataset;
|
||||
import org.sdmxsource.sdmx.api.model.beans.SdmxBeans;
|
||||
import org.sdmxsource.sdmx.api.model.beans.base.AgencyBean;
|
||||
import org.sdmxsource.sdmx.api.model.beans.codelist.CodelistBean;
|
||||
import org.sdmxsource.sdmx.api.model.beans.datastructure.DataflowBean;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SDMXClient {
|
||||
|
||||
public static enum TYPE { INTERNAL, ANOTHER }
|
||||
|
||||
protected SDMXRegistryClient client;
|
||||
protected TYPE type;
|
||||
protected String url;
|
||||
|
||||
public SDMXClient(){
|
||||
type=TYPE.INTERNAL;
|
||||
url=null;
|
||||
SDMXRegistryDescriptor descriptor = new GCubeSDMXRegistryDescriptor();
|
||||
client = new FusionRegistryClient(descriptor);
|
||||
|
||||
}
|
||||
|
||||
public SDMXClient(String url){
|
||||
type=TYPE.ANOTHER;
|
||||
this.url=url;
|
||||
SDMXRegistryDescriptorImpl descriptor = new SDMXRegistryDescriptorImpl();
|
||||
descriptor.setUrl(SDMXRegistryInterfaceType.RESTV2_1, url);
|
||||
client = new FusionRegistryClient(descriptor);
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<Codelist> getAllCodelists() throws Exception
|
||||
{
|
||||
SdmxBeans beans = client.getCodelist("all", "all", "all", Detail.allstubs, References.none);
|
||||
ArrayList<Codelist> codelists = new ArrayList<Codelist>();
|
||||
for (CodelistBean codelist:beans.getCodelists()) codelists.add(new Codelist(codelist.getId(), codelist.getName(), codelist.getAgencyId(), codelist.getVersion(), codelist.getDescription()));
|
||||
return codelists;
|
||||
}
|
||||
|
||||
public ArrayList<Dataset> getAllDatasets() throws Exception
|
||||
{
|
||||
SdmxBeans beans = client.getProvisionAgreement("all", "all", "latest", Detail.full, References.children);
|
||||
ArrayList<Dataset> datasets = new ArrayList<Dataset>();
|
||||
for (DataflowBean dataflowBean:beans.getDataflows()) {
|
||||
datasets.add(new Dataset(dataflowBean.getId(), dataflowBean.getName(), dataflowBean.getAgencyId(),dataflowBean.getVersion(),dataflowBean.getDescription()));
|
||||
}
|
||||
return datasets;
|
||||
}
|
||||
|
||||
public ArrayList<Agencies> getAllAgencies() throws Exception
|
||||
{
|
||||
SdmxBeans beans = client.getAgencyScheme("SDMX", "AGENCIES", "1.0", Detail.full, References.none);
|
||||
ArrayList<Agencies> agenciesList = new ArrayList<Agencies>();
|
||||
for (AgencyBean agency:beans.getAgencies()) agenciesList.add(new Agencies(agency.getId(), agency.getName(), agency.getDescription()));
|
||||
return agenciesList;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,365 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.Task;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.portlets.user.td.gxtservice.server.file.FileUploadSession;
|
||||
import org.gcube.portlets.user.td.gxtservice.server.trservice.TRTasksManager;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Agencies;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Codelist;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Constants;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Dataset;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TDOpenSession;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TRId;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TabResource;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportSession;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.sdmx.SDMXImportSession;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.source.SDMXRegistrySource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SessionUtil {
|
||||
|
||||
protected static final String CURRENT_TABULAR_RESOURCE = "CURRENT_TABULAR_RESOURCE";
|
||||
protected static final String CURRENT_TR_ID= "CURRENT_TR_ID";
|
||||
protected static final String TDOPEN_SESSION = "TDOPEN_SESSION";
|
||||
protected static final String TABULAR_RESOURCE_LIST = "TABULAR_RESOURCE_LIST";
|
||||
|
||||
protected static final String TR_TASK_MANAGER= "TR_TASK_MANAGER";
|
||||
|
||||
protected static final String SDMX_CLIENT_ATTRIBUTE = "SDMX_CLIENT";
|
||||
protected static final String SDMX_IMPORT_SESSION = "SDMX_IMPORT";
|
||||
protected static final String SDMX_IMPORT_TABULAR_RESOURCE = "SDMX_IMPORT_TABULAR_RESOURCE";
|
||||
protected static final String SDMX_IMPORT_TASK="SDMX_IMPORT_TASK";
|
||||
|
||||
|
||||
protected static final String CSV_IMPORT_SESSION = "CSV_IMPORT";
|
||||
protected static final String CSV_IMPORT_FILE_UPLOAD_SESSION = "CSV_IMPORT_FILE_UPLOAD";
|
||||
protected static final String CSV_IMPORT_TASK="CSV_IMPORT_TASK";
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(SessionUtil.class);
|
||||
|
||||
protected static ASLSession getAslSession(HttpSession httpSession) {
|
||||
String username = (String) httpSession
|
||||
.getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
|
||||
ASLSession session;
|
||||
if (username == null) {
|
||||
logger.warn("no user found in session, using test one");
|
||||
username = Constants.DEFAULT_USER;
|
||||
String scope = Constants.DEFAULT_SCOPE;
|
||||
|
||||
httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, username);
|
||||
session = SessionManager.getInstance().getASLSession(
|
||||
httpSession.getId(), username);
|
||||
session.setScope(scope);
|
||||
|
||||
} else {
|
||||
session= SessionManager.getInstance().getASLSession(
|
||||
httpSession.getId(), username);
|
||||
|
||||
}
|
||||
|
||||
Log.info("SessionUtil: aslSession "+session.getUsername()+" "+session.getScope());
|
||||
return session;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void setTDOpenSession(HttpSession httpSession, TDOpenSession s) {
|
||||
|
||||
TDOpenSession session = (TDOpenSession) httpSession
|
||||
.getAttribute(TDOPEN_SESSION);
|
||||
if (session != null)
|
||||
httpSession.removeAttribute(TDOPEN_SESSION);
|
||||
httpSession.setAttribute(TDOPEN_SESSION, s);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void retrieveResources(HttpSession httpSession)
|
||||
throws Exception {
|
||||
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
return;
|
||||
}
|
||||
|
||||
public static void setTabularResources(HttpSession httpSession,
|
||||
List<TabularResource> trs) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<TabularResource> tabularResources = (List<TabularResource>) httpSession
|
||||
.getAttribute(TABULAR_RESOURCE_LIST);
|
||||
if (tabularResources != null)
|
||||
httpSession.removeAttribute(TABULAR_RESOURCE_LIST);
|
||||
httpSession.setAttribute(TABULAR_RESOURCE_LIST, trs);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
}
|
||||
|
||||
public static TRId getTRId(HttpSession httpSession) {
|
||||
TRId id = (TRId) httpSession.getAttribute(CURRENT_TR_ID);
|
||||
if (id == null) {
|
||||
Log.error("SDMX_TR_ID was not acquired");
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public static void setTRId(HttpSession httpSession, TRId trId) {
|
||||
TRId id = (TRId) httpSession.getAttribute(CURRENT_TR_ID);
|
||||
if (id != null)
|
||||
httpSession.removeAttribute(CURRENT_TR_ID);
|
||||
httpSession.setAttribute(CURRENT_TR_ID, trId);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
}
|
||||
|
||||
public static TabResource getTabResource(HttpSession httpSession) {
|
||||
TabResource tabResource = (TabResource) httpSession
|
||||
.getAttribute(CURRENT_TABULAR_RESOURCE);
|
||||
if (tabResource == null) {
|
||||
Log.error("CURRENT_TABULAR_RESOURCE was not acquired");
|
||||
}
|
||||
return tabResource;
|
||||
}
|
||||
|
||||
public static void setTabResource(HttpSession httpSession,
|
||||
TabResource tabResource) {
|
||||
TabResource t = (TabResource) httpSession
|
||||
.getAttribute(CURRENT_TABULAR_RESOURCE);
|
||||
if (t != null)
|
||||
httpSession.removeAttribute(CURRENT_TABULAR_RESOURCE);
|
||||
httpSession.setAttribute(CURRENT_TABULAR_RESOURCE, tabResource);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
}
|
||||
|
||||
public static TabResource getSDMXImportTabResource(HttpSession httpSession) {
|
||||
TabResource tabResource = (TabResource) httpSession
|
||||
.getAttribute(SDMX_IMPORT_TABULAR_RESOURCE);
|
||||
if (tabResource == null) {
|
||||
Log.error("SDMX_IMPORT_TABULAR_RESOURCE was not acquired");
|
||||
}
|
||||
return tabResource;
|
||||
}
|
||||
|
||||
public static void setSDMXImportTabResource(HttpSession httpSession,
|
||||
TabResource tabResource) {
|
||||
TabResource t = (TabResource) httpSession
|
||||
.getAttribute(SDMX_IMPORT_TABULAR_RESOURCE);
|
||||
if (t != null)
|
||||
httpSession.removeAttribute(SDMX_IMPORT_TABULAR_RESOURCE);
|
||||
httpSession.setAttribute(SDMX_IMPORT_TABULAR_RESOURCE, tabResource);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
}
|
||||
|
||||
public static void setSDMXImportSession(HttpSession httpSession,
|
||||
SDMXImportSession s) {
|
||||
|
||||
SDMXImportSession session = (SDMXImportSession) httpSession
|
||||
.getAttribute(SDMX_IMPORT_SESSION);
|
||||
if (session != null)
|
||||
httpSession.removeAttribute(SDMX_IMPORT_SESSION);
|
||||
httpSession.setAttribute(SDMX_IMPORT_SESSION, s);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
}
|
||||
|
||||
public static SDMXImportSession getSDMXImportSession(HttpSession httpSession) {
|
||||
SDMXImportSession importSession = (SDMXImportSession) httpSession
|
||||
.getAttribute(SDMX_IMPORT_SESSION);
|
||||
if (importSession == null) {
|
||||
logger.error("SDMXImportSession was not acquired");
|
||||
}
|
||||
return importSession;
|
||||
}
|
||||
|
||||
public static void setCSVImportSession(HttpSession httpSession,
|
||||
CSVImportSession s) {
|
||||
|
||||
CSVImportSession session = (CSVImportSession) httpSession
|
||||
.getAttribute(CSV_IMPORT_SESSION);
|
||||
if (session != null)
|
||||
httpSession.removeAttribute(CSV_IMPORT_SESSION);
|
||||
httpSession.setAttribute(CSV_IMPORT_SESSION, s);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
}
|
||||
|
||||
public static CSVImportSession getCSVImportSession(HttpSession httpSession) {
|
||||
CSVImportSession importSession = (CSVImportSession) httpSession
|
||||
.getAttribute(CSV_IMPORT_SESSION);
|
||||
if (importSession == null) {
|
||||
logger.error("CSVImportSession was not acquired");
|
||||
}
|
||||
return importSession;
|
||||
}
|
||||
|
||||
|
||||
public static void setFileUploadSession(HttpSession httpSession,
|
||||
FileUploadSession s) {
|
||||
|
||||
FileUploadSession session = (FileUploadSession) httpSession
|
||||
.getAttribute(CSV_IMPORT_FILE_UPLOAD_SESSION);
|
||||
if (session != null)
|
||||
httpSession.removeAttribute(CSV_IMPORT_FILE_UPLOAD_SESSION);
|
||||
httpSession.setAttribute(CSV_IMPORT_FILE_UPLOAD_SESSION, s);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
}
|
||||
|
||||
|
||||
public static FileUploadSession getFileUploadSession(HttpSession httpSession) {
|
||||
FileUploadSession fileUploadSession = (FileUploadSession) httpSession
|
||||
.getAttribute(CSV_IMPORT_FILE_UPLOAD_SESSION);
|
||||
if (fileUploadSession == null) {
|
||||
logger.error("FileUploadSession was not acquired");
|
||||
}
|
||||
return fileUploadSession;
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<Codelist> retrieveCodelists(HttpSession httpSession)
|
||||
throws Exception {
|
||||
logger.info("SessionUtil retriveCodelists");
|
||||
SDMXClient client = getSdmxClient(httpSession);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
return client.getAllCodelists();
|
||||
}
|
||||
|
||||
public static ArrayList<Dataset> retrieveDatasets(HttpSession httpSession)
|
||||
throws Exception {
|
||||
logger.info("SessionUtil retriveDatasets");
|
||||
SDMXClient client = getSdmxClient(httpSession);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
return client.getAllDatasets();
|
||||
}
|
||||
|
||||
public static ArrayList<Agencies> retrieveAgencies(HttpSession httpSession)
|
||||
throws Exception {
|
||||
logger.info("SessionUtil retriveAgencies");
|
||||
SDMXClient client = getSdmxClient(httpSession);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
return client.getAllAgencies();
|
||||
}
|
||||
|
||||
public static SDMXClient getSdmxClient(HttpSession httpSession) {
|
||||
SDMXClient sdmxClient = (SDMXClient) httpSession
|
||||
.getAttribute(SDMX_CLIENT_ATTRIBUTE);
|
||||
SDMXImportSession sdmxImportSession = (SDMXImportSession) httpSession
|
||||
.getAttribute(SDMX_IMPORT_SESSION);
|
||||
if (sdmxImportSession == null) {
|
||||
logger.error("SDMXImportSession was not acquired");
|
||||
} else {
|
||||
if (sdmxImportSession.getSource() instanceof SDMXRegistrySource) {
|
||||
String url = ((SDMXRegistrySource) sdmxImportSession
|
||||
.getSource()).getUrl();
|
||||
if (url == null || url.isEmpty()) {
|
||||
if (sdmxClient == null) {
|
||||
sdmxClient = new SDMXClient();
|
||||
} else {
|
||||
if (sdmxClient.type.compareTo(SDMXClient.TYPE.ANOTHER) == 0) {
|
||||
sdmxClient = new SDMXClient();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (sdmxClient == null) {
|
||||
sdmxClient = new SDMXClient(url);
|
||||
} else {
|
||||
if (sdmxClient.type.compareTo(SDMXClient.TYPE.INTERNAL) == 0) {
|
||||
sdmxClient = new SDMXClient(url);
|
||||
} else {
|
||||
if (sdmxClient.url.compareTo(url) != 0) {
|
||||
sdmxClient = new SDMXClient(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
httpSession.setAttribute(SDMX_CLIENT_ATTRIBUTE, sdmxClient);
|
||||
} else {
|
||||
logger.error("SDMXImportSession does not have a SDMXRegistrySource");
|
||||
}
|
||||
}
|
||||
|
||||
return sdmxClient;
|
||||
}
|
||||
|
||||
public static Task getSDMXImportTask(HttpSession httpSession) {
|
||||
Task monitor = (Task) httpSession.getAttribute(SDMX_IMPORT_TASK);
|
||||
if (monitor == null) {
|
||||
logger.error("SDMX_IMPORT_TASK was not acquired");
|
||||
}
|
||||
return monitor;
|
||||
}
|
||||
|
||||
public static void setSDMXImportTask(HttpSession httpSession, Task task) {
|
||||
Task monitor = (Task) httpSession.getAttribute(SDMX_IMPORT_TASK);
|
||||
if (monitor != null)
|
||||
httpSession.removeAttribute(SDMX_IMPORT_TASK);
|
||||
httpSession.setAttribute(SDMX_IMPORT_TASK, task);
|
||||
}
|
||||
|
||||
|
||||
public static Task getCSVImportFileTask(HttpSession httpSession) {
|
||||
Task monitor = (Task) httpSession.getAttribute(CSV_IMPORT_TASK);
|
||||
if (monitor == null) {
|
||||
logger.error("CSV_IMPORT_TASK was not acquired");
|
||||
}
|
||||
return monitor;
|
||||
}
|
||||
|
||||
public static void setCSVImportFileTask(HttpSession httpSession, Task task) {
|
||||
Task monitor = (Task) httpSession.getAttribute(CSV_IMPORT_TASK);
|
||||
if (monitor != null)
|
||||
httpSession.removeAttribute(CSV_IMPORT_TASK);
|
||||
httpSession.setAttribute(CSV_IMPORT_TASK, task);
|
||||
}
|
||||
|
||||
|
||||
public static TRTasksManager getTRTasksManager(HttpSession httpSession) {
|
||||
TRTasksManager tasksManager = (TRTasksManager) httpSession.getAttribute(TR_TASK_MANAGER);
|
||||
if (tasksManager != null) {
|
||||
return tasksManager;
|
||||
} else {
|
||||
tasksManager=new TRTasksManager();
|
||||
httpSession.setAttribute(TR_TASK_MANAGER, tasksManager);
|
||||
return tasksManager;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setTRTasksManager(HttpSession httpSession,TRTasksManager trTasksManager) {
|
||||
TRTasksManager tm = (TRTasksManager) httpSession.getAttribute(TR_TASK_MANAGER);
|
||||
if (tm != null) {
|
||||
httpSession.removeAttribute(TR_TASK_MANAGER);
|
||||
}
|
||||
httpSession.setAttribute(TR_TASK_MANAGER, trTasksManager);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,791 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.server;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
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.metadata.NoSuchMetadataException;
|
||||
import org.gcube.data.analysis.tabulardata.model.table.Table;
|
||||
import org.gcube.data.analysis.tabulardata.model.table.TableId;
|
||||
import org.gcube.data.analysis.tabulardata.operation.worker.ActivityStatus;
|
||||
import org.gcube.data.analysis.tabulardata.operation.worker.EligibleOperation;
|
||||
import org.gcube.data.analysis.tabulardata.operation.worker.JobResult;
|
||||
import org.gcube.data.analysis.tabulardata.operation.worker.OperationInvocation;
|
||||
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||
import org.gcube.data.analysis.tabulardata.service.TabularDataServiceMock;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.OperationInterface;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.Task;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceInterface;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.AgencyMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.CreationDateMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.DescriptionMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.NameMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.RightsMetadata;
|
||||
import org.gcube.portlets.user.td.gxtservice.client.rpc.TDGXTService;
|
||||
import org.gcube.portlets.user.td.gxtservice.server.file.FileUploadSession;
|
||||
import org.gcube.portlets.user.td.gxtservice.server.storage.FilesStorage;
|
||||
import org.gcube.portlets.user.td.gxtservice.server.trservice.OperationsId;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Agencies;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Codelist;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Dataset;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TDGXTServiceException;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TDOpenSession;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TRId;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TabResource;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.AvailableCharsetList;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVFileUtil;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportMonitor;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportSession;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVParserConfiguration;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVRowError;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadMonitor;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.file.HeaderPresence;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.sdmx.SDMXImportMonitor;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.sdmx.SDMXImportSession;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class TDGXTServiceImpl extends RemoteServiceServlet implements
|
||||
TDGXTService {
|
||||
|
||||
private static final long serialVersionUID = -5707400086333186368L;
|
||||
protected static Logger logger = LoggerFactory
|
||||
.getLogger(TDGXTServiceImpl.class);
|
||||
|
||||
protected static SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
|
||||
protected TabularDataService service;
|
||||
protected HttpSession session;
|
||||
protected ASLSession aslSession;
|
||||
|
||||
public void setTabResource(TabResource tabResource)
|
||||
throws TDGXTServiceException {
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
return;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"Error setting TabResource parameter: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new TDGXTServiceException(
|
||||
"Error setting TabResource parameter: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public TabResource getTabResource() throws TDGXTServiceException {
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
return SessionUtil.getTabResource(session);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"Error setting TabResource parameter: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new TDGXTServiceException(
|
||||
"Error setting TabResource parameter: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the properties of the specified tabular resource
|
||||
*/
|
||||
/*
|
||||
* @Override public TRProperties getTaularResourceProperties(TRId trId)
|
||||
* throws TDGXTServiceException { try { HttpSession session =
|
||||
* this.getThreadLocalRequest().getSession();
|
||||
*
|
||||
* SessionUtil.setTRId(session, trId); TabularResourceId id = new
|
||||
* TabularResourceId(Long.valueOf(trId .getId())); TabularDataService
|
||||
* service = new TabularDataServiceMock();
|
||||
*
|
||||
* TabularResource tr = service.getTabularResource(id);
|
||||
*
|
||||
* NameMetadata nameMeta = tr.getMetadata(NameMetadata.class);
|
||||
* CreationDateMetadata creationDateMeta = tr
|
||||
* .getMetadata(CreationDateMetadata.class); AgencyMetadata agencyMeta =
|
||||
* tr.getMetadata(AgencyMetadata.class);
|
||||
*
|
||||
* String nameTR = nameMeta.getValue(); String agencyTR =
|
||||
* agencyMeta.getValue(); Date dateTR = creationDateMeta.getValue(); TableId
|
||||
* tableId = tr.getHistory().get(tr.getHistory().size() - 1)
|
||||
* .getResultTable().getId();
|
||||
*
|
||||
* HashMap<String, String> properties = new HashMap<String, String>();
|
||||
*
|
||||
* properties.put("Id", String.valueOf(tr.getId().getValue()));
|
||||
* properties.put("Table id", String.valueOf(tableId.getValue()));
|
||||
* properties.put("Name", nameTR); properties.put("Agency", agencyTR);
|
||||
* properties.put("Creation Date", sdf.format(dateTR));
|
||||
*
|
||||
* logger.info("Tabular Resources retrived: " + properties);
|
||||
*
|
||||
* TRProperties trProperties = new TRProperties();
|
||||
* trProperties.setProperties(properties);
|
||||
*
|
||||
* return trProperties; return null; } catch (Exception e) {
|
||||
* logger.error("Error retrieving TabularResources: " +
|
||||
* e.getLocalizedMessage()); throw new TDGXTServiceException(
|
||||
* "Error retrieving Tabular Resources Properties: " +
|
||||
* e.getLocalizedMessage()); }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void setTDOpenSession(TDOpenSession s) throws TDGXTServiceException {
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setTDOpenSession(session, s);
|
||||
return;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error setting TDOpenSession parameter: "
|
||||
+ e.getLocalizedMessage());
|
||||
throw new TDGXTServiceException(
|
||||
"Error setting TDOpenSession parameter: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected TabResource retriveTRMetadataFromService(TabularResource tr, int i)
|
||||
throws TDGXTServiceException {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
|
||||
NameMetadata nameMeta;
|
||||
RightsMetadata rightsMeta;
|
||||
CreationDateMetadata creationDateMeta;
|
||||
AgencyMetadata agencyMeta;
|
||||
DescriptionMetadata descriptionMeta;
|
||||
try {
|
||||
nameMeta = tr.getMetadata(NameMetadata.class);
|
||||
creationDateMeta = tr.getMetadata(CreationDateMetadata.class);
|
||||
agencyMeta = tr.getMetadata(AgencyMetadata.class);
|
||||
descriptionMeta = tr.getMetadata(DescriptionMetadata.class);
|
||||
rightsMeta = tr.getMetadata(RightsMetadata.class);
|
||||
} catch (NoSuchMetadataException e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGXTServiceException(
|
||||
"Error retriving metadata from service: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
if (nameMeta == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error retriving metadata from service: TR nameMeta is null");
|
||||
}
|
||||
String nameTR = nameMeta.getValue();
|
||||
String descriptionTR = "";
|
||||
String agencyTR = "";
|
||||
String rightsTR = "";
|
||||
String dateS = "";
|
||||
|
||||
if (descriptionMeta != null) {
|
||||
descriptionTR = descriptionMeta.getValue();
|
||||
}
|
||||
if (agencyMeta != null) {
|
||||
agencyTR = agencyMeta.getValue();
|
||||
}
|
||||
if (rightsMeta != null) {
|
||||
rightsTR = rightsMeta.getValue();
|
||||
}
|
||||
if (creationDateMeta != null) {
|
||||
Date dateTR = creationDateMeta.getValue();
|
||||
dateS = sdf.format(dateTR);
|
||||
}
|
||||
|
||||
TableId tableId = tr.getHistory().get(tr.getHistory().size() - 1)
|
||||
.getResultTable().getId();
|
||||
TRId trId = new TRId(String.valueOf(tr.getId().getValue()),
|
||||
String.valueOf(tableId.getValue()));
|
||||
TabResource t = new TabResource(i, nameTR, descriptionTR, agencyTR,
|
||||
dateS, rightsTR, trId);
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<TabResource> getTabularResources()
|
||||
throws TDGXTServiceException {
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
aslSession = SessionUtil.getAslSession(session);
|
||||
service = new TabularDataServiceMock();
|
||||
|
||||
List<TabularResource> trs = service.getTabularResources();
|
||||
SessionUtil.setTabularResources(session, trs);
|
||||
|
||||
ArrayList<TabResource> ltr = new ArrayList<TabResource>();
|
||||
|
||||
int i;
|
||||
for (i = 0; i < trs.size(); i++) {
|
||||
TabularResource tr = trs.get(i);
|
||||
TabResource t = retriveTRMetadataFromService(tr, i);
|
||||
ltr.add(t);
|
||||
}
|
||||
|
||||
logger.debug("Tabular Resources retrived: " + ltr);
|
||||
return ltr;
|
||||
} catch (Exception e) {
|
||||
logger.error("Error retrieving TabularResources: "
|
||||
+ e.getLocalizedMessage());
|
||||
throw new TDGXTServiceException(
|
||||
"Error retrieving TabularResources: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param tabResource
|
||||
* @throws TDGXTServiceException
|
||||
*/
|
||||
|
||||
public void removeTabularResource(TabResource tabResource)
|
||||
throws TDGXTServiceException {
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
if (tabResource == null) {
|
||||
logger.error("Error removing TabularResource: tabResource is null");
|
||||
throw new TDGXTServiceException(
|
||||
"Error removing TabularResource no parameters set");
|
||||
}
|
||||
TabularDataService service = new TabularDataServiceMock();
|
||||
TabularResourceId id = new TabularResourceId(
|
||||
Long.valueOf(tabResource.getTrId().getId()));
|
||||
service.removeTabularResource(id);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"Error removing TabularResource: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new TDGXTServiceException("Error removing TabularResource: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void setTabularResourceMetaData(TabResource tabResource,
|
||||
TabularResource serviceTR) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabResource createTabularResource(TabResource tabResource)
|
||||
throws TDGXTServiceException {
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
if (tabResource == null) {
|
||||
logger.error("Error creating new TabularResource: tabResource is null");
|
||||
throw new TDGXTServiceException(
|
||||
"Error creating new TabularResource no parameters set");
|
||||
}
|
||||
service = new TabularDataServiceMock();
|
||||
TabularResource serviceTR = service.createTabularResource();
|
||||
Table table = service.getLastTable(serviceTR.getId());
|
||||
|
||||
TRId trId = new TRId(String.valueOf(serviceTR.getId().getValue()),
|
||||
String.valueOf(table.getId().getValue()));
|
||||
tabResource.setTrId(trId);
|
||||
setTabularResourceMetaData(tabResource, serviceTR);
|
||||
return tabResource;
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"Error creating new TabularResource: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new TDGXTServiceException(
|
||||
"Error creating new TabularResource: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* jar {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<Codelist> getCodelists() throws TDGXTServiceException {
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
return SessionUtil.retrieveCodelists(session);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGXTServiceException("Error retrieving codelists: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<Dataset> getDatasets() throws TDGXTServiceException {
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
return SessionUtil.retrieveDatasets(session);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGXTServiceException("Error retrieving datasets: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<Agencies> getAgencies() throws TDGXTServiceException {
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
return SessionUtil.retrieveAgencies(session);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGXTServiceException("Error retrieving datasets: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* SDMX Import
|
||||
*
|
||||
*/
|
||||
protected Map<String, Object> retrieveOperationParameters(
|
||||
SDMXImportSession sdmxImportSession) {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
Codelist codelist = sdmxImportSession.getSelectedCodelist();
|
||||
|
||||
map.put("Agency", codelist.getAgencyId());
|
||||
map.put("Id", codelist.getId());
|
||||
map.put("Version", codelist.getVersion());
|
||||
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importSDMXClientLibraryRequest(
|
||||
SDMXImportSession sdmxImportSession) throws TDGXTServiceException {
|
||||
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setSDMXImportSession(session, sdmxImportSession);
|
||||
aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
service = new TabularDataServiceMock();
|
||||
OperationInterface oService = service;
|
||||
TabularResourceInterface trService = service;
|
||||
|
||||
List<EligibleOperation> capabilities = service.getCapabilities();
|
||||
|
||||
// Import SDMX Codelist takes id 200
|
||||
EligibleOperation importSDMXCodelistOperation = getEligibleOperationWithId(
|
||||
OperationsId.SDMXCodelistImport.toString(), capabilities);
|
||||
|
||||
TabResource importSDMXTabResource = sdmxImportSession
|
||||
.getTabResource();
|
||||
|
||||
TabularResource serviceTR = trService.createTabularResource();
|
||||
// Table table=trService.getLastTable(serviceTRId);
|
||||
|
||||
TRId trId = new TRId(String.valueOf(serviceTR.getId().getValue()));
|
||||
importSDMXTabResource.setTrId(trId);
|
||||
SessionUtil
|
||||
.setSDMXImportTabResource(session, importSDMXTabResource);
|
||||
|
||||
Map<String, Object> parameterInstances = retrieveOperationParameters(sdmxImportSession);
|
||||
|
||||
OperationInvocation invocation = importSDMXCodelistOperation
|
||||
.createOperationInvocation(parameterInstances);
|
||||
|
||||
Task trTask = oService.execute(invocation, serviceTR.getId());
|
||||
|
||||
SessionUtil.setSDMXImportTask(session, trTask);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGXTServiceException("Error in Client Library Request: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected EligibleOperation getEligibleOperationWithId(String op,
|
||||
List<EligibleOperation> capabilities) throws TDGXTServiceException {
|
||||
for (EligibleOperation operation : capabilities) {
|
||||
if (Long.valueOf(op) == operation.getOperationDescriptor()
|
||||
.getOperationId().getValue()) {
|
||||
return operation;
|
||||
}
|
||||
;
|
||||
|
||||
}
|
||||
throw new TDGXTServiceException("ElegibleOperation not found");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SDMXImportMonitor getSDMXImportMonitor()
|
||||
throws TDGXTServiceException {
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
aslSession = SessionUtil.getAslSession(session);
|
||||
Task task = SessionUtil.getSDMXImportTask(session);
|
||||
TabResource sdmxImportTabResource = SessionUtil
|
||||
.getSDMXImportTabResource(session);
|
||||
TRId trId = sdmxImportTabResource.getTrId();
|
||||
|
||||
SDMXImportMonitor importMonitor = new SDMXImportMonitor();
|
||||
if (trId == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error in importSDMX TabularResource Id null");
|
||||
} else {
|
||||
if (task == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error in importSDMX task null");
|
||||
} else {
|
||||
ActivityStatus status = task.getStatus();
|
||||
if (status == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error in importSDMX Status null");
|
||||
} else {
|
||||
importMonitor.setStatus(task.getStatus().ordinal());
|
||||
importMonitor.setProgress(task.getProgress());
|
||||
JobResult result = task.getResult();
|
||||
if (result == null) {
|
||||
logger.info("Task Result: " + task.getResult());
|
||||
} else {
|
||||
importMonitor.setError(task.getResult()
|
||||
.getException());
|
||||
if (task.getResult().getOutput() == null) {
|
||||
logger.info("Task Result Output: "
|
||||
+ task.getResult().getOutput());
|
||||
} else {
|
||||
if (task.getResult().getOutput().getId() == null) {
|
||||
logger.info("Task Result Output Id: "
|
||||
+ task.getResult().getOutput()
|
||||
.getId());
|
||||
} else {
|
||||
logger.info("Task TableId: "
|
||||
+ task.getResult().getOutput()
|
||||
.getId().getValue());
|
||||
|
||||
trId.setTableId(String.valueOf(task
|
||||
.getResult().getOutput().getId()
|
||||
.getValue()));
|
||||
sdmxImportTabResource.setTrId(trId);
|
||||
SessionUtil.setSDMXImportTabResource(
|
||||
session, sdmxImportTabResource);
|
||||
|
||||
SessionUtil.setTRId(session, trId);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
SessionUtil.setSDMXImportTask(session, task);
|
||||
}
|
||||
|
||||
importMonitor.setTrId(trId);
|
||||
}
|
||||
logger.info("getImportMonitor(): " + importMonitor);
|
||||
return importMonitor;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGXTServiceException(
|
||||
"Error in importSDMX ImportMonitor: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSDMXSession(SDMXImportSession sdmxImportSession)
|
||||
throws TDGXTServiceException {
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setSDMXImportSession(session, sdmxImportSession);
|
||||
return;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"Error setting SDMXImportSession parameter: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new TDGXTServiceException(
|
||||
"Error setting SDMXImportSession parameter: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* CSV Import
|
||||
*
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void setCSVSession(CSVImportSession importSession)
|
||||
throws TDGXTServiceException {
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setCSVImportSession(session, importSession);
|
||||
return;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"Error setting SDMXImportSession parameter: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new TDGXTServiceException(
|
||||
"Error setting SDMXImportSession parameter: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileUploadMonitor getFileUploadMonitor()
|
||||
throws TDGXTServiceException {
|
||||
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
if (session == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error retrieving the session: null");
|
||||
}
|
||||
FileUploadSession fileUploadSession = SessionUtil
|
||||
.getFileUploadSession(session);
|
||||
if (fileUploadSession == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error retrieving the fileUploadSession: null");
|
||||
}
|
||||
return fileUploadSession.getFileUploadMonitor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CSVImportMonitor getCSVImportMonitor() throws TDGXTServiceException {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
if (session == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error retrieving the session: null");
|
||||
}
|
||||
logger.info("Session:" + session.getId());
|
||||
|
||||
FileUploadSession importSession = SessionUtil
|
||||
.getFileUploadSession(session);
|
||||
if (importSession == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error retrieving the fileUploadSession: null");
|
||||
}
|
||||
return importSession.getCsvImportMonitor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AvailableCharsetList getAvailableCharset()
|
||||
throws TDGXTServiceException {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
if (session == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error retrieving the session: null");
|
||||
}
|
||||
logger.info("Session:" + session.getId());
|
||||
String defaultEncoding = Charset.defaultCharset().displayName();
|
||||
ArrayList<String> charsetList = new ArrayList<String>(Charset
|
||||
.availableCharsets().keySet());
|
||||
return new AvailableCharsetList(charsetList, defaultEncoding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> configureCSVParser(String encoding,
|
||||
HeaderPresence headerPresence, char delimiter, char comment)
|
||||
throws TDGXTServiceException {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
if (session == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error retrieving the session: null");
|
||||
}
|
||||
logger.info("Session:" + session.getId());
|
||||
logger.info("configureCSVParser encoding: " + encoding
|
||||
+ " headerPresence: " + headerPresence + " delimiter: "
|
||||
+ delimiter + " comment: " + comment);
|
||||
|
||||
FileUploadSession fileUploadSession = SessionUtil
|
||||
.getFileUploadSession(session);
|
||||
if (fileUploadSession == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error retrieving the fileUploadSession: null");
|
||||
}
|
||||
CSVParserConfiguration parserConfiguration = fileUploadSession
|
||||
.getParserConfiguration();
|
||||
if (parserConfiguration == null) {
|
||||
parserConfiguration = new CSVParserConfiguration(
|
||||
Charset.forName(encoding), delimiter, comment,
|
||||
headerPresence);
|
||||
fileUploadSession.setParserConfiguration(parserConfiguration);
|
||||
} else {
|
||||
parserConfiguration.update(encoding, delimiter, comment,
|
||||
headerPresence);
|
||||
}
|
||||
SessionUtil.setFileUploadSession(session, fileUploadSession);
|
||||
try {
|
||||
return CSVFileUtil.getHeader(fileUploadSession.getCsvFile(),
|
||||
fileUploadSession.getParserConfiguration());
|
||||
} catch (Exception e) {
|
||||
logger.error("Error retrieving the CSV header", e);
|
||||
throw new TDGXTServiceException(
|
||||
"Error calculating the CSV header: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<CSVRowError> checkCSV(long errorsLimit)
|
||||
throws TDGXTServiceException {
|
||||
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
if (session == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error retrieving the session: null");
|
||||
}
|
||||
logger.info("Session:" + session.getId());
|
||||
FileUploadSession fileUploadSession = SessionUtil
|
||||
.getFileUploadSession(session);
|
||||
if (fileUploadSession == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error retrieving the fileUploadSession: null");
|
||||
}
|
||||
|
||||
try {
|
||||
return CSVFileUtil.checkCSV(fileUploadSession.getCsvFile(),
|
||||
fileUploadSession.getParserConfiguration(), errorsLimit);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error checking the CSV file", e);
|
||||
throw new TDGXTServiceException("Error checking the CSV file: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startCSVImport(boolean[] columnToImportMask)
|
||||
throws TDGXTServiceException {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
if (session == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error retrieving the session: null");
|
||||
}
|
||||
logger.info("Session:" + session.getId());
|
||||
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
if (aslSession == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error retrieving the asl session: null");
|
||||
}
|
||||
String user = aslSession.getUsername();
|
||||
logger.info("Session User:" + user);
|
||||
|
||||
FileUploadSession fileUploadSession = SessionUtil
|
||||
.getFileUploadSession(session);
|
||||
if (fileUploadSession == null) {
|
||||
throw new TDGXTServiceException(
|
||||
"Error retrieving the fileUploadSession: null");
|
||||
}
|
||||
|
||||
importCSVFileOnService(user, fileUploadSession, columnToImportMask);
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected Map<String, Object> csvImportFileParameter(
|
||||
String fileUrlOnStorage, FileUploadSession fileUploadSession,
|
||||
boolean[] columnToImportMask) {
|
||||
final String ENCODING = "encoding";
|
||||
final String HASHEADER = "hasHeader";
|
||||
final String SEPARATOR = "separator";
|
||||
final String URL = "url";
|
||||
|
||||
Map<String, Object> parameterInstances = new HashMap<String, Object>();
|
||||
parameterInstances.put(URL, fileUrlOnStorage);
|
||||
parameterInstances.put(SEPARATOR, fileUploadSession
|
||||
.getParserConfiguration().getDelimiter());// ','
|
||||
parameterInstances.put(ENCODING, fileUploadSession
|
||||
.getParserConfiguration().getCharset());// "UTF-8"
|
||||
boolean hasHeader = true;
|
||||
if (fileUploadSession.getParserConfiguration().getHeaderPresence() == HeaderPresence.NONE) {
|
||||
hasHeader = false;
|
||||
}
|
||||
parameterInstances.put(HASHEADER, hasHeader);// true
|
||||
return parameterInstances;
|
||||
}
|
||||
|
||||
protected void importCSVFileOnService(String user,
|
||||
FileUploadSession fileUploadSession, boolean[] columnToImportMask)
|
||||
throws TDGXTServiceException {
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
|
||||
String fileUrlOnStorage = filesStorage.storageCSVTempFile(user,
|
||||
fileUploadSession.getCsvFile());
|
||||
|
||||
Map<String, Object> parameterInstance = csvImportFileParameter(
|
||||
fileUrlOnStorage, fileUploadSession, columnToImportMask);
|
||||
|
||||
service = new TabularDataServiceMock();
|
||||
|
||||
List<EligibleOperation> capabilities = service.getCapabilities();
|
||||
|
||||
// Import CSV file
|
||||
EligibleOperation importCSVFileOperation = getEligibleOperationWithId(
|
||||
OperationsId.CSVImport.toString(), capabilities);
|
||||
|
||||
OperationInvocation oi = importCSVFileOperation
|
||||
.createOperationInvocation(parameterInstance);
|
||||
TabularResource tabularResource = service.createTabularResource();
|
||||
|
||||
Task trTask;
|
||||
try {
|
||||
trTask = service.execute(oi, tabularResource.getId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGXTServiceException(
|
||||
"Tabular Data Service error creating TabularResource: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
SessionUtil.setCSVImportFileTask(session, trTask);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.server.file;
|
||||
|
||||
import org.apache.commons.fileupload.ProgressListener;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadMonitor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class FileUploadListener implements ProgressListener {
|
||||
|
||||
protected FileUploadMonitor fileUploadMonitor;
|
||||
|
||||
public FileUploadListener(FileUploadMonitor fileUploadMonitor) {
|
||||
this.fileUploadMonitor = fileUploadMonitor;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void update(long pBytesRead, long pContentLength, int pItems) {
|
||||
fileUploadMonitor.setTotalLenght(pContentLength);
|
||||
fileUploadMonitor.setElaboratedLenght(pBytesRead);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.server.file;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportMonitor;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVParserConfiguration;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadMonitor;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadState;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class FileUploadSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7906477664944910362L;
|
||||
|
||||
protected String id;
|
||||
|
||||
protected FileUploadState fileUploadState;
|
||||
|
||||
protected File csvFile;
|
||||
protected String csvName;
|
||||
|
||||
protected FileUploadMonitor fileUploadMonitor;
|
||||
|
||||
protected CSVParserConfiguration parserConfiguration;
|
||||
|
||||
protected CSVImportMonitor csvImportMonitor;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public FileUploadState getFileUploadState() {
|
||||
return fileUploadState;
|
||||
}
|
||||
|
||||
public void setFileUploadState(FileUploadState fileUploadState) {
|
||||
this.fileUploadState = fileUploadState;
|
||||
}
|
||||
|
||||
public File getCsvFile() {
|
||||
return csvFile;
|
||||
}
|
||||
|
||||
public void setCsvFile(File csvFile) {
|
||||
this.csvFile = csvFile;
|
||||
}
|
||||
|
||||
public String getCsvName() {
|
||||
return csvName;
|
||||
}
|
||||
|
||||
public void setCsvName(String csvName) {
|
||||
this.csvName = csvName;
|
||||
}
|
||||
|
||||
public FileUploadMonitor getFileUploadMonitor() {
|
||||
return fileUploadMonitor;
|
||||
}
|
||||
|
||||
public void setFileUploadMonitor(FileUploadMonitor fileUploadMonitor) {
|
||||
this.fileUploadMonitor = fileUploadMonitor;
|
||||
}
|
||||
|
||||
public CSVParserConfiguration getParserConfiguration() {
|
||||
return parserConfiguration;
|
||||
}
|
||||
|
||||
public void setParserConfiguration(CSVParserConfiguration parserConfiguration) {
|
||||
this.parserConfiguration = parserConfiguration;
|
||||
}
|
||||
|
||||
public CSVImportMonitor getCsvImportMonitor() {
|
||||
return csvImportMonitor;
|
||||
}
|
||||
|
||||
public void setCsvImportMonitor(CSVImportMonitor csvImportMonitor) {
|
||||
this.csvImportMonitor = csvImportMonitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FileUploadSession [id=" + id + ", fileUploadState=" + fileUploadState
|
||||
+ ", csvFile=" + csvFile + ", csvName=" + csvName
|
||||
+ ", fileUploadMonitor=" + fileUploadMonitor
|
||||
+ ", parserConfiguration=" + parserConfiguration
|
||||
+ ", csvImportMonitor=" + csvImportMonitor +"]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.server.file;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import org.gcube.portlets.user.td.gxtservice.server.SessionUtil;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportSession;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class FileUtil {
|
||||
|
||||
protected static final Logger logger = LoggerFactory.getLogger(FileUtil.class);
|
||||
|
||||
public static final String[] ZIP_MIMETYPES = new String[]{
|
||||
"application/x-compress",
|
||||
"application/x-compressed",
|
||||
"application/x-gzip",
|
||||
"application/x-winzip",
|
||||
"application/x-zip",
|
||||
"application/zip",
|
||||
"multipart/x-zip"};
|
||||
|
||||
/**
|
||||
* Check if the content type is a zip type.
|
||||
* @param contentType the content type to check.
|
||||
* @return <code>true</code> if is a zip file, <code>false</code> otherwise.
|
||||
*/
|
||||
public static boolean isZipContentType(String contentType)
|
||||
{
|
||||
for (String zip_mimetype:ZIP_MIMETYPES) if (zip_mimetype.equals(contentType)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unzip the specified stream
|
||||
* @param is the zip stream.
|
||||
* @param os the output stream.
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String unZip(InputStream is, OutputStream os) throws Exception
|
||||
{
|
||||
try {
|
||||
ZipInputStream zis = new ZipInputStream(is);
|
||||
ZipEntry entry;
|
||||
|
||||
while ((entry = zis.getNextEntry())!=null && !entry.isDirectory());
|
||||
|
||||
if (entry == null || entry.isDirectory()) {
|
||||
zis.close();
|
||||
os.close();
|
||||
throw new Exception("Unzip error: No file entry found");
|
||||
}
|
||||
IOUtils.copy(zis, os);
|
||||
zis.closeEntry();
|
||||
zis.close();
|
||||
os.close();
|
||||
return entry.getName();
|
||||
|
||||
|
||||
} catch(IOException e)
|
||||
{
|
||||
throw new Exception("Unzip error: "+e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String exceptionDetailMessage(Throwable t)
|
||||
{
|
||||
StringWriter out = new StringWriter();
|
||||
PrintWriter writer = new PrintWriter(out);
|
||||
t.printStackTrace(writer);
|
||||
|
||||
StringBuilder message = new StringBuilder("Error message:\n");
|
||||
message.append(out.toString());
|
||||
|
||||
return message.toString();
|
||||
}
|
||||
|
||||
public static void setImportFile(FileUploadSession fileUploadSession, InputStream is, String name, String mimeType) throws Exception
|
||||
{
|
||||
File csvTmp = File.createTempFile("import", "csv");
|
||||
|
||||
//FIXME manage it
|
||||
csvTmp.deleteOnExit();
|
||||
|
||||
logger.trace("mimeType: "+mimeType);
|
||||
if (isZipContentType(mimeType)){
|
||||
//we need to unzip
|
||||
logger.trace("is a zip file");
|
||||
name = unZip(is, new FileOutputStream(csvTmp));
|
||||
} else {
|
||||
logger.trace("is a text file");
|
||||
IOUtils.copy(is, new FileOutputStream(csvTmp));
|
||||
}
|
||||
|
||||
logger.trace("upload completed");
|
||||
|
||||
fileUploadSession.setCsvName(name);
|
||||
fileUploadSession.setCsvFile(csvTmp);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.server.storage;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
|
||||
public class FilesStorage {
|
||||
|
||||
public String storageCSVTempFile(String user, File file) {
|
||||
IClient client = new StorageClient(user, AccessType.PUBLIC,
|
||||
MemoryType.VOLATILE).getClient();
|
||||
String remotePath = "/CSVimport/" + file.getName();
|
||||
client.put(true).LFile(file.getAbsolutePath()).RFile(remotePath);
|
||||
String url=client.getUrl().RFile(remotePath);
|
||||
return url;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.server.trservice;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
* Tabular Data Service Operations Id
|
||||
*
|
||||
* 100 CSVImport
|
||||
* 101 CSVExport
|
||||
* 200 SDMXCodelistImport
|
||||
* 201 SDMXCodelistExport
|
||||
* 202 SDMXDatasetImport
|
||||
* 203 SDMXDatasetExport
|
||||
* 300 JSONImport
|
||||
* 301 JSONExport
|
||||
* 1000 ValidateCodelist
|
||||
* 1001 ValidateDataset
|
||||
* 1002 ChangeTableType
|
||||
* 1003 CreateDatasetView
|
||||
* 1004 RemoveColumn
|
||||
* 1005 ChangeLabel
|
||||
* 1006 AddLabel
|
||||
* 1007 RemoveLabel
|
||||
* 2000 ChangeToAnnotationColumn
|
||||
* 2001 ChangeToAttributeColumn
|
||||
* 2002 ChangeToMeasureColumn
|
||||
* 2003 ChangeToCodeColumn
|
||||
* 2004 ChangeToCodeName
|
||||
* 2005 ChangeToCodeDescription
|
||||
* 2006 ChangeToDimensionColumn
|
||||
* 2007 ChangeToTimeDimensionColumn
|
||||
* 3000 ModifyTuplesValues
|
||||
* 3001 ModifyColumnValueOnCondition
|
||||
* 3002 NewAnnotationColumn
|
||||
* 3003 Filter
|
||||
* 3004 Union
|
||||
* 3005 Denormalize
|
||||
* 3006 Aggregate
|
||||
*
|
||||
*/
|
||||
public enum OperationsId {
|
||||
CSVImport("100"),
|
||||
CSVExport("101"),
|
||||
SDMXCodelistImport("200"),
|
||||
SDMXCodelistExport("201"),
|
||||
SDMXDatasetImport("202"),
|
||||
SDMXDatasetExport("203"),
|
||||
JSONImport("300"),
|
||||
JSONExport("301"),
|
||||
ValidateCodelist("1000"),
|
||||
ValidateDataset("1001"),
|
||||
ChangeTableType("1002"),
|
||||
CreateDatasetView("1003"),
|
||||
RemoveColumn("1004"),
|
||||
ChangeLabel("1005"),
|
||||
AddLabel("1006"),
|
||||
RemoveLabel("1007"),
|
||||
ChangeToAnnotationColumn("2000"),
|
||||
ChangeToAttributeColumn("2001"),
|
||||
ChangeToMeasureColumn("2002"),
|
||||
ChangeToCodeColumn("2003"),
|
||||
ChangeToCodeName("2004"),
|
||||
ChangeToCodeDescription("2005"),
|
||||
ChangeToDimensionColumn("2006"),
|
||||
ChangeToTimeDimensionColumn("2007"),
|
||||
ModifyTuplesValues("3000"),
|
||||
ModifyColumnValueOnCondition("3001"),
|
||||
NewAnnotationColumn("3002"),
|
||||
Filter("3003"),
|
||||
Union("3004"),
|
||||
Denormalize("3005"),
|
||||
Aggregate("3006");
|
||||
|
||||
/**
|
||||
* @param text
|
||||
*/
|
||||
private OperationsId(final String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
private final String id;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.server.trservice;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.Task;
|
||||
|
||||
public class TRTasksManager implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 4517156156005181775L;
|
||||
|
||||
protected HashMap<Long, Task> trTasksMap=new HashMap<Long, Task>();
|
||||
|
||||
public void add(Task trTask){
|
||||
trTasksMap.put(trTask.getId().getValue(),trTask);
|
||||
};
|
||||
|
||||
public Task get(Long id){
|
||||
return trTasksMap.get(id);
|
||||
};
|
||||
|
||||
public void remove(Long id){
|
||||
trTasksMap.remove(id);
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class Agencies implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8353499109124097114L;
|
||||
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected String nameLabel;
|
||||
|
||||
|
||||
public Agencies(){}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param name
|
||||
* @param agencyId
|
||||
*/
|
||||
public Agencies(String id, String name, String description) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.nameLabel=id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return label
|
||||
*/
|
||||
public String getNameLabel() {
|
||||
return nameLabel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Agency [id=");
|
||||
builder.append(id);
|
||||
builder.append(", name=");
|
||||
builder.append(name);
|
||||
builder.append(", description=");
|
||||
builder.append(description);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author "Federico De Faveri defaveri@isti.cnr.it"
|
||||
*
|
||||
*/
|
||||
public class Codelist implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8353499109124097114L;
|
||||
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String agencyId;
|
||||
protected String version;
|
||||
protected String description;
|
||||
|
||||
|
||||
public Codelist(){}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param name
|
||||
* @param agencyId
|
||||
*/
|
||||
public Codelist(String id, String name, String agencyId,String version, String description) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.agencyId = agencyId;
|
||||
this.version = version;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the agencyId
|
||||
*/
|
||||
public String getAgencyId() {
|
||||
return agencyId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the version
|
||||
*/
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the version
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Codelist [id=");
|
||||
builder.append(id);
|
||||
builder.append(", name=");
|
||||
builder.append(name);
|
||||
builder.append(", agencyId=");
|
||||
builder.append(agencyId);
|
||||
builder.append(", version=");
|
||||
builder.append(version);
|
||||
builder.append(", description=");
|
||||
builder.append(description);
|
||||
builder.append("]");
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
public final static String VERSION = "1.0.0";
|
||||
public final static String DEFAULT_USER = "giancarlo.panichi";
|
||||
public final static String DEFAULT_SCOPE = "/gcube/devsec";
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ConstantsWorkspace {
|
||||
|
||||
|
||||
public static final String APPLICATION_NAME = "TabularData";
|
||||
public static final String ITEM_TYPE_GENERIC = "TabularResource";
|
||||
public static final String ITEM_TYPE_CODELIST = "TabularResourceCodelist";
|
||||
|
||||
public static final String[] ITEM_TYPES = new String[]{ITEM_TYPE_GENERIC, ITEM_TYPE_CODELIST};
|
||||
|
||||
public static final String ID_KEY = "Id";
|
||||
public static final String LAST_TABLE_KEY = "TableId";
|
||||
public static final String AGENCY_KEY = "Agency";
|
||||
public static final String ITEM_RIGHT ="Right";
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author "Federico De Faveri defaveri@isti.cnr.it"
|
||||
*
|
||||
*/
|
||||
public class Dataset implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8353499109124097114L;
|
||||
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String agencyId;
|
||||
protected String version;
|
||||
protected String description;
|
||||
|
||||
|
||||
public Dataset(){}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param name
|
||||
* @param agencyId
|
||||
*/
|
||||
public Dataset(String id, String name, String agencyId, String version, String description) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.agencyId = agencyId;
|
||||
this.version = version;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the agencyId
|
||||
*/
|
||||
public String getAgencyId() {
|
||||
return agencyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the version
|
||||
*/
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the version
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Codelist [id=");
|
||||
builder.append(id);
|
||||
builder.append(", name=");
|
||||
builder.append(name);
|
||||
builder.append(", agencyId=");
|
||||
builder.append(agencyId);
|
||||
builder.append(", version=");
|
||||
builder.append(version);
|
||||
builder.append(", description=");
|
||||
builder.append(description);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.shared;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* FieldVerifier validates that the name the user enters is valid.
|
||||
* </p>
|
||||
* <p>
|
||||
* This class is in the <code>shared</code> packing because we use it in both
|
||||
* the client code and on the server. On the client, we verify that the name is
|
||||
* valid before sending an RPC request so the user doesn't have to wait for a
|
||||
* network round trip to get feedback. On the server, we verify that the name is
|
||||
* correct to ensure that the input is correct regardless of where the RPC
|
||||
* originates.
|
||||
* </p>
|
||||
* <p>
|
||||
* When creating a class that is used on both the client and the server, be sure
|
||||
* that all code is translatable and does not use native JavaScript. Code that
|
||||
* is note translatable (such as code that interacts with a database or the file
|
||||
* system) cannot be compiled into client side JavaScript. Code that uses native
|
||||
* JavaScript (such as Widgets) cannot be run on the server.
|
||||
* </p>
|
||||
*/
|
||||
public class FieldVerifier {
|
||||
|
||||
/**
|
||||
* Verifies that the specified name is valid for our service.
|
||||
*
|
||||
* In this example, we only require that the name is at least four
|
||||
* characters. In your application, you can use more complex checks to ensure
|
||||
* that usernames, passwords, email addresses, URLs, and other fields have the
|
||||
* proper syntax.
|
||||
*
|
||||
* @param name the name to validate
|
||||
* @return true if valid, false if invalid
|
||||
*/
|
||||
public static boolean isValidName(String name) {
|
||||
if (name == null) {
|
||||
return false;
|
||||
}
|
||||
return name.length() > 3;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared;
|
||||
|
||||
/**
|
||||
* @author "Federico De Faveri defaveri@isti.cnr.it"
|
||||
*
|
||||
*/
|
||||
public class TDGXTServiceException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -9066034060104406559L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public TDGXTServiceException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
public TDGXTServiceException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class TDOpenSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4176034045408445284L;
|
||||
|
||||
protected String id;
|
||||
|
||||
protected TabResource selectedTabResource;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public TabResource getSelectedTabResource() {
|
||||
return selectedTabResource;
|
||||
}
|
||||
public void setSelectedTabResource(TabResource selectedTabResource) {
|
||||
this.selectedTabResource = selectedTabResource;
|
||||
}
|
||||
|
||||
|
||||
public String toString(){
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("TDOpenSession [getId()=");
|
||||
builder.append(getId());
|
||||
builder.append(", getSelectedTabResource()=");
|
||||
builder.append(getSelectedTabResource());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class TRId implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 192846115142001630L;
|
||||
|
||||
/**
|
||||
* Last table id of tabular resource
|
||||
*/
|
||||
String tableId;
|
||||
|
||||
/**
|
||||
* Tabular resource id
|
||||
*/
|
||||
String id;
|
||||
|
||||
/**
|
||||
* Item on Workspace
|
||||
*/
|
||||
String itemId;
|
||||
|
||||
public TRId(){
|
||||
|
||||
}
|
||||
|
||||
public TRId(String id){
|
||||
this.id=id;
|
||||
this.tableId=null;
|
||||
}
|
||||
|
||||
|
||||
public TRId(String id, String tableId){
|
||||
this.id=id;
|
||||
this.tableId=tableId;
|
||||
this.itemId=null;
|
||||
}
|
||||
|
||||
|
||||
public String getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
public void setTableId(String tableId) {
|
||||
this.tableId = tableId;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
public void setItemId(String itemId) {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TRId [tableId=" + tableId + ", id=" + id + ", itemId=" + itemId
|
||||
+ "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TRId;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class TabResource implements Serializable {
|
||||
|
||||
|
||||
|
||||
private static final long serialVersionUID = -8353499109124097114L;
|
||||
|
||||
protected int id;
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected String agency;
|
||||
protected String date;
|
||||
protected String right;
|
||||
protected TRId trId;
|
||||
|
||||
public TabResource(){}
|
||||
|
||||
public TabResource(int id, String name, String description,String agency, String date, String right, TRId trId){
|
||||
this.id=id;
|
||||
this.name=name;
|
||||
this.description=description;
|
||||
this.agency=agency;
|
||||
this.date=date;
|
||||
this.right=right;
|
||||
this.trId=trId;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAgency() {
|
||||
return agency;
|
||||
}
|
||||
|
||||
public void setAgency(String agency) {
|
||||
this.agency = agency;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
public void setRight(String right) {
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
public TRId getTrId() {
|
||||
return trId;
|
||||
}
|
||||
|
||||
public void setTrId(TRId trId) {
|
||||
this.trId = trId;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TabResource [id=" + id + ", name=" + name + ", description="
|
||||
+ description + ", agency=" + agency + ", date=" + date
|
||||
+ ", right=" + right + ", trId=" + trId + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared.csv;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author Federico De Faveri defaveri@isti.cnr.it
|
||||
*
|
||||
*/
|
||||
public class AvailableCharsetList implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1635081144303522534L;
|
||||
|
||||
protected ArrayList<String> charsetList;
|
||||
protected String defaultCharset;
|
||||
|
||||
protected AvailableCharsetList()
|
||||
{}
|
||||
|
||||
/**
|
||||
* @param charsetList
|
||||
* @param defaultCharset
|
||||
*/
|
||||
public AvailableCharsetList(ArrayList<String> charsetList, String defaultCharset) {
|
||||
this.charsetList = charsetList;
|
||||
this.defaultCharset = defaultCharset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the charsetList
|
||||
*/
|
||||
public ArrayList<String> getCharsetList() {
|
||||
return charsetList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the defaultCharset
|
||||
*/
|
||||
public String getDefaultCharset() {
|
||||
return defaultCharset;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,191 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared.csv;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.file.HeaderPresence;
|
||||
import org.mozilla.universalchardet.UniversalDetector;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.sf.csv4j.CSVReader;
|
||||
import net.sf.csv4j.ParseException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVFileUtil {
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(CSVFileUtil.class);
|
||||
|
||||
public static ArrayList<String> getHeader(File csvFile, CSVParserConfiguration parserConfiguration) throws ParseException, IOException
|
||||
{
|
||||
|
||||
CSVReader csvReader = createCSVReader(csvFile, parserConfiguration);
|
||||
switch (parserConfiguration.getHeaderPresence()) {
|
||||
case FIRST_LINE_COMMENTED_INCLUDED: {
|
||||
List<String> firstLine = getFirstLine(csvReader, true);
|
||||
return new ArrayList<String>(firstLine);
|
||||
}
|
||||
case FIRST_LINE: {
|
||||
List<String> firstLine = getFirstLine(csvReader, false);
|
||||
return new ArrayList<String>(firstLine);
|
||||
}
|
||||
case NONE: break;
|
||||
}
|
||||
|
||||
int fieldCount = (int) csvReader.countFields();
|
||||
ArrayList<String> fakeHeaders = new ArrayList<String>();
|
||||
for (int i = 0; i<fieldCount; i++) fakeHeaders.add("Field "+i);
|
||||
return fakeHeaders;
|
||||
|
||||
}
|
||||
|
||||
public static List<String> getFirstLine(CSVReader csvReader, boolean includeComment) throws ParseException, IOException
|
||||
{
|
||||
logger.trace("getFirstLine includeComment: "+includeComment);
|
||||
|
||||
List<String> header = csvReader.readLine(includeComment);
|
||||
return header==null?Collections.<String>emptyList():header;
|
||||
}
|
||||
|
||||
protected static CSVReader createCSVReader(File csvFile, CSVParserConfiguration parserConfiguration) throws FileNotFoundException
|
||||
{
|
||||
logger.trace("createCSVReader csvFile: "+csvFile+" parserConfiguration: "+parserConfiguration);
|
||||
Reader fileReader = new InputStreamReader(new FileInputStream(csvFile), parserConfiguration.getCharset());
|
||||
CSVReader csvReader = new CSVReader(fileReader, parserConfiguration.getDelimiter(), parserConfiguration.getComment());
|
||||
return csvReader;
|
||||
}
|
||||
|
||||
public static ArrayList<CSVRowError> checkCSV(File csvFile, CSVParserConfiguration config, long errorsLimit) throws ParseException, IOException
|
||||
{
|
||||
return checkCSV(csvFile, config.getCharset(), config.getDelimiter(), config.getComment(), errorsLimit);
|
||||
}
|
||||
|
||||
public static ArrayList<CSVRowError> checkCSV(File csvFile, Charset charset, char delimiter, char comment, long errorsLimit) throws IOException
|
||||
{
|
||||
logger.trace("checkCSV charset: "+charset+" delimiter: "+delimiter+" comment: "+comment);
|
||||
ArrayList<CSVRowError> errors = new ArrayList<CSVRowError>();
|
||||
|
||||
Reader fileReader = new InputStreamReader(new FileInputStream(csvFile), charset);
|
||||
CSVReader csvReader = new CSVReader(fileReader, delimiter, comment);
|
||||
long count = -1;
|
||||
long fields = -1;
|
||||
|
||||
do{
|
||||
try{
|
||||
count = csvReader.countFields();
|
||||
}catch(ParseException exception)
|
||||
{
|
||||
StringBuilder errorMessage = new StringBuilder();
|
||||
errorMessage.append("Error parsing the file ");
|
||||
errorMessage.append(exception.getMessage());
|
||||
|
||||
CSVRowError error = new CSVRowError(csvReader.getLineNumber(), csvReader.getCurrentLine(), errorMessage.toString());
|
||||
errors.add(error);
|
||||
logger.trace(error.getErrorDescription());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count>=0){
|
||||
if (fields<0 ) fields = count;
|
||||
else if (fields != count) {
|
||||
StringBuilder errorMessage = new StringBuilder();
|
||||
errorMessage.append("Expected ");
|
||||
errorMessage.append(fields);
|
||||
errorMessage.append(" fields, found ");
|
||||
errorMessage.append(count);
|
||||
errorMessage.append(" fields. Check the format of your input file.");
|
||||
CSVRowError error = new CSVRowError(csvReader.getLineNumber(), csvReader.getCurrentLine(), errorMessage.toString());
|
||||
errors.add(error);
|
||||
logger.trace(error.getErrorDescription());
|
||||
}
|
||||
}
|
||||
|
||||
}while(count >=0 && errors.size()<errorsLimit);
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
public static void toJson(File csvFile, Charset inputCharset, File outputFile, Charset outputCharset, HeaderPresence headerPresence, char delimiter, char comment, long limit) throws ParseException, IOException
|
||||
{
|
||||
toJson(new FileInputStream(csvFile), inputCharset, new FileOutputStream(outputFile), outputCharset, headerPresence, delimiter, comment, limit);
|
||||
}
|
||||
|
||||
public static void toJson(InputStream csv, OutputStream output, Charset outputCharset, CSVParserConfiguration config, long limit) throws ParseException, IOException
|
||||
{
|
||||
toJson(csv, config.getCharset(), output, outputCharset, config.getHeaderPresence(), config.getDelimiter(), config.getComment(), limit);
|
||||
}
|
||||
|
||||
public static void toJson(InputStream csv, Charset inputCharset, OutputStream output, Charset outputCharset, HeaderPresence headerPresence, char delimiter, char comment, long limit) throws ParseException, IOException
|
||||
{
|
||||
logger.trace("toJson charset: "+inputCharset+" delimiter: "+delimiter+" comment: "+comment);
|
||||
Writer writer = new BufferedWriter(new OutputStreamWriter(output, outputCharset));
|
||||
Reader reader = new InputStreamReader(csv, inputCharset);
|
||||
CSVReader csvReader = new CSVReader(reader, delimiter, comment);
|
||||
String jsonLine;
|
||||
long count = 0;
|
||||
|
||||
if (headerPresence!=HeaderPresence.NONE) {
|
||||
csvReader.readLine(headerPresence==HeaderPresence.FIRST_LINE_COMMENTED_INCLUDED);
|
||||
}
|
||||
|
||||
writer.write("{\"records\":[");
|
||||
while((jsonLine = csvReader.readJSonLine())!=null){
|
||||
|
||||
if (count>0) writer.write(",");
|
||||
writer.write(jsonLine);
|
||||
count++;
|
||||
|
||||
if (count>limit) break;
|
||||
}
|
||||
|
||||
writer.write("]}");
|
||||
|
||||
csvReader.close();
|
||||
writer.close();
|
||||
|
||||
}
|
||||
|
||||
public static String guessEncoding(File file) throws IOException
|
||||
{
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
UniversalDetector detector = new UniversalDetector(null);
|
||||
byte[] buf = new byte[4096];
|
||||
|
||||
int nread;
|
||||
while ((nread = fis.read(buf)) > 0 && !detector.isDone()) {
|
||||
detector.handleData(buf, 0, nread);
|
||||
}
|
||||
|
||||
detector.dataEnd();
|
||||
String encoding = detector.getDetectedCharset();
|
||||
detector.reset();
|
||||
fis.close();
|
||||
|
||||
return encoding;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared.csv;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVImportMonitor implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1150111422206443617L;
|
||||
|
||||
protected long totalLenght;
|
||||
protected long elaboratedLenght;
|
||||
protected CSVImportState state;
|
||||
protected String failureReason;
|
||||
protected String failureDetails;
|
||||
|
||||
public CSVImportMonitor(){
|
||||
state = CSVImportState.STARTED;
|
||||
}
|
||||
|
||||
public CSVImportMonitor(long totalLenght, long elaboratedLenght, CSVImportState state, String failureReason) {
|
||||
this.totalLenght = totalLenght;
|
||||
this.elaboratedLenght = elaboratedLenght;
|
||||
this.state = state;
|
||||
this.failureReason = failureReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the totalLenght
|
||||
*/
|
||||
public long getTotalLenght() {
|
||||
return totalLenght;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the elaboratedLenght
|
||||
*/
|
||||
public long getElaboratedLenght() {
|
||||
return elaboratedLenght;
|
||||
}
|
||||
|
||||
|
||||
public CSVImportState getState(){
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the failureDetails
|
||||
*/
|
||||
public String getFailureDetails() {
|
||||
return failureDetails;
|
||||
}
|
||||
|
||||
public void setState(CSVImportState state)
|
||||
{
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the reason
|
||||
*/
|
||||
public String getFailureReason() {
|
||||
return failureReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param totalLenght the totalLenght to set
|
||||
*/
|
||||
public void setTotalLenght(long totalLenght) {
|
||||
this.totalLenght = totalLenght;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param elaboratedLenght the elaboratedLenght to set
|
||||
*/
|
||||
public void setElaboratedLenght(long elaboratedLenght) {
|
||||
this.elaboratedLenght = elaboratedLenght;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param failed the failed to set
|
||||
*/
|
||||
public void setFailed(String failureReason, String failureDetails) {
|
||||
this.state = CSVImportState.FAILED;
|
||||
this.failureReason = failureReason;
|
||||
this.failureDetails = failureDetails;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CSVImportMonitor [totalLenght=" + totalLenght
|
||||
+ ", elaboratedLenght=" + elaboratedLenght + ", state=" + state
|
||||
+ ", failureReason=" + failureReason + ", failureDetails="
|
||||
+ failureDetails + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared.csv;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TabResource;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.source.Source;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVImportSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4176034045408445284L;
|
||||
|
||||
protected String id;
|
||||
protected Source source;
|
||||
|
||||
protected TabResource tabResource;
|
||||
|
||||
protected ArrayList<String> headers = new ArrayList<String>();
|
||||
|
||||
protected boolean skipInvalidLines = false;
|
||||
|
||||
protected boolean[] columnToImportMask;
|
||||
|
||||
protected String localFileName;
|
||||
protected long fileLenght;
|
||||
protected String serverlFileName;
|
||||
|
||||
protected String csvTitle;
|
||||
protected String csvDescription;
|
||||
protected String csvSource;
|
||||
protected String csvRights;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Source getSource() {
|
||||
return source;
|
||||
}
|
||||
public void setSource(Source source) {
|
||||
this.source = source;
|
||||
}
|
||||
public TabResource getTabResource() {
|
||||
return tabResource;
|
||||
}
|
||||
public void setTabResource(TabResource tabResource) {
|
||||
this.tabResource = tabResource;
|
||||
}
|
||||
public ArrayList<String> getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
public void setHeaders(ArrayList<String> headers) {
|
||||
this.headers = headers;
|
||||
}
|
||||
public boolean isSkipInvalidLines() {
|
||||
return skipInvalidLines;
|
||||
}
|
||||
public void setSkipInvalidLines(boolean skipInvalidLines) {
|
||||
this.skipInvalidLines = skipInvalidLines;
|
||||
}
|
||||
public boolean[] getColumnToImportMask() {
|
||||
return columnToImportMask;
|
||||
}
|
||||
public void setColumnToImportMask(boolean[] columnToImportMask) {
|
||||
this.columnToImportMask = columnToImportMask;
|
||||
}
|
||||
public String getLocalFileName() {
|
||||
return localFileName;
|
||||
}
|
||||
public void setLocalFileName(String localFileName) {
|
||||
this.localFileName = localFileName;
|
||||
}
|
||||
public long getFileLenght() {
|
||||
return fileLenght;
|
||||
}
|
||||
public void setFileLenght(long fileLenght) {
|
||||
this.fileLenght = fileLenght;
|
||||
}
|
||||
public String getServerlFileName() {
|
||||
return serverlFileName;
|
||||
}
|
||||
public void setServerlFileName(String serverlFileName) {
|
||||
this.serverlFileName = serverlFileName;
|
||||
}
|
||||
public String getCsvTitle() {
|
||||
return csvTitle;
|
||||
}
|
||||
public void setCsvTitle(String csvTitle) {
|
||||
this.csvTitle = csvTitle;
|
||||
}
|
||||
public String getCsvDescription() {
|
||||
return csvDescription;
|
||||
}
|
||||
public void setCsvDescription(String csvDescription) {
|
||||
this.csvDescription = csvDescription;
|
||||
}
|
||||
public String getCsvSource() {
|
||||
return csvSource;
|
||||
}
|
||||
public void setCsvSource(String csvSource) {
|
||||
this.csvSource = csvSource;
|
||||
}
|
||||
public String getCsvRights() {
|
||||
return csvRights;
|
||||
}
|
||||
public void setCsvRights(String csvRights) {
|
||||
this.csvRights = csvRights;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CSVImportSession [id=" + id + ", source=" + source
|
||||
+ ", tabResource=" + tabResource + ", headers=" + headers
|
||||
+ ", skipInvalidLines=" + skipInvalidLines
|
||||
+ ", columnToImportMask=" + Arrays.toString(columnToImportMask)
|
||||
+ ", localFileName=" + localFileName + ", fileLenght="
|
||||
+ fileLenght + ", serverlFileName=" + serverlFileName
|
||||
+ ", csvTitle=" + csvTitle + ", csvDescription="
|
||||
+ csvDescription + ", csvSource=" + csvSource + ", csvRights="
|
||||
+ csvRights + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared.csv;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public enum CSVImportState {
|
||||
|
||||
/**
|
||||
* The operation is in progress.
|
||||
*/
|
||||
STARTED,
|
||||
/**
|
||||
* The operation is in progress.
|
||||
*/
|
||||
INPROGRESS,
|
||||
|
||||
/**
|
||||
* The operation is completed.
|
||||
*/
|
||||
COMPLETED,
|
||||
|
||||
/**
|
||||
* The operation is failed.
|
||||
*/
|
||||
FAILED;
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared.csv;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.file.HeaderPresence;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author Federico De Faveri defaveri@isti.cnr.it
|
||||
*
|
||||
*/
|
||||
public class CSVParserConfiguration {
|
||||
|
||||
protected Charset charset;
|
||||
protected char delimiter;
|
||||
protected char comment;
|
||||
protected HeaderPresence headerPresence;
|
||||
|
||||
public CSVParserConfiguration() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param charset
|
||||
* @param delimiter
|
||||
* @param comment
|
||||
* @param hasHeader
|
||||
*/
|
||||
public CSVParserConfiguration(Charset charset, char delimiter, char comment, HeaderPresence headerPresence) {
|
||||
this.charset = charset;
|
||||
this.delimiter = delimiter;
|
||||
this.comment = comment;
|
||||
this.headerPresence = headerPresence;
|
||||
}
|
||||
|
||||
public void update(String charset, char delimiter, char comment, HeaderPresence headerPresence) {
|
||||
this.charset = Charset.forName(charset);
|
||||
this.delimiter = delimiter;
|
||||
this.comment = comment;
|
||||
this.headerPresence = headerPresence;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the charset
|
||||
*/
|
||||
public Charset getCharset() {
|
||||
return charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the delimiter
|
||||
*/
|
||||
public char getDelimiter() {
|
||||
return delimiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the comment
|
||||
*/
|
||||
public char getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the headerPresence
|
||||
*/
|
||||
public HeaderPresence getHeaderPresence() {
|
||||
return headerPresence;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CSVParsingConfig [charset=");
|
||||
builder.append(charset);
|
||||
builder.append(", delimiter=");
|
||||
builder.append(delimiter);
|
||||
builder.append(", comment=");
|
||||
builder.append(comment);
|
||||
builder.append(", headerPresence=");
|
||||
builder.append(headerPresence);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared.csv;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* An error for a row in the CSV.
|
||||
* @author Federico De Faveri defaveri@isti.cnr.it
|
||||
*/
|
||||
public class CSVRowError implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4680781887858741657L;
|
||||
|
||||
protected static int seed;
|
||||
|
||||
protected int id;
|
||||
protected int lineNumber;
|
||||
protected String lineValue;
|
||||
protected String errorDescription;
|
||||
|
||||
public CSVRowError(){}
|
||||
|
||||
/**
|
||||
* @param lineNumber the row number.
|
||||
* @param lineValue the line value.
|
||||
* @param errorDescription the error description.
|
||||
*/
|
||||
public CSVRowError(int lineNumber, String lineValue, String errorDescription) {
|
||||
this.id = seed++;
|
||||
this.lineNumber = lineNumber;
|
||||
this.lineValue = lineValue;
|
||||
this.errorDescription = errorDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lineNumber
|
||||
*/
|
||||
public int getLineNumber() {
|
||||
return lineNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the line value
|
||||
*/
|
||||
public String getLineValue() {
|
||||
return lineValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the error description.
|
||||
*/
|
||||
public String getErrorDescription() {
|
||||
return errorDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CSVRowError [lineNumber=");
|
||||
builder.append(lineNumber);
|
||||
builder.append(", lineValue=");
|
||||
builder.append(lineValue);
|
||||
builder.append(", errorDescription=");
|
||||
builder.append(errorDescription);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.shared.document;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CodelistDocument implements SDMXDocument {
|
||||
|
||||
private static final long serialVersionUID = 8732679674877915333L;
|
||||
|
||||
public static final CodelistDocument INSTANCE = new CodelistDocument();
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return "codelist";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Codelist document";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Select this document if you want to retrive codelist";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Codelist Document [getId()=");
|
||||
builder.append(getId());
|
||||
builder.append(", getName()=");
|
||||
builder.append(getName());
|
||||
builder.append(", getDescription()=");
|
||||
builder.append(getDescription());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.shared.document;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DatasetDocument implements SDMXDocument {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 6134053739629827095L;
|
||||
|
||||
public static final DatasetDocument INSTANCE = new DatasetDocument();
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return "dataset";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Dataset document";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Select this document if you want to retrive dataset";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("DataSet Document [getId()=");
|
||||
builder.append(getId());
|
||||
builder.append(", getName()=");
|
||||
builder.append(getName());
|
||||
builder.append(", getDescription()=");
|
||||
builder.append(getDescription());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared.document;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* SDMX document type interface. All SDMX document type have to implement this interface.
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface SDMXDocument extends Serializable {
|
||||
|
||||
/**
|
||||
* Returns the document id.
|
||||
* @return the document id.
|
||||
*/
|
||||
public String getId();
|
||||
|
||||
/**
|
||||
* Returns the document name.
|
||||
* @return the document name.
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Returns the document description.
|
||||
* @return the document description.
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared.file;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class FileUploadMonitor implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1150111422206443617L;
|
||||
|
||||
protected long totalLenght;
|
||||
protected long elaboratedLenght;
|
||||
protected FileUploadState state;
|
||||
protected String failureReason;
|
||||
protected String failureDetails;
|
||||
|
||||
public FileUploadMonitor(){
|
||||
state = FileUploadState.INPROGRESS;
|
||||
}
|
||||
|
||||
public FileUploadMonitor(long totalLenght, long elaboratedLenght, FileUploadState state, String failureReason) {
|
||||
this.totalLenght = totalLenght;
|
||||
this.elaboratedLenght = elaboratedLenght;
|
||||
this.state = state;
|
||||
this.failureReason = failureReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the totalLenght
|
||||
*/
|
||||
public long getTotalLenght() {
|
||||
return totalLenght;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the elaboratedLenght
|
||||
*/
|
||||
public long getElaboratedLenght() {
|
||||
return elaboratedLenght;
|
||||
}
|
||||
|
||||
|
||||
public FileUploadState getState(){
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the failureDetails
|
||||
*/
|
||||
public String getFailureDetails() {
|
||||
return failureDetails;
|
||||
}
|
||||
|
||||
public void setState(FileUploadState state)
|
||||
{
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the reason
|
||||
*/
|
||||
public String getFailureReason() {
|
||||
return failureReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param totalLenght the totalLenght to set
|
||||
*/
|
||||
public void setTotalLenght(long totalLenght) {
|
||||
this.totalLenght = totalLenght;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param elaboratedLenght the elaboratedLenght to set
|
||||
*/
|
||||
public void setElaboratedLenght(long elaboratedLenght) {
|
||||
this.elaboratedLenght = elaboratedLenght;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param failed the failed to set
|
||||
*/
|
||||
public void setFailed(String failureReason, String failureDetails) {
|
||||
this.state = FileUploadState.FAILED;
|
||||
this.failureReason = failureReason;
|
||||
this.failureDetails = failureDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("OperationProgress [totalLenght=");
|
||||
builder.append(totalLenght);
|
||||
builder.append(", elaboratedLenght=");
|
||||
builder.append(elaboratedLenght);
|
||||
builder.append(", state=");
|
||||
builder.append(state);
|
||||
builder.append(", failureReason=");
|
||||
builder.append(failureReason);
|
||||
builder.append(", failureDetails=");
|
||||
builder.append(failureDetails);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared.file;
|
||||
|
||||
/**
|
||||
* @author Federico De Faveri defaveri@isti.cnr.it
|
||||
*
|
||||
*/
|
||||
public enum FileUploadState {
|
||||
|
||||
STARTED,
|
||||
|
||||
/**
|
||||
* The operation is in progress.
|
||||
*/
|
||||
INPROGRESS,
|
||||
|
||||
/**
|
||||
* The operation is completed.
|
||||
*/
|
||||
COMPLETED,
|
||||
|
||||
/**
|
||||
* The operation is failed.
|
||||
*/
|
||||
FAILED;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared.file;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public enum HeaderPresence {
|
||||
|
||||
NONE("None"),
|
||||
FIRST_LINE("First line"),
|
||||
FIRST_LINE_COMMENTED_INCLUDED("First line, include commented");
|
||||
|
||||
protected String label;
|
||||
|
||||
private HeaderPresence(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public static HeaderPresence fromLabel(String label)
|
||||
{
|
||||
for (HeaderPresence headerPresence:HeaderPresence.values()) {
|
||||
if (headerPresence.label.equals(label)) return headerPresence;
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown label value \""+label+"\"");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.shared.sdmx;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TRId;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SDMXImportMonitor implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5998841163159590481L;
|
||||
|
||||
protected float progress;
|
||||
protected State status;
|
||||
protected String statusDescription;
|
||||
protected Throwable error;
|
||||
protected TRId trId;
|
||||
|
||||
public float getProgress(){
|
||||
return progress;
|
||||
};
|
||||
|
||||
public State getStatus(){
|
||||
return status;
|
||||
}
|
||||
|
||||
public String getStatusDescription(){
|
||||
return statusDescription;
|
||||
}
|
||||
|
||||
public void setProgress(float progress) {
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
public void setStatus(State status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = State.values()[status];
|
||||
}
|
||||
|
||||
public void setStatusDescription(String statusDescription) {
|
||||
this.statusDescription = statusDescription;
|
||||
}
|
||||
|
||||
public Throwable getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(Throwable error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public TRId getTrId() {
|
||||
return trId;
|
||||
}
|
||||
|
||||
public void setTrId(TRId trId) {
|
||||
this.trId = trId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SDMXImportMonitor [progress=" + progress + ", status=" + status
|
||||
+ ", statusDescription=" + statusDescription + ", error="
|
||||
+ error + ", trId=" + trId + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gxtservice.shared.sdmx;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.Codelist;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TabResource;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.document.SDMXDocument;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.source.Source;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SDMXImportSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4176034045408445284L;
|
||||
|
||||
protected String id;
|
||||
protected SDMXDocument sdmxDocument;//operationID
|
||||
protected Source source;
|
||||
protected Codelist selectedCodelist;
|
||||
protected TabResource tabResource;
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public SDMXDocument getSDMXDocument() {
|
||||
return sdmxDocument;
|
||||
}
|
||||
public void setSDMXDocument(SDMXDocument document) {
|
||||
this.sdmxDocument = document;
|
||||
}
|
||||
public Source getSource() {
|
||||
return source;
|
||||
}
|
||||
public void setSource(Source source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
||||
public Codelist getSelectedCodelist() {
|
||||
return selectedCodelist;
|
||||
}
|
||||
public void setSelectedCodelist(Codelist selectedCodelist) {
|
||||
this.selectedCodelist = selectedCodelist;
|
||||
}
|
||||
|
||||
|
||||
public TabResource getTabResource() {
|
||||
return tabResource;
|
||||
}
|
||||
public void setTabResource(TabResource tabResource) {
|
||||
this.tabResource = tabResource;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SDMXImportSession [id=" + id + ", sdmxDocument=" + sdmxDocument
|
||||
+ ", source=" + source + ", selectedCodelist="
|
||||
+ selectedCodelist + ", tabResource=" + tabResource + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.shared.sdmx;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
public enum State implements Serializable{
|
||||
|
||||
WAITING,
|
||||
INITIALIZING,
|
||||
IN_PROGRESS,
|
||||
SUCCEDED,
|
||||
FAILED,
|
||||
ABORTED;
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.shared.source;
|
||||
|
||||
|
||||
|
||||
public class FileSource implements Source {
|
||||
|
||||
|
||||
private static final long serialVersionUID = -5990408094142286488L;
|
||||
|
||||
public static final FileSource INSTANCE = new FileSource();
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return "File";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "File source";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Select this source if you want to retrive document from File";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("File source [getId()=");
|
||||
builder.append(getId());
|
||||
builder.append(", getName()=");
|
||||
builder.append(getName());
|
||||
builder.append(", getDescription()=");
|
||||
builder.append(getDescription());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.shared.source;
|
||||
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.source.Source;
|
||||
|
||||
|
||||
|
||||
|
||||
public class SDMXRegistrySource implements Source {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 3254879141340681969L;
|
||||
|
||||
public static final SDMXRegistrySource INSTANCE = new SDMXRegistrySource();
|
||||
|
||||
protected String url;
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return "SDMXRegistry";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "SDMX Registry source";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Select this source if you want to retrive document from SDMX Registry";
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SDMXRegistry source [getId()=");
|
||||
builder.append(getId());
|
||||
builder.append(", getName()=");
|
||||
builder.append(getName());
|
||||
builder.append(", getDescription()=");
|
||||
builder.append(getDescription());
|
||||
builder.append(", getUrl()=");
|
||||
builder.append(getUrl());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.shared.source;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
public interface Source extends Serializable {
|
||||
|
||||
/**
|
||||
* Returns the document type id.
|
||||
* @return the document type id.
|
||||
*/
|
||||
public String getId();
|
||||
|
||||
/**
|
||||
* Returns the document type name.
|
||||
* @return the document type name.
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Returns the document type description.
|
||||
* @return the document type description.
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.shared.source;
|
||||
|
||||
|
||||
|
||||
|
||||
public class WorkspaceSource implements Source {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 2826706131664617270L;
|
||||
|
||||
public static final WorkspaceSource INSTANCE = new WorkspaceSource();
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return "Workspace";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Workspace source";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Select this source if you want to retrive document from Workspace";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Workspace source [getId()=");
|
||||
builder.append(getId());
|
||||
builder.append(", getName()=");
|
||||
builder.append(getName());
|
||||
builder.append(", getDescription()=");
|
||||
builder.append(getDescription());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module rename-to='GXTService'>
|
||||
<!-- Inherit the core Web Toolkit stuff. -->
|
||||
<inherits name='com.google.gwt.user.User' />
|
||||
|
||||
<!-- We need the JUnit module in the main module, -->
|
||||
<!-- otherwise eclipse complains (Google plugin bug?) -->
|
||||
<inherits name='com.google.gwt.junit.JUnit' />
|
||||
|
||||
<!-- Inherit the default GWT style sheet. You can change -->
|
||||
<!-- the theme of your GWT application by uncommenting -->
|
||||
<!-- any one of the following lines. -->
|
||||
<inherits name='com.google.gwt.user.theme.standard.Standard' />
|
||||
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
|
||||
|
||||
<!-- Other module inherits -->
|
||||
<inherits name='com.sencha.gxt.ui.GXT' />
|
||||
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
|
||||
<inherits name="com.google.gwt.resources.Resources" />
|
||||
|
||||
<!-- Specify the app entry point class. -->
|
||||
<!-- <entry-point class='org.gcube.portlets.user.td.information.client.InformationEntry' /> -->
|
||||
|
||||
<!-- Specify the paths for translatable code -->
|
||||
<source path='client' />
|
||||
<source path='shared' />
|
||||
|
||||
</module>
|
|
@ -0,0 +1,2 @@
|
|||
sendButton = Send
|
||||
nameField = Enter your name
|
|
@ -0,0 +1,2 @@
|
|||
sendButton = Envoyer
|
||||
nameField = Entrez votre nom
|
|
@ -0,0 +1,34 @@
|
|||
/** Add css rules here for your application. */
|
||||
|
||||
|
||||
/** Example rules used by the template application (remove for your app) */
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
font-weight: bold;
|
||||
color: #777777;
|
||||
margin: 40px 0px 70px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sendButton {
|
||||
display: block;
|
||||
font-size: 16pt;
|
||||
}
|
||||
|
||||
/** Most GWT widgets already have a style name defined */
|
||||
.gwt-DialogBox {
|
||||
width: 400px;
|
||||
}
|
||||
|
||||
.dialogVPanel {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.serverResponseLabelError {
|
||||
color: red;
|
||||
}
|
||||
|
||||
/** Set ids using widget.getElement().setId("idOfElement") */
|
||||
#closeButton {
|
||||
margin: 15px 6px 6px;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
<!doctype html>
|
||||
<!-- The DOCTYPE declaration above will set the -->
|
||||
<!-- browser's rendering engine into -->
|
||||
<!-- "Standards Mode". Replacing this declaration -->
|
||||
<!-- with a "Quirks Mode" doctype may lead to some -->
|
||||
<!-- differences in layout. -->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
|
||||
<!-- -->
|
||||
<!-- Consider inlining CSS to reduce the number of requested files -->
|
||||
<!-- -->
|
||||
<link type="text/css" rel="stylesheet" href="GXTService.css">
|
||||
|
||||
<!-- -->
|
||||
<!-- Any title is fine -->
|
||||
<!-- -->
|
||||
<title>Web Application Starter Project</title>
|
||||
|
||||
<!-- -->
|
||||
<!-- This script loads your compiled module. -->
|
||||
<!-- If you add any GWT meta tags, they must -->
|
||||
<!-- be added before this line. -->
|
||||
<!-- -->
|
||||
<script type="text/javascript" language="javascript" src="GXTService/GXTService.nocache.js"></script>
|
||||
</head>
|
||||
|
||||
<!-- -->
|
||||
<!-- The body can have arbitrary html, or -->
|
||||
<!-- you can leave the body empty if you want -->
|
||||
<!-- to create a completely dynamic UI. -->
|
||||
<!-- -->
|
||||
<body>
|
||||
|
||||
<!-- OPTIONAL: include this if you want history support -->
|
||||
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
|
||||
|
||||
<!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
|
||||
<noscript>
|
||||
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
|
||||
Your web browser must have JavaScript enabled
|
||||
in order for this application to display correctly.
|
||||
</div>
|
||||
</noscript>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE web-app
|
||||
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||
"http://java.sun.com/dtd/web-app_2_3.dtd">
|
||||
|
||||
<web-app>
|
||||
|
||||
<!-- Servlets -->
|
||||
<servlet>
|
||||
<servlet-name>TDGXTService</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.td.gxtservice.server.TDGXTServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>CSVImportFileServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.td.gxtservice.server.CSVImportFileServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>LocalUploadServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.td.gxtservice.server.LocalUploadServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>jUnitHostImpl</servlet-name>
|
||||
<servlet-class>com.google.gwt.junit.server.JUnitHostImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
|
||||
|
||||
<!-- Servlets Mapping -->
|
||||
<servlet-mapping>
|
||||
<servlet-name>TDGXTService</servlet-name>
|
||||
<url-pattern>/tdgxtservice/TDGXTService</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>CSVImportFileServlet</servlet-name>
|
||||
<url-pattern>/tdgxtservice/CSVImportFileServlet</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>LocalUploadServlet</servlet-name>
|
||||
<url-pattern>/tdgxtservice/LocalUploadServlet</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>jUnitHostImpl</servlet-name>
|
||||
<url-pattern>TDServiceManagerWidgets/junithost/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<!-- Default page to serve -->
|
||||
<welcome-file-list>
|
||||
<welcome-file>Service.html</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
</web-app>
|
|
@ -0,0 +1,76 @@
|
|||
package org.gcube.portlets.user.td.gxtservice.client;
|
||||
|
||||
import org.gcube.portlets.user.td.gxtservice.client.rpc.TDGXTService;
|
||||
import org.gcube.portlets.user.td.gxtservice.client.rpc.TDGXTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TabResource;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.junit.client.GWTTestCase;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.rpc.ServiceDefTarget;
|
||||
|
||||
/**
|
||||
* GWT JUnit <b>integration</b> tests must extend GWTTestCase. Using
|
||||
* <code>"GwtTest*"</code> naming pattern exclude them from running with
|
||||
* surefire during the test phase.
|
||||
*
|
||||
* If you run the tests using the Maven command line, you will have to navigate
|
||||
* with your browser to a specific url given by Maven. See
|
||||
* http://mojo.codehaus.org/gwt-maven-plugin/user-guide/testing.html for
|
||||
* details.
|
||||
*/
|
||||
public class GwtTestGXTService extends GWTTestCase {
|
||||
|
||||
/**
|
||||
* Must refer to a valid module that sources this class.
|
||||
*/
|
||||
public String getModuleName() {
|
||||
return "org.gcube.portlets.user.td.gxtservice.GXTServiceJUnit";
|
||||
}
|
||||
|
||||
/**
|
||||
* This test will send a request to the server
|
||||
*/
|
||||
public void testCreateTabResource() {
|
||||
// Create the service that we will test.
|
||||
TDGXTServiceAsync tdGXTService = GWT.create(TDGXTService.class);
|
||||
ServiceDefTarget target = (ServiceDefTarget) tdGXTService;
|
||||
System.out.println(GWT.getModuleBaseURL() + "TDGXTService");
|
||||
target.setServiceEntryPoint(GWT.getModuleBaseURL() + "TDGXTService");
|
||||
|
||||
// Since RPC calls are asynchronous, we will need to wait for a response
|
||||
// after this test method returns. This line tells the test runner to
|
||||
// wait
|
||||
// up to 7 seconds before timing out.
|
||||
delayTestFinish(7000);
|
||||
TabResource tabResource=new TabResource();
|
||||
tabResource.setName("TestTabularResource");
|
||||
tabResource.setAgency("FAO");
|
||||
tabResource.setDescription("Tabular Resource Test");
|
||||
tabResource.setRight("");
|
||||
|
||||
// Send a request to the server.
|
||||
TDGXTServiceAsync.INSTANCE.createTabularResource(tabResource,new AsyncCallback<TabResource>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// The request resulted in an unexpected error.
|
||||
fail("Request failure: " + caught.getMessage());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(TabResource result) {
|
||||
assertTrue(result != null);
|
||||
System.out.println(result);
|
||||
finishTest();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module rename-to="GXTServiceJUnit">
|
||||
<!-- Inherit our applications main module. -->
|
||||
<inherits name='org.gcube.portlets.user.td.gxtservice.GXTService' />
|
||||
|
||||
<!-- Specify the path to any remote services. -->
|
||||
<servlet path="/TDGXTService"
|
||||
class="org.gcube.portlets.user.td.gxtservice.server.TDGXTServiceImpl" />
|
||||
|
||||
|
||||
<!-- Specify the paths for translatable code -->
|
||||
<source path='client' />
|
||||
</module>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
gCube System - License
|
||||
------------------------------------------------------------
|
||||
|
||||
The gCube/gCore software is licensed as Free Open Source software conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
|
||||
The software and documentation is provided by its authors/distributors "as is" and no expressed or
|
||||
implied warranty is given for its use, quality or fitness for a particular case.
|
|
@ -0,0 +1 @@
|
|||
Giancarlo Panichi (giancarlo.panichi@isti.cnr.it), CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"
|
|
@ -0,0 +1,40 @@
|
|||
The gCube System - ${name}
|
||||
------------------------------------------------------------
|
||||
|
||||
This work has been supported by the following European projects: iMarine (FP7-INFRASTRUCTURES-2011-2)
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
Giancarlo Panichi (giancarlo.panichi@isti.cnr.it), CNR Pisa,
|
||||
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"
|
||||
|
||||
|
||||
Version and Release Date
|
||||
------------------------
|
||||
|
||||
v. ${version} (${release.date})
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
${project.description}
|
||||
|
||||
Download information
|
||||
--------------------
|
||||
Source code URL: ${scm.url}
|
||||
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
${project.description}
|
||||
|
||||
|
||||
Licensing
|
||||
---------
|
||||
|
||||
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.portlets-user.gxtservice.1-0-0"
|
||||
date="2013-10-18">
|
||||
<Change>First Release</Change>
|
||||
</Changeset>
|
||||
</ReleaseNotes>
|
|
@ -0,0 +1,39 @@
|
|||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>servicearchive</id>
|
||||
<formats>
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
<baseDirectory>/</baseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${distroDirectory}</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<useDefaultExcludes>true</useDefaultExcludes>
|
||||
<includes>
|
||||
<include>README</include>
|
||||
<include>LICENSE</include>
|
||||
<include>INSTALL</include>
|
||||
<include>MAINTAINERS</include>
|
||||
<include>changelog.xml</include>
|
||||
</includes>
|
||||
<fileMode>755</fileMode>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
<files>
|
||||
<file>
|
||||
<source>${distroDirectory}/svnpath.txt</source>
|
||||
<outputDirectory>/${artifactId}</outputDirectory>
|
||||
</file>
|
||||
<file>
|
||||
<source>${configDirectory}/profile.xml</source>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
</file>
|
||||
<file>
|
||||
<source>target/${build.finalName}.${packaging}</source>
|
||||
<outputDirectory>/${artifactId}</outputDirectory>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Resource>
|
||||
<ID></ID>
|
||||
<Type>Service</Type>
|
||||
<Profile>
|
||||
<Description>${project.description}</Description>
|
||||
<Class>PortletsUser</Class>
|
||||
<Name>${project.name}</Name>
|
||||
<Version>1.0.0</Version>
|
||||
<Packages>
|
||||
<Software>
|
||||
<Description>${project.description}</Description>
|
||||
<Name>${project.name}</Name>
|
||||
<Version>${version}</Version>
|
||||
<MavenCoordinates>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>${project.artifactId}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</MavenCoordinates>
|
||||
<Type>library</Type>
|
||||
<Files>
|
||||
<File>${project.build.finalName}.${project.packaging}</File>
|
||||
</Files>
|
||||
</Software>
|
||||
</Packages>
|
||||
</Profile>
|
||||
</Resource>
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
${scm.url}
|
Loading…
Reference in New Issue