Lucio Lelii 2015-02-12 17:44:58 +00:00
parent 8e59d0c7fd
commit 52c1187f89
49 changed files with 364 additions and 206 deletions

View File

@ -11,15 +11,15 @@
<Software>
<Description>Module that declares the interface of the cube manager</Description>
<Name>cube-manager-api</Name>
<Version>3.5.0-SNAPSHOT</Version>
<Version>3.5.2-SNAPSHOT</Version>
<MavenCoordinates>
<groupId>org.gcube.data.analysis.tabulardata</groupId>
<artifactId>cube-manager-api</artifactId>
<version>3.5.0-SNAPSHOT</version>
<version>3.5.2-SNAPSHOT</version>
</MavenCoordinates>
<Type>library</Type>
<Files>
<File>cube-manager-api-3.5.0-SNAPSHOT.jar</File>
<File>cube-manager-api-3.5.2-SNAPSHOT.jar</File>
</Files>
</Software>
</Packages>

View File

@ -12,7 +12,7 @@ Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo".
Version and Release Date
------------------------
v. 3.5.0-SNAPSHOT (2013-10-21)
v. 3.5.2-SNAPSHOT (2013-10-21)
Description
-----------

View File

@ -4,7 +4,7 @@
<parent>
<groupId>org.gcube.data.analysis.tabulardata</groupId>
<artifactId>cube-manager-parent</artifactId>
<version>3.5.1-SNAPSHOT</version>
<version>3.5.2-SNAPSHOT</version>
</parent>
<artifactId>cube-manager-api</artifactId>
<name>Cube Manager API</name>

View File

