-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
175 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package models | ||
|
||
import scala.concurrent.Future | ||
import play.api.libs.json.JsObject | ||
|
||
abstract class Analyzer { | ||
def analyze(artifact: Artifact): Future[JsObject] | ||
val name: String | ||
val version: String | ||
val description: String | ||
val dataTypeList: Seq[String] | ||
val author: String | ||
val url: String | ||
val license: String | ||
val id = (name + "_" + version).replaceAll("\\.", "_") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- app/models/Analyzer.scala | ||
+++ app/models/Analyzer.scala | ||
@@ -9,5 +9,5 @@ abstract class Analyzer { | ||
val version: String | ||
val description: String | ||
val dataTypeList: Seq[String] | ||
- val id = (name + "_" + version).replaceAll("\\.", "_") | ||
+ val id: String = (name + "_" + version).replaceAll("\\.", "_") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package models | ||
|
||
import scala.annotation.implicitNotFound | ||
|
||
import play.api.libs.json.Json | ||
import play.api.libs.json.Json.toJsFieldJsValueWrapper | ||
import play.api.libs.json.Writes | ||
import scala.concurrent.Future | ||
import play.api.libs.json.JsObject | ||
import scala.util.Success | ||
import scala.util.Failure | ||
import play.api.libs.json.JsString | ||
import play.api.libs.json.OWrites | ||
|
||
object JsonFormat { | ||
implicit val analyzerWrites = Writes[Analyzer](analyzer ⇒ Json.obj( | ||
"name" → analyzer.name, | ||
"version" → analyzer.version, | ||
"description" → analyzer.description, | ||
"dataTypeList" → analyzer.dataTypeList, | ||
"author" → analyzer.author, | ||
"url" → analyzer.url, | ||
"license" → analyzer.license, | ||
"id" → analyzer.id)) | ||
|
||
implicit val fileArtifactWrites = OWrites[FileArtifact](fileArtifact ⇒ Json.obj( | ||
"attributes" → fileArtifact.attributes)) | ||
|
||
implicit val dataArtifactWrites = Json.writes[DataArtifact] | ||
implicit val dataActifactReads = Json.reads[DataArtifact] | ||
|
||
implicit val artifactWrites = OWrites[Artifact](artifact ⇒ artifact match { | ||
case dataArtifact: DataArtifact ⇒ dataArtifactWrites.writes(dataArtifact) | ||
case fileArtifact: FileArtifact ⇒ fileArtifactWrites.writes(fileArtifact) | ||
}) | ||
|
||
implicit val jobStatusWrites = Writes[JobStatus.Type](jobStatus ⇒ JsString(jobStatus.toString)) | ||
|
||
implicit val jobWrites = OWrites[Job](job ⇒ Json.obj( | ||
"id" → job.id, | ||
"analyzerId" → job.analyzerId, | ||
"status" → job.status, | ||
"date" → job.date, | ||
"artifact" → job.artifact)) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- app/models/JsonFormat.scala | ||
+++ app/models/JsonFormat.scala | ||
@@ -1,39 +1,30 @@ | ||
package models | ||
|
||
-import scala.annotation.implicitNotFound | ||
- | ||
-import play.api.libs.json.Json | ||
import play.api.libs.json.Json.toJsFieldJsValueWrapper | ||
-import play.api.libs.json.Writes | ||
-import scala.concurrent.Future | ||
-import play.api.libs.json.JsObject | ||
-import scala.util.Success | ||
-import scala.util.Failure | ||
-import play.api.libs.json.JsString | ||
-import play.api.libs.json.OWrites | ||
+import play.api.libs.json._ | ||
|
||
object JsonFormat { | ||
- implicit val analyzerWrites = Writes[Analyzer](analyzer ⇒ Json.obj( | ||
+ implicit val analyzerWrites: Writes[Analyzer] = Writes[Analyzer](analyzer ⇒ Json.obj( | ||
"name" → analyzer.name, | ||
"version" → analyzer.version, | ||
"description" → analyzer.description, | ||
"dataTypeList" → analyzer.dataTypeList, | ||
"id" → analyzer.id)) | ||
|
||
- implicit val fileArtifactWrites = OWrites[FileArtifact](fileArtifact ⇒ Json.obj( | ||
+ implicit val fileArtifactWrites: OWrites[FileArtifact] = OWrites[FileArtifact](fileArtifact ⇒ Json.obj( | ||
"attributes" → fileArtifact.attributes)) | ||
|
||
- implicit val dataArtifactWrites = Json.writes[DataArtifact] | ||
- implicit val dataActifactReads = Json.reads[DataArtifact] | ||
+ implicit val dataArtifactWrites: OWrites[DataArtifact] = Json.writes[DataArtifact] | ||
+ implicit val dataActifactReads: Reads[DataArtifact] = Json.reads[DataArtifact] | ||
|
||
- implicit val artifactWrites = OWrites[Artifact](artifact ⇒ artifact match { | ||
+ implicit val artifactWrites: OWrites[Artifact] = OWrites[Artifact] { | ||
case dataArtifact: DataArtifact ⇒ dataArtifactWrites.writes(dataArtifact) | ||
case fileArtifact: FileArtifact ⇒ fileArtifactWrites.writes(fileArtifact) | ||
- }) | ||
+ } | ||
|
||
- implicit val jobStatusWrites = Writes[JobStatus.Type](jobStatus ⇒ JsString(jobStatus.toString)) | ||
+ implicit val jobStatusWrites: Writes[JobStatus.Type] = Writes[JobStatus.Type](jobStatus ⇒ JsString(jobStatus.toString)) | ||
|
||
- implicit val jobWrites = OWrites[Job](job ⇒ Json.obj( | ||
+ implicit val jobWrites: OWrites[Job] = OWrites[Job](job ⇒ Json.obj( | ||
"id" → job.id, | ||
"analyzerId" → job.analyzerId, | ||
"status" → job.status, |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
package util | ||
|
||
import scala.BigDecimal | ||
import scala.collection.JavaConversions.asScalaBuffer | ||
|
||
import com.typesafe.config.ConfigValueType.{ BOOLEAN, NULL, NUMBER, STRING } | ||
import com.typesafe.config.{ ConfigList, ConfigObject, ConfigValue } | ||
import play.api.Configuration | ||
import play.api.libs.json.{ JsArray, JsBoolean, JsNull, JsNumber, JsObject, JsString, OWrites, Writes } | ||
import play.api.libs.json._ | ||
|
||
import com.typesafe.config.{ ConfigList, ConfigObject, ConfigValue } | ||
import com.typesafe.config.ConfigValueType.{ BOOLEAN, NULL, NUMBER, STRING } | ||
import scala.collection.JavaConversions.asScalaBuffer | ||
|
||
object JsonConfig { | ||
implicit val configValueWrites: Writes[ConfigValue] = Writes((value: ConfigValue) ⇒ value match { | ||
case v: ConfigObject ⇒ configWrites.writes(Configuration(v.toConfig())) | ||
implicit def configValueWrites: Writes[ConfigValue] = Writes[ConfigValue] { | ||
case v: ConfigObject ⇒ configWrites.writes(Configuration(v.toConfig)) | ||
case v: ConfigList ⇒ JsArray(v.toSeq.map(x ⇒ configValueWrites.writes(x))) | ||
case v if v.valueType == NUMBER ⇒ JsNumber(BigDecimal(v.unwrapped.asInstanceOf[java.lang.Number].toString)) | ||
case v if v.valueType == BOOLEAN ⇒ JsBoolean(v.unwrapped.asInstanceOf[Boolean]) | ||
case v if v.valueType == NULL ⇒ JsNull | ||
case v if v.valueType == STRING ⇒ JsString(v.unwrapped.asInstanceOf[String]) | ||
}) | ||
} | ||
|
||
implicit val configWrites = OWrites { (cfg: Configuration) ⇒ | ||
implicit def configWrites: OWrites[Configuration] = OWrites[Configuration] { cfg ⇒ | ||
JsObject(cfg.subKeys.map(key ⇒ key → configValueWrites.writes(cfg.underlying.getValue(key))).toSeq) | ||
} | ||
} |
Empty file.
Empty file.