models

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnumType

type EnumType struct {
	SimpleType
	BaseType SimpleType
	Values   []interface{}
}

func (EnumType) ConvertFromModel

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

func (EnumType) ConvertToModel

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

type FieldDefinition

type FieldDefinition struct {
	Required bool
	Type     FieldType
}

FieldDefintion describes type & other restrictions of a field

func (FieldDefinition) ConvertFromModel

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

Convert from json storage to API form.

func (FieldDefinition) ConvertToModel

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

Convert a field value for storage as json. As the system matures, add more checks (for example whether a user is in the system, etc.)

func (FieldDefinition) MarshalJSON

func (self FieldDefinition) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler

func (*FieldDefinition) Scan

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

func (*FieldDefinition) UnmarshalJSON

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

UnmarshalJSON implements encoding/json.Unmarshaler

func (FieldDefinition) Value

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

type FieldType

type FieldType interface {
	GetKind() Kind
	/*
	   ConvertToModel converts a field value for use in the REST API
	*/
	ConvertToModel(value interface{}) (interface{}, error)
	/*
		ConvertToModel converts a field value for storage in the db
	*/
	ConvertFromModel(value interface{}) (interface{}, error)
}

FieldType describes the possible values of a FieldDefinition

type Fields

type Fields map[string]interface{}

func (*Fields) Scan

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

func (Fields) Value

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

type Kind

type Kind byte

Kind is the kind of field type

const (
	String            Kind = 1
	Integer           Kind = 2
	Float             Kind = 3
	Instant           Kind = 4
	Duration          Kind = 5
	Url               Kind = 6
	WorkitemReference Kind = 7
	User              Kind = 8
	Enum              Kind = 9
	List              Kind = 10
)

constants for describing possible field types

type ListType

type ListType struct {
	SimpleType
	ComponentType SimpleType
}

ListType describes a list of SimpleType values

func (ListType) ConvertFromModel

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

ConvertFromModel implements the FieldType interface

func (ListType) ConvertToModel

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

ConvertToModel implements the FieldType interface

type SimpleType

type SimpleType struct {
	Kind Kind
}

SimpleType is an unstructured FieldType

func (SimpleType) ConvertFromModel

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

ConvertFromModel implements the FieldType interface

func (SimpleType) ConvertToModel

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

ConvertToModel implements the FieldType interface

func (SimpleType) GetKind

func (self SimpleType) GetKind() Kind

GetKind implements FieldType

type WorkItem

type WorkItem struct {
	ID uint64 `gorm:"primary_key"`
	// User Readable Name of this item
	Name string
	// Id of the type of this work item
	Type string
	// Version for optimistic concurrency control
	Version int
	// the field values
	Fields Fields `sql:"type:jsonb"`
}

type WorkItemType

type WorkItemType struct {
	// internal id of this work item type
	Id uint64
	// the name of this work item type. Does not have to be unique.
	Name string
	// definitions of the fields this work item type supports
	Fields map[string]FieldDefinition `sql:"type:jsonb"`
}

Jump to

Keyboard shortcuts

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