def __init__(self, model, name, data): self.model = model self.name = name self.data = data self._label = data.get('label', name) self._plural = data.get('plural', self.label) self._description = data.get('description') self.featured = ensure_list(data.get('featured')) self.uri = URIRef(data.get('rdf', NS[name])) # Do not show in listings: self.abstract = as_bool(data.get('abstract'), False) # Try to perform fuzzy matching. Fuzzy similarity search does not # make sense for entities which have a lot of similar names, such # as land plots, assets etc. self.matchable = as_bool(data.get('matchable'), True) self.extends = set() self.schemata = set([self]) self.names = set([self.name]) self.descendants = set() self.properties = {} for name, prop in data.get('properties', {}).items(): self.properties[name] = Property(self, name, prop)
def __init__(self, model, name, data): self.model = model self.name = name self.data = data self.icon = data.get('icon') self._label = data.get('label', name) self._plural = data.get('plural', self.label) self._description = data.get('description') self._extends = ensure_list(data.get('extends')) self.featured = ensure_list(data.get('featured')) self.uri = NAMESPACE[name] if 'rdf' in data: self.uri = URIRef(data.get('rdf')) # Do not show in listings: self.abstract = as_bool(data.get('abstract'), False) # Try to perform fuzzy matching. Fuzzy similarity search does not # make sense for entities which have a lot of similar names, such # as land plots, assets etc. self.matchable = as_bool(data.get('matchable'), True) self._own_properties = [] for name, prop in data.get('properties', {}).items(): self._own_properties.append(Property(self, name, prop))
def __init__(self, model, name, data): self.model = model self.name = name self.data = data self._label = data.get("label", name) self._plural = data.get("plural", self.label) self._description = data.get("description") self.uri = URIRef(data.get("rdf", NS[name])) # Do not show in listings: self.abstract = as_bool(data.get("abstract"), False) self.hidden = as_bool(data.get("hidden"), False) self.hidden = self.hidden and not self.abstract # Generated by the system, not user-managed self.generated = as_bool(data.get("generated"), False) # Try to perform fuzzy matching. Fuzzy similarity search does not # make sense for entities which have a lot of similar names, such # as land plots, assets etc. self.matchable = as_bool(data.get("matchable"), True) # Mark a set of properties as important, i.e. they should be shown # first, or in an abridged view of the entity. self.featured = ensure_list(data.get("featured")) # Mark a set of properties as required. This is applied only when # an entity is created by the user - bulk created entities will # slip through even if it is technically invalid. self.required = ensure_list(data.get("required")) # Mark a set of properties to be used for the entity's caption. # They will be checked in order and the first existant value will # be used. self.caption = ensure_list(data.get("caption")) # A transform of the entity into an edge for its representation in # the context of a property graph representation like Neo4J/Gephi. edge = data.get("edge", {}) self.edge_source = edge.get("source") self.edge_target = edge.get("target") self.edge = self.edge_source and self.edge_target self.edge_caption = ensure_list(edge.get("caption")) self._edge_label = edge.get("label", self._label) self.edge_directed = edge.get("directed", True) self.extends = set() self.schemata = set([self]) self.names = set([self.name]) self.descendants = set() self.properties = {} for name, prop in data.get("properties", {}).items(): self.properties[name] = Property(self, name, prop)
def __init__(self, model, name, data): self.model = model self.name = name self.data = data self._label = data.get('label', name) self._plural = data.get('plural', self.label) self._description = data.get('description') self.uri = URIRef(data.get('rdf', NS[name])) # Do not show in listings: self.abstract = as_bool(data.get('abstract'), False) # Generated by the system, not user-managed self.generated = as_bool(data.get('generated'), False) # Try to perform fuzzy matching. Fuzzy similarity search does not # make sense for entities which have a lot of similar names, such # as land plots, assets etc. self.matchable = as_bool(data.get('matchable'), True) # Mark a set of properties as important, i.e. they should be shown # first, or in an abridged view of the entity. self.featured = ensure_list(data.get('featured')) # Mark a set of properties to be used for the entity's caption. # They will be checked in order and the first existant value will # be used. self.caption = ensure_list(data.get('caption')) # A transform of the entity into an edge for its representation in # the context of a property graph representation like Neo4J/Gephi. edge = data.get('edge', {}) self.edge_source = edge.get('source') self.edge_target = edge.get('target') self.edge = self.edge_source and self.edge_target self.edge_caption = ensure_list(edge.get('caption')) self._edge_label = edge.get('label', self._label) self.edge_directed = edge.get('directed', True) self.extends = set() self.schemata = set([self]) self.names = set([self.name]) self.descendants = set() self.properties = {} for name, prop in data.get('properties', {}).items(): self.properties[name] = Property(self, name, prop)
def _add_reverse(self, data, other): name = data.get('name', None) if name is None: raise InvalidModel("Unnamed reverse: %s" % other) prop = self.get(name) if prop is None: data.update({ 'type': registry.entity.name, 'reverse': { 'name': other.name }, 'schema': other.schema.name, 'stub': True }) prop = Property(self, name, data) prop.generate() return prop
def _add_reverse(self, data, other): name = data.pop('name', None) if name is None: raise InvalidModel("Unnamed reverse: %s" % other) prop = self.get(name) if prop is None: data.update({ 'type': 'entity', 'reverse': {'name': other.name}, 'schema': other.schema.name }) prop = Property(self, name, data, stub=True) prop.generate() self._own_properties.append(prop) self._flush_properties() assert prop.type == registry.entity, prop.type return prop
def _add_reverse(self, data: ReverseSpec, other: Property) -> Property: name = data.get("name") if name is None: raise InvalidModel("Unnamed reverse: %s" % other) prop = self.get(name) if prop is None: spec: PropertySpec = { "label": data.get("label"), "type": registry.entity.name, "reverse": {"name": other.name}, "range": other.schema.name, "hidden": data.get("hidden", other.hidden), } prop = Property(self, name, spec) prop.stub = True prop.generate() self.properties[name] = prop return prop
def _add_reverse(self, data, other): name = data.get("name", None) if name is None: raise InvalidModel("Unnamed reverse: %s" % other) prop = self.get(name) if prop is None: data.update({ "type": registry.entity.name, "reverse": { "name": other.name }, "range": other.schema.name, "stub": True, }) data["hidden"] = data.get("hidden", other.hidden) prop = Property(self, name, data) prop.generate() self.properties[name] = prop return prop
def __init__(self, model, name, data): self._model = model self.name = name self.data = data self.label = data.get('label', name) self.plural = data.get('plural', self.label) self.icon = data.get('icon') # Do not show in listings: self.hidden = data.get('hidden', False) # Try to perform fuzzy matching. Fuzzy similarity search does not # make sense for entities which have a lot of similar names, such # as land plots, assets etc. self.fuzzy = data.get('fuzzy', True) self._extends = ensure_list(data.get('extends')) self._own_properties = [] for name, prop in data.get('properties', {}).items(): self._own_properties.append(Property(self, name, prop))
def __init__(self, model, name, data): #: Machine-readable name of the schema, used for identification. self.name = name self.model = model self.data = data self._label = data.get("label", name) self._plural = data.get("plural", self.label) self._description = data.get("description") self._hash = hash("<Schema(%r)>" % name) #: RDF identifier for this schema when it is transformed to a triple term. self.uri = URIRef(data.get("rdf", NS[name])) #: Do not store or emit entities of this type, it is used only for #: inheritance. self.abstract = as_bool(data.get("abstract"), False) #: Hide this schema in listings. self.hidden = as_bool(data.get("hidden"), False) self.hidden = self.hidden and not self.abstract #: Entities with this type are generated by the system - for example, via #: `ingest-file`. The user should not be offered an option to create them #: in the interface. self.generated = as_bool(data.get("generated"), False) #: Try to perform fuzzy matching. Fuzzy similarity search does not #: make sense for entities which have a lot of similar names, such #: as land plots, assets etc. self.matchable = as_bool(data.get("matchable"), True) #: Mark a set of properties as important, i.e. they should be shown #: first, or in an abridged view of the entity. In Aleph, these properties #: are included in tabular entity listings. self.featured = ensure_list(data.get("featured")) #: Mark a set of properties as required. This is applied only when #: an entity is created by the user - bulk created entities will #: slip through even if it is technically invalid. self.required = ensure_list(data.get("required")) #: Mark a set of properties to be used for the entity's caption. #: They will be checked in order and the first existant value will #: be used. self.caption = ensure_list(data.get("caption")) # A transform of the entity into an edge for its representation in # the context of a property graph representation like Neo4J/Gephi. edge = data.get("edge", {}) self.edge_source = edge.get("source") self.edge_target = edge.get("target") #: Flag to indicate if this schema should be represented by an edge (rather than #: a node) when the data is converted into a property graph. self.edge = self.edge_source and self.edge_target self.edge_caption = ensure_list(edge.get("caption")) self._edge_label = edge.get("label", self._label) #: Flag to indicate if the edge should be presented as directed to the user, e.g. #: by showing an error at the target end of the edge. self.edge_directed = edge.get("directed", True) #: Direct parent schemata of this schema. self.extends = set() #: All parents of this schema (including indirect parents and the schema itself). self.schemata = set([self]) #: All names of :attr:`~schemata`. self.names = set([self.name]) #: Inverse of :attr:`~schemata`, all derived child types of this schema #: and their children. self.descendants = set() #: The full list of properties defined for the entity, including those #: inherited from parent schemata. self.properties = {} for name, prop in data.get("properties", {}).items(): self.properties[name] = Property(self, name, prop)