636 lines
20 KiB
Go
636 lines
20 KiB
Go
// Code generated by BobGen psql v0.42.5. DO NOT EDIT.
|
|
// This file is meant to be re-generated in place and/or deleted at any time.
|
|
|
|
package factory
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/Gleipnir-Technology/bob"
|
|
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
|
models "github.com/Gleipnir-Technology/nidus-sync/db/models"
|
|
"github.com/aarondl/opt/omit"
|
|
"github.com/jaswdr/faker/v2"
|
|
)
|
|
|
|
type ArcgisLayerFieldMod interface {
|
|
Apply(context.Context, *ArcgisLayerFieldTemplate)
|
|
}
|
|
|
|
type ArcgisLayerFieldModFunc func(context.Context, *ArcgisLayerFieldTemplate)
|
|
|
|
func (f ArcgisLayerFieldModFunc) Apply(ctx context.Context, n *ArcgisLayerFieldTemplate) {
|
|
f(ctx, n)
|
|
}
|
|
|
|
type ArcgisLayerFieldModSlice []ArcgisLayerFieldMod
|
|
|
|
func (mods ArcgisLayerFieldModSlice) Apply(ctx context.Context, n *ArcgisLayerFieldTemplate) {
|
|
for _, f := range mods {
|
|
f.Apply(ctx, n)
|
|
}
|
|
}
|
|
|
|
// ArcgisLayerFieldTemplate is an object representing the database table.
|
|
// all columns are optional and should be set by mods
|
|
type ArcgisLayerFieldTemplate struct {
|
|
LayerFeatureServiceItemID func() string
|
|
LayerIndex func() int32
|
|
Name func() string
|
|
Type func() enums.ArcgisFieldtype
|
|
|
|
r arcgisLayerFieldR
|
|
f *Factory
|
|
|
|
alreadyPersisted bool
|
|
}
|
|
|
|
type arcgisLayerFieldR struct {
|
|
AddressMappings []*arcgisLayerFieldRAddressMappingsR
|
|
Layer *arcgisLayerFieldRLayerR
|
|
ParcelMappings []*arcgisLayerFieldRParcelMappingsR
|
|
}
|
|
|
|
type arcgisLayerFieldRAddressMappingsR struct {
|
|
number int
|
|
o *ArcgisAddressMappingTemplate
|
|
}
|
|
type arcgisLayerFieldRLayerR struct {
|
|
o *ArcgisLayerTemplate
|
|
}
|
|
type arcgisLayerFieldRParcelMappingsR struct {
|
|
number int
|
|
o *ArcgisParcelMappingTemplate
|
|
}
|
|
|
|
// Apply mods to the ArcgisLayerFieldTemplate
|
|
func (o *ArcgisLayerFieldTemplate) Apply(ctx context.Context, mods ...ArcgisLayerFieldMod) {
|
|
for _, mod := range mods {
|
|
mod.Apply(ctx, o)
|
|
}
|
|
}
|
|
|
|
// setModelRels creates and sets the relationships on *models.ArcgisLayerField
|
|
// according to the relationships in the template. Nothing is inserted into the db
|
|
func (t ArcgisLayerFieldTemplate) setModelRels(o *models.ArcgisLayerField) {
|
|
if t.r.AddressMappings != nil {
|
|
rel := models.ArcgisAddressMappingSlice{}
|
|
for _, r := range t.r.AddressMappings {
|
|
related := r.o.BuildMany(r.number)
|
|
for _, rel := range related {
|
|
rel.LayerFeatureServiceItemID = o.LayerFeatureServiceItemID // h2
|
|
rel.LayerIndex = o.LayerIndex // h2
|
|
rel.LayerFieldName = o.Name // h2
|
|
rel.R.LayerField = o
|
|
}
|
|
rel = append(rel, related...)
|
|
}
|
|
o.R.AddressMappings = rel
|
|
}
|
|
|
|
if t.r.Layer != nil {
|
|
rel := t.r.Layer.o.Build()
|
|
rel.R.LayerFields = append(rel.R.LayerFields, o)
|
|
o.LayerFeatureServiceItemID = rel.FeatureServiceItemID // h2
|
|
o.LayerIndex = rel.Index // h2
|
|
o.R.Layer = rel
|
|
}
|
|
|
|
if t.r.ParcelMappings != nil {
|
|
rel := models.ArcgisParcelMappingSlice{}
|
|
for _, r := range t.r.ParcelMappings {
|
|
related := r.o.BuildMany(r.number)
|
|
for _, rel := range related {
|
|
rel.LayerFeatureServiceItemID = o.LayerFeatureServiceItemID // h2
|
|
rel.LayerIndex = o.LayerIndex // h2
|
|
rel.LayerFieldName = o.Name // h2
|
|
rel.R.LayerField = o
|
|
}
|
|
rel = append(rel, related...)
|
|
}
|
|
o.R.ParcelMappings = rel
|
|
}
|
|
}
|
|
|
|
// BuildSetter returns an *models.ArcgisLayerFieldSetter
|
|
// this does nothing with the relationship templates
|
|
func (o ArcgisLayerFieldTemplate) BuildSetter() *models.ArcgisLayerFieldSetter {
|
|
m := &models.ArcgisLayerFieldSetter{}
|
|
|
|
if o.LayerFeatureServiceItemID != nil {
|
|
val := o.LayerFeatureServiceItemID()
|
|
m.LayerFeatureServiceItemID = omit.From(val)
|
|
}
|
|
if o.LayerIndex != nil {
|
|
val := o.LayerIndex()
|
|
m.LayerIndex = omit.From(val)
|
|
}
|
|
if o.Name != nil {
|
|
val := o.Name()
|
|
m.Name = omit.From(val)
|
|
}
|
|
if o.Type != nil {
|
|
val := o.Type()
|
|
m.Type = omit.From(val)
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
// BuildManySetter returns an []*models.ArcgisLayerFieldSetter
|
|
// this does nothing with the relationship templates
|
|
func (o ArcgisLayerFieldTemplate) BuildManySetter(number int) []*models.ArcgisLayerFieldSetter {
|
|
m := make([]*models.ArcgisLayerFieldSetter, number)
|
|
|
|
for i := range m {
|
|
m[i] = o.BuildSetter()
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
// Build returns an *models.ArcgisLayerField
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use ArcgisLayerFieldTemplate.Create
|
|
func (o ArcgisLayerFieldTemplate) Build() *models.ArcgisLayerField {
|
|
m := &models.ArcgisLayerField{}
|
|
|
|
if o.LayerFeatureServiceItemID != nil {
|
|
m.LayerFeatureServiceItemID = o.LayerFeatureServiceItemID()
|
|
}
|
|
if o.LayerIndex != nil {
|
|
m.LayerIndex = o.LayerIndex()
|
|
}
|
|
if o.Name != nil {
|
|
m.Name = o.Name()
|
|
}
|
|
if o.Type != nil {
|
|
m.Type = o.Type()
|
|
}
|
|
|
|
o.setModelRels(m)
|
|
|
|
return m
|
|
}
|
|
|
|
// BuildMany returns an models.ArcgisLayerFieldSlice
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use ArcgisLayerFieldTemplate.CreateMany
|
|
func (o ArcgisLayerFieldTemplate) BuildMany(number int) models.ArcgisLayerFieldSlice {
|
|
m := make(models.ArcgisLayerFieldSlice, number)
|
|
|
|
for i := range m {
|
|
m[i] = o.Build()
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func ensureCreatableArcgisLayerField(m *models.ArcgisLayerFieldSetter) {
|
|
if !(m.LayerFeatureServiceItemID.IsValue()) {
|
|
val := random_string(nil)
|
|
m.LayerFeatureServiceItemID = omit.From(val)
|
|
}
|
|
if !(m.LayerIndex.IsValue()) {
|
|
val := random_int32(nil)
|
|
m.LayerIndex = omit.From(val)
|
|
}
|
|
if !(m.Name.IsValue()) {
|
|
val := random_string(nil)
|
|
m.Name = omit.From(val)
|
|
}
|
|
if !(m.Type.IsValue()) {
|
|
val := random_enums_ArcgisFieldtype(nil)
|
|
m.Type = omit.From(val)
|
|
}
|
|
}
|
|
|
|
// insertOptRels creates and inserts any optional the relationships on *models.ArcgisLayerField
|
|
// according to the relationships in the template.
|
|
// any required relationship should have already exist on the model
|
|
func (o *ArcgisLayerFieldTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.ArcgisLayerField) error {
|
|
var err error
|
|
|
|
isAddressMappingsDone, _ := arcgisLayerFieldRelAddressMappingsCtx.Value(ctx)
|
|
if !isAddressMappingsDone && o.r.AddressMappings != nil {
|
|
ctx = arcgisLayerFieldRelAddressMappingsCtx.WithValue(ctx, true)
|
|
for _, r := range o.r.AddressMappings {
|
|
if r.o.alreadyPersisted {
|
|
m.R.AddressMappings = append(m.R.AddressMappings, r.o.Build())
|
|
} else {
|
|
rel0, err := r.o.CreateMany(ctx, exec, r.number)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = m.AttachAddressMappings(ctx, exec, rel0...)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
isParcelMappingsDone, _ := arcgisLayerFieldRelParcelMappingsCtx.Value(ctx)
|
|
if !isParcelMappingsDone && o.r.ParcelMappings != nil {
|
|
ctx = arcgisLayerFieldRelParcelMappingsCtx.WithValue(ctx, true)
|
|
for _, r := range o.r.ParcelMappings {
|
|
if r.o.alreadyPersisted {
|
|
m.R.ParcelMappings = append(m.R.ParcelMappings, r.o.Build())
|
|
} else {
|
|
rel2, err := r.o.CreateMany(ctx, exec, r.number)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = m.AttachParcelMappings(ctx, exec, rel2...)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
// Create builds a arcgisLayerField and inserts it into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
func (o *ArcgisLayerFieldTemplate) Create(ctx context.Context, exec bob.Executor) (*models.ArcgisLayerField, error) {
|
|
var err error
|
|
opt := o.BuildSetter()
|
|
ensureCreatableArcgisLayerField(opt)
|
|
|
|
if o.r.Layer == nil {
|
|
ArcgisLayerFieldMods.WithNewLayer().Apply(ctx, o)
|
|
}
|
|
|
|
var rel1 *models.ArcgisLayer
|
|
|
|
if o.r.Layer.o.alreadyPersisted {
|
|
rel1 = o.r.Layer.o.Build()
|
|
} else {
|
|
rel1, err = o.r.Layer.o.Create(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
opt.LayerFeatureServiceItemID = omit.From(rel1.FeatureServiceItemID)
|
|
opt.LayerIndex = omit.From(rel1.Index)
|
|
|
|
m, err := models.ArcgisLayerFields.Insert(opt).One(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
m.R.Layer = rel1
|
|
|
|
if err := o.insertOptRels(ctx, exec, m); err != nil {
|
|
return nil, err
|
|
}
|
|
return m, err
|
|
}
|
|
|
|
// MustCreate builds a arcgisLayerField and inserts it into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// panics if an error occurs
|
|
func (o *ArcgisLayerFieldTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.ArcgisLayerField {
|
|
m, err := o.Create(ctx, exec)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateOrFail builds a arcgisLayerField and inserts it into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
|
|
func (o *ArcgisLayerFieldTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.ArcgisLayerField {
|
|
tb.Helper()
|
|
m, err := o.Create(ctx, exec)
|
|
if err != nil {
|
|
tb.Fatal(err)
|
|
return nil
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateMany builds multiple arcgisLayerFields and inserts them into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
func (o ArcgisLayerFieldTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.ArcgisLayerFieldSlice, error) {
|
|
var err error
|
|
m := make(models.ArcgisLayerFieldSlice, number)
|
|
|
|
for i := range m {
|
|
m[i], err = o.Create(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
return m, nil
|
|
}
|
|
|
|
// MustCreateMany builds multiple arcgisLayerFields and inserts them into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// panics if an error occurs
|
|
func (o ArcgisLayerFieldTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.ArcgisLayerFieldSlice {
|
|
m, err := o.CreateMany(ctx, exec, number)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateManyOrFail builds multiple arcgisLayerFields and inserts them into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
|
|
func (o ArcgisLayerFieldTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.ArcgisLayerFieldSlice {
|
|
tb.Helper()
|
|
m, err := o.CreateMany(ctx, exec, number)
|
|
if err != nil {
|
|
tb.Fatal(err)
|
|
return nil
|
|
}
|
|
return m
|
|
}
|
|
|
|
// ArcgisLayerField has methods that act as mods for the ArcgisLayerFieldTemplate
|
|
var ArcgisLayerFieldMods arcgisLayerFieldMods
|
|
|
|
type arcgisLayerFieldMods struct{}
|
|
|
|
func (m arcgisLayerFieldMods) RandomizeAllColumns(f *faker.Faker) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModSlice{
|
|
ArcgisLayerFieldMods.RandomLayerFeatureServiceItemID(f),
|
|
ArcgisLayerFieldMods.RandomLayerIndex(f),
|
|
ArcgisLayerFieldMods.RandomName(f),
|
|
ArcgisLayerFieldMods.RandomType(f),
|
|
}
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m arcgisLayerFieldMods) LayerFeatureServiceItemID(val string) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.LayerFeatureServiceItemID = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m arcgisLayerFieldMods) LayerFeatureServiceItemIDFunc(f func() string) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.LayerFeatureServiceItemID = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m arcgisLayerFieldMods) UnsetLayerFeatureServiceItemID() ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.LayerFeatureServiceItemID = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m arcgisLayerFieldMods) RandomLayerFeatureServiceItemID(f *faker.Faker) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.LayerFeatureServiceItemID = func() string {
|
|
return random_string(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m arcgisLayerFieldMods) LayerIndex(val int32) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.LayerIndex = func() int32 { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m arcgisLayerFieldMods) LayerIndexFunc(f func() int32) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.LayerIndex = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m arcgisLayerFieldMods) UnsetLayerIndex() ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.LayerIndex = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m arcgisLayerFieldMods) RandomLayerIndex(f *faker.Faker) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.LayerIndex = func() int32 {
|
|
return random_int32(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m arcgisLayerFieldMods) Name(val string) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.Name = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m arcgisLayerFieldMods) NameFunc(f func() string) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.Name = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m arcgisLayerFieldMods) UnsetName() ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.Name = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m arcgisLayerFieldMods) RandomName(f *faker.Faker) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.Name = func() string {
|
|
return random_string(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m arcgisLayerFieldMods) Type(val enums.ArcgisFieldtype) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.Type = func() enums.ArcgisFieldtype { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m arcgisLayerFieldMods) TypeFunc(f func() enums.ArcgisFieldtype) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.Type = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m arcgisLayerFieldMods) UnsetType() ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.Type = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m arcgisLayerFieldMods) RandomType(f *faker.Faker) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(_ context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.Type = func() enums.ArcgisFieldtype {
|
|
return random_enums_ArcgisFieldtype(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) WithParentsCascading() ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
if isDone, _ := arcgisLayerFieldWithParentsCascadingCtx.Value(ctx); isDone {
|
|
return
|
|
}
|
|
ctx = arcgisLayerFieldWithParentsCascadingCtx.WithValue(ctx, true)
|
|
{
|
|
|
|
related := o.f.NewArcgisLayerWithContext(ctx, ArcgisLayerMods.WithParentsCascading())
|
|
m.WithLayer(related).Apply(ctx, o)
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) WithLayer(rel *ArcgisLayerTemplate) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.r.Layer = &arcgisLayerFieldRLayerR{
|
|
o: rel,
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) WithNewLayer(mods ...ArcgisLayerMod) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
related := o.f.NewArcgisLayerWithContext(ctx, mods...)
|
|
|
|
m.WithLayer(related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) WithExistingLayer(em *models.ArcgisLayer) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.r.Layer = &arcgisLayerFieldRLayerR{
|
|
o: o.f.FromExistingArcgisLayer(em),
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) WithoutLayer() ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.r.Layer = nil
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) WithAddressMappings(number int, related *ArcgisAddressMappingTemplate) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.r.AddressMappings = []*arcgisLayerFieldRAddressMappingsR{{
|
|
number: number,
|
|
o: related,
|
|
}}
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) WithNewAddressMappings(number int, mods ...ArcgisAddressMappingMod) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
related := o.f.NewArcgisAddressMappingWithContext(ctx, mods...)
|
|
m.WithAddressMappings(number, related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) AddAddressMappings(number int, related *ArcgisAddressMappingTemplate) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.r.AddressMappings = append(o.r.AddressMappings, &arcgisLayerFieldRAddressMappingsR{
|
|
number: number,
|
|
o: related,
|
|
})
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) AddNewAddressMappings(number int, mods ...ArcgisAddressMappingMod) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
related := o.f.NewArcgisAddressMappingWithContext(ctx, mods...)
|
|
m.AddAddressMappings(number, related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) AddExistingAddressMappings(existingModels ...*models.ArcgisAddressMapping) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
for _, em := range existingModels {
|
|
o.r.AddressMappings = append(o.r.AddressMappings, &arcgisLayerFieldRAddressMappingsR{
|
|
o: o.f.FromExistingArcgisAddressMapping(em),
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) WithoutAddressMappings() ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.r.AddressMappings = nil
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) WithParcelMappings(number int, related *ArcgisParcelMappingTemplate) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.r.ParcelMappings = []*arcgisLayerFieldRParcelMappingsR{{
|
|
number: number,
|
|
o: related,
|
|
}}
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) WithNewParcelMappings(number int, mods ...ArcgisParcelMappingMod) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
related := o.f.NewArcgisParcelMappingWithContext(ctx, mods...)
|
|
m.WithParcelMappings(number, related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) AddParcelMappings(number int, related *ArcgisParcelMappingTemplate) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.r.ParcelMappings = append(o.r.ParcelMappings, &arcgisLayerFieldRParcelMappingsR{
|
|
number: number,
|
|
o: related,
|
|
})
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) AddNewParcelMappings(number int, mods ...ArcgisParcelMappingMod) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
related := o.f.NewArcgisParcelMappingWithContext(ctx, mods...)
|
|
m.AddParcelMappings(number, related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) AddExistingParcelMappings(existingModels ...*models.ArcgisParcelMapping) ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
for _, em := range existingModels {
|
|
o.r.ParcelMappings = append(o.r.ParcelMappings, &arcgisLayerFieldRParcelMappingsR{
|
|
o: o.f.FromExistingArcgisParcelMapping(em),
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m arcgisLayerFieldMods) WithoutParcelMappings() ArcgisLayerFieldMod {
|
|
return ArcgisLayerFieldModFunc(func(ctx context.Context, o *ArcgisLayerFieldTemplate) {
|
|
o.r.ParcelMappings = nil
|
|
})
|
|
}
|