From 7a61c2ffa570ef15efb7b7605e7b7a82ff0ca980 Mon Sep 17 00:00:00 2001 From: Valentin Kuznetsov Date: Fri, 20 Dec 2024 09:11:09 -0500 Subject: [PATCH] enforce processing part of prov record --- dbs/datasets.go | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/dbs/datasets.go b/dbs/datasets.go index f51c842..100779d 100644 --- a/dbs/datasets.go +++ b/dbs/datasets.go @@ -182,22 +182,23 @@ func insertParts(rec *DatasetRecord, record *Datasets) error { record.SCRIPT_ID = scriptId // insert processing info - if rec.Processing != "" { + if rec.Processing == "" { + return errors.New("procesing part of provenance records is empty") + } + processingId, err = GetID(tx, "processing", "processing_id", "processing", rec.Processing) + if err != nil || processingId == 0 { + processing := Processing{ + PROCESSING: rec.Processing, + OS_ID: osId, + ENVIRONMENT_ID: environmentId, + SCRIPT_ID: scriptId, + } + if err = processing.Insert(tx); err != nil { + return err + } processingId, err = GetID(tx, "processing", "processing_id", "processing", rec.Processing) - if err != nil || processingId == 0 { - processing := Processing{ - PROCESSING: rec.Processing, - OS_ID: osId, - ENVIRONMENT_ID: environmentId, - SCRIPT_ID: scriptId, - } - if err = processing.Insert(tx); err != nil { - return err - } - processingId, err = GetID(tx, "processing", "processing_id", "processing", rec.Processing) - if err != nil { - return err - } + if err != nil { + return err } } record.PROCESSING_ID = processingId