Skip to content

Commit

Permalink
Added default constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
daveneti committed Mar 13, 2016
1 parent 7010f09 commit be6056e
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.rmi.server.UID;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
Expand All @@ -39,7 +38,6 @@

import uno.informatics.common.io.FileType;
import uno.informatics.data.Dataset;
import uno.informatics.data.FeatureDataset;
import uno.informatics.data.SimpleEntity;
import uno.informatics.data.dataset.DatasetException;
import uno.informatics.data.feature.array.ArrayFeatureDataset;
Expand All @@ -58,6 +56,12 @@ public class FileBasedDatasetServices implements DatasetServices {

private Path path;

public FileBasedDatasetServices() throws DatasetException {
setPath(Paths.get(""));

initialise();
}

public FileBasedDatasetServices(Path path) throws DatasetException {
setPath(path);

Expand All @@ -68,12 +72,14 @@ public synchronized final Path getPath() {
return path;
}

protected synchronized final void setPath(Path path) {
public synchronized final void setPath(Path path) throws DatasetException {
if (path == null) {
throw new IllegalArgumentException("Path must be defined!");
}

this.path = path;

initialise();
}

@Override
Expand Down Expand Up @@ -173,6 +179,10 @@ public boolean removeDataset(String datasetId) throws DatasetException {
@SuppressWarnings("unchecked")
private void initialise() throws DatasetException {
try {
if (!Files.exists(getPath())) {
Files.createDirectories(getPath());
}

Path datasetDescriptionsPath = Paths.get(getPath().toString(), DATASET_DESCRIPTIONS);

if (Files.exists(datasetDescriptionsPath)) {
Expand All @@ -195,10 +205,12 @@ private void initialise() throws DatasetException {
private Dataset loadDataset(String datasetId) throws DatasetException {
Dataset dataset = null;

ZipFeatureDatasetReader reader = new ZipFeatureDatasetReader(
Paths.get(getPath().toString(), datasetId).toFile());
if (datasetId != null) {
ZipFeatureDatasetReader reader = new ZipFeatureDatasetReader(
Paths.get(getPath().toString(), datasetId).toFile());

dataset = reader.read();
dataset = reader.read();
}

return dataset;
}
Expand Down

0 comments on commit be6056e

Please sign in to comment.