@ -38,11 +38,13 @@ public interface CubeManager {
public Collection<Table> getTables(TableType tableType);
public Table getTimeTable(PeriodType periodType) throws NoSuchTableException;
public Table getTable(TableId id) throws NoSuchTableException;
public void removeTable(TableId id) throws NoSuchTableException;
public Table createTimeCodelist(PeriodType periodType);
//public Table createTimeCodelist(PeriodType periodType);
public Table removeValidations(TableId id) throws NoSuchTableException;
@ -51,5 +53,7 @@ public interface CubeManager {
public Table addValidations(TableId id, ValidationsMetadata tableValidationMetadata, Column ... validationColumns ) throws NoSuchTableException;
public Table addValidations(TableId id, Column ... validationColumns ) throws NoSuchTableException;
public Table exchangeColumnPosition(TableId tableId, ColumnLocalId columnId, int newPosition ) throws NoSuchTableException;
}

View File

@ -11,15 +11,15 @@
<Software>
<Description>Cube Manager module that handles management of TD tables on a PostgreSQL DB backend.</Description>
<Name>cube-manager-data</Name>
<Version>3.5.0-SNAPSHOT</Version>
<Version>3.5.2-SNAPSHOT</Version>
<MavenCoordinates>
<groupId>org.gcube.data.analysis.tabulardata</groupId>
<artifactId>cube-manager-data</artifactId>
<version>3.5.0-SNAPSHOT</version>
<version>3.5.2-SNAPSHOT</version>
</MavenCoordinates>
<Type>library</Type>
<Files>
<File>cube-manager-data-3.5.0-SNAPSHOT.jar</File>
<File>cube-manager-data-3.5.2-SNAPSHOT.jar</File>
</Files>
</Software>
</Packages>

View File

@ -12,7 +12,7 @@ Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo".
Version and Release Date
------------------------
v. 3.5.0-SNAPSHOT (2013-10-21)
v. 3.5.2-SNAPSHOT (2013-10-21)
Description
-----------

View File

@ -4,7 +4,7 @@
<parent>
<groupId>org.gcube.data.analysis.tabulardata</groupId>
<artifactId>cube-manager-parent</artifactId>
<version>3.5.1-SNAPSHOT</version>
<version>3.5.2-SNAPSHOT</version>
</parent>
<artifactId>cube-manager-data</artifactId>
<name>Cube Manager Data</name>

View File

@ -149,12 +149,16 @@ public class SQLDatabaseWrangler implements DatabaseWrangler {
else
data = "WITH NO DATA";
sb.append(String.format("CREATE %1$s TABLE %2$s AS TABLE %3$s %4$s;", unlogged, newTableName, tableToCloneName,
sb.append(String.format("CREATE %1$s TABLE %2$s WITHOUT OIDS AS TABLE %3$s %4$s;", unlogged, newTableName, tableToCloneName,
data));
sb.append(String.format("CREATE SEQUENCE %1$s_id_seq OWNED BY %1$s.id;", newTableName));
sb.append(String.format("SELECT setval('%1$s_id_seq', max(id) ) FROM %2$s;", newTableName, tableToCloneName));
sb.append(String.format("CREATE SEQUENCE %1$s_id_seq;", newTableName));
if (withData)
sb.append(String.format("SELECT setval('%1$s_id_seq', max(id) ) FROM %2$s;", newTableName, tableToCloneName));
else
sb.append(String.format("SELECT setval('%1$s_id_seq', 1 );", newTableName));
sb.append(String.format("ALTER TABLE %1$s ALTER id SET NOT NULL;", newTableName));
sb.append(String.format("ALTER TABLE %1$s ALTER id SET DEFAULT nextval('%1$s_id_seq');", newTableName));
log.debug("executing creation queries: "+sb.toString());
return sb.toString();
}

View File

@ -0,0 +1,15 @@
CREATE OR REPLACE FUNCTION count_estimate(query text) RETURNS integer AS
$$
DECLARE
rec record;
rows integer;
BEGIN
FOR rec IN EXECUTE 'EXPLAIN ' || query LOOP
rows := substring(rec."QUERY PLAN" FROM ' rows=([[:digit:]]+)');
EXIT WHEN rows IS NOT NULL;
END LOOP;
RETURN rows;
END
$$
LANGUAGE plpgsql;

View File

@ -0,0 +1,3 @@
CREATE OR REPLACE FUNCTION get_century_id(timestamp with time zone) RETURNS integer as $$
SELECT to_char($1, 'CC')::integer;
$$ LANGUAGE SQL;

View File

@ -0,0 +1,5 @@
CREATE OR REPLACE FUNCTION get_decade_id(timestamp with time zone) RETURNS integer as $$
SELECT substring(to_char($1,'YYYY') FROM '\d\d\d')::integer;
$$ LANGUAGE SQL;

View File

@ -2,8 +2,6 @@ CREATE OR REPLACE FUNCTION is_valid_date(date_value anyelement) RETURNS boolean
DECLARE
tmp date;
BEGIN
IF date_value IS NULL THEN return false;
END IF;
tmp := CAST(date_value AS date);
return true;

View File

@ -0,0 +1,3 @@
CREATE OR REPLACE FUNCTION is_valid_regexp(anyelement, text) RETURNS boolean AS $$
select $1::text~$2
$$ LANGUAGE SQL

View File

@ -0,0 +1,3 @@
CREATE OR REPLACE FUNCTION normalize_century(timestamp with time zone) RETURNS text as $$
SELECT to_char($1, 'CC');
$$ LANGUAGE SQL;

View File

@ -0,0 +1,3 @@
CREATE OR REPLACE FUNCTION normalize_decade(timestamp with time zone) RETURNS text as $$
SELECT substring(to_char($1,'YYYY') FROM '\d\d\d');
$$ LANGUAGE SQL;

View File

@ -0,0 +1,3 @@
CREATE OR REPLACE FUNCTION to_iso_year(anyelement) RETURNS timestamp with time zone as $$
SELECT ($1::text || '01-01-01')::timestamp with time zone;
$$ LANGUAGE SQL;

View File

@ -0,0 +1,3 @@
CREATE OR REPLACE FUNCTION to_iso_decade(anyelement) RETURNS timestamp with time zone as $$
SELECT ($1::text || '0-01-01')::timestamp with time zone;
$$ LANGUAGE SQL;

View File

@ -1,21 +0,0 @@
CREATE OR REPLACE FUNCTION update_gregorian_day_dimension() RETURNS trigger as $$
DECLARE
tmp_day date;
BEGIN
IF is_valid_date(NEW.day_code) THEN
NEW.day_code := normalize_day(NEW.day_code);
tmp_day := DATE(NEW.day_code);
NEW.the_day = tmp_day;
NEW.week_of_iso_year := EXTRACT(WEEK FROM tmp_day);
NEW.month_of_year := EXTRACT(MONTH FROM tmp_day);
NEW.quarter_of_year := EXTRACT(QUARTER FROM tmp_day);
NEW.year := EXTRACT(YEAR FROM tmp_day);
NEW.iso_year := EXTRACT(ISOYEAR FROM tmp_day);
NEW.decade := EXTRACT(DECADE FROM tmp_day);
RETURN NEW;
ELSE
RAISE EXCEPTION '% is not a valid ISO8601 day code', quote_literal(tmp_day);
END IF;
END
$$ LANGUAGE plpgsql;

View File

@ -1,18 +0,0 @@
CREATE OR REPLACE FUNCTION update_gregorian_month_dimension() RETURNS trigger as $$
DECLARE
tmp_day date;
BEGIN
IF (is_valid_month(NEW.month_code)) THEN
NEW.month_code := normalize_month(NEW.month_code);
tmp_day := DATE(NEW.month_code || '-01');
NEW.month_of_year := EXTRACT(MONTH FROM tmp_day);
NEW.quarter_of_year := EXTRACT(QUARTER FROM tmp_day);
NEW.year := EXTRACT(YEAR FROM tmp_day);
NEW.decade := EXTRACT(DECADE FROM tmp_day);
RETURN NEW;
ELSE
RAISE EXCEPTION '% is not a valid ISO8601 month code', quote_literal(month_code);
END IF;
END
$$ LANGUAGE plpgsql;

View File

@ -1,19 +0,0 @@
CREATE OR REPLACE FUNCTION update_gregorian_quarter_dimension() RETURNS trigger as $$
DECLARE
tmp_date date;
BEGIN
IF is_valid_quarter(NEW.quarter_code) THEN
NEW.quarter_code := normalize_quarter(NEW.quarter_code);
NEW.quarter_of_year := SUBSTRING(SUBSTRING(NEW.quarter_code FROM 'Q[0-9]') FROM '[1-4]$');
RAISE NOTICE 'Evaluated Quearter of year: %',NEW.quarter_of_year;
NEW.year := SUBSTRING(NEW.quarter_code FROM 'Q([1-4])$') AS integer;
RAISE NOTICE 'Evaluated year: %',NEW.year;
tmp_date := NEW.year || '-01-01';
NEW.decade := EXTRACT(DECADE FROM tmp_date);
RETURN NEW;
ELSE
RAISE EXCEPTION '% is not a valid quarter code', quote_literal(NEW.quarter_code);
END IF;
END
$$ LANGUAGE plpgsql;

View File

@ -1,16 +0,0 @@
CREATE OR REPLACE FUNCTION update_gregorian_year_dimension() RETURNS trigger as $$
DECLARE
tmp_date date;
BEGIN
IF is_valid_year(NEW.year_code) THEN
NEW.year_code := normalize_year(NEW.year_code);
tmp_date := NEW.year_code || '-01-01';
NEW.year := EXTRACT(YEAR FROM tmp_date);
NEW.decade := EXTRACT(DECADE FROM tmp_date);
RETURN NEW;
ELSE
RAISE EXCEPTION '%s is not a valid ISO8601 year code', quote_literal(year_code);
END IF;
END
$$ LANGUAGE plpgsql;

View File

@ -11,15 +11,15 @@
<Software>
<Description>Cube Manager module that manages the table and column metadata and their persistence on a backend.</Description>
<Name>cube-manager-metadata</Name>
<Version>3.5.0-SNAPSHOT</Version>
<Version>3.5.2-SNAPSHOT</Version>
<MavenCoordinates>
<groupId>org.gcube.data.analysis.tabulardata</groupId>
<artifactId>cube-manager-metadata</artifactId>
<version>3.5.0-SNAPSHOT</version>
<version>3.5.2-SNAPSHOT</version>
</MavenCoordinates>
<Type>library</Type>
<Files>
<File>cube-manager-metadata-3.5.0-SNAPSHOT.jar</File>
<File>cube-manager-metadata-3.5.2-SNAPSHOT.jar</File>
</Files>
</Software>
</Packages>

View File

@ -12,7 +12,7 @@ Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo".
Version and Release Date
------------------------
v. 3.5.0-SNAPSHOT (2013-10-21)
v. 3.5.2-SNAPSHOT (2013-10-21)
Description
-----------

View File

@ -4,7 +4,7 @@
<parent>
<groupId>org.gcube.data.analysis.tabulardata</groupId>
<artifactId>cube-manager-parent</artifactId>
<version>3.5.1-SNAPSHOT</version>
<version>3.5.2-SNAPSHOT</version>
</parent>
<artifactId>cube-manager-metadata</artifactId>
<name>Cube Manager Metadata</name>

View File

@ -1,8 +1,8 @@
package org.gcube.data.analysis.tabulardata.cube.metadata;
import java.util.Map;
import javax.inject.Singleton;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
@ -20,7 +20,7 @@ public class ISEntityManagerProvider {
private DatabaseProvider dbProvider;
private EntityManager em;
private EntityManagerFactory emf;
public ISEntityManagerProvider(DatabaseEndpointIdentifier metaDBEndpointId,
DatabaseProvider dbProvider) {
@ -28,8 +28,8 @@ public class ISEntityManagerProvider {
this.dbProvider = dbProvider;
}
public EntityManager get() {
if (em == null) {
public EntityManagerFactory get() {
if (!isInitialized()){
DatabaseEndpoint dbDescriptor = dbProvider.get(metaDBEndpointId);
// Retrieve driver from properties
@ -60,22 +60,18 @@ public class ISEntityManagerProvider {
properties.put("eclipselink.ddl-generation", "create-tables");
// properties.put("eclipselink.ddl-generation","create-or-extend-tables");
// properties.put("eclipselink.ddl-generation","drop-and-create-tables");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("default", properties);
em = emf.createEntityManager();
emf = Persistence.createEntityManagerFactory("default", properties);
}
return em;
return emf;
}
}
public void close(){
em.flush();
em.close();
em = null;
emf.close();
emf = null;
}
public boolean isInitialized(){
return em!=null;
return emf!=null;
}
}

View File

@ -6,6 +6,7 @@ import javax.enterprise.inject.Default;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
@ -28,7 +29,7 @@ public class JPACubeMetadataWrangler implements CubeMetadataWrangler {
Logger log = LoggerFactory.getLogger(JPACubeMetadataWrangler.class);
EntityManager em = null;
EntityManagerFactory emf = null;
ISEntityManagerProvider emp;
@ -49,73 +50,102 @@ public class JPACubeMetadataWrangler implements CubeMetadataWrangler {
public synchronized Table save(Table table, boolean overwrite) {
TableConsistencyChecker.checkTableConsistency(table);
JPATable jpaTable = null;
EntityManager em = getEntityManagerFactory().createEntityManager();
try{
if (overwrite)
try {
jpaTable = JPATableFactory.updateJPATable(getJPATableById(table.getId().getValue(), em), table);
} catch (NoSuchTableException e) {
log.warn("the table with id {} is not persisted, cannot overwrite ",table.getId().getValue());
}
if (overwrite)
try {
jpaTable = JPATableFactory.updateJPATable(getJPATableById(table.getId().getValue()), table);
} catch (NoSuchTableException e) {
log.warn("the table with id {} is not persisted, cannot overwrite ",table.getId().getValue());
}
if (jpaTable==null)
jpaTable = JPATableFactory.createJPATable(table);
persistEntity(jpaTable);
return TableFactory.createTable(jpaTable);
if (jpaTable==null)
jpaTable = JPATableFactory.createJPATable(table);
persistEntity(jpaTable, em);
return TableFactory.createTable(jpaTable);
}finally{
em.close();
}
}
private void initializeIfNot() {
if (em == null)
em = emp.get();
if (emf == null)
emf = emp.get();
}
@Override
public synchronized Table get(TableId id) throws NoSuchTableException {
return TableFactory.createTable(getJPATableById(id.getValue()));
EntityManager em = getEntityManagerFactory().createEntityManager();
try{
return TableFactory.createTable(getJPATableById(id.getValue(), em));
}finally{
em.close();
}
}
@Override
public Table getTableByName(String name) throws NoSuchTableException {
return TableFactory.createTable(getJPATableByTableName(name));
EntityManager em = getEntityManagerFactory().createEntityManager();
try{
return TableFactory.createTable(getJPATableByTableName(name, em));
}finally{
em.close();
}
}
@Override
public synchronized List<Table> getAll() {
return Lists.transform(getAllJPATables(), new Function<JPATable, Table>() {
EntityManager em = getEntityManagerFactory().createEntityManager();
try{
return Lists.transform(getAllJPATables(em), new Function<JPATable, Table>() {
@Override
public Table apply(JPATable input) {
return TableFactory.createTable(input);
}
@Override
public Table apply(JPATable input) {
return TableFactory.createTable(input);
}
});
});
}finally{
em.close();
}
}
@Override
public synchronized List<Table> getAll(TableType tableType) {
return Lists.transform(getAllJPATablesByType(tableType), new Function<JPATable, Table>() {
EntityManager em = getEntityManagerFactory().createEntityManager();
try{
return Lists.transform(getAllJPATablesByType(tableType, em), new Function<JPATable, Table>() {
@Override
public Table apply(JPATable input) {
return TableFactory.createTable(input);
}
@Override
public Table apply(JPATable input) {
return TableFactory.createTable(input);
}
});
});
}finally{
em.close();
}
}
@Override
public synchronized void remove(TableId id) throws NoSuchTableException {
removeEntity(getJPATableById(id.getValue()));
EntityManager em = getEntityManagerFactory().createEntityManager();
try{
removeEntity(getJPATableById(id.getValue(), em), em);
}finally{
em.close();
}
}
private JPATable getJPATableById(long id) throws NoSuchTableException {
JPATable table = getEntityManager().find(JPATable.class, id);
private JPATable getJPATableById(long id, EntityManager em) throws NoSuchTableException {
JPATable table = em.find(JPATable.class, id);
if (table==null)throw new NoSuchTableException(id);
return table;
}
private JPATable getJPATableByTableName(String name) throws NoSuchTableException {
TypedQuery<JPATable> query = getEntityManager().createNamedQuery("Table.findByName", JPATable.class);
private JPATable getJPATableByTableName(String name, EntityManager em) throws NoSuchTableException {
TypedQuery<JPATable> query = em.createNamedQuery("Table.findByName", JPATable.class);
query.setParameter("Name", name);
try{
return query.getSingleResult();
@ -123,27 +153,28 @@ public class JPACubeMetadataWrangler implements CubeMetadataWrangler {
throw new NoSuchTableException(name);
}
}
private List<JPATable> getAllJPATables() {
TypedQuery<JPATable> query = getEntityManager().createNamedQuery("Table.findAll", JPATable.class);
private List<JPATable> getAllJPATables(EntityManager em) {
TypedQuery<JPATable> query = em.createNamedQuery("Table.findAll", JPATable.class);
return query.getResultList();
}
private List<JPATable> getAllJPATablesByType(TableType tableType) {
TypedQuery<JPATable> query = getEntityManager().createNamedQuery("Table.findAllByType", JPATable.class);
private List<JPATable> getAllJPATablesByType(TableType tableType, EntityManager em ) {
TypedQuery<JPATable> query = em.createNamedQuery("Table.findAllByType", JPATable.class);
query.setParameter("TableType", tableType);
return query.getResultList();
}
private void persistEntity(JPATable entity) {
private void persistEntity(JPATable entity, EntityManager em) {
try{
getEntityManager().getTransaction().begin();
em.getTransaction().begin();
if (!em.contains(entity))
getEntityManager().persist(entity);
else getEntityManager().merge(entity);
getEntityManager().flush();
getEntityManager().getTransaction().commit();
em.persist(entity);
else em.merge(entity);
em.flush();
em.getTransaction().commit();
}catch(Throwable t){
log.warn("DB error",t);
em.getTransaction().rollback();
@ -159,16 +190,16 @@ public class JPACubeMetadataWrangler implements CubeMetadataWrangler {
// log.debug("Updated entity: " + entity);
// }
private void removeEntity(Object entity) {
getEntityManager().getTransaction().begin();
getEntityManager().remove(entity);
getEntityManager().flush();
getEntityManager().getTransaction().commit();
private void removeEntity(Object entity, EntityManager em) {
em.getTransaction().begin();
em.remove(entity);
em.flush();
em.getTransaction().commit();
}
private EntityManager getEntityManager() {
private EntityManagerFactory getEntityManagerFactory() {
initializeIfNot();
return em;
return emf;
}
}

View File

@ -51,21 +51,21 @@ public class TestDatabaseProvider implements DatabaseProvider {
properties.add(new DatabaseProperty("eclipselink.ddl-generation", "drop-and-create-tables"));
return new DatabaseEndpoint("Metadata-Admin", "Metadata-Admin",
"jdbc:postgresql://node7.d.d4science.research-infrastructures.eu:5432/tabularmetadata", new Credential("tabulardataadmin", "gcube2010"), properties);
"jdbc:postgresql://localhost:5432/tabularmetadata", new Credential("tabulardataadmin", "gcube2010"), properties);
}
private static DatabaseEndpoint createDataUserEndpoint() {
Collection<DatabaseProperty> properties = new ArrayList<DatabaseProperty>();
properties.add(new DatabaseProperty("driver", "org.postgresql.Driver"));
return new DatabaseEndpoint("Data-User", "test description",
"jdbc:postgresql://node7.d.d4science.research-infrastructures.eu:5432/tabulardata", new Credential("tabulardataadmin", "gcube2010"), properties);
"jdbc:postgresql://localhost:5432/tabulardata", new Credential("tabulardataadmin", "gcube2010"), properties);
}
private static DatabaseEndpoint createDataAdminEndpoint() {
Collection<DatabaseProperty> properties = new ArrayList<DatabaseProperty>();
properties.add(new DatabaseProperty("driver", "org.postgresql.Driver"));
return new DatabaseEndpoint("Data-Admin", "test description",
"jdbc:postgresql://node7.d.d4science.research-infrastructures.eu:5432/tabulardata", new Credential("tabulardataadmin", "gcube2010"), properties);
"jdbc:postgresql://localhost:5432/tabulardata", new Credential("tabulardataadmin", "gcube2010"), properties);
}
@Override

View File

@ -11,15 +11,15 @@
<Software>
<Description>Component of Tabular Data that manages table creation/deletion on DB backend and keeps a hold of created tables and their structure and metadata.</Description>
<Name>cube-manager</Name>
<Version>3.5.0-SNAPSHOT</Version>
<Version>3.5.2-SNAPSHOT</Version>
<MavenCoordinates>
<groupId>org.gcube.data.analysis.tabulardata</groupId>
<artifactId>cube-manager</artifactId>
<version>3.5.0-SNAPSHOT</version>
<version>3.5.2-SNAPSHOT</version>
</MavenCoordinates>
<Type>library</Type>
<Files>
<File>cube-manager-3.5.0-SNAPSHOT.jar</File>
<File>cube-manager-3.5.2-SNAPSHOT.jar</File>
</Files>
</Software>
</Packages>

View File

@ -12,7 +12,7 @@ Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo".
Version and Release Date
------------------------
v. 3.5.0-SNAPSHOT (2013-10-21)
v. 3.5.2-SNAPSHOT (2013-10-21)
Description
-----------

View File

@ -4,7 +4,7 @@
<parent>
<groupId>org.gcube.data.analysis.tabulardata</groupId>
<artifactId>cube-manager-parent</artifactId>
<version>3.5.1-SNAPSHOT</version>
<version>3.5.2-SNAPSHOT</version>
</parent>
<artifactId>cube-manager</artifactId>
<name>Cube Manager</name>

View File

@ -3,6 +3,7 @@ package org.gcube.data.analysis.tabulardata.cube;
import java.util.ArrayList;
import java.util.Collection;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Default;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
@ -10,6 +11,7 @@ import javax.inject.Named;
import javax.inject.Provider;
import javax.inject.Singleton;
import org.gcube.data.analysis.tabulardata.cube.events.TableRemovedEvent;
import org.gcube.data.analysis.tabulardata.cube.exceptions.NoSuchTableException;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableCreator;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableManager;
@ -39,6 +41,9 @@ public class DefaultCubeManager implements CubeManager {
//private static Logger log = LoggerFactory.getLogger(DefaultCubeManager.class);
private Event<TableRemovedEvent> tableRemovedEvent;
private Provider<TableCreator> codelistCreatorProvider;
private Provider<TableCreator> datasetCreatorProvider;
private Provider<TableCreator> hclCreatorProvider;
@ -58,7 +63,8 @@ public class DefaultCubeManager implements CubeManager {
@Named("ViewTable") Instance<TableCreator> tempTableCreatorProvider,
@Named("GenericTable") Instance<TableCreator> genericTableCreatorProvider,
@Named("ViewTable") Instance<TableCreator> viewTableCreatorProvider,
TableMetaCreatorProvider tableMetaCreatorProvider, TimeCodelistCreator timeCreator) {
TableMetaCreatorProvider tableMetaCreatorProvider, TimeCodelistCreator timeCreator,
Event<TableRemovedEvent> tableRemovedEvent) {
super();
this.tableManager = tableManager;
@ -70,6 +76,7 @@ public class DefaultCubeManager implements CubeManager {
this.viewTableCreatorProvider = viewTableCreatorProvider;
this.defaultTableMetaCreatorProvider = tableMetaCreatorProvider;
this.timeCodelistCreator = timeCreator;
this.tableRemovedEvent = tableRemovedEvent;
}
@ -113,6 +120,7 @@ public class DefaultCubeManager implements CubeManager {
@Override
public void removeTable(TableId id) throws NoSuchTableException {
tableManager.remove(id);
tableRemovedEvent.fire(new TableRemovedEvent(id));
}
@ -122,7 +130,7 @@ public class DefaultCubeManager implements CubeManager {
}
@Override
public Table createTimeCodelist(PeriodType periodType) {
public Table getTimeTable(PeriodType periodType) {
Table resultTable = timeCodelistCreator.getTable(periodType);
return resultTable;
}
@ -182,4 +190,16 @@ public class DefaultCubeManager implements CubeManager {
}
@Override
public Table exchangeColumnPosition(TableId id, ColumnLocalId columnId,
int position) throws NoSuchTableException {
Table table = tableManager.get(id);
Column colToMove = table.getColumnById(columnId);
table.getColumns().remove(colToMove);
table.getColumns().add(position, colToMove);
tableManager.save(table, true);
return table;
}
}

View File

@ -0,0 +1,24 @@
package org.gcube.data.analysis.tabulardata.cube.events;
import java.io.Serializable;
import org.gcube.data.analysis.tabulardata.model.table.Table;
public class TableCreationEvent implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
Table table;
public TableCreationEvent(Table table) {
super();
this.table = table;
}
public Table getTable() {
return table;
}
}

View File

@ -0,0 +1,24 @@
package org.gcube.data.analysis.tabulardata.cube.events;
import java.io.Serializable;
import org.gcube.data.analysis.tabulardata.model.table.TableId;
public class TableRemovedEvent implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
TableId tableId;
public TableRemovedEvent(TableId tableId) {
super();
this.tableId = tableId;
}
public TableId getTableId() {
return tableId;
}
}

View File

@ -8,26 +8,37 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.enterprise.event.Event;
import org.apache.commons.lang.RandomStringUtils;
import org.gcube.data.analysis.tabulardata.cube.data.DatabaseWrangler;
import org.gcube.data.analysis.tabulardata.cube.events.TableCreationEvent;
import org.gcube.data.analysis.tabulardata.cube.exceptions.NoSuchTableException;
import org.gcube.data.analysis.tabulardata.cube.exceptions.TableCreationException;
import org.gcube.data.analysis.tabulardata.cube.metadata.CubeMetadataWrangler;
import org.gcube.data.analysis.tabulardata.model.column.Column;
import org.gcube.data.analysis.tabulardata.model.column.factories.IdColumnFactory;
import org.gcube.data.analysis.tabulardata.model.column.type.IdColumnType;
import org.gcube.data.analysis.tabulardata.model.column.type.TimeDimensionColumnType;
import org.gcube.data.analysis.tabulardata.model.datatype.DataType;
import org.gcube.data.analysis.tabulardata.model.idioms.ColumnHasName;
import org.gcube.data.analysis.tabulardata.model.metadata.column.ColumnMetadata;
import org.gcube.data.analysis.tabulardata.model.metadata.column.PeriodTypeMetadata;
import org.gcube.data.analysis.tabulardata.model.metadata.table.TableMetadata;
import org.gcube.data.analysis.tabulardata.model.table.Table;
import org.gcube.data.analysis.tabulardata.model.table.TableType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
public abstract class DefaultTableCreator implements TableCreator {
Event<TableCreationEvent> tableCreatedEvent;
private static Logger logger = LoggerFactory.getLogger(DefaultTableCreator.class);
protected DatabaseWrangler dbWrangler;
protected CubeMetadataWrangler mdWrangler;
@ -47,12 +58,13 @@ public abstract class DefaultTableCreator implements TableCreator {
private TableType tableType;
public DefaultTableCreator(DatabaseWrangler dbWrangler, CubeMetadataWrangler mdWrangler, TableManager tableManager,
TableType tableType) {
TableType tableType, Event<TableCreationEvent> tableCreatedEvent) {
super();
this.dbWrangler = dbWrangler;
this.mdWrangler = mdWrangler;
this.tableManager = tableManager;
this.tableType = tableType;
this.tableCreatedEvent = tableCreatedEvent;
}
@Override
@ -243,11 +255,16 @@ public abstract class DefaultTableCreator implements TableCreator {
cloneMetadata(tableToClone, newTable);
}
// Register codelist on metadata DB
return mdWrangler.save(newTable, false);
Table createdTable = mdWrangler.save(newTable, false);
tableCreatedEvent.fire(new TableCreationEvent(createdTable));
return createdTable;
}catch(TableCreationException tce){
throw tce;
}catch (Exception e) {
e.printStackTrace();
throw new TableCreationException(e.getMessage());
}finally{
resetTableCreator();
@ -275,6 +292,8 @@ public abstract class DefaultTableCreator implements TableCreator {
for (Column column : getAllColumnsExceptId()) {
if (column.hasRelationship()) {
try {
if (column.getColumnType() instanceof TimeDimensionColumnType && column.contains(PeriodTypeMetadata.class) )
continue;
Table targetTable = tableManager.get(column.getRelationship().getTargetTableId());
targetTable.getColumnById(column.getRelationship().getTargetColumnId());
} catch (NoSuchTableException e) {
@ -308,6 +327,7 @@ public abstract class DefaultTableCreator implements TableCreator {
protected void cloneMetadata(Table sourceTable, Table destTable) {
for (TableMetadata m : sourceTable.getAllMetadata()) {
logger.info("source metadata : "+m);
if (m.isInheritable())
destTable.setMetadata(m);
}

View File

@ -3,7 +3,10 @@ package org.gcube.data.analysis.tabulardata.cube.tablemanagers.codelist;
import java.util.Collection;
import java.util.List;
import javax.enterprise.event.Event;
import org.gcube.data.analysis.tabulardata.cube.data.DatabaseWrangler;
import org.gcube.data.analysis.tabulardata.cube.events.TableCreationEvent;
import org.gcube.data.analysis.tabulardata.cube.metadata.CubeMetadataWrangler;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.DefaultTableCreator;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableManager;
@ -19,8 +22,8 @@ import com.google.common.collect.Lists;
public class CodelistCreator extends DefaultTableCreator {
public CodelistCreator(DatabaseWrangler dw, CubeMetadataWrangler cmw, TableManager tm) {
super(dw, cmw, tm, new CodelistTableType());
public CodelistCreator(DatabaseWrangler dw, CubeMetadataWrangler cmw, TableManager tm, Event<TableCreationEvent> tableCreatedEvent) {
super(dw, cmw, tm, new CodelistTableType(), tableCreatedEvent);
}
private static List<ColumnType> indexedColumnTypes = Lists.newArrayList(new IdColumnType(), new CodeColumnType(),

View File

@ -1,14 +1,17 @@
package org.gcube.data.analysis.tabulardata.cube.tablemanagers.codelist;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import org.gcube.data.analysis.tabulardata.cube.data.DatabaseWrangler;
import org.gcube.data.analysis.tabulardata.cube.events.TableCreationEvent;
import org.gcube.data.analysis.tabulardata.cube.metadata.CubeMetadataWrangler;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableCreator;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableManager;
import org.gcube.data.analysis.tabulardata.model.table.Table;
public class CodelistCreatorProvider implements Provider<TableCreator> {
@ -16,21 +19,24 @@ public class CodelistCreatorProvider implements Provider<TableCreator> {
private DatabaseWrangler dw;
private CubeMetadataWrangler cmw;
private TableManager tm;
private Event<TableCreationEvent> tableCreatedEvent;
@Inject
public CodelistCreatorProvider(DatabaseWrangler dw,
CubeMetadataWrangler cmw, TableManager tm) {
CubeMetadataWrangler cmw, TableManager tm, Event<TableCreationEvent> tableCreatedEvent) {
super();
this.dw = dw;
this.cmw = cmw;
this.tm=tm;
this.tableCreatedEvent = tableCreatedEvent;
}
@Produces
@Named("Codelist")
@Override
public TableCreator get() {
return new CodelistCreator(dw, cmw, tm);
return new CodelistCreator(dw, cmw, tm, this.tableCreatedEvent);
}
}

View File

@ -3,7 +3,10 @@ package org.gcube.data.analysis.tabulardata.cube.tablemanagers.dataset;
import java.util.Collection;
import java.util.List;
import javax.enterprise.event.Event;
import org.gcube.data.analysis.tabulardata.cube.data.DatabaseWrangler;
import org.gcube.data.analysis.tabulardata.cube.events.TableCreationEvent;
import org.gcube.data.analysis.tabulardata.cube.metadata.CubeMetadataWrangler;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.DefaultTableCreator;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableManager;
@ -11,14 +14,15 @@ import org.gcube.data.analysis.tabulardata.model.column.Column;
import org.gcube.data.analysis.tabulardata.model.column.ColumnType;
import org.gcube.data.analysis.tabulardata.model.column.type.DimensionColumnType;
import org.gcube.data.analysis.tabulardata.model.column.type.IdColumnType;
import org.gcube.data.analysis.tabulardata.model.table.Table;
import org.gcube.data.analysis.tabulardata.model.table.type.DatasetTableType;
import com.google.common.collect.Lists;
public class DatasetCreator extends DefaultTableCreator {
public DatasetCreator(DatabaseWrangler dbWrangler, CubeMetadataWrangler cmWrangler, TableManager tableManager) {
super(dbWrangler, cmWrangler, tableManager, new DatasetTableType());
public DatasetCreator(DatabaseWrangler dbWrangler, CubeMetadataWrangler cmWrangler, TableManager tableManager, Event<TableCreationEvent> tableCreatedEvent) {
super(dbWrangler, cmWrangler, tableManager, new DatasetTableType(), tableCreatedEvent);
}
private static List<ColumnType> indexedColumnTypes = Lists.newArrayList(new IdColumnType(), new DimensionColumnType());

View File

@ -1,11 +1,13 @@
package org.gcube.data.analysis.tabulardata.cube.tablemanagers.dataset;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import org.gcube.data.analysis.tabulardata.cube.data.DatabaseWrangler;
import org.gcube.data.analysis.tabulardata.cube.events.TableCreationEvent;
import org.gcube.data.analysis.tabulardata.cube.metadata.CubeMetadataWrangler;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableCreator;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableManager;
@ -18,19 +20,22 @@ public class DatasetCreatorProvider implements Provider<TableCreator> {
private TableManager tableManager;
private Event<TableCreationEvent> tableCreatedEvent;
@Inject
public DatasetCreatorProvider(DatabaseWrangler dbWrangler,
CubeMetadataWrangler mdWrangler, TableManager tableManager) {
CubeMetadataWrangler mdWrangler, TableManager tableManager, Event<TableCreationEvent> tableCreatedEvent) {
this.dbWrangler = dbWrangler;
this.mdWrangler = mdWrangler;
this.tableManager = tableManager;
this.tableCreatedEvent = tableCreatedEvent;
}
@Produces
@Named("Dataset")
@Override
public TableCreator get() {
return new DatasetCreator(dbWrangler, mdWrangler, tableManager);
return new DatasetCreator(dbWrangler, mdWrangler, tableManager, tableCreatedEvent);
}

View File

@ -3,7 +3,10 @@ package org.gcube.data.analysis.tabulardata.cube.tablemanagers.generic;
import java.util.Collection;
import java.util.List;
import javax.enterprise.event.Event;
import org.gcube.data.analysis.tabulardata.cube.data.DatabaseWrangler;
import org.gcube.data.analysis.tabulardata.cube.events.TableCreationEvent;
import org.gcube.data.analysis.tabulardata.cube.metadata.CubeMetadataWrangler;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.DefaultTableCreator;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableManager;
@ -16,8 +19,8 @@ import com.google.common.collect.Lists;
public class GenericTableCreator extends DefaultTableCreator {
public GenericTableCreator(DatabaseWrangler dw, CubeMetadataWrangler cmw, TableManager tm) {
super(dw, cmw, tm, new GenericTableType());
public GenericTableCreator(DatabaseWrangler dw, CubeMetadataWrangler cmw, TableManager tm, Event<TableCreationEvent> tableCreatedEvent) {
super(dw, cmw, tm, new GenericTableType(), tableCreatedEvent);
}
private static List<ColumnType> indexedColumnTypes = Lists.newArrayList((ColumnType)new IdColumnType());

View File

@ -1,11 +1,13 @@
package org.gcube.data.analysis.tabulardata.cube.tablemanagers.generic;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import org.gcube.data.analysis.tabulardata.cube.data.DatabaseWrangler;
import org.gcube.data.analysis.tabulardata.cube.events.TableCreationEvent;
import org.gcube.data.analysis.tabulardata.cube.metadata.CubeMetadataWrangler;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableCreator;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableManager;
@ -17,20 +19,23 @@ public class GenericTableCreatorProvider implements Provider<TableCreator> {
private CubeMetadataWrangler mdWrangler;
private TableManager tableManager;
private Event<TableCreationEvent> tableCreatedEvent;
@Inject
public GenericTableCreatorProvider(DatabaseWrangler dbWrangler, CubeMetadataWrangler mdWrangler,
TableManager tableManager) {
TableManager tableManager, Event<TableCreationEvent> tableCreatedEvent) {
this.dbWrangler = dbWrangler;
this.mdWrangler = mdWrangler;
this.tableManager = tableManager;
this.tableCreatedEvent = tableCreatedEvent;
}
@Produces
@Named("GenericTable")
@Override
public TableCreator get() {
return new GenericTableCreator(dbWrangler, mdWrangler, tableManager);
return new GenericTableCreator(dbWrangler, mdWrangler, tableManager, this.tableCreatedEvent);
}
}

View File

@ -4,7 +4,10 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.enterprise.event.Event;
import org.gcube.data.analysis.tabulardata.cube.data.DatabaseWrangler;
import org.gcube.data.analysis.tabulardata.cube.events.TableCreationEvent;
import org.gcube.data.analysis.tabulardata.cube.metadata.CubeMetadataWrangler;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.DefaultTableCreator;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableManager;
@ -15,8 +18,8 @@ import org.gcube.data.analysis.tabulardata.model.table.type.HierarchicalCodelist
public class HCLCreator extends DefaultTableCreator {
public HCLCreator(DatabaseWrangler dbWrangler, CubeMetadataWrangler cmWrangler, TableManager tableManager) {
super(dbWrangler, cmWrangler, tableManager, new HierarchicalCodelistTableType());
public HCLCreator(DatabaseWrangler dbWrangler, CubeMetadataWrangler cmWrangler, TableManager tableManager, Event<TableCreationEvent> tableCreatedEvent) {
super(dbWrangler, cmWrangler, tableManager, new HierarchicalCodelistTableType(), tableCreatedEvent);
}
private static List<ColumnType> indexedColumnTypes = new ArrayList<ColumnType>();

View File

@ -1,14 +1,17 @@
package org.gcube.data.analysis.tabulardata.cube.tablemanagers.hcl;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import org.gcube.data.analysis.tabulardata.cube.data.DatabaseWrangler;
import org.gcube.data.analysis.tabulardata.cube.events.TableCreationEvent;
import org.gcube.data.analysis.tabulardata.cube.metadata.CubeMetadataWrangler;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableCreator;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableManager;
import org.gcube.data.analysis.tabulardata.model.table.Table;
public class HCLCreatorProvider implements Provider<TableCreator>{
@ -17,22 +20,25 @@ public class HCLCreatorProvider implements Provider<TableCreator>{
private CubeMetadataWrangler hclMetadataWrangler;
private TableManager tableManager;
private Event<TableCreationEvent> tableCreatedEvent;
@Inject
public HCLCreatorProvider(DatabaseWrangler dbWrangler,
CubeMetadataWrangler hclMetadataWrangler,
TableManager tableManager) {
TableManager tableManager, Event<TableCreationEvent> tableCreatedEvent) {
super();
this.dbWrangler = dbWrangler;
this.hclMetadataWrangler = hclMetadataWrangler;
this.tableManager= tableManager;
this.tableCreatedEvent = tableCreatedEvent;
}
@Produces
@Named("HCL")
@Override
public TableCreator get() {
return new HCLCreator(dbWrangler, hclMetadataWrangler, tableManager);
return new HCLCreator(dbWrangler, hclMetadataWrangler, tableManager, tableCreatedEvent);
}
}

View File

@ -3,7 +3,10 @@ package org.gcube.data.analysis.tabulardata.cube.tablemanagers.view;
import java.util.Collection;
import java.util.List;
import javax.enterprise.event.Event;
import org.gcube.data.analysis.tabulardata.cube.data.DatabaseWrangler;
import org.gcube.data.analysis.tabulardata.cube.events.TableCreationEvent;
import org.gcube.data.analysis.tabulardata.cube.metadata.CubeMetadataWrangler;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.DefaultTableCreator;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableManager;
@ -17,8 +20,8 @@ import com.google.common.collect.Lists;
public class ViewTableCreator extends DefaultTableCreator {
public ViewTableCreator(DatabaseWrangler dw, CubeMetadataWrangler cmw, TableManager tm) {
super(dw, cmw, tm, new DatasetViewTableType());
public ViewTableCreator(DatabaseWrangler dw, CubeMetadataWrangler cmw, TableManager tm, Event<TableCreationEvent> tableCreatedEvent) {
super(dw, cmw, tm, new DatasetViewTableType(), tableCreatedEvent);
}
private static List<ColumnType> indexedColumnTypes = Lists.newArrayList(new IdColumnType(),

View File

@ -1,11 +1,13 @@
package org.gcube.data.analysis.tabulardata.cube.tablemanagers.view;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import org.gcube.data.analysis.tabulardata.cube.data.DatabaseWrangler;
import org.gcube.data.analysis.tabulardata.cube.events.TableCreationEvent;
import org.gcube.data.analysis.tabulardata.cube.metadata.CubeMetadataWrangler;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableCreator;
import org.gcube.data.analysis.tabulardata.cube.tablemanagers.TableManager;
@ -15,20 +17,21 @@ public class ViewTableCreatorProvider implements Provider<TableCreator> {
private DatabaseWrangler dbWrangler;
private CubeMetadataWrangler mdWrangler;
private TableManager tableManager;
private Event<TableCreationEvent> tableCreatedEvent;
@Inject
public ViewTableCreatorProvider(DatabaseWrangler dbWrangler, CubeMetadataWrangler mdWrangler,
TableManager tableManager) {
TableManager tableManager, Event<TableCreationEvent> tableCreatedEvent) {
this.dbWrangler = dbWrangler;
this.mdWrangler = mdWrangler;
this.tableManager = tableManager;
this.tableCreatedEvent = tableCreatedEvent;
}
@Produces
@Named("ViewTable")
@Override
public TableCreator get() {
return new ViewTableCreator(dbWrangler, mdWrangler, tableManager);
return new ViewTableCreator(dbWrangler, mdWrangler, tableManager, tableCreatedEvent);
}
}

View File

@ -49,6 +49,9 @@ public class CodelistTests {
@Inject @Named("Dataset")
Instance<TableCreator> datasetCreatorProvider;
@Inject @Named("Hierarchical")
Instance<TableCreator> hInstance;
@BeforeClass
public static void setUp() throws Exception {

View File

@ -1,13 +1,9 @@
package org.gcube.data.analysis.tabulardata.cube.tablemanagers;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.Collection;
import java.util.Collections;
import javax.inject.Inject;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import org.gcube.data.analysis.tabulardata.cube.CubeManager;
import org.gcube.data.analysis.tabulardata.model.column.Column;
@ -29,7 +25,6 @@ import org.gcube.data.analysis.tabulardata.model.metadata.common.Validation;
import org.gcube.data.analysis.tabulardata.model.metadata.common.ValidationsMetadata;
import org.gcube.data.analysis.tabulardata.model.relationship.ImmutableColumnRelationship;
import org.gcube.data.analysis.tabulardata.model.table.Table;
import org.gcube.data.analysis.tabulardata.model.table.TableId;
import org.gcube.data.analysis.tabulardata.model.table.type.CodelistTableType;
import org.gcube.data.analysis.tabulardata.model.table.type.DatasetTableType;
import org.gcube.data.analysis.tabulardata.model.table.type.DatasetViewTableType;
@ -44,7 +39,7 @@ public class CubeManagerTest {
@Inject
CubeManager cm;
@Test
public void addValidationColumns(){
Table table = cm.createTable(new GenericTableType()).create();
@ -125,4 +120,24 @@ public class CubeManagerTest {
cm.removeTable(dataset.getId());
}
@Test
public void excangeColumns(){
TableCreator originCreator = cm.createTable(new CodelistTableType());
Column col = new CodeNameColumnFactory().create("en");
originCreator.addColumn(new CodeColumnFactory().createDefault());
originCreator.addColumn(col);
originCreator.addColumn(new CodeNameColumnFactory().create("it"));
originCreator.addColumn(new AnnotationColumnFactory().create(new ImmutableLocalizedText("My Annotation on species", "en")));
Table t =originCreator.create();
System.out.println(t);
Table newTable = cm.exchangeColumnPosition(t.getId(), col.getLocalId(), 0);
System.out.println(newTable);
}
}

View File

@ -0,0 +1,14 @@
package org.gcube.data.analysis.tabulardata.cube.tablemanagers;
import javax.enterprise.event.Observes;
import javax.inject.Singleton;
import org.gcube.data.analysis.tabulardata.cube.events.TableCreationEvent;
@Singleton
public class ReadEvent {
public void created(@Observes TableCreationEvent tableCreatedEvent){
System.out.println("received event for table "+tableCreatedEvent.getTable().getId());
}
}

View File

@ -38,7 +38,7 @@ public class CodelistCreatorTests {
}
public Table createTableForPeriodType(PeriodType periodType) {
Table table = cubeManager.createTimeCodelist(periodType);
Table table = cubeManager.getTimeTable(periodType);
Assert.assertNotNull(table);
return table;
}

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.data.analysis.tabulardata</groupId>
<artifactId>cube-manager-parent</artifactId>
<version>3.5.1-SNAPSHOT</version>
<version>3.5.2-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>