Skip to content

Commit 643399e

Browse files
committed
[#18] Migration to new versions of tabula, scarph and typesets
1 parent 8ffc2ea commit 643399e

File tree

6 files changed

+25
-43
lines changed

6 files changed

+25
-43
lines changed

src/main/scala/com/bio4j/dynamograph/AnyDynamoVertex.scala

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ import ohnosequences.tabula.AnyItem._
99
import ohnosequences.typesets._
1010

1111

12-
trait AnyDynamoVertex extends AnyVertex { dynamoVertex =>
13-
14-
type Tpe <: DynamoVertexType
15-
type Raw <: Tpe#VertexRecord#Values
12+
trait AnyDynamoVertex extends AnySealedVertex { dynamoVertex =>
1613

1714
val dao: AnyDynamoDbDao = ServiceProvider.dao
1815

19-
implicit def unsafeGetProperty[P <: AnyProperty: Property.Of[this.Tpe]#is](p: P) =
16+
implicit def unsafeGetProperty[P <: Singleton with AnyProperty: Property.Of[this.Tpe]#is](p: P) =
2017
new PropertyGetter[P](p) {
2118
def apply(rep: dynamoVertex.Rep): p.Raw = rep.get(p)
2219
}
@@ -59,13 +56,12 @@ trait AnyDynamoVertex extends AnyVertex { dynamoVertex =>
5956
}
6057
}
6158

62-
class DynamoVertex[VT <: Singleton with DynamoVertexType](val tpe: VT) extends AnyDynamoVertex {
59+
class DynamoVertex[VT <: Singleton with AnySealedVertexType](val tpe: VT) extends AnyDynamoVertex {
6360
type Tpe = VT
64-
final type Raw = VT#VertexRecord#Values
6561
}
6662

6763
object AnyDynamoVertex{
68-
type ofType[VT <: DynamoVertexType] = AnyDynamoVertex { type Tpe = VT }
64+
type ofType[VT <: Singleton with AnySealedVertexType] = AnyDynamoVertex { type Tpe = VT }
6965
}
7066

7167

src/main/scala/com/bio4j/dynamograph/DynamoVertexType.scala

Lines changed: 0 additions & 11 deletions
This file was deleted.

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,19 @@ import ohnosequences.scarph._
44
import com.bio4j.dynamograph.model.GeneralSchema._
55
import ohnosequences.typesets._
66
import ohnosequences.typesets.Represented._
7-
import com.bio4j.dynamograph.DynamoVertexType
87

98
object GoSchema {
109

11-
12-
10+
val goTermAttributes = id :~: name :~: comment :~: definition :~:
11+
case object GoTermRecord extends Record(goTermAttributes)
1312
// Vertex Type
14-
object GoTermType extends DynamoVertexType("GoTerm"){
15-
val attributes = id :~: name :~: comment :~: definition :~:
16-
case object record extends Record(attributes)
17-
}
18-
implicit val GoTermType_properties = GoTermType has GoTermType.attributes
19-
20-
21-
object GoNamespacesType extends DynamoVertexType("GoNamespace"){
22-
val attributes = id :~:
23-
case object record extends Record(attributes)
24-
}
25-
implicit val GoNamespacesType_properties = GoNamespacesType has GoNamespacesType.attributes
13+
object GoTermType extends SealedVertexType("GoTerm",GoTermRecord)
14+
implicit val GoTermType_properties = GoTermType has goTermAttributes
15+
16+
val goNamespacesAttributes = id :~:
17+
case object GoNamespacesRecord extends Record(goNamespacesAttributes)
18+
object GoNamespacesType extends SealedVertexType("GoNamespace", GoNamespacesRecord)
19+
implicit val GoNamespacesType_properties = GoNamespacesType has goNamespacesAttributes
2620

2721
// Edge Types
2822
case object HasPartType extends ManyToMany (GoTermType, "hasPart", GoTermType)

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
package com.bio4j.dynamograph.model.go
22

33
import ohnosequences.tabula._
4-
import com.bio4j.dynamograph.{DynamoVertexType, AnyDynamoVertex, AnyDynamoEdge}
4+
import com.bio4j.dynamograph.{AnyDynamoVertex, AnyDynamoEdge}
55
import com.bio4j.dynamograph.model.GeneralSchema._
66
import ohnosequences.typesets._
77
import shapeless._
88
import ohnosequences.tabula.impl.ImplicitConversions.{fromSDKRep, toSDKRep}
99
import toSDKRep._
1010
import fromSDKRep._
1111
import com.amazonaws.services.dynamodbv2.model.AttributeValue
12+
import ohnosequences.scarph.AnySealedVertexType
1213

1314

1415
object TableGoSchema {
1516

1617

1718
class VertexTable[
18-
VT <: DynamoVertexType,
19+
VT <: AnySealedVertexType,
1920
R <: AnyRegion
2021
](
2122
val vt : VT,
@@ -24,7 +25,7 @@ object TableGoSchema {
2425
){
2526
case object table extends HashKeyTable(tableName, id, region)
2627
type VertexTpe = VT
27-
case object vertexItem extends Item[table.type, vt.VertexRecord](table, vt.record)
28+
case object vertexItem extends Item(table, vt.record)
2829
}
2930

3031

src/main/scala/com/bio4j/dynamograph/reader/VertexReader.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ package com.bio4j.dynamograph.reader
33
import com.amazonaws.services.dynamodbv2.model.{AttributeValue, GetItemRequest}
44
import com.bio4j.dynamograph.model.go.TableGoSchema.VertexTable
55
import ohnosequences.tabula.AnyRegion
6-
import com.bio4j.dynamograph.{DynamoVertexType, AnyDynamoVertex}
6+
import com.bio4j.dynamograph.{AnyDynamoVertex}
77
import com.bio4j.dynamograph.model.GeneralSchema.id
88
import scala.collection.JavaConversions._
99
import com.bio4j.dynamograph.dynamodb.AnyDynamoDbExecutor
1010
import ohnosequences.typesets.TypeSet
11+
import ohnosequences.scarph.AnySealedVertexType
1112

1213

13-
class VertexReader[VT <: DynamoVertexType](val vertexType : VT ,val vertexTable : VertexTable[VT, _], val dbExecutor : AnyDynamoDbExecutor) extends AnyVertexReader{
14+
class VertexReader[VT <: AnySealedVertexType](val vertexType : VT ,val vertexTable : VertexTable[VT, _], val dbExecutor : AnyDynamoDbExecutor) extends AnyVertexReader{
1415
type VertexType = VT
1516

1617
def read(identifier : id.Raw) : ReturnType = {

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.bio4j.dynamograph.writer
22

33
import com.bio4j.dynamograph.model.go.TableGoSchema.VertexTable
44
import ohnosequences.tabula.AnyRegion
5-
import com.bio4j.dynamograph.{DynamoVertexType, ServiceProvider, AnyDynamoVertex}
5+
import com.bio4j.dynamograph.{ServiceProvider, AnyDynamoVertex}
66
import ohnosequences.typesets.TypeSet
77
import ohnosequences.tabula.impl.ImplicitConversions._
88
import toSDKRep._
@@ -11,18 +11,19 @@ import shapeless.Poly1
1111
import ohnosequences.tabula.impl.actions.InHashKeyTable
1212
import ohnosequences.tabula.Active
1313
import ohnosequences.tabula.ThroughputStatus
14+
import ohnosequences.scarph.{AnySealedVertexType, AnySealedVertex}
1415

1516
trait AnyVertexWriter extends AnyWriter{
1617
type Element <: AnyDynamoVertex
1718
}
1819

19-
class VertexWriter[V <: DynamoVertexType, R <: AnyRegion]
20+
class VertexWriter[V <: AnySealedVertexType, R <: AnyRegion]
2021
(val element: V, val vertexTable : VertexTable[V, R]) extends AnyVertexWriter {
2122

2223
type Element = V
2324

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

0 commit comments

Comments
 (0)