当前位置: 首页>>代码示例>>Python>>正文


Python Search.add_join方法代码示例

本文整理汇总了Python中pyasm.search.Search.add_join方法的典型用法代码示例。如果您正苦于以下问题:Python Search.add_join方法的具体用法?Python Search.add_join怎么用?Python Search.add_join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasm.search.Search的用法示例。


在下文中一共展示了Search.add_join方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_data

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_join [as 别名]
    def get_data(self):
        """
        <element name='work_location' title='Originating Site'>
          <display class='tactic.ui.table.ExpressionElementWdg'>
            <expression>@GET(MMS/work_location.location)</expression>
            <alt_expression>@GET(MMS/work_location.id)</alt_expression>
            <order_by>work_location.location</order_by>
          </display>
        </element>
        """


        data = {}

        sobjects = self.sobjects
        if not sobjects:
            return data

        #template = "MMS/subtask.MMS/job.MMS/request.MMS/security_classification"
        template = self.get_option("template")
        keys = template.split(".")

        # get the sobjects (main search)
        search_type_obj = sobjects[0].get_search_type_obj()
        join_table = search_type_obj.get_table()
        search_type = search_type_obj.get_value("search_type")

        if keys[0] != search_type:
            keys.insert(0, search_type)

        search_ids = []
        for sobject in sobjects:
            search_id = sobject.get_id()
            search_ids.append(search_id)


        keys.reverse()

        # create main search
        search = Search(keys[0])
        table = search.get_table()

        # add the columns
        search.add_column("*", table=table)
        # add the id column from the joined table
        search.add_column("id", table=join_table, as_column='%s_id' % join_table)

        current_key = None
        for i in range(1, len(keys)):
            key = keys[i]
            namespace, table = key.split("/")
            search.add_join(key, current_key)

            current_key = key

        search.add_filters("id", search_ids, table=table)
        search.set_show_retired(True)

        results = search.get_sobjects()

        # make into a dictionary based on search id
        for result in results:
            id = result.get_value("%s_id" % join_table)
            data[id] = result
            print id, result.get_data()

        print "results: ", len(results)
        return data
开发者ID:mincau,项目名称:TACTIC,代码行数:70,代码来源:related_element_wdg.py


注:本文中的pyasm.search.Search.add_join方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。