GDBMS
Example application
1. Text of the script
entry after start session
prompt("Session entry message. Session id: "+str(this))
endentry
entry after start transaction on ("ROUTERS0085")
prompt("Transaction start entry message.")
endentry
entry before end transaction
prompt("End transaction entry message")
endentry
entry before end session
prompt("End session entry message Session with id="+str(this)+" is about to be ended." )
endentry
function retransact(a)
close_transaction()
trId=gettransactionid(a)
if trId#0
prompt("Transaction started with id "+str(trId))
else
prompt("Transaction creation error")
reset
endif
endfunction
username=prompt("Enter username")
password=prompt("Enter password")
graphname="ROUTERS0085"
userId=login(username, password)
if userId#0
prompt("Logged in as "+username)
else
prompt("Login error")
reset
endif
ssId=getsessionid(userId)
if ssId#0
prompt("Session started with id "+str(ssId))
else
prompt("Session start error")
reset
endif
if create_graph(graphname)
prompt("Graph created")
else
prompt("Graph creation error")
reset
endif
trId=gettransactionid(graphname)
if trId#0
prompt("Transaction started with id "+str(trId))
else
prompt("Transaction creation error")
reset
endif
;//=======================
;//=======create type info
;//=======================
class clRouters
string name
endclass
class clLinks
int metric
endclass
i=0
clRouters router
clLinks link
while i<5
router.name="R"+str(i+1)
r[i+1]=insert_node(router)
prompt(router.name+" was inserted. ")
i=i+1
endwhile
link.metric=1
insert_edge(link, r[1], r[2])
link.metric=1
insert_edge(link, r[2], r[5])
link.metric=1
insert_edge(link, r[5], r[4])
link.metric=2
insert_edge(link, r[3], r[1])
link.metric=3
insert_edge(link, r[2], r[3])
link.metric=4
insert_edge(link, r[2], r[4])
prompt("Link data inserted")
call retransact("ROUTERS0085")
;query for shortest path between r[1] and r[4]
qres="Query result: (Shortest path)"+nl()
foreach @0[getnode("clRouters.name", "R1")]s[getnode("clRouters.name", "R4")] as currentNode
qres=qres+currentNode.name
qres=qres+nl()
;prompt(currentNode.name)
if currentNode.name=="R2"
currentNode.name="R2 - changed in foreach"
endif
endforeach
prompt(qres)
;query for longest path between r[1] and r[4]
qres="Query result: (Longest path)"+nl()
foreach @0[getnode("clRouters.name", "R1")]l[getnode("clRouters.name", "R4")] as currentNode
qres=qres+currentNode.name
qres=qres+nl()
;prompt(currentNode.name)
endforeach
prompt(qres)
close_transaction()
close_session()