Skip to content

Commit

Permalink
M3-122: prepping release
Browse files Browse the repository at this point in the history
  • Loading branch information
hohonuuli committed Jun 12, 2020
1 parent 5db4c8e commit fc9c32c
Show file tree
Hide file tree
Showing 47 changed files with 1,325 additions and 917 deletions.
56 changes: 38 additions & 18 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,41 +1,46 @@
val akkaVersion = "2.4.7"
val auth0Version = "3.10.2"
val auth0Version = "3.10.3"
val codecVersion = "1.14"
val configVersion = "1.4.0"
val derbyVersion = "10.15.2.0"
val eclipselinkVersion = "2.7.6"
val eclipselinkVersion = "2.7.7"
val gsonJavatimeVersion = "1.1.1"
val gsonVersion = "2.8.6"
val h2Version = "1.4.200"
val hikariVersion = "3.4.2"
val hikariVersion = "3.4.5"
val jansiVersion = "1.18"
val javamelodyVersion = "1.82.0"
val jettyVersion = "9.4.27.v20200227"
val jsonVersion = "3.6.7"
val javamelodyVersion = "1.83.0"
val jettyVersion = "9.4.30.v20200611"
val jsonVersion = "3.6.8"
val jtaVersion = "1.1"
val jtdsVersion = "1.3.1"
val junitVersion = "4.13"
val logbackVersion = "1.2.3"
val logbackVersion = "1.3.0-alpha4"
val oracleVersion = "19.3.0.0"
val postgresqlVersion = "42.2.11"
val rxjavaVersion = "3.0.1"
val scalatestVersion = "3.1.1"
val postgresqlVersion = "42.2.14"
val rxjavaVersion = "3.0.4"
val scalatestVersion = "3.1.2"
val scalatraVersion = "2.7.0"
val scilubeVersion = "2.0.7.jre11"
val servletVersion = "4.0.1"
val slf4jVersion = "1.7.30"
val slf4jVersion = "1.8.0-beta4"
val sqlserverVersion = "8.2.2.jre11"
val uuidgenVersion = "0.1.3"
val vcr4jVersion = "4.0.2"
val zeromqVersion = "0.5.2"

Global / onChangedBuildSource := ReloadOnSourceChanges

addCommandAlias(
"fix",
"clean;scalafix RemoveUnused;scalafix LeakingImplicitClassVal;scalafmtAll;compile"
)

