Exemplo n.º 1
0
    def _add_options(my):
        ''' add the options to the select '''
        search_type = my._get_search_type()
        if not search_type:
            return
        # get all processes if no search type is given
        proj_code = Project.extract_project_code(search_type)
        is_group_restricted = False

        if my.has_empty:
            my.add_first_option()
        else:
            from asset_filter_wdg import ProcessFilterWdg
            if ProcessFilterWdg.has_restriction():
                is_group_restricted = True

        process_names, process_values = Pipeline.get_process_select_data(\
            search_type, is_filter=my.is_filter, project_code=proj_code,\
            is_group_restricted=is_group_restricted, sobject = my._sobject)


        my.set_option("values", process_values)
        my.set_option("labels", process_names)
        if not my.is_filter:
            behavior = {
            'type': 'onchange',
            'cbjs_action': "if (bvr.src_el.value=='')\
                {alert('Please choose a valid process.');}" }
Exemplo n.º 2
0
    def _add_options(self):
        ''' add the options to the select '''
        search_type = self._get_search_type()
        if not search_type:
            return
        # get all processes if no search type is given
        proj_code = Project.extract_project_code(search_type)
        is_group_restricted = False

        if self.has_empty:
            self.add_first_option()
        else:
            from asset_filter_wdg import ProcessFilterWdg
            if ProcessFilterWdg.has_restriction():
                is_group_restricted = True

        process_names, process_values = Pipeline.get_process_select_data(\
            search_type, is_filter=self.is_filter, project_code=proj_code,\
            is_group_restricted=is_group_restricted, sobject = self._sobject)

        self.set_option("values", process_values)
        self.set_option("labels", process_names)
        if not self.is_filter:
            behavior = {
                'type':
                'onchange',
                'cbjs_action':
                "if (bvr.src_el.value=='')\
                {alert('Please choose a valid process.');}"
            }
Exemplo n.º 3
0
    def get_config(my):
        # TEST
        config_xml = '''
        <config>
        <custom_filter>
          <element name='asset_library'>
            <display class='SelectWdg'>
                <query>prod/asset_library|code|code</query>
                <empty>true</empty>
            </display>
          </element>
          <element name='pipeline_code'>
            <display class='SelectWdg'>
                <query>sthpw/pipeline|code|code</query>
                <empty>true</empty>
            </display>
          </element>
        </custom_filter>
        </config>
        '''

        my.view = my.kwargs.get("search_view")
        if not my.view:
            my.view = 'custom_filter'
        #view = "custom_filter"
        project_code = Project.extract_project_code(my.search_type)
        search = Search("config/widget_config", project_code=project_code )
        search.add_filter("view", my.view)
        
       
        search.add_filter("search_type", my.base_search_type)
        config_sobj = search.get_sobject()
        if config_sobj:
            config_xml = config_sobj.get_value("config")
        
        else:
            config_xml = '''
            <config>
            <custom_filter>
            </custom_filter>
            </config>
            '''
            # use the one defined in the default config file
            file_configs = WidgetConfigView.get_configs_from_file(my.base_search_type, my.view)
            if file_configs:
                config = file_configs[0]
                xml_node = config.get_view_node()
                if xml_node is not None:
                    xml = Xml(config.get_xml().to_string())
                    config_xml = '<config>%s</config>' %xml.to_string(node=xml_node)

            


        from pyasm.widget import WidgetConfig
        config = WidgetConfig.get(view=my.view, xml=config_xml)

        return config
