From 0380405e32062dd729326bf7167f4026d6d67f5c Mon Sep 17 00:00:00 2001 From: Siddhartha Basu Date: Wed, 21 Feb 2024 13:29:33 -0600 Subject: [PATCH] feat(action.go): add ontology loading functionality to LoadOntologyToTable function The LoadOntologyToTable function now has the ability to load ontology data into the table. This is achieved by adding a new import statement for the ontology package and creating a new LoadProperties object. The function now checks if the ontology table fields were successfully created and if so, it either loads new ontology data or updates existing data. If the table fields were not created, it only loads new data. --- internal/baserow/cli/action.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/internal/baserow/cli/action.go b/internal/baserow/cli/action.go index 7ef37fd9..5e52edc5 100644 --- a/internal/baserow/cli/action.go +++ b/internal/baserow/cli/action.go @@ -6,6 +6,7 @@ import ( "github.com/dictyBase/modware-import/internal/baserow/client" "github.com/dictyBase/modware-import/internal/baserow/database" + "github.com/dictyBase/modware-import/internal/baserow/ontology" "github.com/dictyBase/modware-import/internal/collection" "github.com/dictyBase/modware-import/internal/registry" "github.com/urfave/cli/v2" @@ -93,7 +94,7 @@ func LoadOntologyToTable(cltx *cli.Context) error { "Id": client.TEXT, "Is_obsolete": client.BOOLEAN, } - err := database.CreateOntologyTableFields( + ok, err := database.CreateOntologyTableFields( &database.OntologyTableFieldsProperties{ Client: bclient, Logger: logger, @@ -105,6 +106,22 @@ func LoadOntologyToTable(cltx *cli.Context) error { if err != nil { return cli.Exit(err.Error(), 2) } + props := &ontology.LoadProperties{ + File: cltx.String("input"), + TableId: cltx.Int("table-id"), + Token: cltx.String("token"), + Client: bclient, + Logger: logger, + } + if ok { + if err := ontology.LoadNewOrUpdate(props); err != nil { + return cli.Exit(err.Error(), 2) + } + return nil + } + if err := ontology.LoadNew(props); err != nil { + return cli.Exit(err.Error(), 2) + } return nil }