models

package
v0.0.0-...-1806229 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

generated by ModelGongFileTemplate

Index

Constants

View Source
const IdentifiersDecls = `
	{{Identifier}} := (&models.{{GeneratedStructName}}{Name: ` + "`" + `{{GeneratedFieldNameValue}}` + "`" + `}).Stage()`
View Source
const NumberInitStatement = `
	{{Identifier}}.{{GeneratedFieldName}} = {{GeneratedFieldNameValue}}`
View Source
const PointerFieldInitStatement = `
	{{Identifier}}.{{GeneratedFieldName}} = {{GeneratedFieldNameValue}}`
View Source
const SliceOfPointersFieldInitStatement = `
	{{Identifier}}.{{GeneratedFieldName}} = append({{Identifier}}.{{GeneratedFieldName}}, {{GeneratedFieldNameValue}})`
View Source
const StringEnumInitStatement = `
	{{Identifier}}.{{GeneratedFieldName}} = {{GeneratedFieldNameValue}}`
View Source
const StringInitStatement = `
	{{Identifier}}.{{GeneratedFieldName}} = ` + "`" + `{{GeneratedFieldNameValue}}` + "`"
View Source
const TimeInitStatement = `` /* 129-byte string literal not displayed */

Variables

This section is empty.

Functions

func AfterCreateFromFront

func AfterCreateFromFront[Type Gongstruct](stage *StageStruct, instance *Type)

AfterCreateFromFront is called after a create from front

func AfterDeleteFromFront

func AfterDeleteFromFront[Type Gongstruct](stage *StageStruct, staged, front *Type)

AfterDeleteFromFront is called after a delete from front

func AfterReadFromFront

func AfterReadFromFront[Type Gongstruct](stage *StageStruct, instance *Type)

AfterReadFromFront is called after a Read from front

func AfterUpdateFromFront

func AfterUpdateFromFront[Type Gongstruct](stage *StageStruct, old, new *Type)

AfterUpdateFromFront is called after a update from front

func CreateORMChartConfiguration

func CreateORMChartConfiguration(chartconfiguration *ChartConfiguration)

CreateORMChartConfiguration enables dynamic staging of a ChartConfiguration instance

func CreateORMDataPoint

func CreateORMDataPoint(datapoint *DataPoint)

CreateORMDataPoint enables dynamic staging of a DataPoint instance

func CreateORMDataset

func CreateORMDataset(dataset *Dataset)

CreateORMDataset enables dynamic staging of a Dataset instance

func CreateORMLabel

func CreateORMLabel(label *Label)

CreateORMLabel enables dynamic staging of a Label instance

func DeleteORMChartConfiguration

func DeleteORMChartConfiguration(chartconfiguration *ChartConfiguration)

DeleteORMChartConfiguration enables dynamic staging of a ChartConfiguration instance

func DeleteORMDataPoint

func DeleteORMDataPoint(datapoint *DataPoint)

DeleteORMDataPoint enables dynamic staging of a DataPoint instance

func DeleteORMDataset

func DeleteORMDataset(dataset *Dataset)

DeleteORMDataset enables dynamic staging of a Dataset instance

func DeleteORMLabel

func DeleteORMLabel(label *Label)

DeleteORMLabel enables dynamic staging of a Label instance

func GetAssociationName

func GetAssociationName[Type Gongstruct]() *Type

GetAssociationName is a generic function that returns an instance of Type where each association is filled with an instance whose name is the name of the association

This function can be handy for generating navigation function that are refactorable

func GetFieldStringValue

func GetFieldStringValue[Type Gongstruct](instance Type, fieldName string) (res string)

func GetFields

func GetFields[Type Gongstruct]() (res []string)

GetFields return the array of the fields

func GetGongstructInstancesMap

func GetGongstructInstancesMap[Type Gongstruct]() *map[string]*Type

GetGongstructInstancesMap returns the map of staged GongstructType instances it is usefull because it allows refactoring of gong struct identifier

func GetGongstructInstancesSet

func GetGongstructInstancesSet[Type Gongstruct]() *map[*Type]any

GetGongstructInstancesSet returns the set staged GongstructType instances it is usefull because it allows refactoring of gongstruct identifier

func GetGongstructName

func GetGongstructName[Type Gongstruct]() (res string)

GetGongstructName returns the name of the Gongstruct this can be usefull if one want program robust to refactoring

func GetPointerReverseMap

func GetPointerReverseMap[Start, End Gongstruct](fieldname string) map[*End][]*Start

GetPointerReverseMap allows backtrack navigation of any Start.Fieldname associations (0..1) that is a pointer from one staged Gongstruct (type Start) instances to another (type End)

The function provides a map with keys as instances of End and values to arrays of *Start the map is construed by iterating over all Start instances and populationg keys with End instances and values with slice of Start instances

func GetSliceOfPointersReverseMap

func GetSliceOfPointersReverseMap[Start, End Gongstruct](fieldname string) map[*End]*Start

GetSliceOfPointersReverseMap allows backtrack navigation of any Start.Fieldname associations (0..N) between one staged Gongstruct instances and many others

The function provides a map with keys as instances of End and values to *Start instances the map is construed by iterating over all Start instances and populating keys with End instances and values with the Start instances

func GongGetMap

func GongGetMap[Type GongstructMapString]() *Type

GongGetMap returns the map of staged GongstructType instances it is usefull because it allows refactoring of gong struct identifier

func GongGetSet

func GongGetSet[Type GongstructSet]() *Type

GongGetSet returns the set staged GongstructType instances it is usefull because it allows refactoring of gong struct identifier

func IntToLetters

func IntToLetters(number int32) (letters string)

func ParseAstFile

func ParseAstFile(pathToFile string) error

ParseAstFile Parse pathToFile and stages all instances declared in the file

func Serialize

func Serialize[Type Gongstruct](tab Tabulator)

func SerializeExcelize

func SerializeExcelize[Type Gongstruct](f *excelize.File)

func SerializeStage

func SerializeStage(filename string)

func SetCallbackAfterCreateFromFront

func SetCallbackAfterCreateFromFront[Type Gongstruct](stage *StageStruct, callback OnAfterCreateInterface[Type])

func SetCallbackAfterDeleteFromFront

func SetCallbackAfterDeleteFromFront[Type Gongstruct](stage *StageStruct, callback OnAfterDeleteInterface[Type])

func SetCallbackAfterReadFromFront

func SetCallbackAfterReadFromFront[Type Gongstruct](stage *StageStruct, callback OnAfterReadInterface[Type])

func SetCallbackAfterUpdateFromFront

func SetCallbackAfterUpdateFromFront[Type Gongstruct](stage *StageStruct, callback OnAfterUpdateInterface[Type])

SetCallbackAfterUpdateFromFront is a function to set up callback that is robust to refactoring

func UnmarshallGongstructStaging

func UnmarshallGongstructStaging(assignStmt *ast.AssignStmt, astCoordinate_ string) (
	instance any,
	identifier string,
	gongstructName string,
	fieldName string)

UnmarshallGoStaging unmarshall a go assign statement

Types

type AllModelsStructCreateInterface

type AllModelsStructCreateInterface interface {
	CreateORMChartConfiguration(ChartConfiguration *ChartConfiguration)
	CreateORMDataPoint(DataPoint *DataPoint)
	CreateORMDataset(Dataset *Dataset)
	CreateORMLabel(Label *Label)
}

swagger:ignore

type AllModelsStructDeleteInterface

type AllModelsStructDeleteInterface interface {
	DeleteORMChartConfiguration(ChartConfiguration *ChartConfiguration)
	DeleteORMDataPoint(DataPoint *DataPoint)
	DeleteORMDataset(Dataset *Dataset)
	DeleteORMLabel(Label *Label)
}

type BackRepoInterface

