Documentation ¶
Index ¶
- Constants
- func Compile(where criteria.Expression) (whereClause string, parameters []interface{}, err []error)
- func TEMPConvertFieldTypesToModel(fields map[string]app.FieldDefinition) (map[string]FieldDefinition, error)
- func Transactional(db *gorm.DB, todo func(tx *gorm.DB) error) error
- type BadParameterError
- type ConversionError
- type EnumType
- type FieldDefinition
- func (f FieldDefinition) ConvertFromModel(name string, value interface{}) (interface{}, error)
- func (f FieldDefinition) ConvertToModel(name string, value interface{}) (interface{}, error)
- func (self FieldDefinition) Equal(u convert.Equaler) bool
- func (f *FieldDefinition) UnmarshalJSON(bytes []byte) error
- type FieldDefinitions
- type FieldType
- type Fields
- type GormWorkItemRepository
- func (r *GormWorkItemRepository) Create(ctx context.Context, typeID string, fields map[string]interface{}, ...) (*app.WorkItem, error)
- func (r *GormWorkItemRepository) Delete(ctx context.Context, ID string) error
- func (r *GormWorkItemRepository) List(ctx context.Context, criteria criteria.Expression, start *int, limit *int) ([]*app.WorkItem, uint64, error)
- func (r *GormWorkItemRepository) Load(ctx context.Context, ID string) (*app.WorkItem, error)
- func (r *GormWorkItemRepository) Save(ctx context.Context, wi app.WorkItem) (*app.WorkItem, error)
- type GormWorkItemTypeRepository
- func (r *GormWorkItemTypeRepository) Create(ctx context.Context, extendedTypeName *string, name string, ...) (*app.WorkItemType, error)
- func (r *GormWorkItemTypeRepository) List(ctx context.Context, start *int, limit *int) ([]*app.WorkItemType, error)
- func (r *GormWorkItemTypeRepository) Load(ctx context.Context, name string) (*app.WorkItemType, error)
- func (r *GormWorkItemTypeRepository) LoadTypeFromDB(ctx context.Context, name string) (*WorkItemType, error)
- type InternalError
- type Kind
- type ListType
- type NotFoundError
- type SimpleType
- type VersionConflictError
- type WorkItem
- type WorkItemType
Constants ¶
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)
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.
type EnumType ¶
type EnumType struct { SimpleType BaseType SimpleType Values []interface{} }
func (EnumType) ConvertFromModel ¶
func (EnumType) ConvertToModel ¶
type FieldDefinition ¶
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
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{}
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
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 ¶
func (r *GormWorkItemTypeRepository) Load(ctx context.Context, name string) (*app.WorkItemType, error)
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.
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 ¶
ConvertFromModel implements the FieldType interface
func (ListType) ConvertToModel ¶
ConvertToModel implements the FieldType interface
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
type VersionConflictError ¶
type VersionConflictError struct {
// contains filtered or unexported fields
}
VersionConflictError means that the version was not as expected in an update operation
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
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.