Esempio n. 1
0
    def __apply_click_event(self, event):
        '''
        get the entities according to the input project path
        '''
        fileconstant = File_constant()
        proj_dir = self.__input01.get()
        #verify the input directory
        if not File_processor.verify_dir_existing(proj_dir):
            showerror('Error', 'Please select a valid directory.')
        if not File_processor.verify_dir_format(proj_dir):
            showerror('Error', 'Please select a valid forlder, not a file.')
            return
        if not File_processor.verify_file(proj_dir + fileconstant.POM_PATH):
            showerror(
                'Error',
                'Please select a valid project directory\n(the directory of pom.xml in webui).'
            )
            return

        #read the entity metadatas
        result, metas, err_message = Xmlfile_processor.read_proj_dir(proj_dir)
        if result:
            #clear the list box first
            self.__listboxleft.delete(0, END)
            #backup the list
            self.__filelists = metas
            #add items into list box
            for name in metas.keys():
                self.__listboxleft.insert(END, name)
        else:
            showerror('Error', err_message)
Esempio n. 2
0
    def get_file_type(dir_path):
        '''
        get the file type
        @param dir_path: file directory
        @return: return file type
        '''
        fileconstant = File_constant()

        #open file as bytes
        bytefile = open(dir_path, 'rb')
        ftype = 'unknown'
        #read the file header
        bins = bytefile.read(20)
        #close file
        bytefile.close()
        #convert bytes to 16 bit
        bins = File_processor.__bytes2hex(bins)
        #keys comparing
        for hcode in fileconstant.FILE_TYPE.keys():
            lens = len(hcode)  #length of key
            if bins[0:lens] == hcode:
                ftype = fileconstant.FILE_TYPE[hcode]
                break

        return ftype
Esempio n. 3
0
    def load_connection_parameters(self, event):
        '''
        load connection parameters from workspace
        '''
        # combine the workspace path
        fileconstant = File_constant()
        workspacepath = self.get_trans().get_workspacepath()
        cassandra_conection_file = workspacepath + fileconstant.CASSANDRA_CONFIG_FOLDER + fileconstant.CASSANDRA_CONNECTION_FILE

        # verify connection file existing
        if not File_processor.verify_file(cassandra_conection_file):
            showerror('Error', 'Cassandra connection file does not exist!')
            return

        # load connection parameters
        connection_params = Database_connection_file_processor.read_connection_params(
            cassandra_conection_file, self.__comboxlist.get())
        # set parameters
        self.__input02.delete(0, END)
        self.__input02.insert(END, connection_params['host'])
        self.__input03.delete(0, END)
        self.__input03.insert(END, connection_params['port'])
        self.__input04.delete(0, END)
        self.__input04.insert(END, connection_params['username'])
        self.__input05.delete(0, END)
        self.__input05.insert(END, connection_params['password'])
Esempio n. 4
0
    def set_maintain_mode(self):
        '''
        verify the initial maintain mode (create or load)
        '''
        self.__maintain_mode = MATAIN_MODE_LOAD

        # setup the connection file path into workspace folder
        fileconstant = File_constant()
        workspacepath = self.get_trans().get_workspacepath()
        cassandra_conection_folder = workspacepath + fileconstant.CASSANDRA_CONFIG_FOLDER

        if not File_processor.verify_dir_existing(cassandra_conection_folder):
            self.__maintain_mode = MATAIN_MODE_NEW
            return

        cassandra_conection_file = cassandra_conection_folder + fileconstant.CASSANDRA_CONNECTION_FILE

        # verify the connection file
        if not File_processor.verify_file(cassandra_conection_file):
            self.__maintain_mode = MATAIN_MODE_NEW
            return
        # load connection names
        connection_names = Database_connection_file_processor.read_connection_names(
            cassandra_conection_file)
        # set tuple to combox list
        templist = tuple(connection_names)
        if len(templist) == 0:
            self.__maintain_mode = MATAIN_MODE_NEW
            return
Esempio n. 5
0
    def before_next(self):
        '''
        overwrite the function in super class
        verify the input directory
        '''
        if self.__listboxright.size() > 0:
            #the dict.items() will convert to tuple
            for index in range(self.__listboxright.size()):
                for tup in self.__filelists.items():
                    if tup[0] == self.__listboxright.get(index):
                        #save the entity info
                        self.get_dtos().set_entityname(tup[0])
                        self.get_dtos().set_viewfullpath(tup[1])

        if self.get_dtos().get_entityname() and self.get_dtos(
        ).get_viewfullpath():
            #--- save the project path
            self.get_trans().set_projectpath(self.__input01.get())
            #--- update default file
            fileconstant = File_constant()
            userdefault = File_processor.get_home_dir()
            userdefault = userdefault + fileconstant.USER_DEFAULT
            User_default_file_processor.update_default_file(
                userdefault, 'project', self.__input01.get())
            return True
        else:
            showerror('Error', 'You must select an existing entity!')
            return False
Esempio n. 6
0
    def create_widges(self):
        fileconstant = File_constant()

        #frame
        self.__frame1 = FormatableFrame(self)
        self.__frame1.pack(side=TOP)
        #Title
        self.__label01 = Label(self.__frame1,
                               text="Mock DTO generator options",
                               width=45)
        self.__label01.pack(side=TOP, fill=X, ipady=10)

        #---- panel 01 ----------
        canv1 = Canvas(self, height=30, width=550)
        #label
        self.__label01 = Label(canv1, text='Mock DTO name :')
        self.__label01.place(height=20, width=130, relx=0.03, rely=0.2)
        #input
        self.__feet = StringVar()
        self.__dicinput = Entry(canv1,
                                textvariable=self.__feet,
                                borderwidth=3,
                                bg='black',
                                foreground='yellow',
                                highlightcolor='red',
                                insertbackground='red')
        self.__dicinput.place(height=20, width=250, relx=0.3, rely=0.2)
        canv1.pack()

        #---- panel 02 ----------
        canv2 = Canvas(self, height=100, width=550)
        #label
        label1 = Label(canv2, text='Options:')
        label1.place(height=20, width=60, relx=0, rely=0)
        #radio box
        self.__vari1 = IntVar()
        self.__rad1 = Radiobutton(canv2,
                                  text='Copy from the standard DTO(generated)',
                                  variable=self.__vari1,
                                  value=1)
        self.__rad1.place(height=20, width=270, relx=0.1, rely=0.2)
        self.__rad1.select()
        self.__rad2 = Radiobutton(canv2,
                                  text='Generated from fin-impl.jar',
                                  variable=self.__vari1,
                                  value=2)
        self.__rad2.place(height=20, width=210, relx=0.1, rely=0.45)
        self.__rad2.deselect()
        canv2.pack()

        if self.get_dtos().get_businessentityname():
            # get the main table interface name
            main_tb_name = self.get_dtos().get_maintableInterDTO(
            ).get_class_name()
            # get the mock ds name
            mock_ds_name = fileconstant.TS_DATASET_PREFIX + main_tb_name + fileconstant.TS_MOCK_DS_SUFFIX + fileconstant.TS_SUFFIX
            self.__feet.set(mock_ds_name)
    def before_next(self):
        '''
        overwrite the function in super class
        verify the input directory
        generating the next frames according to the selections
        '''
        tempdir = None
        #--- verify the input value
        if self.__dicinput.get():
            if not Xmlfile_processor.verify_dir_format(self.__dicinput.get()):
                showerror('Error', 'The directory format is incorrect!')
                return False

            if not Xmlfile_processor.verify_dir_existing(
                    self.__dicinput.get()):
                Xmlfile_processor.create_folder(self.__dicinput.get())
                showinfo(
                    'Note',
                    'A new folder has been created in your workspace path.')

            #--- set the workspace path into transaction dto
            self.get_trans().set_workspacepath(self.__dicinput.get())
            tempdir = self.__dicinput.get()
        else:
            tempdir = os.path.join(os.path.expanduser('~'),
                                   "Desktop") + '\\PyWorkspace'
            #--- desktop temp folder already existing
            self.__feet.set(tempdir)
            if Xmlfile_processor.verify_dir_existing(tempdir):
                showinfo(
                    'Note',
                    'The temp folder(PyWorkspace) on your desktop has been set as the default workspace.'
                )
            else:
                Xmlfile_processor.create_folder(tempdir)
                showinfo(
                    'Note',
                    'A temp folder(PyWorkspace) has been created on your desktop.'
                )

            #--- set the workspace path into transaction dto
            self.get_trans().set_workspacepath(tempdir)

        #--- update default file
        fileconstant = File_constant()
        userdefault = File_processor.get_home_dir()
        userdefault = userdefault + fileconstant.USER_DEFAULT
        User_default_file_processor.update_default_file(
            userdefault, 'workspace', tempdir)

        #--- set the process flow according to the selection
        self.get_trans().remove_subsequent_process_flows_exclude_current()
        self.get_trans().update_process_flow_by_start_selection(
            self.__vari1.get())

        return True
