diff --git a/bds/source/java/ch/systemsx/cisd/bds/AbstractDataStructure.java b/bds/source/java/ch/systemsx/cisd/bds/AbstractDataStructure.java index 48a917329dafaec87ff32ffe9443d5ea01928558..0e8f1c9c0ca168b028613c2c0089c4ad7d1fd5ee 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/AbstractDataStructure.java +++ b/bds/source/java/ch/systemsx/cisd/bds/AbstractDataStructure.java @@ -16,6 +16,8 @@ package ch.systemsx.cisd.bds; +import ch.systemsx.cisd.bds.storage.IDirectory; +import ch.systemsx.cisd.bds.storage.IStorage; import ch.systemsx.cisd.common.exceptions.UserFailureException; /** diff --git a/bds/source/java/ch/systemsx/cisd/bds/Container.java b/bds/source/java/ch/systemsx/cisd/bds/Container.java new file mode 100644 index 0000000000000000000000000000000000000000..d161d843fa0f06ed5ae2047171cd14bc5e498299 --- /dev/null +++ b/bds/source/java/ch/systemsx/cisd/bds/Container.java @@ -0,0 +1,70 @@ +/* + * 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.bds; + +import java.io.File; + +import ch.systemsx.cisd.bds.storage.IStorage; +import ch.systemsx.cisd.bds.storage.filesystem.FileStorage; +import ch.systemsx.cisd.bds.storage.hdf5.HDF5Storage; +import ch.systemsx.cisd.common.exceptions.UserFailureException; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class Container +{ + private final File baseDir; + + public Container(File baseDir) + { + assert baseDir != null : "Unspecified base directory."; + assert baseDir.isDirectory() : "Is not a directory : " + baseDir.getAbsolutePath(); + this.baseDir = baseDir; + } + + public AbstractDataStructure load(String name) + { + IStorage storage = createStorage(name); + storage.load(); + Version version = Version.loadFrom(storage.getRoot()); + return DataStructureFactory.createDataStructure(storage, version); + } + + private IStorage createStorage(String name) + { + File file = new File(baseDir, name); + if (file.exists() == false) + { + throw new UserFailureException("No container name '" + name + "' exists in " + baseDir.getAbsolutePath()); + } + if (file.isDirectory()) + { + return new FileStorage(file); + } + File hdf5File = new File(baseDir, name + ".hdf5"); + if (hdf5File.exists()) + { + return new HDF5Storage(hdf5File); + } + throw new UserFailureException("Couldn't found appropriate container named '" + name + "' in " + + baseDir.getAbsolutePath()); + + } +} diff --git a/bds/source/java/ch/systemsx/cisd/bds/DataStructureFactory.java b/bds/source/java/ch/systemsx/cisd/bds/DataStructureFactory.java index b039165e2e4d17ae62f32c5cd58f8cb925283843..9a3c2d56438e47f2347c1f5cef0d91a6bf6dfbca 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/DataStructureFactory.java +++ b/bds/source/java/ch/systemsx/cisd/bds/DataStructureFactory.java @@ -21,6 +21,7 @@ import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; +import ch.systemsx.cisd.bds.storage.IStorage; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException; diff --git a/bds/source/java/ch/systemsx/cisd/bds/DataStructureV1_0.java b/bds/source/java/ch/systemsx/cisd/bds/DataStructureV1_0.java index bbbfa6a4f98544976699123dae3ed5d68437bbb2..97139abbe4d12bf480bbe05056a187d595b1238b 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/DataStructureV1_0.java +++ b/bds/source/java/ch/systemsx/cisd/bds/DataStructureV1_0.java @@ -16,6 +16,9 @@ package ch.systemsx.cisd.bds; +import ch.systemsx.cisd.bds.storage.IDirectory; +import ch.systemsx.cisd.bds.storage.IStorage; + /** * diff --git a/bds/source/java/ch/systemsx/cisd/bds/ExperimentIdentifier.java b/bds/source/java/ch/systemsx/cisd/bds/ExperimentIdentifier.java index 73c4353f586726cdb4fd37359ba24a7e8104078b..53e3a16ce6b8d8aafc74df11334198d93d0449e1 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/ExperimentIdentifier.java +++ b/bds/source/java/ch/systemsx/cisd/bds/ExperimentIdentifier.java @@ -16,6 +16,8 @@ package ch.systemsx.cisd.bds; +import ch.systemsx.cisd.bds.storage.IDirectory; + /** * Identifier of the experiment which corresponds to the data. This is an immutable but extendable value object class. * An instance of this class allows unique identification in the database. diff --git a/bds/source/java/ch/systemsx/cisd/bds/IDataStructureV1_0.java b/bds/source/java/ch/systemsx/cisd/bds/IDataStructureV1_0.java index 82219390b36901eda5cbed101254083b8bcb162c..2a6eb2643a1dcdab0a387c361bd5eb8333d0dd6e 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/IDataStructureV1_0.java +++ b/bds/source/java/ch/systemsx/cisd/bds/IDataStructureV1_0.java @@ -16,6 +16,8 @@ package ch.systemsx.cisd.bds; +import ch.systemsx.cisd.bds.storage.IDirectory; + /** * Data structure interface for Version 1.0. * diff --git a/bds/source/java/ch/systemsx/cisd/bds/ProcessingType.java b/bds/source/java/ch/systemsx/cisd/bds/ProcessingType.java index 6717aff94faff53b928941feda9f52e9f1dff846..c84a55cb218ae36406b3c6cb023828a6197e1bd6 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/ProcessingType.java +++ b/bds/source/java/ch/systemsx/cisd/bds/ProcessingType.java @@ -16,6 +16,8 @@ package ch.systemsx.cisd.bds; +import ch.systemsx.cisd.bds.storage.IDirectory; + /** * Enumeration of processing types. diff --git a/bds/source/java/ch/systemsx/cisd/bds/Utilities.java b/bds/source/java/ch/systemsx/cisd/bds/Utilities.java index a352ebc55ad3d9f2b40c8b57cc5ebc9b7f5ce617..fff492ed4639b13adfc92226e8e0f7586eceaa27 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/Utilities.java +++ b/bds/source/java/ch/systemsx/cisd/bds/Utilities.java @@ -16,6 +16,9 @@ package ch.systemsx.cisd.bds; +import ch.systemsx.cisd.bds.storage.IDirectory; +import ch.systemsx.cisd.bds.storage.IFile; +import ch.systemsx.cisd.bds.storage.INode; import ch.systemsx.cisd.common.exceptions.UserFailureException; /** diff --git a/bds/source/java/ch/systemsx/cisd/bds/Version.java b/bds/source/java/ch/systemsx/cisd/bds/Version.java index 4bc6052125efa968d0dd6e211c6893205c6fa1c5..0770d4e4e48b5c6c0def65e2e38422dafb20e2be 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/Version.java +++ b/bds/source/java/ch/systemsx/cisd/bds/Version.java @@ -16,6 +16,7 @@ package ch.systemsx.cisd.bds; +import ch.systemsx.cisd.bds.storage.IDirectory; import ch.systemsx.cisd.common.exceptions.UserFailureException; /** diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/IDirectory.java b/bds/source/java/ch/systemsx/cisd/bds/storage/IDirectory.java new file mode 100644 index 0000000000000000000000000000000000000000..98c493481acfde313b49ee24f5934ebe671e1aa1 --- /dev/null +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/IDirectory.java @@ -0,0 +1,39 @@ +/* + * 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.bds.storage; + +import java.io.File; + +/** + * + * + * @author Franz-Josef Elmer + */ +public interface IDirectory extends INode, Iterable<INode> +{ + public INode getNode(String name); + + public IDirectory appendDirectory(String name); + + public void appendNode(INode node); + + public void appendRealFile(File file); + + public void appendKeyValuePair(String key, String value); + + public void appendLink(String name, INode node); +} diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/IFile.java b/bds/source/java/ch/systemsx/cisd/bds/storage/IFile.java new file mode 100644 index 0000000000000000000000000000000000000000..c657dcbb2d422445390c6c2fabe94ac48a96c9d3 --- /dev/null +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/IFile.java @@ -0,0 +1,30 @@ +/* + * 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.bds.storage; + +/** + * Role of a file with a value (content) of type <code>T</code>. + * + * @author Franz-Josef Elmer + */ +public interface IFile<T> extends INode +{ + /** + * Returns the value (or content) of this file node. + */ + public T getValue(); +} diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/ILink.java b/bds/source/java/ch/systemsx/cisd/bds/storage/ILink.java new file mode 100644 index 0000000000000000000000000000000000000000..c533b230cb2100540b96b9423c76b26c3c5ed7a5 --- /dev/null +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/ILink.java @@ -0,0 +1,27 @@ +/* + * 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.bds.storage; + +/** + * + * + * @author Franz-Josef Elmer + */ +public interface ILink extends INode +{ + public INode getReference(); +} diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/INode.java b/bds/source/java/ch/systemsx/cisd/bds/storage/INode.java new file mode 100644 index 0000000000000000000000000000000000000000..42cf6ca8943308ff5b585936432aa55027608339 --- /dev/null +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/INode.java @@ -0,0 +1,49 @@ +/* + * 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.bds.storage; + +import java.io.File; + +import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; +import ch.systemsx.cisd.common.exceptions.UserFailureException; + +/** + * Role of a node in the data structure. + * + * @author Franz-Josef Elmer + */ +public interface INode +{ + /** + * Returns the name of this node. + */ + public String getName(); + + /** + * Returns the parent directory of this node or <code>null</code> if it is the root node. + */ + public IDirectory tryToGetParent(); + + /** + * Extracts this node to the specified directory of the file system. All descendants are also extracted. + * + * @throws UserFailureException if this or a descended node is a link referring to a node which is not this + * node or a descended node. + * @throws EnvironmentFailureException if extraction causes an IOException. + */ + public void extractTo(File directory) throws UserFailureException, EnvironmentFailureException; +} diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/IStorage.java b/bds/source/java/ch/systemsx/cisd/bds/storage/IStorage.java new file mode 100644 index 0000000000000000000000000000000000000000..b02fd16a11c6885d65633e11f15c17fdc5c14097 --- /dev/null +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/IStorage.java @@ -0,0 +1,31 @@ +/* + * 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.bds.storage; + +/** + * + * + * @author Franz-Josef Elmer + */ +public interface IStorage +{ + public void load(); + + public IDirectory getRoot(); + + public void save(); +} diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/AbstractNode.java b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/AbstractNode.java new file mode 100644 index 0000000000000000000000000000000000000000..80c8e52c16a88585bad2b74d0404998675ba9040 --- /dev/null +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/AbstractNode.java @@ -0,0 +1,50 @@ +/* + * 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.bds.storage.filesystem; + +import java.io.File; + +import ch.systemsx.cisd.bds.storage.IDirectory; +import ch.systemsx.cisd.bds.storage.INode; + +/** + * + * + * @author Franz-Josef Elmer + */ +abstract class AbstractNode implements INode +{ + protected final File fileNode; + + AbstractNode(File file) + { + assert file != null : "Unspecified file"; + this.fileNode = file; + } + + public String getName() + { + return fileNode.getName(); + } + + public IDirectory tryToGetParent() + { + File dir = fileNode.getParentFile(); + return dir == null ? null : new Directory(dir); + } + +} diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Directory.java b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Directory.java new file mode 100644 index 0000000000000000000000000000000000000000..d59a75491c048c589f6c88a7898d6814af0fa5b7 --- /dev/null +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Directory.java @@ -0,0 +1,103 @@ +/* + * 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.bds.storage.filesystem; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Iterator; + +import ch.systemsx.cisd.bds.storage.IDirectory; +import ch.systemsx.cisd.bds.storage.INode; +import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; +import ch.systemsx.cisd.common.exceptions.UserFailureException; + +/** + * + * + * @author Franz-Josef Elmer + */ +class Directory extends AbstractNode implements IDirectory +{ + public Directory(File directory) + { + super(directory); + assert directory.isDirectory() : "Not a directory: " + directory.getAbsolutePath(); + } + + public INode getNode(String name) + { + // TODO Auto-generated method stub + return null; + } + + public IDirectory appendDirectory(String name) + { + // TODO Auto-generated method stub + return null; + } + + public void appendKeyValuePair(String key, String value) + { + File file = new File(fileNode, key); + try + { + FileWriter fileWriter = new FileWriter(file); + fileWriter.write(value); + fileWriter.close(); + } catch (IOException ex) + { + file.delete(); + throw new EnvironmentFailureException("Can not create " + file.getAbsolutePath() + ": " + ex); + } + } + + public void appendNode(INode node) + { + // TODO Auto-generated method stub + + } + + public void appendRealFile(File file) + { + File newFile = new File(fileNode, file.getName()); + if (file.renameTo(newFile) == false) + { + throw new EnvironmentFailureException("Couldn't move file " + file.getAbsolutePath() + " to " + + fileNode.getAbsolutePath()); + } + } + + public void appendLink(String name, INode node) + { + // TODO Auto-generated method stub + + } + + public Iterator<INode> iterator() + { + // TODO Auto-generated method stub + return null; + } + + public void extractTo(File directory) throws UserFailureException, EnvironmentFailureException + { + // TODO Auto-generated method stub + + } + +} diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/FileStorage.java b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/FileStorage.java new file mode 100644 index 0000000000000000000000000000000000000000..d5e74a49073344e67d220dd2064cc9b79e72e478 --- /dev/null +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/FileStorage.java @@ -0,0 +1,51 @@ +/* + * 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.bds.storage.filesystem; + +import java.io.File; + +import ch.systemsx.cisd.bds.storage.IDirectory; +import ch.systemsx.cisd.bds.storage.IStorage; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class FileStorage implements IStorage +{ + private Directory root; + + public FileStorage(File folder) + { + root = new Directory(folder); + } + + public IDirectory getRoot() + { + return root; + } + + public void load() + { + } + + public void save() + { + } + +} diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Link.java b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Link.java new file mode 100644 index 0000000000000000000000000000000000000000..87deccea4553589f18214cb01c1d7be46ad92ff1 --- /dev/null +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Link.java @@ -0,0 +1,70 @@ +/* + * 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.bds.storage.filesystem; + +import java.io.File; + +import ch.systemsx.cisd.bds.storage.IDirectory; +import ch.systemsx.cisd.bds.storage.ILink; +import ch.systemsx.cisd.bds.storage.INode; +import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; +import ch.systemsx.cisd.common.exceptions.UserFailureException; + +/** + * + * + * @author Franz-Josef Elmer + */ +class Link implements ILink +{ + + private final String name; + private IDirectory parent; + private final INode reference; + + Link(String name, INode reference) + { + this.name = name; + this.reference = reference; + } + + public String getName() + { + return name; + } + + void setParent(IDirectory parentOrNull) + { + parent = parentOrNull; + } + + public IDirectory tryToGetParent() + { + return parent; + } + + public INode getReference() + { + return reference; + } + + public void extractTo(File directory) throws UserFailureException, EnvironmentFailureException + { + // TODO Auto-generated method stub + } + +} diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/NodeFactory.java b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/NodeFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..1f14d22468102abeeaffce7ca37bf6e246ffc32e --- /dev/null +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/NodeFactory.java @@ -0,0 +1,53 @@ +/* + * 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.bds.storage.filesystem; + +import java.io.File; +import java.io.IOException; + +import ch.systemsx.cisd.bds.storage.INode; +import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; + +/** + * + * + * @author Franz-Josef Elmer + */ +class NodeFactory +{ + static INode createNode(File file) + { + assert file != null : "Unspecified node"; + String absolutePath = file.getAbsolutePath(); + try + { + String canonicalPath = file.getCanonicalPath(); + if (absolutePath.equals(canonicalPath) == false) + { + return new Link(file.getName(), createNode(new File(canonicalPath))); + } + if (file.isDirectory()) + { + return new Directory(file); + } + return new StringFile(file); + } catch (IOException ex) + { + throw new EnvironmentFailureException("Couldn't get canonical path of file " + absolutePath); + } + } +} diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/StringFile.java b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/StringFile.java new file mode 100644 index 0000000000000000000000000000000000000000..394e11a20f6b51968beac405bc42bd06801481e3 --- /dev/null +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/StringFile.java @@ -0,0 +1,49 @@ +/* + * 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.bds.storage.filesystem; + +import java.io.File; + +import ch.systemsx.cisd.bds.storage.IFile; +import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; +import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.common.utilities.FileUtilities; + +/** + * + * + * @author Franz-Josef Elmer + */ +class StringFile extends AbstractNode implements IFile<String> +{ + StringFile(File file) + { + super(file); + assert file.isFile() : "Not a file " + file.getAbsolutePath(); + } + + public String getValue() + { + return FileUtilities.loadToString(fileNode); + } + + public void extractTo(File directory) throws UserFailureException, EnvironmentFailureException + { + // TODO Auto-generated method stub + } + +} diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/hdf5/HDF5Storage.java b/bds/source/java/ch/systemsx/cisd/bds/storage/hdf5/HDF5Storage.java new file mode 100644 index 0000000000000000000000000000000000000000..55f2a8a9c07ab409f80645fe027bdc557418357c --- /dev/null +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/hdf5/HDF5Storage.java @@ -0,0 +1,54 @@ +/* + * 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.bds.storage.hdf5; + +import java.io.File; + +import ch.systemsx.cisd.bds.storage.IDirectory; +import ch.systemsx.cisd.bds.storage.IStorage; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class HDF5Storage implements IStorage +{ + public HDF5Storage(File hdf5File) + { + assert hdf5File != null : "Unspecified HDF5 file."; + } + + public IDirectory getRoot() + { + // TODO Auto-generated method stub + return null; + } + + public void load() + { + // TODO Auto-generated method stub + + } + + public void save() + { + // TODO Auto-generated method stub + + } + +}