models

package
v0.0.0-...-adf365b Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2016 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SystemRemoteItemID = "system.remote_item_id"
	SystemTitle        = "system.title"
	SystemDescription  = "system.description"
	SystemState        = "system.state"
	SystemAssignee     = "system.assignee"
	SystemCreator      = "system.creator"

	// base item type with common fields for planner item types like userstory, experience, bug, feature, etc.
	SystemPlannerItem = "system.planneritem"

	SystemUserStory        = "system.userstory"
	SystemValueProposition = "system.valueproposition"
	SystemFundamental      = "system.fundamental"
	SystemExperience       = "system.experience"
	SystemFeature          = "system.feature"
	SystemBug              = "system.bug"

	SystemStateOpen       = "open"
	SystemStateNew        = "new"
	SystemStateInProgress = "in progress"
	SystemStateResolved   = "resolved"
	SystemStateClosed     = "closed"
)

String constants for the local work item types.

Variables

This section is empty.

Functions

func Compile

func Compile(where criteria.Expression) (whereClause string, parameters []interface{}, err []error)

Compile takes an expression and compiles it to a where clause for use with gorm.DB.Where() Returns the number of expected parameters for the query and a slice of errors if something goes wrong

func TEMPConvertFieldTypesToModel

func TEMPConvertFieldTypesToModel(fields map[string]app.FieldDefinition) (map[string]FieldDefinition, error)

func Transactional

func Transactional(db *gorm.DB, todo func(tx *gorm.DB) error) error

Transactional executes the given function in a transaction. If todo returns an error, the transaction is rolled back

Types

type BadParameterError

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

BadParameterError means that a parameter was not as required

func NewBadParameterError

func NewBadParameterError(param string, actual interface{}) BadParameterError

NewBadParameterError returns the custom defined error of type NewBadParameterError.

func (BadParameterError) Error

func (err BadParameterError) Error() string

Error implements the error interface

func (BadParameterError) Expected

func (err BadParameterError) Expected(expexcted interface{}) BadParameterError

Expected sets the optional expectedValue parameter on the BadParameterError

type ConversionError

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

ConversionError error means something went wrong converting between different representations

func NewConversionError

func NewConversionError(msg string) ConversionError

NewConversionError returns the custom defined error of type NewConversionError.

func (ConversionError) Error

func (err ConversionError) Error() string

type EnumType

type EnumType struct {
	SimpleType
	BaseType SimpleType
	Values   []interface{}
}

func (EnumType) ConvertFromModel

func (fieldType EnumType) ConvertFromModel(value interface{}) (interface{}, error)

func (EnumType) ConvertToModel

func (fieldType EnumType) ConvertToModel(value interface{}) (interface{}, error)

func (EnumType) Equal

func (self EnumType) Equal(u convert.Equaler) bool

Equal returns true if two EnumType objects are equal; otherwise false is returned.

type FieldDefinition

type FieldDefinition struct {
	Required bool
	Type     FieldType
}

FieldDefintion describes type & other restrictions of a field

func (FieldDefinition) ConvertFromModel

func (f FieldDefinition) ConvertFromModel(name string, value interface{}) (interface{}, error)

ConvertFromModel converts from json storage to API form.

func (FieldDefinition) ConvertToModel

func (f FieldDefinition) ConvertToModel(name string, value interface{}) (interface{}, error)

ConvertToModel converts a field value for storage as json. As the system matures, add more checks (for example whether a user is in the system, etc.)

func (FieldDefinition) Equal

func (self FieldDefinition) Equal(u convert.Equaler) bool

Equal returns true if two FieldDefinition objects are equal; otherwise false is returned.

func (*FieldDefinition) UnmarshalJSON

