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

package link

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

Package link contains the code that provides all the required operations to manage work item link, work item link types and work item link categories.

Index

Package Files

category.go category_repository.go doc.go link.go link_repository.go link_revision.go link_revision_repository.go topology.go type.go type_repository.go

Constants

const (
    EndpointWorkItemTypes          = "workitemtypes"
    EndpointWorkItems              = "workitems"
    EndpointWorkItemLinkCategories = "workitemlinkcategories"
    EndpointWorkItemLinkTypes      = "workitemlinktypes"
    EndpointWorkItemLinks          = "workitemlinks"
)

End points

const (
    // the `parent of` type of link
    TypeParentOf = "parent of"
)

Variables

var (
    SystemWorkItemLinkCategorySystemID = uuid.FromStringOrNil("B1482C65-A64D-4058-BEB0-62F7198CB0F4")
    SystemWorkItemLinkCategoryUserID   = uuid.FromStringOrNil("2F24724F-797C-4073-8B16-4BB8CE9E84A6")
)

Never ever change these UUIDs!!!

var (
    SystemWorkItemLinkTypeBugBlockerID     = uuid.FromStringOrNil("2CEA3C79-3B79-423B-90F4-1E59174C8F43")
    SystemWorkItemLinkPlannerItemRelatedID = uuid.FromStringOrNil("9B631885-83B1-4ABB-A340-3A9EDE8493FA")
    SystemWorkItemLinkTypeParentChildID    = uuid.FromStringOrNil("25C326A7-6D03-4F5A-B23B-86A9EE4171E9")
)

Never ever change these UUIDs!!!

type GormWorkItemLinkCategoryRepository Uses

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

GormWorkItemLinkCategoryRepository implements WorkItemLinkCategoryRepository using gorm

func NewWorkItemLinkCategoryRepository Uses

func NewWorkItemLinkCategoryRepository(db *gorm.DB) *GormWorkItemLinkCategoryRepository

NewWorkItemLinkCategoryRepository creates a work item link category repository based on gorm

func (*GormWorkItemLinkCategoryRepository) CheckExists Uses

func (r *GormWorkItemLinkCategoryRepository) CheckExists(ctx context.Context, id string) error

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

func (*GormWorkItemLinkCategoryRepository) Create Uses

func (r *GormWorkItemLinkCategoryRepository) Create(ctx context.Context, linkCat *WorkItemLinkCategory) (*WorkItemLinkCategory, error)

Create creates a new work item link category in the repository. Returns BadParameterError, ConversionError or InternalError

func (*GormWorkItemLinkCategoryRepository) Delete Uses

func (r *GormWorkItemLinkCategoryRepository) Delete(ctx context.Context, ID uuid.UUID) error

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

func (*GormWorkItemLinkCategoryRepository) List Uses

func (r *GormWorkItemLinkCategoryRepository) List(ctx context.Context) ([]WorkItemLinkCategory, error)

List returns all work item link categories TODO: Handle pagination

func (*GormWorkItemLinkCategoryRepository) Load Uses

func (r *GormWorkItemLinkCategoryRepository) Load(ctx context.Context, ID uuid.UUID) (*WorkItemLinkCategory, error)

Load returns the work item link category for the given ID. Returns NotFoundError, ConversionError or InternalError

func (*GormWorkItemLinkCategoryRepository) Save Uses

func (r *GormWorkItemLinkCategoryRepository) Save(ctx context.Context, linkCat WorkItemLinkCategory) (*WorkItemLinkCategory, error)

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

type GormWorkItemLinkRepository Uses

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

GormWorkItemLinkRepository implements WorkItemLinkRepository using gorm

func NewWorkItemLinkRepository Uses

func NewWorkItemLinkRepository(db *gorm.DB) *GormWorkItemLinkRepository

NewWorkItemLinkRepository creates a work item link repository based on gorm

func (*GormWorkItemLinkRepository) CheckExists Uses

func (r *GormWorkItemLinkRepository) CheckExists(ctx context.Context, id string) error

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

func (*GormWorkItemLinkRepository) CheckParentExists Uses

func (r *GormWorkItemLinkRepository) CheckParentExists(ctx context.Context, sourceID *uuid.UUID, targetID uuid.UUID, linkType WorkItemLinkType) (bool, error)

CheckParentExists returns `true` if a link to a work item with the given `targetID` and of the given `linkType` already exists, `false` otherwise. If the `sourceId` argument is not nil, then existing link from the source item to the target item with the given type is ignored. In the context of a link creation, the `sourceID` argument should be nil, so the method will look for a link of the given type and target, since during link creation we need to ensure that the child item has no parent yet. During the link update, the verification should not take into account the existing record in the database.

func (*GormWorkItemLinkRepository) Create Uses

func (r *GormWorkItemLinkRepository) Create(ctx context.Context, sourceID, targetID uuid.UUID, linkTypeID uuid.UUID, creatorID uuid.UUID) (*WorkItemLink, error)

Create creates a new work item link in the repository. Returns BadParameterError, ConversionError or InternalError

func (*GormWorkItemLinkRepository) Delete Uses

func (r *GormWorkItemLinkRepository) Delete(ctx context.Context, linkID uuid.UUID, suppressorID uuid.UUID) error

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

func (r *GormWorkItemLinkRepository) DeleteRelatedLinks(ctx context.Context, wiID uuid.UUID, suppressorID uuid.UUID) error

DeleteRelatedLinks deletes all links in which the source or target equals the given work item ID.

func (*GormWorkItemLinkRepository) GetParentID Uses

func (r *GormWorkItemLinkRepository) GetParentID(ctx context.Context, ID uuid.UUID) (*uuid.UUID, error)

GetParentID returns parent ID of the given work item if any

func (*GormWorkItemLinkRepository) List Uses

func (r *GormWorkItemLinkRepository) List(ctx context.Context) ([]WorkItemLink, error)

List returns all work item links if wiID is nil; otherwise the work item links are returned that have wiID as source or target. TODO: Handle pagination

func (*GormWorkItemLinkRepository) ListByWorkItem Uses

func (r *GormWorkItemLinkRepository) ListByWorkItem(ctx context.Context, wiID uuid.UUID) ([]WorkItemLink, error)

ListByWorkItem returns the work item links that have wiID as source or target. TODO: Handle pagination

func (*GormWorkItemLinkRepository) ListWorkItemChildren Uses

func (r *GormWorkItemLinkRepository) ListWorkItemChildren(ctx context.Context, parentID uuid.UUID, start *int, limit *int) ([]workitem.WorkItem, uint64, error)

ListWorkItemChildren get all child work items

func (*GormWorkItemLinkRepository) Load Uses

func (r *GormWorkItemLinkRepository) Load(ctx context.Context, ID uuid.UUID) (*WorkItemLink, error)

Load returns the work item link for the given ID. Returns NotFoundError, ConversionError or InternalError

func (*GormWorkItemLinkRepository) Save Uses

func (r *GormWorkItemLinkRepository) Save(ctx context.Context, linkToSave WorkItemLink, modifierID uuid.UUID) (*WorkItemLink, error)

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

func (*GormWorkItemLinkRepository) ValidateTopology Uses

func (r *GormWorkItemLinkRepository) ValidateTopology(ctx context.Context, sourceID *uuid.UUID, targetID uuid.UUID, linkType WorkItemLinkType) error

ValidateTopology validates the link topology of the work item given its ID. I.e, the given item should not have a parent with the same kind of link if the `sourceID` arg is not empty, then the corresponding source item is ignored when checking the existing links of the given type.

func (*GormWorkItemLinkRepository) WorkItemHasChildren Uses

func (r *GormWorkItemLinkRepository) WorkItemHasChildren(ctx context.Context, parentID uuid.UUID) (bool, error)

WorkItemHasChildren returns true if the given parent work item has children; otherwise false is returned

type GormWorkItemLinkRevisionRepository Uses

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

GormCommentRevisionRepository implements CommentRevisionRepository using gorm

func NewRevisionRepository Uses

func NewRevisionRepository(db *gorm.DB) *GormWorkItemLinkRevisionRepository

NewRevisionRepository creates a GormCommentRevisionRepository

func (*GormWorkItemLinkRevisionRepository) Create Uses

func (r *GormWorkItemLinkRevisionRepository) Create(ctx context.Context, modifierID uuid.UUID, revisionType RevisionType, l WorkItemLink) error

Create stores a new revision for the given work item link.

func (*GormWorkItemLinkRevisionRepository) List Uses

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

List retrieves all revisions for a given work item link

type GormWorkItemLinkTypeRepository Uses

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

GormWorkItemLinkTypeRepository implements WorkItemLinkTypeRepository using gorm

func NewWorkItemLinkTypeRepository Uses

func NewWorkItemLinkTypeRepository(db *gorm.DB) *GormWorkItemLinkTypeRepository

NewWorkItemLinkTypeRepository creates a work item link type repository based on gorm

func (*GormWorkItemLinkTypeRepository) CheckExists Uses

