Skip to content

Commit d63dd37

Browse files
akoclaude
andcommitted
fix: add virtual System Java actions to ListJavaActions and catalog
System Java actions (System.VerifyPassword, etc.) are built-in and not stored in the MPR SQLite database, so ListJavaActions() and ListJavaActionsFull() returned empty results for them. This caused mxcli check --references to flag calls to System.VerifyPassword as unknown Java actions. Adds system_java_actions.go with: - systemJavaActions table (sourced from mx dump-mpr --module-names=System against Mendix 11.9.0 — same extraction approach as system_module.go entities) - BuildSystemJavaActions() for the lightweight types.JavaAction path used by executor reference validation - BuildSystemJavaActionsFull() for the javaactions.JavaAction path used by the catalog builder Both ListJavaActions() and ListJavaActionsFull() now append the virtual System actions, following the same pattern as ListModules() and ListDomainModels() for the System module and domain model. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ae6edec commit d63dd37

4 files changed

Lines changed: 172 additions & 2 deletions

File tree

sdk/mpr/parser_javaactions.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ func parseInnerParameterType(raw map[string]any) javaactions.CodeActionParameter
509509
return nil
510510
}
511511

512-
// ListJavaActionsFull returns all Java actions with full details.
512+
// ListJavaActionsFull returns all Java actions with full details, including virtual System module actions.
513513
func (r *Reader) ListJavaActionsFull() ([]*javaactions.JavaAction, error) {
514514
units, err := r.listUnitsByType("JavaActions$JavaAction")
515515
if err != nil {
@@ -525,6 +525,9 @@ func (r *Reader) ListJavaActionsFull() ([]*javaactions.JavaAction, error) {
525525
result = append(result, ja)
526526
}
527527

528+
// Append virtual System module Java actions (not stored in the MPR database)
529+
result = append(result, BuildSystemJavaActionsFull()...)
530+
528531
return result, nil
529532
}
530533

sdk/mpr/parser_javaactions_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,52 @@ import (
88
"github.com/mendixlabs/mxcli/sdk/javaactions"
99
)
1010

11+
func TestBuildSystemJavaActions_VerifyPassword(t *testing.T) {
12+
actions := BuildSystemJavaActions()
13+
14+
var found bool
15+
for _, a := range actions {
16+
if a.Name == "VerifyPassword" && string(a.ContainerID) == SystemModuleID {
17+
found = true
18+
break
19+
}
20+
}
21+
if !found {
22+
t.Error("BuildSystemJavaActions: System.VerifyPassword not present")
23+
}
24+
}
25+
26+
func TestBuildSystemJavaActionsFull_VerifyPassword(t *testing.T) {
27+
actions := BuildSystemJavaActionsFull()
28+
29+
var found bool
30+
for _, a := range actions {
31+
if a.Name != "VerifyPassword" || string(a.ContainerID) != SystemModuleID {
32+
continue
33+
}
34+
found = true
35+
if len(a.Parameters) != 2 {
36+
t.Errorf("VerifyPassword: want 2 parameters, got %d", len(a.Parameters))
37+
}
38+
if _, ok := a.ReturnType.(*javaactions.BooleanType); !ok {
39+
t.Errorf("VerifyPassword: want BooleanType return, got %T", a.ReturnType)
40+
}
41+
}
42+
if !found {
43+
t.Error("BuildSystemJavaActionsFull: System.VerifyPassword not present")
44+
}
45+
}
46+
47+
func TestBuildSystemJavaActions_DeterministicIDs(t *testing.T) {
48+
a1 := BuildSystemJavaActions()
49+
a2 := BuildSystemJavaActions()
50+
for i := range a1 {
51+
if a1[i].ID != a2[i].ID {
52+
t.Errorf("non-deterministic ID for %s", a1[i].Name)
53+
}
54+
}
55+
}
56+
1157
func TestParseCodeActionParameterType_JavaActionMicroflowParameter(t *testing.T) {
1258
value := parseCodeActionParameterType(map[string]any{
1359
"$ID": "type-1",

sdk/mpr/reader_types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type (
3434
ProjectVersion = types.ProjectVersion
3535
)
3636

37-
// ListJavaActions returns all Java actions in the project.
37+
// ListJavaActions returns all Java actions in the project, including virtual System module actions.
3838
func (r *Reader) ListJavaActions() ([]*types.JavaAction, error) {
3939
units, err := r.listUnitsByType("JavaActions$JavaAction")
4040
if err != nil {
@@ -50,6 +50,9 @@ func (r *Reader) ListJavaActions() ([]*types.JavaAction, error) {
5050
result = append(result, ja)
5151
}
5252

53+
// Append virtual System module Java actions (not stored in the MPR database)
54+
result = append(result, BuildSystemJavaActions()...)
55+
5356
return result, nil
5457
}
5558

sdk/mpr/system_java_actions.go

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
package mpr
4+
5+
import (
6+
"github.com/mendixlabs/mxcli/mdl/types"
7+
"github.com/mendixlabs/mxcli/model"
8+
"github.com/mendixlabs/mxcli/sdk/javaactions"
9+
)
10+
11+
// systemJavaParamDef defines a parameter of a System Java action.
12+
type systemJavaParamDef struct {
13+
Name string
14+
Type string // "String", "Boolean", "Integer", "Long", "Decimal", "DateTime"
15+
}
16+
17+
// systemJavaActionDef defines a Java action in the System module.
18+
type systemJavaActionDef struct {
19+
Name string
20+
Documentation string
21+
ReturnType string // "Boolean", "String", "Integer", "Long", "Decimal", "DateTime", "Void"
22+
Parameters []systemJavaParamDef
23+
}
24+
25+
// systemJavaActions lists all Java actions in the System module.
26+
// Extracted from Mendix Studio Pro 11.9.0 via mx dump-mpr --module-names=System --unit-type=JavaActions$JavaAction.
27+
var systemJavaActions = []systemJavaActionDef{
28+
{
29+
Name: "VerifyPassword",
30+
Documentation: "Verifies that the specified user name/password combination is valid.",
31+
ReturnType: "Boolean",
32+
Parameters: []systemJavaParamDef{
33+
{Name: "userName", Type: "String"},
34+
{Name: "password", Type: "String"},
35+
},
36+
},
37+
}
38+
39+
// BuildSystemJavaActions returns lightweight types.JavaAction entries for the System module.
40+
// These are built-in Java actions not stored in the MPR SQLite database.
41+
// Used by ListJavaActions() for executor reference validation.
42+
func BuildSystemJavaActions() []*types.JavaAction {
43+
result := make([]*types.JavaAction, 0, len(systemJavaActions))
44+
for _, def := range systemJavaActions {
45+
ja := &types.JavaAction{
46+
ContainerID: model.ID(SystemModuleID),
47+
Name: def.Name,
48+
Documentation: def.Documentation,
49+
}
50+
ja.ID = model.ID(GenerateDeterministicID("System." + def.Name))
51+
result = append(result, ja)
52+
}
53+
return result
54+
}
55+
56+
// BuildSystemJavaActionsFull returns fully-typed javaactions.JavaAction entries for the System module.
57+
// These are built-in Java actions not stored in the MPR SQLite database.
58+
// Used by ListJavaActionsFull() for catalog insertion.
59+
func BuildSystemJavaActionsFull() []*javaactions.JavaAction {
60+
result := make([]*javaactions.JavaAction, 0, len(systemJavaActions))
61+
for _, def := range systemJavaActions {
62+
ja := &javaactions.JavaAction{
63+
ContainerID: model.ID(SystemModuleID),
64+
Name: def.Name,
65+
Documentation: def.Documentation,
66+
ExportLevel: "Hidden",
67+
}
68+
ja.ID = model.ID(GenerateDeterministicID("System." + def.Name))
69+
ja.ReturnType = buildSystemReturnType(def.ReturnType)
70+
for _, p := range def.Parameters {
71+
param := &javaactions.JavaActionParameter{
72+
Name: p.Name,
73+
IsRequired: true,
74+
}
75+
param.ID = model.ID(GenerateDeterministicID("System." + def.Name + "." + p.Name))
76+
param.ParameterType = buildSystemParamType(p.Type)
77+
ja.Parameters = append(ja.Parameters, param)
78+
}
79+
result = append(result, ja)
80+
}
81+
return result
82+
}
83+
84+
func buildSystemReturnType(t string) javaactions.CodeActionReturnType {
85+
switch t {
86+
case "Boolean":
87+
return &javaactions.BooleanType{}
88+
case "String":
89+
return &javaactions.StringType{}
90+
case "Integer":
91+
return &javaactions.IntegerType{}
92+
case "Long":
93+
return &javaactions.LongType{}
94+
case "Decimal":
95+
return &javaactions.DecimalType{}
96+
case "DateTime":
97+
return &javaactions.DateTimeType{}
98+
default:
99+
return &javaactions.VoidType{}
100+
}
101+
}
102+
103+
func buildSystemParamType(t string) javaactions.CodeActionParameterType {
104+
switch t {
105+
case "Boolean":
106+
return &javaactions.BooleanType{}
107+
case "Integer":
108+
return &javaactions.IntegerType{}
109+
case "Long":
110+
return &javaactions.LongType{}
111+
case "Decimal":
112+
return &javaactions.DecimalType{}
113+
case "DateTime":
114+
return &javaactions.DateTimeType{}
115+
default:
116+
return &javaactions.StringType{}
117+
}
118+
}

0 commit comments

Comments
 (0)