Exemplo n.º 4
0
    def get_config(my):
        # TEST
        config_xml = '''
        <config>
        <custom_filter>
          <element name='asset_library'>
            <display class='SelectWdg'>
                <query>prod/asset_library|code|code</query>
                <empty>true</empty>
            </display>
          </element>
          <element name='pipeline_code'>
            <display class='SelectWdg'>
                <query>sthpw/pipeline|code|code</query>
                <empty>true</empty>
            </display>
          </element>
        </custom_filter>
        </config>
        '''

        my.view = my.kwargs.get("search_view")
        if not my.view:
            my.view = 'custom_filter'
        #view = "custom_filter"
        project_code = Project.extract_project_code(my.search_type)
        search = Search("config/widget_config", project_code=project_code )
        search.add_filter("view", my.view)
        
       
        search.add_filter("search_type", my.base_search_type)
        config_sobj = search.get_sobject()
        if config_sobj:
            config_xml = config_sobj.get_value("config")
        
        else:
            config_xml = '''
            <config>
            <custom_filter>
            </custom_filter>
            </config>
            '''
            # use the one defined in the default config file
            file_configs = WidgetConfigView.get_configs_from_file(my.base_search_type, my.view)
            if file_configs:
                config = file_configs[0]
                xml_node = config.get_view_node()
                if xml_node is not None:
                    xml = Xml(config.get_xml().to_string())
                    config_xml = '<config>%s</config>' %xml.to_string(node=xml_node)

            


        from pyasm.widget import WidgetConfig
        config = WidgetConfig.get(view=my.view, xml=config_xml)

        return config
Exemplo n.º 5
0
    def get_config(self):

        self.view = self.kwargs.get("search_view")
        config = self.kwargs.get("search_config")

        if not self.view:
            self.view = 'custom_filter'
        #view = "custom_filter"

        project_code = Project.extract_project_code(self.search_type)

        search = Search("config/widget_config", project_code=project_code)
        search.add_filter("view", self.view)
        search.add_filter("search_type", self.base_search_type)
        config_sobjs = search.get_sobjects()

        from pyasm.search import WidgetDbConfig
        config_sobj = WidgetDbConfig.merge_configs(config_sobjs)

        if config_sobj:
            #config_xml = config_sobj.get("config")
            config_xml = config_sobj.get_xml().to_string()
            config_xml = config_xml.replace("&lt;", "<")
            config_xml = config_xml.replace("&gt;", ">")
            config_xml = Common.run_mako(config_xml)

        elif config:
            config_xml = '''
            <config>
            <custom_filter>%s
            </custom_filter>
            </config>
            ''' % config
        else:
            config_xml = '''
            <config>
            <custom_filter>
            </custom_filter>
            </config>
            '''
            # use the one defined in the default config file
            file_configs = WidgetConfigView.get_configs_from_file(
                self.base_search_type, self.view)
            if file_configs:
                config = file_configs[0]
                xml_node = config.get_view_node()
                if xml_node is not None:
                    xml = Xml(config.get_xml().to_string())
                    config_xml = '<config>%s</config>' % xml.to_string(
                        node=xml_node)

        from pyasm.widget import WidgetConfig
        config = WidgetConfig.get(view=self.view, xml=config_xml)

        return config
Exemplo n.º 6
0
    def get_config(self):


        self.view = self.kwargs.get("search_view")
        config = self.kwargs.get("search_config")

        if not self.view:
            self.view = 'custom_filter'
        #view = "custom_filter"

        project_code = Project.extract_project_code(self.search_type)

        search = Search("config/widget_config", project_code=project_code )
        search.add_filter("view", self.view)
        search.add_filter("search_type", self.base_search_type)
        config_sobjs = search.get_sobjects()

        from pyasm.search import WidgetDbConfig
        config_sobj = WidgetDbConfig.merge_configs(config_sobjs)

        if config_sobj:
            #config_xml = config_sobj.get("config")
            config_xml = config_sobj.get_xml().to_string()
            config_xml = config_xml.replace("&lt;", "<")
            config_xml = config_xml.replace("&gt;", ">")
            config_xml = Common.run_mako(config_xml)

        elif config:
            config_xml = '''
            <config>
            <custom_filter>%s
            </custom_filter>
            </config>
            ''' % config
        else:
            config_xml = '''
            <config>
            <custom_filter>
            </custom_filter>
            </config>
            '''
            # use the one defined in the default config file
            file_configs = WidgetConfigView.get_configs_from_file(self.base_search_type, self.view)
            if file_configs:
                config = file_configs[0]
                xml_node = config.get_view_node()
                if xml_node is not None:
                    xml = Xml(config.get_xml().to_string())
                    config_xml = '<config>%s</config>' %xml.to_string(node=xml_node)

            
        from pyasm.widget import WidgetConfig
        config = WidgetConfig.get(view=self.view, xml=config_xml)

        return config
