Skip to content

Commit

Permalink
Actually set htmlGenerator in Application.scala; for "Make HTML gener…
Browse files Browse the repository at this point in the history
…ation configurable API Scala" #120

- Selenium suite passes (small trouble unrelated to this commit, probably related to the redirection to /history from /index)
- SBT tests pass
  • Loading branch information
jmvanel committed Feb 5, 2017
1 parent e66d10f commit b563d27
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,48 @@ import deductions.runtime.services.DefaultConfiguration
import deductions.runtime.utils.HTTPrequest
import deductions.runtime.html.Form2HTMLBanana
import org.w3.banana.RDFOps
import deductions.runtime.html.HtmlGeneratorInterface

/**
* ApplicationFacade implemeted with Jena,
* Application Facade implemented with Jena,
* but does not expose Jena nor Banana, just ApplicationFacadeInterface
*/
trait ApplicationFacadeJena
extends ApplicationFacadeInterface
with ApplicationFacade[ImplementationSettings.Rdf, ImplementationSettings.DATASET]
with RDFStoreLocalJenaProvider {

/** These 2 dependencies are transmitted below to the actual running instance `impl` */
val config: Configuration
val htmlGenerator: HtmlGeneratorInterface[Rdf#Node, Rdf#URI]

// TODO how to avoid these assignments ?
val conf = config
val ops1 = ops
lazy val htmlGenerator2 = htmlGenerator

override val impl: ApplicationFacadeImpl[Rdf, DATASET] = try {
/**
* NOTES:
* - mandatory that JenaModule (RDFModule) is first; otherwise ops may be null
* - mandatory that RDFStoreLocalJena1Provider is before ApplicationFacadeImpl;
* otherwise allNamedGraph may be null
*/
abstract class ApplicationFacadeImplJena
extends { override val config = conf } with ImplementationSettings.RDFModule
with RDFStoreLocalJenaProvider
with ApplicationFacadeImpl[ImplementationSettings.Rdf, ImplementationSettings.DATASET]
with RDFStoreLocalUserManagement[ImplementationSettings.Rdf, ImplementationSettings.DATASET]

new ApplicationFacadeImplJena {
val htmlGenerator = new Form2HTMLBanana[ImplementationSettings.Rdf] {
implicit val ops: RDFOps[ImplementationSettings.Rdf] = ops1
val config = conf
val nullURI = ops.URI("")
}
}
override val impl: ApplicationFacadeImpl[Rdf, DATASET] =
try {
/**
* NOTES:
* - mandatory that JenaModule (RDFModule) is first; otherwise ops may be null
* - mandatory that RDFStoreLocalJena1Provider is before ApplicationFacadeImpl;
* otherwise allNamedGraph may be null
*/
abstract class ApplicationFacadeImplJena
extends {
override val config = conf
override val htmlGenerator = htmlGenerator2
} with ImplementationSettings.RDFModule
with RDFStoreLocalJenaProvider
with ApplicationFacadeImpl[ImplementationSettings.Rdf, ImplementationSettings.DATASET]
with RDFStoreLocalUserManagement[ImplementationSettings.Rdf, ImplementationSettings.DATASET]

} catch {
case t: Throwable =>
t.printStackTrace()
throw t
}
new ApplicationFacadeImplJena {}

} catch {
case t: Throwable =>
t.printStackTrace()
throw t
}
}
9 changes: 7 additions & 2 deletions scala/forms_play/app/controllers/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ package controllers
import play.api.Play

import deductions.runtime.services.DefaultConfiguration
import deductions.runtime.html.Form2HTMLBanana
import deductions.runtime.jena.ImplementationSettings
import deductions.runtime.html.Form2HTMLObject

/** object Application in another file to facilitate redefinition */
object Application extends {
override val config = new DefaultConfiguration {
override implicit val config = new DefaultConfiguration {
override val serverPort = {
val port = Play.current.configuration.
getString("http.port")
Expand All @@ -21,5 +24,7 @@ object Application extends {
}
}
}
} with ApplicationTrait {
override lazy val htmlGenerator =
Form2HTMLObject.makeDefaultForm2HTML(config)(ops)
}
with ApplicationTrait

0 comments on commit b563d27

Please sign in to comment.