diff --git a/build.gradle b/build.gradle index 67fc2383..076e1a70 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,17 @@ buildscript { - ext.kotlin_version = "1.2.30" -} + ext.kotlin_version = "1.2.31" + repositories { + jcenter() + maven { + url "https://dl.bintray.com/kotlin/kotlin-eap" + } + } -plugins { - id "org.jetbrains.kotlin.jvm" version "1.2.30" apply false + dependencies { + classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.16" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } } - allprojects{ apply plugin: 'idea' apply plugin: 'java' diff --git a/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Channel.kt b/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Channel.kt index 207279d2..fb11ca06 100644 --- a/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Channel.kt +++ b/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Channel.kt @@ -16,12 +16,12 @@ package inr.numass.control.cryotemp +import hep.dataforge.Named import hep.dataforge.kodex.buildMeta import hep.dataforge.kodex.stringValue import hep.dataforge.meta.Meta import hep.dataforge.meta.MetaBuilder import hep.dataforge.meta.Metoid -import hep.dataforge.names.Named internal fun createChannel(name: String): PKT8Channel = @@ -51,11 +51,7 @@ internal fun createChannel(meta: Meta): PKT8Channel { */ class PKT8Channel(override val meta: Meta, private val func: (Double) -> Double) : Named, Metoid { - private val _name: String by meta.stringValue() - - override fun getName(): String { - return _name - } + override val name: String by meta.stringValue() fun description(): String { return meta.getString("description", "") diff --git a/numass-core/src/main/kotlin/inr/numass/data/NumassDataUtils.kt b/numass-core/src/main/kotlin/inr/numass/data/NumassDataUtils.kt index 1201e42f..424c3598 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/NumassDataUtils.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/NumassDataUtils.kt @@ -19,7 +19,7 @@ import kotlin.streams.asSequence * Created by darksnake on 30-Jan-17. */ object NumassDataUtils { - fun join(name: String, sets: Collection): NumassSet { + fun join(setName: String, sets: Collection): NumassSet { return object : NumassSet { override val points: Stream by lazy { val points = sets.stream().flatMap { it.points } @@ -33,9 +33,7 @@ object NumassDataUtils { metaBuilder } - override fun getName(): String { - return name - } + override val name = setName } } diff --git a/numass-core/src/main/kotlin/inr/numass/data/api/NumassSet.kt b/numass-core/src/main/kotlin/inr/numass/data/api/NumassSet.kt index 84d8a653..3ac8ca51 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/api/NumassSet.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/api/NumassSet.kt @@ -5,9 +5,9 @@ */ package inr.numass.data.api +import hep.dataforge.Named import hep.dataforge.kodex.toList import hep.dataforge.meta.Metoid -import hep.dataforge.names.Named import hep.dataforge.providers.Provider import hep.dataforge.providers.Provides import hep.dataforge.providers.ProvidesNames diff --git a/numass-core/src/main/kotlin/inr/numass/data/legacy/NumassDatFile.kt b/numass-core/src/main/kotlin/inr/numass/data/legacy/NumassDatFile.kt index b0e980ad..c112006c 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/legacy/NumassDatFile.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/legacy/NumassDatFile.kt @@ -23,7 +23,7 @@ import java.util.stream.Stream * Created by darksnake on 08.07.2017. */ class NumassDatFile @Throws(IOException::class) -constructor(private val name: String, private val path: Path, meta: Meta) : NumassSet { +constructor(override val name: String, private val path: Path, meta: Meta) : NumassSet { override val meta: Meta private val hVdev: Double @@ -57,10 +57,6 @@ constructor(private val name: String, private val path: Path, meta: Meta) : Numa .build() } - override fun getName(): String { - return name - } - private fun hasUset(): Boolean { return meta.getBoolean("dat.uSet", true) } diff --git a/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataFactory.kt b/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataFactory.kt index 2118634d..dfb0d1e6 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataFactory.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataFactory.kt @@ -2,7 +2,7 @@ package inr.numass.data.storage import hep.dataforge.context.Context import hep.dataforge.data.DataFactory -import hep.dataforge.data.DataTree +import hep.dataforge.data.DataNodeEditor import hep.dataforge.meta.Meta import hep.dataforge.storage.commons.StorageManager import hep.dataforge.storage.commons.StorageUtils @@ -13,12 +13,10 @@ import inr.numass.data.api.NumassSet */ class NumassDataFactory : DataFactory(NumassSet::class.java) { - override fun getName(): String { - return "numass" - } + override val name= "numass" - override fun fill(builder: DataTree.Builder, context: Context, meta: Meta) { + override fun fill(builder: DataNodeEditor, context: Context, meta: Meta) { val newMeta = meta.builder.setValue("type", "numass") val storage = context.load(StorageManager::class.java, Meta.empty()).buildStorage(newMeta) StorageUtils.loaderStream(storage).forEach { loader -> diff --git a/numass-main/src/main/java/inr/numass/WorkspaceTest.java b/numass-main/src/main/java/inr/numass/WorkspaceTest.java deleted file mode 100644 index 0a87a6fe..00000000 --- a/numass-main/src/main/java/inr/numass/WorkspaceTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package inr.numass; - -import hep.dataforge.meta.MetaBuilder; -import hep.dataforge.storage.commons.StorageDataFactory; -import hep.dataforge.workspace.BasicWorkspace; -import hep.dataforge.workspace.Workspace; - -/** - * - * @author Alexander Nozik - */ -public class WorkspaceTest { - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - - String storagepath = "D:\\Work\\Numass\\data\\"; - Workspace workspace = BasicWorkspace.builder() - .setContext(Numass.buildContext()) - .data("", new StorageDataFactory(), new MetaBuilder("storage").putValue("path", storagepath)) - - .build(); - } - -} diff --git a/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt b/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt index 3016955c..3a07443e 100644 --- a/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt +++ b/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt @@ -152,8 +152,8 @@ object NumassUtils { * @return */ fun setToNode(set: NumassSet): DataNode { - val builder = DataSet.builder() - builder.setName(set.name) + val builder = DataSet.edit() + builder.name = set.name set.points.forEach { point -> val pointMeta = MetaBuilder("point") .putValue("voltage", point.voltage) diff --git a/numass-main/src/main/kotlin/inr/numass/WorkspaceTest.kt b/numass-main/src/main/kotlin/inr/numass/WorkspaceTest.kt new file mode 100644 index 00000000..f8309834 --- /dev/null +++ b/numass-main/src/main/kotlin/inr/numass/WorkspaceTest.kt @@ -0,0 +1,32 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package inr.numass + +import hep.dataforge.meta.MetaBuilder +import hep.dataforge.storage.commons.StorageDataFactory +import hep.dataforge.workspace.BasicWorkspace + +/** + * + * @author Alexander Nozik + */ +object WorkspaceTest { + + /** + * @param args the command line arguments + */ + @JvmStatic + fun main(args: Array) { + + val storagepath = "D:\\Work\\Numass\\data\\" + + val workspace = BasicWorkspace.builder().apply { + this.context = Numass.buildContext() + data("", StorageDataFactory(), MetaBuilder("storage").putValue("path", storagepath)) + }.build() + } + +} diff --git a/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt index 356bbb5c..f4a254e5 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt @@ -37,9 +37,11 @@ import java.util.* */ @TypedActionDef(name = "summary", inputType = FitState::class, outputType = Table::class, info = "Generate summary for fit results of different datasets.") @ValueDef(name = "parnames", multiple = true, required = true, info = "List of names of parameters for which summary should be done") -class SummaryAction : ManyToOneAction() { +object SummaryAction : ManyToOneAction() { - protected override fun buildGroups(context: Context, input: DataNode, actionMeta: Meta): List> { + const val SUMMARY_NAME = "sumName" + + override fun buildGroups(context: Context, input: DataNode, actionMeta: Meta): List> { val meta = inputMeta(context, input.meta, actionMeta) val groups: List> if (meta.hasValue("grouping.byValue")) { @@ -108,9 +110,4 @@ class SummaryAction : ManyToOneAction() { super.afterGroup(context, groupName, outputMeta, output) } - companion object { - - val SUMMARY_NAME = "sumName" - } - } diff --git a/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt index 73a98826..724f5e2e 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt @@ -63,7 +63,7 @@ class TimeAnalyzerAction : OneToOneAction() { if (inputMeta.getBoolean("plotHist", true)) { - val histPlot = pm.getPlotFrame(getName(), "histogram"); + val histPlot = pm.getPlotFrame(name, "histogram"); histPlot.configure { node("xAxis") { @@ -99,7 +99,7 @@ class TimeAnalyzerAction : OneToOneAction() { configure(inputMeta.getMetaOrEmpty("plot")) } - pm.getPlotFrame(getName(), "stat-method").add(statPlot) + pm.getPlotFrame(name, "stat-method").add(statPlot) (1..100).map { inputMeta.getDouble("t0Step", 1000.0) * it }.map { t -> val result = analyzer.analyze(input, inputMeta.builder.setValue("t0", t)) diff --git a/numass-main/src/main/kotlin/inr/numass/actions/TimeSpectrumAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/TimeSpectrumAction.kt index 201de95a..05a2983b 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/TimeSpectrumAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/TimeSpectrumAction.kt @@ -68,7 +68,7 @@ class TimeSpectrumAction : OneToOneAction() { if (inputMeta.getBoolean("plotHist", true)) { - val histPlot = pm.getPlotFrame(getName(), "histogram"); + val histPlot = pm.getPlotFrame(name, "histogram"); histPlot.configure { node("xAxis") { @@ -105,7 +105,7 @@ class TimeSpectrumAction : OneToOneAction() { configure(inputMeta.getMetaOrEmpty("plot")) } - pm.getPlotFrame(getName(), "stat-method").add(statPlot) + pm.getPlotFrame(name, "stat-method").add(statPlot) (1..100).map { 1000 * it }.map { t -> val result = analyzer.analyze(input, buildMeta { diff --git a/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt index b6b64fdc..3f0a92f4 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt @@ -1,15 +1,17 @@ package inr.numass.actions +import hep.dataforge.Named import hep.dataforge.actions.OneToOneAction import hep.dataforge.context.Context import hep.dataforge.description.NodeDef import hep.dataforge.description.TypedActionDef import hep.dataforge.description.ValueDef import hep.dataforge.description.ValueDefs +import hep.dataforge.isAnonymous import hep.dataforge.meta.Laminate import hep.dataforge.meta.Meta import hep.dataforge.meta.MetaUtils -import hep.dataforge.names.Named + import hep.dataforge.tables.ColumnFormat import hep.dataforge.tables.ColumnTable import hep.dataforge.tables.ListColumn @@ -49,6 +51,8 @@ class TransformDataAction : OneToOneAction() { if (meta.hasValue("correction")) { val correction = meta.getString("correction") corrections.add(object : Correction { + override val name: String = "" + override fun corr(point: Values): Double { return pointExpression(correction, point) } @@ -60,7 +64,7 @@ class TransformDataAction : OneToOneAction() { for (correction in corrections) { //adding correction columns - if (!correction.isAnonimous) { + if (!correction.isAnonymous) { table = table.buildColumn(ColumnFormat.build(correction.name, NUMBER)) { correction.corr(it) } if (correction.hasError()) { table = table.buildColumn(ColumnFormat.build(correction.name + ".err", NUMBER)) { correction.corrErr(it) } @@ -69,8 +73,8 @@ class TransformDataAction : OneToOneAction() { } // adding original count rate and error columns - table = table.addColumn(ListColumn(ColumnFormat.build(COUNT_RATE_KEY + ".orig", NUMBER), table.getColumn(COUNT_RATE_KEY).stream())) - table = table.addColumn(ListColumn(ColumnFormat.build(COUNT_RATE_ERROR_KEY + ".orig", NUMBER), table + table = table.addColumn(ListColumn(ColumnFormat.build("$COUNT_RATE_KEY.orig", NUMBER), table.getColumn(COUNT_RATE_KEY).stream())) + table = table.addColumn(ListColumn(ColumnFormat.build("$COUNT_RATE_ERROR_KEY.orig", NUMBER), table .getColumn(COUNT_RATE_ERROR_KEY).stream())) val cr = ArrayList() @@ -99,7 +103,7 @@ class TransformDataAction : OneToOneAction() { val res = table.addColumn(ListColumn.build(table.getColumn(COUNT_RATE_KEY).format, cr.stream())) .addColumn(ListColumn.build(table.getColumn(COUNT_RATE_ERROR_KEY).format, crErr.stream())) - context.io.output(name, getName()).push(NumassUtils.wrap(res, meta)) + context.io.output(name, name).push(NumassUtils.wrap(res, meta)) return res } @@ -112,9 +116,7 @@ class TransformDataAction : OneToOneAction() { val expr = corrMeta.getString("value") val errExpr = corrMeta.getString("err", "") return object : Correction { - override fun getName(): String { - return corrMeta.getString("name", corrMeta.name) - } + override val name=corrMeta.getString("name", corrMeta.name) override fun corr(point: Values): Double { return pointExpression(expr, point) @@ -136,10 +138,6 @@ class TransformDataAction : OneToOneAction() { private interface Correction : Named { - override fun getName(): String { - return "" - } - /** * correction coefficient * diff --git a/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/AnalyzePoint.kt b/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/AnalyzePoint.kt index c2b54b2d..71b83e27 100644 --- a/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/AnalyzePoint.kt +++ b/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/AnalyzePoint.kt @@ -45,7 +45,7 @@ fun main(args: Array) { val all = NumassDataUtils.join("sum", loaders) - val data = DataSet.builder(NumassPoint::class.java).apply { + val data = DataSet.edit(NumassPoint::class).apply { hvs.forEach { hv -> putStatic( "point_${hv.toInt()}", diff --git a/numass-main/src/main/kotlin/inr/numass/subthreshold/Threshold.kt b/numass-main/src/main/kotlin/inr/numass/subthreshold/Threshold.kt index 12a1f4ba..2ed60495 100644 --- a/numass-main/src/main/kotlin/inr/numass/subthreshold/Threshold.kt +++ b/numass-main/src/main/kotlin/inr/numass/subthreshold/Threshold.kt @@ -46,7 +46,7 @@ object Threshold { val analyzer = TimeAnalyzer(); - val data = DataSet.builder(NumassPoint::class.java).also { dataBuilder -> + val data = DataSet.edit(NumassPoint::class).also { dataBuilder -> sets.sortedBy { it.startTime } .flatMap { set -> set.points.toList() } .groupBy { it.voltage } diff --git a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt index d20a43e0..9494c76a 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt @@ -27,12 +27,12 @@ import inr.numass.NumassUtils class NumassFitScanSummaryTask : AbstractTask() { override fun run(model: TaskModel, data: DataNode<*>): DataNode
{ - val builder = DataSet.builder(Table::class.java) + val builder = DataSet.edit(Table::class) val action = FitSummaryAction() val input = data.checked(FitResult::class.java) input.nodeStream() .filter { it -> it.getSize(false) > 0 } - .forEach { node -> builder.putData(node.name, action.run(model.context, node, model.meta).data) } + .forEach { node -> builder.putData(node.name, action.run(model.context, node, model.meta).data!!) } return builder.build() } @@ -41,9 +41,7 @@ class NumassFitScanSummaryTask : AbstractTask
() { } - override fun getName(): String { - return "scansum" - } + override val name = "scansum" @TypedActionDef(name = "sterileSummary", inputType = FitResult::class, outputType = Table::class) private inner class FitSummaryAction : ManyToOneAction() { diff --git a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanTask.kt b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanTask.kt index c169473a..d40e3612 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanTask.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanTask.kt @@ -21,7 +21,7 @@ import java.util.stream.Collectors /** * @author Alexander Nozik */ -class NumassFitScanTask : AbstractTask() { +object NumassFitScanTask : AbstractTask() { override fun run(model: TaskModel, data: DataNode<*>): DataNode { @@ -39,7 +39,7 @@ class NumassFitScanTask : AbstractTask() { } val action = FitAction() - val resultBuilder = DataTree.builder(FitResult::class.java) + val resultBuilder = DataTree.edit(FitResult::class) val sourceNode = data.checked(Table::class.java) //do fit @@ -53,7 +53,7 @@ class NumassFitScanTask : AbstractTask() { val resultName = String.format("%s[%s=%s]", table.name, scanParameter, `val`.stringValue()) // overrideMeta.setValue("@resultName", String.format("%s[%s=%s]", table.getName(), scanParameter, val.stringValue())); - if (overrideMeta.hasMeta("params." + scanParameter)) { + if (overrideMeta.hasMeta("params.$scanParameter")) { overrideMeta.setValue("params.$scanParameter.value", `val`) } else { overrideMeta.getMetaList("params.param").stream() @@ -62,7 +62,7 @@ class NumassFitScanTask : AbstractTask() { } // Data
newData = new Data
(data.getGoal(),data.type(),overrideMeta); val node = action.run(model.context, DataNode.of(resultName, table, Meta.empty()), overrideMeta) - resultBuilder.putData(table.name + ".fit_" + i, node.data) + resultBuilder.putData(table.name + ".fit_" + i, node.data!!) } } @@ -76,8 +76,6 @@ class NumassFitScanTask : AbstractTask() { model.dependsOn("filter", meta) } - override fun getName(): String { - return "fitscan" - } + override val name = "fitscan" } diff --git a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitSummaryTask.kt b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitSummaryTask.kt index 7b80d26c..d3f69c7c 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitSummaryTask.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitSummaryTask.kt @@ -16,33 +16,24 @@ package inr.numass.tasks -import hep.dataforge.actions.Action import hep.dataforge.data.DataNode import hep.dataforge.meta.Meta import hep.dataforge.stat.fit.FitState import hep.dataforge.tables.Table -import hep.dataforge.workspace.tasks.SingleActionTask +import hep.dataforge.workspace.tasks.AbstractTask import hep.dataforge.workspace.tasks.TaskModel import inr.numass.actions.SummaryAction /** * Created by darksnake on 16-Sep-16. */ -class NumassFitSummaryTask : SingleActionTask() { - override fun getName(): String { - return "summary" - } +object NumassFitSummaryTask : AbstractTask
() { + override val name: String = "summary" - override fun getAction(model: TaskModel): Action { - return SummaryAction() - } - - override fun gatherNode(data: DataNode<*>): DataNode { - return data.getCheckedNode("fit", FitState::class.java) - } - - override fun transformMeta(model: TaskModel): Meta { - return model.meta.getMeta("summary") + override fun run(model: TaskModel, data: DataNode<*>): DataNode { + val actionMeta = model.meta.getMeta("summary") + val checkedData = data.getCheckedNode("fit", FitState::class.java) + return SummaryAction.run(model.context, checkedData, actionMeta) } override fun buildModel(model: TaskModel.Builder, meta: Meta) { diff --git a/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt b/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt index 88620167..3a5538bc 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt @@ -42,7 +42,7 @@ val selectTask = task("select") { data("*") configure(meta.getMetaOrEmpty("data")) } - transform { data -> + transform { data -> logger.info("Starting selection from data node with size ${data.size}") CustomDataFilter(meta).filter(data.checked(NumassSet::class.java)).also { logger.info("Selected ${it.size} elements") @@ -80,13 +80,13 @@ val monitorTableTask = task("monitor") { } plots + DataPlot.plot(name, Adapters.buildXYAdapter("timestamp", "cr", "crErr"), res) }.also { frame -> - if (frame is JFreeChartFrame) { - //add set markers - addSetMarkers(frame, data.values) - } - context.io.output(name, stage = "numass.monitor", type = "dfp").push(PlotFrame.Wrapper().wrap(frame)) + if (frame is JFreeChartFrame) { + //add set markers + addSetMarkers(frame, data.values) + } + context.io.output(name, stage = "numass.monitor", type = "dfp").push(PlotFrame.Wrapper().wrap(frame)) - } + } } } @@ -139,8 +139,8 @@ val mergeEmptyTask = task("empty") { .setValue("merge." + MERGE_NAME, meta.getString("merge." + MERGE_NAME, "") + "_empty"); dependsOn(mergeTask, newMeta) } - transform { data -> - val builder = DataSet.builder(Table::class.java) + transform
{ data -> + val builder = DataSet.edit(Table::class) data.forEach { builder.putData(it.name + "_empty", it.anonymize()); } @@ -154,12 +154,13 @@ val subtractEmptyTask = task("dif") { dependsOn(mergeTask, meta, "data") dependsOn(mergeEmptyTask, meta, "empty") } - transform { data -> - val builder = DataTree.builder(Table::class.java) - val rootNode = data.getCheckedNode
("data", Table::class.java) - val empty = data.getCheckedNode
("empty", Table::class.java).data + transform
{ data -> + val builder = DataTree.edit(Table::class) + val rootNode = data.getCheckedNode("data", Table::class.java) + val empty = data.getCheckedNode("empty", Table::class.java).data + ?: throw RuntimeException("No empty data found") - rootNode.forEachData(Table::class.java, { input -> + rootNode.visit(Table::class.java, { input -> val resMeta = buildMeta { putNode("data", input.meta) putNode("empty", empty.meta) @@ -170,7 +171,7 @@ val subtractEmptyTask = task("dif") { res.goal.onComplete { r, _ -> if (r != null) { - context.io.output(input.name + "_subtract", stage = "numass.merge").push(NumassUtils.wrap(r,resMeta)) + context.io.output(input.name + "_subtract", stage = "numass.merge").push(NumassUtils.wrap(r, resMeta)) } } diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassDataCache.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassDataCache.kt index b640426d..0fbe211e 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassDataCache.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassDataCache.kt @@ -12,7 +12,7 @@ import java.util.stream.Stream * Cached numass data * Created by darksnake on 23-Jun-17. */ -class NumassDataCache(val data: NumassSet) : NumassSet { +class NumassDataCache(private val data: NumassSet) : NumassSet { //private val cachedDescription: String by lazy { data.description } override val meta: Meta by lazy { data.meta } private val cachedPoints: List by lazy { data.points.collect(Collectors.toList()) } @@ -22,12 +22,5 @@ class NumassDataCache(val data: NumassSet) : NumassSet { override val points: Stream get() = cachedPoints.stream() -// override fun getDescription(): String { -// return cachedDescription -// } - - - override fun getName(): String { - return data.name; - } + override val name: String = data.name } \ No newline at end of file