Skip to content

Commit

Permalink
Fix various deprecation and other warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesname committed Mar 6, 2024
1 parent d15c27a commit 4627bac
Show file tree
Hide file tree
Showing 36 changed files with 94 additions and 101 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ logBuffered := false
logLevel := Level.Info
ThisBuild / organization := "eu.ehri-project"

val projectScalaVersion = "2.13.12"
val projectScalaVersion = "2.13.13"
val appName = "docview"

val backendVersion = "0.15.1"
Expand Down
60 changes: 30 additions & 30 deletions modules/admin/app/client/json/package.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package client

import models.json._
import models.{Entity, EntityType, _}
import models._
import play.api.Logger
import play.api.libs.functional.syntax._
import play.api.libs.json.{JsObject, KeyPathNode, _}
import play.api.libs.json._
import utils.EnumUtils

package object json {
Expand Down Expand Up @@ -68,7 +68,7 @@ package object json {
}

implicit object permissionGrantJson extends ClientWriteable[PermissionGrant] {
private implicit val permissionGrantFormat = Json.format[PermissionGrantF]
private implicit val permissionGrantFormat: OFormat[models.PermissionGrantF] = Json.format[PermissionGrantF]
implicit val clientFormat: Format[PermissionGrant] = (
JsPath.format(permissionGrantFormat) and
(__ \ "accessor").lazyFormatNullable[Accessor](accessorJson.clientFormat) and
Expand All @@ -84,7 +84,7 @@ package object json {
}

implicit object linkJson extends ClientWriteable[Link] {
private implicit val linkFormat = Json.format[LinkF]
private implicit val linkFormat: OFormat[models.LinkF] = Json.format[LinkF]
val clientFormat: Format[Link] = (
JsPath.format[LinkF](linkFormat) and
(__ \ "targets").formatSeqOrEmpty(anyModelJson.clientFormat) and
Expand All @@ -111,7 +111,7 @@ package object json {
}

implicit object versionJson extends ClientWriteable[Version] {
private implicit val fFormat = Json.format[VersionF]
private implicit val fFormat: OFormat[models.VersionF] = Json.format[VersionF]
implicit val clientFormat: Format[Version] = (
JsPath.format[VersionF](fFormat) and
(__ \ "event").lazyFormatNullable(systemEventJson.clientFormat) and
Expand All @@ -130,7 +130,7 @@ package object json {
}

implicit object systemEventJson extends ClientWriteable[SystemEvent] {
private implicit val fFormat = Json.format[SystemEventF]
private implicit val fFormat: OFormat[models.SystemEventF] = Json.format[SystemEventF]

implicit val clientFormat: Format[SystemEvent] = (
JsPath.format[SystemEventF](fFormat) and
Expand Down Expand Up @@ -182,42 +182,42 @@ package object json {
}

implicit object documentaryUnitDescriptionJson extends ClientWriteable[DocumentaryUnitDescriptionF] {
private implicit val accessPointFormat = accessPointJson.clientFormat
private implicit val datePeriodFormat = datePeriodJson.clientFormat
private implicit val isadGIdentityFormat = Json.format[IsadGIdentity]
private implicit val isadGContextFormat = Json.format[IsadGContext]
private implicit val isadGContentFormat = Json.format[IsadGContent]
private implicit val isadGConditionsFormat = Json.format[IsadGConditions]
private implicit val isadGMaterialsFormat = Json.format[IsadGMaterials]
private implicit val isadGControlFormat = Json.format[IsadGControl]
private implicit val accessPointFormat: Format[models.AccessPoint] = accessPointJson.clientFormat
private implicit val datePeriodFormat: Format[models.DatePeriodF] = datePeriodJson.clientFormat
private implicit val isadGIdentityFormat: OFormat[models.IsadGIdentity] = Json.format[IsadGIdentity]
private implicit val isadGContextFormat: OFormat[models.IsadGContext] = Json.format[IsadGContext]
private implicit val isadGContentFormat: OFormat[models.IsadGContent] = Json.format[IsadGContent]
private implicit val isadGConditionsFormat: OFormat[models.IsadGConditions] = Json.format[IsadGConditions]
private implicit val isadGMaterialsFormat: OFormat[models.IsadGMaterials] = Json.format[IsadGMaterials]
private implicit val isadGControlFormat: OFormat[models.IsadGControl] = Json.format[IsadGControl]
val clientFormat: Format[DocumentaryUnitDescriptionF] = Json.format[DocumentaryUnitDescriptionF]
}

implicit object historicalAgentDescriptionJson extends ClientWriteable[HistoricalAgentDescriptionF] {
private implicit val accessPointFormat = accessPointJson.clientFormat
private implicit val datePeriodFormat = datePeriodJson.clientFormat
private implicit val isaarDetailsFormat = Json.format[IsaarDetail]
private implicit val isaarControlFormat = Json.format[IsaarControl]
private implicit val accessPointFormat: Format[models.AccessPoint] = accessPointJson.clientFormat
private implicit val datePeriodFormat: Format[models.DatePeriodF] = datePeriodJson.clientFormat
private implicit val isaarDetailsFormat: OFormat[models.IsaarDetail] = Json.format[IsaarDetail]
private implicit val isaarControlFormat: OFormat[models.IsaarControl] = Json.format[IsaarControl]
val clientFormat: Format[HistoricalAgentDescriptionF] = Json.format[HistoricalAgentDescriptionF]
}

implicit object repositoryDescriptionJson extends ClientWriteable[RepositoryDescriptionF] {
private implicit val addressFormat = addressJson.clientFormat
private implicit val accessPointFormat = accessPointJson.clientFormat
private implicit val isdiahDetailsFormat = Json.format[IsdiahDetails]
private implicit val isdiahAccessFormat = Json.format[IsdiahAccess]
private implicit val isdiahServicesFormat = Json.format[IsdiahServices]
private implicit val isdiahControlFormat = Json.format[IsdiahControl]
private implicit val addressFormat: Writes[models.AddressF] = addressJson.clientFormat
private implicit val accessPointFormat: Format[models.AccessPoint] = accessPointJson.clientFormat
private implicit val isdiahDetailsFormat: OFormat[models.IsdiahDetails] = Json.format[IsdiahDetails]
private implicit val isdiahAccessFormat: OFormat[models.IsdiahAccess] = Json.format[IsdiahAccess]
private implicit val isdiahServicesFormat: OFormat[models.IsdiahServices] = Json.format[IsdiahServices]
private implicit val isdiahControlFormat: OFormat[models.IsdiahControl] = Json.format[IsdiahControl]
val clientFormat: Format[RepositoryDescriptionF] = Json.format[RepositoryDescriptionF]
}

implicit object conceptDescriptionJson extends ClientWriteable[ConceptDescriptionF] {
private implicit val accessPointFormat = accessPointJson.clientFormat
private implicit val accessPointFormat: Format[models.AccessPoint] = accessPointJson.clientFormat
lazy val clientFormat: Format[ConceptDescriptionF] = Json.format[ConceptDescriptionF]
}

implicit object historicalAgentJson extends ClientWriteable[HistoricalAgent] {
private implicit val haDescFmt = historicalAgentDescriptionJson.clientFormat
private implicit val haDescFmt: Format[models.HistoricalAgentDescriptionF] = historicalAgentDescriptionJson.clientFormat
private val fFormat = Json.format[HistoricalAgentF]

val clientFormat: Format[HistoricalAgent] = (
Expand All @@ -230,7 +230,7 @@ package object json {
}

implicit object repositoryJson extends ClientWriteable[Repository] {
private implicit val repoDescFmt = repositoryDescriptionJson.clientFormat
private implicit val repoDescFmt: Format[models.RepositoryDescriptionF] = repositoryDescriptionJson.clientFormat
private val fFormat = Json.format[RepositoryF]

val clientFormat: Format[Repository] = (
Expand All @@ -243,7 +243,7 @@ package object json {
}

implicit object documentaryUnitJson extends ClientWriteable[DocumentaryUnit] {
private implicit val docDescFmt = documentaryUnitDescriptionJson.clientFormat
private implicit val docDescFmt: Format[models.DocumentaryUnitDescriptionF] = documentaryUnitDescriptionJson.clientFormat
private val fFormat = Json.format[DocumentaryUnitF]
lazy val clientFormat: Format[DocumentaryUnit] = (
JsPath.format(fFormat) and
Expand All @@ -256,7 +256,7 @@ package object json {
}

implicit object virtualUnitJson extends ClientWriteable[VirtualUnit] {
private implicit val vuDescFmt = documentaryUnitDescriptionJson.clientFormat
private implicit val vuDescFmt: Format[models.DocumentaryUnitDescriptionF] = documentaryUnitDescriptionJson.clientFormat
private val fFormat = Json.format[VirtualUnitF]

lazy val clientFormat: Format[VirtualUnit] = (
Expand Down Expand Up @@ -297,7 +297,7 @@ package object json {

implicit object conceptJson extends ClientWriteable[Concept] {

private implicit val fdFormat = conceptDescriptionJson.clientFormat
private implicit val fdFormat: Format[models.ConceptDescriptionF] = conceptDescriptionJson.clientFormat
implicit val fFormat: Format[ConceptF] = Json.format[ConceptF]
val clientFormat: Format[Concept] = (
JsPath.format[ConceptF](fFormat) and
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/app/controllers/users/UserProfiles.scala
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ case class UserProfiles @Inject()(
Ok(views.html.admin.userProfile.list(request.page, request.params))
}

def export: Action[AnyContent] = AdminAction.async { implicit request =>
def `export`: Action[AnyContent] = AdminAction.async { implicit request =>
for {
accounts <- accounts.findAll(PageParams.empty.withoutLimit)
users <- userDataApi.list[UserProfile](PageParams.empty.withoutLimit)
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/app/models/OaiPmhIdentity.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object OaiPmhIdentity {
val Day = Value("YYYY-MM-DD")
val Second = Value("YYYY-MM-DDThh:mm:ssZ")

implicit val _format = EnumUtils.enumFormat(Granularity)
implicit val _format: Format[models.OaiPmhIdentity.Granularity.Value] = EnumUtils.enumFormat(Granularity)
}

implicit val _format: Format[OaiPmhIdentity] = Json.format[OaiPmhIdentity]
Expand Down
1 change: 1 addition & 0 deletions modules/admin/app/models/UrlSetConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package models

import akka.http.scaladsl.model.HttpMethods


case class UrlNameMap(url: String, name: String)

case class UrlSetConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ case class SqlImportDatasetService @Inject()(db: Database, actorSystem: ActorSys
db.withTransaction { implicit conn =>
val inserts = info.map { item =>
Seq[NamedParameter](
'repo_id -> repoId,
'id -> item.id,
'name -> item.name,
'type -> item.src,
'content_type -> item.contentType,
'item_id -> item.fonds.filter(_.trim.nonEmpty),
'sync -> item.sync,
'status -> item.status,
'comments -> item.notes
Symbol("repo_id") -> repoId,
Symbol("id") -> item.id,
Symbol("name") -> item.name,
Symbol("type") -> item.src,
Symbol("content_type") -> item.contentType,
Symbol("item_id") -> item.fonds.filter(_.trim.nonEmpty),
Symbol("sync") -> item.sync,
Symbol("status") -> item.status,
Symbol("comments") -> item.notes
)
}
val q = """INSERT INTO import_dataset (repo_id, id, name, type, content_type, item_id, sync, status, comments)
Expand Down
5 changes: 1 addition & 4 deletions modules/admin/app/services/ingest/XmlFormatter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import akka.stream.alpakka.xml.{Characters, EndElement, ParseEvent, StartElement
import akka.stream.scaladsl.Flow
import akka.stream.stage.{GraphStage, GraphStageLogic, InHandler, OutHandler}
import akka.stream.{Attributes, FlowShape, Inlet, Outlet}
import javax.xml.stream.events.EndDocument


object XmlFormatter {
def format(indent: Int = 4): Flow[ParseEvent, ParseEvent, NotUsed] = Flow.fromGraph(XmlFormatter(indent))
Expand Down Expand Up @@ -79,9 +79,6 @@ protected[ingest] case class XmlFormatter(indent: Int) extends GraphStage[FlowSh
state = SeenData
push(out, e)

case e: EndDocument =>
emitMultiple(out, List(Characters("\n"), e))

case e =>
push(out, e)
}
Expand Down
4 changes: 2 additions & 2 deletions modules/backend/src/main/scala/utils/EnumUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object EnumUtils {

def enumWrites[E <: Enumeration]: Writes[E#Value] = Writes[E#Value](v => JsString(v.toString))

def enumFormat[E <: Enumeration](enum: E): Format[E#Value] = Format(enumReads(enum), enumWrites)
def enumFormat[E <: Enumeration](`enum`: E): Format[E#Value] = Format(enumReads(enum), enumWrites)

/**
* Constructs a simple mapping for a text field (mapped as `scala.Enumeration`)
Expand All @@ -36,7 +36,7 @@ object EnumUtils {
*
* @param enum the Enumeration#Value
*/
def enumMapping[E <: Enumeration](enum: E): Mapping[E#Value] = Forms.of(enumFormBinder(enum))
def enumMapping[E <: Enumeration](`enum`: E): Mapping[E#Value] = Forms.of(enumFormBinder(enum))

/**
* Default formatter for `scala.Enumeration`
Expand Down
4 changes: 2 additions & 2 deletions modules/backend/src/main/scala/utils/binders/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import scala.annotation.tailrec
*/
package object binders {

def bindableEnum[E <: Enumeration](enum: E): PathBindable[E#Value] = new PathBindable[E#Value] {
def bindableEnum[E <: Enumeration](`enum`: E): PathBindable[E#Value] = new PathBindable[E#Value] {
def bind(key: String, value: String): Either[String, enum.Value] =
enum.values.find(_.toString.toLowerCase == value.toLowerCase) match {
case Some(v) => Right(v)
Expand All @@ -27,7 +27,7 @@ package object binders {
def unbind(key: String, value: E#Value): String = value.toString.toLowerCase
}

def queryStringBinder[E <: Enumeration](enum: E)(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[E#Value] =
def queryStringBinder[E <: Enumeration](`enum`: E)(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[E#Value] =
new QueryStringBindable[E#Value] {
override def bind(key: String, params: Map[String, Seq[String]]): Option[Either[String, E#Value]] =
for (v <- stringBinder.bind(key, params)) yield v match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import scala.concurrent.duration._

class ByteStringResizerSpec extends PlaySpecification {

private implicit val as = ActorSystem.create("testing")
private implicit val mat = Materializer(as)
private implicit val as: akka.actor.ActorSystem = ActorSystem.create("testing")
private implicit val mat: akka.stream.Materializer = Materializer(as)

def count(size: Int, bytes: ByteString*): Int = Await.result(
Source.apply(bytes.toList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import services.data.{AuthenticatedUser, DataService, DataServiceBuilder, DataUs
import java.time.ZonedDateTime
import scala.concurrent.Future.{successful => immediate}
import scala.concurrent.{ExecutionContext, Future}
import scala.language.higherKinds


/**
Expand Down
8 changes: 4 additions & 4 deletions modules/core/src/main/scala/models/Annotation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ object Annotation {
import Ontology._
import EnumUtils.enumMapping

private implicit val anyModelReads = Model.Converter.restReads
private implicit val userProfileMetaReads = UserProfile.UserProfileResource.restReads
private lazy implicit val systemEventReads = SystemEvent.SystemEventResource.restReads
private implicit val accessorReads = Accessor.Converter.restReads
private implicit val anyModelReads: Reads[models.Model] = Model.Converter.restReads
private implicit val userProfileMetaReads: Reads[models.UserProfile] = UserProfile.UserProfileResource.restReads
private lazy implicit val systemEventReads: Reads[models.SystemEvent] = SystemEvent.SystemEventResource.restReads
private implicit val accessorReads: Reads[models.Accessor] = Accessor.Converter.restReads

implicit val metaReads: Reads[Annotation] = (
__.read[AnnotationF] and
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/main/scala/models/AuthoritativeSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ object AuthoritativeSet {
import Entity._
import eu.ehri.project.definitions.Ontology._

private implicit val systemEventReads = SystemEvent.SystemEventResource.restReads
private implicit val accessorReads = Accessor.Converter.restReads
private implicit val systemEventReads: Reads[models.SystemEvent] = SystemEvent.SystemEventResource.restReads
private implicit val accessorReads: Reads[models.Accessor] = Accessor.Converter.restReads

implicit val metaReads: Reads[AuthoritativeSet] = (
__.read[AuthoritativeSetF] and
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/main/scala/models/Concept.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ object Concept {
import Entity._
import ConceptF._

private implicit val systemEventReads = SystemEvent.SystemEventResource.restReads
private implicit val vocabularyReads = Vocabulary.VocabularyResource.restReads
private implicit val systemEventReads: Reads[models.SystemEvent] = SystemEvent.SystemEventResource.restReads
private implicit val vocabularyReads: Reads[models.Vocabulary] = Vocabulary.VocabularyResource.restReads

implicit val metaReads: Reads[Concept] = (
__.read[ConceptF] and
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/main/scala/models/Group.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object Group {
import Entity._
import Ontology._

private lazy implicit val systemEventReads = SystemEvent.SystemEventResource.restReads
private lazy implicit val systemEventReads: Reads[SystemEvent] = SystemEvent.SystemEventResource.restReads

implicit val metaReads: Reads[Group] = (
__.read[GroupF] and
Expand All @@ -59,7 +59,7 @@ object Group {
val restReads: Reads[Group] = metaReads
}

val form = Form(
val form: Form[GroupF] = Form(
mapping(
ISA -> ignored(EntityType.Group),
ID -> optional(text),
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/main/scala/models/HistoricalAgent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ object HistoricalAgent {
import Ontology._
import utils.EnumUtils.enumMapping

private implicit val systemEventReads = SystemEvent.SystemEventResource.restReads
private implicit val authoritativeSetReads = AuthoritativeSet.AuthoritativeSetResource.restReads
private implicit val systemEventReads: Reads[models.SystemEvent] = SystemEvent.SystemEventResource.restReads
private implicit val authoritativeSetReads: Reads[models.AuthoritativeSet] = AuthoritativeSet.AuthoritativeSetResource.restReads

implicit val metaReads: Reads[HistoricalAgent] = (
__.read[HistoricalAgentF] and
Expand Down
6 changes: 3 additions & 3 deletions modules/core/src/main/scala/models/Link.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ object Link {
import play.api.libs.functional.syntax._
import EnumUtils.enumMapping

private implicit val userProfileMetaReads = models.UserProfile.UserProfileResource.restReads
private implicit val accessPointReads = models.AccessPoint.Converter.restReads
private implicit val systemEventReads = SystemEvent.SystemEventResource.restReads
private implicit val userProfileMetaReads: Reads[models.UserProfile] = models.UserProfile.UserProfileResource.restReads
private implicit val accessPointReads: Reads[models.AccessPoint] = models.AccessPoint.Converter.restReads
private implicit val systemEventReads: Reads[models.SystemEvent] = SystemEvent.SystemEventResource.restReads

implicit val metaReads: Reads[Link] = (
__.read[LinkF] and
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/main/scala/models/UserProfile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ object UserProfile {
import Ontology._
import UserProfileF._

private implicit val groupReads = Group.GroupResource.restReads
private implicit val systemEventReads = SystemEvent.SystemEventResource.restReads
private implicit val groupReads: Reads[models.Group] = Group.GroupResource.restReads
private implicit val systemEventReads: Reads[models.SystemEvent] = SystemEvent.SystemEventResource.restReads

implicit val metaReads: Reads[UserProfile] = (
__.read[UserProfileF] and
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/main/scala/models/Vocabulary.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object Vocabulary {
import Ontology._
import VocabularyF._

private implicit val systemEventReads = SystemEvent.SystemEventResource.restReads
private implicit val systemEventReads: Reads[models.SystemEvent] = SystemEvent.SystemEventResource.restReads

implicit val metaReads: Reads[Vocabulary] = (
__.read[VocabularyF] and
Expand Down
2 changes: 1 addition & 1 deletion modules/guides/app/models/Guide.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object Guide {
val DEFAULT_PAGE = "default_page"
val CSS = "css"

implicit val form = Form(
implicit val form: Form[models.Guide] = Form(
mapping(
OBJECTID -> ignored(Option.empty[Long]),
NAME -> nonEmptyText,
Expand Down
2 changes: 1 addition & 1 deletion modules/guides/app/models/GuidePage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ object GuidePage {
val Nowhere = Value("nowhere")
}

implicit val form = Form(
implicit val form: Form[models.GuidePage] = Form(
mapping(
OBJECTID -> ignored(Option.empty[Long]),
LAYOUT -> enumMapping(Layout),
Expand Down
Loading

0 comments on commit 4627bac

Please sign in to comment.