Skip to content

Commit 61f05a6

Browse files
committed
[#18] Conversion from taw type to item rep
1 parent 56a63af commit 61f05a6

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/main/scala/com/bio4j/dynamograph/model/go/TableGoSchema.scala

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import com.bio4j.dynamograph.model.GeneralSchema._
66
import ohnosequences.typesets._
77
import shapeless._
88
import ohnosequences.scarph.AnyProperty
9-
import shapeless.::
9+
import ohnosequences.tabula.impl.ImplicitConversions.{fromSDKRep, toSDKRep}
10+
import toSDKRep._
11+
import fromSDKRep._
12+
import com.amazonaws.services.dynamodbv2.model.AttributeValue
1013

1114

1215
object TableGoSchema {
@@ -32,6 +35,15 @@ object TableGoSchema {
3235
type Attributes = As
3336
type Representation = Rw
3437
case object vertexItem extends Item[table.type, As, Rw](table, attributes)
38+
39+
40+
def itemRep(sdkRep : Map[String, AttributeValue]) = {
41+
case object toSDKRepAndPropertyTuple extends Poly1 {
42+
implicit def default[A <: Singleton with AnyProperty] =
43+
at[A](a => (sdkRep, a))
44+
}
45+
attributes.map(fromSDKRep)
46+
}
3547
}
3648

3749

src/main/scala/com/bio4j/dynamograph/writer/VertexWriter.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import ohnosequences.typesets.TypeSet
77
import ohnosequences.tabula.impl.ImplicitConversions._
88
import toSDKRep._
99
import fromSDKRep._
10+
import shapeless.Poly1
1011
import ohnosequences.tabula.impl.actions.InHashKeyTable
1112
import ohnosequences.tabula.Active
1213
import ohnosequences.tabula.ThroughputStatus
14+
import ohnosequences.scarph.AnyProperty
1315

1416
trait AnyVertexWriter extends AnyWriter{
1517
type Element <: AnyDynamoVertex
@@ -21,8 +23,7 @@ class VertexWriter[V <: AnyDynamoVertex, R <: AnyRegion, As <:TypeSet, Rw <: Typ
2123
type Element = V
2224

2325
def write(rep: element.Rep): List[WriteType] = {
24-
25-
List(InHashKeyTable(vertexTable.table, Active(vertexTable.table, ServiceProvider.service.account,
26-
ThroughputStatus(1,1))) putItem vertexTable.vertexItem withValue rep)
26+
List(InHashKeyTable(vertexTable.table, Active(vertexTable.table, ServiceProvider.service.account,
27+
ThroughputStatus(1, 1))) putItem vertexTable.vertexItem withValue vertexTable.itemRep(rep))
2728
}
2829
}

0 commit comments

Comments
 (0)