Esempio n. 8
0
    def create_widges(self):
        fileconstant = File_constant()

        #frame
        self.__frame1 = FormatableFrame(self)
        self.__frame1.pack(side=TOP)
        #Title
        self.__label01 = Label(self.__frame1,
                               text="TS CommonService generator options",
                               width=45)
        self.__label01.pack(side=TOP, fill=X, ipady=10)

        #---- panel 01 ----------
        canv1 = Canvas(self, height=30, width=550)
        #label
        self.__label01 = Label(canv1, text='CommonService name :')
        self.__label01.place(height=20, width=130, relx=0.03, rely=0.2)
        #input
        self.__feet = StringVar()
        self.__dicinput = Entry(canv1,
                                textvariable=self.__feet,
                                borderwidth=3,
                                bg='black',
                                foreground='yellow',
                                highlightcolor='red',
                                insertbackground='red')
        self.__dicinput.place(height=20, width=250, relx=0.3, rely=0.2)
        canv1.pack()

        #---- panel 02 ----------
        canv2 = Canvas(self, height=100, width=550)
        self.__label02 = Label(canv2,
                               text='Please select the imports:',
                               width=30)
        self.__label02.place(height=20, width=200, relx=0.05, rely=0.02)
        canv2.pack()

        # TODO: add import options: constant, MockDTO

        #---- panel 03 ----------
        canv3 = Canvas(self, height=150, width=550)
        self.__label03 = Label(canv3,
                               text='Please select the contents:',
                               width=30)
        self.__label03.place(height=20, width=200, relx=0.05, rely=0.02)

        canv3.pack()

        if self.get_dtos().get_businessentityname():
            # get the mock ds name
            mock_ds_name = self.get_dtos().get_businessentityname(
            ) + fileconstant.TS_COMMON_SERVICE_SUFFIX + fileconstant.TS_SUFFIX
            self.__feet.set(mock_ds_name)
Esempio n. 9
0
    def before_next(self):
        '''
        overwrite the function in super class
        verify the input directory
        '''
        if not self.__result:
            showwarning(
                'Warning',
                'There are error existing, the CommonService cannot be generated.'
            )
            return

        # --------------------- analysis the DTO if needed --------------------- #
        if not self.get_dtos().get_tsdtos() or not self.get_dtos(
        ).get_tsdto_value('TSDtoDTO'):
            #path constant
            fileconstant = File_constant()
            proj_path = self.get_trans().get_projectpath()
            # get the main table interface name
            main_tb_name = self.get_dtos().get_maintableInterDTO(
            ).get_class_name()
            # get the generated ds name
            gene_ds_name = fileconstant.TS_DATASET_PREFIX + main_tb_name + fileconstant.TS_SUFFIX
            # get the generated ds full path
            gene_ds_filefullpath = proj_path + fileconstant.RESOURCE_TS_MAIN_PATH + fileconstant.RESOURCE_TS_DTO_BL_FOLDER + gene_ds_name
            # get the mock ds full path
            mock_ds_filefullpath = proj_path + fileconstant.RESOURCE_TS_MAIN_PATH + fileconstant.RESOURCE_TS_DTO_UI_FOLDER + gene_ds_name.replace(
                fileconstant.TS_SUFFIX,
                fileconstant.TS_MOCK_DS_SUFFIX + fileconstant.TS_SUFFIX)

            # use MockDTO if existing
            if File_processor.verify_dir_existing(mock_ds_filefullpath):
                TS_processor.analysis_DTO(self.get_dtos(),
                                          mock_ds_filefullpath)
            elif File_processor.verify_dir_existing(gene_ds_filefullpath):
                TS_processor.analysis_DTO(self.get_dtos(),
                                          gene_ds_filefullpath)
            else:
                showerror(
                    'Error',
                    'The DTO interface TS is not existing, please check.')
                return False

        # create the observable object
        self.__result, self.__message = TS_processor.create_TS_CommonService(
            self.get_dtos(), self.get_trans(), self.__feet.get())
        if not self.__result:
            showerror('Error', self.__message)
            return False

        return True
Esempio n. 10
0
 def set_stylesheet(self):
     '''
     set the style sheet from qss and icons
     '''
     # get the relative project path
     fileconstant = File_constant()
     root_path = os.path.dirname(os.path.abspath(__file__))
     proj_path = root_path[:root_path.index(fileconstant.MY_PROJECT_PACKAGE)]
     # set the qss
     qss_path = proj_path + "\\src\\main\\pydev\\com\\ftd\\resource\\style\\StyleSheet.qss"
     self.setStyleSheet(open(qss_path, "r").read())
     # set the window icon
     icon_path = proj_path + "\\src\\main\\pydev\\com\\ftd\\resource\\icons\\title_icon.jpg"
     self.setWindowIcon(QIcon(icon_path))
Esempio n. 11
0
    def load_connection_names(self):
        '''
        load all connection names from workspace
        @return: count of connections
        '''
        # setup the connection file path into workspace folder
        fileconstant = File_constant()
        workspacepath = self.get_trans().get_workspacepath()
        cassandra_conection_folder = workspacepath + fileconstant.CASSANDRA_CONFIG_FOLDER

        if not File_processor.verify_dir_existing(cassandra_conection_folder):
            File_processor.create_folder(cassandra_conection_folder)

        cassandra_conection_file = cassandra_conection_folder + fileconstant.CASSANDRA_CONNECTION_FILE

        # verify connection file existing
        if not File_processor.verify_file(cassandra_conection_file):
            showerror('Error', 'Cassandra connection file does not exist!')
            return 0

        # load connection names
        connection_names = Database_connection_file_processor.read_connection_names(
            cassandra_conection_file)
        # set tuple to combox list
        self.__comboxlist["values"] = tuple(connection_names)
        if len(self.__comboxlist["values"]) == 0:
            showerror('Error', 'No valid connection, please add one first!')
            return 0

        # default the first one
        self.__comboxlist.current(0)

        # load connection parameters
        connection_params = Database_connection_file_processor.read_connection_params(
            cassandra_conection_file, self.__comboxlist.get())
        # set parameters
        self.__input02.delete(0, END)
        self.__input02.insert(END, connection_params['host'])
        self.__input03.delete(0, END)
        self.__input03.insert(END, connection_params['port'])
        self.__input04.delete(0, END)
        self.__input04.insert(END, connection_params['username'])
        self.__input05.delete(0, END)
        self.__input05.insert(END, connection_params['password'])

        return len(self.__comboxlist["values"])
