From 2e80016e5cf7ef81fdc8b52b5fba6ec2d9c2accb Mon Sep 17 00:00:00 2001 From: brinn <brinn> Date: Mon, 2 May 2011 19:26:19 +0000 Subject: [PATCH] remove: deprecated class BDSStorageProcessor and test SVN: 21099 --- .../cisd/etlserver/BDSStorageProcessor.java | 660 ------------------ .../etlserver/BDSStorageProcessorTest.java | 615 ---------------- 2 files changed, 1275 deletions(-) delete mode 100644 datastore_server/source/java/ch/systemsx/cisd/etlserver/BDSStorageProcessor.java delete mode 100644 datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/BDSStorageProcessorTest.java diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/BDSStorageProcessor.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/BDSStorageProcessor.java deleted file mode 100644 index 2a0236e64f6..00000000000 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/BDSStorageProcessor.java +++ /dev/null @@ -1,660 +0,0 @@ -/* - * Copyright 2007 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.etlserver; - -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.time.DurationFormatUtils; -import org.apache.log4j.Logger; - -import ch.systemsx.cisd.bds.Constants; -import ch.systemsx.cisd.bds.DataSet; -import ch.systemsx.cisd.bds.DataStructureFactory; -import ch.systemsx.cisd.bds.DataStructureLoader; -import ch.systemsx.cisd.bds.ExperimentRegistrationTimestamp; -import ch.systemsx.cisd.bds.ExperimentRegistrator; -import ch.systemsx.cisd.bds.Format; -import ch.systemsx.cisd.bds.FormatParameter; -import ch.systemsx.cisd.bds.IDataStructure.Mode; -import ch.systemsx.cisd.bds.IFormatParameterFactory; -import ch.systemsx.cisd.bds.IFormattedData; -import ch.systemsx.cisd.bds.Reference; -import ch.systemsx.cisd.bds.ReferenceType; -import ch.systemsx.cisd.bds.Sample; -import ch.systemsx.cisd.bds.UnknownFormatV1_0; -import ch.systemsx.cisd.bds.Version; -import ch.systemsx.cisd.bds.hcs.Geometry; -import ch.systemsx.cisd.bds.hcs.HCSImageAnnotations; -import ch.systemsx.cisd.bds.hcs.IHCSImageFormattedData; -import ch.systemsx.cisd.bds.hcs.IHCSImageFormattedData.NodePath; -import ch.systemsx.cisd.bds.hcs.Location; -import ch.systemsx.cisd.bds.hcs.PlateGeometry; -import ch.systemsx.cisd.bds.storage.IDirectory; -import ch.systemsx.cisd.bds.storage.IFile; -import ch.systemsx.cisd.bds.storage.ILink; -import ch.systemsx.cisd.bds.storage.INode; -import ch.systemsx.cisd.bds.storage.filesystem.FileStorage; -import ch.systemsx.cisd.bds.storage.filesystem.NodeFactory; -import ch.systemsx.cisd.bds.v1_1.ExperimentIdentifierWithUUID; -import ch.systemsx.cisd.bds.v1_1.IDataStructureV1_1; -import ch.systemsx.cisd.bds.v1_1.SampleWithOwner; -import ch.systemsx.cisd.common.collections.CollectionUtils; -import ch.systemsx.cisd.common.exceptions.ConfigurationFailureException; -import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; -import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.systemsx.cisd.common.filesystem.FileOperations; -import ch.systemsx.cisd.common.filesystem.FileUtilities; -import ch.systemsx.cisd.common.filesystem.IFileOperations; -import ch.systemsx.cisd.common.logging.LogCategory; -import ch.systemsx.cisd.common.logging.LogFactory; -import ch.systemsx.cisd.common.mail.IMailClient; -import ch.systemsx.cisd.common.utilities.ClassUtils; -import ch.systemsx.cisd.etlserver.HCSImageCheckList.FullLocation; -import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetInformation; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Person; -import ch.systemsx.cisd.openbis.generic.shared.dto.StorageFormat; - -/** - * The <code>AbstractStorageAdapter</code> extension for <i>BDS</i> (Biological Data Standards). - * <p> - * When declared in <code>service.properties</code> file, it must specify a property called - * <code>storage-adapter.version</code>. Otherwise instantiation will fail. - * </p> - * - * @author Christian Ribeaud - */ -// TODO 2010-07-28, Tomasz Pylak: remove this class -@Deprecated -public final class BDSStorageProcessor extends AbstractStorageProcessor -{ - - private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, - BDSStorageProcessor.class); - - private static final Logger notificationLog = LogFactory.getLogger(LogCategory.OPERATION, - BDSStorageProcessor.class); - - private static final String PROPERTY_PREFIX = "Property '%s': "; - - private static final String NO_FORMAT_FORMAT = PROPERTY_PREFIX - + "no valid and known format could be extracted from text '%s'."; - - static final String VERSION_KEY = "version"; - - static final String SAMPLE_TYPE_DESCRIPTION_KEY = "sampleTypeDescription"; - - static final String SAMPLE_TYPE_CODE_KEY = "sampleTypeCode"; - - static final String FORMAT_KEY = "format"; - - static final String FILE_EXTRACTOR_KEY = "file-extractor"; - - static final String NO_VERSION_FORMAT = PROPERTY_PREFIX - + "no version could be extracted from text '%s'."; - - private final Format format; - - private final String sampleTypeCode; - - private final String sampleTypeDescription; - - private final IHCSImageFileExtractor imageFileExtractor; - - private final Version version; - - private final List<FormatParameter> formatParameters; - - // candidates - private IDataStructureV1_1 dataStructure; - - private IHCSImageFormattedData imageFormattedData; - - public BDSStorageProcessor(final Properties properties) - { - super(properties); - version = parseVersion(getMandatoryProperty(VERSION_KEY)); - if (version.equals(new Version(1, 1)) == false) - { - throw new ConfigurationFailureException("Invalid version: " + version); - } - format = parseFormat(getMandatoryProperty(FORMAT_KEY)); - formatParameters = createFormatParameters(); - sampleTypeDescription = getMandatoryProperty(SAMPLE_TYPE_DESCRIPTION_KEY); - if (needsImageFileExtractor()) - { - final String property = getMandatoryProperty(FILE_EXTRACTOR_KEY); - imageFileExtractor = - ClassUtils.create(IHCSImageFileExtractor.class, property, properties); - } else - { - imageFileExtractor = null; - } - try - { - sampleTypeCode = getMandatoryProperty(SAMPLE_TYPE_CODE_KEY); - } catch (final IllegalArgumentException ex) - { - throw new ConfigurationFailureException(ex.getMessage()); - } - } - - private List<FormatParameter> createFormatParameters() - { - final IFormatParameterFactory formatParameterFactory = format.getFormatParameterFactory(); - List<FormatParameter> result = new ArrayList<FormatParameter>(); - for (final String parameterName : format.getMandatoryParameterNames()) - { - final String value = properties.getProperty(parameterName); - if (value == null) - { - throw ConfigurationFailureException.fromTemplate( - "No value has been defined for parameter '%s'", parameterName); - } - FormatParameter parameter = - createFormatParameter(formatParameterFactory, parameterName, value); - result.add(parameter); - } - for (final String parameterName : format.getOptionalParameterNames()) - { - final String value = properties.getProperty(parameterName); - if (value != null) - { - FormatParameter parameter = - createFormatParameter(formatParameterFactory, parameterName, value); - result.add(parameter); - } - } - return result; - } - - private FormatParameter createFormatParameter( - final IFormatParameterFactory formatParameterFactory, final String parameterName, - final String value) - { - final FormatParameter formatParameter = - formatParameterFactory.createFormatParameter(parameterName, value); - if (formatParameter == null) - { - throw ConfigurationFailureException.fromTemplate( - "Given value '%s' is not understandable for parameter '%s'", value, - parameterName); - } - return formatParameter; - } - - final static Version parseVersion(final String versionString) - { - final Version version = Version.createVersionFromString(versionString); - if (version == null) - { - throw ConfigurationFailureException.fromTemplate(NO_VERSION_FORMAT, VERSION_KEY, - versionString); - } - return version; - } - - final static Format parseFormat(final String formatString) - { - final Format format = Format.tryToCreateFormatFromString(formatString); - if (format == null) - { - throw ConfigurationFailureException.fromTemplate(NO_FORMAT_FORMAT, FORMAT_KEY, - formatString); - } - return format; - } - - private final ExperimentIdentifierWithUUID createExperimentIdentifier( - final DataSetInformation dataSetInformation) - { - final ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifier experimentIdentifier = - dataSetInformation.getExperimentIdentifier(); - final String projectCode = experimentIdentifier.getProjectCode(); - final String experimentCode = experimentIdentifier.getExperimentCode(); - final String spaceCode = experimentIdentifier.getSpaceCode(); - final String instanceCode = dataSetInformation.getInstanceCode(); - return new ExperimentIdentifierWithUUID(instanceCode, dataSetInformation.getInstanceUUID(), - spaceCode, projectCode, experimentCode); - } - - private final static void checkDataSetInformation(final DataSetInformation dataSetInformation) - { - assert dataSetInformation != null : "Unspecified data set information"; - assert dataSetInformation.getSampleIdentifier() != null : "Unspecified sample identifier"; - final ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifier experimentIdentifier = - dataSetInformation.getExperimentIdentifier(); - assert experimentIdentifier != null : "Unspecified experiment identifier"; - checkExperimentIdentifier(experimentIdentifier); - } - - private final static void checkExperimentIdentifier( - final ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifier experimentIdentifier) - { - assert experimentIdentifier.getSpaceCode() != null : "Space code is null"; - assert experimentIdentifier.getExperimentCode() != null : "Experiment code is null"; - assert experimentIdentifier.getProjectCode() != null : "Project code is null"; - } - - private final IDataStructureV1_1 createDataStructure(final Experiment experiment, - final DataSetInformation dataSetInformation, final ITypeExtractor typeExtractor, - final File incomingDataSetPath, final File rootDir) - { - final FileStorage storage = new FileStorage(rootDir); - final IDataStructureV1_1 structure = - (IDataStructureV1_1) DataStructureFactory.createDataStructure(storage, version); - - List<FormatParameter> parameters = new ArrayList<FormatParameter>(formatParameters); - final Geometry plateGeometry = getPlateGeometry(dataSetInformation); - parameters.add(new FormatParameter(PlateGeometry.PLATE_GEOMETRY, plateGeometry)); - - structure.create(parameters); - structure.setFormat(format); - structure.setExperimentIdentifier(createExperimentIdentifier(dataSetInformation)); - structure.setExperimentRegistrationTimestamp(new ExperimentRegistrationTimestamp(experiment - .getRegistrationDate())); - final Person registrator = experiment.getRegistrator(); - final String firstName = registrator.getFirstName(); - final String lastName = registrator.getLastName(); - final String email = registrator.getEmail(); - structure.setExperimentRegistrator(new ExperimentRegistrator(firstName, lastName, email)); - structure.setSample(createSample(dataSetInformation)); - structure.setDataSet(createDataSet(dataSetInformation, typeExtractor, incomingDataSetPath)); - - return structure; - } - - private Geometry getPlateGeometry(final DataSetInformation dataSetInformation) - { - final IEntityProperty[] sampleProperties = dataSetInformation.getProperties(); - final PlateDimension plateDimension = - PlateDimensionParser.tryToGetPlateDimension(sampleProperties); - if (plateDimension == null) - { - throw new EnvironmentFailureException( - "Missing plate geometry for the plate registered for sample identifier '" - + dataSetInformation.getSampleIdentifier() + "'."); - } - final Geometry plateGeometry = - new PlateGeometry(plateDimension.getRowsNum(), plateDimension.getColsNum()); - return plateGeometry; - } - - private final Sample createSample(final DataSetInformation dataSetInformation) - { - final String spaceCode = StringUtils.defaultString(dataSetInformation.getSpaceCode()); - final String instanceCode = dataSetInformation.getInstanceCode(); - final String instanceUUID = dataSetInformation.getInstanceUUID(); - assert instanceCode != null : "Unspecified database instance code"; - assert instanceUUID != null : "Unspecified database instance UUID"; - // TODO 2009-09-15, Tomasz Pylak: deal with the case when sample is null - return new SampleWithOwner(dataSetInformation.getSampleCode(), sampleTypeCode, - sampleTypeDescription, instanceUUID, instanceCode, spaceCode); - } - - private final static DataSet createDataSet(final DataSetInformation dataSetInformation, - final ITypeExtractor typeExtractor, final File incomingDataSetPath) - { - final String dataSetCode = dataSetInformation.getDataSetCode(); - final List<String> parentCodes = - new ArrayList<String>(dataSetInformation.getParentDataSetCodes()); - final boolean isMeasured = typeExtractor.isMeasuredData(incomingDataSetPath); - final DataSetType dataSetType = typeExtractor.getDataSetType(incomingDataSetPath); - final DataSet dataSet = - new DataSet(dataSetCode, dataSetType.getCode(), - ch.systemsx.cisd.bds.Utilities.Boolean.fromBoolean(isMeasured), - dataSetInformation.getProductionDate(), - dataSetInformation.getProducerCode(), parentCodes); - return dataSet; - } - - private final static String getPathOf(final INode node) - { - final StringBuilder builder = new StringBuilder(node.getName()); - IDirectory parent = node.tryGetParent(); - while (parent != null) - { - builder.insert(0, '/'); - builder.insert(0, parent.getName()); - parent = parent.tryGetParent(); - } - return builder.toString(); - } - - private final boolean needsImageFileExtractor() - { - return format.getCode().equals(UnknownFormatV1_0.UNKNOWN_1_0.getCode()) == false; - } - - // - // AbstractStorageProcessor - // - public IStorageProcessorTransaction createTransaction() - { - return new BDSStorageProcessorTransaction(); - } - - @Override - public final StorageFormat getStorageFormat() - { - return StorageFormat.BDS_DIRECTORY; - } - - private final class BDSStorageProcessorTransaction extends AbstractStorageProcessorTransaction - implements IHCSImageFileAccepter - { - private File imageFileRootDirectory; - - private File dataStructureDir; - - private HCSImageCheckList imageCheckList; - - @Override - protected File storeData(DataSetInformation dataSetInformation, - ITypeExtractor typeExtractor, IMailClient mailClient) - { - checkDataSetInformation(dataSetInformation); - assert rootDirectory != null : "Root directory can not be null."; - assert incomingDataSetDirectory != null : "Incoming data set directory can not be null."; - assert typeExtractor != null : "Unspecified IProcedureAndDataTypeExtractor implementation."; - - dataStructureDir = rootDirectory; - dataStructureDir.mkdirs(); - Experiment experiment = dataSetInformation.tryToGetExperiment(); - if (experiment == null) - { - throw new UserFailureException("Experiment unknown for data set " - + dataSetInformation); - } - dataStructure = - createDataStructure(experiment, dataSetInformation, typeExtractor, - incomingDataSetDirectory, dataStructureDir); - final IFormattedData formattedData = dataStructure.getFormattedData(); - if (formattedData instanceof IHCSImageFormattedData) - { - imageFormattedData = (IHCSImageFormattedData) formattedData; - final int channels = imageFormattedData.getChannelCount(); - final Geometry plateGeometry = imageFormattedData.getPlateGeometry(); - final Geometry wellGeometry = imageFormattedData.getWellGeometry(); - imageCheckList = new HCSImageCheckList(channels, plateGeometry, wellGeometry); - } - if (needsImageFileExtractor()) - { - imageFileRootDirectory = incomingDataSetDirectory; - final HCSImageFileExtractionResult result = - imageFileExtractor.process( - NodeFactory.createDirectoryNode(incomingDataSetDirectory), - dataSetInformation, this); - if (operationLog.isInfoEnabled()) - { - operationLog.info(String.format("Extraction of %d files took %s.", - result.getTotalFiles(), - DurationFormatUtils.formatDurationHMS(result.getDuration()))); - } - if (result.getInvalidFiles().size() > 0) - { - throw UserFailureException.fromTemplate( - "Following invalid files %s have been found.", - CollectionUtils.abbreviate(result.getInvalidFiles(), 10)); - } - if (result.getTotalFiles() == 0) - { - throw UserFailureException.fromTemplate( - "No extractable files were found inside a dataset '%s'." - + " Have you changed your naming convention?", - incomingDataSetDirectory.getAbsolutePath()); - } - dataStructure.setAnnotations(new HCSImageAnnotations(result.getChannels())); - checkCompleteness(dataSetInformation, incomingDataSetDirectory.getName(), - mailClient); - } else - { - if (imageFormattedData != null && imageFormattedData.isIncomingSymbolicLink()) - { - ILink symbolicLink = - NodeFactory.createSymbolicLinkNode(incomingDataSetDirectory); - dataStructure.getOriginalData().tryAddLink(symbolicLink.getName(), - symbolicLink.getReference()); - - } else - { - dataStructure.getOriginalData().addFile(incomingDataSetDirectory, null, true); - } - if (operationLog.isInfoEnabled()) - { - operationLog.info(String.format("File '%s' added to original data.", - incomingDataSetDirectory)); - } - } - dataStructure.close(); - return dataStructureDir; - } - - @Override - protected UnstoreDataAction executeRollback(Throwable ex) - { - unstoreData(); - return getDefaultUnstoreDataAction(ex); - } - - @Override - protected void executeCommit() - { - // no commit logic - } - - // Although this check should be performed in the BDS library when closing is - // performed, we set - // the complete flag here as we want to inform the registrator about the - // incompleteness. - private void checkCompleteness(final DataSetInformation dataSetInformation, - final String dataSetFileName, final IMailClient mailClientOrNull) - { - final List<FullLocation> fullLocations = imageCheckList.getCheckedOnFullLocations(); - final boolean complete = fullLocations.size() == 0; - final IDataStructureV1_1 thisStructure = getDataStructure(dataStructureDir); - final DataSet dataSet = thisStructure.getDataSet(); - dataSet.setComplete(complete); - thisStructure.setDataSet(dataSet); - dataSetInformation.setComplete(complete); - if (complete == false) - { - final String message = - String.format("Incomplete data set '%s': %d image file(s) " - + "are missing (locations: %s)", dataSetFileName, - fullLocations.size(), CollectionUtils.abbreviate(fullLocations, 10)); - operationLog.warn(message); - if (mailClientOrNull != null) - { - final ExperimentRegistrator registrator = - thisStructure.getExperimentRegistrator(); - final String email = registrator.getEmail(); - if (StringUtils.isBlank(email) == false) - { - try - { - mailClientOrNull.sendMessage("Incomplete data set '" + dataSetFileName - + "'", message, null, null, email); - } catch (final EnvironmentFailureException e) - { - notificationLog.error("Couldn't send the following e-mail to '" + email - + "': " + message, e); - } - } else - { - notificationLog - .error("Unspecified e-mail address of experiment registrator " - + registrator); - } - } - } - } - - private final void unstoreData() - { - checkParameters(incomingDataSetDirectory, dataStructureDir); - - if (dataStructure == null) - { - // Nothing to do here. - return; - } - final IDirectory originalData = getDataStructure(dataStructureDir).getOriginalData(); - final INode node = originalData.tryGetNode(incomingDataSetDirectory.getName()); - // If the 'incoming' data have been moved to 'original' directory. This only - // happens if - // 'containsOriginalData' returns 'true'. - if (node != null) - { - final File incomingDirectory = incomingDataSetDirectory.getParentFile(); - try - { - node.moveTo(incomingDirectory); - if (operationLog.isInfoEnabled()) - { - operationLog.info(String.format( - "Node '%s' has moved to incoming directory '%s'.", node, - incomingDirectory.getAbsolutePath())); - } - } catch (final EnvironmentFailureException ex) - { - notificationLog.error(String.format( - "Could not move '%s' to incoming directory '%s'.", node, - incomingDirectory.getAbsolutePath()), ex); - return; - } - } - final IFileOperations fileOps = FileOperations.getMonitoredInstanceForCurrentThread(); - if (fileOps.exists(incomingDataSetDirectory)) - { - if (dataStructureDir != null - && fileOps.removeRecursivelyQueueing(dataStructureDir) == false) - { - operationLog.error("Cannot delete '" + dataStructureDir.getAbsolutePath() - + "'."); - } - } else - { - notificationLog.error(String.format("Incoming data set directory '%s' does not " - + "exist, keeping store directory '%s'.", incomingDataSetDirectory, - storedDataDirectory)); - } - } - - public final void accept(final int channel, final Location wellLocation, - final Location tileLocation, final IFile imageFile) - { - assert imageFileRootDirectory != null : "Incoming data set directory has not been set."; - final String imageRelativePath = - FileUtilities.getRelativeFile(imageFileRootDirectory, - new File(imageFile.getPath())); - assert imageRelativePath != null : "Image relative path should not be null."; - final NodePath nodePath = - imageFormattedData.addStandardNode(imageFileRootDirectory, imageRelativePath, - channel, wellLocation, tileLocation); - imageCheckList.checkOff(channel, wellLocation, tileLocation); - if (nodePath.getNode() instanceof ILink) - { - // We made a link in the 'standard' directory to the 'original' directory - // image file - // name. The image file did not change during the operation. - final Reference reference = - new Reference(nodePath.getPath(), imageFileRootDirectory.getName() - + Constants.PATH_SEPARATOR + imageRelativePath, - ReferenceType.IDENTICAL); - getDataStructure(dataStructureDir).addReference(reference); - } - } - - /** - * For given <var>directory</var> returns the {@link IDataStructureV1_1}. - * <p> - * In ideal case returns internally saved <code>dataStructureDir</code> but when given - * <var>storedDataDirectory</var> changed (meaning no longer equal to storage root), then we - * have to reload the data structure. - * </p> - */ - private final IDataStructureV1_1 getDataStructure(File directory) - { - final IDataStructureV1_1 thisStructure; - if (directory.equals(dataStructureDir) == false) - { - final DataStructureLoader dataStructureLoader = - new DataStructureLoader(directory.getParentFile()); - thisStructure = - (IDataStructureV1_1) dataStructureLoader.load(directory.getName(), true); - } else - { - thisStructure = dataStructure; - if (thisStructure.isOpenOrCreated() == false) - { - thisStructure.open(Mode.READ_ONLY); - } - } - return thisStructure; - } - - public final File tryGetProprietaryData() - { - assert storedDataDirectory != null : "Unspecified stored data directory."; - if (dataStructure == null) - { - operationLog.error("No data structure defined."); - return null; - } - if (imageFormattedData != null) - { - if (imageFormattedData.containsOriginalData() == false) - { - operationLog.warn("Original data are not available."); - return null; - } - } - final IDataStructureV1_1 thisStructure = getDataStructure(storedDataDirectory); - final IDirectory originalData = thisStructure.getOriginalData(); - final Iterator<INode> iterator = originalData.iterator(); - if (iterator.hasNext() == false) - { - return null; - } - final INode node = iterator.next(); - final String path = getPathOf(node); - final File originalDataFile = new File(path); - if (originalDataFile.exists() == false) - { - operationLog.error("Original data set file '" + originalDataFile.getAbsolutePath() - + "' does not exist."); - return null; - } - return originalDataFile; - } - - } - - @Override - public UnstoreDataAction getDefaultUnstoreDataAction(Throwable exception) - { - return UnstoreDataAction.MOVE_TO_ERROR; - } -} diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/BDSStorageProcessorTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/BDSStorageProcessorTest.java deleted file mode 100644 index 3c2b6d54041..00000000000 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/BDSStorageProcessorTest.java +++ /dev/null @@ -1,615 +0,0 @@ -/* - * Copyright 2007 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.etlserver; - -import java.io.File; -import java.io.IOException; -import java.sql.Date; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Properties; - -import org.apache.log4j.Level; -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import ch.rinn.restrictions.Friend; -import ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase; -import ch.systemsx.cisd.bds.DataSet; -import ch.systemsx.cisd.bds.DataStructureLoader; -import ch.systemsx.cisd.bds.ExperimentRegistrator; -import ch.systemsx.cisd.bds.Format; -import ch.systemsx.cisd.bds.IDataStructure; -import ch.systemsx.cisd.bds.Sample; -import ch.systemsx.cisd.bds.UnknownFormatV1_0; -import ch.systemsx.cisd.bds.Utilities; -import ch.systemsx.cisd.bds.Utilities.Boolean; -import ch.systemsx.cisd.bds.Version; -import ch.systemsx.cisd.bds.hcs.Channel; -import ch.systemsx.cisd.bds.hcs.HCSImageFormatV1_0; -import ch.systemsx.cisd.bds.hcs.Location; -import ch.systemsx.cisd.bds.hcs.WellGeometry; -import ch.systemsx.cisd.bds.storage.IDirectory; -import ch.systemsx.cisd.bds.storage.IFile; -import ch.systemsx.cisd.bds.v1_1.IDataStructureV1_1; -import ch.systemsx.cisd.common.exceptions.ConfigurationFailureException; -import ch.systemsx.cisd.common.filesystem.FileUtilities; -import ch.systemsx.cisd.common.filesystem.QueueingPathRemoverService; -import ch.systemsx.cisd.common.filesystem.SoftLinkMaker; -import ch.systemsx.cisd.common.logging.BufferedAppender; -import ch.systemsx.cisd.common.mail.IMailClient; -import ch.systemsx.cisd.common.types.BooleanOrUnknown; -import ch.systemsx.cisd.etlserver.IStorageProcessorTransactional.IStorageProcessorTransaction; -import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetInformation; -import ch.systemsx.cisd.openbis.dss.generic.shared.utils.DssPropertyParametersUtil; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataTypeCode; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityProperty; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Person; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Project; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleTypePropertyType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space; -import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifier; - -/** - * Test cases for corresponding {@link BDSStorageProcessor} class. - * - * @author Christian Ribeaud - */ -// TODO 2010-07-28, Tomasz Pylak: remove this class -@Deprecated -@Friend(toClasses = DssPropertyParametersUtil.class) -public final class BDSStorageProcessorTest extends AbstractFileSystemTestCase -{ - private static final String EXAMPLE_EMAIL = "j@d"; - - private static final String DATA_SET_CODE = "D"; - - private static final String INCOMING_DATA_SET_DIR = "NEMO.EXP1==CP001A-3AB"; - - private static final String EXAMPLE_TYPE_DESCRIPTION = "Screening Plate"; - - private static final Date REGISTRATION_DATE = new Date(47110000); - - private static final String EXAMPLE_INSTANCE = "I"; - - private static final String EXAMPLE_INSTANCE_GLOBAL = "222-333"; - - private static final String EXAMPLE_SPACE = "G"; - - private static final String DATA_STRUCTURE_NAME = "originalData"; - - private static final String EXAMPLE_DATA = "hello world!"; - - private static final String ORIGINAL_DATA_TXT = DATA_STRUCTURE_NAME + ".txt"; - - private static final String VERSION_PROPERTY_KEY = BDSStorageProcessor.VERSION_KEY; - - private static final String FORMAT_KEY = BDSStorageProcessor.FORMAT_KEY; - - private static final String SAMPLE_TYPE_DESCRIPTION_KEY = - BDSStorageProcessor.SAMPLE_TYPE_DESCRIPTION_KEY; - - private static final String SAMPLE_TYPE_CODE_KEY = - - BDSStorageProcessor.SAMPLE_TYPE_CODE_KEY; - - private static final String CHANNEL_COUNT_KEY = HCSImageFormatV1_0.NUMBER_OF_CHANNELS; - - private static final String CONTAINS_ORIGINAL_DATA_KEY = - HCSImageFormatV1_0.CONTAINS_ORIGINAL_DATA; - - private static final String WELL_GEOMETRY_KEY = WellGeometry.WELL_GEOMETRY; - - private static final String FILE_EXTRACTOR_KEY = IHCSImageFileExtractor.FILE_EXTRACTOR; - - private final static ITypeExtractor TYPE_EXTRACTOR = - new DefaultStorageProcessorTest.TestProcedureAndDataTypeExtractor(); - - private final static String STORE_ROOT_DIR = "store"; - - private BufferedAppender logRecorder; - - private Mockery context; - - private IMailClient mailClient; - - private final static Properties createProperties(final Format format) - { - final Properties props = createPropertiesWithVersion(); - props.setProperty(DssPropertyParametersUtil.STOREROOT_DIR_KEY, "store"); - props.setProperty(SAMPLE_TYPE_DESCRIPTION_KEY, EXAMPLE_TYPE_DESCRIPTION); - props.setProperty(SAMPLE_TYPE_CODE_KEY, "CELL_PLATE"); - props.setProperty(FORMAT_KEY, format.getCode() + " " + format.getVersion()); - props.setProperty(CHANNEL_COUNT_KEY, "1"); - props.setProperty(CONTAINS_ORIGINAL_DATA_KEY, Utilities.Boolean.TRUE.toString()); - props.setProperty(WELL_GEOMETRY_KEY, "3x3"); - props.setProperty(FILE_EXTRACTOR_KEY, TestImageFileExtractor.class.getName()); - return props; - } - - final static DataSetInformation createDataSetInformation() - { - final DataSetInformation dataSetInformation = new DataSetInformation(); - dataSetInformation.setInstanceCode(EXAMPLE_INSTANCE); - dataSetInformation.setInstanceUUID(EXAMPLE_INSTANCE_GLOBAL); - final ExperimentIdentifier experimentIdentifier = new ExperimentIdentifier(); - experimentIdentifier.setExperimentCode("E"); - experimentIdentifier.setProjectCode("P"); - experimentIdentifier.setSpaceCode(EXAMPLE_SPACE); - dataSetInformation.setExperimentIdentifier(experimentIdentifier); - dataSetInformation.setSampleCode("S"); - dataSetInformation.setDataSetCode(DATA_SET_CODE); - final IEntityProperty plateGeometry = - createSampleProperty(PlateDimensionParser.PLATE_GEOMETRY_PROPERTY_NAME, - DataTypeCode.VARCHAR, "_16X24"); - dataSetInformation.setProperties(new IEntityProperty[] - { plateGeometry }); - return dataSetInformation; - } - - private final static IEntityProperty createSampleProperty(final String code, - final DataTypeCode dataType, final String value) - { - final IEntityProperty property = new EntityProperty(); - final SampleTypePropertyType entityTypePropertyType = new SampleTypePropertyType(); - final PropertyType propertyType = new PropertyType(); - propertyType.setCode(code); - propertyType.setLabel(code); - final DataType type = new DataType(); - type.setCode(dataType); - propertyType.setDataType(type); - entityTypePropertyType.setPropertyType(propertyType); - property.setPropertyType(propertyType); - property.setValue(value); - return property; - } - - private final File createOriginalDataInDir() throws IOException - { - final File dir = createDirInIncoming(INCOMING_DATA_SET_DIR); - final File originalData = new File(dir, ORIGINAL_DATA_TXT); - FileUtilities.writeToFile(originalData, EXAMPLE_DATA); - return dir; - } - - private File createDirInIncoming(String incomingItemName) - { - final File incoming = getIncomingDir(); - final File dir = new File(incoming, incomingItemName); - dir.mkdir(); - return dir; - } - - private File getIncomingDir() - { - final File incoming = new File(workingDirectory, "incoming"); - incoming.mkdir(); - return incoming; - } - - static final ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample createSample() - { - ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sample = - new ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample(); - sample.setExperiment(createExperiment()); - return sample; - } - - static final Experiment createExperiment() - { - final Experiment baseExperiment = new Experiment(); - baseExperiment.setRegistrationDate(REGISTRATION_DATE); - final Person person = new Person(); - person.setFirstName("Joe"); - person.setLastName("Doe"); - person.setEmail(EXAMPLE_EMAIL); - final Space space = new Space(); - space.setCode(EXAMPLE_SPACE); - final Project project = new Project(); - project.setSpace(space); - baseExperiment.setProject(project); - baseExperiment.setRegistrator(person); - return baseExperiment; - } - - private final static Properties createPropertiesWithVersion() - { - final Properties props = new Properties(); - props.setProperty(VERSION_PROPERTY_KEY, "1.1"); - return props; - } - - @BeforeClass - public void startQueueingPathRemover() - { - if (QueueingPathRemoverService.isRunning() == false) - { - QueueingPathRemoverService.start(); - } - } - - @Override - @BeforeMethod - public void setUp() throws IOException - { - try - { - super.setUp(); - } catch (AssertionError e) - { - super.setUp(); - } - logRecorder = new BufferedAppender("%-5p %c - %m%n", Level.INFO); - context = new Mockery(); - mailClient = context.mock(IMailClient.class); - } - - @AfterMethod - public void tearDown() - { - logRecorder.reset(); - // The following line of code should also be called at the end of each test method. - // Otherwise one do not known which test failed. - context.assertIsSatisfied(); - } - - @Test - public final void testConstructorWithUnspecifiedArgument() - { - boolean fail = true; - try - { - new BDSStorageProcessor(null); - } catch (final AssertionError ex) - { - fail = false; - } - assertFalse(fail); - } - - @Test - public final void testCheckVersionInProperties() - { - final Properties props = new Properties(); - props.setProperty(DssPropertyParametersUtil.STOREROOT_DIR_KEY, "store"); - final String version = "ae"; - props.setProperty(VERSION_PROPERTY_KEY, version); - try - { - new BDSStorageProcessor(props); - fail("No '.' in given version."); - } catch (final ConfigurationFailureException ex) - { - assertEquals(String.format(BDSStorageProcessor.NO_VERSION_FORMAT, - BDSStorageProcessor.VERSION_KEY, version), ex.getMessage()); - } - } - - @Test - public final void testCheckVersionCompatible() - { - final Properties props = new Properties(); - props.setProperty(DssPropertyParametersUtil.STOREROOT_DIR_KEY, "store"); - props.setProperty(VERSION_PROPERTY_KEY, "1.2"); - try - { - new BDSStorageProcessor(props); - fail("ConfigurationFailureException expected"); - } catch (final ConfigurationFailureException e) - { - assertEquals("Invalid version: V1.2", e.getMessage()); - } - } - - @Test - public final void testMissingFormat() throws Exception - { - final Properties props = createPropertiesWithVersion(); - try - { - new BDSStorageProcessor(props); - fail("ConfigurationFailureException expected"); - } catch (final ConfigurationFailureException e) - { - assertEquals("Given key 'format' not found in properties '[version]'", e.getMessage()); - } - } - - @Test - public final void testMissingSampleTypeDescription() throws Exception - { - final Properties props = createPropertiesWithVersion(); - final Format format = UnknownFormatV1_0.UNKNOWN_1_0; - props.setProperty(FORMAT_KEY, format.getCode() + " " + format.getVersion()); - try - { - new BDSStorageProcessor(props); - fail("ConfigurationFailureException expected"); - } catch (final ConfigurationFailureException e) - { - assertEquals("Given key 'sampleTypeDescription' not found in properties " - + "'[version, format]'", e.getMessage()); - } - } - - @Test - // we check the mode where the incoming folder has just a link to the real data. The original - // data folder in the store should point to this data (and not to the data in incoming folder) - public final void testStoreDataWithSymbolicLink() throws Exception - { - final Properties properties = createProperties(UnknownFormatV1_0.UNKNOWN_1_0); - properties.setProperty(HCSImageFormatV1_0.IS_INCOMING_SYMBOLIC_LINK, "true"); - final IStorageProcessorTransaction storageProcessor = createTransaction(properties); - - final File orgData = new File(workingDirectory, "org-data.txt"); - FileUtilities.writeToFile(orgData, "hello!"); - - final File incoming = getIncomingDir(); - SoftLinkMaker.createSymbolicLink(orgData, incoming); - - final ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample baseSample = createSample(); - final DataSetInformation dataSetInformation = createDataSetInformation(); - dataSetInformation.setSample(baseSample); - - storeData(storageProcessor, new File(incoming, orgData.getName()), dataSetInformation); - File datasetOriginalDir = new File(getStoreDir(), "data/original/" + orgData.getName()); - assertTrue("link to original file has not been created", datasetOriginalDir.isFile()); - String orgDataAbsPath = orgData.getAbsolutePath(); - String datasetOriginalDirReference = datasetOriginalDir.getCanonicalPath(); - assertEquals("link to original file does not point to the original data " + orgDataAbsPath - + ", but to " + datasetOriginalDirReference, datasetOriginalDirReference, - orgDataAbsPath); - } - - @DataProvider(name = "formatProvider") - public Object[][] getFormats() - { - return new Object[][] - { - { UnknownFormatV1_0.UNKNOWN_1_0 }, - { HCSImageFormatV1_0.HCS_IMAGE_1_0 } }; - } - - @Test(dataProvider = "formatProvider") - public final void testStoreData(final Format format) throws Exception - { - final Properties properties = createProperties(format); - final IStorageProcessorTransaction storageProcessor = createTransaction(properties); - assertEquals(0, workingDirectory.list().length); - final File incomingDataSetDirectory = createOriginalDataInDir(); - assertEquals(true, incomingDataSetDirectory.exists()); - final ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample baseSample = createSample(); - final DataSetInformation dataSetInformation = createDataSetInformation(); - dataSetInformation.setSample(baseSample); - prepareMailClient(format); - final File dataFile = - storeData(storageProcessor, incomingDataSetDirectory, dataSetInformation); - assertEquals(getStoreDir().getAbsolutePath(), dataFile.getAbsolutePath()); - final IDataStructure dataStructure = - new DataStructureLoader(workingDirectory).load(STORE_ROOT_DIR, true); - assertEquals(true, dataStructure instanceof IDataStructureV1_1); - final IDataStructureV1_1 ds = (IDataStructureV1_1) dataStructure; - assertEquals(new Version(1, 1), ds.getVersion()); - final ch.systemsx.cisd.bds.ExperimentIdentifier eid = ds.getExperimentIdentifier(); - assertEquals(EXAMPLE_INSTANCE, eid.getInstanceCode()); - assertEquals(EXAMPLE_SPACE, eid.getSpaceCode()); - assertEquals(dataSetInformation.getExperimentIdentifier().getProjectCode(), eid - .getProjectCode()); - assertEquals(dataSetInformation.getExperimentIdentifier().getExperimentCode(), eid - .getExperimentCode()); - final ExperimentRegistrator registrator = ds.getExperimentRegistrator(); - final Experiment baseExperiment = baseSample.getExperiment(); - assertEquals(baseExperiment.getRegistrator().getFirstName(), registrator.getFirstName()); - assertEquals(baseExperiment.getRegistrator().getLastName(), registrator.getLastName()); - assertEquals(baseExperiment.getRegistrator().getEmail(), registrator.getEmail()); - assertEquals(REGISTRATION_DATE, ds.getExperimentRegistratorTimestamp().getDate()); - final Sample sample = ds.getSample(); - assertEquals(EXAMPLE_TYPE_DESCRIPTION, sample.getTypeDescription()); - assertEquals(dataSetInformation.getSampleIdentifier().getSampleCode(), sample.getCode()); - final Format f = ds.getFormattedData().getFormat(); - assertEquals(format, f); - final IDirectory directory = - (IDirectory) ds.getOriginalData().tryGetNode(INCOMING_DATA_SET_DIR); - assertEquals(EXAMPLE_DATA, Utilities.getTrimmedString(directory, ORIGINAL_DATA_TXT)); - assertEquals(false, incomingDataSetDirectory.exists()); - // DataSet - final DataSet dataSet = ds.getDataSet(); - assertEquals(DATA_SET_CODE, dataSet.getCode()); - assertEquals(TYPE_EXTRACTOR.getDataSetType(null).getCode(), dataSet.getDataSetTypeCode()); - assertEquals(0, dataSet.getParentCodes().size()); - assertNull(dataSet.getProducerCode()); - assertNull(dataSet.getProductionTimestamp()); - assertEquals(Boolean.TRUE, dataSet.isMeasured()); - - context.assertIsSatisfied(); - } - - private File storeData(final IStorageProcessorTransaction transaction, - final File incomingDataSetDirectory, final DataSetInformation dataSetInformation) - { - transaction.storeData(dataSetInformation, TYPE_EXTRACTOR, mailClient, - incomingDataSetDirectory, getStoreDir()); - return transaction.getStoredDataDirectory(); - } - - private File getStoreDir() - { - return new File(workingDirectory, STORE_ROOT_DIR); - } - - @Test(dataProvider = "formatProvider") - public final void testUnstoreData(final Format format) throws Exception - { - final Properties properties = createProperties(format); - final IStorageProcessorTransaction transaction = createTransaction(properties); - - assertEquals(0, workingDirectory.list().length); - final File incomingDirectoryData = createOriginalDataInDir(); - // incoming/NEMO.EXP1==CP001A-3AB in 'workingDirectory' - assert incomingDirectoryData.exists(); - final ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample baseSample = createSample(); - final DataSetInformation dataSetInformation = createDataSetInformation(); - dataSetInformation.setSample(baseSample); - // NEMO.EXP1==CP001A-3AB in 'workingDirectory' - prepareMailClient(format); - final File storeRootDir = getStoreDir(); - transaction.storeData(dataSetInformation, TYPE_EXTRACTOR, mailClient, - incomingDirectoryData, storeRootDir); - File dataStore = transaction.getStoredDataDirectory(); - assertEquals(true, dataStore.isDirectory()); - assertEquals(false, incomingDirectoryData.exists()); - transaction.rollback(null); - assertEquals(false, dataStore.exists()); - assertEquals(true, incomingDirectoryData.isDirectory()); - - context.assertIsSatisfied(); - } - - private IStorageProcessorTransaction createTransaction(final Properties properties) - { - return new BDSStorageProcessor(properties).createTransaction(); - } - - @Test(dataProvider = "formatProvider") - public void testTryToGetOriginalData(final Format format) throws Exception - { - final Properties properties = createProperties(format); - final IStorageProcessorTransaction transaction = createTransaction(properties); - final File incomingDirectoryData = createOriginalDataInDir(); - final ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample baseSample = createSample(); - final DataSetInformation dataSetInformation = createDataSetInformation(); - dataSetInformation.setSample(baseSample); - prepareMailClient(format); - transaction.storeData(dataSetInformation, TYPE_EXTRACTOR, mailClient, - incomingDirectoryData, workingDirectory); - final File originalDataSet = transaction.tryGetProprietaryData(); - assertNotNull(originalDataSet); - assertEquals(INCOMING_DATA_SET_DIR, originalDataSet.getName()); - assertEquals(true, originalDataSet.isDirectory()); - assertEquals(format == UnknownFormatV1_0.UNKNOWN_1_0 ? BooleanOrUnknown.U - : BooleanOrUnknown.F, dataSetInformation.getIsCompleteFlag()); - final File[] files = originalDataSet.listFiles(); - assertEquals(1, files.length); - final File file = files[0]; - assertEquals(true, file.exists()); - assertEquals(false, file.isDirectory()); - assertEquals(ORIGINAL_DATA_TXT, file.getName()); - - context.assertIsSatisfied(); - } - - @Test - public void testTryToGetOriginalDataWhichAreNotAvailable() throws Exception - { - final Properties properties = createProperties(HCSImageFormatV1_0.HCS_IMAGE_1_0); - properties.setProperty(CONTAINS_ORIGINAL_DATA_KEY, Utilities.Boolean.FALSE.toString()); - final IStorageProcessorTransaction transaction = createTransaction(properties); - final File incomingDirectoryData = createOriginalDataInDir(); - final ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample baseSample = createSample(); - final DataSetInformation dataSetInformation = createDataSetInformation(); - dataSetInformation.setSample(baseSample); - prepareMailClient(HCSImageFormatV1_0.HCS_IMAGE_1_0); - transaction.storeData(dataSetInformation, TYPE_EXTRACTOR, mailClient, - incomingDirectoryData, workingDirectory); - logRecorder.resetLogContent(); - final File originalDataSet = transaction.tryGetProprietaryData(); - assertEquals(null, originalDataSet); - assertEquals("WARN OPERATION.BDSStorageProcessor - " + "Original data are not available.", - logRecorder.getLogContent()); - - context.assertIsSatisfied(); - } - - @Test - public void testConstructorWithInvalidFormat() throws Exception - { - final Properties properties = createProperties(new Format("bla", new Version(1, 2), "v")); - try - { - new BDSStorageProcessor(properties); - fail("ConfigurationFailureException expected"); - } catch (final ConfigurationFailureException e) - { - assertEquals("Property 'format': no valid and known format could be extracted " - + "from text 'bla V1.2'.", e.getMessage()); - } - } - - private void prepareMailClient(final Format format) - { - if (format != UnknownFormatV1_0.UNKNOWN_1_0) - { - context.checking(new Expectations() - { - { - one(mailClient) - .sendMessage( - "Incomplete data set 'NEMO.EXP1==CP001A-3AB'", - "Incomplete data set 'NEMO.EXP1==CP001A-3AB': " - + "3455 image file(s) are missing (locations: " - + "[[well=[x=16,y=1],tile=[x=3,y=3]], [well=[x=16,y=2],tile=[x=2,y=3]], " - + "[well=[x=16,y=3],tile=[x=1,y=3]], [well=[x=24,y=10],tile=[x=1,y=3]], " - + "[well=[x=24,y=9],tile=[x=2,y=3]], [well=[x=24,y=8],tile=[x=3,y=3]], " - + "[well=[x=7,y=6],tile=[x=1,y=2]], [well=[x=7,y=5],tile=[x=2,y=2]], " - + "[well=[x=7,y=4],tile=[x=3,y=2]], [well=[x=14,y=6],tile=[x=3,y=1]], " - + "... (3445 left)])", null, null, EXAMPLE_EMAIL); - } - }); - } - } - - // - // Helper classes - // - - public final static class TestImageFileExtractor implements IHCSImageFileExtractor - { - - public TestImageFileExtractor(final Properties properties) - { - } - - // - // IHCSImageFileExtractor - // - - public final HCSImageFileExtractionResult process( - final IDirectory incomingDataSetDirectory, - final DataSetInformation dataSetInformation, final IHCSImageFileAccepter accepter) - { - assertEquals(INCOMING_DATA_SET_DIR, incomingDataSetDirectory.getName()); - final List<IFile> listFiles = incomingDataSetDirectory.listFiles(null, true); - assertEquals(1, listFiles.size()); - final IFile file = listFiles.get(0); - assertEquals(ORIGINAL_DATA_TXT, file.getName()); - accepter.accept(1, new Location(1, 1), new Location(1, 1), file); - return new HCSImageFileExtractionResult(0, listFiles.size(), new ArrayList<IFile>(), - Collections.singleton(new Channel(1, 123))); - } - } - -} -- GitLab