Skip to content

Instantly share code, notes, and snippets.

@makotan
Created January 10, 2012 23:44
Show Gist options
  • Save makotan/1591964 to your computer and use it in GitHub Desktop.
Save makotan/1591964 to your computer and use it in GitHub Desktop.
Scala版ワークステートエンジン構想・・・第二版 rev1
class Sample02 {
import sburi.b1._
import scala.reflect.BeanInfo
@BeanInfo
class Sample02Entity(
var id:Long = 0 ,
var name : String = "" ,
var status : String = "")
class Sample02EntityPersistentPlugin extends PersistentPlugin[Sample02Entity,Long] {
import scala.collection.mutable.HashMap
val repo = new HashMap[Long,Sample02Entity]
var idGen = 0;
def setStatus(e :Sample02Entity , state : String) {
e.status = state
}
def save(e :Sample02Entity) = {
if(e.id == 0) {
idGen += 1
e.id = idGen
}
repo += ((e.id,e))
}
def getStatus(e :Sample02Entity) :Option[String] = {
e.status match {
case null => None
case "" => None
case status => Some(status)
}
}
def get(id:Long) : Option[Sample02Entity] = {
repo.get(id)
}
}
class Sample02Builder extends SburiBuilder {
type IdType = Long
type Entity = Sample02Entity
val persistent = new Sample02EntityPersistentPlugin()
val start = StartActivity("Start")
val process = ProcessActivity("p1" , {e => })
val state = Activity("state" , List(status,useUpdate,useDelete) )
val end = EndActivity("End")
this += start %% process
this += process %% state
this += state %% end
//this += end %% state // compile error
//this += state %% start // compile error
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment