diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/ExternalDataModel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/ExternalDataModel.java index c9acdf18b1c08c80f788ea9271fb42079eb97797..f4bc2b62c14366704193cab1cc61a1f7c9941656 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/ExternalDataModel.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/ExternalDataModel.java @@ -71,7 +71,9 @@ public final class ExternalDataModel extends BaseEntityModel<ExternalData> public static ColumnDefsAndConfigs<ExternalData> createColumnsSchema( IMessageProvider messageProvider) { - return BaseEntityModel.createColumnConfigs(CommonExternalDataColDefKind.values(), - messageProvider); + ColumnDefsAndConfigs<ExternalData> columns = + BaseEntityModel.createColumnConfigs(CommonExternalDataColDefKind.values(), + messageProvider); + return columns; } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetPropertyColDef.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetPropertyColDef.java new file mode 100644 index 0000000000000000000000000000000000000000..1db7a62ae6c1e90d80c7af1d486e8c3a3870e499 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetPropertyColDef.java @@ -0,0 +1,53 @@ +/* + * Copyright 2009 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.specific.data; + +import java.util.List; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractPropertyColDef; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ExternalData; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetProperty; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityProperty; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; + +public final class DataSetPropertyColDef extends AbstractPropertyColDef<ExternalData> +{ + private static final String ID_PREFIX = "ds"; + + // GWT only + public DataSetPropertyColDef() + { + } + + public DataSetPropertyColDef(PropertyType propertyType, boolean isDisplayedByDefault, + int width, String propertyTypeLabel) + { + super(propertyType, isDisplayedByDefault, width, propertyTypeLabel, ID_PREFIX); + } + + @Override + protected List<? extends EntityProperty<?, ?>> getProperties(ExternalData entity) + { + return getDataSetProperties(entity); + } + + public static List<DataSetProperty> getDataSetProperties(ExternalData entity) + { + return entity.getDataSetProperties(); + } + +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetSearchFieldsSelectionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetSearchFieldsSelectionWidget.java index 7090573515c75b31ee5abee890a120ceecfc7319..ac6f4de5f05e9e1adbd33fe5c2c7e11cd70fabdc 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetSearchFieldsSelectionWidget.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetSearchFieldsSelectionWidget.java @@ -20,9 +20,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import com.extjs.gxt.ui.client.store.ListStore; -import com.extjs.gxt.ui.client.widget.form.ComboBox; - import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync; import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; import ch.systemsx.cisd.openbis.generic.client.web.client.application.Dict; @@ -35,8 +32,12 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DefaultResultSetCo import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ResultSet; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetSearchField; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetSearchFieldKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; +import com.extjs.gxt.ui.client.store.ListStore; +import com.extjs.gxt.ui.client.widget.form.ComboBox; + /** * {@link ComboBox} containing list of search fields loaded from the server (property types) and * static ones. @@ -74,8 +75,8 @@ public final class DataSetSearchFieldsSelectionWidget extends } @Override - /** - * Always returns null. + /* + * * Always returns null. */ public PropertyType tryGetSelected() { @@ -183,6 +184,7 @@ public final class DataSetSearchFieldsSelectionWidget extends Collections.sort(types); List<String> allExpProps = addExperimentPropertyTypes(result, types); List<String> allSampleProps = addSamplePropertyTypes(result, types); + List<String> allDataSetProps = addDataSetPropertyTypes(result, types); DataSetSearchField anyExperimentProperty = DataSetSearchField.createAnyExperimentProperty(allExpProps); @@ -193,7 +195,7 @@ public final class DataSetSearchFieldsSelectionWidget extends addFieldComboModel(result, anySampleProperty); DataSetSearchField anyField = - DataSetSearchField.createAnyField(allExpProps, allSampleProps); + DataSetSearchField.createAnyField(allExpProps, allSampleProps, allDataSetProps); addFieldComboModel(result, anyField); return result; @@ -215,7 +217,15 @@ public final class DataSetSearchFieldsSelectionWidget extends { List<PropertyType> relevantPropertyTypes = DataSetSearchHitModel.filterSamplePropertyTypes(propertyTypes); - return addPropertyTypes(result, relevantPropertyTypes, false); + return addPropertyTypes(result, relevantPropertyTypes, EntityKind.SAMPLE); + } + + private static List<String> addDataSetPropertyTypes( + final List<DataSetSearchFieldComboModel> result, List<PropertyType> propertyTypes) + { + List<PropertyType> relevantPropertyTypes = + DataSetSearchHitModel.filterDataSetPropertyTypes(propertyTypes); + return addPropertyTypes(result, relevantPropertyTypes, EntityKind.DATA_SET); } private static List<String> addExperimentPropertyTypes( @@ -223,12 +233,12 @@ public final class DataSetSearchFieldsSelectionWidget extends { List<PropertyType> relevantPropertyTypes = DataSetSearchHitModel.filterExperimentPropertyTypes(propertyTypes); - return addPropertyTypes(result, relevantPropertyTypes, true); + return addPropertyTypes(result, relevantPropertyTypes, EntityKind.EXPERIMENT); } // returns codes of added properties private static List<String> addPropertyTypes(final List<DataSetSearchFieldComboModel> result, - List<PropertyType> types, boolean isExperimentProperty) + List<PropertyType> types, EntityKind kind) { List<String> allProps = new ArrayList<String>(); for (final PropertyType st : types) @@ -236,12 +246,19 @@ public final class DataSetSearchFieldsSelectionWidget extends String code = st.getCode(); allProps.add(code); DataSetSearchField field; - if (isExperimentProperty) - { - field = DataSetSearchField.createExperimentProperty(code); - } else + switch (kind) { - field = DataSetSearchField.createSampleProperty(code); + case EXPERIMENT: + field = DataSetSearchField.createExperimentProperty(code); + break; + case SAMPLE: + field = DataSetSearchField.createSampleProperty(code); + break; + case DATA_SET: + field = DataSetSearchField.createDataSetProperty(code); + break; + default: + throw new IllegalArgumentException("Unsupported entity kind."); } DataSetSearchFieldComboModel comboModel = createPropertyComboModel(st, field, isLabelDuplicated(st, types)); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetSearchHitModel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetSearchHitModel.java index ba4f09b8c2b825aaaa28f2134069e4aaf5e12c3b..7e60c6fa61dfc7a821df2d75208612ee1c47a987 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetSearchHitModel.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetSearchHitModel.java @@ -23,11 +23,14 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.Base import ch.systemsx.cisd.openbis.generic.client.web.client.application.renderer.LinkRenderer; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.IColumnDefinitionUI; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.specific.data.DataSetExperimentPropertyColDef; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.specific.data.DataSetPropertyColDef; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.specific.data.DataSetSamplePropertyColDef; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.specific.data.DataSetSearchHitColDefKind; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.ColumnDefsAndConfigs; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IMessageProvider; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ExternalData; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetProperty; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetTypePropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentTypePropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; @@ -47,6 +50,8 @@ public class DataSetSearchHitModel extends BaseEntityModel<ExternalData> private static final String LABEL_SAMPLE_PROPERTY_PREFIX = "Sample "; + private static final String LABEL_DATA_SET_PROPERTY_PREFIX = "Data Set "; + public DataSetSearchHitModel(final ExternalData entity) { super(entity, createColumnsSchema(entity)); @@ -56,10 +61,14 @@ public class DataSetSearchHitModel extends BaseEntityModel<ExternalData> // here we create the columns definition having just one table row. We need them only to render // column values (headers have been already created), so no message provider is needed. - private static List<IColumnDefinitionUI<ExternalData>> createColumnsSchema( - ExternalData entity) + private static List<IColumnDefinitionUI<ExternalData>> createColumnsSchema(ExternalData entity) { List<IColumnDefinitionUI<ExternalData>> list = createCommonColumnsSchema(null); + for (DataSetProperty prop : DataSetPropertyColDef.getDataSetProperties(entity)) + { + DataSetTypePropertyType etpt = prop.getEntityTypePropertyType(); + list.add(createDataSetPropertyTypeColDef(etpt.getPropertyType())); + } for (ExperimentProperty prop : DataSetExperimentPropertyColDef .getExperimentProperties(entity)) { @@ -74,6 +83,13 @@ public class DataSetSearchHitModel extends BaseEntityModel<ExternalData> return list; } + private static IColumnDefinitionUI<ExternalData> createDataSetPropertyTypeColDef( + PropertyType propertyType) + { + String label = LABEL_DATA_SET_PROPERTY_PREFIX + propertyType.getLabel(); + return new DataSetPropertyColDef(propertyType, true, PROPERTY_COLUMN_WIDTH, label); + } + private static IColumnDefinitionUI<ExternalData> createSamplePropertyTypeColDef( PropertyType propertyType) { @@ -96,12 +112,25 @@ public class DataSetSearchHitModel extends BaseEntityModel<ExternalData> ColumnDefsAndConfigs<ExternalData> columns = ColumnDefsAndConfigs.create(commonColumnsSchema); + columns.addColumns(createDataSetPropertyColumnsSchema(propertyTypes)); columns.addColumns(createExperimentsPropertyColumnsSchema(propertyTypes)); columns.addColumns(createSamplesPropertyColumnsSchema(propertyTypes)); return columns; } + private static List<IColumnDefinitionUI<ExternalData>> createDataSetPropertyColumnsSchema( + List<PropertyType> propertyTypes) + { + List<PropertyType> dataSetPropertyTypes = filterDataSetPropertyTypes(propertyTypes); + List<IColumnDefinitionUI<ExternalData>> list = createEmptyColDefList(); + for (PropertyType prop : dataSetPropertyTypes) + { + list.add(createDataSetPropertyTypeColDef(prop)); + } + return list; + } + private static List<IColumnDefinitionUI<ExternalData>> createSamplesPropertyColumnsSchema( List<PropertyType> propertyTypes) { @@ -164,4 +193,17 @@ public class DataSetSearchHitModel extends BaseEntityModel<ExternalData> } return result; } + + public static List<PropertyType> filterDataSetPropertyTypes(List<PropertyType> propertyTypes) + { + List<PropertyType> result = new ArrayList<PropertyType>(); + for (final PropertyType st : propertyTypes) + { + if (st.getDataSetTypePropertyTypes().size() > 0) + { + result.add(st); + } + } + return result; + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/ExternalData.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/ExternalData.java index cfd3cc2b79d82443c88db9a07aa51f88e3935530..3a07d443cecc699dfefcc62e550a119d32219a59 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/ExternalData.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/ExternalData.java @@ -20,6 +20,7 @@ import java.util.Date; import java.util.List; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.CodeWithRegistration; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE; @@ -33,7 +34,7 @@ public class ExternalData extends CodeWithRegistration<ExternalData> implements IInvalidationProvider { private String dataStoreBaseURL; - + private ProcedureType procedureType; private boolean derived; @@ -66,6 +67,8 @@ public class ExternalData extends CodeWithRegistration<ExternalData> implements private List<SampleProperty> sampleProperties; + private List<DataSetProperty> dataSetProperties; + public final ProcedureType getProcedureType() { return procedureType; @@ -235,4 +238,14 @@ public class ExternalData extends CodeWithRegistration<ExternalData> implements { this.dataStoreBaseURL = dataStoreBaseURL; } + + public void setDataSetProperties(List<DataSetProperty> dataSetProperties) + { + this.dataSetProperties = dataSetProperties; + } + + public List<DataSetProperty> getDataSetProperties() + { + return dataSetProperties; + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/translator/DataSetPropertyTranslator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/translator/DataSetPropertyTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..de56d44a3677878054107a3424be6599cce23825 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/translator/DataSetPropertyTranslator.java @@ -0,0 +1,64 @@ +/* + * Copyright 2008 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.client.web.server.translator; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.apache.commons.lang.StringEscapeUtils; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetProperty; +import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetPropertyPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetTypePropertyTypePE; + +/** + * A {@link DataSetProperty} <---> {@link DataSetPropertyPE} translator. + * + * @author Izabela Adamczyk + */ +public final class DataSetPropertyTranslator +{ + private DataSetPropertyTranslator() + { + // Can not be instantiated. + } + + public final static DataSetProperty translate(final DataSetPropertyPE propertyPE) + { + final DataSetProperty result = new DataSetProperty(); + result.setValue(StringEscapeUtils.escapeHtml(propertyPE.tryGetUntypedValue())); + result.setEntityTypePropertyType(DataSetTypePropertyTypeTranslator + .translate((DataSetTypePropertyTypePE) propertyPE.getEntityTypePropertyType())); + return result; + + } + + public final static List<DataSetProperty> translate(final Set<DataSetPropertyPE> list) + { + if (list == null) + { + return null; + } + final List<DataSetProperty> result = new ArrayList<DataSetProperty>(); + for (final DataSetPropertyPE property : list) + { + result.add(translate(property)); + } + return result; + } +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/translator/ExternalDataTranslator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/translator/ExternalDataTranslator.java index fc0fb1d9562c3404e1ad2fee2b74fec17406f2d1..43569e7024da636a9f8947ddb64f7f2204ed00a8 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/translator/ExternalDataTranslator.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/translator/ExternalDataTranslator.java @@ -32,6 +32,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Procedure; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ProcedureType; import ch.systemsx.cisd.openbis.generic.client.web.server.translator.ExperimentTranslator.LoadableFields; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AbstractType; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.dto.AbstractTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE; @@ -39,6 +40,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE; import ch.systemsx.cisd.openbis.generic.shared.dto.InvalidationPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ProcedurePE; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; +import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils; /** * @author Franz-Josef Elmer @@ -99,10 +101,23 @@ public class ExternalDataTranslator externalData.setSampleProperties(SamplePropertyTranslator.translate(sample .getProperties())); } + setProperties(externalDataPE, externalData); externalData.setProcedure(getProcedure(externalDataPE, withExperimentFields)); return externalData; } + private static void setProperties(ExternalDataPE externalDataPE, ExternalData externalData) + { + if (HibernateUtils.isInitialized(externalDataPE.getProperties())) + { + externalData.setDataSetProperties(DataSetPropertyTranslator.translate(externalDataPE + .getProperties())); + } else + { + externalData.setDataSetProperties(new ArrayList<DataSetProperty>()); + } + } + private static ProcedureType getProcedureType(ExternalDataPE externalDataPE) { ProcedurePE procedure = externalDataPE.getProcedure(); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/translator/PropertyTypeTranslator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/translator/PropertyTypeTranslator.java index 3f5c1f15c89d85f18e2a0beb381368a6d6d6ef81..a67568da21fcf7098d08a3260cb73e139b4df4cd 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/translator/PropertyTypeTranslator.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/translator/PropertyTypeTranslator.java @@ -48,8 +48,10 @@ public final class PropertyTypeTranslator return result; } - public final static PropertyType translate(final PropertyTypePE propertyType, MaterialType materialType){ - final PropertyType result = new PropertyType(); + public final static PropertyType translate(final PropertyTypePE propertyType, + MaterialType materialType) + { + final PropertyType result = new PropertyType(); result.setCode(StringEscapeUtils.escapeHtml(propertyType.getCode())); result.setSimpleCode(StringEscapeUtils.escapeHtml(propertyType.getSimpleCode())); result.setInternalNamespace(propertyType.isInternalNamespace()); @@ -57,10 +59,14 @@ public final class PropertyTypeTranslator result.setLabel(StringEscapeUtils.escapeHtml(propertyType.getLabel())); result.setDataType(DataTypeTranslator.translate(propertyType.getType())); result.setVocabulary(VocabularyTranslator.translate(propertyType.getVocabulary())); - if(materialType == null){ - result.setMaterialType(MaterialTypeTranslator.translate(propertyType.getMaterialType())); - }else{ - result.setMaterialType(materialType); + if (materialType == null) + { + result + .setMaterialType(MaterialTypeTranslator.translate(propertyType + .getMaterialType())); + } else + { + result.setMaterialType(materialType); } result.setDescription(StringEscapeUtils.escapeHtml(propertyType.getDescription())); result.setSampleTypePropertyTypes(SampleTypePropertyTypeTranslator.translate(propertyType @@ -69,9 +75,11 @@ public final class PropertyTypeTranslator propertyType.getMaterialTypePropertyTypes(), result)); result.setExperimentTypePropertyTypes(ExperimentTypePropertyTypeTranslator.translate( propertyType.getExperimentTypePropertyTypes(), result)); + result.setDataSetTypePropertyTypes(DataSetTypePropertyTypeTranslator.translate(propertyType + .getDataSetTypePropertyTypes(), result)); return result; } - + public final static PropertyType translate(final PropertyTypePE propertyType) { return translate(propertyType, null); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/PropertyTypeTable.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/PropertyTypeTable.java index 08335a13eadb55a9e9703ea52f8a09833fd47b40..c6b1c68fb44bd1830f36e156bf255d565ab29a2d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/PropertyTypeTable.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/PropertyTypeTable.java @@ -62,6 +62,7 @@ public final class PropertyTypeTable extends AbstractBusinessObject implements I HibernateUtils.initialize(pt.getMaterialTypePropertyTypes()); HibernateUtils.initialize(pt.getSampleTypePropertyTypes()); HibernateUtils.initialize(pt.getExperimentTypePropertyTypes()); + HibernateUtils.initialize(pt.getDataSetTypePropertyTypes()); HibernateUtils.initialize(pt.getVocabulary()); if (pt.getVocabulary() != null) { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAO.java index a8e65037adaa7e2ab426886820ec5f8786ddf7e8..741684b454a7c60fd4584549c19abc6c582aa288 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAO.java @@ -353,13 +353,14 @@ final class HibernateSearchDAO extends HibernateDaoSupport implements IHibernate BooleanQuery query = new BooleanQuery(); query.add(LuceneQueryBuilder.createQuery(datasetSearchCriteria), Occur.MUST); SearchAnalyzer searchAnalyzer = LuceneQueryBuilder.createSearchAnalyzer(); - query.add(LuceneQueryBuilder.parseQuery(SearchFieldConstants.DELETED, "false", searchAnalyzer), - Occur.MUST); + query.add(LuceneQueryBuilder.parseQuery(SearchFieldConstants.DELETED, "false", + searchAnalyzer), Occur.MUST); final FullTextSession fullTextSession = Search.getFullTextSession(session); final FullTextQuery hibernateQuery = fullTextSession.createFullTextQuery(query, ExternalDataPE.class); Criteria criteria = getSession().createCriteria(ExternalDataPE.class); + criteria.setFetchMode("dataSetProperties", FetchMode.JOIN); criteria.setFetchMode("parents", FetchMode.JOIN); criteria.setFetchMode("procedure", FetchMode.JOIN); criteria.setFetchMode("procedure.experimentInternal", FetchMode.JOIN); @@ -383,7 +384,6 @@ final class HibernateSearchDAO extends HibernateDaoSupport implements IHibernate } } - private void initSamplesWithProperties(SamplePE sampleOrNull) { if (sampleOrNull != null) @@ -393,5 +393,4 @@ final class HibernateSearchDAO extends HibernateDaoSupport implements IHibernate } } - } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/LuceneQueryBuilder.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/LuceneQueryBuilder.java index 69c774be7fec1dba1939fca5491f4d9dfb84c9a6..2bd4f96fe79c6235ab3f3ce2e51fdd93231483f3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/LuceneQueryBuilder.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/LuceneQueryBuilder.java @@ -41,12 +41,13 @@ import ch.systemsx.cisd.common.exceptions.InternalErr; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetSearchCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetSearchCriterion; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetSearchField; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetSearchFieldKind; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetSearchCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SearchCriteriaConnection; import ch.systemsx.cisd.openbis.generic.shared.dto.hibernate.SearchFieldConstants; +import ch.systemsx.cisd.openbis.generic.shared.dto.properties.EntityKind; /** * @author Tomasz Pylak @@ -99,10 +100,13 @@ public class LuceneQueryBuilder return getSamplePropertyIndexFields(searchField); case ANY_EXPERIMENT_PROPERTY: return getExperimentPropertyIndexFields(searchField); + case ANY_DATA_SET_PROPERTY: + return getDataSetPropertyIndexFields(searchField); case ANY_FIELD: List<String> fields = new ArrayList<String>(); fields.addAll(getSamplePropertyIndexFields(searchField)); fields.addAll(getExperimentPropertyIndexFields(searchField)); + fields.addAll(getDataSetPropertyIndexFields(searchField)); fields.addAll(getAllIndexSimpleFieldNames()); return fields; default: @@ -131,28 +135,43 @@ public class LuceneQueryBuilder private static List<String> getExperimentPropertyIndexFields(DataSetSearchField searchField) { - return getPropertyIndexFields(searchField.getAllExperimentPropertyCodes(), true); + return getPropertyIndexFields(searchField.getAllExperimentPropertyCodes(), + EntityKind.EXPERIMENT); + } + + private static List<String> getDataSetPropertyIndexFields(DataSetSearchField searchField) + { + return getPropertyIndexFields(searchField.getAllDataSetPropertyCodesOrNull(), + EntityKind.DATA_SET); } private static List<String> getSamplePropertyIndexFields(DataSetSearchField searchField) { - return getPropertyIndexFields(searchField.getAllSamplePropertyCodesOrNull(), false); + return getPropertyIndexFields(searchField.getAllSamplePropertyCodesOrNull(), + EntityKind.SAMPLE); } private static List<String> getPropertyIndexFields(List<String> allPropertyCodes, - boolean isExperiment) + EntityKind kind) { List<String> fields = new ArrayList<String>(); assert allPropertyCodes != null; for (String propertyCode : allPropertyCodes) { DataSetSearchField searchField; - if (isExperiment) - { - searchField = DataSetSearchField.createExperimentProperty(propertyCode); - } else + switch (kind) { - searchField = DataSetSearchField.createSampleProperty(propertyCode); + case EXPERIMENT: + searchField = DataSetSearchField.createExperimentProperty(propertyCode); + break; + case SAMPLE: + searchField = DataSetSearchField.createSampleProperty(propertyCode); + break; + case DATA_SET: + searchField = DataSetSearchField.createDataSetProperty(propertyCode); + break; + default: + throw new IllegalArgumentException("Unsupported entity kind"); } String fieldIndex = tryGetIndexFieldName(searchField); fields.add(fieldIndex); @@ -171,6 +190,8 @@ public class LuceneQueryBuilder return CODE; case DATA_SET_TYPE: return SearchFieldConstants.PREFIX_DATASET_TYPE + CODE; + case DATA_SET_PROPERTY: + return getPropertyIndexField(searchField.getPropertyCode()); case FILE_TYPE: return SearchFieldConstants.PREFIX_FILE_FORMAT_TYPE + CODE; case GROUP: @@ -191,6 +212,7 @@ public class LuceneQueryBuilder return PREFIX_SAMPLE + getPropertyIndexField(searchField.getPropertyCode()); case ANY_SAMPLE_PROPERTY: case ANY_EXPERIMENT_PROPERTY: + case ANY_DATA_SET_PROPERTY: case ANY_FIELD: return null; default: diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetProperty.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..fc2d0a08fed7f5c903e84f0765e9aa67ab6890c4 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetProperty.java @@ -0,0 +1,30 @@ +/* + * Copyright 2008 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic.dto; + +import com.google.gwt.user.client.rpc.IsSerializable; + +/** + * The {@link EntityProperty} extension for <i>Data Set Property</i>. + * + * @author Izabela Adamczyk + */ +public final class DataSetProperty extends EntityProperty<DataSetType, DataSetTypePropertyType> + implements IsSerializable +{ + public static final DataSetProperty[] EMPTY_ARRAY = new DataSetProperty[0]; +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetSearchField.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetSearchField.java index 9d17b2fe9bc6cb1de076e384859f009b980d6af0..a27fbd8358c029c9a4c1806c6022de30ef25b7ab 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetSearchField.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetSearchField.java @@ -35,24 +35,32 @@ public class DataSetSearchField implements IsSerializable private List<String> allSamplePropertyCodesOrNull; + private List<String> allDataSetPropertyCodesOrNull; + public static DataSetSearchField createAnyField(List<String> allExperimentPropertyCodes, - List<String> allSamplePropertyCodes) + List<String> allSamplePropertyCodes, List<String> allDataSetPropertyCodes) { return new DataSetSearchField(DataSetSearchFieldKind.ANY_FIELD, null, - allExperimentPropertyCodes, allSamplePropertyCodes); + allExperimentPropertyCodes, allSamplePropertyCodes, allDataSetPropertyCodes); } public static DataSetSearchField createAnyExperimentProperty( List<String> allExperimentPropertyCodes) { return new DataSetSearchField(DataSetSearchFieldKind.ANY_EXPERIMENT_PROPERTY, null, - allExperimentPropertyCodes, null); + allExperimentPropertyCodes, null, null); } public static DataSetSearchField createAnySampleProperty(List<String> allSamplePropertyCodes) { return new DataSetSearchField(DataSetSearchFieldKind.ANY_SAMPLE_PROPERTY, null, null, - allSamplePropertyCodes); + allSamplePropertyCodes, null); + } + + public static DataSetSearchField createAnyDataSetProperty(List<String> allDataSetPropertyCodes) + { + return new DataSetSearchField(DataSetSearchFieldKind.ANY_DATA_SET_PROPERTY, null, null, + null, allDataSetPropertyCodes); } public static DataSetSearchField createExperimentProperty(String propertyCode) @@ -60,6 +68,11 @@ public class DataSetSearchField implements IsSerializable return new DataSetSearchField(DataSetSearchFieldKind.EXPERIMENT_PROPERTY, propertyCode); } + public static DataSetSearchField createDataSetProperty(String propertyCode) + { + return new DataSetSearchField(DataSetSearchFieldKind.DATA_SET_PROPERTY, propertyCode); + } + public static DataSetSearchField createSampleProperty(String propertyCode) { return new DataSetSearchField(DataSetSearchFieldKind.SAMPLE_PROPERTY, propertyCode); @@ -80,16 +93,18 @@ public class DataSetSearchField implements IsSerializable private DataSetSearchField(DataSetSearchFieldKind kind, String propertyCodeOrNull) { - this(kind, propertyCodeOrNull, null, null); + this(kind, propertyCodeOrNull, null, null, null); } private DataSetSearchField(DataSetSearchFieldKind kind, String propertyCodeOrNull, - List<String> allExperimentPropertyCodesOrNull, List<String> allSamplePropertyCodesOrNull) + List<String> allExperimentPropertyCodesOrNull, + List<String> allSamplePropertyCodesOrNull, List<String> allDataSetPropertyCodesOrNull) { this.kind = kind; this.propertyCodeOrNull = propertyCodeOrNull; this.allExperimentPropertyCodesOrNull = allExperimentPropertyCodesOrNull; this.allSamplePropertyCodesOrNull = allSamplePropertyCodesOrNull; + this.allDataSetPropertyCodesOrNull = allDataSetPropertyCodesOrNull; } public DataSetSearchFieldKind getKind() @@ -100,7 +115,8 @@ public class DataSetSearchField implements IsSerializable public String getPropertyCode() { assert kind == DataSetSearchFieldKind.EXPERIMENT_PROPERTY - || kind == DataSetSearchFieldKind.SAMPLE_PROPERTY; + || kind == DataSetSearchFieldKind.SAMPLE_PROPERTY + || kind == DataSetSearchFieldKind.DATA_SET_PROPERTY; return propertyCodeOrNull; } @@ -118,13 +134,21 @@ public class DataSetSearchField implements IsSerializable return allSamplePropertyCodesOrNull; } + public List<String> getAllDataSetPropertyCodesOrNull() + { + assert kind == DataSetSearchFieldKind.ANY_DATA_SET_PROPERTY + || kind == DataSetSearchFieldKind.ANY_FIELD; + return allDataSetPropertyCodesOrNull; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getKind()); if (getKind().equals(DataSetSearchFieldKind.EXPERIMENT_PROPERTY) - || getKind().equals(DataSetSearchFieldKind.SAMPLE_PROPERTY)) + || getKind().equals(DataSetSearchFieldKind.SAMPLE_PROPERTY) + || getKind().equals(DataSetSearchFieldKind.DATA_SET_PROPERTY)) { sb.append("."); sb.append(getPropertyCode()); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetSearchFieldKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetSearchFieldKind.java index 13280faad032a8a47314e7f028ffeeac05973fc2..6ad78a605419bc9be53123288feeb0c0a34eb1a6 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetSearchFieldKind.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetSearchFieldKind.java @@ -33,6 +33,8 @@ public enum DataSetSearchFieldKind implements IsSerializable ANY_EXPERIMENT_PROPERTY("Any Experiment Property", true), ANY_SAMPLE_PROPERTY("Any Sample Property", true), + + ANY_DATA_SET_PROPERTY("Any Data Set Property", true), DATA_SET_CODE("Data Set Code"), @@ -53,8 +55,11 @@ public enum DataSetSearchFieldKind implements IsSerializable SAMPLE_TYPE("Sample Type"), EXPERIMENT_PROPERTY("Experiment Property", true), + + DATA_SET_PROPERTY("Data Set Property", true), SAMPLE_PROPERTY("Sample Property", true); + private final String description; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PropertyType.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PropertyType.java index e8c4c43c0a78479fdafd3c819239895833577dd3..a4c5b5b715a2c12665a4462e815bb63362a2eddd 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PropertyType.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PropertyType.java @@ -18,10 +18,10 @@ package ch.systemsx.cisd.openbis.generic.shared.basic.dto; import java.util.List; -import com.google.gwt.user.client.rpc.IsSerializable; - import ch.systemsx.cisd.openbis.generic.shared.dto.PropertyTypePE; +import com.google.gwt.user.client.rpc.IsSerializable; + /** * The <i>GWT</i> pendant to {@link PropertyTypePE}. * @@ -60,6 +60,8 @@ public class PropertyType extends Code<PropertyType> implements IsSerializable private List<MaterialTypePropertyType> materialTypePropertyTypes; private List<ExperimentTypePropertyType> experimentTypePropertyTypes; + + private List<DataSetTypePropertyType> dataSetTypePropertyTypes; public String getSimpleCode() { @@ -131,6 +133,15 @@ public class PropertyType extends Code<PropertyType> implements IsSerializable { this.sampleTypePropertyTypes = sampleTypePropertyTypes; } + + public List<DataSetTypePropertyType> getDataSetTypePropertyTypes() { + return dataSetTypePropertyTypes; + } + + public void setDataSetTypePropertyTypes( + final List<DataSetTypePropertyType> dataSetTypePropertyTypes) { + this.dataSetTypePropertyTypes = dataSetTypePropertyTypes; + } public List<MaterialTypePropertyType> getMaterialTypePropertyTypes() { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataPE.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataPE.java index 944994f99e07ac1cec2e04620437d790c3eb5e19..9460a39a442a0bee103eb40cd0f4d058d5a6b5dc 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataPE.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataPE.java @@ -60,310 +60,340 @@ import ch.systemsx.cisd.openbis.generic.shared.GenericSharedConstants; import ch.systemsx.cisd.openbis.generic.shared.dto.hibernate.SearchFieldConstants; /** - * Kind of <i>Java Bean</i> or <i>Value Object</i> which contains any - * information we would like to know about one DATA. + * Kind of <i>Java Bean</i> or <i>Value Object</i> which contains any information we would like to + * know about one DATA. * <p> - * This class is the <i>Java Object</i> representation of the corresponding data - * in the database. + * This class is the <i>Java Object</i> representation of the corresponding data in the database. * </p> * * @author Bernd Rinn */ @Entity @Table(name = TableNames.DATA_TABLE, uniqueConstraints = @UniqueConstraint(columnNames = ColumnNames.CODE_COLUMN)) -@Check(constraints = "(" + ColumnNames.SAMPLE_ACQUIRED_FROM - + " IS NOT NULL AND " + ColumnNames.SAMPLE_DERIVED_FROM - + " IS NULL) OR (" + ColumnNames.SAMPLE_ACQUIRED_FROM + " IS NULL AND " - + ColumnNames.SAMPLE_DERIVED_FROM + " IS NOT NULL)") +@Check(constraints = "(" + ColumnNames.SAMPLE_ACQUIRED_FROM + " IS NOT NULL AND " + + ColumnNames.SAMPLE_DERIVED_FROM + " IS NULL) OR (" + ColumnNames.SAMPLE_ACQUIRED_FROM + + " IS NULL AND " + ColumnNames.SAMPLE_DERIVED_FROM + " IS NOT NULL)") @Inheritance(strategy = InheritanceType.JOINED) @Friend(toClasses = EventPE.class) public class DataPE extends AbstractIdAndCodeHolder<DataPE> implements - IEntityPropertiesHolder<DataSetPropertyPE> + IEntityPropertiesHolder<DataSetPropertyPE> { - private static final long serialVersionUID = GenericSharedConstants.VERSION; - - public static final DataPE[] EMPTY_ARRAY = new DataPE[0]; - - private transient Long id; - - private String code; - - private boolean placeholder; - - private boolean deleted; - - /** Registration date of the database instance. */ - private Date registrationDate; - - private DataSetTypePE dataSetType; - - private ProcedurePE procedure; - - private Date productionDate; - - private String dataProducerCode; - - private SamplePE sampleAcquiredFrom; - - private SamplePE sampleDerivedFrom; - - private Set<DataPE> parents = new HashSet<DataPE>(); - - private Set<EventPE> events = new HashSet<EventPE>(); - - @Column(name = ColumnNames.REGISTRATION_TIMESTAMP_COLUMN, nullable = false, insertable = false) - @Generated(GenerationTime.ALWAYS) - public Date getRegistrationDate() { - return HibernateAbstractRegistrationHolder.getDate(registrationDate); - } - - public void setRegistrationDate(final Date registrationDate) { - this.registrationDate = registrationDate; - } - - @ManyToOne(fetch = FetchType.EAGER) - @NotNull(message = ValidationMessages.DATA_SET_TYPE_NOT_NULL_MESSAGE) - @JoinColumn(name = ColumnNames.DATA_SET_TYPE_COLUMN) - @IndexedEmbedded(prefix = SearchFieldConstants.PREFIX_DATASET_TYPE) - /* * Returns <code>dataSetType</code>. */ - public DataSetTypePE getDataSetType() { - return dataSetType; - } - - /** Sets <code>dataSetType</code>. */ - public void setDataSetType(final DataSetTypePE dataSetType) { - this.dataSetType = dataSetType; - } - - /** - * Returns <code>true</code> if this data set is a placeholder for a data - * set yet to arrive. - */ - @Column(name = ColumnNames.IS_PLACEHOLDER_COLUMN) - public boolean isPlaceholder() { - return placeholder; - } - - /** - * Set to <code>true</code> if this data set is a placeholder for a data set - * yet to arrive. - */ - public void setPlaceholder(final boolean placeholder) { - this.placeholder = placeholder; - } - - @Column(name = ColumnNames.IS_DELETED_COLUMN) - @Field(index = Index.UN_TOKENIZED, store = Store.YES, name = SearchFieldConstants.DELETED) - public boolean isDeleted() { - return deleted; - } - - public void setDeleted(boolean deleted) { - this.deleted = deleted; - } - - @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name = ColumnNames.SAMPLE_ACQUIRED_FROM) - @IndexedEmbedded(prefix = SearchFieldConstants.PREFIX_SAMPLE) - public SamplePE getSampleAcquiredFrom() { - return sampleAcquiredFrom; - } - - @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name = ColumnNames.SAMPLE_DERIVED_FROM) - @IndexedEmbedded(prefix = SearchFieldConstants.PREFIX_SAMPLE) - public SamplePE getSampleDerivedFrom() { - return sampleDerivedFrom; - } - - public void setSampleAcquiredFrom(final SamplePE sampleAcquiredFrom) { - this.sampleAcquiredFrom = sampleAcquiredFrom; - } - - public void setSampleDerivedFrom(final SamplePE sampleDerivedFrom) { - this.sampleDerivedFrom = sampleDerivedFrom; - } - - @Transient - public String getAssociatedSampleCode() { - final SamplePE sample = sampleAcquiredFrom != null ? sampleAcquiredFrom - : sampleDerivedFrom; - return sample != null ? sample.getCode() : null; - } - - /** - * Returns the date when the measurement / calculation that produced this - * external data set has been performed. - * <p> - * This may not be known in which case this method will return - * <code>null</code>. - */ - @Column(name = ColumnNames.PRODUCTION_TIMESTAMP_COLUMN) - public Date getProductionDate() { - return HibernateAbstractRegistrationHolder.getDate(productionDate); - } - - /** - * Sets the date when the measurement / calculation that produced this - * external data set has been performed. - */ - public void setProductionDate(final Date productionDate) { - this.productionDate = productionDate; - } - - /** - * Returns the code identifying the data source (i.e. measurement device or - * software pipeline) that produced this external data set. - * <p> - * This may not be known in which case this method will return - * <code>null</code>. - * </p> - */ - @Length(min = 1, max = 40, message = ValidationMessages.CODE_LENGTH_MESSAGE) - @Column(name = ColumnNames.DATA_PRODUCER_CODE_COLUMN) - public String getDataProducerCode() { - return dataProducerCode; - } - - /** - * Sets the code identifying the data source (i.e. measurement device or - * software pipeline) that produced this external data set. - */ - public void setDataProducerCode(final String dataProducerCode) { - this.dataProducerCode = dataProducerCode; - } - - public void setId(final Long id) { - this.id = id; - } - - /** - * Sets the code (i.e. the externally used unique identifier) of this - * external data. - */ - public void setCode(final String code) { - this.code = code; - } - - @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinTable(name = TableNames.DATA_SET_RELATIONSHIPS_TABLE, joinColumns = @JoinColumn(name = ColumnNames.DATA_CHILD_COLUMN), inverseJoinColumns = @JoinColumn(name = ColumnNames.DATA_PARENT_COLUMN)) - public Set<DataPE> getParents() { - return parents; - } - - public void setParents(final Set<DataPE> parents) { - this.parents = parents; - } - - // - // AbstractIdAndCodeHolder - // - - @Id - @SequenceGenerator(name = SequenceNames.DATA_SEQUENCE, sequenceName = SequenceNames.DATA_SEQUENCE, allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SequenceNames.DATA_SEQUENCE) - @DocumentId - public Long getId() { - return id; - } - - @Column(unique = true) - @NotNull(message = ValidationMessages.CODE_NOT_NULL_MESSAGE) - @Length(min = 1, max = 40, message = ValidationMessages.CODE_LENGTH_MESSAGE) - @Pattern(regex = AbstractIdAndCodeHolder.CODE_PATTERN, flags = java.util.regex.Pattern.CASE_INSENSITIVE, message = ValidationMessages.CODE_PATTERN_MESSAGE) - @Field(index = Index.TOKENIZED, store = Store.YES, name = SearchFieldConstants.CODE) - public String getCode() { - return code; - } - - /** Returns <code>procedure</code>. */ - @ManyToOne(fetch = FetchType.LAZY) - @NotNull(message = ValidationMessages.PROCEDURE_NOT_NULL_MESSAGE) - @JoinColumn(name = ColumnNames.PROCEDURE_PRODUCED_BY_COLUMN) - @IndexedEmbedded(prefix = SearchFieldConstants.PREFIX_PROCEDURE) - public ProcedurePE getProcedure() { - return procedure; - } - - /** Sets <code>procedure</code>. */ - public void setProcedure(final ProcedurePE procedure) { - this.procedure = procedure; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "dataInternal", cascade = CascadeType.ALL) - private final Set<EventPE> getEventsInternal() { - return events; - } - - // Required by Hibernate. - @SuppressWarnings("unused") - private final void setEventsInternal(final Set<EventPE> events) { - this.events = events; - } - - public final void setEvents(final Set<EventPE> events) { - getEventsInternal().clear(); - for (final EventPE child : events) { - addEvent(child); - } - } - - @Transient - public final Set<EventPE> getEvents() { - return new UnmodifiableSetDecorator<EventPE>(getEventsInternal()); - } - - public void addEvent(final EventPE event) { - final DataPE data = event.getData(); - if (data != null) { - data.removeEvent(event); - } - event.setDataInternal(this); - getEventsInternal().add(event); - } - - public void removeEvent(final EventPE event) { - assert event != null : "Unspecified event."; - getEventsInternal().remove(event); - event.setDataInternal(null); - } - - private Set<DataSetPropertyPE> properties = new HashSet<DataSetPropertyPE>(); - - @Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN) - @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "entity") - @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) - @IndexedEmbedded(prefix = SearchFieldConstants.PREFIX_PROPERTIES) - private Set<DataSetPropertyPE> getDataSetProperties() { - return properties; - } - - // Required by Hibernate. - @SuppressWarnings("unused") - private void setDataSetProperties(final Set<DataSetPropertyPE> properties) { - this.properties = properties; - } - - public void addProperty(final DataSetPropertyPE property) { - property.setEntity(this); - getDataSetProperties().add(property); - } - - public void setProperties(final Set<DataSetPropertyPE> properties) { - getDataSetProperties().clear(); - for (final DataSetPropertyPE property : properties) { - final DataPE parent = property.getDataSet(); - if (parent != null) { - parent.getDataSetProperties().remove(property); - } - addProperty(property); - } - } - - @Transient - public Set<DataSetPropertyPE> getProperties() { - return new UnmodifiableSetDecorator<DataSetPropertyPE>( - getDataSetProperties()); - } + private static final long serialVersionUID = GenericSharedConstants.VERSION; + + public static final DataPE[] EMPTY_ARRAY = new DataPE[0]; + + private transient Long id; + + private String code; + + private boolean placeholder; + + private boolean deleted; + + /** Registration date of the database instance. */ + private Date registrationDate; + + private DataSetTypePE dataSetType; + + private ProcedurePE procedure; + + private Date productionDate; + + private String dataProducerCode; + + private SamplePE sampleAcquiredFrom; + + private SamplePE sampleDerivedFrom; + + private Set<DataPE> parents = new HashSet<DataPE>(); + + private Set<EventPE> events = new HashSet<EventPE>(); + + @Column(name = ColumnNames.REGISTRATION_TIMESTAMP_COLUMN, nullable = false, insertable = false) + @Generated(GenerationTime.ALWAYS) + public Date getRegistrationDate() + { + return HibernateAbstractRegistrationHolder.getDate(registrationDate); + } + + public void setRegistrationDate(final Date registrationDate) + { + this.registrationDate = registrationDate; + } + + @ManyToOne(fetch = FetchType.EAGER) + @NotNull(message = ValidationMessages.DATA_SET_TYPE_NOT_NULL_MESSAGE) + @JoinColumn(name = ColumnNames.DATA_SET_TYPE_COLUMN) + @IndexedEmbedded(prefix = SearchFieldConstants.PREFIX_DATASET_TYPE) + public DataSetTypePE getDataSetType() + { + return dataSetType; + } + + /** Sets <code>dataSetType</code>. */ + public void setDataSetType(final DataSetTypePE dataSetType) + { + this.dataSetType = dataSetType; + } + + /** + * Returns <code>true</code> if this data set is a placeholder for a data set yet to arrive. + */ + @Column(name = ColumnNames.IS_PLACEHOLDER_COLUMN) + public boolean isPlaceholder() + { + return placeholder; + } + + /** + * Set to <code>true</code> if this data set is a placeholder for a data set yet to arrive. + */ + public void setPlaceholder(final boolean placeholder) + { + this.placeholder = placeholder; + } + + @Column(name = ColumnNames.IS_DELETED_COLUMN) + @Field(index = Index.UN_TOKENIZED, store = Store.YES, name = SearchFieldConstants.DELETED) + public boolean isDeleted() + { + return deleted; + } + + public void setDeleted(boolean deleted) + { + this.deleted = deleted; + } + + @ManyToOne(fetch = FetchType.EAGER) + @JoinColumn(name = ColumnNames.SAMPLE_ACQUIRED_FROM) + @IndexedEmbedded(prefix = SearchFieldConstants.PREFIX_SAMPLE) + public SamplePE getSampleAcquiredFrom() + { + return sampleAcquiredFrom; + } + + @ManyToOne(fetch = FetchType.EAGER) + @JoinColumn(name = ColumnNames.SAMPLE_DERIVED_FROM) + @IndexedEmbedded(prefix = SearchFieldConstants.PREFIX_SAMPLE) + public SamplePE getSampleDerivedFrom() + { + return sampleDerivedFrom; + } + + public void setSampleAcquiredFrom(final SamplePE sampleAcquiredFrom) + { + this.sampleAcquiredFrom = sampleAcquiredFrom; + } + + public void setSampleDerivedFrom(final SamplePE sampleDerivedFrom) + { + this.sampleDerivedFrom = sampleDerivedFrom; + } + + @Transient + public String getAssociatedSampleCode() + { + final SamplePE sample = sampleAcquiredFrom != null ? sampleAcquiredFrom : sampleDerivedFrom; + return sample != null ? sample.getCode() : null; + } + + /** + * Returns the date when the measurement / calculation that produced this external data set has + * been performed. + * <p> + * This may not be known in which case this method will return <code>null</code>. + */ + @Column(name = ColumnNames.PRODUCTION_TIMESTAMP_COLUMN) + public Date getProductionDate() + { + return HibernateAbstractRegistrationHolder.getDate(productionDate); + } + + /** + * Sets the date when the measurement / calculation that produced this external data set has + * been performed. + */ + public void setProductionDate(final Date productionDate) + { + this.productionDate = productionDate; + } + + /** + * Returns the code identifying the data source (i.e. measurement device or software pipeline) + * that produced this external data set. + * <p> + * This may not be known in which case this method will return <code>null</code>. + * </p> + */ + @Length(min = 1, max = 40, message = ValidationMessages.CODE_LENGTH_MESSAGE) + @Column(name = ColumnNames.DATA_PRODUCER_CODE_COLUMN) + public String getDataProducerCode() + { + return dataProducerCode; + } + + /** + * Sets the code identifying the data source (i.e. measurement device or software pipeline) that + * produced this external data set. + */ + public void setDataProducerCode(final String dataProducerCode) + { + this.dataProducerCode = dataProducerCode; + } + + public void setId(final Long id) + { + this.id = id; + } + + /** + * Sets the code (i.e. the externally used unique identifier) of this external data. + */ + public void setCode(final String code) + { + this.code = code; + } + + @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @JoinTable(name = TableNames.DATA_SET_RELATIONSHIPS_TABLE, joinColumns = @JoinColumn(name = ColumnNames.DATA_CHILD_COLUMN), inverseJoinColumns = @JoinColumn(name = ColumnNames.DATA_PARENT_COLUMN)) + public Set<DataPE> getParents() + { + return parents; + } + + public void setParents(final Set<DataPE> parents) + { + this.parents = parents; + } + + // + // AbstractIdAndCodeHolder + // + + @Id + @SequenceGenerator(name = SequenceNames.DATA_SEQUENCE, sequenceName = SequenceNames.DATA_SEQUENCE, allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SequenceNames.DATA_SEQUENCE) + @DocumentId + public Long getId() + { + return id; + } + + @Column(unique = true) + @NotNull(message = ValidationMessages.CODE_NOT_NULL_MESSAGE) + @Length(min = 1, max = 40, message = ValidationMessages.CODE_LENGTH_MESSAGE) + @Pattern(regex = AbstractIdAndCodeHolder.CODE_PATTERN, flags = java.util.regex.Pattern.CASE_INSENSITIVE, message = ValidationMessages.CODE_PATTERN_MESSAGE) + @Field(index = Index.TOKENIZED, store = Store.YES, name = SearchFieldConstants.CODE) + public String getCode() + { + return code; + } + + /** Returns <code>procedure</code>. */ + @ManyToOne(fetch = FetchType.LAZY) + @NotNull(message = ValidationMessages.PROCEDURE_NOT_NULL_MESSAGE) + @JoinColumn(name = ColumnNames.PROCEDURE_PRODUCED_BY_COLUMN) + @IndexedEmbedded(prefix = SearchFieldConstants.PREFIX_PROCEDURE) + public ProcedurePE getProcedure() + { + return procedure; + } + + /** Sets <code>procedure</code>. */ + public void setProcedure(final ProcedurePE procedure) + { + this.procedure = procedure; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "dataInternal", cascade = CascadeType.ALL) + private final Set<EventPE> getEventsInternal() + { + return events; + } + + // Required by Hibernate. + @SuppressWarnings("unused") + private final void setEventsInternal(final Set<EventPE> events) + { + this.events = events; + } + + public final void setEvents(final Set<EventPE> events) + { + getEventsInternal().clear(); + for (final EventPE child : events) + { + addEvent(child); + } + } + + @Transient + public final Set<EventPE> getEvents() + { + return new UnmodifiableSetDecorator<EventPE>(getEventsInternal()); + } + + public void addEvent(final EventPE event) + { + final DataPE data = event.getData(); + if (data != null) + { + data.removeEvent(event); + } + event.setDataInternal(this); + getEventsInternal().add(event); + } + + public void removeEvent(final EventPE event) + { + assert event != null : "Unspecified event."; + getEventsInternal().remove(event); + event.setDataInternal(null); + } + + private Set<DataSetPropertyPE> properties = new HashSet<DataSetPropertyPE>(); + + @Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN) + @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "entity") + @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) + @IndexedEmbedded(prefix = SearchFieldConstants.PREFIX_PROPERTIES) + private Set<DataSetPropertyPE> getDataSetProperties() + { + return properties; + } + + // Required by Hibernate. + @SuppressWarnings("unused") + private void setDataSetProperties(final Set<DataSetPropertyPE> properties) + { + this.properties = properties; + } + + public void addProperty(final DataSetPropertyPE property) + { + property.setEntity(this); + getDataSetProperties().add(property); + } + + public void setProperties(final Set<DataSetPropertyPE> properties) + { + getDataSetProperties().clear(); + for (final DataSetPropertyPE property : properties) + { + final DataPE parent = property.getDataSet(); + if (parent != null) + { + parent.getDataSetProperties().remove(property); + } + addProperty(property); + } + } + + @Transient + public Set<DataSetPropertyPE> getProperties() + { + return new UnmodifiableSetDecorator<DataSetPropertyPE>(getDataSetProperties()); + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataSetTypePropertyTypePE.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataSetTypePropertyTypePE.java index 3de079bae414b5761a313159f899458000e67c3e..eb608f0881eebb8b273046d2fae967be6f0efde4 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataSetTypePropertyTypePE.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataSetTypePropertyTypePE.java @@ -37,58 +37,66 @@ import org.hibernate.validator.NotNull; import ch.systemsx.cisd.openbis.generic.shared.GenericSharedConstants; /** - * Persistence entity representing experiment type - property type relation. + * Persistence entity representing data set type - property type relation. * * @author Izabela Adamczyk */ @Entity -@Table(name = TableNames.DATA_SET_TYPE_PROPERTY_TYPE_TABLE, uniqueConstraints = { @UniqueConstraint(columnNames = { - ColumnNames.DATA_SET_TYPE_COLUMN, ColumnNames.PROPERTY_TYPE_COLUMN }) }) -public class DataSetTypePropertyTypePE extends EntityTypePropertyTypePE { - - private static final long serialVersionUID = GenericSharedConstants.VERSION; - - public static final DataSetTypePropertyTypePE[] EMPTY_ARRAY = new DataSetTypePropertyTypePE[0]; - - @NotNull(message = ValidationMessages.DATA_SET_TYPE_NOT_NULL_MESSAGE) - @ManyToOne(fetch = FetchType.EAGER, targetEntity = ExperimentTypePE.class) - @JoinColumn(name = ColumnNames.DATA_SET_TYPE_COLUMN) - private EntityTypePE getEntityTypeInternal() { - return entityType; - } - - // - // EntityTypePropertyTypePE - // - - @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "entityTypePropertyType", targetEntity = DataSetPropertyPE.class) - public Set<EntityPropertyPE> getPropertyValues() { - return propertyValues; - } - - @Transient - public EntityTypePE getEntityType() { - return getEntityTypeInternal(); - } - - @Override - // This setter sets the bidirectional connection. That's why we must have an - // another internal - // plain setter for Hibernate. - public void setEntityType(EntityTypePE entityType) { - ((DataSetTypePE) entityType).addDataSetTypePropertyType(this); - } - - @SequenceGenerator(name = SequenceNames.DATA_SET_TYPE_PROPERTY_TYPE_SEQUENCE, sequenceName = SequenceNames.DATA_SET_TYPE_PROPERTY_TYPE_SEQUENCE, allocationSize = 1) - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SequenceNames.DATA_SET_TYPE_PROPERTY_TYPE_SEQUENCE) - public Long getId() { - return id; - } - - @Override - public void setPropertyType(PropertyTypePE propertyType) { - propertyType.addDataSetTypePropertyType(this); - } +@Table(name = TableNames.DATA_SET_TYPE_PROPERTY_TYPE_TABLE, uniqueConstraints = + { @UniqueConstraint(columnNames = + { ColumnNames.DATA_SET_TYPE_COLUMN, ColumnNames.PROPERTY_TYPE_COLUMN }) }) +public class DataSetTypePropertyTypePE extends EntityTypePropertyTypePE +{ + + private static final long serialVersionUID = GenericSharedConstants.VERSION; + + public static final DataSetTypePropertyTypePE[] EMPTY_ARRAY = new DataSetTypePropertyTypePE[0]; + + @NotNull(message = ValidationMessages.DATA_SET_TYPE_NOT_NULL_MESSAGE) + @ManyToOne(fetch = FetchType.EAGER, targetEntity = DataSetTypePE.class) + @JoinColumn(name = ColumnNames.DATA_SET_TYPE_COLUMN) + private EntityTypePE getEntityTypeInternal() + { + return entityType; + } + + // + // EntityTypePropertyTypePE + // + + @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "entityTypePropertyType", targetEntity = DataSetPropertyPE.class) + public Set<EntityPropertyPE> getPropertyValues() + { + return propertyValues; + } + + @Transient + public EntityTypePE getEntityType() + { + return getEntityTypeInternal(); + } + + @Override + // This setter sets the bidirectional connection. That's why we must have an + // another internal + // plain setter for Hibernate. + public void setEntityType(EntityTypePE entityType) + { + ((DataSetTypePE) entityType).addDataSetTypePropertyType(this); + } + + @SequenceGenerator(name = SequenceNames.DATA_SET_TYPE_PROPERTY_TYPE_SEQUENCE, sequenceName = SequenceNames.DATA_SET_TYPE_PROPERTY_TYPE_SEQUENCE, allocationSize = 1) + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SequenceNames.DATA_SET_TYPE_PROPERTY_TYPE_SEQUENCE) + public Long getId() + { + return id; + } + + @Override + public void setPropertyType(PropertyTypePE propertyType) + { + propertyType.addDataSetTypePropertyType(this); + } } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAOTest.java index 417b97c54a5aec4e8db664feaaf953c316171048..7e761a9d1a416bf15ac836471871ac17f92e275c 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAOTest.java @@ -299,7 +299,7 @@ public final class HibernateSearchDAOTest extends AbstractDAOTest private static DataSetSearchField createAnySearchField(List<String> propertyTypes) { - return DataSetSearchField.createAnyField(propertyTypes, propertyTypes); + return DataSetSearchField.createAnyField(propertyTypes, propertyTypes, propertyTypes); } @Test