pbehavior

package
v0.0.0-...-d841f61 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExceptionNotExists = errors.New("exception doesn't exist")
View Source
var ErrReasonNotExists = errors.New("reason doesn't exist")

Functions

func GetNestedAuthorPipeline

func GetNestedAuthorPipeline() []bson.M

func GetNestedExdatesPipeline

func GetNestedExdatesPipeline() []bson.M

func GetNestedObjectsPipeline

func GetNestedObjectsPipeline() []bson.M

func GetNestedReasonPipeline

func GetNestedReasonPipeline() []bson.M

func GetNestedTypePipeline

func GetNestedTypePipeline() []bson.M

Types

type API

type API interface {
	common.CrudAPI
	ListByEntityID(c *gin.Context)
	GetEIDs(c *gin.Context)
	CountFilter(c *gin.Context)
}

func NewApi

func NewApi(
	transformer ModelTransformer,
	store Store,
	computeChan chan<- pbehavior.ComputeTask,
	conf config.UserInterfaceConfigProvider,
	actionLogger logger.ActionLogger,
	logger zerolog.Logger,
) API

type AggregationEIDsResult

type AggregationEIDsResult struct {
	Data       []EID `bson:"data" json:"data"`
	TotalCount int64 `bson:"total_count" json:"total_count"`
}

func (*AggregationEIDsResult) GetData

func (r *AggregationEIDsResult) GetData() interface{}

func (*AggregationEIDsResult) GetTotal

func (r *AggregationEIDsResult) GetTotal() int64

type AggregationResult

type AggregationResult struct {
	Data       []PBehavior `bson:"data" json:"data"`
	TotalCount int64       `bson:"total_count" json:"total_count"`
}

func (*AggregationResult) GetData

func (r *AggregationResult) GetData() interface{}

func (*AggregationResult) GetTotal

func (r *AggregationResult) GetTotal() int64

type CountFilterResult

type CountFilterResult struct {
	OverLimit  bool  `bson:"-" json:"over_limit"`
	TotalCount int64 `bson:"total_count" json:"total_count"`
}

func (*CountFilterResult) GetTotal

func (r *CountFilterResult) GetTotal() int64

type CreateRequest

type CreateRequest struct {
	EditRequest
	ID string `json:"_id" binding:"id"`
}

type EID

type EID struct {
	ID string `bson:"id" json:"id"`
}

type EIDsListRequest

type EIDsListRequest struct {
	pagination.FilteredQuery
	SortBy string `form:"sort_by" json:"sort_by" binding:"oneoforempty=id"`
}

type EditRequest

type EditRequest struct {
	Author     string                             `json:"author" swaggerignore:"true"`
	Enabled    *bool                              `json:"enabled" binding:"required"`
	Filter     interface{}                        `json:"filter" binding:"required"`
	Name       string                             `json:"name" binding:"required,max=255"`
	Reason     string                             `json:"reason" binding:"required"`
	RRule      string                             `json:"rrule"`
	Start      types.CpsTime                      `json:"tstart" binding:"required" swaggertype:"integer"`
	Stop       *types.CpsTime                     `json:"tstop" swaggertype:"integer"`
	Type       string                             `json:"type" binding:"required"`
	Exdates    []pbehaviorexception.ExdateRequest `json:"exdates" binding:"dive"`
	Exceptions []string                           `json:"exceptions"`
}

type Filter

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

func NewFilter

func NewFilter(v interface{}) Filter

func (Filter) MarshalJSON

func (f Filter) MarshalJSON() ([]byte, error)

func (*Filter) UnmarshalBSONValue

func (f *Filter) UnmarshalBSONValue(_ bsontype.Type, b []byte) error

type FilterRequest

type FilterRequest struct {
	Filter interface{} `json:"filter" binding:"required"`
}

type FindByEntityIDRequest

type FindByEntityIDRequest struct {
	ID string `form:"id" binding:"required"`
}

type ListRequest

type ListRequest struct {
	pagination.FilteredQuery
	SortBy string `` /* 144-byte string literal not displayed */
}

type ModelTransformer

type ModelTransformer interface {
	TransformCreateRequestToModel(request CreateRequest) (*PBehavior, error)
	TransformUpdateRequestToModel(request UpdateRequest) (*PBehavior, error)
}

func NewModelTransformer

func NewModelTransformer(
	dbClient mongo.DbClient,
	reasonTransformer apireason.ModelTransformer,
	exceptionTransformer pbehaviorexception.ModelTransformer,
) ModelTransformer

type MongoQuery

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

func CreateMongoQuery

func CreateMongoQuery(client mongo.DbClient) MongoQuery

func (*MongoQuery) CreateAggregationPipeline

func (q *MongoQuery) CreateAggregationPipeline(ctx context.Context, r ListRequest) ([]bson.M, error)

type PBehavior

type PBehavior struct {
	ID         string                         `bson:"_id" json:"_id"`
	Author     string                         `bson:"author" json:"author"`
	Comments   pbehavior.Comments             `bson:"comments" json:"comments"`
	Enabled    bool                           `bson:"enabled" json:"enabled"`
	Filter     Filter                         `bson:"filter" json:"filter"`
	Name       string                         `bson:"name" json:"name"`
	Reason     *pbehaviorreason.Reason        `bson:"reason" json:"reason"`
	RRule      string                         `bson:"rrule" json:"rrule"`
	Start      *types.CpsTime                 `bson:"tstart" json:"tstart" swaggertype:"integer"`
	Stop       *types.CpsTime                 `bson:"tstop" json:"tstop" swaggertype:"integer"`
	Created    *types.CpsTime                 `bson:"created" json:"created" swaggertype:"integer"`
	Updated    *types.CpsTime                 `bson:"updated" json:"updated" swaggertype:"integer"`
	Type       *pbehavior.Type                `bson:"type" json:"type"`
	Exdates    []pbehaviorexception.Exdate    `bson:"exdates" json:"exdates"`
	Exceptions []pbehaviorexception.Exception `bson:"exceptions" json:"exceptions"`
	// IsActiveStatus represents if pbehavior is in action for current time.
	IsActiveStatus *bool `bson:"-" json:"is_active_status,omitempty"`
}

type Store

type Store interface {
	Insert(ctx context.Context, model *PBehavior) error
	Find(ctx context.Context, r ListRequest) (*AggregationResult, error)
	FindByEntityID(ctx context.Context, entityID string) ([]PBehavior, error)
	GetOneBy(ctx context.Context, filter bson.M) (*PBehavior, error)
	GetEIDs(ctx context.Context, pbhID string, request EIDsListRequest) (AggregationEIDsResult, error)
	Update(ctx context.Context, model *PBehavior) (bool, error)
	Delete(ctx context.Context, id string) (bool, error)
	Count(context.Context, Filter, int) (*CountFilterResult, error)
}

func NewStore

func NewStore(
	dbClient mongo.DbClient,
	entityMatcher pbehavior.EntityMatcher,
	redisStore redis.Store,
	service pbehavior.Service,
	timezoneConfigProvider config.TimezoneConfigProvider,
) Store

type UpdateRequest

type UpdateRequest struct {
	EditRequest
	ID string `json:"-"`
}

type Validator

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

func NewValidator

func NewValidator(client mongo.DbClient) *Validator

func (*Validator) ValidateEditRequest

func (v *Validator) ValidateEditRequest(ctx context.Context, sl validator.StructLevel)

Jump to

Keyboard shortcuts

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