1 package gr.grnet.aquarium.model
3 import javax.persistence._
4 import java.util.{HashSet, Set}
6 @javax.persistence.Entity
7 @Table(name = "RESOURCE_TYPE")
9 new NamedQuery(name = "restypeFromType",
10 query = "select rt from ResourceType rt where rt.resType = :type")
12 class ResourceType extends Id {
14 @Column(name = "TYPE")
17 @Column(name = "NAME")
20 @OneToMany(mappedBy = "restype", targetEntity = classOf[ConsumableResource],
21 cascade = Array(CascadeType.ALL))
22 var consResources : Set[ConsumableResource] = new HashSet[ConsumableResource]()
24 @ManyToMany(targetEntity = classOf[ServiceTemplate],
25 mappedBy = "resTypes",
26 cascade= Array(CascadeType.ALL))
27 var srvTemplates : Set[ServiceTemplate] = new HashSet[ServiceTemplate]()
31 def CPU = getResourceByType(0x1, "CPU")
32 def RAM = getResourceByType(0x2, "RAM")
33 def DISKSPACE = getResourceByType(0x4, "DISKSPACE")
34 def NETBANDWIDTH = getResourceByType(0x8, "NETBANDWIDTH")
35 def LICENSE = getResourceByType(0x10, "LICENSE")
37 private def getResourceByType(restype : Int, name : String) : ResourceType = {
38 val res = DB.findAll[ResourceType]("restypeFromType",
39 "type" -> restype).headOption
43 val rt = new ResourceType