Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F76347265
ReadPdoResponseAggregator.scala
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Aug 7, 12:00
Size
1 KB
Mime Type
text/x-c++
Expires
Fri, Aug 9, 12:00 (2 d)
Engine
blob
Format
Raw Data
Handle
19690100
Attached To
R2664 SHRINE MedCo Fork
ReadPdoResponseAggregator.scala
View Options
package net.shrine.aggregation
import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable.Buffer
import net.shrine.protocol.ErrorResponse
import net.shrine.protocol.EventResponse
import net.shrine.protocol.ObservationResponse
import net.shrine.protocol.PatientResponse
import net.shrine.protocol.ReadPdoResponse
import net.shrine.protocol.Result
import net.shrine.protocol.ShrineResponse
import net.shrine.protocol.SingleNodeResult
/**
* @author ???
* @date ???
*/
class ReadPdoResponseAggregator extends Aggregator {
override def aggregate(results: Iterable[SingleNodeResult], errors: Iterable[ErrorResponse]): ShrineResponse = {
val eventBuffer: Buffer[EventResponse] = new ArrayBuffer
val patientBuffer: Buffer[PatientResponse] = new ArrayBuffer
val observationBuffer: Buffer[ObservationResponse] = new ArrayBuffer
//TODO handle errors
results.collect { case result @ Result(_, _, readPdoResponse: ReadPdoResponse) => (result, readPdoResponse) }.foreach {
case (result, readPdoResponse) => {
val response = transform(readPdoResponse, result)
eventBuffer ++= response.events
patientBuffer ++= response.patients
observationBuffer ++= response.observations
}
}
//TODO: What to do with passed-in errors?
ReadPdoResponse(eventBuffer, patientBuffer, observationBuffer)
}
/**
* This method is a no-op transformation but subclasses can override it
* and do something more interesting.
*/
protected def transform(entry: ReadPdoResponse, metadata: Result): ReadPdoResponse = entry
}
Event Timeline
Log In to Comment