type BackRepoInterface interface {
	Commit(stage *StageStruct)
	Checkout(stage *StageStruct)
	Backup(stage *StageStruct, dirPath string)
	Restore(stage *StageStruct, dirPath string)
	BackupXL(stage *StageStruct, dirPath string)
	RestoreXL(stage *StageStruct, dirPath string)
	// insertion point for Commit and Checkout signatures
	CommitChartConfiguration(chartconfiguration *ChartConfiguration)
	CheckoutChartConfiguration(chartconfiguration *ChartConfiguration)
	CommitDataPoint(datapoint *DataPoint)
	CheckoutDataPoint(datapoint *DataPoint)
	CommitDataset(dataset *Dataset)
	CheckoutDataset(dataset *Dataset)
	CommitLabel(label *Label)
	CheckoutLabel(label *Label)
	GetLastCommitFromBackNb() uint
	GetLastPushFromFrontNb() uint
}

type ChartConfiguration

type ChartConfiguration struct {
	Name      string
	Datasets  []*Dataset
	Labels    []*Label
	ChartType ChartType

	// width and height of the canvas object <canvas baseChart [width]="width" [height]="height"
	Width  int
	Heigth int
}

func (*ChartConfiguration) Checkout

func (chartconfiguration *ChartConfiguration) Checkout() *ChartConfiguration

Checkout chartconfiguration to the back repo (if it is already staged)

func (*ChartConfiguration) Commit

func (chartconfiguration *ChartConfiguration) Commit() *ChartConfiguration

commit chartconfiguration to the back repo (if it is already staged)

func (*ChartConfiguration) DeleteStageAndCommit

func (chartconfiguration *ChartConfiguration) DeleteStageAndCommit() *ChartConfiguration

DeleteStageAndCommit appends chartconfiguration to the model stage and commit to the orm repo

func (*ChartConfiguration) GetName

func (chartconfiguration *ChartConfiguration) GetName() (res string)

for satisfaction of GongStruct interface

func (*ChartConfiguration) Stage

func (chartconfiguration *ChartConfiguration) Stage() *ChartConfiguration

insertion point for cumulative sub template with model space calls Stage puts chartconfiguration to the model stage

func (*ChartConfiguration) StageAndCommit

func (chartconfiguration *ChartConfiguration) StageAndCommit() *ChartConfiguration

StageAndCommit appends chartconfiguration to the model stage and commit to the orm repo

func (*ChartConfiguration) StageCopy

func (chartconfiguration *ChartConfiguration) StageCopy() *ChartConfiguration

StageCopy appends a copy of chartconfiguration to the model stage

func (*ChartConfiguration) StageCopyAndCommit

func (chartconfiguration *ChartConfiguration) StageCopyAndCommit() *ChartConfiguration

StageCopyAndCommit appends a copy of chartconfiguration to the model stage and commit to the orm repo

func (*ChartConfiguration) Unstage

func (chartconfiguration *ChartConfiguration) Unstage() *ChartConfiguration

Unstage removes chartconfiguration off the model stage

type ChartType

type ChartType string
const (
	LINE       ChartType = "line"
	BAR        ChartType = "bar"
	RADAR      ChartType = "radar"
	PIE        ChartType = "pie"
	POLAR_AREA ChartType = "polarArea"
	DOUGHNUT   ChartType = "doughnut"
)

values for EnumType

func (*ChartType) FromCodeString

func (charttype *ChartType) FromCodeString(input string) (err error)

func (*ChartType) FromString

func (charttype *ChartType) FromString(input string) (err error)

func (*ChartType) ToCodeString

func (charttype *ChartType) ToCodeString() (res string)

func (ChartType) ToString

func (charttype ChartType) ToString() (res string)

insertion point of enum utility functions Utility function for ChartType if enum values are string, it is stored with the value if enum values are int, they are stored with the code of the value

type DataPoint

type DataPoint struct {
	Name  string
	Value float64
}

func (*DataPoint) Checkout

func (datapoint *DataPoint) Checkout() *DataPoint

Checkout datapoint to the back repo (if it is already staged)

func (*DataPoint) Commit

func (datapoint *DataPoint) Commit() *DataPoint

commit datapoint to the back repo (if it is already staged)

func (*DataPoint) DeleteStageAndCommit

func (datapoint *DataPoint) DeleteStageAndCommit() *DataPoint

DeleteStageAndCommit appends datapoint to the model stage and commit to the orm repo

func (*DataPoint) GetName

func (datapoint *DataPoint) GetName() (res string)

for satisfaction of GongStruct interface

func (*DataPoint) Stage

func (datapoint *DataPoint) Stage() *DataPoint

Stage puts datapoint to the model stage

func (*DataPoint) StageAndCommit

func (datapoint *DataPoint) StageAndCommit() *DataPoint

StageAndCommit appends datapoint to the model stage and commit to the orm repo

func (*DataPoint) StageCopy

func (datapoint *DataPoint) StageCopy() *DataPoint

StageCopy appends a copy of datapoint to the model stage

func (*DataPoint) StageCopyAndCommit

func (datapoint *DataPoint) StageCopyAndCommit() *DataPoint

StageCopyAndCommit appends a copy of datapoint to the model stage and commit to the orm repo

func (*DataPoint) Unstage

func (datapoint *DataPoint) Unstage() *DataPoint

Unstage removes datapoint off the model stage

type Dataset

type Dataset struct {
	Name       string
	DataPoints []*DataPoint
	Label      string
}

func (*Dataset) Checkout

func (dataset *Dataset) Checkout() *Dataset

Checkout dataset to the back repo (if it is already staged)

func (*Dataset) Commit

func (dataset *Dataset) Commit() *Dataset

commit dataset to the back repo (if it is already staged)

func (*Dataset) DeleteStageAndCommit

func (dataset *Dataset) DeleteStageAndCommit() *Dataset

DeleteStageAndCommit appends dataset to the model stage and commit to the orm repo

func (*Dataset) GetName

func (dataset *Dataset) GetName() (res string)

for satisfaction of GongStruct interface

func (*Dataset) Stage

func (dataset *Dataset) Stage() *Dataset

Stage puts dataset to the model stage

func (*Dataset) StageAndCommit

func (dataset *Dataset) StageAndCommit() *Dataset

StageAndCommit appends dataset to the model stage and commit to the orm repo

func (*Dataset) StageCopy

func (dataset *Dataset) StageCopy() *Dataset

StageCopy appends a copy of dataset to the model stage

func (*Dataset) StageCopyAndCommit

func (dataset *Dataset) StageCopyAndCommit() *Dataset

StageCopyAndCommit appends a copy of dataset to the model stage and commit to the orm repo

func (*Dataset) Unstage

func (dataset *Dataset) Unstage() *Dataset

Unstage removes dataset off the model stage

type ExcelizeTabulator

type ExcelizeTabulator struct {
	// contains filtered or unexported fields
}

func (*ExcelizeTabulator) AddCell

func (tab *ExcelizeTabulator) AddCell(sheetName string, rowId, columnIndex int, value string)

func (*ExcelizeTabulator) AddRow

func (tab *ExcelizeTabulator) AddRow(sheetName string) (rowId int)

func (*ExcelizeTabulator) AddSheet

func (tab *ExcelizeTabulator) AddSheet(sheetName string)

func (*ExcelizeTabulator) SetExcelizeFile

func (tab *ExcelizeTabulator) SetExcelizeFile(f *excelize.File)

type GongStructInterface

type GongStructInterface interface {
	GetName() (res string)
	GetFields() (res []string)
	GetFieldStringValue(fieldName string) (res string)
}

GongStructInterface is the interface met by GongStructs It allows runtime reflexion of instances (without the hassle of the "reflect" package)

type Gongstruct

type Gongstruct interface {
	// insertion point for generic types
	ChartConfiguration | DataPoint | Dataset | Label
}

Gongstruct is the type parameter for generated generic function that allows - access to staged instances - navigation between staged instances by going backward association links between gongstruct - full refactoring of Gongstruct identifiers / fields

type GongstructMapString

type GongstructMapString interface {
	map[any]any |

		map[string]*ChartConfiguration |
		map[string]*DataPoint |
		map[string]*Dataset |
		map[string]*Label |
		map[*any]any // because go does not support an extra "|" at the end of type specifications
}

type GongstructSet

type GongstructSet interface {
	map[any]any |

		map[*ChartConfiguration]any |
		map[*DataPoint]any |
		map[*Dataset]any |
		map[*Label]any |
		map[*any]any // because go does not support an extra "|" at the end of type specifications
}

type Label

type Label struct {
	Name string
}

func (*Label) Checkout

func (label *Label) Checkout() *Label

Checkout label to the back repo (if it is already staged)

func (*Label) Commit

func (label *Label) Commit() *Label

commit label to the back repo (if it is already staged)

func (*Label) DeleteStageAndCommit

func (label *Label) DeleteStageAndCommit() *Label

DeleteStageAndCommit appends label to the model stage and commit to the orm repo

func (*Label) GetName

func (label *Label) GetName() (res string)

for satisfaction of GongStruct interface

func (*Label) Stage

func (label *Label) Stage() *Label

Stage puts label to the model stage

func (*Label) StageAndCommit

func (label *Label) StageAndCommit() *Label

StageAndCommit appends label to the model stage and commit to the orm repo

func (*Label) StageCopy

func (label *Label) StageCopy() *Label

StageCopy appends a copy of label to the model stage

func (*Label) StageCopyAndCommit

func (label *Label) StageCopyAndCommit() *Label

StageCopyAndCommit appends a copy of label to the model stage and commit to the orm repo

func (*Label) Unstage

func (label *Label) Unstage() *Label

Unstage removes label off the model stage

type OnAfterCreateInterface

type OnAfterCreateInterface[Type Gongstruct] interface {
	OnAfterCreate(stage *StageStruct,
		instance *Type)
}

OnAfterCreateInterface callback when an instance is updated from the front

type OnAfterDeleteInterface

type OnAfterDeleteInterface[Type Gongstruct] interface {
	OnAfterDelete(stage *StageStruct,
		staged, front *Type)
}

OnAfterDeleteInterface callback when an instance is updated from the front

type OnAfterReadInterface

type OnAfterReadInterface[Type Gongstruct] interface {
	OnAfterRead(stage *StageStruct,
		instance *Type)
}

OnAfterReadInterface callback when an instance is updated from the front

type OnAfterUpdateInterface

type OnAfterUpdateInterface[Type Gongstruct] interface {
	OnAfterUpdate(stage *StageStruct, old, new *Type)
}

OnAfterUpdateInterface callback when an instance is updated from the front

type OnInitCommitInterface

type OnInitCommitInterface interface {
	BeforeCommit(stage *StageStruct)
}

type PointerToGongstruct

type PointerToGongstruct interface {
	*ChartConfiguration | *DataPoint | *Dataset | *Label
	GetName() string
}

Gongstruct is the type parameter for generated generic function that allows - access to staged instances - navigation between staged instances by going backward association links between gongstruct - full refactoring of Gongstruct identifiers / fields

type StageStruct

