Пример #1
0
 def getRelationships(self):
     function = getattr(self.client.service, self.context.protoProtoRelationshipOperation)
     horribleString = function(self.verificationNum)
     relationships = []
     for row in splitDMCCRows(horribleString):
         relationships.append(Relationship(row))
     return relationships
Пример #2
0
    def generateGraph(self):
        context = aq_inner(self.context)
        if not context.webServiceURL: raise MissingParameterError(context, 'webServiceURL')
        if not context.operationName: raise MissingParameterError(context, 'operationName')
        if not context.identifyingKey: raise MissingParameterError(context, 'identifyingKey')
        if not context.uriPrefix: raise MissingParameterError(context, 'uriPrefix')
        if not context.typeURI: raise MissingParameterError(context, 'typeURI')
        verificationNum = context.verificationNum if context.verificationNum else DEFAULT_VERIFICATION_NUM
        predicates = {}
        for objID, item in context.contentItems():
            predicates[item.title] = IAsserter(item)
        client = get_suds_client(context.webServiceURL, context)
        function = getattr(client.service, context.operationName)
        horribleString = function(verificationNum)
        graph = rdflib.Graph()
        for row in splitDMCCRows(horribleString):
            subjectURI, statements, statementsMade = None, [], False
            for key, value in parseTokens(row):
                if key == context.identifyingKey and not subjectURI:
                    subjectURI = URIRef(context.uriPrefix + value)
                elif key in predicates and len(value) > 0:
                    statements.extend(predicates[key].characterize(value))
                    statementsMade = True
            # DMCC is giving out empty rows: they have an Identifier number, but no values in any of the columns.
            # While we may wish to generate RDF for those (essentially just saying "Disease #31 exists", for example)
            # It means we need to update EDRN Portal code to handle them, which we can't do right now.
            # So just drop these.  TODO: Add them back, but update the EDRN Portal.
            if statementsMade:
                graph.add((subjectURI, rdflib.RDF.type, URIRef(context.typeURI)))
                for predicate, obj in statements:
                    graph.add((subjectURI, predicate, obj))
        return graph

                        
Пример #3
0
 def getSpecifics(self):
     function = getattr(self.client.service, self.context.protoSiteSpecificsOperation)
     horribleString = function(self.verificationNum)
     specifics = {}
     for row in splitDMCCRows(horribleString):
         specific = Specifics(row)
         specifics[(specific.protocolID, specific.siteID)] = specific
     return specifics
Пример #4
0
 def generateGraph(self):
     graph = rdflib.Graph()
     context = aq_inner(self.context)
     verificationNum = context.verificationNum if context.verificationNum else DEFAULT_VERIFICATION_NUM
     client = get_suds_client(context.webServiceURL, context)
     committees = getattr(client.service, context.committeeOperation)
     members = getattr(client.service, context.membershipOperation)
     
     # Get the committees
     horribleCommittees = committees(verificationNum)
     for row in splitDMCCRows(horribleCommittees):
         subjectURI = None
         statements = {}
         for key, value in parseTokens(row):
             if key == u'Identifier' and not subjectURI:
                 subjectURI = URIRef(context.uriPrefix + value)
                 graph.add((subjectURI, rdflib.RDF.type, URIRef(context.typeURI)))
             elif key in _committeePredicates and len(value) > 0:
                 predicateURI = URIRef(getattr(context, _committeePredicates[key]))
                 statements[predicateURI] = Literal(value)
         for predicateURI, obj in statements.iteritems():
             graph.add((subjectURI, predicateURI, obj))
     
     # Get the members of the committees
     horribleMembers = members(verificationNum)
     for row in splitDMCCRows(horribleMembers):
         subjectURI = predicateURI = obj = None
         for key, value in parseTokens(row):
             if not value: continue
             if key == u'committee_identifier':
                 subjectURI = URIRef(context.uriPrefix + value)
             elif key == u'Registered_Person_Identifer':
                 obj = URIRef(context.personPrefix + value)
             elif key == u'roleName':
                 if value not in _roleNamePredicates: continue
                 predicateURI = URIRef(getattr(context, _roleNamePredicates[value]))
         if subjectURI and predicateURI and obj:
             graph.add((subjectURI, predicateURI, obj))
     
     # C'est tout.
     return graph
Пример #5
0
 def getSlottedItems(self, operation, kind):
     function = getattr(self.client.service, operation)
     horribleString = function(self.verificationNum)
     objects = {}
     obj = None
     for row in splitDMCCRows(horribleString):
         lastSlot = None
         for key, value in parseTokens(row):
             if key == u"Identifier":
                 if obj is None or obj.identifier != value:
                     obj = kind(value)
                     objects[value] = obj
             elif key == u"slot":
                 lastSlot = value
             elif key == u"value":
                 if lastSlot is None:
                     raise ValueError('Value with no preceding slot in row "%r"' % row)
                 obj.slots[lastSlot] = value
                 lastSlot = None
     return objects