예제 #1
0
 def insertFeedData(self,collName,docs):
     ''' mock for mongo int inserting documents '''
     passCnt = 0
     if len(docs):
         passCnt += mongoInt.insertFeedData(collName,docs)
     else:
         logger.debug('docList is empty')
         if not mongoInt.createCollectionIfnot(collName):
             logger.warn('unable to create collection in mongodb')
     return passCnt
예제 #2
0
 def insertFeedData(self,collName,docs):
     ''' mock for mongo int inserting documents '''
     passCnt = 0
     if len(docs):
         passCnt += mongoInt.insertFeedData(collName,docs)
     else:
         logger.debug('docList is empty')
         if not mongoInt.createCollectionIfnot(collName):
             logger.warn('unable to create collection in mongodb')
     return passCnt
예제 #3
0
 def createUserNode(self,decodedFBJson):
     '''
     latitude & longitude also needs to be stored in neo4j for retrival of reveland tweets
     '''
     #decodedFBJson=json.loads(decodedFBJson) remove true for now
     #if mongoInt.insertFBUserLoginData(decodedFBJson) or True:
     mongoInt.insertFBUserLoginData(decodedFBJson)
     neo4jInt.createUserNode(graphDB,decodedFBJson,'user')
     interestList = ['hometown','location','work','education']
     for intr in interestList:
         if 'work' in intr:
             keyIs='employer'
         elif 'education' in intr:
             keyIs='school'
         if intr in decodedFBJson:
             if isinstance(decodedFBJson[intr],list):
                 for itm in decodedFBJson[intr]:
                     if itm.get('type') == None:
                             itm['type'] = keyIs
                     data = facebookInt.getIdLocation(itm[keyIs]['id'])
                     logger.debug('Facebook get address using id:%s',data)
                     if 'location' in data:
                         itm[keyIs].update(data['location'])
             else:
                 data = facebookInt.getIdLocation(decodedFBJson[intr]['id'])
                 logger.debug('Facebook get address using id:%s',data)
                 if 'location' in data:
                     decodedFBJson[intr].update(data['location'])
             #add IF check whther interest is part of data provided
             neo4jInt.createInterestNode(graphDB,decodedFBJson,intr)
             #creating mongoDb interest nodes with ID as thy are unique
             if not mongoInt.createCollectionIfnot(decodedFBJson['id']):
                 logger.warn('unable to create collection in mongodb')
         else:
             logger.debug('user key doesnot exists')
     logger.debug('dataFb decodedFBJson:%s',decodedFBJson)
     #else:
     #logger.debug('user already exists hence skipping the neo4J creation of nodes & interest')
     #once the nodes are created lets fetch the feeds
     return 1
예제 #4
0
 def createUserNode(self,decodedFBJson):
     '''
     latitude & longitude also needs to be stored in neo4j for retrival of reveland tweets
     '''
     #decodedFBJson=json.loads(decodedFBJson) remove true for now
     #if mongoInt.insertFBUserLoginData(decodedFBJson) or True:
     mongoInt.insertFBUserLoginData(decodedFBJson)
     neo4jInt.createUserNode(graphDB,decodedFBJson,'user')
     interestList = ['hometown','location','work','education']
     for intr in interestList:
         if 'work' in intr:
             keyIs='employer'
         elif 'education' in intr:
             keyIs='school'
         if intr in decodedFBJson:
             if isinstance(decodedFBJson[intr],list):
                 for itm in decodedFBJson[intr]:
                     if itm.get('type') == None:
                             itm['type'] = keyIs
                     data = facebookInt.getIdLocation(itm[keyIs]['id'])
                     logger.debug('Facebook get address using id:%s',data)
                     if 'location' in data:
                         itm[keyIs].update(data['location'])
             else:
                 data = facebookInt.getIdLocation(decodedFBJson[intr]['id'])
                 logger.debug('Facebook get address using id:%s',data)
                 if 'location' in data:
                     decodedFBJson[intr].update(data['location'])
             #add IF check whther interest is part of data provided
             neo4jInt.createInterestNode(graphDB,decodedFBJson,intr)
             #creating mongoDb interest nodes with ID as thy are unique
             if not mongoInt.createCollectionIfnot(decodedFBJson['id']):
                 logger.warn('unable to create collection in mongodb')
         else:
             logger.debug('user key doesnot exists')
     logger.debug('dataFb decodedFBJson:%s',decodedFBJson)
     #else:
     #logger.debug('user already exists hence skipping the neo4J creation of nodes & interest')
     #once the nodes are created lets fetch the feeds
     return 1