json

package
v0.0.0-...-b7d8635 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// CollectionRisk identifier for the JSON collection of risks
	CollectionRisk = "risks"
	// CollectionMatrix identifier for the JSON collection of matrix
	CollectionMatrix = "matrix"
	// MediaPath identifier for the path of media files
	MediaPath = "media"
	// MediaResource is the resource ID to access the MediaPath in the storage
	MediaResource = "1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Risk

type Risk struct {
	ID             string `json:"id"`
	RiskMatrixID   int    `json:"risk_matrix_id"`
	Name           string `json:"name"`
	Probability    int    `json:"probability"`
	Impact         int    `json:"impact"`
	Classification string `json:"classification"`
	Strategy       string `json:"strategy"`
}

type RiskMatrix

type RiskMatrix struct {
	ID              int        `json:"id"`
	Path            string     `json:"path"`
	Project         string     `json:"project"`
	DateCreated     time.Time  `json:"date_created"`
	MatImgWidth     int        `json:"mat_img_width"`
	MatImgHeight    int        `json:"mat_img_height"`
	MatNrRows       int        `json:"mat_nr_rows"`
	MatNrCols       int        `json:"mat_nr_cols"`
	MatSize         int        `json:"mat_size"`
	BorderWidth     int        `json:"border_width"`
	Multiple        int        `json:"multiple"`
	WordHeight      int        `json:"word_height"`
	WordWidth       int        `json:"word_width"`
	HighRiskColor   color.RGBA `json:"high_risk_color"`
	MediumRiskColor color.RGBA `json:"medium_risk_color"`
	LowRiskColor    color.RGBA `json:"low_risk_color"`
	RiskLabelColor  color.RGBA `json:"risk_label_color"`
	BorderColor     color.RGBA `json:"border_color"`
}

type Storage

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

Json storage keeps data in json files

func NewStorage

func NewStorage() (*Storage, error)

NewStorage returns a new JSON storage

func (*Storage) AddRisk

func (s *Storage) AddRisk(r adding.Risk) error

AddRisk saves the given risk in the repository

func (*Storage) AddRiskMatrix

func (s *Storage) AddRiskMatrix(rm adding.RiskMatrix) error

AddRiskMatrix saves the given risk matrix in repository

func (*Storage) DeleteRisk

func (s *Storage) DeleteRisk(riskID string) error

DeleteRisk deletes a risk with the specified ID

func (*Storage) DeleteRiskMatrix

func (s *Storage) DeleteRiskMatrix(riskMatrixID int) error

DeleteMatrix deletes a risk matrix with the specified ID

func (*Storage) GetAllRiskMatrix

func (s *Storage) GetAllRiskMatrix() []listing.RiskMatrix

GetAllRiskMatrix returns all the risk matrix stored in the database

func (*Storage) GetAllRisks

func (s *Storage) GetAllRisks(riskMatrixID int) []listing.Risk

GetAllRisks returns all the risks for a given risk matrix

func (*Storage) GetMediaPath

func (s *Storage) GetMediaPath() (string, error)

GetMediaPath get the media path stored.

func (*Storage) GetRisk

func (s *Storage) GetRisk(riskID string) (listing.Risk, error)

GetRisk returns a risk with the given ID

func (*Storage) GetRiskMatrix

func (s *Storage) GetRiskMatrix(id int) (listing.RiskMatrix, error)

GetRiskMatrix returns a risk matrix with the specified ID

func (*Storage) GetRiskMatrixByPath

func (s *Storage) GetRiskMatrixByPath(p string) (listing.RiskMatrix, error)

GetRiskMatrixByPath returns a risk matrix with the specified image path

func (*Storage) SaveMediaPath

func (s *Storage) SaveMediaPath(path string) error

SaveMediaPath saves the given path that is going to be used to store media files, i.e., the risk matrix pictures.

func (*Storage) UpdateRiskMatrixSize

func (s *Storage) UpdateRiskMatrixSize(riskMatrixID, newSize int) error

UpdateRiskMatrixSize updates the risk matrix size of a given risk matrix in the repository

Jump to

Keyboard shortcuts

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