Cleanup resources
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package resource
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/system/types"
|
||||
)
|
||||
|
||||
@@ -24,14 +22,6 @@ func NewApplication(res *types.Application) *Application {
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *Application) SearchQuery() types.ApplicationFilter {
|
||||
f := types.ApplicationFilter{
|
||||
Name: r.Res.Name,
|
||||
}
|
||||
|
||||
if r.Res.ID > 0 {
|
||||
f.Query = fmt.Sprintf("applicationID=%d", r.Res.ID)
|
||||
}
|
||||
|
||||
return f
|
||||
func (r *Application) SysID() uint64 {
|
||||
return r.Res.ID
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package resource
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/compose/types"
|
||||
)
|
||||
|
||||
@@ -13,29 +11,29 @@ type (
|
||||
Res *types.Chart
|
||||
|
||||
// Might keep track of related namespace
|
||||
NsRef *Ref
|
||||
ModRef RefSet
|
||||
}
|
||||
)
|
||||
|
||||
func NewComposeChart(res *types.Chart, nsRef string) *ComposeChart {
|
||||
r := &ComposeChart{base: &base{}}
|
||||
func NewComposeChart(res *types.Chart, nsRef string, mmRef []string) *ComposeChart {
|
||||
r := &ComposeChart{
|
||||
base: &base{},
|
||||
ModRef: make(RefSet, len(mmRef)),
|
||||
}
|
||||
r.SetResourceType(COMPOSE_CHART_RESOURCE_TYPE)
|
||||
r.Res = res
|
||||
|
||||
r.AddIdentifier(identifiers(res.Handle, res.Name, res.ID)...)
|
||||
|
||||
r.AddRef(COMPOSE_NAMESPACE_RESOURCE_TYPE, nsRef)
|
||||
r.NsRef = r.AddRef(COMPOSE_NAMESPACE_RESOURCE_TYPE, nsRef)
|
||||
for i, mRef := range mmRef {
|
||||
r.ModRef[i] = r.AddRef(COMPOSE_MODULE_RESOURCE_TYPE, mRef)
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (m *ComposeChart) SearchQuery() types.ChartFilter {
|
||||
f := types.ChartFilter{
|
||||
Handle: m.Res.Handle,
|
||||
}
|
||||
|
||||
if m.Res.ID > 0 {
|
||||
f.Query = fmt.Sprintf("chartID=%d", m.Res.ID)
|
||||
}
|
||||
|
||||
return f
|
||||
func (r *ComposeChart) SysID() uint64 {
|
||||
return r.Res.ID
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package resource
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/compose/types"
|
||||
)
|
||||
|
||||
@@ -12,12 +10,16 @@ type (
|
||||
Res *types.Module
|
||||
|
||||
// Might keep track of related NS
|
||||
NsRef *Ref
|
||||
NsRef *Ref
|
||||
ModRef RefSet
|
||||
}
|
||||
)
|
||||
|
||||
func NewComposeModule(res *types.Module, nsRef string) *ComposeModule {
|
||||
r := &ComposeModule{base: &base{}}
|
||||
r := &ComposeModule{
|
||||
base: &base{},
|
||||
ModRef: make(RefSet, 0, len(res.Fields)),
|
||||
}
|
||||
r.SetResourceType(COMPOSE_MODULE_RESOURCE_TYPE)
|
||||
r.Res = res
|
||||
|
||||
@@ -25,13 +27,13 @@ func NewComposeModule(res *types.Module, nsRef string) *ComposeModule {
|
||||
|
||||
r.NsRef = r.AddRef(COMPOSE_NAMESPACE_RESOURCE_TYPE, nsRef)
|
||||
|
||||
// Field deps.
|
||||
// Field deps
|
||||
for _, f := range res.Fields {
|
||||
switch f.Kind {
|
||||
case "Record":
|
||||
refM := f.Options.String("module")
|
||||
if refM != "" && refM != "0" {
|
||||
r.AddRef(COMPOSE_MODULE_RESOURCE_TYPE, refM)
|
||||
r.ModRef = append(r.ModRef, r.AddRef(COMPOSE_MODULE_RESOURCE_TYPE, refM))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,15 +41,6 @@ func NewComposeModule(res *types.Module, nsRef string) *ComposeModule {
|
||||
return r
|
||||
}
|
||||
|
||||
func (m *ComposeModule) SearchQuery() types.ModuleFilter {
|
||||
f := types.ModuleFilter{
|
||||
Handle: m.Res.Handle,
|
||||
Name: m.Res.Name,
|
||||
}
|
||||
|
||||
if m.Res.ID > 0 {
|
||||
f.Query = fmt.Sprintf("moduleID=%d", m.Res.ID)
|
||||
}
|
||||
|
||||
return f
|
||||
func (r *ComposeModule) SysID() uint64 {
|
||||
return r.Res.ID
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package resource
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/compose/types"
|
||||
)
|
||||
|
||||
@@ -23,15 +21,6 @@ func NewComposeNamespace(ns *types.Namespace) *ComposeNamespace {
|
||||
return r
|
||||
}
|
||||
|
||||
func (m *ComposeNamespace) SearchQuery() types.NamespaceFilter {
|
||||
f := types.NamespaceFilter{
|
||||
Slug: m.Res.Slug,
|
||||
Name: m.Res.Name,
|
||||
}
|
||||
|
||||
if m.Res.ID > 0 {
|
||||
f.Query = fmt.Sprintf("namespaceID=%d", m.Res.ID)
|
||||
}
|
||||
|
||||
return f
|
||||
func (r *ComposeNamespace) SysID() uint64 {
|
||||
return r.Res.ID
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package resource
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/compose/types"
|
||||
)
|
||||
|
||||
@@ -12,8 +10,8 @@ type (
|
||||
*base
|
||||
Res *types.Page
|
||||
|
||||
// Might keep track of related namespace, page
|
||||
|
||||
NsRef *Ref
|
||||
ModRef *Ref
|
||||
}
|
||||
)
|
||||
|
||||
@@ -24,20 +22,14 @@ func NewComposePage(pg *types.Page, nsRef, modRef string) *ComposePage {
|
||||
|
||||
r.AddIdentifier(identifiers(pg.Handle, pg.Title, pg.ID)...)
|
||||
|
||||
r.AddRef(COMPOSE_NAMESPACE_RESOURCE_TYPE, nsRef)
|
||||
r.AddRef(COMPOSE_MODULE_RESOURCE_TYPE, modRef)
|
||||
r.NsRef = r.AddRef(COMPOSE_NAMESPACE_RESOURCE_TYPE, nsRef)
|
||||
if modRef != "" {
|
||||
r.ModRef = r.AddRef(COMPOSE_MODULE_RESOURCE_TYPE, modRef)
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (m *ComposePage) SearchQuery() types.PageFilter {
|
||||
f := types.PageFilter{
|
||||
Handle: m.Res.Handle,
|
||||
}
|
||||
|
||||
if m.Res.ID > 0 {
|
||||
f.Query = fmt.Sprintf("pageID=%d", m.Res.ID)
|
||||
}
|
||||
|
||||
return f
|
||||
func (r *ComposePage) SysID() uint64 {
|
||||
return r.Res.ID
|
||||
}
|
||||
|
||||
@@ -17,19 +17,24 @@ type (
|
||||
|
||||
ComposeRecord struct {
|
||||
*base
|
||||
// Res *types.Record
|
||||
|
||||
Walker crsWalker
|
||||
|
||||
NsRef *Ref
|
||||
ModRef *Ref
|
||||
ModFields types.ModuleFieldSet
|
||||
UserRef map[string]string
|
||||
NsRef *Ref
|
||||
ModRef *Ref
|
||||
|
||||
IDMap map[string]uint64
|
||||
RecMap map[string]*types.Record
|
||||
}
|
||||
)
|
||||
|
||||
func NewComposeRecordSet(w crsWalker, nsRef, modRef string) *ComposeRecord {
|
||||
r := &ComposeRecord{base: &base{}}
|
||||
r := &ComposeRecord{
|
||||
base: &base{},
|
||||
IDMap: make(map[string]uint64),
|
||||
RecMap: make(map[string]*types.Record),
|
||||
}
|
||||
|
||||
r.SetResourceType(COMPOSE_RECORD_RESOURCE_TYPE)
|
||||
r.Walker = w
|
||||
|
||||
@@ -44,9 +49,3 @@ func NewComposeRecordSet(w crsWalker, nsRef, modRef string) *ComposeRecord {
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (m *ComposeRecord) SearchQuery() types.RecordFilter {
|
||||
f := types.RecordFilter{}
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ type (
|
||||
Res *rbac.Rule
|
||||
|
||||
// Perhaps?
|
||||
RefRole string
|
||||
RefResource string
|
||||
RefRole *Ref
|
||||
RefResource *Ref
|
||||
}
|
||||
)
|
||||
|
||||
@@ -19,21 +19,12 @@ func NewRbacRule(res *rbac.Rule, refRole string, resRef *Ref) *RbacRule {
|
||||
r := &RbacRule{base: &base{}}
|
||||
r.SetResourceType(RBAC_RESOURCE_TYPE)
|
||||
r.Res = res
|
||||
r.RefRole = refRole
|
||||
|
||||
r.AddRef(ROLE_RESOURCE_TYPE, refRole)
|
||||
r.AddRef(resRef.ResourceType, resRef.Identifiers.StringSlice()...)
|
||||
r.RefRole = r.AddRef(ROLE_RESOURCE_TYPE, refRole)
|
||||
|
||||
// @todo identifiers?
|
||||
// Combination of resID, operation, rule?
|
||||
if resRef != nil {
|
||||
r.RefResource = r.AddRef(resRef.ResourceType, resRef.Identifiers.StringSlice()...)
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *RbacRule) SearchQuery() rbac.RuleFilter {
|
||||
f := rbac.RuleFilter{}
|
||||
|
||||
// @todo?
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package resource
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/system/types"
|
||||
)
|
||||
|
||||
@@ -24,15 +22,6 @@ func NewRole(rl *types.Role) *Role {
|
||||
return r
|
||||
}
|
||||
|
||||
func (m *Role) SearchQuery() types.RoleFilter {
|
||||
f := types.RoleFilter{
|
||||
Handle: m.Res.Handle,
|
||||
Name: m.Res.Name,
|
||||
}
|
||||
|
||||
if m.Res.ID > 0 {
|
||||
f.Query = fmt.Sprintf("roleID=%d", m.Res.ID)
|
||||
}
|
||||
|
||||
return f
|
||||
func (r *Role) SysID() uint64 {
|
||||
return r.Res.ID
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package resource
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/system/types"
|
||||
)
|
||||
|
||||
@@ -24,15 +22,6 @@ func NewUser(u *types.User) *User {
|
||||
return r
|
||||
}
|
||||
|
||||
func (m *User) SearchQuery() types.UserFilter {
|
||||
f := types.UserFilter{
|
||||
Handle: m.Res.Handle,
|
||||
Email: m.Res.Email,
|
||||
}
|
||||
|
||||
if m.Res.ID > 0 {
|
||||
f.Query = fmt.Sprintf("userID=%d", m.Res.ID)
|
||||
}
|
||||
|
||||
return f
|
||||
func (r *User) SysID() uint64 {
|
||||
return r.Res.ID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user