From e4fc9a8ec4af8b5651dcb3322e1804dbcc260b9a Mon Sep 17 00:00:00 2001 From: pkupczyk <piotr.kupczyk@id.ethz.ch> Date: Wed, 16 May 2018 17:33:38 +0200 Subject: [PATCH] SSDM-6516 : Fix inconsistent use of $ for internal namespace properties --- .../property/CreatePropertyTypeExecutor.java | 22 +++-- .../translator/dataset/DataSetBaseRecord.java | 1 - .../v3/translator/dataset/DataSetQuery.java | 11 ++- .../experiment/ExperimentQuery.java | 33 +++++--- .../v3/translator/material/MaterialQuery.java | 5 +- .../property/PropertyAssignmentRecord.java | 6 +- .../PropertyAssignmentTranslator.java | 4 +- .../property/PropertyTypeTranslator.java | 7 +- .../v3/translator/sample/SampleQuery.java | 2 +- .../asapi/v3/AbstractGetEntityTypeTest.java | 31 +++++++ .../asapi/v3/CreateDataSetTypeTest.java | 2 +- .../asapi/v3/CreateEntityTypeTest.java | 31 ++++++- .../asapi/v3/CreateExperimentTypeTest.java | 2 +- .../asapi/v3/CreateMaterialTypeTest.java | 2 +- .../asapi/v3/CreatePropertyTypeTest.java | 73 ++++++++++++++++- .../asapi/v3/CreateSampleTypeTest.java | 2 +- .../asapi/v3/GetPropertyTypeTest.java | 2 +- .../systemtest/asapi/v3/GetSampleTest.java | 24 +++++- .../v3/SearchPropertyAssignmentTest.java | 11 ++- .../asapi/v3/SearchSampleTypeTest.java | 7 +- .../asapi/v3/UpdateEntityTypeTest.java | 82 +++++++++---------- 21 files changed, 272 insertions(+), 88 deletions(-) diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/property/CreatePropertyTypeExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/property/CreatePropertyTypeExecutor.java index 92418fa94a1..5f9ca2a7271 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/property/CreatePropertyTypeExecutor.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/property/CreatePropertyTypeExecutor.java @@ -45,6 +45,8 @@ import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.entity.progress.Create import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.openbis.generic.server.business.bo.DataAccessExceptionTranslator; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; +import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant; +import ch.systemsx.cisd.openbis.generic.shared.basic.CodeConverter; import ch.systemsx.cisd.openbis.generic.shared.dto.DataTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; import ch.systemsx.cisd.openbis.generic.shared.dto.PropertyTypePE; @@ -66,7 +68,7 @@ public class CreatePropertyTypeExecutor @Autowired private ISetPropertyTypeMaterialTypeExecutor setPropertyTypeMaterialTypeExecutor; - + @Autowired private IPropertyTypeAuthorizationExecutor authorizationExecutor; @@ -89,6 +91,16 @@ public class CreatePropertyTypeExecutor { throw new UserFailureException("Code cannot be empty."); } + if (creation.isInternalNameSpace() && false == CodeConverter.isInternalNamespace(creation.getCode())) + { + throw new UserFailureException( + "Code of an internal namespace property type has to start with '" + BasicConstant.INTERNAL_NAMESPACE_PREFIX + "' prefix."); + } + if (false == creation.isInternalNameSpace() && CodeConverter.isInternalNamespace(creation.getCode())) + { + throw new UserFailureException( + "'" + BasicConstant.INTERNAL_NAMESPACE_PREFIX + "' code prefix can be only used for the internal namespace property types."); + } if (StringUtils.isEmpty(creation.getLabel())) { throw new UserFailureException("Label cannot be empty."); @@ -104,7 +116,7 @@ public class CreatePropertyTypeExecutor } if (dataType == DataType.CONTROLLEDVOCABULARY && creation.getVocabularyId() == null) { - throw new UserFailureException("Data type has been specified as " + throw new UserFailureException("Data type has been specified as " + DataType.CONTROLLEDVOCABULARY + " but vocabulary id is missing."); } if (creation.getVocabularyId() != null && dataType != DataType.CONTROLLEDVOCABULARY) @@ -123,7 +135,7 @@ public class CreatePropertyTypeExecutor EntityTypePermId permId = (EntityTypePermId) materialTypeId; if (permId.getEntityKind() != EntityKind.MATERIAL) { - throw new UserFailureException("Specified entity type id (" + materialTypeId + ") is not a " + throw new UserFailureException("Specified entity type id (" + materialTypeId + ") is not a " + EntityKind.MATERIAL + " type."); } } @@ -204,7 +216,7 @@ public class CreatePropertyTypeExecutor protected void updateAll(IOperationContext context, MapBatch<PropertyTypeCreation, PropertyTypePE> batch) { } - + @Override protected void handleException(DataAccessException e) { @@ -234,5 +246,5 @@ public class CreatePropertyTypeExecutor XmlUtils.validateXML(transformation, "XSLT", XmlUtils.XSLT_XSD_FILE_RESOURCE); } } - + } diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/dataset/DataSetBaseRecord.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/dataset/DataSetBaseRecord.java index d8c4a83d982..062756af097 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/dataset/DataSetBaseRecord.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/dataset/DataSetBaseRecord.java @@ -18,7 +18,6 @@ package ch.ethz.sis.openbis.generic.server.asapi.v3.translator.dataset; import java.util.Date; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.DataSetKind; import ch.ethz.sis.openbis.generic.server.asapi.v3.translator.common.ObjectBaseRecord; /** diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/dataset/DataSetQuery.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/dataset/DataSetQuery.java index 4d296546fbb..45a4220d5cc 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/dataset/DataSetQuery.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/dataset/DataSetQuery.java @@ -127,11 +127,9 @@ public interface DataSetQuery extends ObjectQuery + "dsch.git_repository_id as gitRepositoryId, dsch.edms_id as externalDmsId, dsch.edms_code as externalDmsCode, dsch.edms_label as externalDmsLabel, " + "dsch.edms_address as externalDmsAddress, dsch.pers_id_author as authorId, dsch.valid_from_timestamp as validFrom, dsch.valid_until_timestamp as validTo " + "from data_set_copies_history dsch " - + "where dsch.valid_until_timestamp is not null and dsch.data_id = any(?{1})", - parameterBindings = { + + "where dsch.valid_until_timestamp is not null and dsch.data_id = any(?{1})", parameterBindings = { LongSetMapper.class - }, - fetchSize = FETCH_SIZE) + }, fetchSize = FETCH_SIZE) public List<HistoryContentCopyRecord> getContentCopyHistory(LongSet dataSetIds); @Select(sql = "select ds_id from post_registration_dataset_queue where ds_id = any(?{1})", parameterBindings = { @@ -190,7 +188,7 @@ public interface DataSetQuery extends ObjectQuery LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ObjectRelationRecord> getPropertyAssignmentIds(LongSet dataSetTypeIds); - @Select(sql = "select pt.code as prty_code, 'DATA_SET' as kind_code, dt.id as type_id, dt.code as type_code, dtpt.* from data_set_type_property_types dtpt, property_types pt, data_set_types dt where dtpt.id = any(?{1}) and dtpt.prty_id = pt.id and dtpt.dsty_id = dt.id", parameterBindings = { + @Select(sql = "select pt.code as prty_code, pt.is_internal_namespace as prty_is_internal_namespace, 'DATA_SET' as kind_code, dt.id as type_id, dt.code as type_code, dtpt.* from data_set_type_property_types dtpt, property_types pt, data_set_types dt where dtpt.id = any(?{1}) and dtpt.prty_id = pt.id and dtpt.dsty_id = dt.id", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<PropertyAssignmentRecord> getPropertyAssignments(LongSet dataSetTypePropertyTypeIds); @@ -202,7 +200,8 @@ public interface DataSetQuery extends ObjectQuery LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ContentCopyRecord> getContentCopies(LongOpenHashSet longOpenHashSet); - @Select(sql = "select t.id as objectId, t.validation_script_id as relatedId from data_set_types t where t.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + @Select(sql = "select t.id as objectId, t.validation_script_id as relatedId from data_set_types t where t.id = any(?{1})", parameterBindings = { + LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ObjectRelationRecord> getValidationPluginIds(LongSet dataSetTypeIds); } diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/experiment/ExperimentQuery.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/experiment/ExperimentQuery.java index 01acd60e336..ed8598f5cdb 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/experiment/ExperimentQuery.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/experiment/ExperimentQuery.java @@ -42,20 +42,24 @@ public interface ExperimentQuery extends ObjectQuery + "where e.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ExperimentBaseRecord> getExperiments(LongSet experimentIds); - @Select(sql = "select e.id as objectId, e.exty_id as relatedId from experiments e where e.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + @Select(sql = "select e.id as objectId, e.exty_id as relatedId from experiments e where e.id = any(?{1})", parameterBindings = { + LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ObjectRelationRecord> getTypeIds(LongSet experimentIds); @Select(sql = "select et.id, et.code, et.description, et.modification_timestamp as modificationDate " + "from experiment_types et where et.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ExperimentTypeBaseRecord> getTypes(LongSet experimentTypeIds); - @Select(sql = "select e.id as objectId, e.proj_id as relatedId from experiments e where e.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + @Select(sql = "select e.id as objectId, e.proj_id as relatedId from experiments e where e.id = any(?{1})", parameterBindings = { + LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ObjectRelationRecord> getProjectIds(LongSet experimentIds); - @Select(sql = "select s.expe_id as objectId, s.id as relatedId from samples s where s.expe_id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + @Select(sql = "select s.expe_id as objectId, s.id as relatedId from samples s where s.expe_id = any(?{1})", parameterBindings = { + LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ObjectRelationRecord> getSampleIds(LongSet experimentIds); - @Select(sql = "select d.expe_id as objectId, d.id as relatedId from data d where d.expe_id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + @Select(sql = "select d.expe_id as objectId, d.id as relatedId from data d where d.expe_id = any(?{1})", parameterBindings = { + LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ObjectRelationRecord> getDataSetIds(LongSet experimentIds); // PropertyQueryGenerator was used to generate this query @@ -88,26 +92,31 @@ public interface ExperimentQuery extends ObjectQuery @Select(sql = "select erh.main_expe_id as objectId, erh.pers_id_author as authorId, erh.relation_type as relationType, " + "erh.entity_perm_id as relatedObjectId, erh.valid_from_timestamp as validFrom, erh.valid_until_timestamp as validTo, " + "erh.proj_id as projectId, erh.samp_id as sampleId, erh.data_id as dataSetId " - + "from experiment_relationships_history erh where erh.valid_until_timestamp is not null and erh.main_expe_id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + + "from experiment_relationships_history erh where erh.valid_until_timestamp is not null and erh.main_expe_id = any(?{1})", parameterBindings = { + LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ExperimentRelationshipRecord> getRelationshipsHistory(LongSet experimentIds); - @Select(sql = "select e.id as objectId, e.pers_id_registerer as relatedId from experiments e where e.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + @Select(sql = "select e.id as objectId, e.pers_id_registerer as relatedId from experiments e where e.id = any(?{1})", parameterBindings = { + LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ObjectRelationRecord> getRegistratorIds(LongSet experimentIds); - @Select(sql = "select e.id as objectId, e.pers_id_modifier as relatedId from experiments e where e.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + @Select(sql = "select e.id as objectId, e.pers_id_modifier as relatedId from experiments e where e.id = any(?{1})", parameterBindings = { + LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ObjectRelationRecord> getModifierIds(LongSet experimentIds); - @Select(sql = "select ma.expe_id as objectId, ma.mepr_id as relatedId from metaproject_assignments ma where ma.expe_id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + @Select(sql = "select ma.expe_id as objectId, ma.mepr_id as relatedId from metaproject_assignments ma where ma.expe_id = any(?{1})", parameterBindings = { + LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ObjectRelationRecord> getTagIds(LongSet experimentIds); - @Select(sql = "select exty_id as objectId, id as relatedId from experiment_type_property_types where exty_id = any(?{1})", - parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + @Select(sql = "select exty_id as objectId, id as relatedId from experiment_type_property_types where exty_id = any(?{1})", parameterBindings = { + LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ObjectRelationRecord> getPropertyAssignmentIds(LongSet experimentTypeIds); - @Select(sql = "select t.id as objectId, t.validation_script_id as relatedId from experiment_types t where t.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + @Select(sql = "select t.id as objectId, t.validation_script_id as relatedId from experiment_types t where t.id = any(?{1})", parameterBindings = { + LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ObjectRelationRecord> getValidationPluginIds(LongSet experimentTypeIds); - @Select(sql = "select pt.code as prty_code, 'EXPERIMENT' as kind_code, et.id as type_id, et.code as type_code, etpt.* from experiment_type_property_types etpt, property_types pt, experiment_types et where etpt.id = any(?{1}) and etpt.prty_id = pt.id and etpt.exty_id = et.id", parameterBindings = { + @Select(sql = "select pt.code as prty_code, pt.is_internal_namespace as prty_is_internal_namespace, 'EXPERIMENT' as kind_code, et.id as type_id, et.code as type_code, etpt.* from experiment_type_property_types etpt, property_types pt, experiment_types et where etpt.id = any(?{1}) and etpt.prty_id = pt.id and etpt.exty_id = et.id", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<PropertyAssignmentRecord> getPropertyAssignments(LongSet experimentTypePropertyTypeIds); } diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/material/MaterialQuery.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/material/MaterialQuery.java index 0c7ac3900b0..7ce818d512e 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/material/MaterialQuery.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/material/MaterialQuery.java @@ -88,11 +88,12 @@ public interface MaterialQuery extends ObjectQuery LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ObjectRelationRecord> getPropertyAssignmentIds(LongSet materialTypeIds); - @Select(sql = "select pt.code as prty_code, 'MATERIAL' as kind_code, mt.id as type_id, mt.code as type_code, mtpt.* from material_type_property_types mtpt, property_types pt, material_types mt where mtpt.id = any(?{1}) and mtpt.prty_id = pt.id and mtpt.maty_id = mt.id", parameterBindings = { + @Select(sql = "select pt.code as prty_code, pt.is_internal_namespace as prty_is_internal_namespace, 'MATERIAL' as kind_code, mt.id as type_id, mt.code as type_code, mtpt.* from material_type_property_types mtpt, property_types pt, material_types mt where mtpt.id = any(?{1}) and mtpt.prty_id = pt.id and mtpt.maty_id = mt.id", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<PropertyAssignmentRecord> getPropertyAssignments(LongSet materialTypePropertyTypeIds); - @Select(sql = "select t.id as objectId, t.validation_script_id as relatedId from material_types t where t.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + @Select(sql = "select t.id as objectId, t.validation_script_id as relatedId from material_types t where t.id = any(?{1})", parameterBindings = { + LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ObjectRelationRecord> getValidationPluginIds(LongSet materialTypeIds); } diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/property/PropertyAssignmentRecord.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/property/PropertyAssignmentRecord.java index ffb6a337111..b2e972d356d 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/property/PropertyAssignmentRecord.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/property/PropertyAssignmentRecord.java @@ -34,10 +34,12 @@ public class PropertyAssignmentRecord extends ObjectBaseRecord public String prty_code; + public boolean prty_is_internal_namespace; + public Long type_id; - + public String type_code; - + public String kind_code; public Boolean is_mandatory; diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/property/PropertyAssignmentTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/property/PropertyAssignmentTranslator.java index 1f7eb99aa06..1fa9a3b5a9e 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/property/PropertyAssignmentTranslator.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/property/PropertyAssignmentTranslator.java @@ -52,6 +52,7 @@ import ch.ethz.sis.openbis.generic.server.asapi.v3.translator.person.IPersonTran import ch.ethz.sis.openbis.generic.server.asapi.v3.translator.sample.ISampleTypeTranslator; import ch.ethz.sis.openbis.generic.server.asapi.v3.translator.sample.SampleQuery; import ch.ethz.sis.openbis.generic.server.asapi.v3.translator.semanticannotation.ISemanticAnnotationTranslator; +import ch.systemsx.cisd.openbis.generic.shared.basic.CodeConverter; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import net.lemnik.eodsql.QueryTool; @@ -110,7 +111,8 @@ public class PropertyAssignmentTranslator implements IPropertyAssignmentTranslat { EntityKind entityKind = EntityKind.valueOf(assignmentRecord.kind_code); IEntityTypeId entityTypeId = new EntityTypePermId(assignmentRecord.type_code, entityKind); - IPropertyTypeId propertyTypeId = new PropertyTypePermId(assignmentRecord.prty_code); + IPropertyTypeId propertyTypeId = + new PropertyTypePermId(CodeConverter.tryToBusinessLayer(assignmentRecord.prty_code, assignmentRecord.prty_is_internal_namespace)); PropertyAssignment assignment = new PropertyAssignment(); assignment.setPermId(new PropertyAssignmentPermId(entityTypeId, propertyTypeId)); diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/property/PropertyTypeTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/property/PropertyTypeTranslator.java index 5e582a9d397..6fb43405513 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/property/PropertyTypeTranslator.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/property/PropertyTypeTranslator.java @@ -105,9 +105,10 @@ public class PropertyTypeTranslator extends AbstractCachingTranslator<Long, Prop TranslationResults relations = (TranslationResults) objectRelations; PropertyTypeRecord baseRecord = relations.get(IPropertyTypeBaseTranslator.class, typeId); - result.setCode(baseRecord.code); - String permId = CodeConverter.tryToBusinessLayer(baseRecord.code, baseRecord.is_internal_namespace); - result.setPermId(new PropertyTypePermId(permId)); + String businessCode = CodeConverter.tryToBusinessLayer(baseRecord.code, baseRecord.is_internal_namespace); + + result.setCode(businessCode); + result.setPermId(new PropertyTypePermId(businessCode)); result.setLabel(baseRecord.label); result.setDescription(baseRecord.description); result.setDataType(DataType.valueOf(baseRecord.data_type)); diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/sample/SampleQuery.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/sample/SampleQuery.java index d7b24add184..e331c0eb5cd 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/sample/SampleQuery.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/translator/sample/SampleQuery.java @@ -144,7 +144,7 @@ public interface SampleQuery extends ObjectQuery LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ObjectRelationRecord> getPropertyAssignmentIds(LongSet sampleTypeIds); - @Select(sql = "select pt.code as prty_code, 'SAMPLE' as kind_code, st.id as type_id, st.code as type_code, stpt.* from sample_type_property_types stpt, property_types pt, sample_types st where stpt.id = any(?{1}) and stpt.prty_id = pt.id and stpt.saty_id = st.id", parameterBindings = { + @Select(sql = "select pt.code as prty_code, pt.is_internal_namespace as prty_is_internal_namespace, 'SAMPLE' as kind_code, st.id as type_id, st.code as type_code, stpt.* from sample_type_property_types stpt, property_types pt, sample_types st where stpt.id = any(?{1}) and stpt.prty_id = pt.id and stpt.saty_id = st.id", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<PropertyAssignmentRecord> getPropertyAssignments(LongSet sampleTypePropertyTypeIds); diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/AbstractGetEntityTypeTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/AbstractGetEntityTypeTest.java index b49dfd96138..0a49f1e18e0 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/AbstractGetEntityTypeTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/AbstractGetEntityTypeTest.java @@ -33,6 +33,7 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.id.IEntityTypeId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.create.ExperimentTypeCreation; import ch.ethz.sis.openbis.generic.asapi.v3.dto.plugin.id.IPluginId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.plugin.id.PluginPermId; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.PropertyAssignment; import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.create.PropertyAssignmentCreation; import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.id.PropertyTypePermId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.create.SampleTypeCreation; @@ -252,6 +253,36 @@ public abstract class AbstractGetEntityTypeTest extends AbstractTest assertValidationPluginNotFetched(type); } + @Test + public void testGetByIdsWithInternalPropertyAssignments() + { + String sessionToken = v3api.login(TEST_USER, PASSWORD); + + String entityTypeCode = "ENTITY_TEST_TYPE"; + String propertyTypeCodeWithDolar = "$PLATE_GEOMETRY"; + + PropertyAssignmentCreation assignmentCreation = new PropertyAssignmentCreation(); + assignmentCreation.setPropertyTypeId(new PropertyTypePermId(propertyTypeCodeWithDolar)); + + EntityTypePermId permId = createEntityType(sessionToken, entityTypeCode, Arrays.asList(assignmentCreation), null); + + Map<IEntityTypeId, ? extends IEntityType> map = getEntityTypes(sessionToken, Arrays.asList(permId), createFetchOptions(true, false)); + + IEntityType type = map.get(permId); + + assertEquals(((EntityTypePermId) type.getPermId()).getPermId(), permId.getPermId()); + assertEquals(type.getCode(), permId.getPermId()); + + assertEquals(type.getPropertyAssignments().size(), 1); + PropertyAssignment assignment = type.getPropertyAssignments().get(0); + assertEquals(assignment.getPermId().getEntityTypeId(), new EntityTypePermId(entityTypeCode, getEntityKind())); + assertEquals(((PropertyTypePermId) assignment.getPermId().getPropertyTypeId()).getPermId(), propertyTypeCodeWithDolar); + assertEquals(assignment.getPropertyType().getCode(), propertyTypeCodeWithDolar); + assertEquals(((PropertyTypePermId) assignment.getPropertyType().getPermId()).getPermId(), propertyTypeCodeWithDolar); + + assertValidationPluginNotFetched(type); + } + @Test public void testGetByIdsWithValidationPlugin() { diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateDataSetTypeTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateDataSetTypeTest.java index 5b6b8e2d720..d584a54ad2a 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateDataSetTypeTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateDataSetTypeTest.java @@ -27,8 +27,8 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.DataSetType; import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.create.DataSetTypeCreation; import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.fetchoptions.DataSetTypeFetchOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.search.DataSetTypeSearchCriteria; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.EntityKind; import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.id.EntityTypePermId; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; /** * @author pkupczyk diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateEntityTypeTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateEntityTypeTest.java index 0b4c13154f6..6989a925b06 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateEntityTypeTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateEntityTypeTest.java @@ -24,13 +24,14 @@ import java.util.List; import org.testng.annotations.Test; import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.interfaces.IEntityType; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.EntityKind; import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.create.IEntityTypeCreation; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.id.EntityTypePermId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.plugin.id.PluginPermId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.PropertyAssignment; import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.create.PropertyAssignmentCreation; import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.id.PropertyTypePermId; import ch.systemsx.cisd.common.action.IDelegatedAction; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; /** * @author pkupczyk @@ -233,6 +234,34 @@ public abstract class CreateEntityTypeTest<CREATION extends IEntityTypeCreation, }, "Object with PropertyTypePermId = [IDONTEXIST] has not been found"); } + @Test + public void testCreateWithPropertyTypeWithInternalNamespace() + { + final String sessionToken = v3api.login(TEST_USER, PASSWORD); + + String entityTypeCode = "NEW_ENTITY_TYPE"; + String propertyTypeCodeWithDolar = "$PLATE_GEOMETRY"; + + final CREATION typeCreation = newTypeCreation(); + typeCreation.setCode(entityTypeCode); + + PropertyAssignmentCreation assignmentCreation = new PropertyAssignmentCreation(); + assignmentCreation.setPropertyTypeId(new PropertyTypePermId(propertyTypeCodeWithDolar)); + typeCreation.setPropertyAssignments(Arrays.asList(assignmentCreation)); + + createTypes(sessionToken, Arrays.asList(typeCreation)); + TYPE type = getType(sessionToken, typeCreation.getCode()); + + assertEquals(type.getPropertyAssignments().size(), 1); + PropertyAssignment assignment = type.getPropertyAssignments().get(0); + + assertEquals(assignment.getPermId().getEntityTypeId(), new EntityTypePermId(entityTypeCode, getEntityKind())); + assertEquals(((PropertyTypePermId) assignment.getPermId().getPropertyTypeId()).getPermId(), propertyTypeCodeWithDolar); + assertEquals(assignment.getPropertyType().getCode(), propertyTypeCodeWithDolar); + assertEquals(((PropertyTypePermId) assignment.getPropertyType().getPermId()).getPermId(), propertyTypeCodeWithDolar); + assertEquals(assignment.getOrdinal(), Integer.valueOf(1)); + } + @Test public void testCreateWithPropertyAssignmentsWithIncorrectOrdinal() { diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateExperimentTypeTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateExperimentTypeTest.java index 8512a453278..38cb79884a2 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateExperimentTypeTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateExperimentTypeTest.java @@ -21,12 +21,12 @@ import java.util.List; import org.testng.annotations.Test; import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.search.SearchResult; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.EntityKind; import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.id.EntityTypePermId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.ExperimentType; import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.create.ExperimentTypeCreation; import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.fetchoptions.ExperimentTypeFetchOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.search.ExperimentTypeSearchCriteria; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; /** * @author pkupczyk diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateMaterialTypeTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateMaterialTypeTest.java index f32b39f9580..8b3753cb72b 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateMaterialTypeTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateMaterialTypeTest.java @@ -21,12 +21,12 @@ import java.util.List; import org.testng.annotations.Test; import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.search.SearchResult; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.EntityKind; import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.id.EntityTypePermId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.MaterialType; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.create.MaterialTypeCreation; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.fetchoptions.MaterialTypeFetchOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.search.MaterialTypeSearchCriteria; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; /** * @author pkupczyk diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreatePropertyTypeTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreatePropertyTypeTest.java index 7df43321071..9c0782d2093 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreatePropertyTypeTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreatePropertyTypeTest.java @@ -82,12 +82,12 @@ public class CreatePropertyTypeTest extends AbstractTest "xsl:styleshet"); @Test - public void testCreateInternalNamespacePropertyType() + public void testCreateInternalNamespacePropertyTypeWithCodeWithDolarSign() { // Given String sessionToken = v3api.login(TEST_USER, PASSWORD); PropertyTypeCreation creation = new PropertyTypeCreation(); - creation.setCode("test-property"); + creation.setCode("$test-property"); creation.setDataType(DataType.REAL); creation.setDescription("only for testing"); creation.setLabel("Test Property"); @@ -100,7 +100,7 @@ public class CreatePropertyTypeTest extends AbstractTest // Then assertEquals(ids.toString(), "[$TEST-PROPERTY]"); PropertyTypeSearchCriteria searchCriteria = new PropertyTypeSearchCriteria(); - searchCriteria.withCode().thatEquals("$" + creation.getCode().toUpperCase()); + searchCriteria.withCode().thatEquals(creation.getCode().toUpperCase()); PropertyTypeFetchOptions fetchOptions = new PropertyTypeFetchOptions(); Map<IPropertyTypeId, PropertyType> types = v3api.getPropertyTypes(sessionToken, ids, fetchOptions); PropertyType propertyType = types.get(ids.get(0)); @@ -116,6 +116,73 @@ public class CreatePropertyTypeTest extends AbstractTest v3api.logout(sessionToken); } + @Test + public void testCreateInternalNamespacePropertyTypeWithCodeWithoutDolarSign() + { + String sessionToken = v3api.login(TEST_USER, PASSWORD); + PropertyTypeCreation creation = new PropertyTypeCreation(); + creation.setCode("test-property"); + creation.setLabel("Test Property"); + creation.setDescription("only for testing"); + creation.setDataType(DataType.REAL); + creation.setInternalNameSpace(true); + + assertUserFailureException(new IDelegatedAction() + { + @Override + public void execute() + { + v3api.createPropertyTypes(sessionToken, Arrays.asList(creation)); + } + }, "Code of an internal namespace property type has to start with '$' prefix"); + } + + @Test + public void testCreateNonInternalNamespacePropertyTypeWithCodeWithDolarSign() + { + String sessionToken = v3api.login(TEST_USER, PASSWORD); + PropertyTypeCreation creation = new PropertyTypeCreation(); + creation.setCode("$test-property"); + creation.setLabel("Test Property"); + creation.setDescription("only for testing"); + creation.setDataType(DataType.REAL); + creation.setInternalNameSpace(false); + + assertUserFailureException(new IDelegatedAction() + { + @Override + public void execute() + { + v3api.createPropertyTypes(sessionToken, Arrays.asList(creation)); + } + }, "'$' code prefix can be only used for the internal namespace property types"); + } + + @Test + public void testCreateNonInternalNamespacePropertyTypeWithCodeWithoutDolarSign() + { + String sessionToken = v3api.login(TEST_USER, PASSWORD); + PropertyTypeCreation creation = new PropertyTypeCreation(); + creation.setCode("test-property"); + creation.setLabel("Test Property"); + creation.setDescription("only for testing"); + creation.setDataType(DataType.REAL); + creation.setInternalNameSpace(false); + + List<PropertyTypePermId> ids = v3api.createPropertyTypes(sessionToken, Arrays.asList(creation)); + assertEquals(ids.toString(), "[TEST-PROPERTY]"); + + PropertyTypeSearchCriteria searchCriteria = new PropertyTypeSearchCriteria(); + searchCriteria.withCode().thatEquals(creation.getCode().toUpperCase()); + + Map<IPropertyTypeId, PropertyType> types = v3api.getPropertyTypes(sessionToken, ids, new PropertyTypeFetchOptions()); + + PropertyType propertyType = types.get(ids.get(0)); + assertEquals(propertyType.getCode(), creation.getCode().toUpperCase()); + assertEquals(propertyType.getDataType(), creation.getDataType()); + assertEquals(propertyType.isInternalNameSpace(), (Boolean) creation.isInternalNameSpace()); + } + @Test(groups = "broken") public void testCreateXmlPropertyType() { diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateSampleTypeTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateSampleTypeTest.java index b6b55656a70..82e1835a3a4 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateSampleTypeTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateSampleTypeTest.java @@ -23,12 +23,12 @@ import java.util.List; import org.testng.annotations.Test; import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.search.SearchResult; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.EntityKind; import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.id.EntityTypePermId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.SampleType; import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.create.SampleTypeCreation; import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.fetchoptions.SampleTypeFetchOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.search.SampleTypeSearchCriteria; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; /** * @author pkupczyk diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetPropertyTypeTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetPropertyTypeTest.java index 2c1f330e858..dea106f86b0 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetPropertyTypeTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetPropertyTypeTest.java @@ -72,7 +72,7 @@ public class GetPropertyTypeTest extends AbstractTest PropertyType propertyType = v3api.getPropertyTypes(sessionToken, Arrays.asList(permId), fetchOptions).get(permId); // Then - assertEquals(propertyType.getCode(), "PLATE_GEOMETRY"); + assertEquals(propertyType.getCode(), "$PLATE_GEOMETRY"); assertEquals(propertyType.getPermId(), permId); assertEquals(propertyType.getDescription(), "Plate Geometry"); assertEquals(propertyType.getDataType().toString(), DataType.CONTROLLEDVOCABULARY.toString()); diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetSampleTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetSampleTest.java index 5b2c17fd4d0..f7da30544f3 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetSampleTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetSampleTest.java @@ -1089,7 +1089,7 @@ public class GetSampleTest extends AbstractSampleTest assertEquals(type.getCode(), "MASTER_PLATE"); assertEquals(type.getFetchOptions().hasPropertyAssignments(), true); List<PropertyAssignment> propertyAssignments = type.getPropertyAssignments(); - assertEquals(propertyAssignments.get(0).getPropertyType().getCode(), "PLATE_GEOMETRY"); + assertEquals(propertyAssignments.get(0).getPropertyType().getCode(), "$PLATE_GEOMETRY"); assertEquals(propertyAssignments.get(0).getPropertyType().getLabel(), "Plate Geometry"); assertEquals(propertyAssignments.get(0).getPropertyType().getDescription(), "Plate Geometry"); assertEquals(propertyAssignments.get(0).getPropertyType().isInternalNameSpace(), Boolean.TRUE); @@ -1105,6 +1105,28 @@ public class GetSampleTest extends AbstractSampleTest v3api.logout(sessionToken); } + @Test + public void testGetWithPropertyWithInternalNamespace() + { + String sessionToken = v3api.login(TEST_USER, PASSWORD); + + SampleFetchOptions fetchOptions = new SampleFetchOptions(); + fetchOptions.withProperties(); + + List<SamplePermId> sampleIds = Collections.singletonList(new SamplePermId("200811050919915-8")); + Map<ISampleId, Sample> map = v3api.getSamples(sessionToken, sampleIds, fetchOptions); + List<Sample> samples = new ArrayList<Sample>(map.values()); + + assertEquals(samples.size(), 1); + + Sample sample = samples.get(0); + assertEquals(sample.getPermId().getPermId(), "200811050919915-8"); + + Map<String, String> properties = sample.getProperties(); + assertEquals(properties.get("$PLATE_GEOMETRY"), "384_WELLS_16X24"); + v3api.logout(sessionToken); + } + @Test public void testGetWithTypeReused() { diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchPropertyAssignmentTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchPropertyAssignmentTest.java index f0b50b695bd..2a14ba80436 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchPropertyAssignmentTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchPropertyAssignmentTest.java @@ -111,6 +111,14 @@ public class SearchPropertyAssignmentTest extends AbstractTest "HCS_IMAGE.COMMENT"); } + @Test + public void testSearchWithPropertyTypeWithInternalNamespace() + { + PropertyAssignmentSearchCriteria criteria = new PropertyAssignmentSearchCriteria(); + criteria.withPropertyType().withId().thatEquals(new PropertyTypePermId("$PLATE_GEOMETRY")); + testSearch(TEST_USER, criteria, "MASTER_PLATE.$PLATE_GEOMETRY", "CONTROL_LAYOUT.$PLATE_GEOMETRY"); + } + @Test public void testSearchWithSemanticAnnotations() { @@ -141,7 +149,8 @@ public class SearchPropertyAssignmentTest extends AbstractTest } } - assertPropertyAssignments(withOwnSemanticAnnotations, "MASTER_PLATE.PLATE_GEOMETRY", "CONTROL_LAYOUT.PLATE_GEOMETRY", "CELL_PLATE.ORGANISM"); + assertPropertyAssignments(withOwnSemanticAnnotations, "MASTER_PLATE.$PLATE_GEOMETRY", "CONTROL_LAYOUT.$PLATE_GEOMETRY", + "CELL_PLATE.ORGANISM"); assertPropertyAssignments(withInheritedSemanticAnnotations, "MASTER_PLATE.DESCRIPTION", "CONTROL_LAYOUT.DESCRIPTION", "NORMAL.ORGANISM", "DELETION_TEST.ORGANISM", "DELETION_TEST.DESCRIPTION"); diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchSampleTypeTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchSampleTypeTest.java index 1fb1c565e75..ef9c554c2f4 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchSampleTypeTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchSampleTypeTest.java @@ -457,8 +457,9 @@ public class SearchSampleTypeTest extends AbstractTest SampleType type = searchResult.getObjects().get(0); assertEquals(type.getCode(), "MASTER_PLATE"); assertEquals(type.getPropertyAssignments().size(), 2); - assertEquals(type.getPropertyAssignments().get(0).getPropertyType().getCode(), "DESCRIPTION"); - assertEquals(type.getPropertyAssignments().get(1).getPropertyType().getCode(), "PLATE_GEOMETRY"); + assertEquals(type.getPropertyAssignments().get(0).getPropertyType().getCode(), "$PLATE_GEOMETRY"); + assertEquals(type.getPropertyAssignments().get(1).getPropertyType().getCode(), "DESCRIPTION"); + } @Test @@ -638,7 +639,7 @@ public class SearchSampleTypeTest extends AbstractTest @Test public void testSearchWithSemanticAnnotationsFetchedForSamplePropertyAssignmentsAndSemanticAnnotationsDefinedAtBothSamplePropertyAssignmentAndPropertyTypeLevels() { - testSearchWithSemanticAnnotationsFetchedForSamplePropertyAssignments("MASTER_PLATE", "PLATE_GEOMETRY", 3); + testSearchWithSemanticAnnotationsFetchedForSamplePropertyAssignments("MASTER_PLATE", "$PLATE_GEOMETRY", 3); } @SuppressWarnings("null") diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateEntityTypeTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateEntityTypeTest.java index 7ba257ae190..80d14f8a221 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateEntityTypeTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateEntityTypeTest.java @@ -55,9 +55,9 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP protected abstract UPDATE newTypeUpdate(); protected abstract EntityTypePermId getTypeId(); - + protected abstract void createEntity(String sessionToken, IEntityTypeId entityType, String propertyType, String propertyValue); - + protected abstract void updateTypes(String sessionToken, List<UPDATE> updates); protected abstract TYPE getType(String sessionToken, EntityTypePermId typeId); @@ -69,9 +69,9 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP protected abstract String getValidationPluginOrNull(String sessionToken, EntityTypePermId typeId); protected abstract AbstractEntitySearchCriteria<?> createSearchCriteria(EntityTypePermId typeId); - + protected abstract List<? extends IPropertiesHolder> searchEntities(String sessionToken, AbstractEntitySearchCriteria<?> searchCriteria); - + @Test public void testUpdateWithUnspecifiedId() { @@ -97,7 +97,7 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP // Given String sessionToken = v3api.login(TEST_USER, PASSWORD); UPDATE update = newTypeUpdate(); - + update.setTypeId(new EntityTypePermId("UNDEFINED", getTypeId().getEntityKind())); assertUserFailureException(new IDelegatedAction() @@ -110,7 +110,7 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP }, "Object with EntityTypePermId = [" + update.getTypeId() + "] has not been found."); } - + @Test public void testUpdateWithIdWrongEntityKind() { @@ -143,16 +143,16 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP update.setTypeId(typeId); update.setDescription("new description " + System.currentTimeMillis()); updateTypeSpecificFields(update, 0); - + // When updateTypes(sessionToken, Arrays.asList(update)); - + // Then TYPE type = getType(sessionToken, typeId); assertEquals(type.getDescription(), update.getDescription().getValue()); assertTypeSpecificFields(type, update, 0); } - + @Test public void testUpdateDescriptionUsingEntityTypePermIdWithoutEntityKind() { @@ -163,16 +163,16 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP update.setTypeId(typeId); update.setDescription("new description " + System.currentTimeMillis()); updateTypeSpecificFields(update, 0); - + // When updateTypes(sessionToken, Arrays.asList(update)); - + // Then TYPE type = getType(sessionToken, typeId); assertEquals(type.getDescription(), update.getDescription().getValue()); assertTypeSpecificFields(type, update, 0); } - + @Test public void testUpdateWithValidationPlugin() { @@ -183,16 +183,16 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP update.setTypeId(typeId); update.setValidationPluginId(new PluginPermId("validateOK")); updateTypeSpecificFields(update, 1); - + // When updateTypes(sessionToken, Arrays.asList(update)); - + // Then assertEquals(getValidationPluginOrNull(sessionToken, typeId), "validateOK"); TYPE type = getType(sessionToken, typeId); assertTypeSpecificFields(type, update, 1); } - + @Test public void testUpdateRemovingValidationPlugin() { @@ -205,20 +205,20 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP updateTypeSpecificFields(update, 1); updateTypes(sessionToken, Arrays.asList(update)); assertEquals(getValidationPluginOrNull(sessionToken, typeId), "validateOK"); - + update = newTypeUpdate(); update.setTypeId(typeId); update.getValidationPluginId().setValue(null); - + // When updateTypes(sessionToken, Arrays.asList(update)); - + // Then assertEquals(getValidationPluginOrNull(sessionToken, typeId), null); TYPE type = getType(sessionToken, typeId); assertTypeSpecificFields(type, update, 1); } - + @Test public void testUpdateWithValidationPluginOfIncorrectType() { @@ -267,7 +267,7 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP "Entity type validation plugin has entity kind set to '" + incorrectEntityKind.name() + "'. Expected a plugin where entity kind is either '" + getEntityKind().name() + "' or null"); } - + @Test public void testUpdateWithValidationPluginOfCorrectEntityType() { @@ -283,7 +283,7 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP pluginPermId = "test" + correctEntityKind; update.setValidationPluginId(new PluginPermId(pluginPermId)); } - + // When updateTypes(sessionToken, Arrays.asList(update)); @@ -292,7 +292,7 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP TYPE type = getType(sessionToken, typeId); assertTypeSpecificFields(type, update, 1); } - + @Test public void testAddAndRemovePropertyTypeAssignment() { @@ -313,7 +313,7 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP update.getPropertyAssignments().remove(new PropertyAssignmentPermId(typeId, new PropertyTypePermId("description"))); Map<String, String> renderedAssignments = getCurrentRenderedPropertyAssignmentsByPropertyTypeCode(sessionToken); renderedAssignments.remove("DESCRIPTION"); - renderedAssignments.put("SIZE", "PropertyAssignment entity type: " + typeId.getPermId() + renderedAssignments.put("SIZE", "PropertyAssignment entity type: " + typeId.getPermId() + ", property type: SIZE, mandatory: false, showInEditView: false, showRawValueInForms: false"); // When @@ -324,8 +324,9 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP List<String> actual = getSortedRenderedAssignments(sessionToken); assertEquals(actual.toString(), expected.toString()); } - - @Test public void testRemovePropertyTypeAssignmentFailsBecauseOfEntitiesWithSuchProperty() + + @Test + public void testRemovePropertyTypeAssignmentFailsBecauseOfEntitiesWithSuchProperty() { // Given String sessionToken = v3api.login(TEST_USER, PASSWORD); @@ -357,8 +358,7 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP UPDATE update = newTypeUpdate(); EntityTypePermId typeId = getTypeId(); PropertyType propertyType = getType(sessionToken, typeId).getPropertyAssignments().get(0).getPropertyType(); - String prefix = propertyType.isInternalNameSpace() ? "$" : ""; - String propertyTypePermId = prefix + propertyType.getCode(); + String propertyTypePermId = propertyType.getCode(); update.setTypeId(typeId); PropertyAssignmentCreation assignmentCreation = new PropertyAssignmentCreation(); assignmentCreation.setPropertyTypeId(new PropertyTypePermId(propertyTypePermId)); @@ -373,7 +373,7 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP updateTypes(sessionToken, Arrays.asList(update)); } }, - "Property type '" + propertyTypePermId + "' is already assigned to " + "Property type '" + propertyTypePermId + "' is already assigned to " + getEntityKind().getLabel() + " type '" + typeId.getPermId() + "'."); } @@ -407,14 +407,14 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP renderedAssignments.remove("COMMENT"); renderedAssignments.remove("COMPOUND_HCS"); renderedAssignments.remove("GENE_SYMBOL"); - renderedAssignments.put("SIZE", "PropertyAssignment entity type: " + typeId.getPermId() + renderedAssignments.put("SIZE", "PropertyAssignment entity type: " + typeId.getPermId() + ", property type: SIZE, mandatory: true, showInEditView: false, showRawValueInForms: true"); - renderedAssignments.put("PLATE_GEOMETRY", "PropertyAssignment entity type: " + typeId.getPermId() - + ", property type: PLATE_GEOMETRY, mandatory: false, showInEditView: true, showRawValueInForms: false"); - + renderedAssignments.put("$PLATE_GEOMETRY", "PropertyAssignment entity type: " + typeId.getPermId() + + ", property type: $PLATE_GEOMETRY, mandatory: false, showInEditView: true, showRawValueInForms: false"); + // When updateTypes(sessionToken, Arrays.asList(update)); - + // Then List<String> expected = getSortedRenderedAssignments(renderedAssignments); List<String> actual = getSortedRenderedAssignments(sessionToken); @@ -488,7 +488,7 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP UPDATE update = newTypeUpdate(); update.setTypeId(typeId); update.setDescription("new description " + System.currentTimeMillis()); - + // When updateTypes(sessionToken, Arrays.asList(update)); } @@ -506,7 +506,7 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP { return fieldUpdateValue != null && fieldUpdateValue.isModified() ? fieldUpdateValue.getValue() : currentValue; } - + private EntityKind getIncorrectEntityKind() { if (EntityKind.EXPERIMENT.equals(getEntityKind())) @@ -517,7 +517,7 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP return EntityKind.EXPERIMENT; } } - + private EntityKind getCorrectEntityKind() { if (EntityKind.EXPERIMENT.equals(getEntityKind())) @@ -531,7 +531,7 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP return null; } } - + private List<String> getSortedRenderedAssignments(String sessionToken) { return getSortedRenderedAssignments(getCurrentRenderedPropertyAssignmentsByPropertyTypeCode(sessionToken)); @@ -543,7 +543,7 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP Collections.sort(renderedAssignments); return renderedAssignments; } - + private Map<String, String> getCurrentRenderedPropertyAssignmentsByPropertyTypeCode(String sessionToken) { Map<String, String> result = new HashMap<String, String>(); @@ -560,12 +560,12 @@ public abstract class UpdateEntityTypeTest<UPDATE extends IEntityTypeUpdate, TYP } return result; } - + private ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.EntityKind nextEntityKind( ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.EntityKind entityKind) { - ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.EntityKind[] values - = ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.EntityKind.values(); + ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.EntityKind[] values = + ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.EntityKind.values(); return values[(entityKind.ordinal() + 1) % values.length]; } -- GitLab