From d6c5bafdf1fa9f03b3e007434f59e5d579b78def Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Thu, 8 Oct 2009 13:00:11 +0000 Subject: [PATCH] [LMS-1205] enable to configure ordering of vocabulary terms - part 1 (migration, registration, and displaying terms using order information) SVN: 12889 --- .../client/web/client/application/Dict.java | 2 ++ .../model/ModelDataPropertyNames.java | 2 ++ .../model/VocabularyTermModel.java | 8 ++--- .../specific/VocabularyTermColDefKind.java | 15 ++++++++-- .../field/VocabularyTermSelectionWidget.java | 23 +++++++------- .../web/server/CommonClientService.java | 6 ++++ .../bo/AbstractSampleBusinessObject.java | 2 +- .../server/business/bo/VocabularyBO.java | 1 + .../bo/common/VocabularyTermRecord.java | 3 +- .../datasetlister/IDatasetListingQuery.java | 2 +- .../bo/samplelister/ISampleListingQuery.java | 2 +- .../basic/dto/ListOrSearchSampleCriteria.java | 2 ++ .../shared/basic/dto/VocabularyTerm.java | 12 ++++++++ .../generic/shared/dto/ColumnNames.java | 2 ++ .../generic/shared/dto/VocabularyTermPE.java | 15 +++++++++- .../translator/VocabularyTermTranslator.java | 1 + .../cisd/openbis/public/common-dictionary.js | 1 + openbis/source/sql/generic/043/data-043.sql | 16 ++++++---- openbis/source/sql/generic/043/schema-043.sql | 2 +- .../migration/migration-042-043.sql | 6 ++++ .../dataaccess/db/VocabularyDAOTest.java | 11 +++---- .../043/006=controlled_vocabulary_terms.tsv | 30 +++++++++---------- .../043/017=database_version_logs.tsv | 4 +-- .../sql/postgresql/043/finish-043.sql | 23 ++++++++++++-- .../sql/postgresql/043/schema-043.sql | 3 +- 25 files changed, 137 insertions(+), 57 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java index 5c38735d293..60d99016a5b 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java @@ -48,6 +48,8 @@ public abstract class Dict public static final String CODE = "code"; + public static final String ORDINAL = "ordinal"; + public static final String FILE = "file"; public static final String PERM_ID = "perm_id"; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/ModelDataPropertyNames.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/ModelDataPropertyNames.java index 3a0b8d1ad80..f5b2a2662ff 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/ModelDataPropertyNames.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/ModelDataPropertyNames.java @@ -40,6 +40,8 @@ public final class ModelDataPropertyNames public static final String CODE_WITH_LABEL = "code_with_label"; + public static final String ORDINAL = "ordinal"; + public static final String TOOLTIP = "tooltip"; public static final String LABEL = "label"; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/VocabularyTermModel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/VocabularyTermModel.java index ee3b450754f..0065c3131f5 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/VocabularyTermModel.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/VocabularyTermModel.java @@ -39,9 +39,9 @@ public class VocabularyTermModel extends BaseModel implements Comparable<Vocabul public VocabularyTermModel(VocabularyTerm term) { set(ModelDataPropertyNames.CODE, term.getCode()); + set(ModelDataPropertyNames.ORDINAL, term.getOrdinal()); set(ModelDataPropertyNames.CODE_WITH_LABEL, getCodeWithLabel(term)); - set(ModelDataPropertyNames.TOOLTIP, VocabularyPropertyColRenderer - .renderAsTooltip(term)); + set(ModelDataPropertyNames.TOOLTIP, VocabularyPropertyColRenderer.renderAsTooltip(term)); set(ModelDataPropertyNames.OBJECT, term); } @@ -76,9 +76,9 @@ public class VocabularyTermModel extends BaseModel implements Comparable<Vocabul } /** @return value that will be used to compare Vocabulary Terms and display them in order */ - private String getValueToCompare() + private Long getValueToCompare() { - return get(ModelDataPropertyNames.CODE_WITH_LABEL); + return get(ModelDataPropertyNames.ORDINAL); } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/VocabularyTermColDefKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/VocabularyTermColDefKind.java index c3973550b20..e26fc04d759 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/VocabularyTermColDefKind.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/VocabularyTermColDefKind.java @@ -55,6 +55,15 @@ public enum VocabularyTermColDefKind implements IColumnDefinitionKind<Vocabulary } }), + ORDINAL(new AbstractColumnDefinitionKind<VocabularyTermWithStats>(Dict.ORDINAL, 100, true) + { + @Override + public String tryGetValue(VocabularyTermWithStats entity) + { + return entity.getTerm().getOrdinal().toString(); + } + }), + URL(new AbstractColumnDefinitionKind<VocabularyTermWithStats>(Dict.URL, 200) { @Override @@ -63,7 +72,7 @@ public enum VocabularyTermColDefKind implements IColumnDefinitionKind<Vocabulary return entity.getTerm().getUrl(); } }), - + REGISTRATOR(new AbstractColumnDefinitionKind<VocabularyTermWithStats>(Dict.REGISTRATOR) { @Override @@ -82,8 +91,8 @@ public enum VocabularyTermColDefKind implements IColumnDefinitionKind<Vocabulary return renderRegistrationDate(entity.getTerm()); } }), - - TOTAL_USAGE(new AbstractColumnDefinitionKind<VocabularyTermWithStats>(Dict.TERM_TOTAL_USAGE) + + TOTAL_USAGE(new AbstractColumnDefinitionKind<VocabularyTermWithStats>(Dict.TERM_TOTAL_USAGE) { @Override public String tryGetValue(VocabularyTermWithStats entity) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/VocabularyTermSelectionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/VocabularyTermSelectionWidget.java index 5652987820b..a580a7a6e49 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/VocabularyTermSelectionWidget.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/VocabularyTermSelectionWidget.java @@ -17,7 +17,6 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.field; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; @@ -66,6 +65,7 @@ public class VocabularyTermSelectionWidget extends viewContext, null, initialTermCodeOrNull).asDatabaseModificationAware(); } + // TODO 2009-10-08, Piotr Buczek: use this for ordinal edition /** * Allows to choose one of the specified vocabulary terms. */ @@ -104,7 +104,6 @@ public class VocabularyTermSelectionWidget extends { final List<VocabularyTermModel> models = new ArrayList<VocabularyTermModel>(); models.addAll(convertItems(terms)); - Collections.sort(models); updateStore(models); getPropertyEditor().setList(store.getModels()); } @@ -168,15 +167,15 @@ public class VocabularyTermSelectionWidget extends } private native String getTooltipTemplate(String displayField, String tooltipField) /*-{ - return [ - '<tpl for=".">', - '<div class="x-combo-list-item" qtip="{[values.', - tooltipField, - ']}">{[values.', - displayField, - ']}</div>', - '</tpl>' - ].join(""); - }-*/; + return [ + '<tpl for=".">', + '<div class="x-combo-list-item" qtip="{[values.', + tooltipField, + ']}">{[values.', + displayField, + ']}</div>', + '</tpl>' + ].join(""); + }-*/; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java index ae7d005f18f..c17ee5d2738 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java @@ -1198,6 +1198,12 @@ public final class CommonClientService extends AbstractClientService implements .getOriginalFilename())); results.addAll(loadedTerms); } + // set initial order equivalent with order from the file + Long order = 1L; + for (VocabularyTerm term : results) + { + term.setOrdinal(order++); + } return results; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractSampleBusinessObject.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractSampleBusinessObject.java index bef4018e356..4216a5feada 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractSampleBusinessObject.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractSampleBusinessObject.java @@ -129,7 +129,7 @@ abstract class AbstractSampleBusinessObject extends AbstractSampleIdentifierBusi samplePE.setCode(sampleIdentifier.getSampleSubCode()); samplePE.setRegistrator(findRegistrator()); samplePE.setSampleType(sampleTypePE); - samplePE.setGroup(sampleOwner.tryGetGroup()); + samplePE.setGroup(sampleOwner.tryGetGroup()); // FIXME 2009-10-08, Piotr Buczek samplePE.setDatabaseInstance(sampleOwner.tryGetDatabaseInstance()); defineSampleProperties(samplePE, newSample.getProperties()); String parentIdentifier = newSample.getParentIdentifier(); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/VocabularyBO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/VocabularyBO.java index 8963cc61c52..ea1be6cd5cf 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/VocabularyBO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/VocabularyBO.java @@ -104,6 +104,7 @@ public class VocabularyBO extends AbstractBusinessObject implements IVocabularyB vocabularyTermPE.setDescription(description); vocabularyTermPE.setLabel(label); vocabularyTermPE.setRegistrator(findRegistrator()); + vocabularyTermPE.setOrdinal(new Long(vocabularyPE.getTerms().size())); vocabularyPE.addTerm(vocabularyTermPE); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/common/VocabularyTermRecord.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/common/VocabularyTermRecord.java index d88d89bcf7d..6bab551b747 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/common/VocabularyTermRecord.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/common/VocabularyTermRecord.java @@ -1,6 +1,5 @@ package ch.systemsx.cisd.openbis.generic.server.business.bo.common; - /** * A record object for a vocabulary term. */ @@ -13,4 +12,6 @@ public class VocabularyTermRecord extends BaseEntityPropertyRecord public String code; public String label; + + public long ordinal; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetListingQuery.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetListingQuery.java index bfe8623815d..741b4076aa3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetListingQuery.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetListingQuery.java @@ -143,7 +143,7 @@ public interface IDatasetListingQuery extends TransactionQuery, IPropertyListing * * @param entityIds The set of sample ids to get the property values for. */ - @Select(sql = "select pr.ds_id as entity_id, etpt.prty_id, cvte.id, cvte.covo_id, cvte.code, cvte.label" + @Select(sql = "select pr.ds_id as entity_id, etpt.prty_id, cvte.id, cvte.covo_id, cvte.code, cvte.label, cvte.ordinal" + " from data_set_properties pr" + " join data_set_type_property_types etpt on pr.dstpt_id=etpt.id" + " join controlled_vocabulary_terms cvte on pr.cvte_id=cvte.id" diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/ISampleListingQuery.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/ISampleListingQuery.java index aa74188c8a0..76aa3c01b90 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/ISampleListingQuery.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/ISampleListingQuery.java @@ -251,7 +251,7 @@ public interface ISampleListingQuery extends TransactionQuery, IPropertyListingQ * * @param sampleIds The set of sample ids to get the property values for. */ - @Select(sql = "select sp.samp_id as entity_id, stpt.prty_id, cvte.id, cvte.covo_id, cvte.code, cvte.label" + @Select(sql = "select sp.samp_id as entity_id, stpt.prty_id, cvte.id, cvte.covo_id, cvte.code, cvte.label, cvte.ordinal" + " from sample_properties sp" + " join sample_type_property_types stpt on sp.stpt_id=stpt.id" + " join controlled_vocabulary_terms cvte on sp.cvte_id=cvte.id" diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ListOrSearchSampleCriteria.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ListOrSearchSampleCriteria.java index 63623a2e0b5..1e051492733 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ListOrSearchSampleCriteria.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ListOrSearchSampleCriteria.java @@ -29,6 +29,8 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; */ public final class ListOrSearchSampleCriteria extends ListSampleCriteria { + private static final long serialVersionUID = ServiceVersionHolder.VERSION; + private ListSampleCriteria listCriteria; private Collection<Long> sampleIds; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/VocabularyTerm.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/VocabularyTerm.java index 638b88db94a..afa220fc3aa 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/VocabularyTerm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/VocabularyTerm.java @@ -36,6 +36,8 @@ public final class VocabularyTerm extends CodeWithRegistration<Vocabulary> imple private String url; + private Long ordinal; + public VocabularyTerm() { } @@ -100,4 +102,14 @@ public final class VocabularyTerm extends CodeWithRegistration<Vocabulary> imple { this.url = url; } + + public Long getOrdinal() + { + return ordinal; + } + + public void setOrdinal(Long ordinal) + { + this.ordinal = ordinal; + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/ColumnNames.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/ColumnNames.java index ea3bba62d9c..d7d839688bc 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/ColumnNames.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/ColumnNames.java @@ -150,6 +150,8 @@ public final class ColumnNames public static final String MATERIAL_TYPE_PROPERTY_TYPE_COLUMN = "mtpt_id"; + public static final String ORDINAL_COLUMN = "ordinal"; + public static final String PARENT_DATA_SET_CODE_COLUMN = "data_producer_code"; public static final String PART_OF_DEPTH = "part_of_depth"; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/VocabularyTermPE.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/VocabularyTermPE.java index c757183cf8a..59a0a4430b2 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/VocabularyTermPE.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/VocabularyTermPE.java @@ -70,6 +70,8 @@ public class VocabularyTermPE extends HibernateAbstractRegistrationHolder implem private String description; + private Long ordinal; + private VocabularyPE vocabulary; public VocabularyTermPE() @@ -113,6 +115,17 @@ public class VocabularyTermPE extends HibernateAbstractRegistrationHolder implem this.label = label; } + @Column(name = ColumnNames.ORDINAL_COLUMN) + public Long getOrdinal() + { + return ordinal; + } + + public void setOrdinal(Long ordinal) + { + this.ordinal = ordinal; + } + public void setId(final long id) { this.id = id; @@ -210,7 +223,7 @@ public class VocabularyTermPE extends HibernateAbstractRegistrationHolder implem public final int compareTo(final VocabularyTermPE o) { - return AbstractIdAndCodeHolder.compare(this, o); + return this.getOrdinal().compareTo(o.getOrdinal()); } @Transient diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/VocabularyTermTranslator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/VocabularyTermTranslator.java index 1a13d103d1d..413a2120412 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/VocabularyTermTranslator.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/VocabularyTermTranslator.java @@ -47,6 +47,7 @@ public class VocabularyTermTranslator result.setCode(StringEscapeUtils.escapeHtml(vt.getCode())); result.setLabel(StringEscapeUtils.escapeHtml(vt.getLabel())); result.setDescription(StringEscapeUtils.escapeHtml(vt.getDescription())); + result.setOrdinal(vt.getOrdinal()); result.setUrl(StringEscapeUtils.escapeHtml(vt.getUrl())); result.setRegistrationDate(vt.getRegistrationDate()); result.setRegistrator(PersonTranslator.translate(vt.getRegistrator())); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js index 08cb89b3d54..e0224f4ef79 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js @@ -11,6 +11,7 @@ var common = { attachment: "Attachment", code: "Code", + ordinal: "Ordinal", file: "File", perm_id: "PermID", registrator: "Registrator", diff --git a/openbis/source/sql/generic/043/data-043.sql b/openbis/source/sql/generic/043/data-043.sql index 63dc3f860ff..16bb4780fb6 100644 --- a/openbis/source/sql/generic/043/data-043.sql +++ b/openbis/source/sql/generic/043/data-043.sql @@ -61,14 +61,14 @@ insert into controlled_vocabularies , description , pers_id_registerer , is_managed_internally - , dbin_id ) + , dbin_id) values (nextval('CONTROLLED_VOCABULARY_ID_SEQ') , 'STORAGE_FORMAT' , true , 'The on-disk storage format of a data set' , (select id from persons where user_id ='system') , true - ,(select id from database_instances where code = 'SYSTEM_DEFAULT')); + , (select id from database_instances where code = 'SYSTEM_DEFAULT')); ----------------------------------------------------------------------------------- @@ -78,21 +78,25 @@ insert into controlled_vocabulary_terms ( id , code , covo_id - , pers_id_registerer ) + , pers_id_registerer + , ordinal ) values (nextval('CVTE_ID_SEQ') , 'PROPRIETARY' , (select id from controlled_vocabularies where code = 'STORAGE_FORMAT' and is_internal_namespace = true) - , (select id from persons where user_id ='system')); + , (select id from persons where user_id ='system') + , 1); insert into controlled_vocabulary_terms ( id , code , covo_id - , pers_id_registerer ) + , pers_id_registerer + , ordinal) values (nextval('CVTE_ID_SEQ') , 'BDS_DIRECTORY' , (select id from controlled_vocabularies where code = 'STORAGE_FORMAT' and is_internal_namespace = true) - , (select id from persons where user_id ='system')); + , (select id from persons where user_id ='system') + , 2); ------------------------------------------------------------------ -- Purpose: Insert an initial data set into the table DATA_TYPES diff --git a/openbis/source/sql/generic/043/schema-043.sql b/openbis/source/sql/generic/043/schema-043.sql index 1ce98beb3e1..e7b2fe77ad1 100644 --- a/openbis/source/sql/generic/043/schema-043.sql +++ b/openbis/source/sql/generic/043/schema-043.sql @@ -35,7 +35,7 @@ -- Creating tables CREATE TABLE CONTROLLED_VOCABULARIES (ID TECH_ID NOT NULL,CODE CODE NOT NULL,DESCRIPTION DESCRIPTION_1000,REGISTRATION_TIMESTAMP TIME_STAMP_DFL NOT NULL DEFAULT CURRENT_TIMESTAMP,PERS_ID_REGISTERER TECH_ID NOT NULL,IS_MANAGED_INTERNALLY BOOLEAN_CHAR NOT NULL DEFAULT 'F',IS_INTERNAL_NAMESPACE BOOLEAN_CHAR NOT NULL DEFAULT 'F',DBIN_ID TECH_ID NOT NULL, MODIFICATION_TIMESTAMP TIME_STAMP DEFAULT CURRENT_TIMESTAMP, IS_CHOSEN_FROM_LIST BOOLEAN_CHAR NOT NULL DEFAULT TRUE, SOURCE_URI CHARACTER VARYING(250)); -CREATE TABLE CONTROLLED_VOCABULARY_TERMS (ID TECH_ID NOT NULL,CODE OBJECT_NAME NOT NULL,REGISTRATION_TIMESTAMP TIME_STAMP_DFL NOT NULL DEFAULT CURRENT_TIMESTAMP,COVO_ID TECH_ID NOT NULL,PERS_ID_REGISTERER TECH_ID NOT NULL,LABEL COLUMN_LABEL, DESCRIPTION DESCRIPTION_1000); +CREATE TABLE CONTROLLED_VOCABULARY_TERMS (ID TECH_ID NOT NULL,CODE OBJECT_NAME NOT NULL,REGISTRATION_TIMESTAMP TIME_STAMP_DFL NOT NULL DEFAULT CURRENT_TIMESTAMP,COVO_ID TECH_ID NOT NULL,PERS_ID_REGISTERER TECH_ID NOT NULL,LABEL COLUMN_LABEL, DESCRIPTION DESCRIPTION_1000, ORDINAL BIGINT NOT NULL); CREATE TABLE DATA (ID TECH_ID NOT NULL,CODE CODE,DSTY_ID TECH_ID NOT NULL,DAST_ID TECH_ID NOT NULL,EXPE_ID TECH_ID NOT NULL,DATA_PRODUCER_CODE CODE,PRODUCTION_TIMESTAMP TIME_STAMP,SAMP_ID TECH_ID,REGISTRATION_TIMESTAMP TIME_STAMP_DFL NOT NULL DEFAULT CURRENT_TIMESTAMP,IS_PLACEHOLDER BOOLEAN_CHAR DEFAULT 'F',IS_VALID BOOLEAN_CHAR DEFAULT 'T', MODIFICATION_TIMESTAMP TIME_STAMP DEFAULT CURRENT_TIMESTAMP, IS_DERIVED BOOLEAN_CHAR NOT NULL); CREATE TABLE DATABASE_INSTANCES (ID TECH_ID NOT NULL,CODE CODE NOT NULL,UUID CODE NOT NULL,IS_ORIGINAL_SOURCE BOOLEAN_CHAR NOT NULL DEFAULT 'F',REGISTRATION_TIMESTAMP TIME_STAMP_DFL NOT NULL DEFAULT CURRENT_TIMESTAMP); CREATE TABLE DATA_SET_RELATIONSHIPS (DATA_ID_PARENT TECH_ID NOT NULL,DATA_ID_CHILD TECH_ID NOT NULL); diff --git a/openbis/source/sql/postgresql/migration/migration-042-043.sql b/openbis/source/sql/postgresql/migration/migration-042-043.sql index 8e9e8cb47cc..d5d3e830c73 100644 --- a/openbis/source/sql/postgresql/migration/migration-042-043.sql +++ b/openbis/source/sql/postgresql/migration/migration-042-043.sql @@ -16,3 +16,9 @@ CREATE INDEX GRID_CUSTOM_COLUMNS_DBIN_FK_I ON GRID_CUSTOM_COLUMNS (DBIN_ID); -- drop troublesome unique constraint in events table ALTER TABLE EVENTS DROP CONSTRAINT EVNT_BK_UK; + +-- add ordinal column to controlled vocabulary terms table with initial value equal to id +ALTER TABLE controlled_vocabulary_terms ADD COLUMN ordinal BIGINT; +UPDATE controlled_vocabulary_terms SET ordinal = id; +ALTER TABLE controlled_vocabulary_terms ALTER COLUMN ordinal SET NOT NULL; + diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/VocabularyDAOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/VocabularyDAOTest.java index b6e36d86a0e..6fd567da515 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/VocabularyDAOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/VocabularyDAOTest.java @@ -45,11 +45,12 @@ import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils; @Friend(toClasses = VocabularyPE.class) public final class VocabularyDAOTest extends AbstractDAOTest { - private final VocabularyTermPE createVocabularyTerm(final String code) + private final VocabularyTermPE createVocabularyTerm(final String code, final int ordinal) { final VocabularyTermPE vocabularyTermPE = new VocabularyTermPE(); vocabularyTermPE.setRegistrator(getSystemPerson()); vocabularyTermPE.setCode(code); + vocabularyTermPE.setOrdinal(new Long(ordinal)); return vocabularyTermPE; } @@ -92,9 +93,9 @@ public final class VocabularyDAOTest extends AbstractDAOTest vocabularyPE.setDatabaseInstance(daoFactory.getHomeDatabaseInstance()); vocabularyPE.setDescription("The format description"); vocabularyPE.setRegistrator(registrator); - vocabularyPE.addTerm(createVocabularyTerm("SMALL")); - vocabularyPE.addTerm(createVocabularyTerm("MEDIUM")); - vocabularyPE.addTerm(createVocabularyTerm("BIG:.-_-")); + vocabularyPE.addTerm(createVocabularyTerm("SMALL", 1)); + vocabularyPE.addTerm(createVocabularyTerm("MEDIUM", 2)); + vocabularyPE.addTerm(createVocabularyTerm("BIG:.-_-", 3)); vocabularyDAO.createOrUpdateVocabulary(vocabularyPE); // Check saved vocabulary. final VocabularyPE savedVocabulary = vocabularyDAO.tryFindVocabularyByCode(vocabularyCode); @@ -120,7 +121,7 @@ public final class VocabularyDAOTest extends AbstractDAOTest VocabularyTermPE termPE = vocabularyDAO.tryFindVocabularyTermByCode(vocabularyPE, realTermCode); assertNotNull(termPE); - VocabularyTermPE realTermPE = createVocabularyTerm(realTermCode); + VocabularyTermPE realTermPE = createVocabularyTerm(realTermCode, 8); realTermPE.setVocabulary(vocabularyPE); assertEquals(termPE, realTermPE); } diff --git a/openbis/sourceTest/sql/postgresql/043/006=controlled_vocabulary_terms.tsv b/openbis/sourceTest/sql/postgresql/043/006=controlled_vocabulary_terms.tsv index 14ff418fe9e..e0474c1b72e 100644 --- a/openbis/sourceTest/sql/postgresql/043/006=controlled_vocabulary_terms.tsv +++ b/openbis/sourceTest/sql/postgresql/043/006=controlled_vocabulary_terms.tsv @@ -1,15 +1,15 @@ -1 96_WELLS_8X12 2008-11-05 09:18:00.622+01 1 1 \N \N -2 384_WELLS_16X24 2008-11-05 09:18:00.622+01 1 1 \N \N -3 1536_WELLS_32X48 2008-11-05 09:18:00.622+01 1 1 \N \N -4 PROPRIETARY 2008-11-05 09:18:00.622+01 2 1 \N \N -5 BDS_DIRECTORY 2008-11-05 09:18:00.622+01 2 1 \N \N -6 RAT 2008-11-05 09:18:30.327+01 3 2 \N \N -7 DOG 2008-11-05 09:18:30.327+01 3 2 \N \N -8 HUMAN 2008-11-05 09:18:30.327+01 3 2 \N \N -9 GORILLA 2008-11-05 09:18:30.327+01 3 2 \N \N -10 FLY 2008-11-05 09:18:30.327+01 3 2 \N \N -11 MALE 2008-11-05 09:18:30.421+01 4 2 \N \N -12 FEMALE 2008-11-05 09:18:30.421+01 4 2 \N \N -13 MAN 2008-11-05 09:18:30.983+01 5 2 \N \N -14 WOMAN 2008-11-05 09:18:30.983+01 5 2 \N \N -15 CHILD 2008-11-05 09:18:31.061+01 5 2 \N \N +1 96_WELLS_8X12 2008-11-05 09:18:00.622+01 1 1 \N \N 1 +2 384_WELLS_16X24 2008-11-05 09:18:00.622+01 1 1 \N \N 2 +3 1536_WELLS_32X48 2008-11-05 09:18:00.622+01 1 1 \N \N 3 +4 PROPRIETARY 2008-11-05 09:18:00.622+01 2 1 \N \N 4 +5 BDS_DIRECTORY 2008-11-05 09:18:00.622+01 2 1 \N \N 5 +6 RAT 2008-11-05 09:18:30.327+01 3 2 \N \N 6 +7 DOG 2008-11-05 09:18:30.327+01 3 2 \N \N 7 +8 HUMAN 2008-11-05 09:18:30.327+01 3 2 \N \N 8 +9 GORILLA 2008-11-05 09:18:30.327+01 3 2 \N \N 9 +10 FLY 2008-11-05 09:18:30.327+01 3 2 \N \N 10 +11 MALE 2008-11-05 09:18:30.421+01 4 2 \N \N 11 +12 FEMALE 2008-11-05 09:18:30.421+01 4 2 \N \N 12 +13 MAN 2008-11-05 09:18:30.983+01 5 2 \N \N 13 +14 WOMAN 2008-11-05 09:18:30.983+01 5 2 \N \N 14 +15 CHILD 2008-11-05 09:18:31.061+01 5 2 \N \N 15 diff --git a/openbis/sourceTest/sql/postgresql/043/017=database_version_logs.tsv b/openbis/sourceTest/sql/postgresql/043/017=database_version_logs.tsv index e3489de31e3..9bbc54d37f1 100644 --- a/openbis/sourceTest/sql/postgresql/043/017=database_version_logs.tsv +++ b/openbis/sourceTest/sql/postgresql/043/017=database_version_logs.tsv @@ -15,5 +15,5 @@ 039 source/sql/postgresql/migration/migration-038-039.sql SUCCESS 2009-08-03 11:21:01.768 -- Longer descriptions\\012ALTER TABLE sample_types ALTER COLUMN description TYPE DESCRIPTION_1000;\\012ALTER TABLE data_set_types ALTER COLUMN description TYPE DESCRIPTION_1000;\\012ALTER TABLE experiment_types ALTER COLUMN description TYPE DESCRIPTION_1000;\\012ALTER TABLE material_types ALTER COLUMN description TYPE DESCRIPTION_1000;\\012ALTER TABLE controlled_vocabularies ALTER COLUMN description TYPE DESCRIPTION_1000;\\012ALTER TABLE data_types ALTER COLUMN description TYPE DESCRIPTION_1000;\\012ALTER TABLE file_format_types ALTER COLUMN description TYPE DESCRIPTION_1000;\\012ALTER TABLE locator_types ALTER COLUMN description TYPE DESCRIPTION_1000;\\012ALTER TABLE property_types ALTER COLUMN description TYPE DESCRIPTION_1000;\\012ALTER TABLE events ALTER COLUMN description TYPE DESCRIPTION_1000;\\012ALTER TABLE events ALTER COLUMN reason TYPE DESCRIPTION_1000;\\012ALTER TABLE groups ALTER COLUMN description TYPE DESCRIPTION_1000;\\012ALTER TABLE invalidations ALTER COLUMN reason TYPE DESCRIPTION_1000;\\012\\012\\012DROP TYPE DESCRIPTION_250;\\012\\012-- Add label and description to controlled vocabularies\\012\\012ALTER TABLE CONTROLLED_VOCABULARY_TERMS ADD COLUMN label COLUMN_LABEL;\\012ALTER TABLE CONTROLLED_VOCABULARY_TERMS ADD COLUMN description DESCRIPTION_1000;\\012\\012-- Add authorization groups\\012\\012CREATE TABLE AUTHORIZATION_GROUPS (ID TECH_ID NOT NULL, DBIN_ID TECH_ID NOT NULL, CODE CODE NOT NULL, DESCRIPTION DESCRIPTION_1000,REGISTRATION_TIMESTAMP TIME_STAMP_DFL NOT NULL DEFAULT CURRENT_TIMESTAMP, PERS_ID_REGISTERER TECH_ID NOT NULL, MODIFICATION_TIMESTAMP TIME_STAMP DEFAULT CURRENT_TIMESTAMP);\\012ALTER TABLE AUTHORIZATION_GROUPS ADD CONSTRAINT AG_PK PRIMARY KEY(ID);\\012ALTER TABLE AUTHORIZATION_GROUPS ADD CONSTRAINT AG_BK_UK UNIQUE(CODE,DBIN_ID);\\012ALTER TABLE AUTHORIZATION_GROUPS ADD CONSTRAINT AG_DBIN_FK FOREIGN KEY (DBIN_ID) REFERENCES DATABASE_INSTANCES(ID);\\012ALTER TABLE AUTHORIZATION_GROUPS ADD CONSTRAINT AG_PERS_FK FOREIGN KEY (PERS_ID_REGISTERER) REFERENCES PERSONS(ID);\\012CREATE SEQUENCE AUTHORIZATION_GROUP_ID_SEQ;\\012\\012CREATE TABLE AUTHORIZATION_GROUP_PERSONS (AG_ID TECH_ID NOT NULL, PERS_ID TECH_ID NOT NULL);\\012ALTER TABLE AUTHORIZATION_GROUP_PERSONS ADD CONSTRAINT AGP_PK PRIMARY KEY(PERS_ID,AG_ID);\\012ALTER TABLE AUTHORIZATION_GROUP_PERSONS ADD CONSTRAINT AGP_AG_FK FOREIGN KEY (AG_ID) REFERENCES AUTHORIZATION_GROUPS(ID);\\012ALTER TABLE AUTHORIZATION_GROUP_PERSONS ADD CONSTRAINT AGP_PERS_FK FOREIGN KEY (PERS_ID) REFERENCES PERSONS(ID);\\012\\012ALTER TABLE ROLE_ASSIGNMENTS ALTER COLUMN PERS_ID_GRANTEE DROP NOT NULL;\\012ALTER TABLE ROLE_ASSIGNMENTS ADD COLUMN AG_ID_GRANTEE TECH_ID;\\012ALTER TABLE ROLE_ASSIGNMENTS DROP CONSTRAINT ROAS_GROUP_BK_UK;\\012ALTER TABLE ROLE_ASSIGNMENTS DROP CONSTRAINT ROAS_INSTANCE_BK_UK;\\012ALTER TABLE ROLE_ASSIGNMENTS ADD CONSTRAINT ROAS_AG_PERS_ARC_CK CHECK ((AG_ID_GRANTEE IS NOT NULL AND PERS_ID_GRANTEE IS NULL) OR (AG_ID_GRANTEE IS NULL AND PERS_ID_GRANTEE IS NOT NULL));\\012CREATE INDEX ROAS_AG_FK_I_GRANTEE ON ROLE_ASSIGNMENTS (AG_ID_GRANTEE);\\012\\012CREATE UNIQUE INDEX ROAS_ROLE_GROUP_DBI_AG_PERS_UQ_I ON ROLE_ASSIGNMENTS (ROLE_CODE, COALESCE(PERS_ID_GRANTEE,-1), COALESCE(AG_ID_GRANTEE,-1), COALESCE(GROU_ID,-1), COALESCE(DBIN_ID,-1));\\012\\012GRANT SELECT ON SEQUENCE AUTHORIZATION_GROUP_ID_SEQ TO GROUP OPENBIS_READONLY;\\012GRANT SELECT ON TABLE AUTHORIZATION_GROUPS TO GROUP OPENBIS_READONLY;\\012GRANT SELECT ON TABLE AUTHORIZATION_GROUP_PERSONS TO GROUP OPENBIS_READONLY;\\012\\012-- remove group leader and parent\\012\\012ALTER TABLE groups DROP COLUMN grou_id_parent;\\012ALTER TABLE groups DROP COLUMN pers_id_leader;\\012 \N 040 source/sql/postgresql/migration/migration-039-040.sql SUCCESS 2009-08-11 16:04:43.88 -- Change events table check constraint (add 'AUTHORIZATION_GROUP')\\012\\012ALTER TABLE events DROP CONSTRAINT evnt_et_enum_ck;\\012ALTER TABLE events ADD CONSTRAINT evnt_et_enum_ck CHECK \\012\\011\\011(entity_type IN ('ATTACHMENT', 'DATASET', 'EXPERIMENT', 'GROUP', 'MATERIAL', 'PROJECT', 'PROPERTY_TYPE', 'SAMPLE', 'VOCABULARY', 'AUTHORIZATION_GROUP'));\\012 \N 041 source/sql/postgresql/migration/migration-040-041.sql SUCCESS 2009-09-14 13:48:57.539 -- Create FILTERS table\\012\\012CREATE TABLE FILTERS (ID TECH_ID NOT NULL, DBIN_ID TECH_ID NOT NULL, NAME VARCHAR(200) NOT NULL, DESCRIPTION DESCRIPTION_1000,REGISTRATION_TIMESTAMP TIME_STAMP_DFL NOT NULL DEFAULT CURRENT_TIMESTAMP, PERS_ID_REGISTERER TECH_ID NOT NULL, MODIFICATION_TIMESTAMP TIME_STAMP DEFAULT CURRENT_TIMESTAMP, EXPRESSION VARCHAR(2000) NOT NULL, IS_PUBLIC BOOLEAN NOT NULL, GRID_ID VARCHAR(200) NOT NULL);\\012CREATE SEQUENCE FILTER_ID_SEQ;\\012ALTER TABLE FILTERS ADD CONSTRAINT FILT_PK PRIMARY KEY(ID);\\012ALTER TABLE FILTERS ADD CONSTRAINT FILT_BK_UK UNIQUE(NAME, DBIN_ID, GRID_ID);\\012ALTER TABLE FILTERS ADD CONSTRAINT FILT_PERS_FK FOREIGN KEY (PERS_ID_REGISTERER) REFERENCES PERSONS(ID);\\012ALTER TABLE FILTERS ADD CONSTRAINT FILT_DBIN_FK FOREIGN KEY (DBIN_ID) REFERENCES DATABASE_INSTANCES(ID);\\012CREATE INDEX FILT_PERS_FK_I ON FILTERS (PERS_ID_REGISTERER);\\012CREATE INDEX FILT_DBIN_FK_I ON FILTERS (DBIN_ID);\\012GRANT SELECT ON SEQUENCE filter_id_seq TO GROUP OPENBIS_READONLY;\\012GRANT SELECT ON TABLE filters TO GROUP OPENBIS_READONLY;\\012\\012-- Add missing foreign key to role assignments authorization group\\012ALTER TABLE ROLE_ASSIGNMENTS ADD CONSTRAINT ROAS_AG_FK_GRANTEE FOREIGN KEY (AG_ID_GRANTEE) REFERENCES AUTHORIZATION_GROUPS(ID);\\012\\012--------------------------------------------------------------------------------------------------\\012-- Modify dataset connections:\\012-- 1. connection with sample shouldn't be mandatory any more\\012-- 2. introduce an arc condition that dataset cannot be connected with a sample and a parent dataset at the same time\\012--------------------------------------------------------------------------------------------------\\012\\012-- Weaken data-sample connection constraint - allow dataset to have no connection with sample\\012ALTER TABLE data ALTER COLUMN samp_id DROP NOT NULL;\\012\\012-- Remove data-sample connection for datasets that have a parent\\012\\012UPDATE data \\012 SET samp_id = NULL \\012 WHERE id IN (SELECT DISTINCT data_id_child FROM data_set_relationships);\\012\\012-- With PostgreSQL 8.4 one can check that before migration there were no cycles in dataset relationships:\\012--\\012-- WITH RECURSIVE data_set_parents(id, parent_ids, cycle) AS (\\012-- SELECT r.data_id_child AS id, \\012-- ARRAY[CAST (r.data_id_parent AS bigint)] AS parent_ids, \\012-- false AS cycle \\012-- FROM data_set_relationships r\\012-- UNION ALL\\012-- SELECT r.data_id_child,\\012-- CAST (r.data_id_parent AS bigint) || p.parent_ids,\\012-- r.data_id_child = ANY(p.parent_ids)\\012-- FROM data_set_relationships r, data_set_parents p\\012-- WHERE r.data_id_parent = p.id AND NOT cycle\\012-- )\\012-- SELECT count(*) AS cycles FROM data_set_parents WHERE cycle = true;\\012\\012---------------------------------------------------------------------------------------------------\\012-- Purpose: Create DEFERRED triggers:\\012-- * check_dataset_relationships_on_data_table_modification,\\012-- * check_dataset_relationships_on_relationships_table_modification.\\012-- They check that after all modifications of database (just before commit) \\012-- if 'data'/'data_set_relationships' tables are among modified tables \\012-- dataset is not connected with a sample and a parent dataset at the same time.\\012-- This connections are held in two different tables so simple immediate trigger \\012-- with arc check cannot be used and we need two deferred triggers.\\012----------------------------------------------------------------------------------------------------\\012\\012-- trigger for 'data' table\\012\\012CREATE OR REPLACE FUNCTION check_dataset_relationships_on_data_table_modification() RETURNS trigger AS $$\\012DECLARE\\012\\011counter\\011INTEGER;\\012BEGIN\\012\\011-- if there is a connection with a Sample there should not be any connection with a parent Data Set\\012\\011IF (NEW.samp_id IS NOT NULL) THEN\\012\\011\\011-- count number of parents\\012\\011\\011SELECT count(*) INTO counter \\012\\011\\011\\011FROM data_set_relationships \\012\\011\\011\\011WHERE data_id_child = OLD.id;\\012\\011\\011IF (counter > 0) THEN\\012\\011\\011\\011RAISE EXCEPTION 'Insert/Update of Data Set (Code: %) failed because it cannot be connected with a Sample and a parent Data Set at the same time.', OLD.code;\\012\\011\\011END IF;\\012\\011END IF;\\012 RETURN NEW;\\012END;\\012$$ LANGUAGE 'plpgsql';\\012\\012CREATE CONSTRAINT TRIGGER check_dataset_relationships_on_data_table_modification \\012 AFTER INSERT OR UPDATE ON data\\012\\011DEFERRABLE INITIALLY DEFERRED\\012\\011FOR EACH ROW \\012\\011EXECUTE PROCEDURE check_dataset_relationships_on_data_table_modification();\\012\\012-- trigger for 'data_set_relationships'\\012\\012CREATE OR REPLACE FUNCTION check_dataset_relationships_on_relationships_table_modification() RETURNS trigger AS $$\\012DECLARE\\012\\011counter\\011INTEGER;\\012\\011sample_id\\011TECH_ID;\\012\\011data_code\\011CODE;\\012BEGIN\\012\\011-- child will have a parent added so it should not be connected with any sample\\012\\011SELECT samp_id, code INTO sample_id, data_code \\012\\011\\011FROM data \\012\\011\\011WHERE id = NEW.data_id_child;\\012\\011IF (sample_id IS NOT NULL) THEN\\012\\011\\011RAISE EXCEPTION 'Insert/Update of Data Set (Code: %) failed because it cannot be connected to a Sample and to a parent Data Set at the same time.', data_code;\\012\\011END IF;\\012\\011RETURN NEW;\\012END;\\012$$ LANGUAGE 'plpgsql';\\012 \\012CREATE CONSTRAINT TRIGGER check_dataset_relationships_on_relationships_table_modification \\012 AFTER INSERT OR UPDATE ON data_set_relationships\\012\\011DEFERRABLE INITIALLY DEFERRED\\012\\011FOR EACH ROW \\012\\011EXECUTE PROCEDURE check_dataset_relationships_on_relationships_table_modification();\\012 \N -042 source/sql/postgresql/migration/migration-041-042.sql SUCCESS 2009-10-06 16:18:17.233 -- Make some labels wider\\012alter table CONTROLLED_VOCABULARY_TERMS alter column LABEL type varchar(128);\\012alter table PROPERTY_TYPES alter column LABEL type varchar(128);\\012drop domain COLUMN_LABEL;\\012create domain COLUMN_LABEL as varchar(128);\\012alter table CONTROLLED_VOCABULARY_TERMS alter column LABEL type COLUMN_LABEL;\\012alter table PROPERTY_TYPES alter column LABEL type COLUMN_LABEL;\\012 \N -043 source/sql/postgresql/migration/migration-042-043.sql SUCCESS 2009-10-06 16:18:17.347 -- Migration from 042 to 043\\012CREATE DOMAIN GRID_EXPRESSION AS VARCHAR(2000);\\012CREATE DOMAIN GRID_ID AS VARCHAR(200);\\012\\012CREATE TABLE GRID_CUSTOM_COLUMNS (ID TECH_ID NOT NULL, DBIN_ID TECH_ID NOT NULL, CODE VARCHAR(200) NOT NULL, LABEL column_label NOT NULL, DESCRIPTION DESCRIPTION_1000,REGISTRATION_TIMESTAMP TIME_STAMP_DFL NOT NULL DEFAULT CURRENT_TIMESTAMP, PERS_ID_REGISTERER TECH_ID NOT NULL, MODIFICATION_TIMESTAMP TIME_STAMP DEFAULT CURRENT_TIMESTAMP, EXPRESSION GRID_EXPRESSION NOT NULL, IS_PUBLIC BOOLEAN NOT NULL, GRID_ID GRID_ID NOT NULL);\\012CREATE SEQUENCE GRID_CUSTOM_COLUMNS_ID_SEQ;\\012ALTER TABLE GRID_CUSTOM_COLUMNS ADD CONSTRAINT GRID_CUSTOM_COLUMNS_PK PRIMARY KEY(ID);\\012ALTER TABLE GRID_CUSTOM_COLUMNS ADD CONSTRAINT GRID_CUSTOM_COLUMNS_BK_UK UNIQUE(CODE, DBIN_ID, GRID_ID);\\012\\012ALTER TABLE GRID_CUSTOM_COLUMNS ADD CONSTRAINT GRID_CUSTOM_COLUMNS_PERS_FK FOREIGN KEY (PERS_ID_REGISTERER) REFERENCES PERSONS(ID);\\012ALTER TABLE GRID_CUSTOM_COLUMNS ADD CONSTRAINT GRID_CUSTOM_COLUMNS_DBIN_FK FOREIGN KEY (DBIN_ID) REFERENCES DATABASE_INSTANCES(ID);\\012\\012CREATE INDEX GRID_CUSTOM_COLUMNS_PERS_FK_I ON GRID_CUSTOM_COLUMNS (PERS_ID_REGISTERER);\\012CREATE INDEX GRID_CUSTOM_COLUMNS_DBIN_FK_I ON GRID_CUSTOM_COLUMNS (DBIN_ID);\\012 \N +042 source/sql/postgresql/migration/migration-041-042.sql SUCCESS 2009-10-08 13:44:05.722 -- Make some labels wider\\012alter table CONTROLLED_VOCABULARY_TERMS alter column LABEL type varchar(128);\\012alter table PROPERTY_TYPES alter column LABEL type varchar(128);\\012drop domain COLUMN_LABEL;\\012create domain COLUMN_LABEL as varchar(128);\\012alter table CONTROLLED_VOCABULARY_TERMS alter column LABEL type COLUMN_LABEL;\\012alter table PROPERTY_TYPES alter column LABEL type COLUMN_LABEL;\\012 \N +043 source/sql/postgresql/migration/migration-042-043.sql SUCCESS 2009-10-08 13:44:05.82 -- Migration from 042 to 043\\012CREATE DOMAIN GRID_EXPRESSION AS VARCHAR(2000);\\012CREATE DOMAIN GRID_ID AS VARCHAR(200);\\012\\012CREATE TABLE GRID_CUSTOM_COLUMNS (ID TECH_ID NOT NULL, DBIN_ID TECH_ID NOT NULL, CODE VARCHAR(200) NOT NULL, LABEL column_label NOT NULL, DESCRIPTION DESCRIPTION_1000,REGISTRATION_TIMESTAMP TIME_STAMP_DFL NOT NULL DEFAULT CURRENT_TIMESTAMP, PERS_ID_REGISTERER TECH_ID NOT NULL, MODIFICATION_TIMESTAMP TIME_STAMP DEFAULT CURRENT_TIMESTAMP, EXPRESSION GRID_EXPRESSION NOT NULL, IS_PUBLIC BOOLEAN NOT NULL, GRID_ID GRID_ID NOT NULL);\\012CREATE SEQUENCE GRID_CUSTOM_COLUMNS_ID_SEQ;\\012ALTER TABLE GRID_CUSTOM_COLUMNS ADD CONSTRAINT GRID_CUSTOM_COLUMNS_PK PRIMARY KEY(ID);\\012ALTER TABLE GRID_CUSTOM_COLUMNS ADD CONSTRAINT GRID_CUSTOM_COLUMNS_BK_UK UNIQUE(CODE, DBIN_ID, GRID_ID);\\012\\012ALTER TABLE GRID_CUSTOM_COLUMNS ADD CONSTRAINT GRID_CUSTOM_COLUMNS_PERS_FK FOREIGN KEY (PERS_ID_REGISTERER) REFERENCES PERSONS(ID);\\012ALTER TABLE GRID_CUSTOM_COLUMNS ADD CONSTRAINT GRID_CUSTOM_COLUMNS_DBIN_FK FOREIGN KEY (DBIN_ID) REFERENCES DATABASE_INSTANCES(ID);\\012\\012CREATE INDEX GRID_CUSTOM_COLUMNS_PERS_FK_I ON GRID_CUSTOM_COLUMNS (PERS_ID_REGISTERER);\\012CREATE INDEX GRID_CUSTOM_COLUMNS_DBIN_FK_I ON GRID_CUSTOM_COLUMNS (DBIN_ID);\\012\\012-- drop troublesome unique constraint in events table\\012\\012ALTER TABLE EVENTS DROP CONSTRAINT EVNT_BK_UK;\\012\\012-- add ordinal column to controlled vocabulary terms table with initial value equal to id\\012ALTER TABLE controlled_vocabulary_terms ADD COLUMN ordinal BIGINT;\\012UPDATE controlled_vocabulary_terms SET ordinal = id;\\012ALTER TABLE controlled_vocabulary_terms ALTER COLUMN ordinal SET NOT NULL;\\012\\012 \N diff --git a/openbis/sourceTest/sql/postgresql/043/finish-043.sql b/openbis/sourceTest/sql/postgresql/043/finish-043.sql index 39973ab7063..d7188977417 100644 --- a/openbis/sourceTest/sql/postgresql/043/finish-043.sql +++ b/openbis/sourceTest/sql/postgresql/043/finish-043.sql @@ -62,8 +62,6 @@ ALTER TABLE ONLY experiment_type_property_types ADD CONSTRAINT etpt_bk_uk UNIQUE (exty_id, prty_id); ALTER TABLE ONLY experiment_type_property_types ADD CONSTRAINT etpt_pk PRIMARY KEY (id); -ALTER TABLE ONLY events - ADD CONSTRAINT evnt_bk_uk UNIQUE (event_type, entity_type, identifier); ALTER TABLE ONLY events ADD CONSTRAINT evnt_pk PRIMARY KEY (id); ALTER TABLE ONLY attachment_contents @@ -496,5 +494,24 @@ REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; - +REVOKE ALL ON SEQUENCE authorization_group_id_seq FROM PUBLIC; +REVOKE ALL ON SEQUENCE authorization_group_id_seq FROM buczekp; +GRANT ALL ON SEQUENCE authorization_group_id_seq TO buczekp; +GRANT SELECT ON SEQUENCE authorization_group_id_seq TO openbis_readonly; +REVOKE ALL ON TABLE authorization_group_persons FROM PUBLIC; +REVOKE ALL ON TABLE authorization_group_persons FROM buczekp; +GRANT ALL ON TABLE authorization_group_persons TO buczekp; +GRANT SELECT ON TABLE authorization_group_persons TO openbis_readonly; +REVOKE ALL ON TABLE authorization_groups FROM PUBLIC; +REVOKE ALL ON TABLE authorization_groups FROM buczekp; +GRANT ALL ON TABLE authorization_groups TO buczekp; +GRANT SELECT ON TABLE authorization_groups TO openbis_readonly; +REVOKE ALL ON SEQUENCE filter_id_seq FROM PUBLIC; +REVOKE ALL ON SEQUENCE filter_id_seq FROM buczekp; +GRANT ALL ON SEQUENCE filter_id_seq TO buczekp; +GRANT SELECT ON SEQUENCE filter_id_seq TO openbis_readonly; +REVOKE ALL ON TABLE filters FROM PUBLIC; +REVOKE ALL ON TABLE filters FROM buczekp; +GRANT ALL ON TABLE filters TO buczekp; +GRANT SELECT ON TABLE filters TO openbis_readonly; diff --git a/openbis/sourceTest/sql/postgresql/043/schema-043.sql b/openbis/sourceTest/sql/postgresql/043/schema-043.sql index 86e13626443..e97eb3e2706 100644 --- a/openbis/sourceTest/sql/postgresql/043/schema-043.sql +++ b/openbis/sourceTest/sql/postgresql/043/schema-043.sql @@ -342,7 +342,8 @@ CREATE TABLE controlled_vocabulary_terms ( covo_id tech_id NOT NULL, pers_id_registerer tech_id NOT NULL, label column_label, - description description_1000 + description description_1000, + ordinal bigint NOT NULL ); CREATE SEQUENCE cvte_id_seq INCREMENT BY 1 -- GitLab