name | arguments | returns |
set_database | cls, db :NeoAccess | None |
IMPORTANT: this method MUST be called before using this class!
:param db: Database-interface object, created with the NeoAccess library
:return: None
|
name | arguments | returns |
initialize_collections | cls | (int, str) |
Create a new Schema Class node that represents a "Collection"
:return: An (int, str) pair of integers with the internal database ID
and the unique uri assigned to the node just created
|
name | arguments | returns |
is_collection | cls, collection_uri :str | bool |
Return True if the Data Node with the given uri is a Collection,
that is, if its schema is a Class that is an INSTANCE_OF the "Collections" Class
:param collection_uri: A string with the URI of a Data Node
:return: True if the given data node is a Collection, or False otherwise
|
name | arguments | returns |
collection_size | cls, collection_id :str, membership_rel_name: str, skip_check=False | int |
Return the number of elements in the given Collection (i.e. Data Items linked to it thru the specified relationship)
:param collection_id: The uri of a data node whose schema is an instance of the Class "Collections"
:param membership_rel_name: The name of the relationship from other Data Items to the given Collection node
:param skip_check: If True, no check is done to verify that the data node whose uri matches collection_id
is indeed a Collection.
Without a check, this function will return a zero if given a bad collection_id;
with a check, it'll raise an Exception
:return: The number of elements in the given Collection (possibly zero)
|
name | arguments | returns |
add_to_collection_at_beginning | cls, collection_uri :str, membership_rel_name: str, item_class_name: str, item_properties: dict,
new_uri=None | str |
Create a new data node, of the class specified in item_class_name, and with the given properties -
and add it at the beginning of the specified Collection, linked by the specified relationship
EXAMPLE: new_uri = add_to_collection_at_beginning(collection_id=708, membership_rel_name="BA_in_category",
item_class_name="Headers", item_properties={"text": "New Caption, at the end"})
:return: The auto-increment "uri" assigned to the newly-created data node
|
name | arguments | returns |
link_to_collection_at_end | cls, item_uri :str, collection_uri :str, membership_rel_name :str | None |
Given an existing data node (meant to be a "Collection Item"),
link it to the end of the specified Collection data node,
using the requested relationship name.
If a link already exists, an Exception is raised.
:param item_uri: The URI of an existing Data Node representing a "Collection Item"
:param collection_uri: The URI of an existing Collection Data Node
:param membership_rel_name: The name to give to the relationship
in the direction from the "Collection Item" to the Collection node
:return: None
|
name | arguments | returns |
relocate_to_other_collection_at_end | cls, item_uri :str, from_collection_uri :str, to_collection_uri :str, membership_rel_name :str | |
Given an existing data node (representing a "Collection Item" of the specified "from" Collection),
switch it to become a "Collection Item" of the "to" Collection, positioned at the end of it.
The collection-membership relationship is severed from the "Collection Item" to the "from" Collection,
and a new one is created from the "Collection Item" to the "to" Collection.
In case no operation is performed, an Exception is raised.
:param item_uri: The URI of a Data Node representing a "Collection Item" of the "from" Collection below
:param from_collection_uri: The URI of a Collection Data Node to which the above "Collection Item" is connected
:param to_collection_uri: The URI of a Collection Data Node to which the above "Collection Item" needs to be switched to
:param membership_rel_name: The name to give to the relationship
in the direction from the "Collection Item" to the Collection node
:return: None
|
name | arguments | returns |
bulk_relocate_to_other_collection_at_end | cls, items :Union[List[str], str],
from_collection :str, to_collection :str, membership_rel_name :str | int |
Given an existing list of data nodes (representing "Collection Items" of the specified "from" Collection),
switch each of them to become a "Collection Item" of the "to" Collection, positioned at the end of it.
The collection-membership relationship is severed from each of the "Collection Items" to the "from" Collection,
and a new one is created from that "Collection Item" to the "to" Collection.
Return the number of Collection Items successfully relocated.
:param items: URI, or list of URI's, of Data Node(s)
representing a "Collection Items" of the "from" Collection below
:param from_collection: The URI of a Collection Data Node to which the above Collection Item(s) are connected
:param to_collection: The URI of a Collection Data Node to which the above Collection Item(s) needs to be switched to
:param membership_rel_name: The name to give to the relationship
in the direction from the "Collection Item" to the Collection node
:return: The number of Collection Items successfully relocated
|
name | arguments | returns |
add_to_collection_at_end | cls, collection_uri :str, membership_rel_name: str, item_class_name: str, item_properties: dict,
new_uri=None | str |
Create a new data node, of the class specified in item_class_name, and with the given properties -
and add it at the end of the specified Collection, linked by the specified relationship
EXAMPLE: new_uri = add_to_collection_at_end(collection_id=708, membership_rel_name="BA_in_category",
item_class_name="Headers", item_properties={"text": "New Caption, at the end"}
:param collection_uri: The uri of a data node whose schema is an instance of the Class "Collections"
:param membership_rel_name:
:param item_class_name:
:param item_properties:
:param new_uri: Normally, the Item ID is auto-generated, but it can also be provided (Note: MUST be unique)
:return: The auto-increment "uri" assigned to the newly-created data node
|
name | arguments | returns |
add_to_collection_after_element | cls, collection_uri :str, membership_rel_name: str,
item_class_name: str, item_properties: dict, insert_after :str,
new_uri=None | str |
Create a new data node, of the class specified in item_class_name, and with the given properties -
and add to the specified Collection, linked by the specified relationship and inserted after the given collection Item
(in the context of the positional order encoded in the relationship attribute "pos")
:param collection_uri: The uri of a data node whose schema is an instance of the Class "Collections"
:param membership_rel_name: The name of the relationship to which the positions ("pos" attribute) apply
:param item_class_name: Name of the Class for the newly-created node
:param item_properties: Dictionary with the properties of the newly-created node
:param insert_after: The URI of the element after which we want to insert
:param new_uri: Normally, the Item ID is auto-generated, but it can also be provided (Note: MUST be unique)
:return: The auto-increment "uri" assigned to the newly-created data node
|
name | arguments | returns |
shift_down | cls, collection_id :str, membership_rel_name :str, first_to_move :int | int |
Shift down the positions (values of the "pos" relationship attributes) by an arbitrary fixed amount,
starting with nodes with the specified position value (and all greater values);
this operation applies to nodes linked to the specified Collection thru a relationship with the given name.
:param collection_id: The uri of a data node whose schema is an instance of the Class "Collections"
:param membership_rel_name: The name of the relationship to which the positions ("pos" attribute) apply
:param first_to_move: All position ("pos") values greater or equal to this one will get shifted down
:return: The number of modified items
|