Skip to content

Commit

Permalink
feat(action.go): add ontology loading functionality to LoadOntologyTo…
Browse files Browse the repository at this point in the history
…Table 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.
  • Loading branch information
cybersiddhu committed Feb 21, 2024
1 parent 3dd1d30 commit 0380405
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion internal/baserow/cli/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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
}
Expand Down

0 comments on commit 0380405

Please sign in to comment.