fabric8-wit: github.com/fabric8-services/fabric8-wit/workitem Index | Files | Directories

package workitem

import "github.com/fabric8-services/fabric8-wit/workitem"

Package workitem contains the code that allows to manage work items, work item types.

Index

Package Files

board.go board_repository.go doc.go enum_type.go expression_compiler.go field_definition.go field_test_data.go json_storage.go list_type.go simple_type.go table_join.go typegroup.go typegroup_repository.go workitem.go workitem_repository.go workitem_revision.go workitem_revision_repository.go workitem_storage.go workitemtype.go workitemtype_cache.go workitemtype_repository.go

Constants

const (
    SystemVersion = "version"

    SystemRemoteItemID        = "system.remote_item_id"
    SystemNumber              = "system.number"
    SystemTitle               = "system.title"
    SystemDescription         = "system.description"
    SystemDescriptionMarkup   = "system.description.markup"
    SystemDescriptionRendered = "system.description.rendered"
    SystemState               = "system.state"
    SystemAssignees           = "system.assignees"
    SystemCreator             = "system.creator"
    SystemCreatedAt           = "system.created_at"
    SystemUpdatedAt           = "system.updated_at"
    SystemOrder               = "system.order"
    SystemIteration           = "system.iteration"
    SystemArea                = "system.area"
    SystemCodebase            = "system.codebase"
    SystemLabels              = "system.labels"
    SystemBoardcolumns        = "system.boardcolumns"
    SystemMetaState           = "system.metastate"

    SystemBoard = "Board"

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

String constants for the local work item types.

Variables

var (
    SortWorkItemsByExecutionAsc  = SortWorkItemsBy("execution_order ASC")
    SortWorkItemsByExecutionDesc = SortWorkItemsBy("execution_order DESC")
    SortWorkItemsByCreatedAtAsc  = SortWorkItemsBy("created_at ASC")
    SortWorkItemsByCreatedAtDesc = SortWorkItemsBy("created_at DESC")
    SortWorkItemsByUpdatedAtAsc  = SortWorkItemsBy("updated_at ASC")
    SortWorkItemsByUpdatedAtDesc = SortWorkItemsBy("updated_at DESC")
    SortWorkItemsByDefault       = SortWorkItemsByExecutionDesc
)

Available sort orders

var (
    // base item type with common fields for planner item types like userstory,
    // experience, bug, feature, etc.
    SystemPlannerItem      = uuid.FromStringOrNil("86af5178-9b41-469b-9096-57e5155c3f31") // "planneritem"
    SystemTask             = uuid.FromStringOrNil("bbf35418-04b6-426c-a60b-7f80beb0b624") // "task"
    SystemValueProposition = uuid.FromStringOrNil("3194ab60-855b-4155-9005-9dce4a05f1eb") // "valueproposition"
    SystemFundamental      = uuid.FromStringOrNil("ee7ca005-f81d-4eea-9b9b-1965df0988d0") // "fundamental"
    SystemExperience       = uuid.FromStringOrNil("b9a71831-c803-4f66-8774-4193fffd1311") // "experience"
    SystemFeature          = uuid.FromStringOrNil("0a24d3c2-e0a6-4686-8051-ec0ea1915a28") // "feature"
    SystemScenario         = uuid.FromStringOrNil("71171e90-6d35-498f-a6a7-2083b5267c18") // "scenario"
    SystemBug              = uuid.FromStringOrNil("26787039-b68f-4e28-8814-c2f93be1ef4e") // "bug"
    SystemPapercuts        = uuid.FromStringOrNil("6d603ab4-7c5e-4c5f-bba8-a3ba9d370985") // "papercuts"
)

Never ever change these UUIDs!!!

var DefaultTableJoins = func() TableJoinMap {
    res := TableJoinMap{
        "iteration": {
            TableName:        "iterations",
            TableAlias:       "iter",
            On:               JoinOnJSONField(SystemIteration, "iter.id") + " AND " + Column("iter", "space_id") + "=" + Column(WorkItemStorage{}.TableName(), "space_id"),
            PrefixActivators: []string{"iteration."},
            AllowedColumns:   []string{"name", "created_at", "number"},
        },
        "area": {
            TableName:        "areas",
            TableAlias:       "ar",
            On:               JoinOnJSONField(SystemArea, "ar.id") + " AND " + Column("ar", "space_id") + "=" + Column(WorkItemStorage{}.TableName(), "space_id"),
            PrefixActivators: []string{"area."},
            AllowedColumns:   []string{"name", "number"},
        },
        "codebase": {
            TableName:        "codebases",
            TableAlias:       "cb",
            On:               JoinOnJSONField(SystemCodebase, "cb.id") + " AND " + Column("cb", "space_id") + "=" + Column(WorkItemStorage{}.TableName(), "space_id"),
            PrefixActivators: []string{"codebase."},
            AllowedColumns:   []string{"url"},
        },
        "work_item_type": {
            TableName:        "work_item_types",
            TableAlias:       "wit",
            On:               "wit.id = " + WorkItemStorage{}.TableName() + ".type",
            PrefixActivators: []string{"wit.", "workitemtype.", "work_item_type.", "type."},
            AllowedColumns:   []string{"name"},
        },
        "creator": {
            TableName:        "users",
            TableAlias:       "creator",
            On:               JoinOnJSONField(SystemCreator, "creator.id"),
            PrefixActivators: []string{"creator.", "author."},
            AllowedColumns:   []string{"full_name"},
        },
        "space": {
            TableName:        "spaces",
            TableAlias:       "space",
            On:               Column("space", "id") + "=" + Column(WorkItemStorage{}.TableName(), "space_id"),
            PrefixActivators: []string{"space."},
            AllowedColumns:   []string{"name"},
        },
        "boardcolumns": {
            TableName:  `(SELECT id colid, board_id id, jsonb_agg(id::text) AS colids FROM ` + BoardColumn{}.TableName() + ` GROUP BY 1,2)`,
            TableAlias: "boardcolumns",
            On: fmt.Sprintf(Column("boardcolumns", "colid")+`::text IN (
				SELECT jsonb_array_elements_text(jsonb_strip_nulls(`+Column(WorkItemStorage{}.TableName(), "fields")+`)->'%s')
			)`, SystemBoardcolumns),
            PrefixActivators: []string{"board."},
            AllowedColumns:   []string{"id"},
        },
        "typegroup": {
            TableName:  "work_item_type_groups",
            TableAlias: "witg",
            On:         fmt.Sprintf(`%s=%s`, Column("witg", "space_template_id"), Column("space", "space_template_id")),

            Where: fmt.Sprintf(`%s=%s AND %s=%s`,
                Column("witg_members", "type_group_id"), Column("witg", "id"),
                Column(WorkItemStorage{}.TableName(), "type"), Column("witg_members", "work_item_type_id"),
            ),

            AllowedColumns:     []string{"name"},
            ActivateOtherJoins: []string{"space"},
        },
        "label": {
            TableName:  "labels",
            TableAlias: "lbl",
            On: Column("lbl", "space_id") + "=" + Column(WorkItemStorage{}.TableName(), "space_id") + `
		                    AND lbl.id::text IN (
		                        SELECT
						jsonb_array_elements_text(` + Column(WorkItemStorage{}.TableName(), "fields") + `->'system.labels')
					FROM labels)`,
            PrefixActivators: []string{"label."},
            AllowedColumns:   []string{"name"},
        },
    }

    res["typegroup_members"] = &TableJoin{
        TableName:          "work_item_type_group_members",
        TableAlias:         "witg_members",
        On:                 Column("witg_members", "type_group_id") + "=" + Column("witg", "id"),
        PrefixActivators:   []string{"typegroup_members.", "typegroup."},
        AllowedColumns:     []string{"work_item_type_id"},
        ActivateOtherJoins: []string{"typegroup"},

        DelegateTo: map[string]*TableJoin{
            "typegroup.": res["typegroup"],
        },
    }

    res["parent_link"] = &TableJoin{
        TableName:  "work_item_links",
        TableAlias: "parent_link",

        On: Column("parent_link", "link_type_id") + "= '25C326A7-6D03-4F5A-B23B-86A9EE4171E9' AND " + Column("parent_link", "target_id") + "=" + Column(WorkItemStorage{}.TableName(), "id"),
    }
    res["parent"] = &TableJoin{
        TableName:          WorkItemStorage{}.TableName(),
        TableAlias:         "parent",
        On:                 Column("parent_link", "source_id") + "=" + Column("parent", "id"),
        AllowedColumns:     []string{"id", "number"},
        PrefixActivators:   []string{"parent."},
        ActivateOtherJoins: []string{"parent_link"},
    }

    return res
}

DefaultTableJoins returns the default list of joinable tables used when creating a new expression compiler.

func ClearGlobalWorkItemTypeCache Uses

func ClearGlobalWorkItemTypeCache()

ClearGlobalWorkItemTypeCache removes all work items from the global cache

func Column Uses

func Column(table, column string) string

Column returns a proper column name from the given column name in the given table.

func ConvertList Uses

func ConvertList(converter Converter, componentType SimpleType, value interface{}) ([]interface{}, error)

func GetTypePathSeparator Uses

func GetTypePathSeparator() string

GetTypePathSeparator returns the work item type's path separator "."

func JoinOnJSONField Uses

func JoinOnJSONField(jsonField, foreignCol string) string

JoinOnJSONField returns the ON part of an SQL JOIN for the given fields

func LtreeSafeID Uses

func LtreeSafeID(witID uuid.UUID) string

LtreeSafeID returns the ID of the work item type in an postgres ltree safe manner The returned string can be used as an ltree node.

func ParseWorkItemIDToUint64 Uses

func ParseWorkItemIDToUint64(wiIDStr string) (uint64, error)

ParseWorkItemIDToUint64 does what it says

type Board Uses

type Board struct {
    gormsupport.Lifecycle `json:"lifecycle"`
    ID                    uuid.UUID     `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key" json:"id"`
    SpaceTemplateID       uuid.UUID     `sql:"type:uuid" json:"space_template_id"`
    Name                  string        `json:"name"`
    Description           string        `json:"description"`
    Columns               []BoardColumn `gorm:"-" json:"columns,omitempty"`
    Context               string        `json:"context"`
    ContextType           string        `json:"context_type"`
}

Board represents the board configuration.

func (Board) Equal Uses

func (wib Board) Equal(u convert.Equaler) bool

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

func (Board) EqualValue Uses

func (wib Board) EqualValue(u convert.Equaler) bool

EqualValue implements convert.Equaler

func (Board) GetETagData Uses

func (wib Board) GetETagData() []interface{}

GetETagData returns the field values to use to generate the ETag

func (Board) GetLastModified Uses

func (wib Board) GetLastModified() time.Time

GetLastModified returns the last modification time

func (Board) TableName Uses

func (wib Board) TableName() string

TableName implements gorm.tabler

type BoardColumn Uses

type BoardColumn struct {
    gormsupport.Lifecycle `json:"lifecycle"`
    ID                    uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key" json:"id"`
    BoardID               uuid.UUID `sql:"type:uuid" json:"board_id"`
    Name                  string    `json:"name"`
    Order                 int       `json:"order" gorm:"column:column_order"`
    TransRuleKey          string    `json:"trans_rule_key"`
    TransRuleArgument     string    `json:"trans_rule_argument"` // TODO: this is a JSON, not a string
}

BoardColumn represents a column in a board.

func (BoardColumn) Equal Uses

func (wibc BoardColumn) Equal(u convert.Equaler) bool

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

func (BoardColumn) EqualValue Uses

func (wibc BoardColumn) EqualValue(u convert.Equaler) bool

EqualValue implements convert.Equaler interface

func (BoardColumn) TableName Uses

func (wibc BoardColumn) TableName() string

TableName implements gorm.tabler

type BoardRepository Uses

type BoardRepository interface {
    repository.Exister
    Create(ctx context.Context, board Board) (*Board, error)
    Load(ctx context.Context, groupID uuid.UUID) (*Board, error)
    List(ctx context.Context, spaceTemplateID uuid.UUID) ([]*Board, error)
}

BoardRepository encapsulates storage & retrieval of work item boards.

type ChildType Uses

type ChildType struct {
    gormsupport.Lifecycle
    ID                   uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"`
    ParentWorkItemTypeID uuid.UUID `sql:"type:uuid"`
    ChildWorkItemTypeID  uuid.UUID `sql:"type:uuid"`
    Position             int       // position in type list of child types
}

ChildType models the relationship from one parent work item type to its child types.

func (ChildType) TableName Uses

func (wit ChildType) TableName() string

TableName implements gorm.tabler

type Converter Uses

type Converter func(FieldType, interface{}) (interface{}, error)

type DirectionType Uses

type DirectionType string

DirectionType represents execution order direction

const (
    DirectionAbove  DirectionType = "above"
    DirectionBelow  DirectionType = "below"
    DirectionTop    DirectionType = "top"
    DirectionBottom DirectionType = "bottom"
)

Possible values for execution order direction

type EnumType Uses

type EnumType struct {
    SimpleType       `json:"simple_type"`
    BaseType         SimpleType    `json:"base_type"`
    Values           []interface{} `json:"values"`
    RewritableValues bool          `json:"rewritable_values"`
    DefaultValue     interface{}   `json:"default_value,omitempty"`
}

The EnumType defines the members that make up an enum field type definition. The SimpleType is set to KindEnum and the BaseType is set to whatever type of enum you want to have (e.g. an enum of strings or integers). The Values array specifies what the allowed values in this enum are. If RewritableValues is set to true, this type can be overwritten by a work item type that also defines a field of the same name with the same type, except with different allowed values inside. A classic example for this is the state field that can be overwritten by every work item type to fit its needs.

func (EnumType) ConvertFromModel Uses

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

ConvertFromModel implements the FieldType interface

func (EnumType) ConvertToModel Uses

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

func (EnumType) Equal Uses

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

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

func (EnumType) EqualEnclosing Uses

func (t EnumType) EqualEnclosing(other EnumType) bool

EqualEnclosing returns true if two EnumType objects are equal and/or the values set is enclosing (larger and containing) the other values set.

func (EnumType) EqualValue Uses

func (t EnumType) EqualValue(u convert.Equaler) bool

EqualValue implements convert.Equaler

func (EnumType) GetDefaultValue Uses

func (t EnumType) GetDefaultValue() interface{}

GetDefaultValue implements FieldType

func (EnumType) SetDefaultValue Uses

func (t EnumType) SetDefaultValue(v interface{}) (FieldType, error)

SetDefaultValue implements FieldType

func (EnumType) Validate Uses

func (t EnumType) Validate() error

Validate checks that the type of the enum is "enum", that the base type itself a simple type (e.g. not a list or an enum), that the default value matches the Kind of the BaseType, that the default value is in the list of allowed values and that the Values are all of the base type.

type FieldDefinition Uses

type FieldDefinition struct {
    Required    bool      `json:"required"`
    ReadOnly    bool      `json:"read_only"`
    Label       string    `json:"label"`
    Description string    `json:"description"`
    Type        FieldType `json:"type"`
}

FieldDefinition describes type & other restrictions of a field

func (FieldDefinition) ConvertFromModel Uses

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

ConvertFromModel converts a field value for use in the REST API layer

func (FieldDefinition) ConvertToModel Uses

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

ConvertToModel converts a field value for use in the persistence layer

func (FieldDefinition) Equal Uses

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

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

func (FieldDefinition) EqualValue Uses

func (f FieldDefinition) EqualValue(u convert.Equaler) bool

EqualValue implements the convert.Equaler interface

func (*FieldDefinition) UnmarshalJSON Uses

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

UnmarshalJSON implements encoding/json.Unmarshaler

func (FieldDefinition) Validate Uses

func (f FieldDefinition) Validate() error

Validate checks that a field has a proper setup

type FieldDefinitions Uses

type FieldDefinitions map[string]FieldDefinition

FieldDefinitions define a map of field names pointing to their field definition.

func (*FieldDefinitions) Scan Uses

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

Scan implements the https://golang.org/pkg/database/sql/#Scanner interface See also https://stackoverflow.com/a/25374979/835098 See also https://github.com/jinzhu/gorm/issues/302#issuecomment-80566841

func (*FieldDefinitions) Validate Uses

func (j *FieldDefinitions) Validate() error

Validate checks that each field definition is valid

func (FieldDefinitions) Value Uses

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

Value implements the https://golang.org/pkg/database/sql/driver/#Valuer interface

type FieldType Uses

type FieldType interface {
    GetKind() Kind
    // ConvertToModel converts a field value for use in the persistence layer
    ConvertToModel(value interface{}) (interface{}, error)
    // ConvertFromModel converts a field value for use in the REST API layer
    ConvertFromModel(value interface{}) (interface{}, error)
    // Equal implements the convert.Equaler interface
    Equal(u convert.Equaler) bool
    // EqualValue implements the convert.Equaler interface
    EqualValue(u convert.Equaler) bool
    // GetDefaultValue is called if a field's value is nil.
    GetDefaultValue() interface{}
    // SetDefaultValue returns a copy of the FieldType object at hand if there
    // was no error setting the default value of that field type.
    SetDefaultValue(v interface{}) (FieldType, error)
    // Validate checks that the type definition of a field is correct. Take a
    // look at the implementation of this function to find out what's actually
    // been checked for each individual type.
    Validate() error
    // ConvertToModelWithType tries to find way to convert the value v from this
    // FieldType to the other FieldType in model representation; returns error
    // otherwise.
    //
    // For example if the given value v is a string and the other FieldType is a
    // string list, we will return the value v as an array of interfaces.
    //
    // Let's say the current FieldType is a string list and the other FieldType
    // is a string field, then we check if the value v has only one element and
    // return that instead of the whole list.
    ConvertToModelWithType(other FieldType, v interface{}) (interface{}, error)
}

FieldType describes the possible values of a FieldDefinition

type FieldTypeTestDataMap Uses

type FieldTypeTestDataMap map[Kind]ValidInvalid

FieldTypeTestDataMap defines a map with additional functionality on it.

func GetFieldTypeTestData Uses

func GetFieldTypeTestData(t *testing.T) FieldTypeTestDataMap

GetFieldTypeTestData returns a list of legal and illegal values to be used with a given field type (here: the map key).

func (FieldTypeTestDataMap) GetKinds Uses

func (s FieldTypeTestDataMap) GetKinds() []Kind

GetKinds returns the keys of the test data map in sorted order.

type Fields Uses

type Fields map[string]interface{}

Fields is a helper map that later gets replaced with the FieldDefinitions type and only exists for parsing in content from JSON.

func (Fields) Equal Uses

func (f 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) EqualValue Uses

func (f Fields) EqualValue(u convert.Equaler) bool

EqualValue implements the convert.Equaler interface

func (*Fields) Scan Uses

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

Scan implements the https://golang.org/pkg/database/sql/#Scanner interface See also https://stackoverflow.com/a/25374979/835098 See also https://github.com/jinzhu/gorm/issues/302#issuecomment-80566841

func (Fields) Value Uses

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

Value implements the driver.Valuer interface

type GormBoardRepository Uses

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

GormBoardRepository implements BoardRepository using gorm.

func NewBoardRepository Uses

func NewBoardRepository(db *gorm.DB) *GormBoardRepository

NewBoardRepository creates a wi type group repository based on gorm.

func (*GormBoardRepository) CheckExists Uses

func (r *GormBoardRepository) CheckExists(ctx context.Context, id uuid.UUID) error

CheckExists returns nil if the given ID exists otherwise returns an error

func (*GormBoardRepository) Create Uses

func (r *GormBoardRepository) Create(ctx context.Context, b Board) (*Board, error)

Create creates a new work item board in the repository

func (*GormBoardRepository) List Uses

func (r *GormBoardRepository) List(ctx context.Context, spaceTemplateID uuid.UUID) ([]*Board, error)

List returns all boards for the given space template ID ordered by their position value.

func (*GormBoardRepository) Load Uses

func (r *GormBoardRepository) Load(ctx context.Context, boardID uuid.UUID) (*Board, error)

Load returns the board for the given id.

type GormRevisionRepository Uses

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

GormRevisionRepository implements RevisionRepository using gorm

func NewRevisionRepository Uses

func NewRevisionRepository(db *gorm.DB) *GormRevisionRepository

NewRevisionRepository creates a GormRevisionRepository

func (*GormRevisionRepository) Create Uses

func (r *GormRevisionRepository) Create(ctx context.Context, modifierID uuid.UUID, revisionType RevisionType, workitem WorkItemStorage) (Revision, error)

Create stores a new revision for the given work item.

func (*GormRevisionRepository) List Uses

func (r *GormRevisionRepository) List(ctx context.Context, workitemID uuid.UUID) ([]Revision, error)

List retrieves all revisions for a given work item

type GormWorkItemRepository Uses

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

GormWorkItemRepository implements WorkItemRepository using gorm

func NewWorkItemRepository Uses

func NewWorkItemRepository(db *gorm.DB) *GormWorkItemRepository

NewWorkItemRepository creates a GormWorkItemRepository

func (*GormWorkItemRepository) CalculateOrder Uses

func (r *GormWorkItemRepository) CalculateOrder(above, below *float64) float64

CalculateOrder calculates the order of the reorder workitem

func (*GormWorkItemRepository) ChangeWorkItemType Uses

func (r *GormWorkItemRepository) ChangeWorkItemType(ctx context.Context, wiStorage *WorkItemStorage, oldWIType *WorkItemType, newWIType *WorkItemType, spaceID uuid.UUID) error

ChangeWorkItemType changes the workitem in wiStorage to newWIType. Returns error if the operation fails

func (*GormWorkItemRepository) CheckExists Uses

func (r *GormWorkItemRepository) CheckExists(ctx context.Context, workitemID uuid.UUID) error

CheckExists returns nil if the given ID exists otherwise returns an error

func (*GormWorkItemRepository) CheckTypeAndSpaceShareTemplate Uses

func (r *GormWorkItemRepository) CheckTypeAndSpaceShareTemplate(ctx context.Context, wit *WorkItemType, spaceID uuid.UUID) (bool, error)

CheckTypeAndSpaceShareTemplate returns true if the given workitem type (wit) belongs to the same space template as the space (spaceID); otherwise false is returned

func (*GormWorkItemRepository) Count Uses

func (r *GormWorkItemRepository) Count(ctx context.Context, spaceID uuid.UUID, criteria criteria.Expression) (int, error)

Count returns the amount of work item that satisfy the given criteria.Expression

func (*GormWorkItemRepository) Create Uses

func (r *GormWorkItemRepository) Create(ctx context.Context, spaceID uuid.UUID, typeID uuid.UUID, fields map[string]interface{}, creatorID uuid.UUID) (*WorkItem, *Revision, error)

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

func (*GormWorkItemRepository) Delete Uses

func (r *GormWorkItemRepository) Delete(ctx context.Context, workitemID uuid.UUID, suppressorID uuid.UUID) error

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

func (*GormWorkItemRepository) Fetch Uses

func (r *GormWorkItemRepository) Fetch(ctx context.Context, spaceID uuid.UUID, criteria criteria.Expression) (*WorkItem, error)

Fetch fetches the (first) work item matching by the given criteria.Expression.

func (*GormWorkItemRepository) FindFirstItem Uses

func (r *GormWorkItemRepository) FindFirstItem(ctx context.Context, spaceID uuid.UUID, id uuid.UUID) (*float64, error)

FindFirstItem returns the order of the target workitem

func (*GormWorkItemRepository) FindSecondItem Uses

func (r *GormWorkItemRepository) FindSecondItem(ctx context.Context, order *float64, spaceID uuid.UUID, secondItemDirection DirectionType) (*uuid.UUID, *float64, error)

FindSecondItem returns the order of the second workitem required to reorder. Reordering a workitem requires order of two closest workitems: above and below. If direction == "above", then

	FindFirstItem returns the value above which reorder item has to be placed
     FindSecondItem returns the value below which reorder item has to be placed

If direction == "below", then

	FindFirstItem returns the value below which reorder item has to be placed
     FindSecondItem returns the value above which reorder item has to be placed

func (*GormWorkItemRepository) GetCountsForIteration Uses

func (r *GormWorkItemRepository) GetCountsForIteration(ctx context.Context, itr *iteration.Iteration) (map[string]WICountsPerIteration, error)

GetCountsForIteration returns Closed and Total counts of WIs for given iteration It fetches all child iterations of input iteration and then uses list to counts work items SELECT count(*) AS Total,

count(CASE fields->>'system.state'
          WHEN 'closed' THEN '1'
          ELSE NULL
      END) AS Closed

FROM work_items wi WHERE fields->>'system.iteration' IN ('input iteration ID + children IDs')

AND wi.deleted_at IS NULL

func (*GormWorkItemRepository) GetCountsPerIteration Uses

func (r *GormWorkItemRepository) GetCountsPerIteration(ctx context.Context, spaceID uuid.UUID) (map[string]WICountsPerIteration, error)

GetCountsPerIteration counts WIs including iteration-children and returns a map of iterationID->WICountsPerIteration

func (*GormWorkItemRepository) List Uses

func (r *GormWorkItemRepository) List(ctx context.Context, spaceID uuid.UUID, criteria criteria.Expression, parentExists *bool, start *int, limit *int, sort SortWorkItemsBy) ([]WorkItem, int, 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 Uses

func (r *GormWorkItemRepository) Load(ctx context.Context, spaceID uuid.UUID, wiNumber int) (*WorkItem, error)

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

func (*GormWorkItemRepository) LoadBatchByID Uses

func (r *GormWorkItemRepository) LoadBatchByID(ctx context.Context, ids []uuid.UUID) ([]*WorkItem, error)

LoadBatchByID returns work items for the given ids

func (*GormWorkItemRepository) LoadBatchFromDB Uses

func (r *GormWorkItemRepository) LoadBatchFromDB(ctx context.Context, ids []uuid.UUID) ([]WorkItemStorage, error)

LoadBatchFromDB returns the work items using IN query expression.

func (*GormWorkItemRepository) LoadBottomWorkitem Uses

func (r *GormWorkItemRepository) LoadBottomWorkitem(ctx context.Context, spaceID uuid.UUID) (*WorkItem, error)

LoadBottomWorkitem returns bottom work item of the list. Bottom most workitem has the lowest order. returns NotFoundError, ConversionError or InternalError

func (*GormWorkItemRepository) LoadByID Uses

func (r *GormWorkItemRepository) LoadByID(ctx context.Context, id uuid.UUID) (*WorkItem, error)

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

func (*GormWorkItemRepository) LoadByIteration Uses

func (r *GormWorkItemRepository) LoadByIteration(ctx context.Context, iterationID uuid.UUID) ([]*WorkItem, error)

LoadByIteration returns the list of work items belongs to given iteration

func (*GormWorkItemRepository) LoadFromDB Uses

func (r *GormWorkItemRepository) LoadFromDB(ctx context.Context, id uuid.UUID) (*WorkItemStorage, error)

LoadFromDB returns the work item with the given natural ID in model representation.

func (*GormWorkItemRepository) LoadHighestOrder Uses

func (r *GormWorkItemRepository) LoadHighestOrder(ctx context.Context, spaceID uuid.UUID) (float64, error)

LoadHighestOrder returns the highest execution order in the given space

func (*GormWorkItemRepository) LoadTopWorkitem Uses

func (r *GormWorkItemRepository) LoadTopWorkitem(ctx context.Context, spaceID uuid.UUID) (*WorkItem, error)

LoadTopWorkitem returns top most work item of the list. Top most workitem has the Highest order. returns NotFoundError, ConversionError or InternalError

func (*GormWorkItemRepository) LookupIDByNamedSpaceAndNumber Uses

func (r *GormWorkItemRepository) LookupIDByNamedSpaceAndNumber(ctx context.Context, ownerName, spaceName string, wiNumber int) (*uuid.UUID, *uuid.UUID, error)

LookupIDByNamedSpaceAndNumber returns the work item's ID for the given owner name, space name and item number returns NotFoundError, ConversionError or InternalError

func (*GormWorkItemRepository) Reorder Uses

func (r *GormWorkItemRepository) Reorder(ctx context.Context, spaceID uuid.UUID, direction DirectionType, targetID *uuid.UUID, wi WorkItem, modifierID uuid.UUID) (*WorkItem, error)

Reorder places the to-be-reordered workitem above the input workitem. The order of workitems are spaced by a factor of 1000. The new order of workitem := (order of previousitem + order of nextitem)/2 Version must be the same as the one int the stored version

func (*GormWorkItemRepository) Save Uses

func (r *GormWorkItemRepository) Save(ctx context.Context, spaceID uuid.UUID, updatedWorkItem WorkItem, modifierID uuid.UUID) (*WorkItem, *Revision, error)

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 GormWorkItemTypeGroupRepository Uses

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

GormWorkItemTypeGroupRepository implements WorkItemTypeGroupRepository using gorm

func NewWorkItemTypeGroupRepository Uses

func NewWorkItemTypeGroupRepository(db *gorm.DB) *GormWorkItemTypeGroupRepository

NewWorkItemTypeGroupRepository creates a wi type group repository based on gorm

func (*GormWorkItemTypeGroupRepository) CheckExists Uses

func (r *GormWorkItemTypeGroupRepository) CheckExists(ctx context.Context, id uuid.UUID) error

CheckExists returns nil if the given ID exists otherwise returns an error

func (*GormWorkItemTypeGroupRepository) Create Uses

func (r *GormWorkItemTypeGroupRepository) Create(ctx context.Context, g WorkItemTypeGroup) (*WorkItemTypeGroup, error)

Create creates a new work item type group in the repository

func (*GormWorkItemTypeGroupRepository) List Uses

func (r *GormWorkItemTypeGroupRepository) List(ctx context.Context, spaceTemplateID uuid.UUID) ([]*WorkItemTypeGroup, error)

List returns all work item type groups for the given space template ID ordered by their position value.

func (*GormWorkItemTypeGroupRepository) Load Uses

func (r *GormWorkItemTypeGroupRepository) Load(ctx context.Context, groupID uuid.UUID) (*WorkItemTypeGroup, error)

Load returns the work item type group for the given id

type GormWorkItemTypeRepository Uses

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

GormWorkItemTypeRepository implements WorkItemTypeRepository using gorm

func NewWorkItemTypeRepository Uses

func NewWorkItemTypeRepository(db *gorm.DB) *GormWorkItemTypeRepository

NewWorkItemTypeRepository creates a wi type repository based on gorm

func (*GormWorkItemTypeRepository) AddChildTypes Uses

func (r *GormWorkItemTypeRepository) AddChildTypes(ctx context.Context, parentTypeID uuid.UUID, childTypeIDs []uuid.UUID) error

AddChildTypes adds the given child work item types to the parent work item type.

func (*GormWorkItemTypeRepository) CheckExists Uses

func (r *GormWorkItemTypeRepository) CheckExists(ctx context.Context, id uuid.UUID) error

CheckExists returns nil if the given ID exists otherwise returns an error

func (*GormWorkItemTypeRepository) Create Uses

func (r *GormWorkItemTypeRepository) Create(ctx context.Context, spaceTemplateID uuid.UUID, id *uuid.UUID, extendedTypeID *uuid.UUID, name string, description *string, icon string, fields FieldDefinitions, canConstruct bool) (*WorkItemType, error)

Create creates a new work item type according to the given parameters.

func (*GormWorkItemTypeRepository) CreateFromModel Uses

func (r *GormWorkItemTypeRepository) CreateFromModel(ctx context.Context, model WorkItemType) (*WorkItemType, error)

CreateFromModel creates a new work item type in the repository based on the given model of it.

func (*GormWorkItemTypeRepository) List Uses

func (r *GormWorkItemTypeRepository) List(ctx context.Context, spaceTemplateID uuid.UUID) ([]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) ListPlannerItemTypes Uses

func (r *GormWorkItemTypeRepository) ListPlannerItemTypes(ctx context.Context, spaceTemplateID uuid.UUID) ([]WorkItemType, error)

ListPlannerItemTypes returns work item types that derives from PlannerItem type

func (*GormWorkItemTypeRepository) Load Uses

func (r *GormWorkItemTypeRepository) Load(ctx context.Context, id uuid.UUID) (*WorkItemType, error)

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

type Kind Uses

type Kind string

Kind is the kind of field type

const (
    // non-relational
    KindString  Kind = "string"
    KindInteger Kind = "integer"
    KindFloat   Kind = "float"
    KindBoolean Kind = "bool"
    KindInstant Kind = "instant"
    KindURL     Kind = "url"
    KindMarkup  Kind = "markup"
    // relational
    KindIteration   Kind = "iteration"
    KindUser        Kind = "user"
    KindLabel       Kind = "label"
    KindBoardColumn Kind = "boardcolumn"
    KindArea        Kind = "area"
    KindCodebase    Kind = "codebase"
    // composite
    KindEnum Kind = "enum"
    KindList Kind = "list"
)

constants for describing possible field types

func ConvertAnyToKind Uses

func ConvertAnyToKind(any interface{}) (*Kind, error)

func ConvertStringToKind Uses

func ConvertStringToKind(k string) (*Kind, error)

ConvertStringToKind returns the given string as a Kind object

func (Kind) IsRelational Uses

func (k Kind) IsRelational() bool

IsRelational returns 'true' if the kind must be represented with a relationship.

func (Kind) IsSimpleType Uses

func (k Kind) IsSimpleType() bool

IsSimpleType returns 'true' if the kind is simple, i.e., not a list nor an enum

func (Kind) String Uses

func (k Kind) String() string

String implements the Stringer interface and returns the kind as a string object.

type ListType Uses

type ListType struct {
    SimpleType    `json:"simple_type"`
    ComponentType SimpleType  `json:"component_type"`
    DefaultValue  interface{} `json:"default_value,omitempty"`
}

ListType describes a list of SimpleType values

func (ListType) ConvertFromModel Uses

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

ConvertFromModel implements the FieldType interface

func (ListType) ConvertToModel Uses

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

ConvertToModel implements the FieldType interface

func (ListType) Equal Uses

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

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

func (ListType) EqualValue Uses

func (t ListType) EqualValue(u convert.Equaler) bool

EqualValue implements convert.Equaler interface

func (ListType) GetDefaultValue Uses

func (t ListType) GetDefaultValue() interface{}

GetDefaultValue implements FieldType

func (ListType) SetDefaultValue Uses

func (t ListType) SetDefaultValue(v interface{}) (FieldType, error)

SetDefaultValue implements FieldType

func (ListType) Validate Uses

func (t ListType) Validate() error

Validate checks that the type of the list is "list", that the component type iteself a simple tpye (e.g. not a list or an enum) and that the default value matches the Kind of the ComponentType.

type Revision Uses

type Revision struct {
    ID  uuid.UUID `gorm:"primary_key"`
    // the timestamp of the modification
    Time time.Time `gorm:"column:revision_time"`
    // the type of modification
    Type RevisionType `gorm:"column:revision_type"`
    // the identity of author of the workitem modification
    ModifierIdentity uuid.UUID `sql:"type:uuid" gorm:"column:modifier_id"`
    // the id of the work item that changed
    WorkItemID uuid.UUID `gorm:"column:work_item_id"`
    // Id of the type of this work item
    WorkItemTypeID uuid.UUID `gorm:"column:work_item_type_id"`
    // Version of the workitem that was modified
    WorkItemVersion int `gorm:"column:work_item_version"`
    // the field values (or empty when the work item was deleted)
    WorkItemFields Fields `gorm:"column:work_item_fields" sql:"type:jsonb"`
}

Revision represents a version of a work item

func (Revision) TableName Uses

func (w Revision) TableName() string

TableName implements gorm.tabler

type RevisionRepository Uses

type RevisionRepository interface {
    // Create stores a new revision for the given work item.
    Create(ctx context.Context, modifierID uuid.UUID, revisionType RevisionType, workitem WorkItemStorage) (Revision, error)
    // List retrieves all revisions for a given work item
    List(ctx context.Context, workitemID uuid.UUID) ([]Revision, error)
}

RevisionRepository encapsulates storage & retrieval of historical versions of work items

type RevisionType Uses

type RevisionType int

RevisionType defines the type of revision for a work item

const (

    // RevisionTypeCreate a work item creation
    RevisionTypeCreate RevisionType // 1
    // RevisionTypeDelete a work item deletion
    RevisionTypeDelete // 2

    // RevisionTypeUpdate a work item update
    RevisionTypeUpdate // 4
)

type SimpleType Uses

type SimpleType struct {
    Kind         Kind        `json:"kind"`
    DefaultValue interface{} `json:"default_value,omitempty"`
}

SimpleType is an unstructured FieldType

func (SimpleType) ConvertFromModel Uses

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

ConvertFromModel implements the FieldType interface

func (SimpleType) ConvertToModel Uses

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

ConvertToModel implements the FieldType interface

func (SimpleType) ConvertToModelWithType Uses

func (t SimpleType) ConvertToModelWithType(newFieldType FieldType, v interface{}) (interface{}, error)

ConvertToModelWithType implements FieldType

func (SimpleType) Equal Uses

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

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

func (SimpleType) EqualValue Uses

func (t SimpleType) EqualValue(u convert.Equaler) bool

EqualValue implements convert.Equaler interface

func (SimpleType) GetDefaultValue Uses

func (t SimpleType) GetDefaultValue() interface{}

GetDefaultValue implements FieldType

func (SimpleType) GetKind Uses

func (t SimpleType) GetKind() Kind

GetKind implements FieldType

func (SimpleType) SetDefaultValue Uses

func (t SimpleType) SetDefaultValue(v interface{}) (FieldType, error)

SetDefaultValue implements FieldType

func (SimpleType) Validate Uses

func (t SimpleType) Validate() error

Validate checks that the default value matches the Kind

type SortWorkItemsBy Uses

type SortWorkItemsBy string

SortWorkItemsBy is type used to define parameters using which workitems will be sorted

func ParseSortWorkItemsBy Uses

func ParseSortWorkItemsBy(s *string) (SortWorkItemsBy, error)

ParseSortWorkItemsBy parses the string input and returns object of type SortWorkItemsBy which can directly be used while querying database to order the output.

type TableJoin Uses

type TableJoin struct {
    Active bool // true if this table join is used

    // TableName specifies the foreign table upon which to join. This can also
    // be subselect on its own.
    TableName string // e.g. "iterations"

    // TableAlias allows us to specify an alias for the table to be used in the
    // WHERE clause.
    TableAlias string // e.g. "iter"

    // On is the ON part of the JOIN.
    On  string // e.g. `fields@> concat('{"system.iteration": "', iter.ID, '"}')::jsonb`

    // Where defines what condition to place in the main WHERE clause of the
    // final query.
    Where string

    // PrefixActivators can hold a number of prefix strings that cause this join
    // object to be activated.
    PrefixActivators []string // e.g. []string{"iteration."}

    // AllowedColumns specified all fields that are allowed to be queried from
    // the foreign table. When empty, all columns are allowed.
    AllowedColumns []string // e.g. ["name"].

    // DisallowedColumns specified all fields that are not allowed to be queried
    // from the foreign table. When empty, all columns are allowed.
    DisallowedColumns []string // e.g. ["created_at"].

    // HandledFields contains those fields that were found to reference this
    // table join. It is later used by Validate() to find out if a field name
    // exists in the database.
    HandledFields []string // e.g. []string{"name", "created_at", "foobar"}

    // ActivateOtherJoins is useful when you make complex joins over mutliple
    // tables. Just put in the names of the table join keys in here that you
    // would like to activate as well. See DefaultTypeGroups() for how the map
    // looks like. If you ask for "A" and that requires "B", then "B" is also
    // added automatically.
    ActivateOtherJoins []string

    // All prefixes in the map keys that would normally be handled by this join
    // will be handled by the join specified here (if any).
    DelegateTo map[string]*TableJoin
}

A TableJoin helps to construct a query like this:

SELECT *
  FROM workitems
  LEFT JOIN iterations iter ON fields@> concat('{"system.iteration": "', iter.ID, '"}')::jsonb
  WHERE iter.name = "foo"

With the prefix activators we can identify if a certain field expression points at data from a joined table. By default there are no restrictions on what can be queried in the joined table but if you fill the allowed/disallowed columns arrays you can explicitly allow or disallow columns to be queried. The names in the allowed/disalowed columns are those of the foreign (aka joined) table.

func Compile Uses

func Compile(where criteria.Expression) (whereClause string, parameters []interface{}, joins []*TableJoin, 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 (TableJoin) GetJoinExpression Uses

func (j TableJoin) GetJoinExpression() string

GetJoinExpression returns the SQL JOIN expression for this table join.

func (*TableJoin) HandlesFieldName Uses

func (j *TableJoin) HandlesFieldName(fieldName string) bool

HandlesFieldName returns true if the given field name should be handled by this table join.

func (*TableJoin) TranslateFieldName Uses

func (j *TableJoin) TranslateFieldName(fieldName string) (string, error)

TranslateFieldName returns a non-empty string if the given field name has the prefix specified by the table join and if the field is allowed to be queried; otherwise it returns an empty string.

func (TableJoin) Validate Uses

func (j TableJoin) Validate(db *gorm.DB) error

Validate returns nil if the join is active and all the fields handled by this join do exist in the joined table; otherwise an error is returned.

type TableJoinMap Uses

type TableJoinMap map[string]*TableJoin

TableJoinMap is used to store join in the expression compiler

func (*TableJoinMap) ActivateRequiredJoins Uses

func (joins *TableJoinMap) ActivateRequiredJoins() error

ActivateRequiredJoins recursively walks over all given joins potentially multiple times and activates all other required joins.

func (*TableJoinMap) GetOrderdActivatedJoins Uses

func (joins *TableJoinMap) GetOrderdActivatedJoins() ([]*TableJoin, error)

GetOrderdActivatedJoins returns a slice of activated joins in a proper order, beginning with the join that activates no other join, and ending with the join that activates another join but isn't activated by another join itself.

type TypeBucket Uses

type TypeBucket string

TypeBucket represents a dedicated string type for a bucket of type groups

const (
    BucketPortfolio   TypeBucket = "portfolio"
    BucketRequirement TypeBucket = "requirement"
    BucketIteration   TypeBucket = "iteration"
)

Use following bucket constants while defining static groups. NOTE: Those buckets can later be used by reporting tools for example to gather information on a collective range of work item types.

func (*TypeBucket) Scan Uses

func (t *TypeBucket) Scan(value interface{}) error

Scan implements the https://golang.org/pkg/database/sql/#Scanner interface See also https://stackoverflow.com/a/25374979/835098 See also https://github.com/jinzhu/gorm/issues/302#issuecomment-80566841

func (TypeBucket) String Uses

func (t TypeBucket) String() string

String implements the Stringer interface

func (TypeBucket) Value Uses

func (t TypeBucket) Value() (driver.Value, error)

Value implements the https://golang.org/pkg/database/sql/driver/#Valuer interface

type ValidInvalid Uses

type ValidInvalid struct {
    // Valid should contain more than one valid examples so a test function can
    // properly handle work item creation and updating
    Valid   []interface{}
    Invalid []interface{}
    // When the actual value is a zero (0), it will be interpreted as a float64
    // rather than an int. To compensate for that ambiguity, a kind can opt-in
    // to provide a construction function that returns the correct value.
    Compensate func(interface{}) interface{}
}

ValidInvalid given a bunch of tests with expected error results for each work item type field kind, a work item type for each kind...

type WICountsPerIteration Uses

type WICountsPerIteration struct {
    IterationID string `gorm:"column:iterationid"`
    Total       int
    Closed      int
}

WICountsPerIteration counting work item states by iteration

type WorkItem Uses

type WorkItem struct {
    // unique id per installation (used for references at the DB level)
    ID  uuid.UUID
    // unique number per _space_
    Number int
    // ID of the type of this work item
    Type uuid.UUID
    // Version for optimistic concurrency control
    Version int
    // ID of the space to which this work item belongs
    SpaceID uuid.UUID
    // The field values, according to the field type
    Fields map[string]interface{}
    // contains filtered or unexported fields
}

WorkItem the model structure for the work item.

func ConvertWorkItemStorageToModel Uses

func ConvertWorkItemStorageToModel(wiType *WorkItemType, wi *WorkItemStorage) (*WorkItem, error)

ConvertWorkItemStorageToModel convert work item model to app WI

func (WorkItem) ChangeSet Uses

func (wi WorkItem) ChangeSet(older change.Detector) (change.Set, error)

ChangeSet derives a changeset between this workitem and a given workitem.

func (WorkItem) GetETagData Uses

func (wi WorkItem) GetETagData() []interface{}

GetETagData returns the field values to use to generate the ETag

func (WorkItem) GetLastModified Uses

func (wi WorkItem) GetLastModified() time.Time

GetLastModified returns the last modification time

type WorkItemRepository Uses

type WorkItemRepository interface {
    repository.Exister
    Load(ctx context.Context, spaceID uuid.UUID, wiNumber int) (*WorkItem, error)
    LoadByID(ctx context.Context, id uuid.UUID) (*WorkItem, error)
    LoadBatchByID(ctx context.Context, ids []uuid.UUID) ([]*WorkItem, error)
    LoadByIteration(ctx context.Context, id uuid.UUID) ([]*WorkItem, error)
    LookupIDByNamedSpaceAndNumber(ctx context.Context, ownerName, spaceName string, wiNumber int) (*uuid.UUID, *uuid.UUID, error)
    Save(ctx context.Context, spaceID uuid.UUID, wi WorkItem, modifierID uuid.UUID) (*WorkItem, *Revision, error)
    Reorder(ctx context.Context, spaceID uuid.UUID, direction DirectionType, targetID *uuid.UUID, wi WorkItem, modifierID uuid.UUID) (*WorkItem, error)
    Delete(ctx context.Context, id uuid.UUID, suppressorID uuid.UUID) error
    Create(ctx context.Context, spaceID uuid.UUID, typeID uuid.UUID, fields map[string]interface{}, creatorID uuid.UUID) (*WorkItem, *Revision, error)
    List(ctx context.Context, spaceID uuid.UUID, criteria criteria.Expression, parentExists *bool, start *int, length *int, sort SortWorkItemsBy) ([]WorkItem, int, error)
    Fetch(ctx context.Context, spaceID uuid.UUID, criteria criteria.Expression) (*WorkItem, error)
    GetCountsPerIteration(ctx context.Context, spaceID uuid.UUID) (map[string]WICountsPerIteration, error)
    GetCountsForIteration(ctx context.Context, itr *iteration.Iteration) (map[string]WICountsPerIteration, error)
    Count(ctx context.Context, spaceID uuid.UUID, criteria criteria.Expression) (int, error)
    ChangeWorkItemType(ctx context.Context, wiStorage *WorkItemStorage, oldWIType *WorkItemType, newWIType *WorkItemType, spaceID uuid.UUID) error
}

WorkItemRepository encapsulates storage & retrieval of work items

type WorkItemStorage Uses

type WorkItemStorage struct {
    gormsupport.Lifecycle
    // unique id per installation (used for references at the DB level)
    ID  uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"`
    // unique number per _space_
    Number int
    // Id of the type of this work item
    Type uuid.UUID `sql:"type:uuid"`
    // Version for optimistic concurrency control
    Version int
    // the field values
    Fields Fields `sql:"type:jsonb"`
    // the position of workitem
    ExecutionOrder float64
    // Reference to one Space
    SpaceID uuid.UUID `sql:"type:uuid"`
    // optional timestamp of the latest addition/removal of a relationship with this workitem
    RelationShipsChangedAt *time.Time `sql:"column:relationships_changed_at"`
}

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

func (WorkItemStorage) Equal Uses

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

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

func (WorkItemStorage) EqualValue Uses

func (wi WorkItemStorage) EqualValue(u convert.Equaler) bool

EqualValue implements convert.Equaler interface

func (WorkItemStorage) TableName Uses

func (wi WorkItemStorage) TableName() string

TableName implements gorm.tabler

type WorkItemType Uses

type WorkItemType struct {
    gormsupport.Lifecycle `json:"lifecycle,omitempty"`

    // ID is the primary key of a work item type.
    ID  uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key" json:"id,omitempty"`

    // Name is a human readable name of this work item type.
    Name string `json:"name,omitempty"`

    // Description is an optional description of the work item type.
    Description *string `json:"description,omitempty"`

    // Icon contains the CSS icon class(es) to render an icon for the work item
    // type.
    Icon string `json:"icon,omitempty"`

    // Version contains the revision number of this work item type and is used
    // for optimistic concurrency control.
    Version int `json:"version,omitempty"`

    // Path contains the IDs of the parents, separated with a dot (".")
    // separator.
    // TODO(kwk): Think about changing this to the dedicated path type also used
    // by iterations.
    Path string `json:"path,omitempty"`

    // Fields contains the definitions of the fields this work item type
    // supports.
    Fields FieldDefinitions `sql:"type:jsonb" json:"fields,omitempty"`

    // SpaceTemplateID refers to the space template to which this work item type
    // belongs.
    SpaceTemplateID uuid.UUID `sql:"type:uuid" json:"space_template_id,omitempty"`

    // Extends is a helper ID to support "extends" attribute of WIT in a space
    // template. This field is not filled when you load a work item type from
    // the DB. Instead the Path member contains the information.
    Extends uuid.UUID `gorm:"-" json:"extends,omitempty"`

    // CanConstruct is true when you can create work items from this work item
    // type.
    CanConstruct bool `gorm:"can_construct" json:"can_construct,omitempty"`

    // ChildTypeIDs is a list of work item type IDs that can be used as child
    // type of this work item. This field is filled upon loading the work item
    // type from the DB.
    ChildTypeIDs []uuid.UUID `gorm:"-" json:"child_types,omitempty"`
}

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

func (WorkItemType) ConvertWorkItemStorageToModel Uses

func (wit WorkItemType) ConvertWorkItemStorageToModel(workItem WorkItemStorage) (*WorkItem, error)

ConvertWorkItemStorageToModel converts a workItem from the storage/persistence layer into a workItem of the model domain layer

func (WorkItemType) Equal Uses

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

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

func (WorkItemType) EqualValue Uses

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

EqualValue implements convert.Equaler interface

func (WorkItemType) GetETagData Uses

func (wit WorkItemType) GetETagData() []interface{}

GetETagData returns the field values to use to generate the ETag

func (WorkItemType) GetLastModified Uses

func (wit WorkItemType) GetLastModified() time.Time

GetLastModified returns the last modification time

func (WorkItemType) IsTypeOrSubtypeOf Uses

func (wit WorkItemType) IsTypeOrSubtypeOf(typeID uuid.UUID) bool

IsTypeOrSubtypeOf returns true if the work item type with the given type ID, is of the same type as the current WIT or of it is a subtype; otherwise false is returned.

func (WorkItemType) LtreeSafeID Uses

func (wit WorkItemType) LtreeSafeID() string

LtreeSafeID returns the ID of the work item type in an postgres ltree safe manner. The returned string can be used as an ltree node.

func (WorkItemType) TableName Uses

func (wit WorkItemType) TableName() string

TableName implements gorm.tabler

func (WorkItemType) Validate Uses

func (wit WorkItemType) Validate() error

Validate runs some checks on the work item type to ensure the field definitions make sense.

type WorkItemTypeCache Uses

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

WorkItemTypeCache represents WorkItemType cache

func NewWorkItemTypeCache Uses

func NewWorkItemTypeCache() *WorkItemTypeCache

NewWorkItemTypeCache constructs WorkItemTypeCache

func (*WorkItemTypeCache) Clear Uses

func (c *WorkItemTypeCache) Clear()

Clear clears the cache

func (*WorkItemTypeCache) Get Uses

func (c *WorkItemTypeCache) Get(id uuid.UUID) (WorkItemType, bool)

Get returns WorkItemType by ID. The second value (ok) is a bool that is true if the WorkItemType exists in the cache, and false if not.

func (*WorkItemTypeCache) Put Uses

func (c *WorkItemTypeCache) Put(wit WorkItemType)

Put puts a work item type to the cache

type WorkItemTypeGroup Uses

type WorkItemTypeGroup struct {
    gormsupport.Lifecycle `json:"lifecycle"`
    ID                    uuid.UUID   `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key" json:"id"`
    SpaceTemplateID       uuid.UUID   `sql:"type:uuid" json:"space_template_id"`
    Bucket                TypeBucket  `json:"bucket,omitempty"`
    Name                  string      `json:"name,omitempty"` // the name to be displayed to user (is unique)
    Description           *string     `json:"description,omitempty"`
    Icon                  string      `json:"icon,omitempty"`
    Position              int         `json:"-"`
    TypeList              []uuid.UUID `gorm:"-" json:"type_list,omitempty"`
}

WorkItemTypeGroup represents the node in the group of work item types

func TypeGroupByName Uses

func TypeGroupByName(name string) *WorkItemTypeGroup

TypeGroupByName returns a type group based on its name if such a group exists; otherwise nil is returned.

func TypeGroups Uses

func TypeGroups() []WorkItemTypeGroup

TypeGroups returns the list of work item type groups

func TypeGroupsByBucket Uses

func TypeGroupsByBucket(bucket TypeBucket) []WorkItemTypeGroup

TypeGroupsByBucket returns all type groups which fall into the given bucket

func (WorkItemTypeGroup) Equal Uses

func (witg WorkItemTypeGroup) Equal(u convert.Equaler) bool

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

func (WorkItemTypeGroup) EqualValue Uses

func (witg WorkItemTypeGroup) EqualValue(u convert.Equaler) bool

EqualValue implements convert.Equaler interface

func (WorkItemTypeGroup) GetETagData Uses

func (witg WorkItemTypeGroup) GetETagData() []interface{}

GetETagData returns the field values to use to generate the ETag

func (WorkItemTypeGroup) GetLastModified Uses

func (witg WorkItemTypeGroup) GetLastModified() time.Time

GetLastModified returns the last modification time

func (WorkItemTypeGroup) TableName Uses

func (witg WorkItemTypeGroup) TableName() string

TableName implements gorm.tabler

type WorkItemTypeGroupRepository Uses

type WorkItemTypeGroupRepository interface {
    repository.Exister
    Create(ctx context.Context, group WorkItemTypeGroup) (*WorkItemTypeGroup, error)
    Load(ctx context.Context, groupID uuid.UUID) (*WorkItemTypeGroup, error)
    List(ctx context.Context, spaceTemplateID uuid.UUID) ([]*WorkItemTypeGroup, error)
}

WorkItemTypeGroupRepository encapsulates storage & retrieval of work item type groups

type WorkItemTypeRepository Uses

type WorkItemTypeRepository interface {
    repository.Exister
    Load(ctx context.Context, id uuid.UUID) (*WorkItemType, error)
    Create(ctx context.Context, spaceTemplateID uuid.UUID, id *uuid.UUID, extendedTypeID *uuid.UUID, name string, description *string, icon string, fields FieldDefinitions, canConstruct bool) (*WorkItemType, error)
    CreateFromModel(ctx context.Context, model WorkItemType) (*WorkItemType, error)
    List(ctx context.Context, spaceTemplateID uuid.UUID) ([]WorkItemType, error)
    ListPlannerItemTypes(ctx context.Context, spaceTemplateID uuid.UUID) ([]WorkItemType, error)
    AddChildTypes(ctx context.Context, parentTypeID uuid.UUID, childTypeIDs []uuid.UUID) error
}

WorkItemTypeRepository encapsulates storage & retrieval of work item types

Directories

PathSynopsis
event
linkPackage link contains the code that provides all the required operations to manage work item link, work item link types and work item link categories.
number_sequence

Package workitem imports 40 packages (graph) and is imported by 77 packages. Updated 2018-10-21. Refresh now. Tools for package owners.