Skip to content
Snippets Groups Projects
Commit 62e286eb878f 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
No related merge requests found
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
f"from {dataservice.dc_title()} to populate {import_procedure.dc_title()}" f"from {dataservice.dc_title()} to populate {import_procedure.dc_title()}"
) )
process_to_apply = cnx.vreg["rodolf.appobject.processtype"].select( 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) rdf_graph = process_to_apply(import_process, log)
log.info(f"Data was successfully downloaded from {dataservice.dc_title()}") 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() sync_schema_props_perms()
...@@ -70,11 +70,7 @@ ...@@ -70,11 +70,7 @@
name = String(required=True) name = String(required=True)
dataservice = SubjectRelation("DataService", cardinality="1*", composite="object") dataservice = SubjectRelation("DataService", cardinality="1*", composite="object")
graph_uri = String() graph_uri = String()
process_type = String( use_process = SubjectRelation("ProcessType", cardinality="1*", composite="object")
required=True,
vocabulary=["default", "default-dryrun"],
default="default",
)
class ImportProcess(WorkflowableEntityType): class ImportProcess(WorkflowableEntityType):
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
self.fakeredis = fakeredis.FakeStrictRedis() self.fakeredis = fakeredis.FakeStrictRedis()
def _create_test_data(self, cnx): def _create_test_data(self, cnx):
process_dryrun = cnx.find("ProcessFunction", regid="default-dryrun").one()
ds1 = cnx.create_entity( ds1 = cnx.create_entity(
"DataService", "DataService",
data_url="https://dbpedia.org/resource/Leonardo_da_Vinci", data_url="https://dbpedia.org/resource/Leonardo_da_Vinci",
...@@ -41,7 +42,7 @@ ...@@ -41,7 +42,7 @@
"ImportRecipe", "ImportRecipe",
name="IR1", name="IR1",
dataservice=[ds1], dataservice=[ds1],
process_type="default-dryrun", use_process=process_dryrun,
) )
ds2 = cnx.create_entity( ds2 = cnx.create_entity(
"DataService", "DataService",
...@@ -52,7 +53,7 @@ ...@@ -52,7 +53,7 @@
"ImportRecipe", "ImportRecipe",
name="IR2", name="IR2",
dataservice=[ds2], dataservice=[ds2],
process_type="default-dryrun", use_process=process_dryrun,
) )
importprocedure = cnx.create_entity( importprocedure = cnx.create_entity(
"ImportProcedure", "ImportProcedure",
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
"ImportRecipe", "ImportRecipe",
name="Ma recette", name="Ma recette",
dataservice=[dataservice], dataservice=[dataservice],
process_type="default-dryrun", use_process=cnx.find("ProcessType", regid="default-dryrun").one(),
) )
with open(self.datapath("dboPerson.rdf"), "rb") as fp: with open(self.datapath("dboPerson.rdf"), "rb") as fp:
file = cnx.create_entity( 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