Skip to content
Snippets Groups Projects
Commit e76e2c64 authored by tpylak's avatar tpylak
Browse files

SE-187 LMC: change BDS to allow symbolic links to original data

SVN: 14484
parent e40d67b5
No related merge requests found
......@@ -165,8 +165,7 @@ public class Format implements IStorable
}
/**
* Returns the <code>IFormatParameterFactory</code> implementation for this
* <code>Format</code>.
* Returns the <code>IFormatParameterFactory</code> implementation for this <code>Format</code>.
*/
public IFormatParameterFactory getFormatParameterFactory()
{
......@@ -180,7 +179,18 @@ public class Format implements IStorable
* returns an empty list.
* </p>
*/
public List<String> getParameterNames()
public List<String> getMandatoryParameterNames()
{
return Collections.emptyList();
}
/**
* Returns an unmodifiable list of optional parameters that are specific to this format.
* <p>
* Default implementation returns an empty list.
* </p>
*/
public List<String> getOptionalParameterNames()
{
return Collections.emptyList();
}
......
......@@ -66,7 +66,7 @@ public interface IFormatParameterFactory
* Creates a <code>FormatParameter</code> from given <var>value</var>.
*
* @param name name of the format parameter. Usually it is one of the values returned by
* {@link Format#getParameterNames()}.
* {@link Format#getMandatoryParameterNames()}.
* @param value generic value that should help to construct the <code>FormatParameter</code>.
* @return <code>null</code> if no appropriate <code>FormatParameter</code> could be created
* from given <code>value</code>.
......
......@@ -77,12 +77,19 @@ public final class FormatParameterFactory implements IFormatParameterFactory
.parseInt(value));
} else if (nodeName.equals(HCSImageFormatV1_0.CONTAINS_ORIGINAL_DATA))
{
return new FormatParameter(HCSImageFormatV1_0.CONTAINS_ORIGINAL_DATA, Utilities.Boolean
.fromString(value));
return createBooleanParameter(HCSImageFormatV1_0.CONTAINS_ORIGINAL_DATA, value);
} else if (nodeName.equals(HCSImageFormatV1_0.IS_INCOMING_SYMBOLIC_LINK))
{
return createBooleanParameter(HCSImageFormatV1_0.IS_INCOMING_SYMBOLIC_LINK, value);
}
return formatParameter;
}
private static FormatParameter createBooleanParameter(String name, String value)
{
return new FormatParameter(name, Utilities.Boolean.fromString(value));
}
public final FormatParameter createFormatParameter(final String name, final String value)
{
if (name.equals(PlateGeometry.PLATE_GEOMETRY))
......@@ -103,6 +110,9 @@ public final class FormatParameterFactory implements IFormatParameterFactory
{
return new FormatParameter(name, Integer.parseInt(value));
} else if (name.equals(HCSImageFormatV1_0.CONTAINS_ORIGINAL_DATA))
{
return new FormatParameter(name, Utilities.Boolean.fromString(value));
} else if (name.equals(HCSImageFormatV1_0.IS_INCOMING_SYMBOLIC_LINK))
{
return new FormatParameter(name, Utilities.Boolean.fromString(value));
}
......
......@@ -45,6 +45,13 @@ public final class HCSImageFormatV1_0 extends Format
*/
public final static String NUMBER_OF_CHANNELS = "number_of_channels";
/**
* Boolean flag specifying whether the items in the incoming folder are just a symbolic links to
* the original data. In this case we do not move any data. Instead we create symbolic link to
* original data which points to the same place as the link in incoming directory.
*/
public final static String IS_INCOMING_SYMBOLIC_LINK = "incoming_items_are_symbolic_link";
/**
* The format parameters that must be defined so that this implementation is able to work
* properly.
......@@ -52,9 +59,12 @@ public final class HCSImageFormatV1_0 extends Format
* These parameters are located in <code>metadata/parameters</code>.
* </p>
*/
private final static String[] FORMAT_PARAMETERS = new String[]
private final static String[] MANDATORY_FORMAT_PARAMETERS = new String[]
{ WellGeometry.WELL_GEOMETRY, NUMBER_OF_CHANNELS, CONTAINS_ORIGINAL_DATA };
private final static String[] OPTIONAL_FORMAT_PARAMETERS = new String[]
{ IS_INCOMING_SYMBOLIC_LINK };
/**
* The one and only one instance.
*/
......@@ -70,9 +80,15 @@ public final class HCSImageFormatV1_0 extends Format
//
@Override
public final List<String> getParameterNames()
public final List<String> getMandatoryParameterNames()
{
return Arrays.asList(MANDATORY_FORMAT_PARAMETERS);
}
@Override
public List<String> getOptionalParameterNames()
{
return Arrays.asList(FORMAT_PARAMETERS);
return Arrays.asList(OPTIONAL_FORMAT_PARAMETERS);
}
@Override
......
......@@ -56,6 +56,9 @@ public final class HCSImageFormattedData extends AbstractFormattedData implement
private final boolean containsOriginalData;
/** see {@link HCSImageFormatV1_0#IS_INCOMING_SYMBOLIC_LINK} */
private final boolean isIncomingSymbolicLink;
private final Geometry wellGeometry;
private final Geometry plateGeometry;
......@@ -72,7 +75,8 @@ public final class HCSImageFormattedData extends AbstractFormattedData implement
public HCSImageFormattedData(final FormattedDataContext context)
{
super(context);
this.containsOriginalData = figureContainsOriginalData(getFormatParameters());
IFormatParameters formatParameters = getFormatParameters();
this.containsOriginalData = figureContainsOriginalData(formatParameters);
if (containsOriginalData)
{
this.originalDataDirectoryOrNull =
......@@ -81,15 +85,16 @@ public final class HCSImageFormattedData extends AbstractFormattedData implement
{
this.originalDataDirectoryOrNull = null;
}
this.isIncomingSymbolicLink = figureIsIncomingSymbolicLink(formatParameters);
IDirectory standardDataDirectory =
Utilities.getSubDirectory(dataDirectory, DataStructureV1_0.DIR_STANDARD);
this.standardDataDirectoryCache =
new DirectoryContentCache(standardDataDirectory, createChannelDirNameProvider());
this.wellGeometry = figureWellGeometry(getFormatParameters());
this.plateGeometry = figurePlateGeometry(getFormatParameters());
this.channelCount = figureChannelCount(getFormatParameters());
this.wellGeometry = figureWellGeometry(formatParameters);
this.plateGeometry = figurePlateGeometry(formatParameters);
this.channelCount = figureChannelCount(formatParameters);
}
private static int figureChannelCount(IFormatParameters params)
......@@ -113,11 +118,29 @@ public final class HCSImageFormattedData extends AbstractFormattedData implement
.toBoolean();
}
private static boolean figureIsIncomingSymbolicLink(IFormatParameters params)
{
String paramName = HCSImageFormatV1_0.IS_INCOMING_SYMBOLIC_LINK;
if (params.containsParameter(paramName))
{
return ((Utilities.Boolean) params.getValue(paramName)).toBoolean();
} else
{
return false; // default value
}
}
public final boolean containsOriginalData()
{
return containsOriginalData;
}
/** see {@link HCSImageFormatV1_0#IS_INCOMING_SYMBOLIC_LINK} */
public final boolean isIncomingSymbolicLink()
{
return isIncomingSymbolicLink;
}
public final Geometry getWellGeometry()
{
return wellGeometry;
......@@ -489,7 +512,7 @@ public final class HCSImageFormattedData extends AbstractFormattedData implement
super.assertValidFormatAndFormatParameters();
final IFormatParameters formatParameters = getFormatParameters();
final Set<String> notPresent = new HashSet<String>();
for (final String formatParameterName : format.getParameterNames())
for (final String formatParameterName : format.getMandatoryParameterNames())
{
if (formatParameters.containsParameter(formatParameterName) == false)
{
......
......@@ -35,12 +35,15 @@ public interface IHCSImageFormattedData extends IFormattedData
* Returns <code>true</code> if the data structure contains the original data.
*/
public boolean containsOriginalData();
/** see {@link HCSImageFormatV1_0#IS_INCOMING_SYMBOLIC_LINK} */
public boolean isIncomingSymbolicLink();
/**
* Returns the number of channels.
*/
public int getChannelCount();
/**
* Returns the geometric arrangement of the tiles of a well.
*/
......@@ -51,11 +54,9 @@ public interface IHCSImageFormattedData extends IFormattedData
*/
public Geometry getPlateGeometry();
/**
* For given <var>channel</var>, given <var>wellLocation</var> and given <var>tileLocation</var>
* returns the corresponding <code>INode</code> (found in <code>data/standard</code>
* directory).
* returns the corresponding <code>INode</code> (found in <code>data/standard</code> directory).
*
* @return this could be, for instance, a {@link ILink} pointing to the
* <code>data/original</code> directory or a {@link IFile} that can be extracted
......@@ -71,15 +72,14 @@ public interface IHCSImageFormattedData extends IFormattedData
* incoming data set directory.
* @param imageRelativePath relative path (to <var>imageRootDirectory</var>) name of the image
* file that is going to be added in the <code>standard</code> directory.
* @return the new <code>INode</code> just added (encapsulated in returned
* <code>NodePath</code>) with its path in the <code>standard</code> directory.
* Never returns <code>null</code>.
* @return the new <code>INode</code> just added (encapsulated in returned <code>NodePath</code>
* ) with its path in the <code>standard</code> directory. Never returns
* <code>null</code>.
* @throws DataStructureException if a node already exists at given coordinates.
*/
public NodePath addStandardNode(final File imageRootDirectory, final String imageRelativePath,
final int channel, final Location wellLocation, final Location tileLocation)
throws DataStructureException;
//
// Helper classes
......
......@@ -16,7 +16,6 @@
package ch.systemsx.cisd.bds.storage;
import java.io.File;
import java.util.List;
/**
......@@ -73,10 +72,7 @@ public interface IDirectory extends INode, Iterable<INode>
* {@link IDirectory} if <code>file</code> is a folder, or {@link IFile} if
* <code>file</code> is a plain file.
*/
// TODO 2007-12-03, Tomasz Pylak review: this generic interface should not use java.io.File. Is
// the 'move' parameter possible to implement in HDF5? Maybe those operations should be done
// before, depending on the implementation which is used?
public INode addFile(final File file, final String nameOrNull, final boolean move);
public INode addFile(final java.io.File file, final String nameOrNull, final boolean move);
/**
* Removes given <var>node</var> from this directory.
......
......@@ -94,7 +94,7 @@ public class HCSImageFormattedDataTest extends AbstractFileSystemTestCase
context.checking(new Expectations()
{
{
for (final String formatParameterName : format.getParameterNames())
for (final String formatParameterName : format.getMandatoryParameterNames())
{
one(formatParameters).containsParameter(formatParameterName);
will(returnValue(true));
......
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