Documentation ¶
Index ¶
- func Init()
- func InitUnitTest()
- func ReplaceGlobals(repository Repository) func()
- type Base
- type Calendar
- type Graph
- type InPeriodContains
- type Node
- type Period
- type PeriodStatus
- type PostgresRepository
- func (r *PostgresRepository) Create(calendar Calendar) (int64, error)
- func (r *PostgresRepository) Delete(id int64) error
- func (r *PostgresRepository) Get(id int64) (Calendar, bool, error)
- func (r *PostgresRepository) GetAll() (map[int64]Calendar, error)
- func (r *PostgresRepository) GetAllModifiedFrom(from time.Time) (map[int64]Calendar, error)
- func (r *PostgresRepository) Update(calendar Calendar) error
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitUnitTest ¶
func InitUnitTest()
InitUnitTest initialize the global calendar base singleton in unite test mode
func ReplaceGlobals ¶
func ReplaceGlobals(repository Repository) func()
ReplaceGlobals affect a new repository to the global repository singleton
Types ¶
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base ..
func (*Base) GetResolved ¶
GetResolved get calendar resolved from global CBase
func (*Base) InPeriodFromCalendarID ¶
InPeriodFromCalendarID ..
type Calendar ¶
type Calendar struct { ID int64 `json:"id,omitempty"` Name string `json:"name"` Description string `json:"description"` Periods []Period `json:"periods"` UnionCalendarIDs []int64 `json:"unionCalendarIDs,omitempty"` Enabled bool `json:"enabled"` }
Calendar ..
func (Calendar) ResolveCalendar ¶
ResolveCalendar resolve a calendar definition dynamically and recursively with its subcalendars Resolution order : - For each sub-calendar (with respect of order)
- Sub-calendar Periods (with respect of order)
- Calendar Periods (with respect of order)
type InPeriodContains ¶
type InPeriodContains struct {
Contains bool `json:"contains"`
}
InPeriodContains ..
type Period ¶
type Period struct { Included bool `json:"included"` DateTimeIntervals *dateTimeInterval `json:"dateTimeIntervals,omitempty"` MonthsOfYear *monthInterval `json:"monthsOfYear,omitempty"` DaysOfMonth *dayInterval `json:"daysOfMonth,omitempty"` DaysOfWeek *dayWeekInterval `json:"daysOfWeek,omitempty"` HoursOfDay *hoursInterval `json:"hoursOfDay,omitempty"` }
Period of the calendars
type PeriodStatus ¶
type PeriodStatus int
PeriodStatus indicate if the status of a date in a period
const ( // InPeriod period status InPeriod PeriodStatus = iota + 1 // OutOfPeriod period status OutOfPeriod // NoInfo period status NoInfo )
func ToPeriodStatus ¶
func ToPeriodStatus(s string) PeriodStatus
ToPeriodStatus get the PeriodStatus from is string representation
func (PeriodStatus) MarshalJSON ¶
func (s PeriodStatus) MarshalJSON() ([]byte, error)
MarshalJSON marshals the enum as a quoted json string
func (PeriodStatus) String ¶
func (s PeriodStatus) String() string
func (*PeriodStatus) UnmarshalJSON ¶
func (s *PeriodStatus) UnmarshalJSON(b []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type PostgresRepository ¶
type PostgresRepository struct {
// contains filtered or unexported fields
}
PostgresRepository is a repository containing the user groups data based on a PSQL database and implementing the repository interface
func (*PostgresRepository) Create ¶
func (r *PostgresRepository) Create(calendar Calendar) (int64, error)
Create method used to create a Calendar
func (*PostgresRepository) Delete ¶
func (r *PostgresRepository) Delete(id int64) error
Delete method used to delete a Calendar
func (*PostgresRepository) Get ¶
func (r *PostgresRepository) Get(id int64) (Calendar, bool, error)
Get search and returns a Calendar from the repository by its id
func (*PostgresRepository) GetAll ¶
func (r *PostgresRepository) GetAll() (map[int64]Calendar, error)
GetAll method used to get all Calendars
func (*PostgresRepository) GetAllModifiedFrom ¶
GetAllModifiedFrom returns all entities that have been modified since 'from' parameter
func (*PostgresRepository) Update ¶
func (r *PostgresRepository) Update(calendar Calendar) error
Update method used to update a Calendar
type Repository ¶
type Repository interface { Get(id int64) (Calendar, bool, error) Create(calendar Calendar) (int64, error) Update(calendar Calendar) error Delete(id int64) error GetAll() (map[int64]Calendar, error) GetAllModifiedFrom(from time.Time) (map[int64]Calendar, error) }
Repository is a storage interface which can be implemented by multiple backend (in-memory map, sql database, in-memory cache, file system, ...) It allows standard CRUD operation on calendars
func NewPostgresRepository ¶
func NewPostgresRepository(dbClient *sqlx.DB) Repository
NewPostgresRepository returns a new instance of PostgresRepository