SlideShare a Scribd company logo
Scala	
  Domain	
  Modeling	
  
and	
  Architecture	
  
Experience	
  Report	
  
                           Hossam	
  Karim	
  
for {!
      !
      locus    Chromosome ⤞ Gene ⤞ Locus!
         if Locus    range!
!
     path    locus ⤞ Sequence ⤞ nucleotide!
        if nucleotide alignment (_ > 89)!
!
} yield path!
 
inputMessage >>= fasta >>= {   	
  
        case n: Nucleotide ⇒ !
          ("media" → "nucleotide") ~> n.giNumber   	
  
                                                 	
  
        case _: AminoAcid ⇒ !
          fail[String](!
             "Expected a ‘nucleotide’ Sequence")


                                                              	
  
        case _             ⇒ !


 	
   	
  
          fail[String](!
             "Expected a ‘single’ Sequence representation”)


 	
   	
  
   } >>= {

        for {

                                               	
   	
  
           	
  
          query ← meta.Sequence ⤞ meta.nucleotide


 	
  
               if meta.nucleotide.giNumber === _
        } yield query



   } >>= xml   	
  !
 
inputMessage >>= fasta >>= {   	
  
        case n: Nucleotide ⇒ !
          ("media" → "nucleotide") ~> n.giNumber   	
  
                                                 	
  
        case _: AminoAcid ⇒ !
          fail[String](!
             "Expected a ‘nucleotide’ Sequence")


                                                              	
  
        case _             ⇒ !


 	
   	
  
          fail[String](!
             "Expected a ‘single’ Sequence representation”)


 	
   	
  
   } >>= {

        for {

                                               	
   	
  
           	
  
          query ← meta.Sequence ⤞ meta.nucleotide


 	
  
               if meta.nucleotide.giNumber === _
        } yield query



   } >>= xml   	
  !
 
inputMessage >>= fasta >>= {   	
  
        case n: Nucleotide ⇒ !
          ("media" → "nucleotide") ~> n.giNumber   	
  
                                                 	
  
        case _: AminoAcid ⇒ !
          fail[String](!
             "Expected a ‘nucleotide’ Sequence")


                                                              	
  
        case _             ⇒ !


 	
   	
  
          fail[String](!
             "Expected a ‘single’ Sequence representation”)


 	
   	
  
   } >>= {

        for {

                                               	
   	
  
           	
  
          query ← meta.Sequence ⤞ meta.nucleotide


 	
  
               if meta.nucleotide.giNumber === _
        } yield query



   } >>= xml   	
  !
 
inputMessage >>= fasta >>= {   	
  
        case n: Nucleotide ⇒ !
          ("media" → "nucleotide") ~> n.giNumber   	
  
                                                 	
  
        case _: AminoAcid ⇒ !
          fail[String](!
             "Expected a ‘nucleotide’ Sequence")


                                                              	
  
        case _             ⇒ !


 	
   	
  
          fail[String](!
             "Expected a ‘single’ Sequence representation”)


 	
   	
  
   } >>= {

        for {

                                               	
   	
  
           	
  
          query ← meta.Sequence ⤞ meta.nucleotide


 	
  
               if meta.nucleotide.giNumber === _
        } yield query



   } >>= xml   	
  !
 
inputMessage >>= fasta >>= {   	
  
        case n: Nucleotide ⇒ !
          ("media" → "nucleotide") ~> n.giNumber   	
  
                                                 	
  
        case _: AminoAcid ⇒ !
          fail[String](!
             "Expected a ‘nucleotide’ Sequence")


                                                              	
  
        case _             ⇒ !


 	
   	
  
          fail[String](!
             "Expected a ‘single’ Sequence representation”)


 	
   	
  
   } >>= {

        for {

                                               	
   	
  
           	
  
          query ← meta.Sequence ⤞ meta.nucleotide


 	
  
               if meta.nucleotide.giNumber === _
        } yield query



   } >>= xml   	
  !
trait Message[A, H] {	
  
       val body: Validation[H, Option[A]]	
  
       val headers: H	
  
 }	
  
 	
  
 	
  
   trait MessageBuilder {	
  
         def build[A, H: Monoid](	
  
             body: Validation[H, Option[A]],    	
  
             headers: H): Message[A, H]	
  
   }	
  
trait Message[A, H] {	
  
       val body: Validation[H, Option[A]]	
  
       val headers: H	
  
 }	
  
 	
  
 	
  
   trait MessageBuilder {	
  
         def build[A, H: Monoid](	
  
             body: Validation[H, Option[A]],    	
  
             headers: H): Message[A, H]	
  
   }	
  
implicit def m2m[H]!
           (implicit builder: MessageBuilder, !
            monoid: Monoid[H]) =!
	
  
new Monad[({type λ[α] = Message[α, H]})#λ] {	
  
     	
  
     def pure[A](a: => A): Message[A, H] = . . .!
	
  
     def bind[A, B]!
          (a: Message[A, H], !
           f: (A) => Message[B, H]): Message[B, H] = . . .	
  
}	
  
def pure[A](a: => A) = !
   builder.build[A, H](Success(Option(a)), ∅[H])	
  	
  
def bind[A, B](!



                                                       	
   	
  
   m: Message[A, H], !
   f: (A) => Message[B, H]): Message[B, H] = {!
	
  
       val mb: Message[B, H] = m.body match {
              case Success(Some(value))   ⇒ f(value)


                                                                   	
  
              case Success(None)          ⇒!
                  builder.build[B, H](!
                      Success(Option.empty[B]), ∅[H])



                                                	
  
              case Failure(a)           ⇒!
                  builder.build[B, H](!
                      Failure(a), ∅[H] |+| a)



       	
                                                                 	
  
       }!
	
  
       builder.build[B, H](mb.body, m.headers |+| mb.headers)
}
implicit object BasicMessageBuilder extends MessageBuilder {         	
  
     def build[A, H: Monoid](!
       body: Validation[H, Option[A]], headers: H) =   	
  
       BasicMessage(body, headers)	
  
} 	
  
!
implicit object DiagnosisMessageBuilder extends!
    MessageBuilder {	
  
    def build[A, H: Monoid](!
       body: Validation[H, Option[A]], headers: H) =   	
  
       DiagnosisMessage(body, headers)   	
  
}	
  
 	
  
def body[A](value: A)(implicit builder: MessageBuilder) :!
      Message[A, HL] =     	
  
 builder.build(Success(Some(value)), List.empty[Header])      	
  
  	
  
    	
  
import Basic._!
//import Diagnosis._!
//import Transactional._!
!
         	
  
gene map {
  for (!
       e ← meta.Chromosome ⤞ meta.Gene !
            if meta.Gene.uuid === _.uuid!
  ) yield e     	
  
} >>= search           	
  
(genex <**> geney) (_ ++ _) >>=	
  
         header("media-type", "application/vnd.x.gene+json") >>= 	
  
           json	
  
 	
  
 	
  
for {	
  
       m        ← body(<gene xmlns="urn:model:gene:1.0">...</gene>)	
  
       gene ← xml(m)	
  
 } yield gene	
  
 	
  
 	
  
gene map {	
  
      for {	
  
          e ← meta.Gene ⤞ meta.Gene.uuid 	
  
                 if meta.Gene.uuid === _.uuid	
  
      } yield e	
  
} >>= search	
  	
  
import scalaz._!
import Scalaz._!
// profit!!
trait Resource {!
      val name: String!
} !
 	
  
trait Ontology extends Resource {!
      val nestingOntology: Option[Ontology]!
      val nestedOntology: List[Ontology]!
      val ownedType: List[Type]!
      val ownedRelation: List[Relation]!
}!
	
  
trait GraphResource {	
  
       this: Resource =>	
  
 }	
  
 	
  
 trait GraphVertex extends GraphResource {	
  
       this: Entity =>	
  
       val graphFeatures: List[PrimitiveFeature]	
  
       val master: Boolean	
  
       val rootToMasterEdge: GraphEdge with Relation	
  
       val masterToSelf: Option[GraphEdge with Relation] = None	
  
 }	
  
 	
  
 trait GraphEdge extends GraphResource {	
  
           this: Relation =>	
  
 }	
  	
  
trait RelationalResource {	
  
       this: Resource =>	
  
 }	
  
 	
  
 trait NamedRelationalResource          extends RelationalResource {	
  
       this: Resource =>	
  
       val relationalName: String	
  
 }	
  
 	
  
 	
  
 trait RelationalEntity extends NamedRelationalResource {	
  
       this: Entity =>	
  
 }	
  
 	
  
 trait RelationalCompositeFeature extends RelationalResource {	
  
       this: CompositeFeature =>	
  
       val mapping: Map[String, String]	
  
 }	
  
object Chromosome extends	
  
                        Entity	
  
                   with RelationalEntity!
           	
  	
  with GraphVertex	
  
                   with XmlElement {	
  
           self =>	
  
 	
  
           sealed trait ChromosomePart {	
  
                    val ownerType = self	
  
           }	
  
 	
  
           // Ontology Trait	
  
           val featuringType = self	
  
           val ownedFeature = chromatine :: Nil	
  
 	
  
           // XML Trait	
  
           val namespace = "urn:domain:chromosome:1.0"	
  
           val prefix = "chr"	
  
 	
  
           // Features	
  
           val chromatine =	
  
                    new Chromatine(	
  
                      name = "chromatine",	
  
                      ownerType = Chromosome,	
  
                      mapping = Map.empty[String, String]) 	
  
 }	
  	
  
implicit def enrich[A <: DomainModel](model: A) = new {	
  
      def metamodel: Option[Type] = Ontology.typeOf(model)	
  
}	
  
 	
  
def xmlFilter[A <: DomainModel] =	
  
      (model: A) ⇒ model.metamodel match {	
  
        case Some(_: XmlElement) ⇒ body(XmlModel[A](model))	
  
        case _ ⇒ fail[XmlModel[A]]!
          ("No XmlElement meta-model definition could be found")	
  
}	
  
 	
  
def ingoingEdges[A <: DomainModel] =	
  
      (model: A) ⇒ model.metamodel match {	
  
        case Some(vertex: GraphVertex) ⇒ !
             Ontology.edges.filter(_.target == vertex)	
  
        case _ ⇒ List.empty[GraphEdge]	
  
}	
  
implicit def enrich[A <: DomainModel](model: A) = new {	
  
      def metamodel: Option[Type] = Ontology.typeOf(model)	
  
}	
  
 	
  
def xmlFilter[A <: DomainModel] =	
  
      (model: A) ⇒ model.metamodel match {	
  
        case Some(_: XmlElement) ⇒ body(XmlModel[A](model))	
  
        case _ ⇒ fail[XmlModel[A]]!
          ("No XmlElement meta-model definition could be found")	
  
}	
  
 	
  
def ingoingEdges[A <: DomainModel] =	
  
      (model: A) ⇒ model.metamodel match {	
  
        case Some(vertex: GraphVertex) ⇒ !
             Ontology.edges.filter(_.target == vertex)	
  
        case _ ⇒ List.empty[GraphEdge]	
  
}	
  
trait Type extends Resource 	
  
       trait SimpleType extends Type	
  
       trait Entity extends Type!
!
       trait Relation extends Type 	
  
	
  
       trait   Feature[+T <: Type] extends Resource 	
  
       trait   SimpleFeature[+T <: SimpleType] extends Feature[T] 	
  
       trait   PrimitiveFeature extends SimpleFeature[Primitive] 	
  
       trait   EnumerationFeature extends SimpleFeature[Enumeration] 	
  
       trait   CompositeFeature extends SimpleFeature[Composite]	
  
       	
  
       trait   Primitive extends SimpleType 	
  
       trait   Enumeration extends SimpleType 	
  
       trait   Composite extends SimpleType	
  
       	
  
       	
  
trait PrimitiveLogic {	
  
       	
  
                               val resource: Primitive 	
  
	
  	
  	
   def ===[A](value: Primitive[A]): Operator = . . .	
  
           	
  	
  	
  	
  	
  	
  def in[A](values: PrimitiveList[A]): Operator = . . .	
  
}	
  	
  
	
  
	
  
def find(operator: Operator): Option[T]	
  
def list(operator: Operator): List[T]!
	
  
 	
  
import PrimitiveLogic._	
  
       	
  
dao list (Locus.locusUUID in list)	
  
 	
  
dao find (Locus.locusUUID === uuid)	
  	
  
import Logic._	
  
val validation =	
  
  Sequence.nucleotide.accession.accessionNumber !== x	
  
	
  
import GraphOps._	
  
val path =	
  
  Sequence.nucleotide ⤞	
  
       Sequence.protein ⤞	
  
               Locus.typeOfGene where (_ !== y)	
  	
  
for {!
      !
      locus    Chromosome ⤞ Gene ⤞ Locus!
         if Locus    range!
!
     path    locus ⤞ Sequence ⤞ nucleotide!
        if nucleotide alignment (_ > 89)!
!
} yield path!
trait Qvt[PIM, Query, View, PSM] {	
  
 	
  
         def query(pim: PIM): List[Query]	
  
 	
  
         def view(query: Query): View	
  
 	
  
         def transform(view: View): PSM	
  
         	
  
 }	
  
class GraphSimpleQvt(	
  
     ontologyProfile: OntologyProfile, 	
  
     graphProfile: GraphProfile)	
  
   extends SimpleQvt[Model, Package, GraphOntology] {	
  
          	
  
                 def query(pim: Model) = {	
  
                       walk[Package](pim)(_.getNestedPackages).	
  
                         filter(graphProfile.graphPredicate)	
  
                 }	
  
   	
  
                 def transform(view: Package) = graph(view)	
  
   	
  
                 def graph(element: Package): GraphOntology = {	
  
                       ...	
  
                 }	
  
                 .	
  
                 .	
  
                 .	
  
}	
  
def walk[A]	
  
      (element: A)	
  
      (f: A => Iterable[A]): List[A] = {	
  
        val children = f(element).toList	
  
        children ++ !
          (children.flatMap(walk(_, f)))	
  
}	
  
def packageName(element: Package): String =	
  
     Stream!
      .iterate(element)(_.getNestingPackage)	
  
      .takeWhile(!_.isInstanceOf[Model])	
  
      .map(_.getName)	
  
      .reverse	
  
      .mkString(".") //.scala rocks !!	
  
Thank	
  You	
  

More Related Content

What's hot

Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
CloudxLab
 
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
Sanjeev_Knoldus
 
Types and Immutability: why you should care
Types and Immutability: why you should careTypes and Immutability: why you should care
Types and Immutability: why you should care
Jean Carlo Emer
 
Scala 2013 review
Scala 2013 reviewScala 2013 review
Scala 2013 review
Sagie Davidovich
 
The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210
Mahmoud Samir Fayed
 
Lecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of TwenteLecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of Twente
Dirkjan Bussink
 
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
scalaconfjp
 
The Ring programming language version 1.7 book - Part 41 of 196
The Ring programming language version 1.7 book - Part 41 of 196The Ring programming language version 1.7 book - Part 41 of 196
The Ring programming language version 1.7 book - Part 41 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 40 of 212
The Ring programming language version 1.10 book - Part 40 of 212The Ring programming language version 1.10 book - Part 40 of 212
The Ring programming language version 1.10 book - Part 40 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 43 of 180
The Ring programming language version 1.5.1 book - Part 43 of 180The Ring programming language version 1.5.1 book - Part 43 of 180
The Ring programming language version 1.5.1 book - Part 43 of 180
Mahmoud Samir Fayed
 
Java script objects 2
Java script objects 2Java script objects 2
Java script objects 2
H K
 
G3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy AnnotationsG3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy Annotations
Iván López Martín
 
Scala best practices
Scala best practicesScala best practices
Scala best practices
Alexander Zaidel
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
andyrobinson8
 
The Ring programming language version 1.2 book - Part 20 of 84
The Ring programming language version 1.2 book - Part 20 of 84The Ring programming language version 1.2 book - Part 20 of 84
The Ring programming language version 1.2 book - Part 20 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.9 book - Part 41 of 210The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.9 book - Part 41 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 35 of 189
The Ring programming language version 1.6 book - Part 35 of 189The Ring programming language version 1.6 book - Part 35 of 189
The Ring programming language version 1.6 book - Part 35 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212
Mahmoud Samir Fayed
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kirill Rozov
 

What's hot (20)

Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
 
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
 
Types and Immutability: why you should care
Types and Immutability: why you should careTypes and Immutability: why you should care
Types and Immutability: why you should care
 
Scala 2013 review
Scala 2013 reviewScala 2013 review
Scala 2013 review
 
The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210
 
Lecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of TwenteLecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of Twente
 
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
 
The Ring programming language version 1.7 book - Part 41 of 196
The Ring programming language version 1.7 book - Part 41 of 196The Ring programming language version 1.7 book - Part 41 of 196
The Ring programming language version 1.7 book - Part 41 of 196
 
The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88
 
The Ring programming language version 1.10 book - Part 40 of 212
The Ring programming language version 1.10 book - Part 40 of 212The Ring programming language version 1.10 book - Part 40 of 212
The Ring programming language version 1.10 book - Part 40 of 212
 
The Ring programming language version 1.5.1 book - Part 43 of 180
The Ring programming language version 1.5.1 book - Part 43 of 180The Ring programming language version 1.5.1 book - Part 43 of 180
The Ring programming language version 1.5.1 book - Part 43 of 180
 
Java script objects 2
Java script objects 2Java script objects 2
Java script objects 2
 
G3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy AnnotationsG3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy Annotations
 
Scala best practices
Scala best practicesScala best practices
Scala best practices
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
 
The Ring programming language version 1.2 book - Part 20 of 84
The Ring programming language version 1.2 book - Part 20 of 84The Ring programming language version 1.2 book - Part 20 of 84
The Ring programming language version 1.2 book - Part 20 of 84
 
The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.9 book - Part 41 of 210The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.9 book - Part 41 of 210
 
The Ring programming language version 1.6 book - Part 35 of 189
The Ring programming language version 1.6 book - Part 35 of 189The Ring programming language version 1.6 book - Part 35 of 189
The Ring programming language version 1.6 book - Part 35 of 189
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2
 

Similar to Scala Domain Modeling and Architecture

ddd+scala
ddd+scaladdd+scala
ddd+scala
潤一 加藤
 
An introduction to property-based testing
An introduction to property-based testingAn introduction to property-based testing
An introduction to property-based testing
Vincent Pradeilles
 
Scala for Jedi
Scala for JediScala for Jedi
Scala for Jedi
Vladimir Parfinenko
 
First-Class Patterns
First-Class PatternsFirst-Class Patterns
First-Class Patterns
John De Goes
 
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
adrianoalmeida7
 
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
Eelco Visser
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
Aleksandar Prokopec
 
Scala taxonomy
Scala taxonomyScala taxonomy
Scala taxonomy
Radim Pavlicek
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?
Tomasz Wrobel
 
Pattern Matching in Scala
Pattern Matching in ScalaPattern Matching in Scala
Pattern Matching in Scala
Derek Chen-Becker
 
Metaprogramming in Haskell
Metaprogramming in HaskellMetaprogramming in Haskell
Metaprogramming in Haskell
Hiromi Ishii
 
Coding in Style
Coding in StyleCoding in Style
Coding in Style
scalaconfjp
 
Programming haskell chapter10
Programming haskell chapter10Programming haskell chapter10
Programming haskell chapter10
Kousuke Ruichi
 
Spock and Geb
Spock and GebSpock and Geb
Spock and Geb
Christian Baranowski
 
QuickCheck - Software Testing
QuickCheck - Software TestingQuickCheck - Software Testing
QuickCheck - Software Testing
Javran
 
Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014
Baruch Sadogursky
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEB
Howard Lewis Ship
 
Good functional programming is good programming
Good functional programming is good programmingGood functional programming is good programming
Good functional programming is good programming
kenbot
 
JavaScript Code Formatting With Prettier by Christopher Chedeau
JavaScript Code Formatting With Prettier by Christopher ChedeauJavaScript Code Formatting With Prettier by Christopher Chedeau
JavaScript Code Formatting With Prettier by Christopher Chedeau
React London 2017
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
Dmitry Sheiko
 

Similar to Scala Domain Modeling and Architecture (20)

ddd+scala
ddd+scaladdd+scala
ddd+scala
 
An introduction to property-based testing
An introduction to property-based testingAn introduction to property-based testing
An introduction to property-based testing
 
Scala for Jedi
Scala for JediScala for Jedi
Scala for Jedi
 
First-Class Patterns
First-Class PatternsFirst-Class Patterns
First-Class Patterns
 
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
 
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Scala taxonomy
Scala taxonomyScala taxonomy
Scala taxonomy
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?
 
Pattern Matching in Scala
Pattern Matching in ScalaPattern Matching in Scala
Pattern Matching in Scala
 
Metaprogramming in Haskell
Metaprogramming in HaskellMetaprogramming in Haskell
Metaprogramming in Haskell
 
Coding in Style
Coding in StyleCoding in Style
Coding in Style
 
Programming haskell chapter10
Programming haskell chapter10Programming haskell chapter10
Programming haskell chapter10
 
Spock and Geb
Spock and GebSpock and Geb
Spock and Geb
 
QuickCheck - Software Testing
QuickCheck - Software TestingQuickCheck - Software Testing
QuickCheck - Software Testing
 
Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEB
 
Good functional programming is good programming
Good functional programming is good programmingGood functional programming is good programming
Good functional programming is good programming
 
JavaScript Code Formatting With Prettier by Christopher Chedeau
JavaScript Code Formatting With Prettier by Christopher ChedeauJavaScript Code Formatting With Prettier by Christopher Chedeau
JavaScript Code Formatting With Prettier by Christopher Chedeau
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 

Recently uploaded

GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
Pravash Chandra Das
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Jeffrey Haguewood
 

Recently uploaded (20)

GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
 

Scala Domain Modeling and Architecture

  • 1. Scala  Domain  Modeling   and  Architecture   Experience  Report   Hossam  Karim  
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. for {! ! locus Chromosome ⤞ Gene ⤞ Locus! if Locus range! ! path locus ⤞ Sequence ⤞ nucleotide! if nucleotide alignment (_ > 89)! ! } yield path!
  • 8.
  • 9.
  • 10.
  • 11.   inputMessage >>= fasta >>= {   case n: Nucleotide ⇒ ! ("media" → "nucleotide") ~> n.giNumber     case _: AminoAcid ⇒ ! fail[String](! "Expected a ‘nucleotide’ Sequence")   case _ ⇒ !     fail[String](! "Expected a ‘single’ Sequence representation”)     } >>= { for {       query ← meta.Sequence ⤞ meta.nucleotide   if meta.nucleotide.giNumber === _ } yield query } >>= xml  !
  • 12.   inputMessage >>= fasta >>= {   case n: Nucleotide ⇒ ! ("media" → "nucleotide") ~> n.giNumber     case _: AminoAcid ⇒ ! fail[String](! "Expected a ‘nucleotide’ Sequence")   case _ ⇒ !     fail[String](! "Expected a ‘single’ Sequence representation”)     } >>= { for {       query ← meta.Sequence ⤞ meta.nucleotide   if meta.nucleotide.giNumber === _ } yield query } >>= xml  !
  • 13.   inputMessage >>= fasta >>= {   case n: Nucleotide ⇒ ! ("media" → "nucleotide") ~> n.giNumber     case _: AminoAcid ⇒ ! fail[String](! "Expected a ‘nucleotide’ Sequence")   case _ ⇒ !     fail[String](! "Expected a ‘single’ Sequence representation”)     } >>= { for {       query ← meta.Sequence ⤞ meta.nucleotide   if meta.nucleotide.giNumber === _ } yield query } >>= xml  !
  • 14.   inputMessage >>= fasta >>= {   case n: Nucleotide ⇒ ! ("media" → "nucleotide") ~> n.giNumber     case _: AminoAcid ⇒ ! fail[String](! "Expected a ‘nucleotide’ Sequence")   case _ ⇒ !     fail[String](! "Expected a ‘single’ Sequence representation”)     } >>= { for {       query ← meta.Sequence ⤞ meta.nucleotide   if meta.nucleotide.giNumber === _ } yield query } >>= xml  !
  • 15.   inputMessage >>= fasta >>= {   case n: Nucleotide ⇒ ! ("media" → "nucleotide") ~> n.giNumber     case _: AminoAcid ⇒ ! fail[String](! "Expected a ‘nucleotide’ Sequence")   case _ ⇒ !     fail[String](! "Expected a ‘single’ Sequence representation”)     } >>= { for {       query ← meta.Sequence ⤞ meta.nucleotide   if meta.nucleotide.giNumber === _ } yield query } >>= xml  !
  • 16. trait Message[A, H] {   val body: Validation[H, Option[A]]   val headers: H   }         trait MessageBuilder {   def build[A, H: Monoid](   body: Validation[H, Option[A]],   headers: H): Message[A, H]   }  
  • 17. trait Message[A, H] {   val body: Validation[H, Option[A]]   val headers: H   }         trait MessageBuilder {   def build[A, H: Monoid](   body: Validation[H, Option[A]],   headers: H): Message[A, H]   }  
  • 18. implicit def m2m[H]! (implicit builder: MessageBuilder, ! monoid: Monoid[H]) =!   new Monad[({type λ[α] = Message[α, H]})#λ] {     def pure[A](a: => A): Message[A, H] = . . .!   def bind[A, B]! (a: Message[A, H], ! f: (A) => Message[B, H]): Message[B, H] = . . .   }  
  • 19. def pure[A](a: => A) = ! builder.build[A, H](Success(Option(a)), ∅[H])    
  • 20. def bind[A, B](!     m: Message[A, H], ! f: (A) => Message[B, H]): Message[B, H] = {!   val mb: Message[B, H] = m.body match { case Success(Some(value)) ⇒ f(value)   case Success(None) ⇒! builder.build[B, H](! Success(Option.empty[B]), ∅[H])   case Failure(a) ⇒! builder.build[B, H](! Failure(a), ∅[H] |+| a)     }!   builder.build[B, H](mb.body, m.headers |+| mb.headers) }
  • 21. implicit object BasicMessageBuilder extends MessageBuilder {   def build[A, H: Monoid](! body: Validation[H, Option[A]], headers: H) =   BasicMessage(body, headers)   }   ! implicit object DiagnosisMessageBuilder extends! MessageBuilder {   def build[A, H: Monoid](! body: Validation[H, Option[A]], headers: H) =   DiagnosisMessage(body, headers)   }       def body[A](value: A)(implicit builder: MessageBuilder) :! Message[A, HL] =   builder.build(Success(Some(value)), List.empty[Header])      
  • 22. import Basic._! //import Diagnosis._! //import Transactional._! !   gene map { for (! e ← meta.Chromosome ⤞ meta.Gene ! if meta.Gene.uuid === _.uuid! ) yield e   } >>= search  
  • 23. (genex <**> geney) (_ ++ _) >>=   header("media-type", "application/vnd.x.gene+json") >>=   json           for {   m ← body(<gene xmlns="urn:model:gene:1.0">...</gene>)   gene ← xml(m)   } yield gene           gene map {   for {   e ← meta.Gene ⤞ meta.Gene.uuid   if meta.Gene.uuid === _.uuid   } yield e   } >>= search    
  • 25.
  • 26.
  • 27.
  • 28. trait Resource {! val name: String! } !     trait Ontology extends Resource {! val nestingOntology: Option[Ontology]! val nestedOntology: List[Ontology]! val ownedType: List[Type]! val ownedRelation: List[Relation]! }!  
  • 29. trait GraphResource {   this: Resource =>   }     trait GraphVertex extends GraphResource {   this: Entity =>   val graphFeatures: List[PrimitiveFeature]   val master: Boolean   val rootToMasterEdge: GraphEdge with Relation   val masterToSelf: Option[GraphEdge with Relation] = None   }     trait GraphEdge extends GraphResource {   this: Relation =>   }    
  • 30. trait RelationalResource {   this: Resource =>   }     trait NamedRelationalResource extends RelationalResource {   this: Resource =>   val relationalName: String   }       trait RelationalEntity extends NamedRelationalResource {   this: Entity =>   }     trait RelationalCompositeFeature extends RelationalResource {   this: CompositeFeature =>   val mapping: Map[String, String]   }  
  • 31. object Chromosome extends   Entity   with RelationalEntity!    with GraphVertex   with XmlElement {   self =>     sealed trait ChromosomePart {   val ownerType = self   }     // Ontology Trait   val featuringType = self   val ownedFeature = chromatine :: Nil     // XML Trait   val namespace = "urn:domain:chromosome:1.0"   val prefix = "chr"     // Features   val chromatine =   new Chromatine(   name = "chromatine",   ownerType = Chromosome,   mapping = Map.empty[String, String])   }    
  • 32. implicit def enrich[A <: DomainModel](model: A) = new {   def metamodel: Option[Type] = Ontology.typeOf(model)   }     def xmlFilter[A <: DomainModel] =   (model: A) ⇒ model.metamodel match {   case Some(_: XmlElement) ⇒ body(XmlModel[A](model))   case _ ⇒ fail[XmlModel[A]]! ("No XmlElement meta-model definition could be found")   }     def ingoingEdges[A <: DomainModel] =   (model: A) ⇒ model.metamodel match {   case Some(vertex: GraphVertex) ⇒ ! Ontology.edges.filter(_.target == vertex)   case _ ⇒ List.empty[GraphEdge]   }  
  • 33. implicit def enrich[A <: DomainModel](model: A) = new {   def metamodel: Option[Type] = Ontology.typeOf(model)   }     def xmlFilter[A <: DomainModel] =   (model: A) ⇒ model.metamodel match {   case Some(_: XmlElement) ⇒ body(XmlModel[A](model))   case _ ⇒ fail[XmlModel[A]]! ("No XmlElement meta-model definition could be found")   }     def ingoingEdges[A <: DomainModel] =   (model: A) ⇒ model.metamodel match {   case Some(vertex: GraphVertex) ⇒ ! Ontology.edges.filter(_.target == vertex)   case _ ⇒ List.empty[GraphEdge]   }  
  • 34. trait Type extends Resource   trait SimpleType extends Type   trait Entity extends Type! ! trait Relation extends Type     trait Feature[+T <: Type] extends Resource   trait SimpleFeature[+T <: SimpleType] extends Feature[T]   trait PrimitiveFeature extends SimpleFeature[Primitive]   trait EnumerationFeature extends SimpleFeature[Enumeration]   trait CompositeFeature extends SimpleFeature[Composite]     trait Primitive extends SimpleType   trait Enumeration extends SimpleType   trait Composite extends SimpleType      
  • 35. trait PrimitiveLogic {     val resource: Primitive         def ===[A](value: Primitive[A]): Operator = . . .              def in[A](values: PrimitiveList[A]): Operator = . . .   }         def find(operator: Operator): Option[T]   def list(operator: Operator): List[T]!       import PrimitiveLogic._     dao list (Locus.locusUUID in list)       dao find (Locus.locusUUID === uuid)    
  • 36. import Logic._   val validation =   Sequence.nucleotide.accession.accessionNumber !== x     import GraphOps._   val path =   Sequence.nucleotide ⤞   Sequence.protein ⤞   Locus.typeOfGene where (_ !== y)    
  • 37. for {! ! locus Chromosome ⤞ Gene ⤞ Locus! if Locus range! ! path locus ⤞ Sequence ⤞ nucleotide! if nucleotide alignment (_ > 89)! ! } yield path!
  • 38.
  • 39. trait Qvt[PIM, Query, View, PSM] {     def query(pim: PIM): List[Query]     def view(query: Query): View     def transform(view: View): PSM     }  
  • 40. class GraphSimpleQvt(   ontologyProfile: OntologyProfile,   graphProfile: GraphProfile)   extends SimpleQvt[Model, Package, GraphOntology] {     def query(pim: Model) = {   walk[Package](pim)(_.getNestedPackages).   filter(graphProfile.graphPredicate)   }     def transform(view: Package) = graph(view)     def graph(element: Package): GraphOntology = {   ...   }   .   .   .   }  
  • 41. def walk[A]   (element: A)   (f: A => Iterable[A]): List[A] = {   val children = f(element).toList   children ++ ! (children.flatMap(walk(_, f)))   }  
  • 42. def packageName(element: Package): String =   Stream! .iterate(element)(_.getNestingPackage)   .takeWhile(!_.isInstanceOf[Model])   .map(_.getName)   .reverse   .mkString(".") //.scala rocks !!  
  • 43.