Skip to content
Snippets Groups Projects
Commit 1ddab388 authored by felmer's avatar felmer
Browse files

SSDM-3401: searchExperimentTypes introduced, implemented and tested

SVN: 36088
parent 73f8b47f
No related branches found
No related tags found
No related merge requests found
Showing
with 289 additions and 0 deletions
......@@ -39,9 +39,11 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.IDeletionId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.search.DeletionSearchCriteria;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.search.EntityTypeSearchCriteria;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.Experiment;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.ExperimentType;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.create.ExperimentCreation;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.delete.ExperimentDeletionOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.fetchoptions.ExperimentFetchOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.fetchoptions.ExperimentTypeFetchOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.id.ExperimentPermId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.id.IExperimentId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.search.ExperimentSearchCriteria;
......@@ -128,6 +130,7 @@ import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.ISearchCustom
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.ISearchDataSetMethodExecutor;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.ISearchDeletionMethodExecutor;
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.ISearchObjectKindModificationMethodExecutor;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.ISearchProjectMethodExecutor;
......@@ -241,6 +244,9 @@ public class ApplicationServerApi extends AbstractServer<IApplicationServerApi>
@Autowired
private ISearchExperimentMethodExecutor searchExperimentExecutor;
@Autowired
private ISearchExperimentTypeMethodExecutor searchExperimentTypeExecutor;
@Autowired
private ISearchSampleMethodExecutor searchSampleExecutor;
......@@ -562,6 +568,13 @@ public class ApplicationServerApi extends AbstractServer<IApplicationServerApi>
return searchExperimentExecutor.search(sessionToken, searchCriteria, fetchOptions);
}
@Override
public SearchResult<ExperimentType> searchExperimentTypes(String sessionToken, EntityTypeSearchCriteria searchCriteria,
ExperimentTypeFetchOptions fetchOptions)
{
return searchExperimentTypeExecutor.search(sessionToken, searchCriteria, fetchOptions);
}
@Override
@Transactional(readOnly = true)
@RolesAllowed({ RoleWithHierarchy.SPACE_OBSERVER, RoleWithHierarchy.SPACE_ETL_SERVER })
......
......@@ -35,9 +35,11 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.IDeletionId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.search.DeletionSearchCriteria;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.search.EntityTypeSearchCriteria;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.Experiment;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.ExperimentType;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.create.ExperimentCreation;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.delete.ExperimentDeletionOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.fetchoptions.ExperimentFetchOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.fetchoptions.ExperimentTypeFetchOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.id.ExperimentPermId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.id.IExperimentId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.search.ExperimentSearchCriteria;
......@@ -307,6 +309,14 @@ public class ApplicationServerApiLogger extends AbstractServerLogger implements
return null;
}
@Override
public SearchResult<ExperimentType> searchExperimentTypes(String sessionToken, EntityTypeSearchCriteria searchCriteria,
ExperimentTypeFetchOptions fetchOptions)
{
logAccess(sessionToken, "search-experiment-types", "SEARCH_CRITERIA:\n%s\nFETCH_OPTIONS:\n%s\n", searchCriteria, fetchOptions);
return null;
}
@Override
public SearchResult<Sample> searchSamples(String sessionToken, SampleSearchCriteria searchCriteria, SampleFetchOptions fetchOptions)
{
......
/*
* 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.experiment;
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.ExperimentTypePE;
/**
*
*
* @author Franz-Josef Elmer
*/
public interface ISearchExperimentTypeExecutor extends ISearchObjectExecutor<EntityTypeSearchCriteria, ExperimentTypePE>
{
}
/*
* 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.experiment;
import java.util.List;
import org.springframework.stereotype.Component;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.search.CodeSearchCriteria;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.search.ISearchCriteria;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.search.PermIdSearchCriteria;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.search.EntityTypeSearchCriteria;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.common.AbstractSearchObjectManuallyExecutor;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.common.CodeMatcher;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.common.Matcher;
import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentTypePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.properties.EntityKind;
/**
*
*
* @author Franz-Josef Elmer
*/
@Component
public class SearchExperimentTypeExecutor extends AbstractSearchObjectManuallyExecutor<EntityTypeSearchCriteria, ExperimentTypePE>
implements ISearchExperimentTypeExecutor
{
@Override
protected List<ExperimentTypePE> listAll()
{
return daoFactory.getEntityTypeDAO(EntityKind.EXPERIMENT).listEntityTypes();
}
@Override
protected Matcher<ExperimentTypePE> getMatcher(ISearchCriteria criteria)
{
if (criteria instanceof PermIdSearchCriteria || criteria instanceof CodeSearchCriteria)
{
return new CodeMatcher<ExperimentTypePE>();
} else
{
throw new IllegalArgumentException("Unknown search criteria: " + criteria.getClass());
}
}
}
/*
* 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.experiment.ExperimentType;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.fetchoptions.ExperimentTypeFetchOptions;
/**
*
*
* @author Franz-Josef Elmer
*/
public interface ISearchExperimentTypeMethodExecutor extends ISearchMethodExecutor<ExperimentType, EntityTypeSearchCriteria, ExperimentTypeFetchOptions>
{
}
/*
* 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.experiment.ExperimentType;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.fetchoptions.ExperimentTypeFetchOptions;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.experiment.ISearchExperimentTypeExecutor;
import ch.ethz.sis.openbis.generic.server.asapi.v3.translator.ITranslator;
import ch.ethz.sis.openbis.generic.server.asapi.v3.translator.entity.experiment.IExperimentTypeTranslator;
import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentTypePE;
/**
*
* @author Franz-Josef Elmer
*/
@Component
public class SearchExperimentTypeSqlMethodExecutor extends AbstractIdSearchMethodExecutor<ExperimentType, ExperimentTypePE, EntityTypeSearchCriteria, ExperimentTypeFetchOptions>
implements ISearchExperimentTypeMethodExecutor
{
@Autowired
private ISearchExperimentTypeExecutor searchExecutor;
@Autowired
private IExperimentTypeTranslator translator;
@Override
protected List<ExperimentTypePE> searchPEs(IOperationContext context, EntityTypeSearchCriteria criteria)
{
return searchExecutor.search(context, criteria);
}
@Override
protected ITranslator<Long, ExperimentType, ExperimentTypeFetchOptions> getTranslator()
{
return translator;
}
}
/*
* 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.experiment.ExperimentType;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.fetchoptions.ExperimentTypeFetchOptions;
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 SearchExperimentTypeTest extends AbstractTest
{
@Test
public void testSearchWithCodeThatStartsWithD()
{
String sessionToken = v3api.login(TEST_USER, PASSWORD);
EntityTypeSearchCriteria searchCriteria = new EntityTypeSearchCriteria();
searchCriteria.withCode().thatStartsWith("D");
ExperimentTypeFetchOptions fetchOptions = new ExperimentTypeFetchOptions();
SearchResult<ExperimentType> searchResult = v3api.searchExperimentTypes(sessionToken, searchCriteria, fetchOptions);
List<ExperimentType> types = searchResult.getObjects();
List<String> codes = extractCodes(types);
Collections.sort(codes);
assertEquals(codes.toString(), "[DELETION_TEST]");
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("D");
ExperimentTypeFetchOptions fetchOptions = new ExperimentTypeFetchOptions();
fetchOptions.withPropertyAssignments().sortBy().code().desc();
SearchResult<ExperimentType> searchResult = v3api.searchExperimentTypes(sessionToken, searchCriteria, fetchOptions);
List<ExperimentType> types = searchResult.getObjects();
Collections.sort(types, new CodeComparator<ExperimentType>());
List<String> codes = extractCodes(types);
assertEquals(codes.toString(), "[DELETION_TEST]");
assertEquals(types.get(0).getFetchOptions().hasPropertyAssignments(), true);
List<PropertyAssignment> propertyAssignments = types.get(0).getPropertyAssignments();
assertOrder(propertyAssignments, "ORGANISM", "DESCRIPTION", "BACTERIUM");
v3api.logout(sessionToken);
}
}
......@@ -34,9 +34,11 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.IDeletionId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.search.DeletionSearchCriteria;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.search.EntityTypeSearchCriteria;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.Experiment;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.ExperimentType;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.create.ExperimentCreation;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.delete.ExperimentDeletionOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.fetchoptions.ExperimentFetchOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.fetchoptions.ExperimentTypeFetchOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.id.ExperimentPermId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.id.IExperimentId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.search.ExperimentSearchCriteria;
......@@ -174,6 +176,8 @@ public interface IApplicationServerApi extends IRpcService
public SearchResult<Experiment> searchExperiments(String sessionToken, ExperimentSearchCriteria searchCriteria,
ExperimentFetchOptions fetchOptions);
public SearchResult<ExperimentType> searchExperimentTypes(String sessionToken, EntityTypeSearchCriteria searchCriteria, ExperimentTypeFetchOptions fetchOptions);
public SearchResult<Sample> searchSamples(String sessionToken, SampleSearchCriteria searchCriteria, SampleFetchOptions fetchOptions);
public SearchResult<SampleType> searchSampleTypes(String sessionToken, EntityTypeSearchCriteria searchCriteria, SampleTypeFetchOptions fetchOptions);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment