Commit 900a208e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

latest database is translated into hsql

parent c9566fc1
......@@ -83,8 +83,13 @@ public class ProjectDao extends BaseDao<Project> {
public long getNextId() {
Dialect dialect = getDialect();
NativeQuery<?> sqlQuery = getSession().createNativeQuery(dialect.getSequenceNextValString("project_sequence"));
return ((BigInteger) sqlQuery.getResultList().get(0)).longValue();
Object result = sqlQuery.getResultList().get(0);
// postgres database returns BigInteger
if (result instanceof BigInteger) {
return ((BigInteger) sqlQuery.getResultList().get(0)).longValue();
} else { //hsql database returns Integer
return ((Integer) sqlQuery.getResultList().get(0)).longValue();
}
}
......
-- remove metaid columns (some useless identifier)
alter table species_table drop column metaid;
alter table reaction_table drop column metaid;
alter table model_table drop column metaid;
insert into changelog (svnversion, description, type, requestproject_iddb, requestuser_iddb) values
(1024, 'Search by reaction id is not case sensitive', 'BUG_FIX', null,
(select iddb from external_user where email ='alberto.noronha@uni.lu'));
insert into changelog (svnversion, description, type, requestproject_iddb, requestuser_iddb) values
(1024, 'CellDesigner font size is processed properly', 'BUG_FIX', null,
(select iddb from external_user where email ='marek.ostaszewski@uni.lu'));
--column with input file data for a project
alter table project_table add column inputdata binary;
ALTER TABLE project_table ADD COLUMN inputfilename varchar(1024);
\ No newline at end of file
insert into changelog (svnversion, description, type, requestproject_iddb, requestuser_iddb) values
(1024, 'Project info tab available for users', 'FUNCTIONALITY', null,
(select iddb from external_user where email ='piotr.gawron@uni.lu'));
INSERT INTO cache_type(iddb, validity, classname)
VALUES (19, 28, 'lcsb.mapviewer.annotation.services.genome.UcscReferenceGenomeConnector');
CREATE SEQUENCE public.big_file_entry_iddb_seq
INCREMENT by 1
MINVALUE 1
no MAXVALUE
START with 1;
CREATE TABLE public.big_file_entry
(
iddb integer GENERATED BY DEFAULT AS SEQUENCE big_file_entry_iddb_seq NOT NULL,
url clob,
localpath clob,
downloaddate timestamp without time zone,
downloadprogress double precision,
downloadthreadid integer,
removed boolean default false,
CONSTRAINT big_file_entry_pkey PRIMARY KEY (iddb)
);
drop table if exists public.reference_genome;
drop SEQUENCE if exists public.reference_genome_iddb_seq;
CREATE SEQUENCE public.reference_genome_iddb_seq
INCREMENT by 1
MINVALUE 1
no MAXVALUE
START with 1;
CREATE TABLE public.reference_genome
(
iddb integer GENERATED BY DEFAULT AS SEQUENCE reference_genome_iddb_seq NOT NULL,
organism_iddb integer NOT NULL ,
"type" varchar(255),
version varchar(255),
sourceurl clob,
downloadprogress double precision,
CONSTRAINT reference_genome_pkey PRIMARY KEY (iddb),
CONSTRAINT reference_genome_organism_fk FOREIGN KEY (organism_iddb)
REFERENCES public.miriam_data_table (iddb) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
);
--obligatory fields for reference genome table
alter table reference_genome alter column "type" set not null;
alter table reference_genome alter column organism_iddb set not null;
alter table reference_genome alter column version set not null;
--gene mapping files table for reference genome table
drop table if exists public.reference_genome_gene_mapping;
drop SEQUENCE if exists public.reference_genome_gene_mapping_iddb_seq;
CREATE SEQUENCE public.reference_genome_gene_mapping_iddb_seq
INCREMENT by 1
MINVALUE 1
no MAXVALUE
START with 1;
CREATE TABLE public.reference_genome_gene_mapping
(
iddb integer GENERATED BY DEFAULT AS SEQUENCE reference_genome_gene_mapping_iddb_seq NOT NULL,
referencegenome_iddb integer NOT NULL,
name varchar(255) not null,
sourceurl clob not null,
downloadprogress double precision,
CONSTRAINT reference_genome_gene_mapping_pkey PRIMARY KEY (iddb),
CONSTRAINT reference_genome_gene_mapping_reference_genome_fk FOREIGN KEY (referencegenome_iddb)
REFERENCES public.reference_genome (iddb) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT reference_genome_gene_mapping_unique_name UNIQUE (referencegenome_iddb, name)
);
-- fixing privileges for admin (genome managing is availabvle by default for admin)
insert into privilege_table (privilege_class_type_db,level,type,idobject,user_iddb) select 'BASIC_PRIVILEGE',1,11,null, t.iddb from user_table t where iddb=1 and not(t.iddb in (select user_iddb from privilege_table where type=11));
-- project should have organism id
alter table project_table add column organism_iddb integer;
ALTER TABLE project_table ADD CONSTRAINT project_organism_constraint FOREIGN KEY (organism_iddb)
REFERENCES public.miriam_data_table (iddb) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION;
\ No newline at end of file
-- reorganizing files in the system
alter table big_file_entry rename to file_entry;
alter table file_entry add column filecontent binary;
alter table file_entry add column file_type_db varchar(255);
alter table file_entry add column originalfilename varchar(255);
-- all files up to this point were big files
update file_entry set file_type_db = 'BIG_FILE_ENTRY';
--and now we move content of files from layout file to file_entry table
--tmp column
alter table file_entry add column layout_id_tmp integer;
--move content content
insert into file_entry (filecontent,file_type_db,originalfilename,layout_id_tmp) select inputdata, 'UPLOADED_FILE_ENTRY', 'layout_'||iddb||'.txt',iddb from layout where inputdata is not null;
--add foreign key
alter table layout add column file_entry_iddb integer;
ALTER TABLE layout ADD CONSTRAINT layout_file_constraint FOREIGN KEY (file_entry_iddb)
REFERENCES public.file_entry (iddb) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION;
--put data to foreign key
update layout l set file_entry_iddb = (select iddb from file_entry ef where ef.layout_id_tmp = l.iddb) where l.inputdata is not null;
--remove unused columns
alter table file_entry drop column layout_id_tmp;
alter table layout drop column inputdata;
insert into changelog (svnversion, description, type, requestproject_iddb, requestuser_iddb) values
(1024, 'Hiding left panel', 'BUG_FIX', null,
(select iddb from external_user where email ='alberto.noronha@uni.lu'));
insert into changelog (svnversion, description, type, requestproject_iddb, requestuser_iddb) values
(1024, 'Coordinates in url', 'BUG_FIX', null,
(select iddb from external_user where email ='alberto.noronha@uni.lu'));
insert into changelog (svnversion, description, type, requestproject_iddb, requestuser_iddb) values
(1024, 'Unexpected errors when uploading layouts', 'BUG_FIX', null,
(select iddb from external_user where email ='alberto.noronha@uni.lu'));
delete from cachequery where type = (select iddb from cache_type where classname = 'lcsb.mapviewer.annotation.services.DrugbankHTMLParser') and query like 'drug:%';
insert into changelog (svnversion, description, type, requestproject_iddb, requestuser_iddb) values
(1024, 'Corrupted drug names', 'BUG_FIX', null,
(select iddb from external_user where email ='alberto.noronha@uni.lu'));
insert into changelog (svnversion, description, type, requestproject_iddb, requestuser_iddb) values
(1049, 'Out of memory when caching a lot of data', 'BUG_FIX', null,
(select iddb from external_user where email ='marek.ostaszewski@uni.lu'));
insert into changelog (svnversion, description, type, requestproject_iddb, requestuser_iddb) values
(1049, 'Management of overlays in admin panel', 'FUNCTIONALITY', null,
(select iddb from external_user where email ='marek.ostaszewski@uni.lu'));
insert into changelog (svnversion, description, type, requestproject_iddb, requestuser_iddb) values
(1049, 'Zooming issue when searching for results on submaps', 'BUG_FIX', null,
(select iddb from external_user where email ='piotr.gawron@uni.lu'));
insert into changelog (svnversion, description, type, requestproject_iddb, requestuser_iddb) values
(1049, 'Exception when accessing non-existing project', 'BUG_FIX', null,
(select iddb from external_user where email ='piotr.gawron@uni.lu'));
insert into changelog (svnversion, description, type, requestproject_iddb, requestuser_iddb) values
(1056, 'Visualization of text mining', 'BUG_FIX', null,
(select iddb from external_user where email ='marek.ostaszewski@uni.lu'));
insert into framework_version(version,"time", svnversion) values (10, timestamp'2016-08-22',1119);
update species_table set hypothetical=false where hypothetical is null;
\ No newline at end of file
ALTER TABLE model_table
ADD COLUMN idmodel character varying(255);
ALTER TABLE model_table
ADD COLUMN metaid character varying(255);
create table history_table (
iddb INTEGER IDENTITY PRIMARY KEY,
query varchar(1024),
map varchar(255),
timestamp timestamp without time zone,
type integer,
ipaddress varchar(255)
);
\ No newline at end of file
-- change cache query
ALTER TABLE cachequery ADD COLUMN type integer;
update cachequery set type =0 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.reactome.model.ReactomeCandidateSet';
update cachequery set type =0 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.reactome.model.ReactomeCatalystActivity';
update cachequery set type =0 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.reactome.model.ReactomeComplex';
update cachequery set type =0 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.reactome.model.ReactomeDatabaseObject';
update cachequery set type =0 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.reactome.model.ReactomeEntitySet';
update cachequery set type =0 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.reactome.model.ReactomeEntityWithAccessionedSequence';
update cachequery set type =0 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.reactome.model.ReactomeEvent';
update cachequery set type =0 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.reactome.model.ReactomeLiteratureReference';
update cachequery set type =0 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.reactome.model.ReactomePhysicalEntity';
update cachequery set type =0 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.reactome.model.ReactomeReactionlikeEvent';
update cachequery set type =0 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.reactome.model.ReactomeReferenceMolecule';
update cachequery set type =0 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.reactome.model.ReactomeReferenceSequence';
update cachequery set type =0 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.reactome.model.ReactomeSimpleEntity';
update cachequery set type =0 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.reactome.model.ReactomeStableIdentifier';
update cachequery set type =1 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.utils.annotation.AnnotationRestService';
update cachequery set type =2 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.utils.annotation.ChEMBLParser';
update cachequery set type =3 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.utils.annotation.data.Article';
update cachequery set type =4 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.utils.annotation.DrugbankHTMLParser';
update cachequery set type =5 where substring (query from 0 for position(chr(10) in query)) = 'lcsb.mapviewer.utils.annotation.IdConverter';
ALTER TABLE cachequery ALTER COLUMN type set not null;
update cachequery set query= substring(query from position(chr(10) in query)+1) where position(chr(10) in query)>0;
ALTER TABLE cachequery ADD COLUMN expires timestamp without time zone;
update cachequery set expires = accessed + 42 day;
-- and now entry
drop table cacheentry;
-- set auto increment id
CREATE SEQUENCE cacheentry_iddb_seq
INCREMENT BY 1
MINVALUE 1
NO MAXVALUE
START WITH 1;
CREATE TABLE cacheentry (
iddb integer GENERATED BY DEFAULT AS SEQUENCE cacheentry_iddb_seq NOT NULL,
accessed timestamp without time zone,
type integer not null,
expires timestamp without time zone,
customid integer,
value CLOB
);
--create search index
CREATE INDEX query_index
ON cachequery (type, query);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment