Skip to content
Snippets Groups Projects
Commit 2cc77540 authored by felmer's avatar felmer
Browse files

- remove interfaces no longer used

- IDirectory method signatures changed

SVN: 2086
parent 06b489d2
No related branches found
No related tags found
No related merge requests found
Showing
with 23 additions and 273 deletions
...@@ -87,10 +87,10 @@ public class ExperimentIdentifier ...@@ -87,10 +87,10 @@ public class ExperimentIdentifier
public void saveTo(IDirectory directory) public void saveTo(IDirectory directory)
{ {
IDirectory folder = directory.appendDirectory(FOLDER); IDirectory folder = directory.makeDirectory(FOLDER);
folder.appendKeyValuePair(GROUP_CODE, groupCode); folder.addKeyValuePair(GROUP_CODE, groupCode);
folder.appendKeyValuePair(PROJECT_CODE, projectCode); folder.addKeyValuePair(PROJECT_CODE, projectCode);
folder.appendKeyValuePair(EXPERIMENT_CODE, experimentCode); folder.addKeyValuePair(EXPERIMENT_CODE, experimentCode);
} }
@Override @Override
......
/*
* 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 ch.systemsx.cisd.common.exceptions.EnvironmentFailureException;
/**
* Common interface of all versions of data structures.
*
* @author Franz-Josef Elmer
*/
public interface IDataStructure extends IHasVersion
{
/**
* Returns the name of this data structure.
*/
public String getName();
/**
* Save the current structure.
*
* @throws EnvironmentFailureException if it couldn't saved.
*/
public void save() throws EnvironmentFailureException;
}
/*
* 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 ch.systemsx.cisd.bds.storage.IDirectory;
/**
* Data structure interface for Version 1.0.
*
* @author Franz-Josef Elmer
*/
public interface IDataStructureV1_0 extends IDataStructure
{
public IDirectory getOriginalData();
public IFormatedData getFormatedData();
public ExperimentIdentifier getExperimentIdentifier();
public void setExperimentIdentifier(ExperimentIdentifier id);
public ProcessingType getProcessingType();
public void setProcessingType(ProcessingType type);
}
/*
* 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;
/**
*
*
* @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);
}
/*
* 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;
/**
* 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();
}
/*
* 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;
/**
*
*
* @author Franz-Josef Elmer
*/
public interface ILink extends INode
{
public INode getReference();
}
/*
* 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.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;
}
/*
* 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;
/**
*
*
* @author Franz-Josef Elmer
*/
public interface IStorage
{
public void load();
public IDirectory getRoot();
public void save();
}
...@@ -48,6 +48,6 @@ public enum ProcessingType ...@@ -48,6 +48,6 @@ public enum ProcessingType
public void saveTo(IDirectory directory) public void saveTo(IDirectory directory)
{ {
directory.appendKeyValuePair(PROCESSING_TYPE, toString()); directory.addKeyValuePair(PROCESSING_TYPE, toString());
} }
} }
...@@ -106,9 +106,9 @@ public final class Version ...@@ -106,9 +106,9 @@ public final class Version
public void saveTo(IDirectory directory) public void saveTo(IDirectory directory)
{ {
IDirectory versionFolder = directory.appendDirectory(VERSION); IDirectory versionFolder = directory.makeDirectory(VERSION);
versionFolder.appendKeyValuePair(MAJOR, Integer.toString(major)); versionFolder.addKeyValuePair(MAJOR, Integer.toString(major));
versionFolder.appendKeyValuePair(MINOR, Integer.toString(minor)); versionFolder.addKeyValuePair(MINOR, Integer.toString(minor));
} }
@Override @Override
......
...@@ -27,13 +27,13 @@ public interface IDirectory extends INode, Iterable<INode> ...@@ -27,13 +27,13 @@ public interface IDirectory extends INode, Iterable<INode>
{ {
public INode getNode(String name); public INode getNode(String name);
public IDirectory appendDirectory(String name); public IDirectory makeDirectory(String name);
public void appendNode(INode node); public void addNode(INode node);
public void appendRealFile(File file); public IFile<File> addRealFile(File file);
public void appendKeyValuePair(String key, String value); public IFile<String> addKeyValuePair(String key, String value);
public void appendLink(String name, INode node); public ILink addLink(String name, INode node);
} }
...@@ -22,6 +22,8 @@ import java.io.IOException; ...@@ -22,6 +22,8 @@ import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
import ch.systemsx.cisd.bds.storage.IDirectory; 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.INode;
import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException;
import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException;
...@@ -45,13 +47,13 @@ class Directory extends AbstractNode implements IDirectory ...@@ -45,13 +47,13 @@ class Directory extends AbstractNode implements IDirectory
return null; return null;
} }
public IDirectory appendDirectory(String name) public IDirectory makeDirectory(String name)
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
public void appendKeyValuePair(String key, String value) public IFile<String> addKeyValuePair(String key, String value)
{ {
File file = new File(fileNode, key); File file = new File(fileNode, key);
try try
...@@ -64,15 +66,16 @@ class Directory extends AbstractNode implements IDirectory ...@@ -64,15 +66,16 @@ class Directory extends AbstractNode implements IDirectory
file.delete(); file.delete();
throw new EnvironmentFailureException("Can not create " + file.getAbsolutePath() + ": " + ex); throw new EnvironmentFailureException("Can not create " + file.getAbsolutePath() + ": " + ex);
} }
return null;
} }
public void appendNode(INode node) public void addNode(INode node)
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
public void appendRealFile(File file) public IFile<File> addRealFile(File file)
{ {
File newFile = new File(fileNode, file.getName()); File newFile = new File(fileNode, file.getName());
if (file.renameTo(newFile) == false) if (file.renameTo(newFile) == false)
...@@ -80,12 +83,13 @@ class Directory extends AbstractNode implements IDirectory ...@@ -80,12 +83,13 @@ class Directory extends AbstractNode implements IDirectory
throw new EnvironmentFailureException("Couldn't move file " + file.getAbsolutePath() + " to " throw new EnvironmentFailureException("Couldn't move file " + file.getAbsolutePath() + " to "
+ fileNode.getAbsolutePath()); + fileNode.getAbsolutePath());
} }
return null;
} }
public void appendLink(String name, INode node) public ILink addLink(String name, INode node)
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null;
} }
public Iterator<INode> iterator() public Iterator<INode> iterator()
......
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