Source

grrdrr / gd_htsql_test.py

Full commit

from gd import *

graph = Graph()

op_organization = graph.add_node()
op_project = graph.add_node()
op_person = graph.add_node()
op_participation = graph.add_node()
hr_private_info = graph.add_node()
ws_workitem = graph.add_node()
ws_worklist = graph.add_node()
ws_dependency = graph.add_node()
wsx_issue = graph.add_node()
wsx_meeting = graph.add_node()
wsx_meeting_topic = graph.add_node()
wsx_standing_meeting = graph.add_node()
tb_invoice = graph.add_node()
tb_lineitem = graph.add_node()
tb_timeslip = graph.add_node()

organization_division_of_fk = graph.add_arc(op_organization, op_organization, 0.5)
project_organization_fk = graph.add_arc(op_project, op_organization, 0.5)
person_organization_fk = graph.add_arc(op_person, op_organization, 1.0)
participation_project_fk = graph.add_arc(op_participation, op_project, 1.0)
participation_person_fk = graph.add_arc(op_participation, op_person, 1.0)
private_info_person_fk = graph.add_arc(hr_private_info, op_person, 1.0)
workitem_project_fk = graph.add_arc(ws_workitem, op_project, 1.0)
workitem_worklist_fk = graph.add_arc(ws_workitem, ws_worklist, 0.5)
worklist_workitem_fk = graph.add_arc(ws_worklist, ws_workitem, 1.0)
worklist_person_fk = graph.add_arc(ws_worklist, op_person, 0.5)
dependency_of_workitem_fk = graph.add_arc(ws_dependency, ws_workitem, 1.0)
dependency_on_workitem_fk = graph.add_arc(ws_dependency, ws_workitem, 1.0)
issue_workitem_fk = graph.add_arc(wsx_issue, ws_workitem, 1.0)
issue_person_fk = graph.add_arc(wsx_issue, op_person, 0.5)
meeting_workitem_fk = graph.add_arc(wsx_meeting, ws_workitem, 1.0)
meeting_topic_meeting_fk = graph.add_arc(wsx_meeting_topic, wsx_meeting, 1.0)
standing_meeting_meeting_fk = graph.add_arc(wsx_standing_meeting, wsx_meeting, 1.0)
invoice_organization_fk = graph.add_arc(tb_invoice, op_organization, 0.5)
lineitem_invoice_fk = graph.add_arc(tb_lineitem, tb_invoice, 1.0)
timeslip_participation_fk = graph.add_arc(tb_timeslip, op_participation, 1.0)
timeslip_lineitem_fk = graph.add_arc(tb_timeslip, tb_lineitem, 0.5)
timeslip_workitem_fk = graph.add_arc(tb_timeslip, ws_workitem, 0.5)

op_organization.set_label("op.organization")
op_project.set_label("op.project")
op_person.set_label("op.person")
op_participation.set_label("op.participation")
hr_private_info.set_label("hr.private_info")
ws_workitem.set_label("ws.workitem")
ws_worklist.set_label("ws.worklist")
ws_dependency.set_label("ws.dependency")
wsx_issue.set_label("wsx.issue")
wsx_meeting.set_label("wsx.meeting")
wsx_meeting_topic.set_label("wsx.meeting_topic")
wsx_standing_meeting.set_label("wsx.standing_meeting")
tb_invoice.set_label("tb.invoice")
tb_lineitem.set_label("tb.lineitem")
tb_timeslip.set_label("tb.timeslip")

organization_division_of_fk.set_label("division_of")
project_organization_fk.set_label("organization")
person_organization_fk.set_label("organization")
participation_project_fk.set_label("project")
participation_person_fk.set_label("person")
private_info_person_fk.set_label("person")
workitem_project_fk.set_label("project")
workitem_worklist_fk.set_label("worklist")
worklist_workitem_fk.set_label("workitem")
worklist_person_fk.set_label("assigned_to")
dependency_of_workitem_fk.set_label("of")
dependency_on_workitem_fk.set_label("on")
issue_workitem_fk.set_label("workitem")
issue_person_fk.set_label("reported_by")
meeting_workitem_fk.set_label("workitem")
meeting_topic_meeting_fk.set_label("meeting")
standing_meeting_meeting_fk.set_label("meeting")
invoice_organization_fk.set_label("organization")
lineitem_invoice_fk.set_label("invoice")
timeslip_participation_fk.set_label("participation")
timeslip_lineitem_fk.set_label("lineitem")
timeslip_workitem_fk.set_label("workitem")

graph.set_style(
        background_color=(0.5, 0.5, 0.5),
        node_color=(0.0, 0.0, 0.5),
        arc_color=(0.5, 0.0, 0.0),
        text_color=(1.0, 1.0, 1.0),
        font_size=18.0)

stream = open('gd_htsql_test.png', 'wb')
graph.draw(stream)