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


Python XMLdata.executeQueryFullResult方法代码示例

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


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

示例1: test_invert_str

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import executeQueryFullResult [as 别名]
 def test_invert_str(self):
     criteria = build_criteria("content.root.str", "is", "test1", "xs:string", "xs")
     results = XMLdata.executeQueryFullResult(criteria)
     self.assertTrue(len(results) == 1)
     inverted = invertQuery(criteria)
     inverted_results = XMLdata.executeQueryFullResult(inverted)
     self.assertTrue(len(inverted_results) == 2)
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:9,代码来源:tests.py

示例2: test_invert_numeric

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import executeQueryFullResult [as 别名]
 def test_invert_numeric(self):
     criteria = build_criteria("content.root.integer", "=", 1, "xs:int", "xs")
     results = XMLdata.executeQueryFullResult(criteria)
     self.assertTrue(len(results) == 1)
     inverted = invertQuery(criteria)
     inverted_results = XMLdata.executeQueryFullResult(inverted)
     self.assertTrue(len(inverted_results) == 2)
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:9,代码来源:tests.py

示例3: test_invert_and_numeric

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import executeQueryFullResult [as 别名]
 def test_invert_and_numeric(self):
     criteria1 = build_criteria("content.root.integer", "gt", 1, "xs:int", "xs")
     criteria2 = build_criteria("content.root.integer", "lte", 3, "xs:int", "xs")
     criteria = ANDCriteria(criteria1, criteria2)
     results = XMLdata.executeQueryFullResult(criteria)
     self.assertTrue(len(results) == 2)
     inverted = invertQuery(criteria)
     inverted_results = XMLdata.executeQueryFullResult(inverted)
     self.assertTrue(len(inverted_results) == 3)
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:11,代码来源:tests.py

示例4: get_record

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import executeQueryFullResult [as 别名]
    def get_record(self):
        try:
            #Bool if we need to transform the XML via XSLT
            hasToBeTransformed = False
            #Check if the identifier pattern is OK
            id = self.check_identifier()
            #Template name
            self.template_name = 'oai_pmh/xml/get_record.xml'
            query = dict()
            #Convert id to ObjectId
            try:
                query['_id'] = ObjectId(id)
                #The record has to be published
                query['ispublished'] = True
            except Exception:
                raise idDoesNotExist(self.identifier)
            data = XMLdata.executeQueryFullResult(query)
            #This id doesn't exist
            if len(data) == 0:
                raise idDoesNotExist(self.identifier)
            data = data[0]
            #Get the template for the identifier
            template = data['schema']
            #Retrieve sets for this template
            sets = OaiMySet.objects(templates=template).all()
            #Retrieve the XSLT for the transformation
            try:
                #Get the metadataformat for the provided prefix
                myMetadataFormat = OaiMyMetadataFormat.objects.get(metadataPrefix=self.metadataPrefix)
                #If this metadata prefix is not associated to a template, we need to retrieve the XSLT to do the transformation
                if not myMetadataFormat.isTemplate:
                    hasToBeTransformed = True
                    #Get information about the XSLT for the MF and the template
                    objTempMfXslt = OaiTemplMfXslt.objects(myMetadataFormat=myMetadataFormat, template=template, activated=True).get()
                    #If no information or desactivated
                    if not objTempMfXslt.xslt:
                        raise cannotDisseminateFormat(self.metadataPrefix)
                    else:
                        #Get the XSLT for the transformation
                        xslt = objTempMfXslt.xslt
            except:
                raise cannotDisseminateFormat(self.metadataPrefix)

            #Transform XML data
            dataToTransform = [{'title': data['_id'], 'content': self.cleanXML(xmltodict.unparse(data['content']))}]
            if hasToBeTransformed:
                dataXML = self.getXMLTranformXSLT(dataToTransform, xslt)
            else:
                dataXML = dataToTransform
            #Fill the response
            record_info = {
                'identifier': self.identifier,
                'last_modified': datestamp.datetime_to_datestamp(data['publicationdate']) if 'publicationdate' in data else datestamp.datetime_to_datestamp(datetime.datetime.min),
                'sets': sets,
                'XML': dataXML[0]['content']
            }
            return self.render_to_response(record_info)
        except OAIExceptions, e:
            return self.errors(e.errors)
开发者ID:pdessauw,项目名称:MaterialsResourceRegistry,代码行数:61,代码来源:views.py

示例5: list_identifiers

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import executeQueryFullResult [as 别名]
    def list_identifiers(self):
        try:
            #Template name
            self.template_name = 'oai_pmh/xml/list_identifiers.xml'
            query = dict()
            items=[]
            #Handle FROM and UNTIL
            query = self.check_dates()
            try:
                #Get the metadata format thanks to the prefix
                myMetadataFormat = OaiMyMetadataFormat.objects.get(metadataPrefix=self.metadataPrefix)
                #Get all template using it (activated True)
                templates = OaiTemplMfXslt.objects(myMetadataFormat=myMetadataFormat, activated=True).distinct(field="template")
                #Ids
                templatesID = [str(x.id) for x in templates]
                #If myMetadataFormat is linked to a template, we add the template id
                if myMetadataFormat.isTemplate:
                    templatesID.append(str(myMetadataFormat.template.id))
            except:
                #The metadata format doesn't exist
                raise cannotDisseminateFormat(self.metadataPrefix)
            if self.set:
                try:
                    setsTemplates = OaiMySet.objects(setSpec=self.set).only('templates').get()
                    templatesID = set(templatesID).intersection([str(x.id) for x in setsTemplates.templates])
                except Exception, e:
                    raise noRecordsMatch
            for template in templatesID:
                #Retrieve sets for this template
                sets = OaiMySet.objects(templates=template).all()
                query['schema'] = template
                #The record has to be published
                query['ispublished'] = True
                #Get all records for this template
                data = XMLdata.executeQueryFullResult(query)
                #IF no records, go to the next template
                if len(data) == 0:
                    continue
                for i in data:
                    #Fill the response
                    identifier = '%s:%s:id/%s' % (settings.OAI_SCHEME, settings.OAI_REPO_IDENTIFIER, str(i['_id']))
                    item_info = {
                        'identifier': identifier,
                        'last_modified': self.get_last_modified_date(i),
                        'sets': sets,
                        'deleted': i.get('status', '') == Status.DELETED
                    }
                    items.append(item_info)
            #If there is no records
            if len(items) == 0:
                raise noRecordsMatch

            return self.render_to_response({'items': items})
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:55,代码来源:views.py

