Skip to content
Snippets Groups Projects
Commit 58b73154897e authored by Simon Chabot's avatar Simon Chabot
Browse files

feat(schema): replace process_type to a relation toward a ProcessFunction

related #45
parent 8eb2bf70e04c
No related branches found
No related tags found
1 merge request!66Read process types from the registry
......@@ -143,7 +143,7 @@
f"from {dataservice.dc_title()} to populate {import_procedure.dc_title()}"
)
process_to_apply = cnx.vreg["rodolf.appobject.processtype"].select(
import_recipe.process_type, req=cnx
import_recipe.use_process[0].regid, req=cnx
)
rdf_graph = process_to_apply(import_process, log)
log.info(f"Data was successfully downloaded from {dataservice.dc_title()}")
......
from functools import cache
add_entity_type("ProcessType")
add_relation_definition("ImportRecipe", "use_process", "ProcessType")
process_type_label_map = {
"default": "Processus d'import standard",
"default-dryrun": "Processus d'import standard sans publication",
}
@cache
def get_process(process_type):
return cnx.create_entity(
"ProcessType",
name=process_type_label_map.get(process_type, process_type),
regid=process_type,
activated=False,
)
for recipe in cnx.find("ImportRecipe").entities():
# create a deactivated process
# the process, if the corresponding code exists, will be activated on
# startup
process = get_process(recipe.process_type)
recipe.cw_set(use_process=process)
drop_attribute("ImportRecipe", "process_type")
sync_schema_props_perms()
......@@ -70,11 +70,7 @@
name = String(required=True)
dataservice = SubjectRelation("DataService", cardinality="1*", composite="object")
graph_uri = String()
process_type = String(
required=True,
vocabulary=["default", "default-dryrun"],
default="default",
)
use_process = SubjectRelation("ProcessType", cardinality="1*", composite="object")
class ImportProcess(WorkflowableEntityType):
......
......@@ -32,6 +32,7 @@
self.fakeredis = fakeredis.FakeStrictRedis()
def _create_test_data(self, cnx):
process_dryrun = cnx.find("ProcessType", regid="default-dryrun").one()
ds1 = cnx.create_entity(
"DataService",
data_url="https://dbpedia.org/resource/Leonardo_da_Vinci",
......@@ -41,7 +42,7 @@
"ImportRecipe",
name="IR1",
dataservice=[ds1],
process_type="default-dryrun",
use_process=process_dryrun,
)
ds2 = cnx.create_entity(
"DataService",
......@@ -52,7 +53,7 @@
"ImportRecipe",
name="IR2",
dataservice=[ds2],
process_type="default-dryrun",
use_process=process_dryrun,
)
importprocedure = cnx.create_entity(
"ImportProcedure",
......
......@@ -74,7 +74,7 @@
"ImportRecipe",
name="Ma recette",
dataservice=[dataservice],
process_type="default-dryrun",
use_process=cnx.find("ProcessType", regid="default-dryrun").one(),
)
with open(self.datapath("dboPerson.rdf"), "rb") as fp:
file = cnx.create_entity(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment