diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/IScreeningOpenbisServiceFacade.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/IScreeningOpenbisServiceFacade.java index 1195eca66e64d612bf06569e916d7bc6cfc21f15..52968f6e8a673a32072b27af31d97d8dc93554f1 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/IScreeningOpenbisServiceFacade.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/IScreeningOpenbisServiceFacade.java @@ -39,6 +39,7 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateIdentifi import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateImageReference; 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.api.v1.dto.WellIdentifier; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.WellPosition; /** @@ -105,6 +106,11 @@ public interface IScreeningOpenbisServiceFacade public List<PlateWellReferenceWithDatasets> listPlateWells( MaterialIdentifier materialIdentifier, boolean findDatasets); + /** + * For the given <var>plateIdentifier</var> find all wells that are connected to it. + */ + public List<WellIdentifier> listPlateWells(PlateIdentifier plateIdentifier); + /** * Converts the given list of {@link PlateWellReferenceWithDatasets} into a list of * {@link FeatureVectorDatasetWellReference}. @@ -251,7 +257,7 @@ public interface IScreeningOpenbisServiceFacade public void loadImages(List<PlateImageReference> imageReferences, IImageOutputStreamProvider outputStreamProvider, boolean convertToPNG) throws IOException; - + /** * Loads original images or thumbnails for a specified data set, a list of well positions (empty * list means all wells), a channel, and an optional thumb nail size. Images of all tiles are @@ -264,30 +270,29 @@ public interface IScreeningOpenbisServiceFacade public List<byte[]> loadImages(IDatasetIdentifier dataSetIdentifier, List<WellPosition> wellPositions, String channel, ImageSize thumbnailSizeOrNull) throws IOException; - + /** - * Loads PNG-encoded images for specified data set, list of well positions (empty - * list means all wells), channel, and optional thumb nail size. Images of all tiles are - * delivered. If thumb nail size isn't specified the original image is delivered otherwise a - * thumb nail image with same aspect ratio as the original image but which fits into specified - * size will be delivered. + * Loads PNG-encoded images for specified data set, list of well positions (empty list means all + * wells), channel, and optional thumb nail size. Images of all tiles are delivered. If thumb + * nail size isn't specified the original image is delivered otherwise a thumb nail image with + * same aspect ratio as the original image but which fits into specified size will be delivered. * * @param plateImageHandler Handles delivered images. */ public void loadImages(IDatasetIdentifier datasetIdentifier, List<WellPosition> wellPositions, String channel, ImageSize thumbnailSizeOrNull, IPlateImageHandler plateImageHandler) throws IOException; - + /** - * Saves the specified transformer factory for the specified channel and the experiment to - * which the specified data sets belong. + * Saves the specified transformer factory for the specified channel and the experiment to which + * the specified data sets belong. */ - public void saveImageTransformerFactory(List<IDatasetIdentifier> dataSetIdentifiers, String channel, - IImageTransformerFactory transformerFactoryOrNull); + public void saveImageTransformerFactory(List<IDatasetIdentifier> dataSetIdentifiers, + String channel, IImageTransformerFactory transformerFactoryOrNull); /** - * Returns the transformer factory for the specified channel and the experiment to which - * the specified data sets belong. + * Returns the transformer factory for the specified channel and the experiment to which the + * specified data sets belong. * * @return <code>null</code> if such a factory has been defined yet. */ diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningOpenbisServiceFacade.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningOpenbisServiceFacade.java index 943dc7e6ec052f38e1c8af33ac963f8648768afa..73a1476e4a814fa2efa6a23f6b4f4daae92c2eda 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningOpenbisServiceFacade.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningOpenbisServiceFacade.java @@ -11,8 +11,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; +import java.util.Set; import ch.systemsx.cisd.base.image.IImageTransformerFactory; import ch.systemsx.cisd.common.api.MinimalMinorVersion; @@ -38,6 +38,7 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateIdentifi import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateImageReference; 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.api.v1.dto.WellIdentifier; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.WellPosition; /** @@ -237,6 +238,18 @@ public class ScreeningOpenbisServiceFacade implements IScreeningOpenbisServiceFa .listPlateWells(sessionToken, materialIdentifier, findDatasets); } + /** + * For the given <var>plateIdentifier</var> find all wells that are connected to it. + */ + public List<WellIdentifier> listPlateWells(PlateIdentifier plateIdentifier) + { + checkASMinimalMinorVersion("listPlateWells", PlateIdentifier.class); + return openbisScreeningServer.listPlateWells(sessionToken, plateIdentifier); + } + + // IDataSetDss getDataSet(WellIdentifier well) + // IDataSetDss putDataSet(WellIdentifier well, File dataSetFile) + /** * Converts a given list of dataset codes to dataset identifiers which can be used in other API * calls. @@ -499,8 +512,8 @@ public class ScreeningOpenbisServiceFacade implements IScreeningOpenbisServiceFa { // Only available since v1.3 stream = - dssService.getService().loadImages(sessionToken, - references, convertToPNG); + dssService.getService().loadImages(sessionToken, + references, convertToPNG); } else { checkDSSMinimalMinorVersion(dssService, "loadImages", @@ -540,7 +553,7 @@ public class ScreeningOpenbisServiceFacade implements IScreeningOpenbisServiceFa throw ex.getIoException(); } } - + public List<byte[]> loadImages(IDatasetIdentifier dataSetIdentifier, List<WellPosition> wellPositions, String channel, ImageSize thumbnailSizeOrNull) throws IOException @@ -595,16 +608,18 @@ public class ScreeningOpenbisServiceFacade implements IScreeningOpenbisServiceFa } while (size >= 0); } - public void saveImageTransformerFactory(List<IDatasetIdentifier> dataSetIdentifiers, String channel, - IImageTransformerFactory transformerFactoryOrNull) + public void saveImageTransformerFactory(List<IDatasetIdentifier> dataSetIdentifiers, + String channel, IImageTransformerFactory transformerFactoryOrNull) { Map<String, List<IDatasetIdentifier>> map = getReferencesPerDss(dataSetIdentifiers); Set<Entry<String, List<IDatasetIdentifier>>> entrySet = map.entrySet(); for (Entry<String, List<IDatasetIdentifier>> entry : entrySet) { String serverUrl = entry.getKey(); - IDssServiceRpcScreening service = dssServiceCache.createDssService(serverUrl).getService(); - service.saveImageTransformerFactory(sessionToken, entry.getValue(), channel, transformerFactoryOrNull); + IDssServiceRpcScreening service = + dssServiceCache.createDssService(serverUrl).getService(); + service.saveImageTransformerFactory(sessionToken, entry.getValue(), channel, + transformerFactoryOrNull); } } @@ -615,10 +630,12 @@ public class ScreeningOpenbisServiceFacade implements IScreeningOpenbisServiceFa Set<Entry<String, List<IDatasetIdentifier>>> entrySet = map.entrySet(); if (entrySet.size() != 1) { - throw new IllegalArgumentException("Only one data store expected instead of " + map.keySet()); + throw new IllegalArgumentException("Only one data store expected instead of " + + map.keySet()); } Entry<String, List<IDatasetIdentifier>> entry = entrySet.iterator().next(); - IDssServiceRpcScreening service = dssServiceCache.createDssService(entry.getKey()).getService(); + IDssServiceRpcScreening service = + dssServiceCache.createDssService(entry.getKey()).getService(); return service.getImageTransformerFactoryOrNull(sessionToken, dataSetIdentifiers, channel); } 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 23532bf6e237e4d19b2fb97589a43420234bd899..1018a666056c32f4e5d935d4a4ae73b843068cb9 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 @@ -71,6 +71,7 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateWellMate import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateWellReferenceWithDatasets; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.ImageSampleContent; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.LogicalImageInfo; +import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.WellIdentifier; 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.WellContent; @@ -89,7 +90,7 @@ public final class ScreeningServer extends AbstractServer<IScreeningServer> impl /** * The minor version of this service. */ - public static final int MINOR_VERSION = 2; + public static final int MINOR_VERSION = 3; @Resource(name = ResourceNames.SCREENING_BUSINESS_OBJECT_FACTORY) private IScreeningBusinessObjectFactory businessObjectFactory; @@ -217,6 +218,11 @@ public final class ScreeningServer extends AbstractServer<IScreeningServer> impl .listPlateWells(materialIdentifier, findDatasets); } + public List<WellIdentifier> listPlateWells(String sessionToken, PlateIdentifier plateIdentifier) + { + return null; // TODO + } + public List<Plate> listPlates(String sessionToken) { return createScreeningApiImpl(sessionToken).listPlates(); 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 a35c0f747f43b436b43d6fe3e3941ec88bd697b7..4c007300c46beadef57be47fbd39483c3db67088 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 @@ -44,6 +44,7 @@ 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.api.v1.dto.WellIdentifier; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.ImageSampleContent; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.LogicalImageInfo; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.PlateContent; @@ -183,6 +184,12 @@ final class ScreeningServerLogger extends AbstractServerLogger implements IScree return null; } + public List<WellIdentifier> listPlateWells(String sessionToken, PlateIdentifier plateIdentifier) + { + logAccess(sessionToken, "listPlateWells", "plate: %s", plateIdentifier); + return null; + } + public List<Plate> listPlates(String sessionToken) { logAccess(sessionToken, "listPlates"); diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/api/authorization/PlateIdentifierPredicate.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/api/authorization/PlateIdentifierPredicate.java new file mode 100644 index 0000000000000000000000000000000000000000..b5cdbb55097c49ee5ec58279610681c09edee1ef --- /dev/null +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/api/authorization/PlateIdentifierPredicate.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.plugin.screening.shared.api.authorization; + +import java.util.List; + +import ch.systemsx.cisd.common.exceptions.Status; +import ch.systemsx.cisd.openbis.generic.shared.authorization.RoleWithIdentifier; +import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.AbstractSpacePredicate; +import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; +import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateIdentifier; + +/** + * A predicate for {@link PlateIdentifier}. + * + * @author Piotr Buczek + */ +public class PlateIdentifierPredicate extends AbstractSpacePredicate<PlateIdentifier> +{ + + @Override + public String getCandidateDescription() + { + return "experiment"; + } + + @Override + protected Status doEvaluation(PersonPE person, List<RoleWithIdentifier> allowedRoles, + PlateIdentifier value) + { + // TODO 2010-12-13, Piotr Buczek: implement dealing with shared plates and permIds + if (value.getPermId() != null) + { + return null; + } + + final String spaceCode = value.tryGetSpaceCode(); + return evaluate(person, allowedRoles, authorizationDataProvider.getHomeDatabaseInstance(), + spaceCode); + } + +} diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/api/v1/IScreeningApiServer.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/api/v1/IScreeningApiServer.java index 00286fc3ed211a4c5109909ddd4e694ec2b4ae0a..b011981e8d72ce822b2817a62db2ea138126df80 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/api/v1/IScreeningApiServer.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/api/v1/IScreeningApiServer.java @@ -28,6 +28,7 @@ import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RolesAll import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.DataSetCodeCollectionPredicate; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.authorization.ExperimentIdentifierPredicate; +import ch.systemsx.cisd.openbis.plugin.screening.shared.api.authorization.PlateIdentifierPredicate; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.authorization.PlateWellReferenceWithDatasetsValidator; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.authorization.ScreeningExperimentValidator; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.authorization.ScreeningPlateListReadOnlyPredicate; @@ -42,6 +43,7 @@ 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.api.v1.dto.WellIdentifier; /** * This interface is a part of the official public screening API. It is forbidden to change it in a @@ -69,7 +71,7 @@ public interface IScreeningApiServer extends IRpcService /** * Authenticates the user with a given password. * - *@return sessionToken if authentication succeeded, <code>null</code> otherwise. + * @return sessionToken if authentication succeeded, <code>null</code> otherwise. */ @Transactional // this is not a readOnly transaction - it can create new users @@ -162,6 +164,18 @@ public interface IScreeningApiServer extends IRpcService List<PlateWellReferenceWithDatasets> listPlateWells(String sessionToken, MaterialIdentifier materialIdentifier, boolean findDatasets); + /** + * For the given <var>plateIdentifier</var> find all wells that are connected to it. + * + * @since 1.3 + */ + @Transactional(readOnly = true) + @RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER) + @MinimalMinorVersion(3) + public List<WellIdentifier> listPlateWells( + String sessionToken, + @AuthorizationGuard(guardClass = PlateIdentifierPredicate.class) PlateIdentifier plateIdentifier); + /** * For a given list of <var>plates</var>, return the mapping of plate wells to materials * contained in each well.