diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/IScreeningClientService.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/IScreeningClientService.java index 0c1fa31e4b6536510a12c05c1ce9359faced69df..51b8997f0586fbee8cd7b16fbe9273eec7b8bfbe 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/IScreeningClientService.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/IScreeningClientService.java @@ -16,6 +16,7 @@ package ch.systemsx.cisd.openbis.plugin.screening.client.web.client; +import java.util.Collection; import java.util.List; import ch.systemsx.cisd.openbis.generic.client.web.client.IClientService; @@ -31,12 +32,12 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.GenericTableRow; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleParentWithDerived; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Vocabulary; -import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellImageChannelStack; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.LibraryRegistrationInfo; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateContent; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateImages; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateMaterialsSearchCriteria; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellContent; +import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellImageChannelStack; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellLocation; /** @@ -74,6 +75,11 @@ public interface IScreeningClientService extends IClientService */ public PlateImages getPlateContentForDataset(TechId datasetId); + /** + * @return ids of materials in experiment with specified id. + */ + public Collection<Long> listExperimentMaterials(TechId experimentTechId); + /** * @return well locations which belong to a parent plate connected to a specified experiment(s) * and have specified material(s) inside. diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/IScreeningClientServiceAsync.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/IScreeningClientServiceAsync.java index 1c7f95116cc0004463129777a5786205e346c55e..00153dadb85d174c460faa31ff376a3b18c8c5df 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/IScreeningClientServiceAsync.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/IScreeningClientServiceAsync.java @@ -16,6 +16,7 @@ package ch.systemsx.cisd.openbis.plugin.screening.client.web.client; +import java.util.Collection; import java.util.List; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -31,12 +32,12 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.GenericTableRow; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleParentWithDerived; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Vocabulary; -import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellImageChannelStack; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.LibraryRegistrationInfo; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateContent; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateImages; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateMaterialsSearchCriteria; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellContent; +import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellImageChannelStack; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellLocation; /** @@ -61,6 +62,12 @@ public interface IScreeningClientServiceAsync extends IClientServiceAsync /** @see IScreeningClientService#getDataSetInfo(TechId) */ public void getDataSetInfo(TechId datasetTechId, AsyncCallback<ExternalData> callback); + /** + * @see IScreeningClientService#listExperimentMaterials(TechId) + */ + public void listExperimentMaterials(TechId experimentId, + AsyncCallback<Collection<Long>> callback); + /** * @see IScreeningClientService#listPlateWells(DefaultResultSetConfig, * PlateMaterialsSearchCriteria) diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/ExperimentWellMaterialsSection.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/ExperimentWellMaterialsSection.java index 7ec0a7989acf1b762ba30ab43744139b78b25dc7..e75687356d7c91d470ade86a34ed5981f3c50dfc 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/ExperimentWellMaterialsSection.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/ExperimentWellMaterialsSection.java @@ -1,10 +1,16 @@ package ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.detailviewers; +import java.util.Collection; + +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.DisposableSectionPanel; import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IDisposableComponent; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.material.MaterialBrowserGrid; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction; import ch.systemsx.cisd.openbis.generic.shared.basic.IEntityInformationHolderWithIdentifier; +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.IScreeningClientServiceAsync; import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.Dict; import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.DisplayTypeIDGenerator; @@ -18,12 +24,12 @@ public class ExperimentWellMaterialsSection extends DisposableSectionPanel { public static final String ID_SUFFIX = "ExperimentWellMaterialsSection"; - @SuppressWarnings("unused") private final IViewContext<IScreeningClientServiceAsync> screeningViewContext; - @SuppressWarnings("unused") private final IEntityInformationHolderWithIdentifier experiment; + private Collection<Long> allowedMaterialIds; + public ExperimentWellMaterialsSection( IViewContext<IScreeningClientServiceAsync> screeningViewContext, IEntityInformationHolderWithIdentifier experiment) @@ -35,10 +41,51 @@ public class ExperimentWellMaterialsSection extends DisposableSectionPanel setDisplayID(DisplayTypeIDGenerator.PLATE_MATERIAL_BROWSER, ID_SUFFIX); } + @Override + protected void showContent() + { + IDelegatedAction onSuccessAction = new IDelegatedAction() + { + public void execute() + { + ExperimentWellMaterialsSection.super.showContent(); + } + }; + screeningViewContext.getService().listExperimentMaterials( + TechId.create(experiment), + new ListMaterialIdsCallback(viewContext.getCommonViewContext(), this, + onSuccessAction)); + } + @Override protected IDisposableComponent createDisposableContent() { - return MaterialBrowserGrid.createWithTypeChooser(viewContext.getCommonViewContext()); + return MaterialBrowserGrid.createWithTypeChooser(viewContext.getCommonViewContext(), + allowedMaterialIds); + } + + private final class ListMaterialIdsCallback extends AbstractAsyncCallback<Collection<Long>> + { + + private final IDelegatedAction onSuccessAction; + + private ExperimentWellMaterialsSection section; + + public ListMaterialIdsCallback(final IViewContext<ICommonClientServiceAsync> viewContext, + ExperimentWellMaterialsSection section, IDelegatedAction onSuccessAction) + { + super(viewContext); + this.section = section; + this.onSuccessAction = onSuccessAction; + } + + @Override + protected void process(Collection<Long> result) + { + section.allowedMaterialIds = result; + onSuccessAction.execute(); + } + } } \ No newline at end of file diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/ScreeningClientService.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/ScreeningClientService.java index 74ef62db67bdd0c91d9a547d6289b46a561a470a..002666c851bf280159f47c5c7c0463ff45677606 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/ScreeningClientService.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/ScreeningClientService.java @@ -16,6 +16,7 @@ package ch.systemsx.cisd.openbis.plugin.screening.client.web.server; +import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -57,13 +58,13 @@ import ch.systemsx.cisd.openbis.plugin.screening.BuildAndEnvironmentInfo; import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.IScreeningClientService; import ch.systemsx.cisd.openbis.plugin.screening.shared.IScreeningServer; import ch.systemsx.cisd.openbis.plugin.screening.shared.ResourceNames; -import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellImageChannelStack; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.LibraryRegistrationInfo; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateContent; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateImages; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateMaterialsSearchCriteria; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.ScreeningConstants; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellContent; +import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellImageChannelStack; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellLocation; /** @@ -185,6 +186,25 @@ public final class ScreeningClientService extends AbstractClientService implemen } } + public ResultSet<WellContent> listExperimentMaterials( + DefaultResultSetConfig<String, WellContent> gridCriteria, + final PlateMaterialsSearchCriteria materialCriteria) + { + try + { + return listEntities(gridCriteria, new IOriginalDataProvider<WellContent>() + { + public List<WellContent> getOriginalData() throws UserFailureException + { + return server.listPlateWells(getSessionToken(), materialCriteria); + } + }); + } catch (final ch.systemsx.cisd.common.exceptions.UserFailureException e) + { + throw UserFailureExceptionTranslator.translate(e); + } + } + public String prepareExportPlateLocations(TableExportCriteria<WellContent> criteria) throws ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException { @@ -290,4 +310,10 @@ public final class ScreeningClientService extends AbstractClientService implemen return server .listImageChannelStacks(sessionToken, datasetCode, datastoreCode, wellLocation); } + + public Collection<Long> listExperimentMaterials(TechId experimentId) + { + final String sessionToken = getSessionToken(); + return server.listExperimentMaterials(sessionToken, experimentId); + } } diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServer.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServer.java index 86ca28aa00bd8213a64aa512b3e2384623553748..dec15a8020c8febbf5bcacde7070eca065a42b46 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServer.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServer.java @@ -16,10 +16,16 @@ package ch.systemsx.cisd.openbis.plugin.screening.server; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Collection; import java.util.List; import javax.annotation.Resource; +import net.lemnik.eodsql.DataIterator; +import net.lemnik.eodsql.QueryTool; + import org.springframework.stereotype.Component; import ch.rinn.restrictions.Private; @@ -28,6 +34,7 @@ import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.spring.IInvocationLoggerContext; import ch.systemsx.cisd.openbis.generic.server.AbstractServer; import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleBO; +import ch.systemsx.cisd.openbis.generic.server.business.bo.common.DatabaseContextUtils; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IVocabularyDAO; import ch.systemsx.cisd.openbis.generic.server.plugin.IDataSetTypeSlaveServerPlugin; @@ -44,6 +51,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.SessionContextDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.VocabularyPE; import ch.systemsx.cisd.openbis.generic.shared.translator.SampleTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.VocabularyTranslator; +import ch.systemsx.cisd.openbis.plugin.screening.server.dataaccess.IScreeningQuery; import ch.systemsx.cisd.openbis.plugin.screening.server.logic.GenePlateLocationsLoader; import ch.systemsx.cisd.openbis.plugin.screening.server.logic.PlateContentLoader; import ch.systemsx.cisd.openbis.plugin.screening.server.logic.ScreeningApiImpl; @@ -59,11 +67,11 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.Plate; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateIdentifier; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateWellMaterialMapping; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateWellReferenceWithDatasets; -import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellImageChannelStack; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateContent; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateImages; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateMaterialsSearchCriteria; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellContent; +import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellImageChannelStack; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellLocation; /** @@ -238,6 +246,25 @@ public final class ScreeningServer extends AbstractServer<IScreeningServer> impl materialTypeIdentifierOrNull); } + public Collection<Long> listExperimentMaterials(String sessionToken, TechId experimentId) + { + // TODO 2010-09-01, Piotr Buczek: move it to some BO when we have more queries like that + IScreeningQuery dao = createDAO(getDAOFactory()); + DataIterator<Long> iterator = dao.getMaterialsForExperimentWells(experimentId.getId()); + Collection<Long> result = new ArrayList<Long>(); + for (Long l : iterator) + { + result.add(l); + } + return result; + } + + private static IScreeningQuery createDAO(IDAOFactory daoFactory) + { + Connection connection = DatabaseContextUtils.getConnection(daoFactory); + return QueryTool.getQuery(connection, IScreeningQuery.class); + } + private ScreeningApiImpl createScreeningApiImpl(String sessionToken) { final Session session = getSession(sessionToken); diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerLogger.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerLogger.java index 827e69adc51c381a247e1a0f69a8810d8e8480bf..995b9be958bf3832d1303b95a856bac68546051f 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerLogger.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerLogger.java @@ -42,11 +42,11 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.Plate; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateIdentifier; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateWellMaterialMapping; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateWellReferenceWithDatasets; -import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellImageChannelStack; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateContent; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateImages; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateMaterialsSearchCriteria; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellContent; +import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellImageChannelStack; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellLocation; /** @@ -208,6 +208,12 @@ final class ScreeningServerLogger extends AbstractServerLogger implements IScree return null; } + public Collection<Long> listExperimentMaterials(String sessionToken, TechId experimentId) + { + logAccess(sessionToken, "listExperimentMaterials", "experimentId(%s)", experimentId); + return null; + } + public int getMajorVersion() { return MAJOR_VERSION; @@ -217,4 +223,5 @@ final class ScreeningServerLogger extends AbstractServerLogger implements IScree { return ScreeningServer.MINOR_VERSION; } + } diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/dataaccess/IScreeningQuery.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/dataaccess/IScreeningQuery.java index 9a31fa2cbd943166fda8394a05ff296cd01d126b..01cb5665e4d217f37155527a2edd895946a8407b 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/dataaccess/IScreeningQuery.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/dataaccess/IScreeningQuery.java @@ -210,4 +210,27 @@ public interface IScreeningQuery extends BaseQuery + " and pt.is_internal_namespace = true and space.code = ?{1} and pl.code = ?{2}") public PlateGeometryContainer tryGetPlateGeometry(String spaceCode, String plateCode); + /** + * Returns the ids of all materials used in specified experiment. + */ + @Select(sql = "SELECT distinct well_material.id " + + " FROM samples pl " + + " JOIN samples well ON well.samp_id_part_of = pl.id" + + " JOIN sample_properties well_props ON well_props.samp_id = well.id" + + " JOIN materials well_material ON well_material.id = well_props.mate_prop_id" + + " WHERE pl.expe_id = ?{1}", fetchSize = FETCH_SIZE) + public DataIterator<Long> getMaterialsForExperimentWells(long experimentId); + + /** + * Returns the ids of materials of specified type and used in specified experiment. + */ + @Select(sql = "SELECT distinct well_material.id " + + " FROM samples pl " + + " JOIN samples well ON well.samp_id_part_of = pl.id" + + " JOIN sample_properties well_props ON well_props.samp_id = well.id" + + " JOIN materials well_material ON well_material.id = well_props.mate_prop_id" + + " WHERE pl.expe_id = ?{1} " + + " AND well_material.maty_id = {2}", fetchSize = FETCH_SIZE) + public DataIterator<Long> getMaterialsForExperimentWells(long experimentId, long materialTypeId); + } diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/IScreeningServer.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/IScreeningServer.java index 1772381c512ed65a078f61686d4b3b84477bdd3b..62c236022123c564625f7114a471dce589101b9f 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/IScreeningServer.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/IScreeningServer.java @@ -16,6 +16,7 @@ package ch.systemsx.cisd.openbis.plugin.screening.shared; +import java.util.Collection; import java.util.List; import org.springframework.transaction.annotation.Transactional; @@ -38,11 +39,11 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModel; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Vocabulary; import ch.systemsx.cisd.openbis.plugin.screening.shared.authorization.PlateMaterialsSearchCriteriaPredicate; import ch.systemsx.cisd.openbis.plugin.screening.shared.authorization.WellContentValidator; -import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellImageChannelStack; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateContent; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateImages; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateMaterialsSearchCriteria; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellContent; +import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellImageChannelStack; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellLocation; /** @@ -77,6 +78,14 @@ public interface IScreeningServer extends IServer String sessionToken, @AuthorizationGuard(guardClass = PlateMaterialsSearchCriteriaPredicate.class) PlateMaterialsSearchCriteria materialCriteria); + /** + * Loads all ids of materials connected with the specified experiment. + */ + @Transactional(readOnly = true) + @RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER) + public Collection<Long> listExperimentMaterials(String sessionToken, + @AuthorizationGuard(guardClass = ExperimentTechIdPredicate.class) TechId experimentId); + @Transactional @RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER) public List<WellImageChannelStack> listImageChannelStacks(String sessionToken,