Esempio n. 12
0
    def read_proj_dir(dir_path):
        '''
        read the all view metadata xml files from the project directory
        @param dir_path: the full path of the project
        @return: return status
        @return: viewMetadataNames in list
        @return: message if validation failed
        '''
        # verify if file is existing
        if not File_processor.verify_dir_existing(dir_path):
            return False, None, "File not exist!"

        try:
            fileconstant = File_constant()
            #view metadata file list
            viewMetadataNames = {}

            #change the work path
            os.chdir(dir_path)
            #go through the inner files
            for fullname in File_processor.dir_iterbrowse(dir_path):
                #get the view metadata files
                if (fullname.startswith(dir_path +
                                        fileconstant.VIEW_METADATA_PATH)):
                    #trim the file name
                    filename = os.path.basename(fullname)
                    #remove the suffix
                    filename = filename[:-4]
                    #insert into file list
                    viewMetadataNames[filename] = fullname

            #no files
            if len(viewMetadataNames) == 0:
                return False, None, 'There is no correct view metadata.'

            return True, viewMetadataNames, None

        except OSError as e:
            print('Caught exception:', e.message())
            return False, None, e.message()
        except FileNotFoundError as e:
            print('Caught exception:', e.message())
            return False, None, e.message()
        finally:
            pass
Esempio n. 13
0
    def load_user_default(self):
        '''
        load the local user default
        '''
        fileconstant = File_constant()
        userdefault = File_processor.get_home_dir()
        userdefault = userdefault + fileconstant.USER_DEFAULT

        #create default file if not existing
        if not File_processor.verify_dir_existing(userdefault):
            User_default_file_processor.create_default_file(userdefault)
        #read default file
        default_info = User_default_file_processor.read_default_file(
            userdefault)

        if default_info['project'] and default_info['project'] != "":
            self.get_trans().set_projectpath(default_info['project'])
            self.__dicinput.delete(0, END)
            self.__dicinput.insert(END, default_info['project'])
Esempio n. 14
0
    def multiprocessing_service(transDTO):
        '''
        Multiple processing service
        '''
        fileconstant = File_constant()
        #jar full path
        impljarfullpath = transDTO.get_finImplJarPath()
        apijarfullpath = transDTO.get_finApiJarPath()
        #workspace full path
        unzip_path = transDTO.get_workspacepath(
        ) + fileconstant.UNZIP_JAR_FOLDER

        #remove the legacy folder
        if File_processor.verify_dir_existing(unzip_path):
            if not askyesno(
                    'Confirm',
                    'The decompile folder existing, do you want to skip decompile?'
            ):
                File_processor.remove_folder(unzip_path)
            else:
                return

        print('Parent process %s.' % os.getpid())
        #process the child processing
        p1 = Process(target=Multiple_processor.jar_decompile_proc,
                     args=(
                         'JarDecompile',
                         impljarfullpath,
                         unzip_path + fileconstant.IMPL_FOLDER,
                     ))
        p1.start()

        p2 = Process(target=Multiple_processor.jar_decompile_proc,
                     args=(
                         'JarDecompile',
                         apijarfullpath,
                         unzip_path + fileconstant.API_FOLDER,
                     ))
        p2.start()
        # p.join() join will be waiting for the child process
        print('Child process end.')
    def create_widges(self):

        fileconstant = File_constant()

        #frame
        self.__frame1 = FormatableFrame(self)
        self.__frame1.pack(side=TOP)
        #Title
        self.__label01 = Label(self.__frame1,
                               text="TS Constants generator options",
                               width=45)
        self.__label01.pack(side=TOP, fill=X, ipady=10)

        #---- panel 01 ----------
        canv1 = Canvas(self, height=30, width=550)
        #label
        self.__label01 = Label(canv1, text='TS Constants name :')
        self.__label01.place(height=20, width=130, relx=0.03, rely=0.2)
        #input
        self.__feet = StringVar()
        self.__dicinput = Entry(canv1,
                                textvariable=self.__feet,
                                borderwidth=3,
                                bg='black',
                                foreground='yellow',
                                highlightcolor='red',
                                insertbackground='red')
        self.__dicinput.place(height=20, width=250, relx=0.3, rely=0.2)

        if self.get_dtos().get_businessentityname():
            temp_name = self.get_dtos().get_businessentityname(
            ) + fileconstant.TS_CONSTANT_SUFFIX + fileconstant.TS_SUFFIX
            self.__feet.set(temp_name)
        else:
            self.__result, self.__error, business_entity_name, self.__classlist = Java_processor.validate_lib_javas(
                self.get_trans(), self.get_dtos())
            if not self.__result:
                #---- panel 02 ----------
                self.__pack_errorpanel()
                return
            if business_entity_name:
                self.get_dtos().set_businessentityname(business_entity_name)
                temp_name = self.get_dtos().get_businessentityname(
                ) + fileconstant.TS_CONSTANT_SUFFIX + fileconstant.TS_SUFFIX
                self.__feet.set(temp_name)

        canv1.pack()

        #---- panel 02 ----------
        canv2 = Canvas(self, height=100, width=550)
        #label
        label1 = Label(canv2, text='Options:')
        label1.place(height=20, width=60, relx=0, rely=0)
        #radio box
        self.__vari1 = IntVar()
        self.__rad1 = Radiobutton(canv2,
                                  text='Re-write the previous file',
                                  variable=self.__vari1,
                                  value=1)
        self.__rad1.place(height=20, width=170, relx=0.1, rely=0.2)
        self.__rad1.select()
        self.__rad2 = Radiobutton(canv2,
                                  text='Attach new functions to the file',
                                  variable=self.__vari1,
                                  value=2)
        self.__rad2.place(height=20, width=210, relx=0.1, rely=0.45)
        self.__rad2.deselect()
        self.__rad3 = Radiobutton(canv2,
                                  text='Save the previous file as backup',
                                  variable=self.__vari1,
                                  value=3)
        self.__rad3.place(height=20, width=220, relx=0.1, rely=0.7)
        self.__rad3.deselect()
        canv2.pack()
Esempio n. 16
0
    def before_next(self):
        '''
        overwrite the function in super class
        generating the next frames according to the selections
        '''
        #check box flag
        frame_constant = Frame_constant()
        checkFlag = False
        selections = dict(self.__checkvalues01, **self.__checkvalues02,
                          **self.__checkvalues03)

        for val in selections.values():
            if val.get() == 1:
                checkFlag = True
                break

        if checkFlag:
            #merge the selections into process flow
            self.get_trans().update_process_flow_by_gene_selection(selections)

            # --------- analysis the serviceImpl and datacontroller class if needed
            fileconstant = File_constant()
            tempstr01, tempstr02, parent_pack, tempstr03 = Java_processor.analysis_jar_package_name(
                self.get_dtos().get_serviceInterDTO().get_class_package())
            self.__result, self.__error, business_entity_name, self.__classlist = Java_processor.validate_lib_javas(
                self.get_trans(), self.get_dtos())

            proc = self.get_trans().get_processflow()
            if self.__checkvalues02[frame_constant.DATA_CONTROLLER].get(
            ) == 1 and self.__checkvalues02[
                    frame_constant.SERVICE_IMPL].get() != 1 in proc:
                if not self.get_dtos().get_serviceImplPath():
                    serviceImpl_path = self.get_trans().get_projectpath(
                    ) + fileconstant.JAVA_SERVICEIMPL_PATH % (
                        parent_pack, business_entity_name +
                        fileconstant.SERVICEIMPL_SUFFIX +
                        fileconstant.JAVA_SUFFIX)
                    self.__result, self.__error, dcJavaDTO = Java_processor.analysis_serviceImpl(
                        business_entity_name + fileconstant.SERVICEIMPL_SUFFIX,
                        serviceImpl_path, self.get_dtos())
                    if not self.__result:
                        #---- panel 02 ----------
                        self.__pack_errorpanel()
                        return
                    else:
                        self.get_dtos().set_serviceImplInfo(
                            business_entity_name +
                            fileconstant.SERVICEIMPL_SUFFIX +
                            fileconstant.JAVA_SUFFIX, serviceImpl_path,
                            dcJavaDTO)

            if (self.__checkvalues03[frame_constant.TS_HANDLER].get() == 1 or self.__checkvalues03[frame_constant.OBSERVABLE_OBJ].get() == 1) and \
                self.__checkvalues02[frame_constant.DATA_CONTROLLER].get() != 1:

                if not self.get_dtos().get_dataControllerPath():
                    dataController_path = self.get_trans().get_projectpath(
                    ) + fileconstant.JAVA_DATACONTROLLER_PATH % (
                        parent_pack, business_entity_name +
                        fileconstant.DATACONTROLLER_SUFFIX +
                        fileconstant.JAVA_SUFFIX)
                    self.__result, self.__error, dcJavaDTO = Java_processor.analysis_dataController(
                        business_entity_name +
                        fileconstant.DATACONTROLLER_SUFFIX,
                        dataController_path, self.get_dtos())
                    if not self.__result:
                        #---- panel 02 ----------
                        self.__pack_errorpanel()
                        return
                    else:
                        self.get_dtos().set_dataControllerInfo(
                            business_entity_name +
                            fileconstant.DATACONTROLLER_SUFFIX +
                            fileconstant.JAVA_SUFFIX, dataController_path,
                            dcJavaDTO)

            return True
        else:
            showerror('Error', 'You must select at least one generation file!')
            return False
Esempio n. 17
0
    def create_widges(self):

        fileconstant = File_constant()

        #frame
        self.__frame1 = FormatableFrame(self)
        self.__frame1.pack(side=TOP)
        #Title
        self.__label01 = Label(self.__frame1,
                               text="Observable Obj generator options",
                               width=45)
        self.__label01.pack(side=TOP, fill=X, ipady=10)

        #---- panel 01 ----------
        canv1 = Canvas(self, height=30, width=550)
        #label
        self.__label01 = Label(canv1, text='Observable Obj name :')
        self.__label01.place(height=20, width=130, relx=0.03, rely=0.2)
        #input
        self.__feet = StringVar()
        self.__dicinput = Entry(canv1,
                                textvariable=self.__feet,
                                borderwidth=3,
                                bg='black',
                                foreground='yellow',
                                highlightcolor='red',
                                insertbackground='red')
        self.__dicinput.place(height=20, width=250, relx=0.3, rely=0.2)

        canv1.pack()

        #---- panel 02 ----------
        canv2 = Canvas(self, height=100, width=550)
        #label
        label1 = Label(canv2, text='Options:')
        label1.place(height=20, width=60, relx=0, rely=0)
        #radio box
        self.__vari1 = IntVar()
        self.__rad1 = Radiobutton(canv2,
                                  text='Re-write the previous file',
                                  variable=self.__vari1,
                                  value=1)
        self.__rad1.place(height=20, width=170, relx=0.1, rely=0.2)
        self.__rad1.select()
        self.__rad2 = Radiobutton(canv2,
                                  text='Attach new functions to the file',
                                  variable=self.__vari1,
                                  value=2)
        self.__rad2.place(height=20, width=210, relx=0.1, rely=0.45)
        self.__rad2.deselect()
        self.__rad3 = Radiobutton(canv2,
                                  text='Save the previous file as backup',
                                  variable=self.__vari1,
                                  value=3)
        self.__rad3.place(height=20, width=220, relx=0.1, rely=0.7)
        self.__rad3.deselect()
        canv2.pack()

        if self.get_dtos().get_businessentityname():
            temp_name = self.get_dtos().get_businessentityname(
            ) + fileconstant.TS_OBSERVABLE_OBJECT_SUFFIX + fileconstant.TS_SUFFIX
            self.__feet.set(temp_name)
Esempio n. 18
0
    def before_next(self):
        '''
        overwrite the function in super class
        verify the input directory
        generating the next frames according to the selections
        '''
        # verify the connection name
        if not self.__input01.get(
        ) and self.__maintain_mode == MATAIN_MODE_NEW:
            showerror('Error', 'Please provide the connection name!')
            return False

        # verify the input value
        if not self.__input02.get() or not self.__input03.get(
        ) or not self.__input04.get() or not self.__input05.get():
            showerror('Error', 'Please provide the complete info!')
            return False

        # setup the connection file path into workspace folder
        fileconstant = File_constant()
        workspacepath = self.get_trans().get_workspacepath()
        cassandra_conection_folder = workspacepath + fileconstant.CASSANDRA_CONFIG_FOLDER

        if not File_processor.verify_dir_existing(cassandra_conection_folder):
            File_processor.create_folder(cassandra_conection_folder)

        cassandra_conection_file = cassandra_conection_folder + fileconstant.CASSANDRA_CONNECTION_FILE

        # combine the connection parameter
        # TODO: this should be implemented as toString() in Cassandra_connection_dto
        if self.__maintain_mode == MATAIN_MODE_NEW:
            connection_name = self.__input01.get()
            connection_param = self.__input01.get(
            ) + ':' + 'host=' + self.__input02.get(
            ) + ',port=' + self.__input03.get(
            ) + ',username='******',password='******':' + 'host=' + self.__input02.get(
            ) + ',port=' + self.__input03.get(
            ) + ',username='******',password='******'Warning',
                        'The connection name is existing, do you confirm to overwrite?'
                ):
                    return False
            Database_connection_file_processor.update_connection_file(
                cassandra_conection_file, connection_name, connection_param)

        return True
Esempio n. 19
0
    def create_TS_CommonService(entityDto, transDto, ts_name):
        '''
        This method is used to create the CommonService TSHandler 
        '''
        #path constant
        fileconstant = File_constant()
        tsconstant = TS_constant()
        proj_path = transDto.get_projectpath()

        # get the main table interface name
        controller_dto = entityDto.get_dataControllerDTO()
        business_entity_name = entityDto.get_businessentityname()
        # get the parent package name
        parent_pack = Java_processor.analysis_dataController_package_name(
            controller_dto.get_class_package())

        # get the generated constant full path
        commsev_filefullpath = proj_path + fileconstant.RESOURCE_TS_MAIN_PATH + parent_pack + '\\' + business_entity_name.lower(
        ) + '\\' + ts_name

        # create the header for constant file
        temp_lines = []
        additional_reference = []
        import_list = []

        # ------------------------------------------------------- #
        # ----- Prepare the imports -----
        # ------------------------------------------------------- #
        import_list.append(tsconstant.TS_TAB +
                           tsconstant.TS_FIN_COMMONSERVICE_IMPORT)

        # DTO import
        #tempStr = tsconstant.TS_DTO_IMPORT_TEMP % (dsName,parent_pack,business_entity_name.lower(),business_entity_name,)
        #import_list.append(tsconstant.TS_TAB + tempStr)

        # ------------------------------------------------------- #
        # ----- Create the file -----
        # ------------------------------------------------------- #
        if not File_processor.verify_dir_existing(commsev_filefullpath):
            # create file
            Path(commsev_filefullpath).touch()

        # ------------------------------------------------------- #
        # ----- open the observable object file -----
        # ------------------------------------------------------- #
        file = open(commsev_filefullpath, 'w')

        # ------------------------------------------------------- #
        # ----- write the common references -----
        # ------------------------------------------------------- #
        for temp_ref in tsconstant.TS_REFERENCE_COMMON_REFERENCES:
            file.write(temp_ref)
            file.write('\n')

        for temp_ref in tsconstant.TS_REFERENCE_UTIL_REFERENCES:
            file.write(temp_ref)
            file.write('\n')

        # ------------------------------------------------------- #
        # ----- write the common references -----
        # ------------------------------------------------------- #
        for temp_ref in additional_reference:
            file.write(temp_ref)
            file.write('\n')

        file.write('\n')

        # ------------------------------------------------------- #
        # ----- write the observable object header -----
        # ------------------------------------------------------- #
        temp_header = tsconstant.TS_COMMONSERVICE_HEADER % (
            parent_pack, business_entity_name.lower())
        file.write(temp_header)
        file.write('\n')

        # ------------------------------------------------------- #
        # ----- write the imports -----
        # ------------------------------------------------------- #
        for temp_ref in import_list:
            file.write(temp_ref)
            file.write('\n')

        file.write('\n')

        # ------------------------------------------------------- #
        # ----- write the observable object content -----
        # ------------------------------------------------------- #
        for sub_line in temp_lines:
            file.write(sub_line)

        file.write(tsconstant.TS_RIGHT_BRACE)

        file.close()

        return True, None
Esempio n. 20
0
    def create_TS_Constant(entityDto, transDto, tsConstant_name):
        '''
        create TS Constant
        '''
        #path constant
        fileconstant = File_constant()
        tsconstant = TS_constant()
        proj_path = transDto.get_projectpath()

        # get the main table interface name
        controller_dto = entityDto.get_dataControllerDTO()
        business_entity_name = entityDto.get_businessentityname()
        # get the parent package name
        parent_pack = Java_processor.analysis_dataController_package_name(
            controller_dto.get_class_package())

        # get the generated constant full path
        const_filefullpath = proj_path + fileconstant.RESOURCE_TS_MAIN_PATH + parent_pack + '\\' + business_entity_name.lower(
        ) + '\\' + tsConstant_name

        # create the header for constant file
        tempLines = []
        fieldLines = []
        gridLines = []
        gridfieldLines = {}

        tempStr = tsconstant.TS_CONSTANT_HEADER % (
            parent_pack, business_entity_name.lower())
        tempLines.append(tempStr)
        tempLines.append('\n')

        viewMetaDataDTO = entityDto.get_viewDTO()

        if not viewMetaDataDTO:
            return False, 'The View Metadata has not been analyzed, please do it first.'

        # ------------------------------------------------------- #
        # ----- prepare the field & labels -----
        # ------------------------------------------------------- #
        for datafield in viewMetaDataDTO.get_datafields():
            if datafield.get_name():
                tempName = datafield.get_name()
                constName = TS_processor.convertConstName(tempName)

                # add fields into const file
                fieldLines.append(tsconstant.TS_CONSTANT_FIELD_LINE_TEMP %
                                  (constName, tempName))

        for datalabels in viewMetaDataDTO.get_datalabels():
            if datalabels.get_name():
                tempName = datalabels.get_name()
                constName = TS_processor.convertConstName(tempName)

                # add fields into const file
                fieldLines.append(tsconstant.TS_CONSTANT_FIELD_LINE_TEMP %
                                  (constName, tempName))

        # create field&label constant
        if len(fieldLines) > 0:
            fieldContent = ''
            for fieldLine in fieldLines:
                fieldContent = fieldContent + fieldLine

            tempLines.append(tsconstant.TS_CONSTANT_FIELDS_TEMP %
                             (business_entity_name, fieldContent))

        # ------------------------------------------------------- #
        # ----- prepare the grids -----
        # ------------------------------------------------------- #
        for datagrids in viewMetaDataDTO.get_datagrids():
            if datagrids.get_name():
                tempGridName = datagrids.get_name()
                constGridName = TS_processor.convertConstName(tempGridName)

                # add fields into const file
                gridLines.append(tsconstant.TS_CONSTANT_FIELD_LINE_TEMP %
                                 (constGridName, tempGridName))

                # ------------------------------------------------------- #
                # ----- prepare the grid fields -----
                # ------------------------------------------------------- #
                if datagrids.get_datagridtable(
                ) and datagrids.get_datagridtable().get_datagridfields(
                ) and len(datagrids.get_datagridtable().get_datagridfields()
                          ) > 0:

                    tempGridFieldList = []

                    for datagridfield in datagrids.get_datagridtable(
                    ).get_datagridfields():
                        if datagridfield.get_fieldname():
                            tempFieldName = datagridfield.get_fieldname()
                            constFieldName = TS_processor.convertConstName(
                                tempFieldName)

                            # add grid fields into const file
                            tempGridFieldList.append(
                                tsconstant.TS_CONSTANT_FIELD_LINE_TEMP %
                                (constFieldName, tempFieldName))

                    gridfieldLines[tempGridName] = tempGridFieldList

        # create grid constant
        if len(gridLines) > 0:
            gridContent = ''
            for gridLine in gridLines:
                gridContent = gridContent + gridLine

            tempLines.append(tsconstant.TS_CONSTANT_GRIDS_TEMP %
                             (business_entity_name, gridContent))

        # create gridfield constant
        for key, value in gridfieldLines.items():
            gridFieldContent = ''
            for gridFieldLine in value:
                gridFieldContent = gridFieldContent + gridFieldLine

            tempLines.append(tsconstant.TS_CONSTANT_GRIDFIELD_TEMP %
                             (key, gridFieldContent))

        # write the constant file
        if not File_processor.verify_dir_existing(const_filefullpath):
            # create file
            Path(const_filefullpath).touch()

        # ------------------------------------------------------- #
        # ----- open the constant file -----
        # ------------------------------------------------------- #
        newfile = open(const_filefullpath, 'w')

        for line in tempLines:
            newfile.write(line)

        newfile.write(tsconstant.TS_RIGHT_BRACE)

        newfile.close()

        return True, None
Esempio n. 21
0
    def before_next(self):    
        fileconstant = File_constant()
        curDtos = self.get_dtos()
        curTrans = self.get_trans()
        const = Frame_constant()
        
        #--- update the process options in transaction dto ----
        result, message = curTrans.update_options(
            {'Xml':{'EntityMap':self.__vari1.get(), 'BeanAppContext':self.__vari2.get()}}, const.ACTION_UPDATE)
        
        if not result:
            showerror('Error', message)
            return False
        
        #--- read the resource metadata
        resDTO = curDtos.get_resourceDTO()
        
        #--- process beans-app-context.xml
        bean_path = curTrans.get_projectpath() + fileconstant.BEAN_APP_CONTEXT_PATH
        status01, beanDTO, message01 = Xmlfile_processor.read_beans_app_context(bean_path)
        if status01:
            #--- verify if the target entity uri is existing in the beans-app-context
            if resDTO.get_primary_secure_uri() in beanDTO.get_entity_uri_mapstring():
                showwarning('Note', 'The entity uri had been added in the beans-app-context.xml.')
            else:
                #--- backup beans-app-context
                Xmlfile_processor.copy_file(bean_path, curTrans.get_workspacepath() + beanDTO.get_filename() + fileconstant.BACKUP_SUFFIX)
                #--- format the new uri
                value = resDTO.get_primary_secure_uri() + ',' + resDTO.get_meta_uri()
                #--- update beans-app-context
                status01, message01 = Xmlfile_processor.write_beans_app_context(bean_path, value)
                #--- clean the backup if needed
                if self.__vari1.get() == 2:
                    status01, message01 = Xmlfile_processor.remove_file(curTrans.get_workspacepath() + beanDTO.get_filename() + fileconstant.BACKUP_SUFFIX) 
                
        if not status01:
            showerror('Error', message01)
            return False
        
        #--- process entityMap.xml
        entmap_path = curTrans.get_projectpath() + fileconstant.ENTITY_MAP_PATH
        status02, entMapDTO, message02 = Xmlfile_processor.read_entity_map(entmap_path)
        if status02:
            #--- verify if the target entity uri is existing in the entityMap
            if resDTO.get_primary_secure_uri() in entMapDTO.get_entitymap_uris():
                showwarning('Note', 'The entity uri had been added in the entityMap.xml.')
            else:
                #--- backup entityMap
                Xmlfile_processor.copy_file(entmap_path, curTrans.get_workspacepath() + entMapDTO.get_filename() + fileconstant.BACKUP_SUFFIX)
                #--- write entityMap
                status02, message02 = Xmlfile_processor.write_entity_map(entmap_path, resDTO.get_primary_secure_uri(), self.__varc3.get(), self.__varc5.get(), self.__varc4.get())
                #--- clean the backup if needed
                if self.__vari2.get() == 2:
                    status02, message02 = Xmlfile_processor.remove_file(curTrans.get_workspacepath() + entMapDTO.get_filename() + fileconstant.BACKUP_SUFFIX) 
                
        if not status02:
            showerror('Error', message02)
            return False

        # --- Info message
        showinfo('Note', 'The xml files are processed, please verify them later.')
        
        return True    
Esempio n. 22
0
    def create_MockDTO(entityDto, transDto, mock_ds_name, isCopy):
        '''
        create Observable Object
        @param copyFromBlDto: if the mock DTO is copied from the generated one
        '''
        #path constant
        fileconstant = File_constant()
        tsconstant = TS_constant()
        proj_path = transDto.get_projectpath()

        # get the main table interface name
        main_tb_name = entityDto.get_maintableInterDTO().get_class_name()

        # copy from the generated ds
        if isCopy == 1:
            # get the generated ds name
            gene_ds_name = fileconstant.TS_DATASET_PREFIX + main_tb_name + fileconstant.TS_SUFFIX

            # get the generated ds full path
            gene_ds_filefullpath = proj_path + fileconstant.RESOURCE_TS_MAIN_PATH + fileconstant.RESOURCE_TS_DTO_BL_FOLDER + gene_ds_name
            # get the mock ds full path
            mock_ds_filefullpath = proj_path + fileconstant.RESOURCE_TS_MAIN_PATH + fileconstant.RESOURCE_TS_DTO_UI_FOLDER + mock_ds_name

            if not File_processor.verify_dir_existing(gene_ds_filefullpath):
                # throw error
                return False, 'The DTO %s does not generated in bl folder, please check.' % gene_ds_name

            # buffer the content of generated ds
            with open(gene_ds_filefullpath, 'r') as file:
                lines = file.readlines()

            # write the mock ds
            if not File_processor.verify_dir_existing(mock_ds_filefullpath):
                # create file
                Path(mock_ds_filefullpath).touch()

            # ------------------------------------------------------- #
            # ----- open the mock ds file -----
            # ------------------------------------------------------- #
            newfile = open(mock_ds_filefullpath, 'w')

            comment_flag = False
            for line in lines:
                if tsconstant.TS_LEFT_COMMENT in line:
                    comment_flag = True
                elif tsconstant.TS_RIGHT_COMMENT in line:
                    comment_flag = False

                if line[:6] == tsconstant.TS_KEYWORD_MODULE:
                    line = line.replace(tsconstant.TS_DTO_MODULE,
                                        tsconstant.TS_DTO_UI_MODULE)

                if not comment_flag and tsconstant.TS_COLON in line:
                    line = line.replace(
                        tsconstant.TS_COLON,
                        tsconstant.TS_QUESTION_MARK + tsconstant.TS_COLON)

                newfile.write(line)

            newfile.close()

        return True, None
Esempio n. 23
0
    def create_TS_ObserObj(entityDto, transDto, filename):
        '''
        create Observable Object
        '''
        #path constant
        fileconstant = File_constant()
        tsconstant = TS_constant()
        business_entity_name = entityDto.get_businessentityname()
        proj_path = transDto.get_projectpath()
        controller_dto = entityDto.get_dataControllerDTO()

        # get the parent package name
        parent_pack = Java_processor.analysis_dataController_package_name(
            controller_dto.get_class_package())
        # get the file full path
        filefullpath = proj_path + fileconstant.RESOURCE_TS_MAIN_PATH + fileconstant.RESOURCE_TS_DTO_UI_FOLDER + filename
        # additional references
        additional_reference = []
        # imports
        import_list = []
        # temp lines
        temp_lines = []

        # ------------------------------------------------------- #
        # ----- preparation -----
        # TODO: grid obj
        # ------------------------------------------------------- #
        for ajaxMtd in controller_dto.get_class_methods():
            # skip the method without parameters
            if len(ajaxMtd.get_method_ajax_resp()) == 0:
                continue

            # get the response parameters
            ajax_temp = ''
            for ajaxResp in ajaxMtd.get_method_ajax_resp():
                # convert the java type to TS type
                ajax_para_type_temp = TS_processor.convertJavaTypeToTSType(
                    ajaxResp.get_parameter_type())
                # verify and convert container type
                if ajax_para_type_temp.endswith(
                        fileconstant.JAVA_CONTAINER_SUFFIX):
                    # add import
                    import_name = ajax_para_type_temp[:-9]
                    import_prefix_part = ''
                    import_cells = ajaxResp.get_parameter_import().split(
                        tsconstant.TS_DOT_MARK)
                    idx = 0
                    while idx < len(import_cells):
                        if idx != len(import_cells) - 1:
                            import_prefix_part = import_prefix_part + import_cells[
                                idx] + tsconstant.TS_DOT_MARK
                        idx = idx + 1

                    import_temp = tsconstant.TS_OBSERVABLE_OBJ_NAMESPACE_TEMP % (
                        import_name, import_prefix_part, business_entity_name,
                        import_name + 's')
                    import_list.append(tsconstant.TS_TAB + import_temp)

                    # add additional references
                    reference_temp = tsconstant.TS_OBSERVABLE_OBJ_REFERENCE_TEMP % (
                        'bl', import_name)
                    additional_reference.append(reference_temp)

                    # convert the Container type to import name
                    ajax_para_type_temp = import_name

                ajax_temp = ajax_temp + '\n' + tsconstant.TS_TAB + tsconstant.TS_TAB + ajaxResp.get_parameter_name(
                ) + ': ' + ajax_para_type_temp + tsconstant.TS_END_MARK

            ajaxMtd_name = ajaxMtd.get_method_name()
            ajaxMtd_name = ajaxMtd_name[:1].upper() + ajaxMtd_name[1:]
            line = tsconstant.TS_TAB + tsconstant.TS_OBSERVABLE_OBJ_RESPONSE_TEMPLATE % (
                ajaxMtd_name, ajax_temp)

            temp_lines.append(line)
            temp_lines.append('\n')

        if not File_processor.verify_dir_existing(filefullpath):
            # create file
            Path(filefullpath).touch()

        # ------------------------------------------------------- #
        # ----- open the observable object file -----
        # ------------------------------------------------------- #
        file = open(filefullpath, 'w')

        # ------------------------------------------------------- #
        # ----- write the common references -----
        # ------------------------------------------------------- #
        for temp_ref in tsconstant.TS_REFERENCE_COMMON_REFERENCES:
            file.write(temp_ref)
            file.write('\n')

        # ------------------------------------------------------- #
        # ----- write the common references -----
        # ------------------------------------------------------- #
        for temp_ref in additional_reference:
            file.write(temp_ref)
            file.write('\n')

        file.write('\n')

        # ------------------------------------------------------- #
        # ----- write the observable object header -----
        # ------------------------------------------------------- #
        temp_header = tsconstant.TS_OBSERVABLE_OBJ_HEADER % (
            parent_pack, business_entity_name.lower(), business_entity_name)
        file.write(temp_header)
        file.write('\n')

        # ------------------------------------------------------- #
        # ----- write the imports -----
        # ------------------------------------------------------- #
        for temp_ref in import_list:
            file.write(temp_ref)
            file.write('\n')

        file.write('\n')

        # ------------------------------------------------------- #
        # ----- write the observable object content -----
        # ------------------------------------------------------- #
        for sub_line in temp_lines:
            file.write(sub_line)

        file.write(tsconstant.TS_RIGHT_BRACE)

        file.close()

        return True, None
Esempio n. 24
0
    def create_widges(self):
        javaconstant = Java_constant()
        #frame
        self.__frame1 = FormatableFrame(self)
        self.__frame1.pack(side=TOP)
        #Title
        self.__label01 = Label(self.__frame1,
                               text="ServiceImpl generator options",
                               width=45)
        self.__label01.pack(side=TOP, fill=X, ipady=10)

        #---- java validation flag
        self.__error = None
        self.__result = True

        #---- panel 01 ----------
        canv1 = Canvas(self, height=30, width=550)
        #label
        self.__label01 = Label(canv1, text='ServiceImpl name :')
        self.__label01.place(height=20, width=130, relx=0.03, rely=0.2)
        #input
        self.__feet = StringVar()
        self.__dicinput = Entry(canv1,
                                textvariable=self.__feet,
                                borderwidth=3,
                                bg='black',
                                foreground='yellow',
                                highlightcolor='red',
                                insertbackground='red')
        self.__dicinput.place(height=20, width=250, relx=0.3, rely=0.2)

        canv1.pack()

        #---- panel 02 ----------
        serviceInterDTO = self.get_dtos().get_serviceInterDTO()
        if not serviceInterDTO:
            self.__pack_errorpanel()
            return

        canv2 = Canvas(self, height=150, width=550)
        #label01
        self.__label01 = Label(canv2, text='Select the functions :')
        self.__label01.place(height=20, width=150, relx=0.01, rely=0.05)
        #left listbox and scrollbar
        self.__listboxleft = Listbox(canv2, width=30)
        self.__scrollleft = Scrollbar(canv2)
        self.__listboxleft.config(yscrollcommand=self.__scrollleft.set)
        self.__listboxleft.place(height=120, width=220, relx=0.02, rely=0.18)
        self.__scrollleft.place(height=120, width=20, relx=0.42, rely=0.18)
        self.__scrollleft.config(command=self.__listboxleft.yview)

        #middle buttons
        self.__button01 = Button(canv2,
                                 text='>',
                                 relief=RAISED,
                                 cursor='hand2')
        self.__button01.bind(
            '<Button-1>',
            self.__to_right_click_event)  #bind button click event
        self.__button01.place(height=25, width=25, relx=0.465, rely=0.2)

        self.__button02 = Button(canv2,
                                 text='>>',
                                 relief=RAISED,
                                 cursor='hand2')
        self.__button02.bind(
            '<Button-1>',
            self.__all_to_right_click_event)  #bind button click event
        self.__button02.place(height=25, width=25, relx=0.465, rely=0.4)

        self.__button03 = Button(canv2,
                                 text='<',
                                 relief=RAISED,
                                 cursor='hand2')
        self.__button03.bind(
            '<Button-1>', self.__to_left_click_event)  #bind button click event
        self.__button03.place(height=25, width=25, relx=0.465, rely=0.6)

        self.__button04 = Button(canv2,
                                 text='<<',
                                 relief=RAISED,
                                 cursor='hand2')
        self.__button04.bind(
            '<Button-1>',
            self.__all_to_left_click_event)  #bind button click event
        self.__button04.place(height=25, width=25, relx=0.465, rely=0.8)

        #right listbox and scrollbar
        self.__listboxright = Listbox(canv2, width=30)
        self.__scrollright = Scrollbar(canv2)
        self.__listboxright.config(yscrollcommand=self.__scrollright.set)
        self.__listboxright.place(height=120, width=220, relx=0.52, rely=0.18)
        self.__scrollright.place(height=120, width=20, relx=0.92, rely=0.18)
        self.__scrollright.config(command=self.__listboxright.yview)

        canv2.pack()

        #---- panel 03 ----------
        canv3 = Canvas(self, height=100, width=550)
        #label
        label1 = Label(canv3, text='Options:')
        label1.place(height=20, width=60, relx=0, rely=0)
        #radio box
        self.__vari1 = IntVar()
        self.__rad1 = Radiobutton(canv3,
                                  text='Re-write the previous file',
                                  variable=self.__vari1,
                                  value=1)
        self.__rad1.place(height=20, width=170, relx=0.1, rely=0.2)
        self.__rad1.select()
        self.__rad2 = Radiobutton(canv3,
                                  text='Attach new functions to the file',
                                  variable=self.__vari1,
                                  value=2)
        self.__rad2.place(height=20, width=210, relx=0.1, rely=0.45)
        self.__rad2.deselect()
        self.__rad3 = Radiobutton(canv3,
                                  text='Save the previous file as backup',
                                  variable=self.__vari1,
                                  value=3)
        self.__rad3.place(height=20, width=220, relx=0.1, rely=0.7)
        self.__rad3.deselect()
        canv3.pack()

        # set the serviceImpl name
        fileconstant = File_constant()
        serviceImpl_name = self.get_dtos().get_businessentityname(
        ) + fileconstant.SERVICEIMPL_SUFFIX + fileconstant.JAVA_SUFFIX
        self.__feet.set(serviceImpl_name)

        #set the function list to the left box
        for javaMtd in serviceInterDTO.get_class_methods():
            self.__funclists[javaMtd.get_method_name()] = javaMtd

            # CRUD functions are mandatory
            if javaMtd.get_method_name(
            ) == javaconstant.JAVA_FUNCTION_CREATE or javaMtd.get_method_name(
            ) == javaconstant.JAVA_FUNCTION_UPDATE or javaMtd.get_method_name(
            ) == javaconstant.JAVA_FUNCTION_DELETE or javaMtd.get_method_name(
            ) == javaconstant.JAVA_FUNCTION_FETCH:
                self.__listboxright.insert(END, javaMtd.get_method_name())
                continue

            #add items into list box
            self.__listboxleft.insert(END, javaMtd.get_method_name())
Esempio n. 25
0
    def verify_proj_files(self):
        '''
        verify the project fiels
        '''
        #path constant
        fileconstant = File_constant()
        entity_name = self.get_dtos().get_entityname()
        proj_path = self.get_trans().get_projectpath()

        #verify view metadata
        view_exist = False
        viewfullpath = self.get_dtos().get_viewfullpath()
        if not viewfullpath and entity_name:
            viewfullpath = proj_path + fileconstant.VIEW_METADATA_PATH + entity_name + fileconstant.XML_SUFFIX
            view_exist, self.__message = Xmlfile_processor.veriy_view_metadata(
                viewfullpath)
        elif viewfullpath:
            view_exist = True
        if view_exist:
            newlabel01 = "< passed >"
            self.__label04.config(text=newlabel01, fg='blue')
            self.get_dtos().set_viewfullpath(viewfullpath)
            self.__checkstatus['ViewMetadata'] = [True, self.__checkval01]
        else:
            newlabel01 = "< failed >"
            self.__label04.config(text=newlabel01, fg='red')
            btnlabel = 'Correct'
            self.__button01.config(text=btnlabel)
            self.__checkstatus['ViewMetadata'] = [False, self.__checkval01]
        self.__checkval01.set(1)
        #bind button click event
        self.__button01.bind(
            '<Button-1>',
            self.event_adapter(self.detal_button_click,
                               iscorrect=self.__checkstatus['ViewMetadata'][0],
                               filename=entity_name + fileconstant.XML_SUFFIX,
                               filetype='ViewMetadata',
                               filepath=viewfullpath))

        #verify source metadata
        resource_exist = False
        resourcefullpath = self.get_dtos().get_resourcefullpath()
        if not resourcefullpath and entity_name:
            resourcefullpath = proj_path + fileconstant.RESOURCE_METADATA_PATH + entity_name + fileconstant.RESOURCE_METADATA_SUFFIX
            resource_exist, self.__message = Xmlfile_processor.veriy_resource_metadata(
                resourcefullpath)
        if resource_exist:
            newlabel = "< passed >"
            self.__label06.config(text=newlabel, fg='blue')
            self.get_dtos().set_resourcefullpath(resourcefullpath)
            self.__checkstatus['ResourceMetadata'] = [True, self.__checkval02]
        else:
            newlabel = "< failed >"
            self.__label06.config(text=newlabel, fg='red')
            btnlabel = 'Correct'
            self.__button02.config(text=btnlabel)
            self.__checkstatus['ResourceMetadata'] = [False, self.__checkval02]
        self.__checkval02.set(1)
        self.__button02.bind(
            '<Button-1>',
            self.event_adapter(
                self.detal_button_click,
                iscorrect=self.__checkstatus['ResourceMetadata'][0],
                filename=entity_name + fileconstant.RESOURCE_METADATA_SUFFIX,
                filetype='ResourceMetadata',
                filepath=resourcefullpath))

        #verify pom
        result, self.__message = Xmlfile_processor.verify_pom(
            proj_path + fileconstant.POM_PATH)
        if result:
            #read the pom
            result, pomDto, self.__message = Xmlfile_processor.read_pom(
                proj_path + fileconstant.POM_PATH)
            newlabel = "< passed >"
            self.__label08.config(text=newlabel, fg='blue')
            self.get_trans().set_pomDto(pomDto)
            self.__checkstatus['Pom'] = [True, self.__checkval03]
        else:
            newlabel = "< failed >"
            self.__label08.config(text=newlabel, fg='red')
            btnlabel = 'Correct'
            self.__button03.config(text=btnlabel)
            self.__checkstatus['Pom'] = [False, self.__checkval03]
        self.__checkval03.set(1)
        self.__button03.bind(
            '<Button-1>',
            self.event_adapter(self.detal_button_click,
                               iscorrect=self.__checkstatus['Pom'][0],
                               filename='pom.xml',
                               filetype='POM',
                               filepath=proj_path + fileconstant.POM_PATH))

        #verify beans-app-context
        result, self.__message = Xmlfile_processor.verify_beans_app_context(
            proj_path + fileconstant.BEAN_APP_CONTEXT_PATH)
        if result:
            newlabel = "< passed >"
            self.__label10.config(text=newlabel, fg='blue')
            self.get_trans().set_pomDto(pomDto)
            self.__checkstatus['beans-app-context'] = [True, self.__checkval04]
        else:
            newlabel = "< failed >"
            self.__label10.config(text=newlabel, fg='red')
            btnlabel = 'Correct'
            self.__button04.config(text=btnlabel)
            self.__checkstatus['beans-app-context'] = [
                False, self.__checkval04
            ]
        self.__checkval04.set(1)
        self.__button04.bind(
            '<Button-1>',
            self.event_adapter(
                self.detal_button_click,
                iscorrect=self.__checkstatus['beans-app-context'][0],
                filename='beans-app-server.xml',
                filetype='beans',
                filepath=proj_path + fileconstant.BEAN_APP_CONTEXT_PATH))

        #verify entityMap
        result, self.__message = Xmlfile_processor.verify_entity_map(
            proj_path + fileconstant.ENTITY_MAP_PATH)
        if result:
            newlabel = "< passed >"
            self.__label12.config(text=newlabel, fg='blue')
            self.get_trans().set_pomDto(pomDto)
            self.__checkstatus['entityMap'] = [True, self.__checkval05]
        else:
            newlabel = "< failed >"
            self.__label12.config(text=newlabel, fg='red')
            btnlabel = 'Correct'
            self.__button05.config(text=btnlabel)
            self.__checkstatus['entityMap'] = [False, self.__checkval05]
        self.__checkval05.set(1)
        self.__button05.bind(
            '<Button-1>',
            self.event_adapter(self.detal_button_click,
                               iscorrect=self.__checkstatus['entityMap'][0],
                               filename='entityMap.xml',
                               filetype='entityMap',
                               filepath=proj_path +
                               fileconstant.ENTITY_MAP_PATH))

        #verify jar
        result = False
        jarname = None
        implJarfullpath = self.get_trans().get_finImplJarPath()
        apiJarfullpath = self.get_trans().get_finApiJarPath()
        #verify if jar is existing at the Maven's default repository
        #impl jar
        if not implJarfullpath:
            userhomepath = File_processor.get_user_home(
            ) + fileconstant.IMPL_JAR_LIB_PATH
            #jar name and full path
            implJarfullpath = userhomepath + pomDto.get_financials_api_version(
            ) + '\\' + fileconstant.FIN_IMPL_JAR_PREFIX + pomDto.get_financials_api_version(
            ) + fileconstant.JAR_SUFFIX
            jarname = fileconstant.FIN_IMPL_JAR_PREFIX + pomDto.get_financials_api_version(
            ) + fileconstant.JAR_SUFFIX

            result, self.__message = Java_processor.verify_jar_type(
                implJarfullpath)

            if result:
                newlabel = "< passed >"
                self.__label92.config(text=newlabel, fg='blue')
                self.get_trans().set_finImplJarPath(implJarfullpath)
                self.__checkstatus['ImplJAR'] = [True, self.__checkval91]
            else:
                newlabel = "< failed >"
                self.__label92.config(text=newlabel, fg='red')
                btnlabel = 'Correct'
                self.__button91.config(text=btnlabel)
                self.__checkstatus['ImplJAR'] = [False, self.__checkval91]
        else:
            newlabel = "< passed >"
            self.__label92.config(text=newlabel, fg='blue')
            self.__checkstatus['ImplJAR'] = [True, self.__checkval91]
            #jar name
            jarname = File_processor.get_file_name(
                self.get_trans().get_finImplJarPath())

        self.__checkval91.set(1)
        self.__button91.bind(
            '<Button-1>',
            self.event_adapter(self.detal_button_click,
                               iscorrect=self.__checkstatus['ImplJAR'][0],
                               filename=jarname,
                               filetype='ImplJAR',
                               filepath=implJarfullpath))
        # api jar
        if not apiJarfullpath:
            userhomepath = File_processor.get_user_home(
            ) + fileconstant.API_JAR_LIB_PATH
            #jar name and full path
            apiJarfullpath = userhomepath + pomDto.get_financials_api_version(
            ) + '\\' + fileconstant.FIN_API_JAR_PREFIX + pomDto.get_financials_api_version(
            ) + fileconstant.JAR_SUFFIX
            jarname = fileconstant.FIN_IMPL_JAR_PREFIX + pomDto.get_financials_api_version(
            ) + fileconstant.JAR_SUFFIX

            result, self.__message = Java_processor.verify_jar_type(
                apiJarfullpath)

            if result:
                newlabel = "< passed >"
                self.__label94.config(text=newlabel, fg='blue')
                self.get_trans().set_finApiJarPath(apiJarfullpath)
                self.__checkstatus['ApiJAR'] = [True, self.__checkval92]
            else:
                newlabel = "< failed >"
                self.__label94.config(text=newlabel, fg='red')
                btnlabel = 'Correct'
                self.__button92.config(text=btnlabel)
                self.__checkstatus['ApiJAR'] = [False, self.__checkval92]
        else:
            newlabel = "< passed >"
            self.__label94.config(text=newlabel, fg='blue')
            self.__checkstatus['ApiJAR'] = [True, self.__checkval92]
            #jar name
            jarname = File_processor.get_file_name(
                self.get_trans().get_finImplJarPath())

        self.__checkval92.set(1)
        self.__button92.bind(
            '<Button-1>',
            self.event_adapter(self.detal_button_click,
                               iscorrect=self.__checkstatus['ApiJAR'][0],
                               filename=jarname,
                               filetype='ApiJAR',
                               filepath=apiJarfullpath))