-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dave Shiga
committed
May 4, 2015
1 parent
64f04c9
commit 47e0bb2
Showing
12 changed files
with
167 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...ain/scala/org/broadinstitute/dsde/agora/server/webservice/methods/MethodsAddHandler.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.broadinstitute.dsde.agora.server.webservice.methods | ||
|
||
import java.util.Date | ||
|
||
import akka.actor.Actor | ||
import com.novus.salat._ | ||
import com.novus.salat.global._ | ||
import org.broadinstitute.dsde.agora.server.dataaccess.AgoraDao | ||
import org.broadinstitute.dsde.agora.server.model.{AgoraAddRequest, AgoraEntity} | ||
import org.broadinstitute.dsde.agora.server.webservice.util.ServiceMessages | ||
import spray.routing.RequestContext | ||
|
||
/** | ||
* Created by dshiga on 5/4/15. | ||
*/ | ||
class MethodsAddHandler extends Actor { | ||
|
||
implicit val system = context.system | ||
|
||
def receive = { | ||
case ServiceMessages.Add(requestContext: RequestContext, agoraAddRequest: AgoraAddRequest) => | ||
add(requestContext, agoraAddRequest) | ||
context.stop(self) | ||
} | ||
|
||
private def add(requestContext: RequestContext, agoraAddRequest: AgoraAddRequest): Unit = { | ||
val agoraEntity = AgoraEntity.fromAgoraAddRequest(agoraAddRequest, createDate = Option(new Date())) | ||
val method = AgoraDao.createAgoraDao.insert(agoraEntity) | ||
context.parent ! grater[AgoraEntity].toJSON(method) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 4 additions & 9 deletions
13
...main/scala/org/broadinstitute/dsde/agora/server/webservice/util/ServiceHandlerProps.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,14 @@ | ||
package org.broadinstitute.dsde.agora.server.webservice.util | ||
|
||
import akka.actor.Props | ||
import org.broadinstitute.dsde.agora.server.webservice.methods.MethodsQueryHandler | ||
import org.broadinstitute.dsde.agora.server.webservice.methods.{MethodsAddHandler, MethodsQueryHandler} | ||
|
||
/** | ||
* Generic trait to safely provide props for creating service handler actors. | ||
* Override to supply specific service handler implementations (ie Standard, Mock) | ||
*/ | ||
trait ServiceHandlerProps { | ||
def methodsQueryHandlerProps: Props | ||
def methodsQueryHandlerProps = Props(new MethodsQueryHandler()) | ||
|
||
def methodsAddHandlerProps = Props(new MethodsAddHandler()) | ||
} | ||
|
||
/** | ||
* Provides props for the safe creation of standard service handler actors | ||
*/ | ||
trait StandardServiceHandlerProps extends ServiceHandlerProps{ | ||
override def methodsQueryHandlerProps = Props(new MethodsQueryHandler()) | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/scala/org/broadinstitute/dsde/agora/server/webservice/util/ServiceMessages.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
package org.broadinstitute.dsde.agora.server.webservice.util | ||
|
||
import org.broadinstitute.dsde.agora.server.model.AgoraAddRequest | ||
import spray.routing.RequestContext | ||
|
||
/** | ||
* Case classes representing messages to pass to service handler actors | ||
*/ | ||
object ServiceMessages { | ||
case class Query(requestContext: RequestContext, namespace: String, name: String, id: Int) | ||
|
||
case class Add(requestContext: RequestContext, agoraAddRequest: AgoraAddRequest) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters