Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mdl/backend/java.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
// JavaBackend provides Java and JavaScript action operations.
type JavaBackend interface {
ListJavaActions() ([]*mpr.JavaAction, error)
ListJavaActionsFull() ([]*javaactions.JavaAction, error)
ListJavaScriptActions() ([]*mpr.JavaScriptAction, error)
ReadJavaActionByName(qualifiedName string) (*javaactions.JavaAction, error)
ReadJavaScriptActionByName(qualifiedName string) (*mpr.JavaScriptAction, error)
Expand Down
1 change: 1 addition & 0 deletions mdl/backend/mock/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ type MockBackend struct {

// JavaBackend
ListJavaActionsFunc func() ([]*mpr.JavaAction, error)
ListJavaActionsFullFunc func() ([]*javaactions.JavaAction, error)
ListJavaScriptActionsFunc func() ([]*mpr.JavaScriptAction, error)
ReadJavaActionByNameFunc func(qualifiedName string) (*javaactions.JavaAction, error)
ReadJavaScriptActionByNameFunc func(qualifiedName string) (*mpr.JavaScriptAction, error)
Expand Down
7 changes: 7 additions & 0 deletions mdl/backend/mock/mock_java.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ func (m *MockBackend) ListJavaActions() ([]*mpr.JavaAction, error) {
return nil, nil
}

func (m *MockBackend) ListJavaActionsFull() ([]*javaactions.JavaAction, error) {
if m.ListJavaActionsFullFunc != nil {
return m.ListJavaActionsFullFunc()
}
return nil, nil
}

func (m *MockBackend) ListJavaScriptActions() ([]*mpr.JavaScriptAction, error) {
if m.ListJavaScriptActionsFunc != nil {
return m.ListJavaScriptActionsFunc()
Expand Down
15 changes: 15 additions & 0 deletions mdl/backend/mpr/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ type MprBackend struct {
path string
}

// Wrap creates an MprBackend that wraps an existing Writer (and its Reader).
// This is used during migration when the Executor already owns the Writer
// and we want to expose it through the Backend interface without opening
// a second connection.
func Wrap(writer *mpr.Writer, path string) *MprBackend {
return &MprBackend{
reader: writer.Reader(),
writer: writer,
path: path,
}
}

// ---------------------------------------------------------------------------
// ConnectionBackend
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -526,6 +538,9 @@ func (b *MprBackend) DeleteJsonStructure(id string) error {
func (b *MprBackend) ListJavaActions() ([]*mpr.JavaAction, error) {
return b.reader.ListJavaActions()
}
func (b *MprBackend) ListJavaActionsFull() ([]*javaactions.JavaAction, error) {
return b.reader.ListJavaActionsFull()
}
func (b *MprBackend) ListJavaScriptActions() ([]*mpr.JavaScriptAction, error) {
return b.reader.ListJavaScriptActions()
}
Expand Down
57 changes: 55 additions & 2 deletions mdl/catalog/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,72 @@ import (

"github.com/mendixlabs/mxcli/model"
"github.com/mendixlabs/mxcli/sdk/domainmodel"
"github.com/mendixlabs/mxcli/sdk/javaactions"
"github.com/mendixlabs/mxcli/sdk/microflows"
"github.com/mendixlabs/mxcli/sdk/mpr"
"github.com/mendixlabs/mxcli/sdk/pages"
"github.com/mendixlabs/mxcli/sdk/security"
"github.com/mendixlabs/mxcli/sdk/workflows"
)

// CatalogReader defines the read-only backend surface used by the catalog builder.
// Both *mpr.Reader and backend.FullBackend satisfy this interface.
type CatalogReader interface {
// Infrastructure
GetRawUnit(id model.ID) (map[string]any, error)
ListRawUnitsByType(typePrefix string) ([]*mpr.RawUnit, error)
ListUnits() ([]*mpr.UnitInfo, error)
ListFolders() ([]*mpr.FolderInfo, error)

// Modules
ListModules() ([]*model.Module, error)

// Settings & security
GetProjectSettings() (*model.ProjectSettings, error)
GetProjectSecurity() (*security.ProjectSecurity, error)
GetNavigation() (*mpr.NavigationDocument, error)

// Domain models & enumerations
ListDomainModels() ([]*domainmodel.DomainModel, error)
ListEnumerations() ([]*model.Enumeration, error)
ListConstants() ([]*model.Constant, error)

// Microflows & nanoflows
ListMicroflows() ([]*microflows.Microflow, error)
ListNanoflows() ([]*microflows.Nanoflow, error)

// Pages, layouts & snippets
ListPages() ([]*pages.Page, error)
ListLayouts() ([]*pages.Layout, error)
ListSnippets() ([]*pages.Snippet, error)

// Workflows
ListWorkflows() ([]*workflows.Workflow, error)

// Java actions
ListJavaActionsFull() ([]*javaactions.JavaAction, error)

// Services
ListConsumedODataServices() ([]*model.ConsumedODataService, error)
ListPublishedODataServices() ([]*model.PublishedODataService, error)
ListConsumedRestServices() ([]*model.ConsumedRestService, error)
ListPublishedRestServices() ([]*model.PublishedRestService, error)
ListBusinessEventServices() ([]*model.BusinessEventService, error)
ListDatabaseConnections() ([]*model.DatabaseConnection, error)

// Mappings & JSON structures
ListImportMappings() ([]*model.ImportMapping, error)
ListExportMappings() ([]*model.ExportMapping, error)
ListJsonStructures() ([]*mpr.JsonStructure, error)
}

// DescribeFunc generates MDL source for a given object type and qualified name.
type DescribeFunc func(objectType string, qualifiedName string) (string, error)

// Builder populates catalog tables from MPR data.
type Builder struct {
catalog *Catalog
reader *mpr.Reader
reader CatalogReader
snapshot *Snapshot
progress ProgressFunc
hierarchy *hierarchy
Expand Down Expand Up @@ -148,7 +201,7 @@ func (h *hierarchy) buildFolderPath(containerID model.ID) string {
}

// NewBuilder creates a new catalog builder.
func NewBuilder(catalog *Catalog, reader *mpr.Reader) *Builder {
func NewBuilder(catalog *Catalog, reader CatalogReader) *Builder {
return &Builder{
catalog: catalog,
reader: reader,
Expand Down
Loading