def addConcernToUser(current, concern): title = concern.get('title') description = concern.get('description') user = __getUserByEmail(current) newConcern, = getGraph().create({"title" : title, "description" : description}) __addConcernToIndex(title, newConcern) getGraph().create((user, "CREATES", newConcern))
def addConcernToUser(current, concern): title = concern.get('title') description = concern.get('description') user = __getUserByEmail(current) newConcern, = getGraph().create({ "title": title, "description": description }) __addConcernToIndex(title, newConcern) getGraph().create((user, "CREATES", newConcern))
def getContacts(email) : currentUser = __getUserByEmail(email) rels = list(getGraph().match(start_node=currentUser, rel_type="IS_FRIEND_OF")) contacts = [] for rel in rels: contacts.append(rel.end_node.get_properties()) #print getGraph().node(rel.end_node) return contacts
def getCommunities(email): currentUser = __getUserByEmail(email) rels = list(getGraph().match(start_node=currentUser, rel_type="BELONGS_TO")) communities = [] for rel in rels: communities.append(rel.end_node.get_properties()) #print (getGraph().node(rel.end_node)) return communities
def getContacts(email): currentUser = __getUserByEmail(email) rels = list(getGraph().match(start_node=currentUser, rel_type="IS_FRIEND_OF")) contacts = [] for rel in rels: contacts.append(rel.end_node.get_properties()) #print (getGraph().node(rel.end_node)) return contacts
def __newUser(userJson): email = userJson.get('email') newUser, = getGraph().create({ "name": userJson.get('name'), "surname": userJson.get('surname'), "email": email, "country": userJson.get('country'), "city": userJson.get('city') }) __addToUsersIndex(email, newUser)
def getAllConcerns(email): print ("getAllConcerns") currentUser = __getUserByEmail(email) rels = list(getGraph().match(start_node=currentUser, rel_type="CREATES")) concerns = [] for rel in rels: currentConcern = rel.end_node.get_properties() currentConcern["id"] = rel.end_node._id concerns.append(currentConcern) return concerns
def getAllConcerns(email): print("getAllConcerns") currentUser = __getUserByEmail(email) rels = list(getGraph().match(start_node=currentUser, rel_type="CREATES")) concerns = [] for rel in rels: currentConcern = rel.end_node.get_properties() currentConcern["id"] = rel.end_node._id concerns.append(currentConcern) return concerns
def addContactToUser(currentUser, newContact) : currentUser = __getUserByEmail(currentUser) newContact = __getUserByEmail(newContact) getGraph().create((currentUser, "IS_FRIEND_OF", newContact))
def deleteOneConcern(id): concern = getGraph().node(id) print(concern[0])
def getConcernsIndex(): return getGraph().get_or_create_index(neo4j.Node, "Concerns")
def __getCommunityIndex(): return getGraph().get_or_create_index(neo4j.Node, "Communities")
def __newCommunity(community): name = community.get('name') newCommunity = getGraph().create({"name" : name, "description" : community.get('description')}) __addToCommunityIndex(name, newCommunity)
def addContactToUser(currentUser, newContact): currentUser = __getUserByEmail(currentUser) newContact = __getUserByEmail(newContact) getGraph().create((currentUser, "IS_FRIEND_OF", newContact))
def addCommunityToContact(name, email): userFound = __getUserByEmail(email) communityFound = __getCommunity(name) getGraph().create((userFound, "BELONGS_TO", communityFound))
def __addToUsersIndex(email, newUser) : getGraph().get_or_create_index(neo4j.Node, "Users").add("email", email, newUser)
def __addToUsersIndex(email, newUser): getGraph().get_or_create_index(neo4j.Node, "Users").add("email", email, newUser)
def __getUsersIndex(): return getGraph().get_or_create_index(neo4j.Node, "Users")
def __newUser(userJson): email = userJson.get('email') newUser, = getGraph().create({"name" : userJson.get('name'), "surname" : userJson.get('surname'), "email" : email, "country" : userJson.get('country'), "city" : userJson.get('city')}) __addToUsersIndex(email, newUser)
def deleteOneConcern(id): concern = getGraph().node(id) print (concern[0])