def __init__(self, pcf_name): self.name = "navigator" self.slots = {} self.graph = Graph(Storage.read(pcf_name)) self.current_node = self.graph.add_node(None, Point(305, 150)) self.current_link = {"linkID": None, "roleID": None}
def create_mva1(self, form_data): pcf = Storage.read(self.pcf_name) if self.mva_form1 == "derived": # form = self.mva_form1_data # assert(form["datatype"] == form_data["datatype"]) # assert(form["name"] == form_data["name"]) # assert(form["sqldef"] == form_data["sqldef"]) # assert(form["nargs"] == form_data["nargs"] and form["nargs"] == str(1)) # assert(form["sort1"] == form_data["sort1"]) # assert(form["role1"] == form_data["role1"]) if not (form_data["name"] and form_data["sqldef"] and form_data["datatype"] and form_data["role1"]): return if form_data["sort1"] not in pcf.sorts: return sort = [ form_data["sort{0}".format(i + 1)] for i in range(int(form_data["nargs"])) ] roles = [ form_data["role{0}".format(i + 1)] for i in range(int(form_data["nargs"])) ] pcf.add_mva(form_data["name"], sort, form_data["datatype"], form_data["sqldef"], roles) self.mva_form1_data = { "datatype": None, "name": "", "sqldef": "", "sort1": self.current_sort, "role1": "ATTR", "nargs": "1", } Storage.write(pcf, self.pcf_name)
def render(self): views = [] pcf = Storage.read(self.pcf_name) views.append({ "cmd": "set_edit_view", "args": { "slot": "mainView", "template": "script#edit_base_template", "data": {}, } }) views.append({ "cmd": "set_pcf_sorts_view", "args": { "slot": "sortsMenu", "template": "script#pcf_sorts_template", "data": self.pcf_sorts_view_data(pcf, self.current_sort), } }) if self.current_sort is None: views.append({ "cmd": "set_sort_api_view", "args": { "slot": "sortView", "template": None, "data": None, } }) else: views.append({ "cmd": "set_sort_api_view", "args": { "slot": "sortView", "template": "script#sort_api_template", "data": self.pcf_api_view_data(pcf, self.current_sort, self.mva_form2), } }) if self.mva_form1 == "derived": views.append({ "cmd": "set_derived_mva_form", "args": { "slot": "mvaForm1", "template": "script#derived_mva_form_template", "data": self.derived_mva_form_data(pcf, self.mva_form1_data), } }) if self.mva_form2 == "derived": views.append({ "cmd": "set_derived_mva_form", "args": { "slot": "mvaForm2", "template": "script#derived_mva_form_template", "data": self.derived_mva_form_data(pcf, self.mva_form2_data), } }) elif self.mva_form2 == "fk": views.append({ "cmd": "set_foreign_key_form", "args": { "slot": "mvaForm2", "template": "script#foreign_key_form_template", "data": self.foreign_key_form_data(pcf, self.mva_form2_data), } }) return views
def set_output_sql(self, sqlterm): pcf = Storage.read(self.pcf_name) pcf.set_printsql(self.current_sort, sqlterm) Storage.write(pcf, self.pcf_name)
def delete_mva(self, mva_id): pcf = Storage.read(self.pcf_name) pcf.delete_mva(mva_id) Storage.write(pcf, self.pcf_name)
def scale_mva(self, mva_id, context_class): pcf = Storage.read(self.pcf_name) pcf.scale_mva(mva_id, context_class) Storage.write(pcf, self.pcf_name)
def create_mva2(self, form_data): pcf = Storage.read(self.pcf_name) if self.mva_form2 == "derived": # form = self.mva_form2_data # assert(form["datatype"] == form_data["datatype"]) # assert(form["name"] == form_data["name"]) # assert(form["sqldef"] == form_data["sqldef"]) # assert(form["nargs"] == form_data["nargs"]) # for i in range(1,int(form["nargs"])+1): # assert(form["sort{0}".format(i)] == form_data["sort{0}".format(i)]) # assert(form["role{0}".format(i)] == form_data["role{0}".format(i)]) if not (form_data["name"] and form_data["sqldef"] and form_data["datatype"]): return for i in range(1, int(form_data["nargs"]) + 1): if form_data["sort{0}".format(i)] not in pcf.sorts: return if not form_data["role{0}".format(i)]: return sort = [ form_data["sort{0}".format(i + 1)] for i in range(int(form_data["nargs"])) ] roles = [ form_data["role{0}".format(i + 1)] for i in range(int(form_data["nargs"])) ] pcf.add_mva(form_data["name"], sort, form_data["datatype"], form_data["sqldef"], roles) self.mva_form2_data = { "datatype": None, "name": "", "sqldef": "", "sort1": self.current_sort, "role1": "ARG1", "sort2": self.current_sort, "role2": "ARG2", "nargs": "2", } elif self.mva_form2 == "fk": # form = self.mva_form2_data # assert(form["name"] == form_data["name"]) # assert(form["sort1"] == form_data["sort1"]) # assert(form["column1"] == form_data["column1"]) # assert(form["role1"] == form_data["role1"]) # assert(form["sort2"] == form_data["sort2"]) # assert(form["column2"] == form_data["column2"]) # assert(form["role2"] == form_data["role2"]) if not (form_data["name"] and form_data["column1"] and form_data["column2"] and form_data["role1"] and form_data["role2"]): return if not (form_data["sort1"] in pcf.sorts and form_data["sort2"] in pcf.sorts): return roles = [form_data["role1"], form_data["role2"]] colname1 = pcf.mvas[form_data["column1"]].name colname2 = pcf.mvas[form_data["column2"]].name mva_id = pcf.add_foreign_key(form_data["name"], form_data["sort1"], colname1, form_data["sort2"], colname2) pcf.mvas[mva_id].roles = roles self.mva_form2_data = { "name": "", "sort1": self.current_sort, "column1": None, "role1": "ARG1", "sort2": self.current_sort, "column2": None, "role2": "ARG2", } Storage.write(pcf, self.pcf_name)