示例6: test_enum_not

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import executeQueryFullResult [as 别名]
 def test_enum_not(self):
     criteria = build_criteria("content.root.enum", "is", "a", "enum", "xs", isNot=True)
     results = XMLdata.executeQueryFullResult(criteria)
     self.assertTrue(len(results) == 2)
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:6,代码来源:tests.py

示例7: test_numeric_superior_equals

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import executeQueryFullResult [as 别名]
 def test_numeric_superior_equals(self):
     criteria = build_criteria("content.root.integer", "gte", 1, "xs:int", "xs")
     results = XMLdata.executeQueryFullResult(criteria)
     self.assertTrue(len(results) == 3)
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:6,代码来源:tests.py

示例8: set

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import executeQueryFullResult [as 别名]
 #if a set was provided, we filter the templates
 if self.set:
     try:
         setsTemplates = OaiMySet.objects(setSpec=self.set).only('templates').get()
         templatesID = set(templatesID).intersection([str(x.id) for x in setsTemplates.templates])
     except Exception, e:
         raise noRecordsMatch
 #For each template found
 for template in templatesID:
     #Retrieve sets for this template
     sets = OaiMySet.objects(templates=template).all()
     query['schema'] = template
     #The record has to be published
     query['ispublished'] = True
     #Get all records for this template
     data = XMLdata.executeQueryFullResult(query)
     #IF no records, go to the next template
     if len(data) == 0:
         continue
     dataToTransform = [{'title': x['_id'], 'content': self.cleanXML(xmltodict.unparse(x['content']))} for x in data]
     if myMetadataFormat.isTemplate:
         #No transformation needed
         dataXML = dataToTransform
     else:
         #Get the XSLT file
         xslt = objTempMfXslt(template=template).get().xslt
         #Transform all XML data (1 call)
         dataXML = self.getXMLTranformXSLT(dataToTransform, xslt)
     #Add each record
     for elt in data:
         identifier = '%s:%s:id/%s' % (settings.OAI_SCHEME, settings.OAI_REPO_IDENTIFIER,
开发者ID:pdessauw,项目名称:MaterialsResourceRegistry,代码行数:33,代码来源:views.py

示例9: test_numeric_not

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import executeQueryFullResult [as 别名]
 def test_numeric_not(self):
     criteria = build_criteria("content.root.integer", "=", 1, "xs:int", "xs", isNot=True)
     results = XMLdata.executeQueryFullResult(criteria)
     self.assertTrue(len(results) == 2)
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:6,代码来源:tests.py

示例10: test_numeric_inferior

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import executeQueryFullResult [as 别名]
 def test_numeric_inferior(self):
     criteria = build_criteria("content.root.integer", "lt", 3, "xs:int", "xs")
     results = XMLdata.executeQueryFullResult(criteria)
     self.assertTrue(len(results) == 2)
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:6,代码来源:tests.py

示例11: test_decimal_not

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import executeQueryFullResult [as 别名]
 def test_decimal_not(self):
     criteria = build_criteria("content.root.float", "=", 1, "xs:float", "xs", isNot=True)
     results = XMLdata.executeQueryFullResult(criteria)
     self.assertTrue(len(results) == 2)
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:6,代码来源:tests.py

示例12: test_str_encoding

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import executeQueryFullResult [as 别名]
 def test_str_encoding(self):
     criteria = build_criteria("content.root.str", "is", "test", "xs:string", "xs", isNot=True)
     results = XMLdata.executeQueryFullResult(criteria)
     self.assertTrue(len(results) == 1)
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:6,代码来源:tests.py

示例13: test_regex_not

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import executeQueryFullResult [as 别名]
 def test_regex_not(self):
     criteria = build_criteria("content.root.str", "like", "test", "xs:string", "xs", isNot=True)
     manageRegexBeforeExe(criteria)
     results = XMLdata.executeQueryFullResult(criteria)
     self.assertTrue(len(results) == 0)
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:7,代码来源:tests.py

示例14: test_str_false

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import executeQueryFullResult [as 别名]
 def test_str_false(self):
     criteria = build_criteria("content.root.str", "is", "test4", "xs:string", "xs")
     results = XMLdata.executeQueryFullResult(criteria)
     self.assertTrue(len(results) == 0)
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:6,代码来源:tests.py

示例15: test_decimal_false

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import executeQueryFullResult [as 别名]
 def test_decimal_false(self):
     criteria = build_criteria("content.root.float", "=", 4, "xs:float", "xs")
     results = XMLdata.executeQueryFullResult(criteria)
     self.assertTrue(len(results) == 0)
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:6,代码来源:tests.py


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