MCPcopy Create free account
hub / github.com/alephdata/aleph / create_entityset

Function create_entityset

aleph/logic/entitysets.py:21–43  ·  view source on GitHub ↗

Create an entity set. This will create or update any entities that already exist in the entityset and sign their IDs into the collection.

(collection, data, authz)

Source from the content-addressed store, hash-verified

19
20
21def create_entityset(collection, data, authz):
22 """Create an entity set. This will create or update any entities
23 that already exist in the entityset and sign their IDs into the collection.
24 """
25 old_to_new_id_map = {}
26 entity_ids = []
27 for entity in data.pop("entities", []):
28 old_id = entity.get("id")
29 new_id = upsert_entity(entity, collection, sign=True, sync=True)
30 old_to_new_id_map[old_id] = new_id
31 entity_ids.append(new_id)
32 layout = data.get("layout", {})
33 data["layout"] = replace_layout_ids(layout, old_to_new_id_map)
34 entityset = EntitySet.create(data, collection, authz)
35 for entity_id in entity_ids:
36 save_entityset_item(entityset, collection, entity_id)
37 publish(
38 Events.CREATE_ENTITYSET,
39 params={"collection": collection, "entityset": entityset},
40 channels=[collection, authz.role],
41 actor_id=authz.id,
42 )
43 return entityset
44
45
46def save_entityset_item(entityset, collection, entity_id, **data):

Callers 1

createFunction · 0.90

Calls 6

upsert_entityFunction · 0.90
publishFunction · 0.90
replace_layout_idsFunction · 0.85
save_entityset_itemFunction · 0.85
getMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected