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

package iteration

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

Package iteration provides all the required functions to manage the iterations over the work items.

Index

Package Files

doc.go iteration.go state.go

Constants

const (
    APIStringTypeIteration = "iterations"
    PathSepInService       = "/"
    PathSepInDatabase      = "."
    IterationActive        = true
    IterationNotActive     = false
)

Defines "type" string to be used while validating jsonapi spec based payload

type GormIterationRepository Uses

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

GormIterationRepository is the implementation of the storage interface for Iterations.

func (*GormIterationRepository) CanStart Uses

func (m *GormIterationRepository) CanStart(ctx context.Context, i *Iteration) (bool, error)

CanStart checks the rule - 1. Only one iteration from a space can have state=start at a time. 2. Root iteration of the space can not be started.(Hence can not be closed - via UI) Currently there is no State-machine for state transitions of iteraitons till then we will not allow user to start root iteration. More rules can be added as needed in this function

func (*GormIterationRepository) CheckExists Uses

func (m *GormIterationRepository) CheckExists(ctx context.Context, id uuid.UUID) error

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

func (*GormIterationRepository) Create Uses

func (m *GormIterationRepository) Create(ctx context.Context, u *Iteration) error

Create creates a new record.

func (*GormIterationRepository) Delete Uses

func (m *GormIterationRepository) Delete(ctx context.Context, ID uuid.UUID) error

Delete deletes the itertion with the given id returns NotFoundError or InternalError

func (*GormIterationRepository) List Uses

func (m *GormIterationRepository) List(ctx context.Context, spaceID uuid.UUID) ([]Iteration, error)

List all Iterations related to a single item

func (*GormIterationRepository) Load Uses

func (m *GormIterationRepository) Load(ctx context.Context, id uuid.UUID) (*Iteration, error)

Load a single Iteration regardless of parent

func (*GormIterationRepository) LoadChildren Uses

func (m *GormIterationRepository) LoadChildren(ctx context.Context, parentIterationID uuid.UUID) ([]Iteration, error)

LoadChildren executes - select * from iterations where path <@ 'parent_path.parent_id';

func (*GormIterationRepository) LoadMultiple Uses

func (m *GormIterationRepository) LoadMultiple(ctx context.Context, ids []uuid.UUID) ([]Iteration, error)

LoadMultiple returns multiple instances of iteration.Iteration

func (*GormIterationRepository) Root Uses

func (m *GormIterationRepository) Root(ctx context.Context, spaceID uuid.UUID) (*Iteration, error)

Root returns the Root Iteration for a space

func (*GormIterationRepository) Save Uses

func (m *GormIterationRepository) Save(ctx context.Context, i Iteration) (*Iteration, error)

Save updates the given iteration in the db. Version must be the same as the one in the stored version returns NotFoundError, VersionConflictError or InternalError

type Iteration Uses

type Iteration struct {
    gormsupport.Lifecycle
    ID          uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"` // This is the ID PK field
    SpaceID     uuid.UUID `sql:"type:uuid"`
    Path        path.Path
    StartAt     *time.Time
    EndAt       *time.Time
    Name        string
    Description *string
    State       State // this tells if iteration is currently running or not
    UserActive  bool
    // optional, private timestamp of the latest addition/removal of a relationship with this iteration
    // this field is used to generate the `ETag` and `Last-Modified` values in the HTTP responses and conditional requests processing
    RelationShipsChangedAt *time.Time `sql:"column:relationships_changed_at"`
}

Iteration describes a single iteration

func (*Iteration) FullPath Uses

func (m *Iteration) FullPath() string

FullPath returns the Path by appending self ID to it.

func (Iteration) GetETagData Uses

func (m Iteration) GetETagData() []interface{}

GetETagData returns the field values to use to generate the ETag

func (Iteration) GetLastModified Uses

func (m Iteration) GetLastModified() time.Time

GetLastModified returns the last modification time

func (*Iteration) IsActive Uses

func (m *Iteration) IsActive() bool

func (Iteration) IsRoot Uses

func (m Iteration) IsRoot(spaceID uuid.UUID) bool

IsRoot Checks if given iteration is a root iteration or not

func (*Iteration) MakeChildOf Uses

func (m *Iteration) MakeChildOf(parent Iteration)

MakeChildOf does all the path magic to make the current iteration a child of the given parent iteration.

func (Iteration) Parent Uses

func (m Iteration) Parent() uuid.UUID

Parent returns UUID of parent iteration or uuid.Nil handle root itearion case, leaf node case, intermediate case

func (Iteration) TableName Uses

func (m Iteration) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type Repository Uses

type Repository interface {
    repository.Exister
    Create(ctx context.Context, u *Iteration) error
    List(ctx context.Context, spaceID uuid.UUID) ([]Iteration, error)
    Root(ctx context.Context, spaceID uuid.UUID) (*Iteration, error)
    Load(ctx context.Context, id uuid.UUID) (*Iteration, error)
    Save(ctx context.Context, i Iteration) (*Iteration, error)
    CanStart(ctx context.Context, i *Iteration) (bool, error)
    LoadMultiple(ctx context.Context, ids []uuid.UUID) ([]Iteration, error)
    LoadChildren(ctx context.Context, parentIterationID uuid.UUID) ([]Iteration, error)
    Delete(ctx context.Context, ID uuid.UUID) error
}

Repository describes interactions with Iterations

func NewIterationRepository Uses

func NewIterationRepository(db *gorm.DB) Repository

NewIterationRepository creates a new storage type.

type State Uses

type State string

State defines an iterations state

const (
    // StateNew represents a new iteration
    StateNew State = "new"
    // StateStart represents a started iteration
    StateStart State = "start"
    // StateClose represents a closed iteration
    StateClose State = "close"
)

func (State) CheckValid Uses

func (s State) CheckValid() error

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

func (State) IsSet Uses

func (s State) IsSet() bool

IsSet returns true if no state is specified

func (*State) Scan Uses

func (s *State) 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 (State) String Uses

func (s State) String() string

String implements the Stringer interface

func (State) StringPtr Uses

func (s State) StringPtr() *string

StringPtr returns a pointer to the string

func (State) Value Uses

func (s State) Value() (driver.Value, error)

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

Package iteration imports 14 packages (graph) and is imported by 35 packages. Updated 2018-05-22. Refresh now. Tools for package owners.