lazy val buildSettings = Seq(
organization := "org.mbari.vars",
version := "0.6.3",
scalaVersion in ThisBuild := "2.13.1",
crossScalaVersions := Seq("2.13.1"),
version := "0.7.0",
scalaVersion in ThisBuild := "2.13.2",
crossScalaVersions := Seq("2.13.2"),
organizationName := "Monterey Bay Aquarium Research Institute",
startYear := Some(2017),
licenses += ("Apache-2.0", new URL(
Expand Down Expand Up @@ -63,15 +68,30 @@ lazy val dependencySettings = Seq(
)

lazy val optionSettings = Seq(
semanticdbEnabled := true, // enable SemanticDB,
semanticdbVersion := scalafixSemanticdb.revision,
scalacOptions ++= Seq(
"-deprecation",
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-encoding",
"UTF-8", // yes, this is 2 args
"-feature",
"UTF-8", // yes, this is 2 args. Specify character encoding used by source files.
"-explaintypes", // Explain type errors in more detail.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-unchecked",
"-Xlint"
"-Xlint",
"-Yrangepos", // required by SemanticDB compiler plugin
"-Ywarn-dead-code", // Warn when dead code is identified.
"-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined.
"-Ywarn-numeric-widen", // Warn when numerics are widened.
"-Ywarn-unused:implicits", // Warn if an implicit parameter is unused.
"-Ywarn-unused:imports", // Warn if an import selector is not referenced.
"-Ywarn-unused:locals", // Warn if a local definition is unused.
"-Ywarn-unused:params", // Warn if a value parameter is unused.
"-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused.
"-Ywarn-unused:privates", // Warn if a private member is unused.
"-Ywarn-value-discard" // Warn when non-Unit expression results are unused.
),
javacOptions ++= Seq("-target", "11", "-source", "11"),
updateOptions := updateOptions.value.withCachedResolution(true)
Expand Down
8 changes: 4 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.4")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.17")
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.1.0")
addSbtPlugin("com.github.atais" % "sbt-eclipselink-static-weave" % "0.1.1")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.0")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.4.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.2")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.5.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.12")

Expand Down
1 change: 0 additions & 1 deletion src/main/scala/JettyMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import org.eclipse.jetty.webapp.WebAppContext
import org.mbari.vars.annotation.Constants
import org.mbari.vars.annotation.messaging.zeromq.ZeroMQPublisher
import org.scalatra.servlet.ScalatraListener
import org.slf4j.LoggerFactory

object JettyMain {

Expand Down
3 changes: 0 additions & 3 deletions src/main/scala/ScalatraBootstrap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@

import java.util.concurrent.Executors

import com.typesafe.config.ConfigFactory
import javax.servlet.ServletContext
import org.mbari.vars.annotation.{AppConfig, Constants}
import org.mbari.vars.annotation.api.v1._
import org.mbari.vars.annotation.api.v2._
import org.mbari.vars.annotation.controllers._
import org.mbari.vars.annotation.dao.jpa.JPADAOFactory
import org.mbari.vars.annotation.messaging.zeromq.ZeroMQPublisher
import org.scalatra.LifeCycle
import org.slf4j.LoggerFactory

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/org/mbari/vars/annotation/AppConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.mbari.vars.annotation

import com.typesafe.config.{Config, ConfigFactory}
import com.typesafe.config.Config
import org.slf4j.LoggerFactory

import scala.util.Try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ class AnnotationV1Api(controller: AnnotationController)(implicit val executor: E
get("/imagereference/:uuid") {
val uuid = params
.getAs[UUID]("uuid")
.getOrElse(halt(BadRequest(toJson(ErrorMsg(400, "A image reference 'uuid' parameter is required")))))
.getOrElse(
halt(BadRequest(toJson(ErrorMsg(400, "A image reference 'uuid' parameter is required"))))
)
controller
.findByImageReferenceUUID(uuid)
.map(_.asJava)
Expand All @@ -218,11 +220,17 @@ class AnnotationV1Api(controller: AnnotationController)(implicit val executor: E
validateRequest() // Apply API security
val videoReferenceUUID = params
.getAs[UUID]("video_reference_uuid")
.getOrElse(halt(BadRequest(toJson(ErrorMsg(400, "A 'video_reference_uuid' parameter is required")))))
.getOrElse(
halt(BadRequest(toJson(ErrorMsg(400, "A 'video_reference_uuid' parameter is required"))))
)
val concept =
params.get("concept").getOrElse(halt(BadRequest(toJson(ErrorMsg(400, "A 'concept' parameter is required")))))
params
.get("concept")
.getOrElse(halt(BadRequest(toJson(ErrorMsg(400, "A 'concept' parameter is required")))))
val observer =
params.get("observer").getOrElse(halt(BadRequest(toJson(ErrorMsg(400, "An 'observer' parameter is required")))))
params
.get("observer")
.getOrElse(halt(BadRequest(toJson(ErrorMsg(400, "An 'observer' parameter is required")))))
val observationDate = params.getAs[Instant]("observation_timestamp").getOrElse(Instant.now())
val timecode = params.getAs[Timecode]("timecode")
val elapsedTime = params.getAs[Duration]("elapsed_time_millis")
Expand All @@ -233,9 +241,14 @@ class AnnotationV1Api(controller: AnnotationController)(implicit val executor: E

if (timecode.isEmpty && elapsedTime.isEmpty && recordedDate.isEmpty) {
halt(
BadRequest(toJson(ErrorMsg(400,
"One or more of the following indices into the video are required: timecode, elapsed_time_millis, recorded_date"
)))
BadRequest(
toJson(
ErrorMsg(
400,
"One or more of the following indices into the video are required: timecode, elapsed_time_millis, recorded_date"
)
)
)
)
}

Expand Down Expand Up @@ -266,7 +279,14 @@ class AnnotationV1Api(controller: AnnotationController)(implicit val executor: E
.map(annos => toJson(annos.asJava))
case _ =>
halt(
BadRequest(toJson(ErrorMsg(400, "Posts to /bulk only accept JSON body (i.e. Content-Type: application/json)")))
BadRequest(
toJson(
ErrorMsg(
400,
"Posts to /bulk only accept JSON body (i.e. Content-Type: application/json)"
)
)
)
)
}
}
Expand All @@ -275,7 +295,9 @@ class AnnotationV1Api(controller: AnnotationController)(implicit val executor: E
validateRequest() // Apply API security
val uuid = params
.getAs[UUID]("uuid")
.getOrElse(halt(BadRequest(toJson(ErrorMsg(400, "An observation 'uuid' parameter is required")))))
.getOrElse(
halt(BadRequest(toJson(ErrorMsg(400, "An observation 'uuid' parameter is required"))))
)
val videoReferenceUUID = params.getAs[UUID]("video_reference_uuid")
val concept = params.get("concept")
val observer = params.get("observer")
Expand Down Expand Up @@ -303,7 +325,11 @@ class AnnotationV1Api(controller: AnnotationController)(implicit val executor: E
)
.map({
case None =>
halt(NotFound(toJson(ErrorMsg(404, s"An annotation with observation_uuid of $uuid was not found"))))
halt(
NotFound(
toJson(ErrorMsg(404, s"An annotation with observation_uuid of $uuid was not found"))
)
)
case Some(ann) => toJson(ann)
}) // Convert to JSON

Expand All @@ -319,7 +345,14 @@ class AnnotationV1Api(controller: AnnotationController)(implicit val executor: E
.map(annos => toJson(annos.asJava))
case _ =>
halt(
BadRequest(toJson(ErrorMsg(400, "Puts to /bulk only accept JSON body (i.e. Content-Type: application/json)")))
BadRequest(
toJson(
ErrorMsg(
400,
"Puts to /bulk only accept JSON body (i.e. Content-Type: application/json)"
)
)
)
)
}
}
Expand All @@ -336,7 +369,14 @@ class AnnotationV1Api(controller: AnnotationController)(implicit val executor: E
.map(annos => toJson(annos.asJava))
case _ =>
halt(
BadRequest(toJson(ErrorMsg(400, "Puts to tapetime only accept JSON body (i.e. Content-Type: application/json)")))
BadRequest(
toJson(
ErrorMsg(
400,
"Puts to tapetime only accept JSON body (i.e. Content-Type: application/json)"
)
)
)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ class AssociationV1Api(controller: AssociationController)(implicit val executor:
// Find an association
get("/:uuid") {
val uuid =
params.getAs[UUID]("uuid").getOrElse(halt(BadRequest(toJson(ErrorMsg(400, "Please provide a 'uuid' parameter")))))
params
.getAs[UUID]("uuid")
.getOrElse(halt(BadRequest(toJson(ErrorMsg(400, "Please provide a 'uuid' parameter")))))
controller
.findByUUID(uuid)
.map({
case None => halt(NotFound(toJson(ErrorMsg(400, s"An Association with a UUID of $uuid was not found"))))
case None =>
halt(
NotFound(toJson(ErrorMsg(400, s"An Association with a UUID of $uuid was not found")))
)
case Some(v) => toJson(v)
})
}
Expand All @@ -58,7 +63,8 @@ class AssociationV1Api(controller: AssociationController)(implicit val executor:
.getAs[UUID]("video_reference_uuid")
.getOrElse(halt(BadRequest(toJson(ErrorMsg(400, "Please provide a video-reference 'uuid'")))))
val linkName =
params.get("link_name")
params
.get("link_name")
.getOrElse(halt(BadRequest(toJson(ErrorMsg(400, "A 'link_name' parameter is required")))))
val concept = params.get("concept")
controller
Expand All @@ -72,11 +78,12 @@ class AssociationV1Api(controller: AssociationController)(implicit val executor:
.getAs[UUID]("observation_uuid")
.getOrElse(halt(BadRequest(toJson(ErrorMsg(400, "Please provide an 'observation_uuid'")))))
val linkName =
params.get("link_name")
params
.get("link_name")
.getOrElse(halt(BadRequest(toJson(ErrorMsg(400, "A 'link_name' parameter is required")))))
val toConcept = params.get("to_concept").getOrElse(Association.TO_CONCEPT_SELF)
val linkValue = params.get("link_value").getOrElse(Association.LINK_VALUE_NIL)
val mimeType = params.get("mime_type").getOrElse("text/plain")
val toConcept = params.get("to_concept").getOrElse(Association.TO_CONCEPT_SELF)
val linkValue = params.get("link_value").getOrElse(Association.LINK_VALUE_NIL)
val mimeType = params.get("mime_type").getOrElse("text/plain")
val associationUuid = params.getAs[UUID]("association_uuid")
controller.create(uuid, linkName, toConcept, linkValue, mimeType, associationUuid).map(toJson)
}
Expand Down Expand Up @@ -187,9 +194,9 @@ class AssociationV1Api(controller: AssociationController)(implicit val executor:
post("/conceptassociations") {
request.getHeader("Content-Type") match {
case "application/json" =>
val b = request.body
val limit = params.getAs[Int]("limit")
val offset = params.getAs[Int]("offset")
val b = request.body
params.getAs[Int]("limit")
params.getAs[Int]("offset")
val conceptAssociationRequest = fromJson(b, classOf[ConceptAssociationRequest])
controller
.findByConceptAssociationRequest(conceptAssociationRequest)
Expand Down
Loading

0 comments on commit fc9c32c

Please sign in to comment.