# HG changeset patch # User Tomas Zeman # Date 1302627823 -7200 # Node ID 6e3d323f9ec5f6bc0ea09e4d9e1d8fb38fe5717d # Parent b3b5c577098275699595d3d384b5c2aa75de4aef d6a28603feb67d4d CDR table columns diff -r b3b5c5770982 -r 6e3d323f9ec5 src/main/scala/net/tz/lift/snippet/SnippetHelpers.scala --- a/src/main/scala/net/tz/lift/snippet/SnippetHelpers.scala Tue Apr 12 13:30:23 2011 +0200 +++ b/src/main/scala/net/tz/lift/snippet/SnippetHelpers.scala Tue Apr 12 19:03:43 2011 +0200 @@ -28,7 +28,7 @@ } object A { - def apply(href: String)(in: NodeSeq): NodeSeq = (new A(href))(in) + def apply(href: String, in: NodeSeq): NodeSeq = (new A(href))(in) def apply(href: String): A = new A(href) def apply(href: String, cnt: String): NodeSeq = (new A(href))(Text(cnt)) } diff -r b3b5c5770982 -r 6e3d323f9ec5 src/main/scala/radview/model/Account.scala --- a/src/main/scala/radview/model/Account.scala Tue Apr 12 13:30:23 2011 +0200 +++ b/src/main/scala/radview/model/Account.scala Tue Apr 12 19:03:43 2011 +0200 @@ -75,6 +75,7 @@ OrderBy(app, Ascending)) def byImsi(imsiVal: String) = Box(findAll(By(imsi, imsiVal))) + def byImsi(imsis: Seq[String]) = findAll(ByList(imsi, imsis)) } class RadCheckSub extends LongKeyedMapper[RadCheckSub] with ImsiAware with diff -r b3b5c5770982 -r 6e3d323f9ec5 src/main/scala/radview/model/Cdr.scala --- a/src/main/scala/radview/model/Cdr.scala Tue Apr 12 13:30:23 2011 +0200 +++ b/src/main/scala/radview/model/Cdr.scala Tue Apr 12 19:03:43 2011 +0200 @@ -31,9 +31,8 @@ OrderBy(radacctid, Ascending)) def fieldsForList = List(sid, ts, inBytes, outBytes, statusType, acctuniqueid, - username, groupname, realm, nasipaddress, nasportid, nasporttype, - acctsessiontime, acctauthentic, serviceType, framedProto, framedIp, - statusType, cell) + username, nasipaddress, nasporttype, acctsessiontime, serviceType, + framedProto, framedIp, statusType) import java.sql.{Date => SqlDate} implicit def d2sqlD(d: Date): SqlDate = new SqlDate(d.getTime) @@ -85,7 +84,8 @@ c1 <- cdr1 c2 <- tsMap.get(c1.sid.is) } yield { - CdrSession(c1.sid, c2.ts, c1.ts, c1.inBytes, c1.outBytes, c2.cell) + CdrSession(c1.sid, c2.ts, c1.ts, c1.inBytes, c1.outBytes, c2.cell, + c2.callingNo) } } } @@ -177,10 +177,12 @@ object activeTime extends MappedIntColName(this, "3GPP2_Active_Time", "3GPP2 Active Time") + object serviceOption extends MappedIntColName(this, "3GPP2_Service_Option", + "3GPP2 Service Option") } case class CdrSession(sid: String, start: Date, end: Date, inBytes: Long, - outBytes: Long, cellId: String) { + outBytes: Long, cellId: String, callingNo: Long) { def cell: Box[Cell] = Cell.findByKey(cellId) } diff -r b3b5c5770982 -r 6e3d323f9ec5 src/main/scala/radview/snippet/SessionSnippet.scala --- a/src/main/scala/radview/snippet/SessionSnippet.scala Tue Apr 12 13:30:23 2011 +0200 +++ b/src/main/scala/radview/snippet/SessionSnippet.scala Tue Apr 12 19:03:43 2011 +0200 @@ -88,11 +88,14 @@ } } +import radview.model.RadCheckSub + object CdrSessionTable { def apply(l: Iterable[CdrSession]): (NodeSeq => NodeSeq) = { - val cells: Map[String, Cell] = Map() ++ - (Cell.findAll(ByList(Cell.idpk, l.map { _.cellId }.toList.distinct)). - map { c => (c.idpk.is, c) }) + val accounts: Map[String, RadCheckSub] = Map() ++ + (RadCheckSub.byImsi(l.map { _.callingNo.toString }.toList.distinct). + map { r => (r.imsi.is, r) }) + Table[CdrSession](List( Column(Cdr.sid.displayName, { s: CdrSession => A(SessionSnippet.url(s), s.sid) } ), @@ -102,8 +105,10 @@ { s: CdrSession => Bytes.mb(s.inBytes) }, "td-right"), Column(Cdr.outBytes.displayName + " [MB]", { s: CdrSession => Bytes.mb(s.outBytes) }, "td-right"), - Column("Cell", { s: CdrSession => cells.get(s.cellId).map { c => - A(CellSnippet.url(CellView(c)), c.btsName.is) } getOrElse NodeSeq.Empty }) + Column(RadCheckSub.imsi.displayName, + { s: CdrSession => accounts.get(s.callingNo.toString).map { r => + A(AccountSnippet.url(ViewAccount(r)), r.imsi.asHtml) + } getOrElse NodeSeq.Empty }) ), l) } } @@ -123,12 +128,29 @@ def valF(f: MappedField[_, Cdr])(cdr: Cdr): NodeSeq = f.actualField(cdr).asHtml - Table[Cdr](fieldsForList.map { f => - new Column[Cdr](Text(f.displayName), valF(f) _, cssF(f) _) }, cdr) + val cells: Map[String, Cell] = Map() ++ + (Cell.findAll(ByList(Cell.idpk, cdr.map { _.cell.is }.toList.distinct)). + map { c => (c.idpk.is, c) }) + + val cdrCols = fieldsForList.map { f => + new Column[Cdr](Text(f.displayName), valF(f) _, cssF(f) _) } + + val cellCols = List(Cell.btsDesc, Cell.btsSysIdHex, Cell.bssIntDesc). + map { f => Column(f.displayName, + { cdr: Cdr => cells.get(cdr.cell.is).map { c => + val cnt = f.actualField(c).asHtml + if (f.name != Cell.btsSysIdHex.name) cnt + else A(CellSnippet.url(CellView(c)))(cnt) + } getOrElse NodeSeq.Empty }) + } + + val cdr2Cols = List(serviceOption, releaseInd).map { f => + new Column[Cdr](Text(f.displayName), valF(f) _, cssF(f) _) } + + Table[Cdr](cdrCols ++ cellCols ++ cdr2Cols, cdr) } def apply(s: CdrSession): (NodeSeq => NodeSeq) = apply(bySession(s)) } - // vim: set ts=2 sw=2 et: