def group_locations(self): """ :return: list of locations """ group_locations = self._graph_db.match(start_node=self.group_node, rel_type=GraphRelationship.LOCATED_IN, end_node=None) locations_list = [] for rel in group_locations: location_dict = {} location = Location() location.id = rel.end_node['id'] location_dict = dict(location.location_properties) locations_list.append(location_dict) # locations_list.append(item.end_node["formatted_address"]) return locations_list
def add_location(self, location_json): """ link user to location nodes :param locations_place_id: :return: """ #TODO exception handling #TODO do in location and pass in the node from the actual object (better pattern) location_place_id = location_json['id'] location = Location() location.id = location_place_id location_node = location.location_node_by_place_id if not location_node: location.set_location_properties(location_json) location.create_location() location_node = location.location_node_by_place_id() user_location_relationship = Relationship(self.user_node, GraphRelationship.LOCATED_IN, location_node) # try: self._graph_db.create_unique(user_location_relationship)