Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
VinceMacBuche committed Dec 13, 2016
1 parent 1687c0f commit 224d531
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,40 +45,51 @@ sealed trait DataSourceType {
def name : String
}

object DataSourceType {
def apply(name : String) : Box[DataSourceType] = {
if (name == ByNodeSourceType.name) {
Full(ByNodeSourceType)
} else {
Failure("not a valid source type name")
}
}
case class HtmlDataSourceType (
url : String
, headers : Map[String,String]
, httpMethod : String
, path : String
, requestMode: HtmlRequestMode
) extends DataSourceType {
val name = "html"
}
case object ByNodeSourceType extends DataSourceType {

sealed trait HtmlRequestMode {
def name : String
}
case object OneRequestByNode extends HtmlRequestMode {
val name = "byNode"
}

case class AllNodesSourceType(
case class OneRequestAllNodes(
matchingPath : String
, nodeAttribute : String
) extends DataSourceType {
) extends HtmlRequestMode {
val name = AllNodesSourceType.name
}

object AllNodesSourceType {
val name = "allNodes"
}
case class DataSourceName(value : String) extends AnyVal
case class DataSourceId (value : String) extends AnyVal

case class DataSourceRunParameters (
runAutomatically : Boolean
, runFrequency : Seconds
, runOnGeneration : Boolean
, runOnNewElem : Boolean
)

case class DataSource (
name : DataSourceName
, description: String
id : DataSourceId
, name : DataSourceName
, sourceType : DataSourceType
, url : String
, headers : Map[String,String]
, httpMethod : String
, path : String
, frequency : Seconds
, runParam : DataSourceRunParameters
, description: String
, lastUpdate : Option[DateTime]
, enabled : Boolean
)
) {
val scope = "all"
}
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ case class RestDataSerializerImpl (

def serializeDataSource(source : DataSource): JValue = {
( ( "name" -> source.name.value )
~ ( "id" -> source.id.value )
~ ( "description" -> source.description )
~ ( "type" -> (
( "name" -> source.sourceType.name )
Expand Down

0 comments on commit 224d531

Please sign in to comment.