func (r *GormWorkItemLinkTypeRepository) CheckExists(ctx context.Context, id string) error

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

func (*GormWorkItemLinkTypeRepository) Create Uses

func (r *GormWorkItemLinkTypeRepository) Create(ctx context.Context, linkType *WorkItemLinkType) (*WorkItemLinkType, error)

Create creates a new work item link type in the repository. Returns BadParameterError, ConversionError or InternalError

func (*GormWorkItemLinkTypeRepository) Delete Uses

func (r *GormWorkItemLinkTypeRepository) Delete(ctx context.Context, spaceID uuid.UUID, ID uuid.UUID) error

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

func (*GormWorkItemLinkTypeRepository) List Uses

func (r *GormWorkItemLinkTypeRepository) List(ctx context.Context, spaceID uuid.UUID) ([]WorkItemLinkType, error)

List returns all work item link types TODO: Handle pagination

func (*GormWorkItemLinkTypeRepository) Load Uses

func (r *GormWorkItemLinkTypeRepository) Load(ctx context.Context, ID uuid.UUID) (*WorkItemLinkType, error)

Load returns the work item link type for the given ID. Returns NotFoundError, ConversionError or InternalError

func (*GormWorkItemLinkTypeRepository) Save Uses

func (r *GormWorkItemLinkTypeRepository) Save(ctx context.Context, modelToSave WorkItemLinkType) (*WorkItemLinkType, error)

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

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 work item modification
    ModifierIdentity uuid.UUID `sql:"type:uuid" gorm:"column:modifier_id"`
    // the ID of the work item link that changed
    WorkItemLinkID uuid.UUID `sql:"type:uuid"`
    // the version of the work item link that changed
    WorkItemLinkVersion int
    // the ID of the source of the work item link that changed
    WorkItemLinkSourceID uuid.UUID `sql:"type:uuid"`
    // the ID of the target of the work item link that changed
    WorkItemLinkTargetID uuid.UUID `sql:"type:uuid"`
    // the ID of the type of the work item link that changed
    WorkItemLinkTypeID uuid.UUID `sql:"type:uuid"`
}

Revision represents a version of a work item link

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 link.
    Create(ctx context.Context, modifierID uuid.UUID, revisionType RevisionType, l WorkItemLink) error
    // List retrieves all revisions for a given work item link
    List(ctx context.Context, workitemID uuid.UUID) ([]Revision, error)
}

RevisionRepository encapsulates storage & retrieval of historical versions of work item links

type RevisionType Uses

type RevisionType int

RevisionType defines the type of revision for a work item link

const (

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

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

type Topology Uses

type Topology string

Topology determines the way that links can be created

const (
    TopologyNetwork         Topology = "network"
    TopologyDirectedNetwork Topology = "directed_network"
    TopologyDependency      Topology = "dependency"
    TopologyTree            Topology = "tree"
)

func (Topology) CheckValid Uses

func (t Topology) CheckValid() error

CheckValid returns nil if the given topology is valid; otherwise a BadParameterError is returned.

func (*Topology) Scan Uses

func (t *Topology) 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 (Topology) String Uses

func (t Topology) String() string

func (Topology) Value Uses

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

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

type WorkItemLink struct {
    gormsupport.Lifecycle
    // ID
    ID  uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"`
    // Version for optimistic concurrency control
    Version    int
    SourceID   uuid.UUID `sql:"type:uuid"`
    TargetID   uuid.UUID `sql:"type:uuid"`
    LinkTypeID uuid.UUID `sql:"type:uuid"`
}

WorkItemLink represents the connection of two work items as it is stored in the db

func (*WorkItemLink) CheckValidForCreation Uses

func (l *WorkItemLink) CheckValidForCreation() error

CheckValidForCreation returns an error if the work item link cannot be used for the creation of a new work item link.

func (WorkItemLink) Equal Uses

func (l WorkItemLink) Equal(u convert.Equaler) bool

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

func (WorkItemLink) GetETagData Uses

func (l WorkItemLink) GetETagData() []interface{}

GetETagData returns the field values to use to generate the ETag

func (WorkItemLink) GetLastModified Uses

func (l WorkItemLink) GetLastModified() time.Time

GetLastModified returns the last modification time

func (WorkItemLink) TableName Uses

func (l WorkItemLink) TableName() string

TableName implements gorm.tabler

type WorkItemLinkCategory Uses

type WorkItemLinkCategory struct {
    gormsupport.Lifecycle
    // ID
    ID  uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"`
    // Name is the unique name of this work item link category.
    Name string
    // Description is an optional description of the work item link category
    Description *string
    // Version for optimistic concurrency control
    Version int
}

WorkItemLinkCategory represents the category of a work item link as it is stored in the db

func (WorkItemLinkCategory) Equal Uses

func (c WorkItemLinkCategory) Equal(u convert.Equaler) bool

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

func (WorkItemLinkCategory) TableName Uses

func (c WorkItemLinkCategory) TableName() string

TableName implements gorm.tabler

type WorkItemLinkCategoryRepository Uses

type WorkItemLinkCategoryRepository interface {
    repository.Exister
    Create(ctx context.Context, linkCat *WorkItemLinkCategory) (*WorkItemLinkCategory, error)
    Load(ctx context.Context, ID uuid.UUID) (*WorkItemLinkCategory, error)
    List(ctx context.Context) ([]WorkItemLinkCategory, error)
    Delete(ctx context.Context, ID uuid.UUID) error
    Save(ctx context.Context, linkCat WorkItemLinkCategory) (*WorkItemLinkCategory, error)
}

WorkItemLinkCategoryRepository encapsulates storage & retrieval of work item link categories

type WorkItemLinkRepository Uses

type WorkItemLinkRepository interface {
    repository.Exister
    Create(ctx context.Context, sourceID, targetID uuid.UUID, linkTypeID uuid.UUID, creatorID uuid.UUID) (*WorkItemLink, error)
    Load(ctx context.Context, ID uuid.UUID) (*WorkItemLink, error)
    List(ctx context.Context) ([]WorkItemLink, error)
    ListByWorkItem(ctx context.Context, wiID uuid.UUID) ([]WorkItemLink, error)
    DeleteRelatedLinks(ctx context.Context, wiID uuid.UUID, suppressorID uuid.UUID) error
    Delete(ctx context.Context, ID uuid.UUID, suppressorID uuid.UUID) error
    Save(ctx context.Context, linkCat WorkItemLink, modifierID uuid.UUID) (*WorkItemLink, error)
    ListWorkItemChildren(ctx context.Context, parentID uuid.UUID, start *int, limit *int) ([]workitem.WorkItem, uint64, error)
    WorkItemHasChildren(ctx context.Context, parentID uuid.UUID) (bool, error)
    GetParentID(ctx context.Context, ID uuid.UUID) (*uuid.UUID, error) // GetParentID returns parent ID of the given work item if any
}

WorkItemLinkRepository encapsulates storage & retrieval of work item links

type WorkItemLinkType Uses

type WorkItemLinkType struct {
    gormsupport.Lifecycle
    // ID
    ID  uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"`
    // Name is the unique name of this work item link type.
    Name string
    // Description is an optional description of the work item link type
    Description *string
    // Version for optimistic concurrency control
    Version  int
    Topology Topology

    ForwardName string
    ReverseName string

    LinkCategoryID uuid.UUID `sql:"type:uuid"`

    // Reference to one Space
    SpaceID uuid.UUID `sql:"type:uuid"`
}

WorkItemLinkType represents the type of a work item link as it is stored in the db

func (*WorkItemLinkType) CheckValidForCreation Uses

func (t *WorkItemLinkType) CheckValidForCreation() error

CheckValidForCreation returns an error if the work item link type cannot be used for the creation of a new work item link type.

func (WorkItemLinkType) Equal Uses

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

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

func (WorkItemLinkType) GetETagData Uses

func (t WorkItemLinkType) GetETagData() []interface{}

GetETagData returns the field values to use to generate the ETag

func (WorkItemLinkType) GetLastModified Uses

func (t WorkItemLinkType) GetLastModified() time.Time

GetLastModified returns the last modification time

func (WorkItemLinkType) TableName Uses

func (t WorkItemLinkType) TableName() string

TableName implements gorm.tabler

type WorkItemLinkTypeRepository Uses

type WorkItemLinkTypeRepository interface {
    repository.Exister
    Create(ctx context.Context, linkType *WorkItemLinkType) (*WorkItemLinkType, error)
    Load(ctx context.Context, ID uuid.UUID) (*WorkItemLinkType, error)
    List(ctx context.Context, spaceID uuid.UUID) ([]WorkItemLinkType, error)
    Delete(ctx context.Context, spaceID uuid.UUID, ID uuid.UUID) error
    Save(ctx context.Context, linkCat WorkItemLinkType) (*WorkItemLinkType, error)
}

WorkItemLinkTypeRepository encapsulates storage & retrieval of work item link types

Package link imports 16 packages (graph) and is imported by 24 packages. Updated 2017-10-27. Refresh now. Tools for package owners.