Removed wildcards from Data and DataNodes

This commit is contained in:
Alexander Nozik 2017-09-15 20:14:01 +03:00
parent c8d6391219
commit 67d212713a
2 changed files with 25 additions and 18 deletions

View File

@ -27,7 +27,9 @@ import hep.dataforge.utils.ReferenceRegistry;
import org.apache.commons.io.output.TeeOutputStream; import org.apache.commons.io.output.TeeOutputStream;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.*; import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
@ -105,6 +107,7 @@ public class NumassIO extends BasicIOManager {
if (!Files.exists(parentDir)) { if (!Files.exists(parentDir)) {
throw new RuntimeException("Working directory does not exist"); throw new RuntimeException("Working directory does not exist");
} }
try {
if (dirName != null && !dirName.isEmpty()) { if (dirName != null && !dirName.isEmpty()) {
parentDir = parentDir.resolve(dirName); parentDir = parentDir.resolve(dirName);
Files.createDirectories(parentDir); Files.createDirectories(parentDir);
@ -112,13 +115,13 @@ public class NumassIO extends BasicIOManager {
// String output = source.meta().getString("output", this.meta().getString("output", fileName + ".onComplete")); // String output = source.meta().getString("output", this.meta().getString("output", fileName + ".onComplete"));
outputFile = parentDir.resolve(fileName); outputFile = parentDir.resolve(fileName);
try {
if (getContext().getBoolean("numass.consoleOutput", false)) { if (getContext().getBoolean("numass.consoleOutput", false)) {
return new TeeOutputStream(Files.newOutputStream(outputFile), System.out); return new TeeOutputStream(Files.newOutputStream(outputFile), System.out);
} else { } else {
return Files.newOutputStream(outputFile); return Files.newOutputStream(outputFile);
} }
} catch (FileNotFoundException ex) { } catch (IOException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
} }

View File

@ -20,8 +20,7 @@ import inr.numass.models.FSS;
import inr.numass.utils.NumassIntegrator; import inr.numass.utils.NumassIntegrator;
import org.apache.commons.math3.analysis.UnivariateFunction; import org.apache.commons.math3.analysis.UnivariateFunction;
import java.io.FileInputStream; import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.InputStream; import java.io.InputStream;
import static hep.dataforge.values.ValueType.BOOLEAN; import static hep.dataforge.values.ValueType.BOOLEAN;
@ -61,14 +60,19 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction {
public SterileNeutrinoSpectrum(Context context, Meta configuration) { public SterileNeutrinoSpectrum(Context context, Meta configuration) {
super(list); super(list);
if (configuration.getBoolean("useFSS", true)) { if (configuration.getBoolean("useFSS", true)) {
InputStream fssStream; InputStream fssStream = configuration.optString("fssFile")
if (configuration.hasValue("fssFile")) { .map(fssFile -> {
fssStream = context.io().optBinary(configuration.getString("fssFile")) try {
.orElseThrow(()-> new RuntimeException("Could not locate FSS file")) return context.io().optBinary(fssFile)
.orElseThrow(() -> new RuntimeException("Could not locate FSS file"))
.getStream(); .getStream();
} else { } catch (IOException e) {
fssStream = getClass().getResourceAsStream("/data/FS.txt"); throw new RuntimeException("Could not load FSS file", e);
} }
})
.orElse(getClass().getResourceAsStream("/data/FS.txt"));
fss = new FSS(fssStream); fss = new FSS(fssStream);
} }