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

LMS-1632 Renamed new classes to match old names to avoid requiring a change in...

LMS-1632 Renamed new classes to match old names to avoid requiring a change in the service.properties.

SVN: 17408
parent 0b7fa819
No related branches found
No related tags found
No related merge requests found
......@@ -112,7 +112,7 @@ default-plate-image-analysis.properties-file =
plate-image-analysis-graph.label = Image Analysis Graphs
plate-image-analysis-graph.dataset-types = HCS_IMAGE_ANALYSIS_DATA, HCS_ANALYSIS_PER_GENE
plate-image-analysis-graph.class = ch.systemsx.cisd.openbis.dss.generic.server.plugins.DatabaseImageAnalysisGraphReportingPlugin
plate-image-analysis-graph.class = ch.systemsx.cisd.openbis.dss.generic.server.plugins.ImageAnalysisGraphReportingPlugin
plate-image-analysis-graph.servlet-path = datastore_server_graph/
plate-image-analysis-graph.properties-file = etc/tabular-data-graph.properties
......@@ -128,7 +128,7 @@ screening-image-download-servlet.class = ch.systemsx.cisd.openbis.dss.generic.se
# URL which will be mapped to this servlet
screening-image-download-servlet.path = /datastore_server_screening/*
tabular-data-graph-servlet.class = ch.systemsx.cisd.openbis.dss.generic.server.ImagingDataGraphServlet
tabular-data-graph-servlet.class = ch.systemsx.cisd.openbis.dss.generic.server.TabularDataGraphServlet
tabular-data-graph-servlet.path = /datastore_server_graph/*
tabular-data-graph-servlet.properties-file = etc/tabular-data-graph.properties
......
......@@ -106,7 +106,7 @@ default-plate-image-analysis.properties-file =
plate-image-analysis-graph.label = Image Analysis Graphs
plate-image-analysis-graph.dataset-types = HCS_IMAGE_ANALYSIS_DATA, HCS_ANALYSIS_PER_GENE
plate-image-analysis-graph.class = ch.systemsx.cisd.openbis.dss.generic.server.plugins.DatabaseImageAnalysisGraphReportingPlugin
plate-image-analysis-graph.class = ch.systemsx.cisd.openbis.dss.generic.server.plugins.ImageAnalysisGraphReportingPlugin
plate-image-analysis-graph.servlet-path = datastore_server_graph/
plate-image-analysis-graph.properties-file = etc/tabular-data-graph.properties
......@@ -122,7 +122,7 @@ screening-image-download-servlet.class = ch.systemsx.cisd.openbis.dss.generic.se
# URL which will be mapped to this servlet
screening-image-download-servlet.path = /datastore_server_screening/*
tabular-data-graph-servlet.class = ch.systemsx.cisd.openbis.dss.generic.server.ImagingDataGraphServlet
tabular-data-graph-servlet.class = ch.systemsx.cisd.openbis.dss.generic.server.TabularDataGraphServlet
tabular-data-graph-servlet.path = /datastore_server_graph/*
tabular-data-graph-servlet.properties-file = etc/tabular-data-graph.properties
......
/*
* 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.dss.generic.server;
import java.io.File;
import java.io.IOException;
import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ITabularData;
import ch.systemsx.cisd.utils.CsvFileReaderHelper;
/**
* @author Chandrasekhar Ramakrishnan
*/
public class FileTabularDataGraphServlet extends AbstractTabularDataGraphServlet
{
private static final long serialVersionUID = 1L;
/**
* Return the tabular data from a file as a DatasetFileLines.
*/
@Override
protected ITabularData getDatasetLines(String dataSetCode, String pathOrNull)
throws IOException
{
if (pathOrNull == null)
{
throw new UserFailureException("No value for the parameter " + FILE_PATH_PARAM
+ " found in the URL");
}
return CsvFileReaderHelper.getDatasetFileLines(new File(pathOrNull), configuration);
}
}
/*
* 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.dss.generic.server;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ITabularData;
import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService;
import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider;
import ch.systemsx.cisd.openbis.dss.shared.DssScreeningUtils;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.WellPosition;
import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.PlateUtils;
import ch.systemsx.cisd.openbis.plugin.screening.shared.imaging.dataaccess.IImagingQueryDAO;
/**
* Create a graph from the imaging database.
* <p>
* TODO 2010-08-09, CR, LMS-1692, This implementation is inefficient. The better way to implement
* this would be to lazily get feature vectors necessary for generating the graph, not to egerly get
* all feature vectors.
*
* @author Chandrasekhar Ramakrishnan
*/
public class ImagingDataGraphServlet extends AbstractTabularDataGraphServlet
{
private static final long serialVersionUID = 1L;
private IImagingQueryDAO imagingDbDao;
private IEncapsulatedOpenBISService openBisService;
/**
* An CSV-file-like interface to feature data from the database.
*
* @author Chandrasekhar Ramakrishnan
*/
private final class ImagingTabularData implements ITabularData
{
private static final String WELL_NAME_COLUMN = "WellName";
private static final String WELL_ROW_COLUMN = "Row";
private static final String WELL_COLUMN_COLUMN = "Column";
private final IImagingQueryDAO dao;
private final IEncapsulatedOpenBISService service;
private final String dataSetCode;
private String[] headerTokens;
private ArrayList<String[]> lines;
private ImagingTabularData(IImagingQueryDAO dao, IEncapsulatedOpenBISService service,
String dataSetCode)
{
this.dao = dao;
this.service = service;
this.dataSetCode = dataSetCode;
initialize();
}
private void initialize()
{
final FeatureTableBuilder tableBuilder = new FeatureTableBuilder(dao, service);
tableBuilder.addFeatureVectorsOfDataSet(dataSetCode);
List<String> featureNames = tableBuilder.getFeatureNames();
int headerTokensLength = featureNames.size() + 3;
headerTokens = new String[headerTokensLength];
headerTokens[0] = WELL_NAME_COLUMN;
headerTokens[1] = WELL_ROW_COLUMN;
headerTokens[2] = WELL_COLUMN_COLUMN;
int i = 1;
for (String name : featureNames)
{
headerTokens[i++] = name;
}
lines = new ArrayList<String[]>();
final List<FeatureTableRow> rows = tableBuilder.createFeatureTableRows();
for (FeatureTableRow row : rows)
{
String[] line = new String[headerTokensLength];
WellPosition pos = row.getWellPosition();
String rowLetter = PlateUtils.translateRowNumberIntoLetterCode(pos.getWellRow());
String columnNumber = Integer.toString(row.getWellPosition().getWellColumn());
line[0] = rowLetter + columnNumber;
line[1] = rowLetter;
line[2] = columnNumber;
i = 1;
float[] values = row.getFeatureValues();
for (float value : values)
{
line[i++] = Float.toString(value);
}
lines.add(line);
}
// final ImgDatasetDTO dataSet = dao.tryGetDatasetByPermId(dataSetCode);
// if (dataSet == null)
// {
// throw new UserFailureException("Unkown data set " + dataSetCode);
// }
//
// final List<ImgFeatureDefDTO> featureDefinitions =
// dao.listFeatureDefsByDataSetId(dataSet.getId());
//
// int headersLength = featureDefinitions.size();
// headerTokens = new String[headersLength];
// lines = new ArrayList<String[]>();
// int featureDefCount = 0;
// for (ImgFeatureDefDTO featureDefinition : featureDefinitions)
// {
// headerTokens[featureDefCount++] = featureDefinition.getName();
// }
// int numRows = dataSet.getFieldNumberOfRows();
// int numCols = dataSet.getFieldNumberOfColumns();
// for (int row = 0; row < numRows; ++row)
// {
// for (int col = 0; col < numCols; ++col)
// {
// for (ImgFeatureDefDTO featureDefinition : featureDefinitions)
// {
// List<ImgFeatureValuesDTO> featureValues =
// dao.getFeatureValues(featureDefinition);
// }
// }
// }
}
public List<String[]> getDataLines()
{
return lines;
}
public String[] getHeaderTokens()
{
return headerTokens;
}
}
@Override
protected ITabularData getDatasetLines(String dataSetCode, String filePathOrNull)
throws IOException
{
return new ImagingTabularData(getDAO(), getService(), dataSetCode);
}
private IImagingQueryDAO getDAO()
{
synchronized (this)
{
if (imagingDbDao == null)
{
imagingDbDao = DssScreeningUtils.createQuery();
}
}
return imagingDbDao;
}
private IEncapsulatedOpenBISService getService()
{
synchronized (this)
{
if (openBisService == null)
{
openBisService = ServiceProvider.getOpenBISService();
}
}
return openBisService;
}
}
......@@ -16,32 +16,179 @@
package ch.systemsx.cisd.openbis.dss.generic.server;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ITabularData;
import ch.systemsx.cisd.utils.CsvFileReaderHelper;
import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService;
import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider;
import ch.systemsx.cisd.openbis.dss.shared.DssScreeningUtils;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.WellPosition;
import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.PlateUtils;
import ch.systemsx.cisd.openbis.plugin.screening.shared.imaging.dataaccess.IImagingQueryDAO;
/**
* Create a graph from the imaging database.
* <p>
* TODO 2010-08-09, CR, LMS-1692, This implementation is inefficient. The better way to implement
* this would be to lazily get feature vectors necessary for generating the graph, not to egerly get
* all feature vectors.
*
* @author Chandrasekhar Ramakrishnan
*/
public class TabularDataGraphServlet extends AbstractTabularDataGraphServlet
{
private static final long serialVersionUID = 1L;
private IImagingQueryDAO imagingDbDao;
private IEncapsulatedOpenBISService openBisService;
/**
* Return the tabular data from a file as a DatasetFileLines.
* An CSV-file-like interface to feature data from the database.
*
* @author Chandrasekhar Ramakrishnan
*/
private final class ImagingTabularData implements ITabularData
{
private static final String WELL_NAME_COLUMN = "WellName";
private static final String WELL_ROW_COLUMN = "Row";
private static final String WELL_COLUMN_COLUMN = "Column";
private final IImagingQueryDAO dao;
private final IEncapsulatedOpenBISService service;
private final String dataSetCode;
private String[] headerTokens;
private ArrayList<String[]> lines;
private ImagingTabularData(IImagingQueryDAO dao, IEncapsulatedOpenBISService service,
String dataSetCode)
{
this.dao = dao;
this.service = service;
this.dataSetCode = dataSetCode;
initialize();
}
private void initialize()
{
final FeatureTableBuilder tableBuilder = new FeatureTableBuilder(dao, service);
tableBuilder.addFeatureVectorsOfDataSet(dataSetCode);
List<String> featureNames = tableBuilder.getFeatureNames();
int headerTokensLength = featureNames.size() + 3;
headerTokens = new String[headerTokensLength];
headerTokens[0] = WELL_NAME_COLUMN;
headerTokens[1] = WELL_ROW_COLUMN;
headerTokens[2] = WELL_COLUMN_COLUMN;
int i = 1;
for (String name : featureNames)
{
headerTokens[i++] = name;
}
lines = new ArrayList<String[]>();
final List<FeatureTableRow> rows = tableBuilder.createFeatureTableRows();
for (FeatureTableRow row : rows)
{
String[] line = new String[headerTokensLength];
WellPosition pos = row.getWellPosition();
String rowLetter = PlateUtils.translateRowNumberIntoLetterCode(pos.getWellRow());
String columnNumber = Integer.toString(row.getWellPosition().getWellColumn());
line[0] = rowLetter + columnNumber;
line[1] = rowLetter;
line[2] = columnNumber;
i = 1;
float[] values = row.getFeatureValues();
for (float value : values)
{
line[i++] = Float.toString(value);
}
lines.add(line);
}
// final ImgDatasetDTO dataSet = dao.tryGetDatasetByPermId(dataSetCode);
// if (dataSet == null)
// {
// throw new UserFailureException("Unkown data set " + dataSetCode);
// }
//
// final List<ImgFeatureDefDTO> featureDefinitions =
// dao.listFeatureDefsByDataSetId(dataSet.getId());
//
// int headersLength = featureDefinitions.size();
// headerTokens = new String[headersLength];
// lines = new ArrayList<String[]>();
// int featureDefCount = 0;
// for (ImgFeatureDefDTO featureDefinition : featureDefinitions)
// {
// headerTokens[featureDefCount++] = featureDefinition.getName();
// }
// int numRows = dataSet.getFieldNumberOfRows();
// int numCols = dataSet.getFieldNumberOfColumns();
// for (int row = 0; row < numRows; ++row)
// {
// for (int col = 0; col < numCols; ++col)
// {
// for (ImgFeatureDefDTO featureDefinition : featureDefinitions)
// {
// List<ImgFeatureValuesDTO> featureValues =
// dao.getFeatureValues(featureDefinition);
// }
// }
// }
}
public List<String[]> getDataLines()
{
return lines;
}
public String[] getHeaderTokens()
{
return headerTokens;
}
}
@Override
protected ITabularData getDatasetLines(String dataSetCode, String pathOrNull)
protected ITabularData getDatasetLines(String dataSetCode, String filePathOrNull)
throws IOException
{
if (pathOrNull == null)
return new ImagingTabularData(getDAO(), getService(), dataSetCode);
}
private IImagingQueryDAO getDAO()
{
synchronized (this)
{
throw new UserFailureException("No value for the parameter " + FILE_PATH_PARAM
+ " found in the URL");
if (imagingDbDao == null)
{
imagingDbDao = DssScreeningUtils.createQuery();
}
}
return CsvFileReaderHelper.getDatasetFileLines(new File(pathOrNull), configuration);
return imagingDbDao;
}
private IEncapsulatedOpenBISService getService()
{
synchronized (this)
{
if (openBisService == null)
{
openBisService = ServiceProvider.getOpenBISService();
}
}
return openBisService;
}
}
......@@ -37,7 +37,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription;
* Reporting plugin that returns a table in which each column contains a graph. The number and
* format of the graphs can be configured in a properties file.
* <p>
* This plugin reads data from a file. The {@link DatabaseImageAnalysisGraphReportingPlugin} reads
* This plugin reads data from a file. The {@link ImageAnalysisGraphReportingPlugin} reads
* from the imaging db.
*
* @author Chandrasekhar Ramakrishnan
......@@ -63,7 +63,7 @@ public class FileBasedImageAnalysisGraphReportingPlugin extends AbstractDataMerg
if (propertiesFilePath == null)
{
throw new EnvironmentFailureException(
"DatabaseImageAnalysisGraphReportingPlugin requires a properties file (specified with the "
"ImageAnalysisGraphReportingPlugin requires a properties file (specified with the "
+ PROPERTIES_FILE_KEY + "key).");
}
......
......@@ -41,7 +41,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription;
*
* @author Chandrasekhar Ramakrishnan
*/
public class DatabaseImageAnalysisGraphReportingPlugin extends AbstractDataMergingReportingPlugin
public class ImageAnalysisGraphReportingPlugin extends AbstractDataMergingReportingPlugin
{
private static final long serialVersionUID = 1L;
......@@ -54,7 +54,7 @@ public class DatabaseImageAnalysisGraphReportingPlugin extends AbstractDataMergi
private final static String PROPERTIES_FILE_KEY = "properties-file";
public DatabaseImageAnalysisGraphReportingPlugin(Properties properties, File storeRoot)
public ImageAnalysisGraphReportingPlugin(Properties properties, File storeRoot)
{
super(properties, storeRoot, SEMICOLON_SEPARATOR);
graphServletPath = properties.getProperty(SERVLET_PATH_PROP, "datastore_server_graph/");
......@@ -62,7 +62,7 @@ public class DatabaseImageAnalysisGraphReportingPlugin extends AbstractDataMergi
if (propertiesFilePath == null)
{
throw new EnvironmentFailureException(
"DatabaseImageAnalysisGraphReportingPlugin requires a properties file (specified with the "
"ImageAnalysisGraphReportingPlugin requires a properties file (specified with the "
+ PROPERTIES_FILE_KEY + "key).");
}
......
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