Exemplo n.º 7
0
    def get_process_names(my):
        '''get a unique list of process names'''
        search_type = my._get_search_type()
        proj_code = Project.extract_project_code(search_type)

        dict = Pipeline.get_process_name_dict(search_type, project_code=proj_code)
        process_list = []
        for x in dict.values():
            process_list.extend(x)
        names = Common.get_unique_list(process_list)
        return names
Exemplo n.º 8
0
    def get_process_names(self):
        '''get a unique list of process names'''
        search_type = self._get_search_type()
        proj_code = Project.extract_project_code(search_type)

        dict = Pipeline.get_process_name_dict(search_type,
                                              project_code=proj_code)
        process_list = []
        for x in dict.values():
            process_list.extend(x)
        names = Common.get_unique_list(process_list)
        return names
Exemplo n.º 9
0
    def execute(my):

        input = my.get_input()
        search_key = input.get("search_key")
        search_code = input.get('search_code')

        sobj_id = input.get('id')
        if not sobj_id:
            sobj = Search.get_by_search_key(search_key)
            sobj_id = sobj.get_id()

        assert(sobj_id != None)

        # it is possible that the id is not an integer (ie MongoDb)
        # In this case, search_id cannot be used and this id is considered
        # a code
        if not search_code and not isinstance(sobj_id, int):
            search_code = sobj_id

        search_type = SearchKey.extract_search_type(search_key)
        
        # find the old sobject
        if sobj_id != -1:
            search = Search("sthpw/sobject_list")
            search.add_filter( "search_type", search_type )
            if search_code:
                search.add_filter( "search_code", search_code )
            else:
                search.add_filter( "search_id", sobj_id )
            sobject = search.get_sobject()
        else:
            sobject = None
        
        
        if input.get("is_delete") == True:
            if sobject:
                sobject.delete()
            return

        if not sobject:
            sobject = SearchType.create("sthpw/sobject_list")


        if not search_type.startswith("sthpw/"):
            project_code = Project.extract_project_code(search_type)
        else:
            project = "admin"

        sobject.set_value("project_code", project_code)



        caller = my.get_caller()

        data = set()

        data.update( my.cleanup(caller.get_value("code", no_exception=True) ))
        data.update( my.cleanup(caller.get_value("name", no_exception=True) ))
        data.update( my.cleanup(caller.get_value("description", no_exception=True) ))
        data.update( my.cleanup(caller.get_value("keywords", no_exception=True) ))

        # extra columns to add
        columns = []
        for column in columns:
            data.append( my.cleanup(caller.get_value(column) ))

        
        keywords = " ".join(data)
        sobject.set_value("keywords", keywords)

        sobject.set_parent(caller)
        sobject.commit(triggers=False)
