def __init__(self, dbm, entity_type=None, location=None, aggregation_paths=None, geometry=None, centroid=None, gr_id=None, id=None, short_code=None, is_datasender=True): """ Construct a new entity. Note: _couch_document is used for 'protected' factory methods and should not be passed in standard construction. If _couch_document is passed, the other args are ignored :param entity_type: may be a string (flat type) or sequence (hierarchical type) :param location: hierarchical list of location names :pram aggregation_paths: hierarchical list of aggregation path :pram geometry: hierarchical list of aggregation path :pram short_code: code for the entity """ assert isinstance(dbm, DatabaseManager) assert entity_type is None or is_sequence(entity_type) or is_string(entity_type) assert location is None or is_sequence(location) assert aggregation_paths is None or isinstance(aggregation_paths, dict) assert geometry is None or isinstance(geometry, dict) assert centroid is None or isinstance(centroid, list) assert gr_id is None or is_string(gr_id) DataObject.__init__(self, dbm) # Are we being constructed from an existing doc, in which case all the work is # in _set_document? if entity_type is None: return # Not made from existing doc, so create a new one self._create_new_entity_doc(aggregation_paths, centroid, entity_type, geometry, gr_id, id, location, short_code, is_datasender)
def __init__(self, dbm, entity_type=None, location=None, aggregation_paths=None, geometry=None, centroid=None, gr_id=None, id=None, short_code=None): """ Construct a new entity. Note: _couch_document is used for 'protected' factory methods and should not be passed in standard construction. If _couch_document is passed, the other args are ignored entity_type may be a string (flat type) or sequence (hierarchical type) """ assert isinstance(dbm, DatabaseManager) assert entity_type is None or is_sequence(entity_type) or is_string(entity_type) assert location is None or is_sequence(location) assert aggregation_paths is None or isinstance(aggregation_paths, dict) assert geometry is None or isinstance(geometry, dict) assert centroid is None or isinstance(centroid, list) assert gr_id is None or is_string(gr_id) DataObject.__init__(self, dbm) # Are we being constructed from an existing doc, in which case all the work is # in _set_document? if entity_type is None: return # Not made from existing doc, so create a new one doc = EntityDocument(id) self._set_document(doc) # add aggregation paths if is_string(entity_type): entity_type = [entity_type] doc.entity_type = entity_type if location is not None: doc.location = location if geometry is not None: doc.geometry = geometry if centroid is not None: doc.centroid = centroid if gr_id is not None: doc.gr_id = gr_id if short_code is not None: doc.short_code = short_code if aggregation_paths is not None: reserved_names = (attributes.TYPE_PATH, attributes.GEO_PATH) for name in aggregation_paths.keys(): if name in reserved_names: raise ValueError(u'Attempted to add an aggregation path with a reserved name') self.set_aggregation_path(name, aggregation_paths[name])
def __init__(self, dbm, id=None): """"" Note: _document is for 'protected' factory methods. If it is passed in the other arguments are ignored. """ "" assert (id is None or is_not_empty(id)) DataObject.__init__(self, dbm) self.graph = None # being constructed from DB? If so, no more work here if id is None: return # ok, newly constructed, so set up a new Document self._set_document(AggregationTreeDocument(id=id))
def __init__(self, dbm, id=None): """"" Note: _document is for 'protected' factory methods. If it is passed in the other arguments are ignored. """"" assert (id is None or is_not_empty(id)) DataObject.__init__(self, dbm) self.graph = None # being constructed from DB? If so, no more work here if id is None: return # ok, newly constructed, so set up a new Document self._set_document(AggregationTreeDocument(id=id))
def save(self): id = None with Lock(): self._sync_graph_to_doc() id = DataObject.save(self) return id
def _set_document(self, document): DataObject._set_document(self, document) self._sync_doc_to_graph()
def __init__(self, dbm): assert isinstance(dbm, DatabaseManager) DataObject.__init__(self, dbm)
def __init__(self, dbm, entity_type=None, location=None, aggregation_paths=None, geometry=None, centroid=None, gr_id=None, id=None, short_code=None): """ Construct a new entity. Note: _couch_document is used for 'protected' factory methods and should not be passed in standard construction. If _couch_document is passed, the other args are ignored entity_type may be a string (flat type) or sequence (hierarchical type) """ assert isinstance(dbm, DatabaseManager) assert entity_type is None or is_sequence(entity_type) or is_string( entity_type) assert location is None or is_sequence(location) assert aggregation_paths is None or isinstance(aggregation_paths, dict) assert geometry is None or isinstance(geometry, dict) assert centroid is None or isinstance(centroid, list) assert gr_id is None or is_string(gr_id) DataObject.__init__(self, dbm) # Are we being constructed from an existing doc, in which case all the work is # in _set_document? if entity_type is None: return # Not made from existing doc, so create a new one doc = EntityDocument(id) self._set_document(doc) # add aggregation paths if is_string(entity_type): entity_type = [entity_type] doc.entity_type = entity_type if location is not None: doc.location = location if geometry is not None: doc.geometry = geometry if centroid is not None: doc.centroid = centroid if gr_id is not None: doc.gr_id = gr_id if short_code is not None: doc.short_code = short_code if aggregation_paths is not None: reserved_names = (attributes.TYPE_PATH, attributes.GEO_PATH) for name in aggregation_paths.keys(): if name in reserved_names: raise ValueError( u'Attempted to add an aggregation path with a reserved name' ) self.set_aggregation_path(name, aggregation_paths[name])