Beispiel #1
0
    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)
Beispiel #2
0
 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)
Beispiel #3
0
 def delete_mva(self, mva_id):
     pcf = Storage.read(self.pcf_name)
     pcf.delete_mva(mva_id)
     Storage.write(pcf, self.pcf_name)
Beispiel #4
0
 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)
Beispiel #5
0
    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)
Beispiel #6
0
    def create_binding(self, form):

        pcf = DBContextFamily(form["user"], form["password"], form["host"],
                              form["database"])
        pcf.load_contents()
        Storage.write(pcf, form["name"] if form["name"] else form["database"])