func (f *FieldDefinition) UnmarshalJSON(bytes []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler

type FieldDefinitions

type FieldDefinitions map[string]FieldDefinition

func (*FieldDefinitions) Scan

func (j *FieldDefinitions) Scan(src interface{}) error

func (FieldDefinitions) Value

func (j FieldDefinitions) Value() (driver.Value, error)

type FieldType

type FieldType interface {
	GetKind() Kind
	// ConvertToModel converts a field value for use in the REST API
	ConvertToModel(value interface{}) (interface{}, error)
	// ConvertToModel converts a field value for storage in the db
	ConvertFromModel(value interface{}) (interface{}, error)
	// Implement the Equaler interface
	Equal(u convert.Equaler) bool
}

FieldType describes the possible values of a FieldDefinition

type Fields

type Fields map[string]interface{}

func (Fields) Equal

func (self Fields) Equal(u convert.Equaler) bool

Equal returns true if two Fields objects are equal; otherwise false is returned. TODO: (kwk) think about a better comparison for Fields map.

func (*Fields) Scan

func (j *Fields) Scan(src interface{}) error

func (Fields) Value

func (j Fields) Value() (driver.Value, error)

type GormWorkItemRepository

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

GormWorkItemRepository implements WorkItemRepository using gorm

func NewWorkItemRepository

func NewWorkItemRepository(db *gorm.DB) *GormWorkItemRepository

NewWorkItemRepository creates a wi repository based on gorm

func (*GormWorkItemRepository) Create

func (r *GormWorkItemRepository) Create(ctx context.Context, typeID string, fields map[string]interface{}, creator string) (*app.WorkItem, error)

Create creates a new work item in the repository returns BadParameterError, ConversionError or InternalError

func (*GormWorkItemRepository) Delete

func (r *GormWorkItemRepository) Delete(ctx context.Context, ID string) error

Delete deletes the work item with the given id returns NotFoundError or InternalError

func (*GormWorkItemRepository) List

func (r *GormWorkItemRepository) List(ctx context.Context, criteria criteria.Expression, start *int, limit *int) ([]*app.WorkItem, uint64, error)

List returns work item selected by the given criteria.Expression, starting with start (zero-based) and returning at most limit items

func (*GormWorkItemRepository) Load

Load returns the work item for the given id returns NotFoundError, ConversionError or InternalError

func (*GormWorkItemRepository) Save

Save updates the given work item in storage. Version must be the same as the one int the stored version returns NotFoundError, VersionConflictError, ConversionError or InternalError

type GormWorkItemTypeRepository

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

GormWorkItemTypeRepository implements WorkItemTypeRepository using gorm

func NewWorkItemTypeRepository

func NewWorkItemTypeRepository(db *gorm.DB) *GormWorkItemTypeRepository

NewWorkItemTypeRepository creates a wi type repository based on gorm

func (*GormWorkItemTypeRepository) Create

func (r *GormWorkItemTypeRepository) Create(ctx context.Context, extendedTypeName *string, name string, fields map[string]app.FieldDefinition) (*app.WorkItemType, error)

Create creates a new work item in the repository returns BadParameterError, ConversionError or InternalError

func (*GormWorkItemTypeRepository) List

func (r *GormWorkItemTypeRepository) List(ctx context.Context, start *int, limit *int) ([]*app.WorkItemType, error)

List returns work item types selected by the given criteria.Expression, starting with start (zero-based) and returning at most "limit" item types

func (*GormWorkItemTypeRepository) Load

Load returns the work item for the given id returns NotFoundError, InternalError

func (*GormWorkItemTypeRepository) LoadTypeFromDB

func (r *GormWorkItemTypeRepository) LoadTypeFromDB(ctx context.Context, name string) (*WorkItemType, error)

LoadTypeFromDB return work item type for the given id

type InternalError

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

InternalError means that the operation failed for some internal, unexpected reason

func NewInternalError

func NewInternalError(msg string) InternalError

NewInternalError returns the custom defined error of type NewInternalError.

func (InternalError) Error

func (err InternalError) Error() string

type Kind

type Kind string

Kind is the kind of field type

const (
	KindString            Kind = "string"
	KindInteger           Kind = "integer"
	KindFloat             Kind = "float"
	KindInstant           Kind = "instant"
	KindDuration          Kind = "duration"
	KindURL               Kind = "url"
	KindWorkitemReference Kind = "workitem"
	KindUser              Kind = "user"
	KindEnum              Kind = "enum"
	KindList              Kind = "list"
)

constants for describing possible field types

type ListType

type ListType struct {
	SimpleType
	ComponentType SimpleType
}

ListType describes a list of SimpleType values

func (ListType) ConvertFromModel

func (fieldType ListType) ConvertFromModel(value interface{}) (interface{}, error)

ConvertFromModel implements the FieldType interface

func (ListType) ConvertToModel

func (fieldType ListType) ConvertToModel(value interface{}) (interface{}, error)

ConvertToModel implements the FieldType interface

func (ListType) Equal

func (self ListType) Equal(u convert.Equaler) bool

Equal returns true if two ListType objects are equal; otherwise false is returned.

type NotFoundError

type NotFoundError struct {
	ID string
	// contains filtered or unexported fields
}

NotFoundError means the object specified for the operation does not exist

func NewNotFoundError

func NewNotFoundError(entity string, id string) NotFoundError

NewNotFoundError returns the custom defined error of type NewNotFoundError.

func (NotFoundError) Error

func (err NotFoundError) Error() string

type SimpleType

type SimpleType struct {
	Kind Kind
}

SimpleType is an unstructured FieldType

func (SimpleType) ConvertFromModel

func (fieldType SimpleType) ConvertFromModel(value interface{}) (interface{}, error)

ConvertFromModel implements the FieldType interface

func (SimpleType) ConvertToModel

func (fieldType SimpleType) ConvertToModel(value interface{}) (interface{}, error)

ConvertToModel implements the FieldType interface

func (SimpleType) Equal

func (self SimpleType) Equal(u convert.Equaler) bool

Equal returns true if two SimpleType objects are equal; otherwise false is returned.

func (SimpleType) GetKind

func (self SimpleType) GetKind() Kind

GetKind implements FieldType

type VersionConflictError

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

VersionConflictError means that the version was not as expected in an update operation

func (VersionConflictError) Error

func (err VersionConflictError) Error() string

type WorkItem

type WorkItem struct {
	gormsupport.Lifecycle
	ID uint64 `gorm:"primary_key"`
	// Id of the type of this work item
	Type string
	// Version for optimistic concurrency control
	Version int
	// the field values
	Fields Fields `sql:"type:jsonb"`
}

WorkItem represents a work item as it is stored in the database

func (WorkItem) Equal

func (wi WorkItem) Equal(u convert.Equaler) bool

Equal returns true if two WorkItem objects are equal; otherwise false is returned.

type WorkItemType

type WorkItemType struct {
	gormsupport.Lifecycle
	// the unique name of this work item type.
	Name string `gorm:"primary_key"`
	// Version for optimistic concurrency control
	Version int
	// the id's of the parents, separated with some separator
	ParentPath string
	// definitions of the fields this work item type supports
	Fields FieldDefinitions `sql:"type:jsonb"`
}

WorkItemType represents a work item type as it is stored in the db

func (WorkItemType) ConvertFromModel

func (wiType WorkItemType) ConvertFromModel(workItem WorkItem) (*app.WorkItem, error)

ConvertFromModel serializes a database persisted workitem.

func (WorkItemType) Equal

func (wit WorkItemType) Equal(u convert.Equaler) bool

Equal returns true if two WorkItemType objects are equal; otherwise false is returned.

Jump to

Keyboard shortcuts

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