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

LMS-2700 Added API support for finding the image formats available for an image

SVN: 24068
parent 6d917589
No related branches found
No related tags found
No related merge requests found
...@@ -3,3 +3,5 @@ ...@@ -3,3 +3,5 @@
/.updater /.updater
/.dynamic_property_evaluator_queue /.dynamic_property_evaluator_queue
/tmp /tmp
/dss-tmp
/indices-screening
...@@ -22,6 +22,7 @@ import java.io.InputStream; ...@@ -22,6 +22,7 @@ import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
...@@ -65,6 +66,7 @@ import ch.systemsx.cisd.openbis.dss.shared.DssScreeningUtils; ...@@ -65,6 +66,7 @@ import ch.systemsx.cisd.openbis.dss.shared.DssScreeningUtils;
import ch.systemsx.cisd.openbis.generic.shared.basic.CodeNormalizer; import ch.systemsx.cisd.openbis.generic.shared.basic.CodeNormalizer;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData;
import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.DatasetImageRepresentationFormats;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureInformation; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureInformation;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureVector; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureVector;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureVectorDataset; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureVectorDataset;
...@@ -78,6 +80,7 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.IImageSetMeta ...@@ -78,6 +80,7 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.IImageSetMeta
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.IImageSetSelectionCriterion; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.IImageSetSelectionCriterion;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.ImageChannel; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.ImageChannel;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.ImageDatasetMetadata; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.ImageDatasetMetadata;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.ImageRepresentationFormat;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.ImageSize; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.ImageSize;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.ImageTransformationInfo; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.ImageTransformationInfo;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.MicroscopyImageReference; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.MicroscopyImageReference;
...@@ -103,6 +106,7 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.imaging.dataaccess.ImgCo ...@@ -103,6 +106,7 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.imaging.dataaccess.ImgCo
import ch.systemsx.cisd.openbis.plugin.screening.shared.imaging.dataaccess.ImgFeatureDefDTO; import ch.systemsx.cisd.openbis.plugin.screening.shared.imaging.dataaccess.ImgFeatureDefDTO;
import ch.systemsx.cisd.openbis.plugin.screening.shared.imaging.dataaccess.ImgImageDatasetDTO; import ch.systemsx.cisd.openbis.plugin.screening.shared.imaging.dataaccess.ImgImageDatasetDTO;
import ch.systemsx.cisd.openbis.plugin.screening.shared.imaging.dataaccess.ImgImageTransformationDTO; import ch.systemsx.cisd.openbis.plugin.screening.shared.imaging.dataaccess.ImgImageTransformationDTO;
import ch.systemsx.cisd.openbis.plugin.screening.shared.imaging.dataaccess.ImgImageZoomLevelDTO;
/** /**
* Implementation of the screening API interface using RPC. The instance will be created in spring * Implementation of the screening API interface using RPC. The instance will be created in spring
...@@ -784,6 +788,69 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc ...@@ -784,6 +788,69 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc
return createPlateImageReferences(imageAccessor, dataSetIdentifier, wellPositions, channels); return createPlateImageReferences(imageAccessor, dataSetIdentifier, wellPositions, channels);
} }
public List<DatasetImageRepresentationFormats> listAvailableImageRepresentationFormats(
String sessionToken, List<? extends IDatasetIdentifier> imageDatasets)
{
IImagingReadonlyQueryDAO queryInterface = getDAO();
ArrayList<DatasetImageRepresentationFormats> result =
new ArrayList<DatasetImageRepresentationFormats>(imageDatasets.size());
// Get the database identifiers for the data sets
String[] permIds = new String[imageDatasets.size()];
for (int i = 0; i < imageDatasets.size(); ++i)
{
permIds[i] = imageDatasets.get(i).getPermId();
}
List<ImgImageDatasetDTO> primImageDatasets =
queryInterface.listImageDatasetsByPermId(permIds);
// Convert this to a hash map for faster indexing
HashMap<String, ImgImageDatasetDTO> imageDataSetMap =
new HashMap<String, ImgImageDatasetDTO>();
for (ImgImageDatasetDTO primImageDataSet : primImageDatasets)
{
imageDataSetMap.put(primImageDataSet.getPermId(), primImageDataSet);
}
// Not an efficient way to execute this query, but it reuses the queries at our disposal
for (IDatasetIdentifier imageDataset : imageDatasets)
{
ImgImageDatasetDTO primImageDataSet = imageDataSetMap.get(imageDataset.getPermId());
if (null == primImageDataSet)
{
List<ImageRepresentationFormat> emptyList = Collections.emptyList();
DatasetImageRepresentationFormats datasetResult =
new DatasetImageRepresentationFormats(imageDataset, emptyList);
result.add(datasetResult);
continue;
}
List<ImgImageZoomLevelDTO> zoomLevels =
queryInterface.listImageZoomLevels(primImageDataSet.getId());
List<ImageRepresentationFormat> formats =
convertZoomLevelsToRepresentationFormats(zoomLevels);
DatasetImageRepresentationFormats datasetResult =
new DatasetImageRepresentationFormats(imageDataset, formats);
result.add(datasetResult);
}
return result;
}
private List<ImageRepresentationFormat> convertZoomLevelsToRepresentationFormats(
List<ImgImageZoomLevelDTO> zoomLevels)
{
ArrayList<ImageRepresentationFormat> results = new ArrayList<ImageRepresentationFormat>();
for (ImgImageZoomLevelDTO zoomLevel : zoomLevels)
{
ImageRepresentationFormat result =
new ImageRepresentationFormat(zoomLevel.getIsOriginal(), zoomLevel.getWidth(),
zoomLevel.getHeight(), zoomLevel.getColorDepth(),
zoomLevel.getFileType());
results.add(result);
}
return results;
}
private IImagingDatasetLoader createImageLoader(IDatasetIdentifier dataSetIdentifier) private IImagingDatasetLoader createImageLoader(IDatasetIdentifier dataSetIdentifier)
{ {
final String datasetCode = dataSetIdentifier.getDatasetCode(); final String datasetCode = dataSetIdentifier.getDatasetCode();
......
...@@ -26,6 +26,7 @@ import ch.systemsx.cisd.common.spring.IInvocationLoggerContext; ...@@ -26,6 +26,7 @@ import ch.systemsx.cisd.common.spring.IInvocationLoggerContext;
import ch.systemsx.cisd.openbis.dss.screening.shared.api.v1.IDssServiceRpcScreening; import ch.systemsx.cisd.openbis.dss.screening.shared.api.v1.IDssServiceRpcScreening;
import ch.systemsx.cisd.openbis.dss.screening.shared.api.v1.LoadImageConfiguration; import ch.systemsx.cisd.openbis.dss.screening.shared.api.v1.LoadImageConfiguration;
import ch.systemsx.cisd.openbis.generic.shared.AbstractServerLogger; import ch.systemsx.cisd.openbis.generic.shared.AbstractServerLogger;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.DatasetImageRepresentationFormats;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureInformation; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureInformation;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureVectorDataset; 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.FeatureVectorDatasetReference;
...@@ -254,4 +255,12 @@ public class DssServiceRpcScreeningLogger extends AbstractServerLogger implement ...@@ -254,4 +255,12 @@ public class DssServiceRpcScreeningLogger extends AbstractServerLogger implement
return null; return null;
} }
public List<DatasetImageRepresentationFormats> listAvailableImageRepresentationFormats(
String sessionToken, List<? extends IDatasetIdentifier> imageDatasets)
{
logAccess(sessionToken, "list_available_image_representation_formats", "DATA_SETS(%s)",
imageDatasets);
return null;
}
} }
...@@ -29,6 +29,7 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.authorization.Da ...@@ -29,6 +29,7 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.authorization.Da
import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.authorization.PrivilegeLevel; import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.authorization.PrivilegeLevel;
import ch.systemsx.cisd.openbis.dss.screening.shared.api.internal.authorization.DatasetIdentifierPredicate; import ch.systemsx.cisd.openbis.dss.screening.shared.api.internal.authorization.DatasetIdentifierPredicate;
import ch.systemsx.cisd.openbis.dss.screening.shared.api.internal.authorization.SingleDataSetIdentifierPredicate; import ch.systemsx.cisd.openbis.dss.screening.shared.api.internal.authorization.SingleDataSetIdentifierPredicate;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.DatasetImageRepresentationFormats;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureInformation; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureInformation;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureVectorDataset; 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.FeatureVectorDatasetReference;
...@@ -393,4 +394,16 @@ public interface IDssServiceRpcScreening extends IRpcService ...@@ -393,4 +394,16 @@ public interface IDssServiceRpcScreening extends IRpcService
@AuthorizationGuard(guardClass = DatasetIdentifierPredicate.class) @AuthorizationGuard(guardClass = DatasetIdentifierPredicate.class)
List<? extends IImageDatasetIdentifier> imageDatasets); List<? extends IImageDatasetIdentifier> imageDatasets);
/**
* Return image representation formats available for the specified image datasets.
*
* @param imageDatasets The image data sets for which the representation formats are requested.
* @return A list with one entry for each in <b>imageDatasets</b>.
*/
@MinimalMinorVersion(10)
@DataSetAccessGuard
public List<DatasetImageRepresentationFormats> listAvailableImageRepresentationFormats(String sessionToken,
@AuthorizationGuard(guardClass = DatasetIdentifierPredicate.class)
List<? extends IDatasetIdentifier> imageDatasets);
} }
/*
* Copyright 2011 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.v1.dto;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
/**
* A bean that lists all image representation formats available for a data set.
*
* @since 1.10
* @author Chandrasekhar Ramakrishnan
*/
public class DatasetImageRepresentationFormats implements Serializable,
Comparable<DatasetImageRepresentationFormats>
{
private static final long serialVersionUID = 1L;
private final IDatasetIdentifier dataset;
private final ArrayList<ImageRepresentationFormat> imageRepresentationFormats;
/**
* Constructor.
*
* @param dataSet
* @param formats
*/
public DatasetImageRepresentationFormats(IDatasetIdentifier dataSet,
List<ImageRepresentationFormat> formats)
{
super();
this.dataset = dataSet;
this.imageRepresentationFormats = new ArrayList<ImageRepresentationFormat>(formats);
}
/**
* The data set the formats relate to.
*/
public IDatasetIdentifier getDataset()
{
return dataset;
}
/**
* @return An immutable list containing the image representation formats for this data set.
*/
public List<ImageRepresentationFormat> getImageRepresentationFormats()
{
return Collections.unmodifiableList(imageRepresentationFormats);
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((dataset == null) ? 0 : dataset.hashCode());
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
DatasetImageRepresentationFormats other = (DatasetImageRepresentationFormats) obj;
if (dataset == null)
{
if (other.dataset != null)
{
return false;
}
} else if (dataset.equals(other.dataset) == false)
{
return false;
}
return true;
}
public int compareTo(DatasetImageRepresentationFormats o)
{
return dataset.getDatasetCode().compareTo(o.getDataset().getDatasetCode());
}
@Override
public String toString()
{
ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
builder.append(dataset);
builder.append(imageRepresentationFormats);
return builder.toString();
}
}
/*
* Copyright 2011 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.v1.dto;
import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
/**
* An image representation format is made up of its dimensions, bit depth, and file format.
*
* @since 1.10
* @author Chandrasekhar Ramakrishnan
*/
public class ImageRepresentationFormat implements Serializable
{
private static final long serialVersionUID = 1L;
private boolean original;
private Integer width;
private Integer height;
private Integer colorDepth;
private String fileType;
/**
* Constructor.
*
* @param original
* @param width
* @param height
* @param colorDepth
* @param fileType
*/
public ImageRepresentationFormat(boolean original, Integer width, Integer height,
Integer colorDepth, String fileType)
{
super();
this.original = original;
this.width = width;
this.height = height;
this.colorDepth = colorDepth;
this.fileType = fileType;
}
/**
* @return True if the format is the original format of the underlying image.
*/
public boolean isOriginal()
{
return original;
}
/**
* @return The width of the image.
*/
public Integer getWidth()
{
return width;
}
/**
* @return The height of the image.
*/
public Integer getHeight()
{
return height;
}
/**
* @return The number of bits of color of the image.
*/
public Integer getColorDepth()
{
return colorDepth;
}
/**
* @return The file type of the image.
*/
public String getFileType()
{
return fileType;
}
@Override
public int hashCode()
{
HashCodeBuilder builder = new HashCodeBuilder();
builder.append(original);
builder.append(width);
builder.append(height);
builder.append(colorDepth);
builder.append(fileType);
return builder.toHashCode();
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
ImageRepresentationFormat other = (ImageRepresentationFormat) obj;
EqualsBuilder builder = new EqualsBuilder();
builder.append(original, other.original);
builder.append(width, other.width);
builder.append(height, other.height);
builder.append(colorDepth, other.colorDepth);
builder.append(fileType, other.fileType);
return builder.isEquals();
}
@Override
public String toString()
{
ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
builder.append(original);
builder.append(width);
builder.append(height);
builder.append(colorDepth);
builder.append(fileType);
return builder.toString();
}
}
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