Commit d3f66d76 authored by Romain Reuillon's avatar Romain Reuillon

[Plugin] enh: implement JSON Hook

parent 3c58687a
...@@ -15,6 +15,7 @@ package object extension { ...@@ -15,6 +15,7 @@ package object extension {
type Hook = org.openmole.core.workflow.mole.FromContextHook type Hook = org.openmole.core.workflow.mole.FromContextHook
def Hook = org.openmole.core.workflow.mole.Hook def Hook = org.openmole.core.workflow.mole.Hook
def FormattedFileHook = org.openmole.core.workflow.mole.FormattedFileHook
type Source = org.openmole.core.workflow.mole.Source type Source = org.openmole.core.workflow.mole.Source
type FromContextSource = org.openmole.core.workflow.mole.FromContextSource type FromContextSource = org.openmole.core.workflow.mole.FromContextSource
......
...@@ -81,6 +81,7 @@ object KeyWord { ...@@ -81,6 +81,7 @@ object KeyWord {
case class SamplingKeyWord(name: String) extends KeyWord case class SamplingKeyWord(name: String) extends KeyWord
case class WordKeyWord(name: String) extends KeyWord case class WordKeyWord(name: String) extends KeyWord
case class DomainKeyWord(name: String) extends KeyWord case class DomainKeyWord(name: String) extends KeyWord
case class OtherKeyWord(name: String) extends KeyWord
} }
trait PluginInfoActivator extends BundleActivator { trait PluginInfoActivator extends BundleActivator {
......
...@@ -2,6 +2,7 @@ package org.openmole.core.workflow ...@@ -2,6 +2,7 @@ package org.openmole.core.workflow
import org.openmole.core.pluginmanager.PluginInfo import org.openmole.core.pluginmanager.PluginInfo
import org.openmole.core.preference.ConfigurationInfo import org.openmole.core.preference.ConfigurationInfo
import org.openmole.core.workflow.mole.CSVHook.CSVOutputFormat
import org.osgi.framework.{ BundleActivator, BundleContext } import org.osgi.framework.{ BundleActivator, BundleContext }
class Activator extends BundleActivator { class Activator extends BundleActivator {
...@@ -54,7 +55,8 @@ class Activator extends BundleActivator { ...@@ -54,7 +55,8 @@ class Activator extends BundleActivator {
TaskKeyWord(objectName(ToArrayTask)), TaskKeyWord(objectName(ToArrayTask)),
TaskKeyWord(objectName(MoleTask)), TaskKeyWord(objectName(MoleTask)),
TaskKeyWord(objectName(FromContextTask)), TaskKeyWord(objectName(FromContextTask)),
HookKeyWord(objectName(FromContextHook)) HookKeyWord(objectName(FromContextHook)),
OtherKeyWord(objectName(CSVOutputFormat))
) )
} }
......
...@@ -33,7 +33,10 @@ class Activator extends PluginInfoActivator { ...@@ -33,7 +33,10 @@ class Activator extends PluginInfoActivator {
import org.openmole.core.pluginmanager.KeyWord._ import org.openmole.core.pluginmanager.KeyWord._
val keyWords: Vector[KeyWord] = val keyWords: Vector[KeyWord] =
Vector() Vector(
TaskKeyWord(objectName(JSONHook)),
OtherKeyWord(objectName(JSONOutputFormat))
)
PluginInfo.register(this, Vector(this.getClass.getPackage), keyWords = keyWords) PluginInfo.register(this, Vector(this.getClass.getPackage), keyWords = keyWords)
ConfigurationInfo.register( ConfigurationInfo.register(
......
package org.openmole.plugin.hook.json
import org.openmole.core.dsl._
import org.openmole.core.dsl.extension._
object JSONHook {
def apply(output: WritableOutput, values: Val[_]*)(implicit name: sourcecode.Name, definitionScope: DefinitionScope): FromContextHook =
apply(output, values.toVector)
def apply(
output: WritableOutput,
values: Seq[Val[_]] = Vector.empty,
exclude: Seq[Val[_]] = Vector.empty)(implicit name: sourcecode.Name, definitionScope: DefinitionScope): FromContextHook =
FormattedFileHook(
format = JSONOutputFormat(),
output = output,
values = values,
exclude = exclude,
name = Some("JSONHook")
)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment