Beispiel #1
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    
    def create_widges(self):
        javaconstant = Java_constant()
        #frame
        self.__frame1 = FormatableFrame(self)
        self.__frame1.pack(side=TOP)
        #Title
        self.__label01 = Label(self.__frame1,
                               text="Controller 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='DataController 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

        # get the function list from serviceImpl
        func_list = []
        if self.get_dtos().get_serviceImplPath():
            for temp_mtd in self.get_dtos().get_serviceImplDTO(
            ).get_class_methods():
                func_list.append(temp_mtd.get_method_name())
        else:
            self.__error = 'ServiceImpl cannot analysis, please check!'
            self.__pack_errorpanel()
            return

        #---- panel 02 ----------
        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 dataController name
        fileconstant = File_constant()
        dataController_name = self.get_dtos().get_businessentityname(
        ) + fileconstant.DATACONTROLLER_SUFFIX + fileconstant.JAVA_SUFFIX
        self.__feet.set(dataController_name)

        # set the functions into left box
        if func_list:
            for func_name in func_list:
                # CRUD functions are mandatory
                if func_name == javaconstant.JAVA_FUNCTION_CREATE or func_name == javaconstant.JAVA_FUNCTION_UPDATE or func_name == javaconstant.JAVA_FUNCTION_DELETE or func_name == javaconstant.JAVA_FUNCTION_FETCH:
                    self.__listboxright.insert(END, func_name)
                    continue

                #add items into list box
                self.__listboxleft.insert(END, func_name)
                self.__funclists.append(func_name)
Beispiel #3
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
    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))