Exemplo n.º 10
0
    def execute(self):

        self.handle_keywords()


        input = self.get_input()
        search_key = input.get("search_key")
        search_code = input.get('search_code')

        sobj_id = input.get('id')
        sobj = Search.get_by_search_key(search_key)


        # Why not user caller???? 
        caller = self.get_caller()

        # see if this sobject is the list of sobjects that need to be in the
        # sobject list
        search_types = ProjectSetting.get_value_by_key("global_search/search_types")
        if search_types:
            search_types = search_types.split(",")
            if sobj and sobj.get_base_search_type() not in search_types:
                return

        
        if not sobj_id:
            sobj_id = sobj.get_id()

        assert(sobj_id != None)

        # it is possible that the id is not an integer (ie MongoDb)
        # In this case, search_id cannot be used and this id is considered
        # a code
        if not search_code and not isinstance(sobj_id, int):
            search_code = sobj_id

        search_type = SearchKey.extract_search_type(search_key)

        input_search_type = input.get("search_type")
        base_search_type = input_search_type.split("?")[0]

        # find the old sobject list entry
        if sobj_id != -1:
            search = Search("sthpw/sobject_list")
            search.add_filter( "search_type", search_type )
            if search_code:
                search.add_filter( "search_code", search_code )
            else:
                search.add_filter( "search_id", sobj_id )
            sobject = search.get_sobject()
        else:
            sobject = None


        # delete the sobject list
        if input.get("is_delete") == True:
            if sobject:
                sobject.delete()
            return

        if not sobject:
            sobject = SearchType.create("sthpw/sobject_list")
            sobject.set_auto_code()

        if not search_type.startswith("sthpw/"):
            project_code = Project.extract_project_code(search_type)
        else:
            project = "admin"

        sobject.set_value("project_code", project_code)



        # build up a data set for sobject list
        data = set()

        data.update( self.cleanup(caller.get_value("code", no_exception=True) ))
        data.update( self.cleanup(caller.get_value("name", no_exception=True) ))
        data.update( self.cleanup(caller.get_value("description", no_exception=True) ))
        data.update( self.cleanup(caller.get_value("keywords", no_exception=True) ))

        # commit the information
        keywords = " ".join(data)
        sobject.set_value("keywords", keywords)

        sobject.set_parent(caller)
        sobject.commit(triggers=False)
Exemplo n.º 11
0
    def execute(self):

        self.handle_keywords()

        input = self.get_input()
        search_key = input.get("search_key")
        search_code = input.get('search_code')

        sobj_id = input.get('id')
        sobj = Search.get_by_search_key(search_key)

        # Why not user caller????
        caller = self.get_caller()

        # see if this sobject is the list of sobjects that need to be in the
        # sobject list
        search_types = ProjectSetting.get_value_by_key(
            "global_search/search_types")
        if search_types:
            search_types = search_types.split(",")
            if sobj and sobj.get_base_search_type() not in search_types:
                return

        if not sobj_id:
            sobj_id = sobj.get_id()

        assert (sobj_id != None)

        # it is possible that the id is not an integer (ie MongoDb)
        # In this case, search_id cannot be used and this id is considered
        # a code
        if not search_code and not isinstance(sobj_id, int):
            search_code = sobj_id

        search_type = SearchKey.extract_search_type(search_key)

        input_search_type = input.get("search_type")
        base_search_type = input_search_type.split("?")[0]

        # find the old sobject list entry
        if sobj_id != -1:
            search = Search("sthpw/sobject_list")
            search.add_filter("search_type", search_type)
            if search_code:
                search.add_filter("search_code", search_code)
            else:
                search.add_filter("search_id", sobj_id)
            sobject = search.get_sobject()
        else:
            sobject = None

        # delete the sobject list
        if input.get("is_delete") == True:
            if sobject:
                sobject.delete()
            return

        if not sobject:
            sobject = SearchType.create("sthpw/sobject_list")
            sobject.set_auto_code()

        if not search_type.startswith("sthpw/"):
            project_code = Project.extract_project_code(search_type)
        else:
            project = "admin"

        sobject.set_value("project_code", project_code)

        # build up a data set for sobject list
        data = set()

        data.update(self.cleanup(caller.get_value("code", no_exception=True)))
        data.update(self.cleanup(caller.get_value("name", no_exception=True)))
        data.update(
            self.cleanup(caller.get_value("description", no_exception=True)))
        data.update(
            self.cleanup(caller.get_value("keywords", no_exception=True)))

        # commit the information
        keywords = " ".join(data)
        sobject.set_value("keywords", keywords)

        sobject.set_parent(caller)
        sobject.commit(triggers=False)