link

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

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

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

End points

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

Variables

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

Never ever change these UUIDs!!!

View Source
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

func CheckValidTopology(t string) error

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) Create

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

List returns all work item link categories TODO: Handle pagination

func (*GormWorkItemLinkCategoryRepository) Load

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

func (*GormWorkItemLinkCategoryRepository) Save

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) CheckParentExists

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

CheckParentExists returns error if there is an attempt to create more than 1 parent of a workitem.

func (*GormWorkItemLinkRepository) Create

func (r *GormWorkItemLinkRepository) Create(ctx context.Context, sourceID, targetID uint64, 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

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, wiIDStr string, suppressorID uuid.UUID) error

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

func (*GormWorkItemLinkRepository) List

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) ListByWorkItemID

func (r *GormWorkItemLinkRepository) ListByWorkItemID(ctx context.Context, wiIDStr string) ([]WorkItemLink, error)

ListByWorkItemID 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, parent string) ([]workitem.WorkItem, error)

ListWorkItemChildren get all child work items

func (*GormWorkItemLinkRepository) Load

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) ValidateCorrectSourceAndTargetType

func (r *GormWorkItemLinkRepository) ValidateCorrectSourceAndTargetType(ctx context.Context, sourceID, targetID uint64, linkTypeID uuid.UUID) error

ValidateCorrectSourceAndTargetType returns an error if the Path of the source WIT as defined by the work item link type is not part of the actual source's WIT; the same applies for the target.

func (*GormWorkItemLinkRepository) ValidateTopology

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

func (*GormWorkItemLinkRepository) WorkItemHasChildren

func (r *GormWorkItemLinkRepository) WorkItemHasChildren(ctx context.Context, parent string) (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.

func (*GormWorkItemLinkRevisionRepository) List

List retrieves all revisions for a 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) Create

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

List returns all work item link types TODO: Handle pagination

func (*GormWorkItemLinkTypeRepository) ListSourceLinkTypes

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

func (*GormWorkItemLinkTypeRepository) ListTargetLinkTypes

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

func (*GormWorkItemLinkTypeRepository) Load

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

func (*GormWorkItemLinkTypeRepository) Save

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 uint64
	// the ID of the target of the work item link that changed
	WorkItemLinkTargetID uint64
	// 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

func (w Revision) TableName() string

TableName implements gorm.tabler

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 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   uint64
	TargetID   uint64
	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

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 {
	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 {
	Create(ctx context.Context, sourceID, targetID uint64, linkTypeID uuid.UUID, creatorID uuid.UUID) (*WorkItemLink, error)
	Load(ctx context.Context, ID uuid.UUID) (*WorkItemLink, error)
	List(ctx context.Context) ([]WorkItemLink, error)
	ListByWorkItemID(ctx context.Context, wiIDStr string) ([]WorkItemLink, error)
	DeleteRelatedLinks(ctx context.Context, wiIDStr string, 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, parent string) ([]workitem.WorkItem, error)
	WorkItemHasChildren(ctx context.Context, parent string) (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

	SourceTypeID uuid.UUID `sql:"type:uuid"`
	TargetTypeID uuid.UUID `sql:"type:uuid"`

	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 WorkItemLinkTypeRepository

type WorkItemLinkTypeRepository interface {
	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)
	// ListSourceLinkTypes returns the possible link types for where the given
	// WIT can be used in the source.
	ListSourceLinkTypes(ctx context.Context, witID uuid.UUID) ([]WorkItemLinkType, error)
	// ListSourceLinkTypes returns the possible link types for where the given
	// WIT can be used in the target.
	ListTargetLinkTypes(ctx context.Context, witID uuid.UUID) ([]WorkItemLinkType, error)
}

WorkItemLinkTypeRepository encapsulates storage & retrieval of work item link types

Jump to

Keyboard shortcuts

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