Skip to content

Commit

Permalink
Merge pull request #26 from webability-go/late-night
Browse files Browse the repository at this point in the history
patch v2021.02.16
  • Loading branch information
metalwolf authored Feb 16, 2021
2 parents 712a00a + f647056 commit e8a5a5b
Show file tree
Hide file tree
Showing 24 changed files with 169 additions and 111 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ import "github.com/webability-go/xmodules/ingredient"

import "github.com/webability-go/xmodules/material"

v2021-02-16:
- All the modules have been changed to meet new Xamboo applications interfaces

v2021-01-25:
- base, user, adminmenu and useradmin support now transactions to setup the modules.
- Errors control and messages enhanced during the installation of the modules.
Expand Down
12 changes: 6 additions & 6 deletions adminmenu/adminmenu.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (

"github.com/webability-go/xdominion"

serverassets "github.com/webability-go/xamboo/assets"
"github.com/webability-go/xamboo/applications"
)

func AddGroup(ds serverassets.Datasource, key string, name string) error {
func AddGroup(ds applications.Datasource, key string, name string) error {
adminmenu_group := ds.GetTable("adminmenu_group")
if adminmenu_group == nil {
errmessage := "xmodules::adminmenu::AddGroup: Error, the adminmenu_group table is not available on this datasource"
Expand All @@ -26,11 +26,11 @@ func AddGroup(ds serverassets.Datasource, key string, name string) error {
return nil
}

func GetGroup(ds serverassets.Datasource, key string) (*xdominion.XRecord, error) {
func GetGroup(ds applications.Datasource, key string) (*xdominion.XRecord, error) {
return nil, nil
}

func AddOption(ds serverassets.Datasource, data *xdominion.XRecord) error {
func AddOption(ds applications.Datasource, data *xdominion.XRecord) error {

adminmenu_option := ds.GetTable("adminmenu_option")
if adminmenu_option == nil {
Expand All @@ -50,11 +50,11 @@ func AddOption(ds serverassets.Datasource, data *xdominion.XRecord) error {
return nil
}

func GetOption(ds serverassets.Datasource, key string) (*xdominion.XRecord, error) {
func GetOption(ds applications.Datasource, key string) (*xdominion.XRecord, error) {
return nil, nil
}

func GetMenu(ds serverassets.Datasource, group string, father string) (*xdominion.XRecords, error) {
func GetMenu(ds applications.Datasource, group string, father string) (*xdominion.XRecords, error) {

adminmenu_option := ds.GetTable("adminmenu_option")
if adminmenu_option == nil {
Expand Down
12 changes: 6 additions & 6 deletions adminmenu/assets/moduleentries.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package assets
import (
"github.com/webability-go/xdominion"

"github.com/webability-go/xamboo/assets"
"github.com/webability-go/xamboo/applications"
)

type ModuleEntries struct {
AddGroup func(ds assets.Datasource, key string, name string) error
GetGroup func(ds assets.Datasource, key string) (*xdominion.XRecord, error)
AddOption func(ds assets.Datasource, data *xdominion.XRecord) error
GetOption func(ds assets.Datasource, key string) (*xdominion.XRecord, error)
AddGroup func(ds applications.Datasource, key string, name string) error
GetGroup func(ds applications.Datasource, key string) (*xdominion.XRecord, error)
AddOption func(ds applications.Datasource, data *xdominion.XRecord) error
GetOption func(ds applications.Datasource, key string) (*xdominion.XRecord, error)

GetMenu func(ds assets.Datasource, group string, father string) (*xdominion.XRecords, error)
GetMenu func(ds applications.Datasource, group string, father string) (*xdominion.XRecords, error)
}
9 changes: 5 additions & 4 deletions adminmenu/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ package adminmenu
import (
"golang.org/x/text/language"

serverassets "github.com/webability-go/xamboo/assets"
"github.com/webability-go/xamboo/applications"
"github.com/webability-go/xamboo/cms/context"

"github.com/webability-go/xmodules/adminmenu/assets"
"github.com/webability-go/xmodules/base"
Expand Down Expand Up @@ -48,15 +49,15 @@ func init() {

// InitModule is called during the init phase to link the module with the system
// adds tables and caches to sitecontext::database
func Setup(ds serverassets.Datasource, prefix string) ([]string, error) {
func Setup(ds applications.Datasource, prefix string) ([]string, error) {

linkTables(ds)
ds.SetModule(MODULEID, VERSION)

return []string{}, nil
}

func Synchronize(ds serverassets.Datasource, prefix string) ([]string, error) {
func Synchronize(ds applications.Datasource, prefix string) ([]string, error) {

result := []string{}

Expand Down Expand Up @@ -112,7 +113,7 @@ func Synchronize(ds serverassets.Datasource, prefix string) ([]string, error) {
return result, err
}

func StartContext(ds serverassets.Datasource, ctx *serverassets.Context) error {
func StartContext(ds applications.Datasource, ctx *context.Context) error {

return nil
}
12 changes: 5 additions & 7 deletions adminmenu/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package adminmenu

import (
"fmt"
// "time"

serverassets "github.com/webability-go/xamboo/assets"
"github.com/webability-go/xamboo/applications"

// "github.com/webability-go/xcore/v2"
"github.com/webability-go/xdominion"
"github.com/webability-go/xmodules/base"
"github.com/webability-go/xmodules/tools"
Expand All @@ -26,7 +24,7 @@ var moduletables = map[string]func() *xdominion.XTable{
"adminmenu_option": adminmenuOption,
}

func linkTables(ds serverassets.Datasource) {
func linkTables(ds applications.Datasource) {

for _, tbl := range moduletablesorder {
table := moduletables[tbl]()
Expand All @@ -35,7 +33,7 @@ func linkTables(ds serverassets.Datasource) {
}
}

func synchroTables(ds serverassets.Datasource, oldversion string) (error, []string) {
func synchroTables(ds applications.Datasource, oldversion string) (error, []string) {

result := []string{}

Expand All @@ -55,7 +53,7 @@ func synchroTables(ds serverassets.Datasource, oldversion string) (error, []stri
return nil, result
}

func install(ds serverassets.Datasource) (error, []string) {
func install(ds applications.Datasource) (error, []string) {

result := []string{}

Expand Down Expand Up @@ -134,7 +132,7 @@ func install(ds serverassets.Datasource) (error, []string) {
}
}

func upgrade(ds serverassets.Datasource, oldversion string) (error, []string) {
func upgrade(ds applications.Datasource, oldversion string) (error, []string) {

if oldversion < "0.0.1" {
// do things
Expand Down
5 changes: 3 additions & 2 deletions base/assets/moduleentries.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package assets

import (
"github.com/webability-go/xamboo/assets"
"github.com/webability-go/xamboo/applications"
"github.com/webability-go/xamboo/cms/context"
)

type ModuleEntries struct {
TryDatasource func(ctx *assets.Context, datasourcename string) assets.Datasource
TryDatasource func(ctx *context.Context, datasourcename string) applications.Datasource
}
23 changes: 12 additions & 11 deletions base/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import (
"github.com/webability-go/xcore/v2"
"github.com/webability-go/xdominion"

"github.com/webability-go/xamboo/assets"
"github.com/webability-go/xamboo/applications"
"github.com/webability-go/xamboo/cms/context"

"github.com/webability-go/xmodules/tools"
)
Expand All @@ -35,7 +36,7 @@ import (
// every line can be repeated for each dbid or logid
type Container struct {
mdatasources sync.RWMutex
datasources map[string]assets.Datasource
datasources map[string]applications.Datasource
CoreLog *log.Logger
}

Expand All @@ -51,22 +52,22 @@ func (cntl *ContainersList) GetContainer(id string) *Container {
return (*cntl)[id]
}

func (cnt *Container) SetDatasource(id string, ds assets.Datasource) {
func (cnt *Container) SetDatasource(id string, ds applications.Datasource) {
cnt.mdatasources.Lock()
cnt.datasources[id] = ds
cnt.mdatasources.Unlock()
}

func (cnt *Container) GetDatasource(id string) assets.Datasource {
func (cnt *Container) GetDatasource(id string) applications.Datasource {
cnt.mdatasources.RLock()
ds := cnt.datasources[id]
cnt.mdatasources.RUnlock()
return ds
}

func (cnt *Container) GetDatasources() map[string]assets.Datasource {
func (cnt *Container) GetDatasources() map[string]applications.Datasource {
cnt.mdatasources.RLock()
dss := make(map[string]assets.Datasource)
dss := make(map[string]applications.Datasource)
for i, v := range cnt.datasources {
dss[i] = v
}
Expand All @@ -75,7 +76,7 @@ func (cnt *Container) GetDatasources() map[string]assets.Datasource {
}

// Createdatasource will create a new datasource, link databases and logs based on XConfig data
func (cnt *Container) CreateDatasource(name string, config *xconfig.XConfig) (assets.Datasource, error) {
func (cnt *Container) CreateDatasource(name string, config *xconfig.XConfig) (applications.Datasource, error) {
// Crear los datasourceos basados en el CoreConfig
ds := &Datasource{
Name: name,
Expand Down Expand Up @@ -178,10 +179,10 @@ func (cnt *Container) CreateDatasource(name string, config *xconfig.XConfig) (as
}

// TryDatasource will create a new datasource, link databases and logs based on XConfig data
func (cnt *Container) TryDatasource(ctx *assets.Context, datasourcename string) assets.Datasource {
func (cnt *Container) TryDatasource(ctx *context.Context, datasourcename string) applications.Datasource {

var dsn string
var datasource assets.Datasource
var datasource applications.Datasource
if datasourcename != "" {
dsn, _ = ctx.Sysparams.GetString(datasourcename)
datasource = cnt.GetDatasource(dsn)
Expand Down Expand Up @@ -222,7 +223,7 @@ func Create(configfile string) *Container {
CoreLog.Println("xmodules::base::Create: Starting Core Log")

cnt := &Container{
datasources: map[string]assets.Datasource{},
datasources: map[string]applications.Datasource{},
CoreLog: CoreLog,
}

Expand All @@ -239,7 +240,7 @@ func Create(configfile string) *Container {
return cnt
}

func TryDatasource(ctx *assets.Context, datasourcename string) assets.Datasource {
func TryDatasource(ctx *context.Context, datasourcename string) applications.Datasource {

dscn, _ := ctx.Sysparams.GetString("datasourcecontainername")
cnt := Containers.GetContainer(dscn)
Expand Down
4 changes: 2 additions & 2 deletions base/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/webability-go/xcore/v2"
"github.com/webability-go/xdominion"

"github.com/webability-go/xamboo/assets"
"github.com/webability-go/xamboo/applications"

"github.com/webability-go/xmodules/tools"
)
Expand Down Expand Up @@ -181,7 +181,7 @@ func (ds *Datasource) IsModuleAuthorized(id string) bool {
return ds.GetModule(id) != ""
}

func (ds *Datasource) CloneShell() assets.Datasource {
func (ds *Datasource) CloneShell() applications.Datasource {
if ds.cloned {
return ds
}
Expand Down
9 changes: 5 additions & 4 deletions base/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ package base
import (
"golang.org/x/text/language"

serverassets "github.com/webability-go/xamboo/assets"
"github.com/webability-go/xamboo/applications"
"github.com/webability-go/xamboo/cms/context"

"github.com/webability-go/xmodules/base/assets"
"github.com/webability-go/xmodules/tools"
Expand Down Expand Up @@ -46,15 +47,15 @@ func init() {
// It must be called AFTER GetContainer
// adds tables and caches to sitecontext::database
// It should be called AFTER createContext
func setup(ds serverassets.Datasource, prefix string) ([]string, error) {
func setup(ds applications.Datasource, prefix string) ([]string, error) {

linkTables(ds)
ds.SetModule(MODULEID, VERSION)

return []string{}, nil
}

func synchronize(ds serverassets.Datasource, prefix string) ([]string, error) {
func synchronize(ds applications.Datasource, prefix string) ([]string, error) {

result := []string{}

Expand Down Expand Up @@ -110,6 +111,6 @@ func synchronize(ds serverassets.Datasource, prefix string) ([]string, error) {
return result, err
}

func startContext(ds serverassets.Datasource, ctx *serverassets.Context) error {
func startContext(ds applications.Datasource, ctx *context.Context) error {
return nil
}
6 changes: 3 additions & 3 deletions base/installation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package base
import (
"errors"

serverassets "github.com/webability-go/xamboo/assets"
"github.com/webability-go/xamboo/applications"

"github.com/webability-go/xmodules/tools"
)

func VerifyNeeds(ds serverassets.Datasource, needs []string) (bool, []string) {
func VerifyNeeds(ds applications.Datasource, needs []string) (bool, []string) {

result := []string{}
flag := true
Expand All @@ -27,7 +27,7 @@ func VerifyNeeds(ds serverassets.Datasource, needs []string) (bool, []string) {
return flag, []string{}
}

func SynchroTable(ds serverassets.Datasource, tablename string) (error, []string) {
func SynchroTable(ds applications.Datasource, tablename string) (error, []string) {

result := []string{}
result = append(result, tools.Message(messages, "analyze", tablename))
Expand Down
Loading

0 comments on commit e8a5a5b

Please sign in to comment.