Skip to content
Snippets Groups Projects
Commit 67765162 authored by cramakri's avatar cramakri
Browse files

LMS-1505 Created an interface for the Screening Service Facade.

SVN: 15888
parent baa71c47
No related branches found
No related tags found
No related merge requests found
/*
* 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.client.api.v1;
import java.io.IOException;
import java.util.List;
import ch.systemsx.cisd.openbis.plugin.screening.client.api.v1.ScreeningOpenbisServiceFacade.IImageOutputStreamProvider;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureVectorDataset;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureVectorDatasetReference;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.IDatasetIdentifier;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.IFeatureVectorDatasetIdentifier;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.IImageDatasetIdentifier;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.ImageDatasetMetadata;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.ImageDatasetReference;
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.PlateImageReference;
/**
*
*
* @author Chandrasekhar Ramakrishnan
*/
public interface IScreeningOpenbisServiceFacade
{
/**
* Return the session token for this authenticated user.
*/
public abstract String getSessionToken();
/** Closes connection with the server. After calling this method this facade cannot be used. */
public abstract void logout();
/**
* Return the list of all visible plates assigned to any experiment, along with their
* hierarchical context (space, project, experiment).
*/
public abstract List<Plate> listPlates();
/**
* For a given set of plates provides the list of all connected data sets containing feature
* vectors.
*/
public abstract List<FeatureVectorDatasetReference> listFeatureVectorDatasets(
List<? extends PlateIdentifier> plates);
/**
* For a given set of plates provides the list of all connected data sets containing images.
*/
public abstract List<ImageDatasetReference> listImageDatasets(
List<? extends PlateIdentifier> plates);
/**
* Converts a given list of dataset codes to dataset identifiers which can be used in other API
* calls.
*/
public abstract List<IDatasetIdentifier> getDatasetIdentifiers(List<String> datasetCodes);
/**
* For a given set of feature vector data sets provides the list of all available features. This
* is just the name of the feature. If for different data sets different sets of features are
* available, provides the union of the feature names of all data sets.
*/
public abstract List<String> listAvailableFeatureNames(
List<? extends IFeatureVectorDatasetIdentifier> featureDatasets);
/**
* For a given set of data sets and a set of features (given by their name), provide all the
* feature vectors.
*/
public abstract List<FeatureVectorDataset> loadFeatures(
List<? extends IFeatureVectorDatasetIdentifier> featureDatasets,
List<String> featureNames);
/**
* Saves images for a given list of image references (given by data set code, well position,
* channel and tile) in the provided output streams. Output streams will not be closed
* automatically.<br>
* The number of image references has to be the same as the number of files.
*
* @throws IOException when reading images from the server or writing them to the output streams
* fails
*/
public abstract void loadImages(List<PlateImageReference> imageReferences,
IImageOutputStreamProvider outputStreamProvider) throws IOException;
/**
* For a given set of image data sets, provide all image channels that have been acquired and
* the available (natural) image size(s).
*/
public abstract List<ImageDatasetMetadata> listImageMetadata(
List<? extends IImageDatasetIdentifier> imageDatasets);
}
\ No newline at end of file
......@@ -66,7 +66,7 @@ public class ScreeningClientApiTest
System.out.println(String.format("Connecting to the server '%s' as a user '%s.", serverUrl,
userId));
ScreeningOpenbisServiceFacade facade =
IScreeningOpenbisServiceFacade facade =
ScreeningOpenbisServiceFacade.tryCreate(userId, userPassword, serverUrl);
if (facade == null)
{
......@@ -104,7 +104,7 @@ public class ScreeningClientApiTest
facade.logout();
}
private static IDatasetIdentifier getDatasetIdentifier(ScreeningOpenbisServiceFacade facade,
private static IDatasetIdentifier getDatasetIdentifier(IScreeningOpenbisServiceFacade facade,
String datasetCode)
{
IDatasetIdentifier datasetIdentifier =
......@@ -112,7 +112,7 @@ public class ScreeningClientApiTest
return datasetIdentifier;
}
private static void loadImages(ScreeningOpenbisServiceFacade facade,
private static void loadImages(IScreeningOpenbisServiceFacade facade,
IDatasetIdentifier datasetIdentifier) throws FileNotFoundException, IOException
{
File dir = new File(datasetIdentifier.getDatasetCode());
......@@ -148,7 +148,7 @@ public class ScreeningClientApiTest
*
* @throws IOException when reading images from the server or writing them to the files fails
*/
private static void loadImages(ScreeningOpenbisServiceFacade facade,
private static void loadImages(IScreeningOpenbisServiceFacade facade,
List<PlateImageReference> imageReferences, List<File> imageOutputFiles)
throws IOException
{
......
......@@ -28,7 +28,7 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateImageRef
*
* @author Tomasz Pylak
*/
public class ScreeningOpenbisServiceFacade
public class ScreeningOpenbisServiceFacade implements IScreeningOpenbisServiceFacade
{
private static final String DSS_SCREENING_API = "/rmi-datastore-server-screening-api-v1/";
......@@ -48,7 +48,7 @@ public class ScreeningOpenbisServiceFacade
*
* @return null if the user could not be authenticated.
*/
public static ScreeningOpenbisServiceFacade tryCreate(String userId, String userPassword,
public static IScreeningOpenbisServiceFacade tryCreate(String userId, String userPassword,
String serverUrl)
{
IScreeningApiServer openbisServer = createScreeningOpenbisServer(serverUrl);
......@@ -60,6 +60,19 @@ public class ScreeningOpenbisServiceFacade
return new ScreeningOpenbisServiceFacade(openbisServer, sessionToken);
}
/**
* Creates a service facade which communicates with the openBIS server at the specified URL for
* an authenticated user.
*
* @param sessionToken The session token for the authenticated user
* @param serverUrl The URL for the openBIS application server
*/
public static IScreeningOpenbisServiceFacade tryCreate(String sessionToken, String serverUrl)
{
IScreeningApiServer openbisServer = createScreeningOpenbisServer(serverUrl);
return new ScreeningOpenbisServiceFacade(openbisServer, sessionToken);
}
private static IScreeningApiServer createScreeningOpenbisServer(String serverUrl)
{
return HttpInvokerUtils.createServiceStub(IScreeningApiServer.class, serverUrl
......@@ -79,6 +92,14 @@ public class ScreeningOpenbisServiceFacade
this.sessionToken = sessionToken;
}
/**
* Return the session token for this authenticated user.
*/
public String getSessionToken()
{
return sessionToken;
}
/** Closes connection with the server. After calling this method this facade cannot be used. */
public void logout()
{
......@@ -192,7 +213,8 @@ public class ScreeningOpenbisServiceFacade
InputStream stream = dssServer.loadImages(sessionToken, imageReferences);
try
{
ConcatenatedFileOutputStreamWriter imagesWriter = new ConcatenatedFileOutputStreamWriter(stream);
ConcatenatedFileOutputStreamWriter imagesWriter =
new ConcatenatedFileOutputStreamWriter(stream);
for (PlateImageReference imageRef : imageReferences)
{
OutputStream output = outputStreamProvider.getOutputStream(imageRef);
......
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