diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/ApplicationServerApi.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/ApplicationServerApi.java index 4a49d72c1064d5269578c0b009b49812470813a8..4ea7bbd7aa8237dbf5994e7ebb8ecb44f8d1e935 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/ApplicationServerApi.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/ApplicationServerApi.java @@ -54,9 +54,11 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.global.GlobalSearchObject; import ch.ethz.sis.openbis.generic.asapi.v3.dto.global.fetchoptions.GlobalSearchObjectFetchOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.global.search.GlobalSearchCriteria; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.Material; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.MaterialType; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.create.MaterialCreation; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.delete.MaterialDeletionOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.fetchoptions.MaterialFetchOptions; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.fetchoptions.MaterialTypeFetchOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.id.IMaterialId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.id.MaterialPermId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.search.MaterialSearchCriteria; @@ -135,6 +137,7 @@ import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.ISearchDeleti import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.ISearchExperimentMethodExecutor; import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.ISearchExperimentTypeMethodExecutor; import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.ISearchMaterialMethodExecutor; +import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.ISearchMaterialTypeMethodExecutor; import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.ISearchObjectKindModificationMethodExecutor; import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.ISearchProjectMethodExecutor; import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.ISearchSampleMethodExecutor; @@ -266,6 +269,9 @@ public class ApplicationServerApi extends AbstractServer<IApplicationServerApi> @Autowired private ISearchMaterialMethodExecutor searchMaterialExecutor; + @Autowired + private ISearchMaterialTypeMethodExecutor searchMaterialTypeExecutor; + @Autowired private ISearchVocabularyTermMethodExecutor searchVocabularyTermExecutor; @@ -625,6 +631,15 @@ public class ApplicationServerApi extends AbstractServer<IApplicationServerApi> return searchMaterialExecutor.search(sessionToken, searchCriteria, fetchOptions); } + @Override + @Transactional(readOnly = true) + @RolesAllowed({ RoleWithHierarchy.SPACE_OBSERVER, RoleWithHierarchy.SPACE_ETL_SERVER }) + public SearchResult<MaterialType> searchMaterialTypes(String sessionToken, EntityTypeSearchCriteria searchCriteria, + MaterialTypeFetchOptions fetchOptions) + { + return searchMaterialTypeExecutor.search(sessionToken, searchCriteria, fetchOptions); + } + @Override @Transactional(readOnly = true) @RolesAllowed({ RoleWithHierarchy.SPACE_OBSERVER, RoleWithHierarchy.SPACE_ETL_SERVER }) diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/ApplicationServerApiLogger.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/ApplicationServerApiLogger.java index 14bf5478759cb2897e649672e3eb4d9f750d3c97..3d53dc965415ef56c93b342a5007c765ab66ade3 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/ApplicationServerApiLogger.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/ApplicationServerApiLogger.java @@ -50,9 +50,11 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.global.GlobalSearchObject; import ch.ethz.sis.openbis.generic.asapi.v3.dto.global.fetchoptions.GlobalSearchObjectFetchOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.global.search.GlobalSearchCriteria; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.Material; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.MaterialType; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.create.MaterialCreation; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.delete.MaterialDeletionOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.fetchoptions.MaterialFetchOptions; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.fetchoptions.MaterialTypeFetchOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.id.IMaterialId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.id.MaterialPermId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.search.MaterialSearchCriteria; @@ -356,6 +358,14 @@ public class ApplicationServerApiLogger extends AbstractServerLogger implements return null; } + @Override + public SearchResult<MaterialType> searchMaterialTypes(String sessionToken, EntityTypeSearchCriteria searchCriteria, + MaterialTypeFetchOptions fetchOptions) + { + logAccess(sessionToken, "search-material-types", "SEARCH_CRITERIA:\n%s\nFETCH_OPTIONS:\n%s\n", searchCriteria, fetchOptions); + return null; + } + @Override public SearchResult<VocabularyTerm> searchVocabularyTerms(String sessionToken, VocabularyTermSearchCriteria searchCriteria, VocabularyTermFetchOptions fetchOptions) diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/material/ISearchMaterialTypeExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/material/ISearchMaterialTypeExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..39709d2411a13c6ec02730ddb9d4879b413b1ddd --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/material/ISearchMaterialTypeExecutor.java @@ -0,0 +1,31 @@ +/* + * Copyright 2016 ETH Zuerich, SIS + * + * 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.ethz.sis.openbis.generic.server.asapi.v3.executor.material; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.search.EntityTypeSearchCriteria; +import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.common.ISearchObjectExecutor; +import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialTypePE; + +/** + * + * + * @author Franz-Josef Elmer + */ +public interface ISearchMaterialTypeExecutor extends ISearchObjectExecutor<EntityTypeSearchCriteria, MaterialTypePE> +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/material/SearchMaterialTypeExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/material/SearchMaterialTypeExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..38c9f19dff567e11d5d779d89d3c190ffb1a227f --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/material/SearchMaterialTypeExecutor.java @@ -0,0 +1,37 @@ +/* + * Copyright 2016 ETH Zuerich, SIS + * + * 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.ethz.sis.openbis.generic.server.asapi.v3.executor.material; + +import org.springframework.stereotype.Component; + +import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.entity.AbstractSearchEntityTypeExecutor; +import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialTypePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.properties.EntityKind; + +/** + * + * + * @author Franz-Josef Elmer + */ +@Component +public class SearchMaterialTypeExecutor extends AbstractSearchEntityTypeExecutor<MaterialTypePE> implements ISearchMaterialTypeExecutor +{ + public SearchMaterialTypeExecutor() + { + super(EntityKind.MATERIAL); + } +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/method/ISearchMaterialTypeMethodExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/method/ISearchMaterialTypeMethodExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..82f5db89a7c4285f6b7a467013a03ec12d55d255 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/method/ISearchMaterialTypeMethodExecutor.java @@ -0,0 +1,31 @@ +/* + * Copyright 2016 ETH Zuerich, SIS + * + * 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.ethz.sis.openbis.generic.server.asapi.v3.executor.method; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.search.EntityTypeSearchCriteria; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.MaterialType; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.fetchoptions.MaterialTypeFetchOptions; + +/** + * + * + * @author Franz-Josef Elmer + */ +public interface ISearchMaterialTypeMethodExecutor extends ISearchMethodExecutor<MaterialType, EntityTypeSearchCriteria, MaterialTypeFetchOptions> +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/method/SearchMaterialTypeSqlMethodExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/method/SearchMaterialTypeSqlMethodExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..f33cc4c88597e4dfaa477423c836e5bbc025db86 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/method/SearchMaterialTypeSqlMethodExecutor.java @@ -0,0 +1,59 @@ +/* + * Copyright 2016 ETH Zuerich, SIS + * + * 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.ethz.sis.openbis.generic.server.asapi.v3.executor.method; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.search.EntityTypeSearchCriteria; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.MaterialType; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.fetchoptions.MaterialTypeFetchOptions; +import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext; +import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.material.ISearchMaterialTypeExecutor; +import ch.ethz.sis.openbis.generic.server.asapi.v3.translator.ITranslator; +import ch.ethz.sis.openbis.generic.server.asapi.v3.translator.entity.material.IMaterialTypeTranslator; +import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialTypePE; + +/** + * + * @author Franz-Josef Elmer + */ +@Component +public class SearchMaterialTypeSqlMethodExecutor extends AbstractIdSearchMethodExecutor<MaterialType, MaterialTypePE, EntityTypeSearchCriteria, MaterialTypeFetchOptions> + implements ISearchMaterialTypeMethodExecutor +{ + @Autowired + private ISearchMaterialTypeExecutor searchExecutor; + + @Autowired + private IMaterialTypeTranslator translator; + + @Override + protected List<MaterialTypePE> searchPEs(IOperationContext context, EntityTypeSearchCriteria criteria) + { + return searchExecutor.search(context, criteria); + } + + @Override + protected ITranslator<Long, MaterialType, MaterialTypeFetchOptions> getTranslator() + { + return translator; + } + +} diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchDataSetTypeTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchDataSetTypeTest.java index c2506ae61585b758c2bddf89cec8527df9598c28..0e4a8fb4ab8b5675501ed34e4eb888d7ea181fd2 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchDataSetTypeTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchDataSetTypeTest.java @@ -72,7 +72,6 @@ public class SearchDataSetTypeTest extends AbstractTest assertEquals(codes.toString(), "[DELETION_TEST, DELETION_TEST_CONTAINER]"); assertEquals(types.get(0).getFetchOptions().hasPropertyAssignments(), true); List<PropertyAssignment> propertyAssignments = types.get(0).getPropertyAssignments(); - System.err.println(propertyAssignments.get(0).getPropertyType()); assertOrder(propertyAssignments, "ORGANISM", "DESCRIPTION", "BACTERIUM"); v3api.logout(sessionToken); } diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchMaterialTypeTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchMaterialTypeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6fc9d3c7e91b471c5f52170c12143a37ecb88cdb --- /dev/null +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchMaterialTypeTest.java @@ -0,0 +1,79 @@ +/* + * Copyright 2016 ETH Zuerich, SIS + * + * 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.ethz.sis.openbis.systemtest.asapi.v3; + +import static org.testng.Assert.assertEquals; + +import java.util.Collections; +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.search.EntityTypeSearchCriteria; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.MaterialType; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.fetchoptions.MaterialTypeFetchOptions; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.PropertyAssignment; +import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.sort.CodeComparator; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class SearchMaterialTypeTest extends AbstractTest +{ + @Test + public void testSearchWithCodeThatStartsWithB() + { + String sessionToken = v3api.login(TEST_USER, PASSWORD); + EntityTypeSearchCriteria searchCriteria = new EntityTypeSearchCriteria(); + searchCriteria.withCode().thatStartsWith("B"); + MaterialTypeFetchOptions fetchOptions = new MaterialTypeFetchOptions(); + + SearchResult<MaterialType> searchResult = v3api.searchMaterialTypes(sessionToken, searchCriteria, fetchOptions); + + List<MaterialType> types = searchResult.getObjects(); + List<String> codes = extractCodes(types); + Collections.sort(codes); + assertEquals(codes.toString(), "[BACTERIUM]"); + assertEquals(types.get(0).getFetchOptions().hasPropertyAssignments(), false); + v3api.logout(sessionToken); + } + + @Test + public void testSearchWithPropertyAssignmentSortByLabelDesc() + { + String sessionToken = v3api.login(TEST_USER, PASSWORD); + EntityTypeSearchCriteria searchCriteria = new EntityTypeSearchCriteria(); + searchCriteria.withCode().thatStartsWith("B"); + MaterialTypeFetchOptions fetchOptions = new MaterialTypeFetchOptions(); + fetchOptions.withPropertyAssignments().sortBy().label().desc(); + + SearchResult<MaterialType> searchResult = v3api.searchMaterialTypes(sessionToken, searchCriteria, fetchOptions); + + List<MaterialType> types = searchResult.getObjects(); + Collections.sort(types, new CodeComparator<MaterialType>()); + List<String> codes = extractCodes(types); + assertEquals(codes.toString(), "[BACTERIUM]"); + assertEquals(types.get(0).getFetchOptions().hasPropertyAssignments(), true); + List<PropertyAssignment> propertyAssignments = types.get(0).getPropertyAssignments(); + assertOrder(propertyAssignments, "ORGANISM", "DESCRIPTION"); + v3api.logout(sessionToken); + } + +} diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/asapi/v3/IApplicationServerApi.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/asapi/v3/IApplicationServerApi.java index d89d93b64993fba121cbd49b7cff43d0e55c871f..97d03e4edf29936d76ec67647fb8468a1a9b3c4b 100644 --- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/asapi/v3/IApplicationServerApi.java +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/asapi/v3/IApplicationServerApi.java @@ -49,9 +49,11 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.global.GlobalSearchObject; import ch.ethz.sis.openbis.generic.asapi.v3.dto.global.fetchoptions.GlobalSearchObjectFetchOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.global.search.GlobalSearchCriteria; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.Material; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.MaterialType; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.create.MaterialCreation; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.delete.MaterialDeletionOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.fetchoptions.MaterialFetchOptions; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.fetchoptions.MaterialTypeFetchOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.id.IMaterialId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.id.MaterialPermId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.material.search.MaterialSearchCriteria; @@ -190,6 +192,8 @@ public interface IApplicationServerApi extends IRpcService public SearchResult<Material> searchMaterials(String sessionToken, MaterialSearchCriteria searchCriteria, MaterialFetchOptions fetchOptions); + public SearchResult<MaterialType> searchMaterialTypes(String sessionToken, EntityTypeSearchCriteria searchCriteria, MaterialTypeFetchOptions fetchOptions); + public SearchResult<VocabularyTerm> searchVocabularyTerms(String sessionToken, VocabularyTermSearchCriteria searchCriteria, VocabularyTermFetchOptions fetchOptions);