type StageStruct struct {
	ChartConfigurations           map[*ChartConfiguration]any
	ChartConfigurations_mapString map[string]*ChartConfiguration

	OnAfterChartConfigurationCreateCallback OnAfterCreateInterface[ChartConfiguration]
	OnAfterChartConfigurationUpdateCallback OnAfterUpdateInterface[ChartConfiguration]
	OnAfterChartConfigurationDeleteCallback OnAfterDeleteInterface[ChartConfiguration]
	OnAfterChartConfigurationReadCallback   OnAfterReadInterface[ChartConfiguration]

	DataPoints           map[*DataPoint]any
	DataPoints_mapString map[string]*DataPoint

	OnAfterDataPointCreateCallback OnAfterCreateInterface[DataPoint]
	OnAfterDataPointUpdateCallback OnAfterUpdateInterface[DataPoint]
	OnAfterDataPointDeleteCallback OnAfterDeleteInterface[DataPoint]
	OnAfterDataPointReadCallback   OnAfterReadInterface[DataPoint]

	Datasets           map[*Dataset]any
	Datasets_mapString map[string]*Dataset

	OnAfterDatasetCreateCallback OnAfterCreateInterface[Dataset]
	OnAfterDatasetUpdateCallback OnAfterUpdateInterface[Dataset]
	OnAfterDatasetDeleteCallback OnAfterDeleteInterface[Dataset]
	OnAfterDatasetReadCallback   OnAfterReadInterface[Dataset]

	Labels           map[*Label]any
	Labels_mapString map[string]*Label

	OnAfterLabelCreateCallback OnAfterCreateInterface[Label]
	OnAfterLabelUpdateCallback OnAfterUpdateInterface[Label]
	OnAfterLabelDeleteCallback OnAfterDeleteInterface[Label]
	OnAfterLabelReadCallback   OnAfterReadInterface[Label]

	AllModelsStructCreateCallback AllModelsStructCreateInterface

	AllModelsStructDeleteCallback AllModelsStructDeleteInterface

	BackRepo BackRepoInterface

	// if set will be called before each commit to the back repo
	OnInitCommitCallback          OnInitCommitInterface
	OnInitCommitFromFrontCallback OnInitCommitInterface
	OnInitCommitFromBackCallback  OnInitCommitInterface

	// store the number of instance per gongstruct
	Map_GongStructName_InstancesNb map[string]int
}

StageStruct enables storage of staged instances swagger:ignore

var Stage StageStruct = StageStruct{
	ChartConfigurations:           make(map[*ChartConfiguration]any),
	ChartConfigurations_mapString: make(map[string]*ChartConfiguration),

	DataPoints:           make(map[*DataPoint]any),
	DataPoints_mapString: make(map[string]*DataPoint),

	Datasets:           make(map[*Dataset]any),
	Datasets_mapString: make(map[string]*Dataset),

	Labels:           make(map[*Label]any),
	Labels_mapString: make(map[string]*Label),

	Map_GongStructName_InstancesNb: make(map[string]int),
}

swagger:ignore instructs the gong compiler (gongc) to avoid this particular struct

func (*StageStruct) Backup

func (stage *StageStruct) Backup(dirPath string)

backup generates backup files in the dirPath

func (*StageStruct) BackupXL

func (stage *StageStruct) BackupXL(dirPath string)

backup generates backup files in the dirPath

func (*StageStruct) Checkout

func (stage *StageStruct) Checkout()

func (*StageStruct) Commit

func (stage *StageStruct) Commit()

func (*StageStruct) CreateReverseMap_ChartConfiguration_Datasets

func (stageStruct *StageStruct) CreateReverseMap_ChartConfiguration_Datasets() (res map[*Dataset]*ChartConfiguration)

generate function for reverse association maps of ChartConfiguration

func (*StageStruct) CreateReverseMap_ChartConfiguration_Labels

func (stageStruct *StageStruct) CreateReverseMap_ChartConfiguration_Labels() (res map[*Label]*ChartConfiguration)

func (*StageStruct) CreateReverseMap_Dataset_DataPoints

func (stageStruct *StageStruct) CreateReverseMap_Dataset_DataPoints() (res map[*DataPoint]*Dataset)

generate function for reverse association maps of Dataset

func (*StageStruct) Marshall

func (stage *StageStruct) Marshall(file *os.File, modelsPackageName, packageName string)

Marshall marshall the stage content into the file as an instanciation into a stage

func (*StageStruct) Nil

func (stage *StageStruct) Nil()

func (*StageStruct) Reset

func (stage *StageStruct) Reset()

func (*StageStruct) Restore

func (stage *StageStruct) Restore(dirPath string)

Restore resets Stage & BackRepo and restores their content from the restore files in dirPath

func (*StageStruct) RestoreXL

func (stage *StageStruct) RestoreXL(dirPath string)

Restore resets Stage & BackRepo and restores their content from the restore files in dirPath

type Tabulator

type Tabulator interface {
	AddSheet(sheetName string)
	AddRow(sheetName string) int
	AddCell(sheetName string, rowId, columnIndex int, value string)
}

Tabulator is an interface for writing to a table strings

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL