Documentation ¶
Overview ¶
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 ¶
- Constants
- Variables
- func CheckValidTopology(t string) error
- type GormWorkItemLinkCategoryRepository
- func (r *GormWorkItemLinkCategoryRepository) CheckExists(ctx context.Context, id string) error
- func (r *GormWorkItemLinkCategoryRepository) Create(ctx context.Context, linkCat *WorkItemLinkCategory) (*WorkItemLinkCategory, error)
- func (r *GormWorkItemLinkCategoryRepository) Delete(ctx context.Context, ID uuid.UUID) error
- func (r *GormWorkItemLinkCategoryRepository) List(ctx context.Context) ([]WorkItemLinkCategory, error)
- func (r *GormWorkItemLinkCategoryRepository) Load(ctx context.Context, ID uuid.UUID) (*WorkItemLinkCategory, error)
- func (r *GormWorkItemLinkCategoryRepository) Save(ctx context.Context, linkCat WorkItemLinkCategory) (*WorkItemLinkCategory, error)
- type GormWorkItemLinkRepository
- func (m *GormWorkItemLinkRepository) CheckExists(ctx context.Context, id string) error
- func (r *GormWorkItemLinkRepository) CheckParentExists(ctx context.Context, sourceID *uuid.UUID, targetID uuid.UUID, ...) (bool, error)
- func (r *GormWorkItemLinkRepository) Create(ctx context.Context, sourceID, targetID uuid.UUID, linkTypeID uuid.UUID, ...) (*WorkItemLink, error)
- func (r *GormWorkItemLinkRepository) CreateFromModel(ctx context.Context, link *WorkItemLink, creatorID uuid.UUID) error
- func (r *GormWorkItemLinkRepository) Delete(ctx context.Context, linkID uuid.UUID, suppressorID uuid.UUID) error
- func (r *GormWorkItemLinkRepository) DeleteRelatedLinks(ctx context.Context, wiID uuid.UUID, suppressorID uuid.UUID) error
- func (r *GormWorkItemLinkRepository) List(ctx context.Context) ([]WorkItemLink, error)
- func (r *GormWorkItemLinkRepository) ListByWorkItem(ctx context.Context, wiID uuid.UUID) ([]WorkItemLink, error)
- func (r *GormWorkItemLinkRepository) ListWorkItemChildren(ctx context.Context, parentID uuid.UUID, start *int, limit *int) ([]workitem.WorkItem, uint64, error)
- func (r *GormWorkItemLinkRepository) Load(ctx context.Context, ID uuid.UUID) (*WorkItemLink, error)
- func (r *GormWorkItemLinkRepository) Save(ctx context.Context, linkToSave WorkItemLink, modifierID uuid.UUID) (*WorkItemLink, error)
- func (r *GormWorkItemLinkRepository) ValidateTopology(ctx context.Context, sourceID *uuid.UUID, targetID uuid.UUID, ...) error
- func (r *GormWorkItemLinkRepository) WorkItemHasChildren(ctx context.Context, parentID uuid.UUID) (bool, error)
- type GormWorkItemLinkRevisionRepository
- type GormWorkItemLinkTypeRepository
- func (r *GormWorkItemLinkTypeRepository) CheckExists(ctx context.Context, id string) error
- func (r *GormWorkItemLinkTypeRepository) Create(ctx context.Context, linkType *WorkItemLinkType) (*WorkItemLinkType, error)
- func (r *GormWorkItemLinkTypeRepository) Delete(ctx context.Context, spaceID uuid.UUID, ID uuid.UUID) error
- func (r *GormWorkItemLinkTypeRepository) List(ctx context.Context, spaceID uuid.UUID) ([]WorkItemLinkType, error)
- func (r *GormWorkItemLinkTypeRepository) Load(ctx context.Context, ID uuid.UUID) (*WorkItemLinkType, error)
- func (r *GormWorkItemLinkTypeRepository) Save(ctx context.Context, modelToSave WorkItemLinkType) (*WorkItemLinkType, error)
- type Revision
- type RevisionRepository
- type RevisionType
- type WorkItemLink
- type WorkItemLinkCategory
- type WorkItemLinkCategoryRepository
- type WorkItemLinkRepository
- type WorkItemLinkType
- type WorkItemLinkTypeCombination
- func (tc *WorkItemLinkTypeCombination) CheckValidForCreation() error
- func (tc WorkItemLinkTypeCombination) Equal(u convert.Equaler) bool
- func (tc WorkItemLinkTypeCombination) GetETagData() []interface{}
- func (tc WorkItemLinkTypeCombination) GetLastModified() time.Time
- func (tc WorkItemLinkTypeCombination) TableName() string
- type WorkItemLinkTypeRepository
Constants ¶
const ( EndpointWorkItemTypes = "workitemtypes" EndpointWorkItems = "workitems" EndpointWorkItemLinkCategories = "workitemlinkcategories" EndpointWorkItemLinkTypes = "workitemlinktypes" EndpointWorkItemLinks = "workitemlinks" )
End points
const ( TopologyNetwork = "network" TopologyDirectedNetwork = "directed_network" TopologyDependency = "dependency" TopologyTree = "tree" )
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!!!
Functions ¶
func CheckValidTopology ¶
CheckValidTopology returns nil if the given topology is valid; otherwise a BadParameterError is returned.
Types ¶
type GormWorkItemLinkCategoryRepository ¶
type GormWorkItemLinkCategoryRepository struct {
// contains filtered or unexported fields
}
GormWorkItemLinkCategoryRepository implements WorkItemLinkCategoryRepository using gorm
func NewWorkItemLinkCategoryRepository ¶
func NewWorkItemLinkCategoryRepository(db *gorm.DB) *GormWorkItemLinkCategoryRepository
NewWorkItemLinkCategoryRepository creates a work item link category repository based on gorm
func (*GormWorkItemLinkCategoryRepository) CheckExists ¶
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 ¶
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 ¶
Delete deletes the work item link category with the given id returns NotFoundError or InternalError
func (*GormWorkItemLinkCategoryRepository) List ¶
func (r *GormWorkItemLinkCategoryRepository) List(ctx context.Context) ([]WorkItemLinkCategory, error)
List returns all work item link categories TODO: Handle pagination
func (*GormWorkItemLinkCategoryRepository) Load ¶
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 ¶
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 ¶
type GormWorkItemLinkRepository struct {
// contains filtered or unexported fields
}
GormWorkItemLinkRepository implements WorkItemLinkRepository using gorm
func NewWorkItemLinkRepository ¶
func NewWorkItemLinkRepository(db *gorm.DB) *GormWorkItemLinkRepository
NewWorkItemLinkRepository creates a work item link repository based on gorm
func (*GormWorkItemLinkRepository) CheckExists ¶
func (m *GormWorkItemLinkRepository) CheckExists(ctx context.Context, id string) error
CheckExists returns nil if the given ID exists otherwise returns an error
func (*GormWorkItemLinkRepository) CheckParentExists ¶
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 ¶
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) CreateFromModel ¶
func (r *GormWorkItemLinkRepository) CreateFromModel(ctx context.Context, link *WorkItemLink, creatorID uuid.UUID) error
func (*GormWorkItemLinkRepository) Delete ¶
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 (*GormWorkItemLinkRepository) DeleteRelatedLinks ¶
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) List ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
type GormWorkItemLinkRevisionRepository struct {
// contains filtered or unexported fields
}
GormCommentRevisionRepository implements CommentRevisionRepository using gorm
func NewRevisionRepository ¶
func NewRevisionRepository(db *gorm.DB) *GormWorkItemLinkRevisionRepository
NewRevisionRepository creates a GormCommentRevisionRepository
func (*GormWorkItemLinkRevisionRepository) Create ¶
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.
type GormWorkItemLinkTypeRepository ¶
type GormWorkItemLinkTypeRepository struct {
// contains filtered or unexported fields
}
GormWorkItemLinkTypeRepository implements WorkItemLinkTypeRepository using gorm
func NewWorkItemLinkTypeRepository ¶
func NewWorkItemLinkTypeRepository(db *gorm.DB) *GormWorkItemLinkTypeRepository
NewWorkItemLinkTypeRepository creates a work item link type repository based on gorm
func (*GormWorkItemLinkTypeRepository) CheckExists ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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
type RevisionRepository ¶
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 ¶
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 WorkItemLink ¶
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 ¶
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 ¶
func (l WorkItemLink) Equal(u convert.Equaler) bool
Equal returns true if two WorkItemLink objects are equal; otherwise false is returned.
func (WorkItemLink) GetETagData ¶
func (l WorkItemLink) GetETagData() []interface{}
GetETagData returns the field values to use to generate the ETag
func (WorkItemLink) GetLastModified ¶
func (l WorkItemLink) GetLastModified() time.Time
GetLastModified returns the last modification time
func (WorkItemLink) TableName ¶
func (l WorkItemLink) TableName() string
TableName implements gorm.tabler
type WorkItemLinkCategory ¶
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 ¶
func (c WorkItemLinkCategory) Equal(u convert.Equaler) bool
Equal returns true if two WorkItemLinkCategory objects are equal; otherwise false is returned.
func (WorkItemLinkCategory) TableName ¶
func (c WorkItemLinkCategory) TableName() string
TableName implements gorm.tabler
type WorkItemLinkCategoryRepository ¶
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 ¶
type WorkItemLinkRepository interface { repository.Exister Create(ctx context.Context, sourceID, targetID uuid.UUID, linkTypeID uuid.UUID, creatorID uuid.UUID) (*WorkItemLink, error) CreateFromModel(ctx context.Context, link *WorkItemLink, creatorID uuid.UUID) 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) }
WorkItemLinkRepository encapsulates storage & retrieval of work item links
type WorkItemLinkType ¶
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 string // Valid values: network, directed_network, dependency, tree 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 ¶
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 ¶
func (t WorkItemLinkType) Equal(u convert.Equaler) bool
Equal returns true if two WorkItemLinkType objects are equal; otherwise false is returned.
func (WorkItemLinkType) GetETagData ¶
func (t WorkItemLinkType) GetETagData() []interface{}
GetETagData returns the field values to use to generate the ETag
func (WorkItemLinkType) GetLastModified ¶
func (t WorkItemLinkType) GetLastModified() time.Time
GetLastModified returns the last modification time
func (WorkItemLinkType) TableName ¶
func (t WorkItemLinkType) TableName() string
TableName implements gorm.tabler
type WorkItemLinkTypeCombination ¶
type WorkItemLinkTypeCombination struct { gormsupport.Lifecycle ID uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"` // ID Version int // Version for optimistic concurrency control SpaceID uuid.UUID `sql:"type:uuid"` // Reference to one Space LinkTypeID uuid.UUID `sql:"type:uuid"` SourceTypeID uuid.UUID `sql:"type:uuid"` TargetTypeID uuid.UUID `sql:"type:uuid"` }
WorkItemLinkTypeCombination stores the allowed work item types for each link type
func (*WorkItemLinkTypeCombination) CheckValidForCreation ¶
func (tc *WorkItemLinkTypeCombination) CheckValidForCreation() error
CheckValidForCreation returns an error if the work item link WorkItemLinkTypeCombination cannot be used for the creation of a new work item link WorkItemLinkTypeCombination.
func (WorkItemLinkTypeCombination) Equal ¶
func (tc WorkItemLinkTypeCombination) Equal(u convert.Equaler) bool
Equal returns true if two WorkItemLinkTypeCombination objects are equal; otherwise false is returned.
func (WorkItemLinkTypeCombination) GetETagData ¶
func (tc WorkItemLinkTypeCombination) GetETagData() []interface{}
GetETagData returns the field values to use to generate the ETag
func (WorkItemLinkTypeCombination) GetLastModified ¶
func (tc WorkItemLinkTypeCombination) GetLastModified() time.Time
GetLastModified returns the last modification time
func (WorkItemLinkTypeCombination) TableName ¶
func (tc WorkItemLinkTypeCombination) TableName() string
TableName implements gorm.tabler
type WorkItemLinkTypeRepository ¶
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