models

package
v2.0.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: GPL-3.0 Imports: 28 Imported by: 10

Documentation

Index

Constants

View Source
const CMR_CAS = `` /* 23819-byte string literal not displayed */

CMR_CAS is a list of product CAS numbers that are CMRs They are inserted into the database during its creation

View Source
const HAZARDSTATEMENT = `` /* 5625-byte string literal not displayed */

HAZARDSTATEMENT is the list of chemical products hazard statements They are inserted into the database during its creation

View Source
const PRECAUTIONARYSTATEMENT = `` /* 7220-byte string literal not displayed */

PRECAUTIONARYSTATEMENT is the list of chemical products precautionary statements They are inserted into the database during its creation

Variables

View Source
var CMR_H = map[string]string{
	"H340":   "M1",
	"H341":   "M2",
	"H350":   "C1",
	"H350i":  "C1",
	"H351":   "C2",
	"H360":   "R1",
	"H360F":  "R1",
	"H360D":  "R1",
	"H360Fd": "R1",
	"H360Df": "R1",
	"H360FD": "R1",
	"H361":   "R2",
	"H361f":  "R2",
	"H361d":  "R2",
	"H361fd": "R2",
	"H362":   "L",
}

CMR_H is a list of H phrases that are CMRs They are NOT inserted into the database

Functions

func ProductsToCSV

func ProductsToCSV(prs []Product) string

ProductsToCSV returns a file name of the products prs exported into CSV

func StoragesToCSV

func StoragesToCSV(sts []Storage) string

StoragesToCSV returns a file name of the products prs exported into CSV

Types

type AppHandlerFunc

type AppHandlerFunc func(http.ResponseWriter, *http.Request) *helpers.AppError

AppHandlerFunc is an HandlerFunc returning an AppError

type Bookmark

type Bookmark struct {
	BookmarkID sql.NullInt64 `db:"bookmark_id" json:"bookmark_id" schema:"bookmark_id"`
	Person     `db:"person" json:"person" schema:"person"`
	Product    `db:"product" json:"product" schema:"product"`
}

Bookmark is a product person bookmark

type Borrowing

type Borrowing struct {
	BorrowingID      sql.NullInt64                               `db:"borrowing_id" json:"borrowing_id" schema:"borrowing_id"`
	BorrowingComment sql.NullString                              `db:"borrowing_comment" json:"borrowing_comment" schema:"borrowing_comment"`
	Person           `db:"person" json:"person" schema:"person"` // logged person
	Storage          `db:"storage" json:"storage" schema:"storage"`
	Borrower         *Person `db:"borrower" json:"borrower" schema:"borrower"` // logged person
}

Borrowing represent a storage borrowing

func (Borrowing) String

func (b Borrowing) String() string

type CasNumber

type CasNumber struct {
	C              int            `db:"c" json:"c"` // not stored in db but db:"c" set for sqlx
	CasNumberID    int            `db:"casnumber_id" json:"casnumber_id" schema:"casnumber_id"`
	CasNumberLabel string         `db:"casnumber_label" json:"casnumber_label" schema:"casnumber_label"`
	CasNumberCMR   sql.NullString `db:"casnumber_cmr" json:"casnumber_cmr" schema:"casnumber_cmr"`
}

CasNumber is a product CAS number

func (CasNumber) String

func (c CasNumber) String() string

type CeNumber

type CeNumber struct {
	C             int            `db:"c" json:"c"` // not stored in db but db:"c" set for sqlx
	CeNumberID    sql.NullInt64  `db:"cenumber_id" json:"cenumber_id" schema:"cenumber_id"`
	CeNumberLabel sql.NullString `db:"cenumber_label" json:"cenumber_label" schema:"cenumber_label"`
}

CeNumber is a product CE number

func (CeNumber) String

func (c CeNumber) String() string

type ClassOfCompound

type ClassOfCompound struct {
	// nullable values to handle optional Product foreign key (gorilla shema nil values)
	C                    int    `db:"c" json:"c"` // not stored in db but db:"c" set for sqlx
	ClassOfCompoundID    int    `db:"classofcompound_id" json:"classofcompound_id" schema:"classofcompound_id"`
	ClassOfCompoundLabel string `db:"classofcompound_label" json:"classofcompound_label" schema:"classofcompound_label"`
}

ClassOfCompound is a product class of compound

type Datastore

type Datastore interface {
	CreateDatabase() error
	ImportV1(dir string) error
	Import(url string) error

	// welcome announce
	GetWelcomeAnnounce() (WelcomeAnnounce, error)
	UpdateWelcomeAnnounce(w WelcomeAnnounce) error

	// products
	GetExposedProducts() ([]Product, int, error)
	GetProducts(helpers.DbselectparamProduct) ([]Product, int, error)

	GetProductsCasNumbers(helpers.Dbselectparam) ([]CasNumber, int, error)
	GetProductsCasNumber(id int) (CasNumber, error)
	GetProductsCasNumberByLabel(label string) (CasNumber, error)

	GetProductsCeNumbers(helpers.Dbselectparam) ([]CeNumber, int, error)
	GetProductsCeNumberByLabel(label string) (CeNumber, error)

	GetProductsNames(helpers.Dbselectparam) ([]Name, int, error)
	GetProductsName(id int) (Name, error)
	GetProductsNameByLabel(label string) (Name, error)

	GetProductsSymbols(helpers.Dbselectparam) ([]Symbol, int, error)
	GetProductsSymbol(id int) (Symbol, error)
	GetProductsSymbolByLabel(label string) (Symbol, error)

	GetProductsEmpiricalFormulas(helpers.Dbselectparam) ([]EmpiricalFormula, int, error)
	GetProductsEmpiricalFormula(id int) (EmpiricalFormula, error)
	GetProductsEmpiricalFormulaByLabel(label string) (EmpiricalFormula, error)

	GetProductsLinearFormulas(helpers.Dbselectparam) ([]LinearFormula, int, error)
	GetProductsLinearFormulaByLabel(label string) (LinearFormula, error)

	GetProductsPhysicalStates(helpers.Dbselectparam) ([]PhysicalState, int, error)
	GetProductsPhysicalStateByLabel(label string) (PhysicalState, error)

	GetProductsSignalWords(helpers.Dbselectparam) ([]SignalWord, int, error)
	GetProductsSignalWord(id int) (SignalWord, error)
	GetProductsSignalWordByLabel(label string) (SignalWord, error)

	GetProductsClassOfCompounds(helpers.Dbselectparam) ([]ClassOfCompound, int, error)
	GetProductsClassOfCompoundByLabel(label string) (ClassOfCompound, error)

	GetProductsHazardStatementByReference(string) (HazardStatement, error)
	GetProductsHazardStatements(helpers.Dbselectparam) ([]HazardStatement, int, error)
	GetProductsHazardStatement(id int) (HazardStatement, error)

	GetProductsPrecautionaryStatementByReference(string) (PrecautionaryStatement, error)
	GetProductsPrecautionaryStatements(helpers.Dbselectparam) ([]PrecautionaryStatement, int, error)
	GetProductsPrecautionaryStatement(id int) (PrecautionaryStatement, error)

	GetProduct(id int) (Product, error)
	CountProductStorages(id int) (int, error)
	DeleteProduct(id int) error
	CreateProduct(p Product) (int, error)
	UpdateProduct(p Product) error
	CreateProductBookmark(pr Product, pe Person) error
	DeleteProductBookmark(pr Product, pe Person) error
	IsProductBookmark(pr Product, pe Person) (bool, error)

	// storages
	GetStorages(helpers.DbselectparamStorage) ([]Storage, int, error)
	GetOtherStorages(helpers.DbselectparamStorage) ([]Entity, int, error)
	GetStorage(id int) (Storage, error)
	GetStoragesUnits(helpers.Dbselectparam) ([]Unit, int, error)
	GetStoragesSuppliers(helpers.Dbselectparam) ([]Supplier, int, error)
	GetStorageEntity(id int) (Entity, error)
	DeleteStorage(id int) error
	ArchiveStorage(id int) error
	RestoreStorage(id int) error
	CreateStorage(s Storage) (int, error)
	UpdateStorage(s Storage) error
	GenerateAndUpdateStorageBarecode(s *Storage) error
	IsStorageBorrowing(b Borrowing) (bool, error)
	CreateStorageBorrowing(b Borrowing) error
	DeleteStorageBorrowing(b Borrowing) error
	UpdateAllQRCodes() error

	// store locations
	GetStoreLocations(helpers.DbselectparamStoreLocation) ([]StoreLocation, int, error)
	GetStoreLocation(id int) (StoreLocation, error)
	GetStoreLocationChildren(id int) ([]StoreLocation, error)
	GetStoreLocationEntity(id int) (Entity, error)
	DeleteStoreLocation(id int) error
	CreateStoreLocation(s StoreLocation) (int, error)
	UpdateStoreLocation(s StoreLocation) error
	IsStoreLocationEmpty(id int) (bool, error)
	ComputeStockStorelocation(p Product, s *StoreLocation, u Unit) float64

	// entities
	ComputeStockEntity(p Product, r *http.Request) []StoreLocation

	GetEntities(helpers.DbselectparamEntity) ([]Entity, int, error)
	GetEntity(id int) (Entity, error)
	GetEntityPeople(id int) ([]Person, error)
	DeleteEntity(id int) error
	CreateEntity(e Entity) (int, error)
	UpdateEntity(e Entity) error
	IsEntityEmpty(id int) (bool, error)
	HasEntityNoStorelocation(id int) (bool, error)

	// people
	GetPeople(helpers.DbselectparamPerson) ([]Person, int, error)
	GetPerson(id int) (Person, error)
	GetPersonByEmail(email string) (Person, error)
	GetPersonPermissions(id int) ([]Permission, error)
	GetPersonEntities(loggedpersonID int, id int) ([]Entity, error)
	GetPersonManageEntities(id int) ([]Entity, error)
	DoesPersonBelongsTo(id int, entities []Entity) (bool, error)
	HasPersonPermission(id int, perm string, item string, eids []int) (bool, error)
	CreatePerson(p Person) (int, error)
	UpdatePerson(p Person) error
	UpdatePersonPassword(p Person) error
	DeletePerson(id int) error
	GetAdmins() ([]Person, error)
	IsPersonAdmin(id int) (bool, error)
	UnsetPersonAdmin(id int) error
	SetPersonAdmin(id int) error
	IsPersonManager(id int) (bool, error)

	// captcha
	InsertCaptcha(*captcha.Data) (string, error)
	ValidateCaptcha(token string, text string) (bool, error)
}

Datastore is an interface to be implemented to store data

type EmpiricalFormula

type EmpiricalFormula struct {
	C                     int    `db:"c" json:"c"` // not stored in db but db:"c" set for sqlx
	EmpiricalFormulaID    int    `db:"empiricalformula_id" json:"empiricalformula_id" schema:"empiricalformula_id"`
	EmpiricalFormulaLabel string `db:"empiricalformula_label" json:"empiricalformula_label" schema:"empiricalformula_label"`
}

EmpiricalFormula is a product empirical formula

type Entity

type Entity struct {
	EntityID          int      `db:"entity_id" json:"entity_id" schema:"entity_id"`
	EntityName        string   `db:"entity_name" json:"entity_name" schema:"entity_name"`
	EntityDescription string   `db:"entity_description" json:"entity_description" schema:"entity_description"`
	Managers          []Person `db:"-" json:"managers" schema:"managers"`

	// total store location count
	EntitySLC int `db:"entity_slc" json:"entity_slc" schema:"entity_slc"` // not in db but sqlx requires the "db" entry
	// total person count
	EntityPC int `db:"entity_pc" json:"entity_pc" schema:"entity_pc"` // not in db but sqlx requires the "db" entry
}

Entity represent a department, a laboratory...

type HazardStatement

type HazardStatement struct {
	HazardStatementID        int            `db:"hazardstatement_id" json:"hazardstatement_id" schema:"hazardstatement_id"`
	HazardStatementLabel     string         `db:"hazardstatement_label" json:"hazardstatement_label" schema:"hazardstatement_label"`
	HazardStatementReference string         `db:"hazardstatement_reference" json:"hazardstatement_reference" schema:"hazardstatement_reference"`
	HazardStatementCMR       sql.NullString `db:"hazardstatement_cmr" json:"hazardstatement_cmr" schema:"hazardstatement_cmr"`
}

HazardStatement is a product hazard statement

type LinearFormula

type LinearFormula struct {
	C                  int            `db:"c" json:"c"` // not stored in db but db:"c" set for sqlx
	LinearFormulaID    sql.NullInt64  `db:"linearformula_id" json:"linearformula_id" schema:"linearformula_id"`
	LinearFormulaLabel sql.NullString `db:"linearformula_label" json:"linearformula_label" schema:"linearformula_label"`
}

LinearFormula is a product linear formula

type Name

type Name struct {
	C         int    `db:"c" json:"c"` // not stored in db but db:"c" set for sqlx
	NameID    int    `db:"name_id" json:"name_id" schema:"name_id"`
	NameLabel string `db:"name_label" json:"name_label" schema:"name_label"`
}

Name is a product name

type Permission

type Permission struct {
	PermissionID       int    `db:"permission_id" json:"permission_id"`
	PermissionPermName string `db:"permission_perm_name" json:"permission_perm_name" schema:"permission_perm_name"` // ex: r
	PermissionItemName string `db:"permission_item_name" json:"permission_item_name" schema:"permission_item_name"` // ex: entity
	PermissionEntityID int    `db:"permission_entity_id" json:"permission_entity_id" schema:"permission_entity_id"` // ex: 8
	Person             `db:"person" json:"person"`
}

Permission represent who is able to do what on something

func (Permission) String

func (p Permission) String() string

type Person

type Person struct {
	PersonID       int          `db:"person_id" json:"person_id" schema:"person_id"`
	PersonEmail    string       `db:"person_email" json:"person_email" schema:"person_email"`
	PersonPassword string       `db:"person_password" json:"person_password" schema:"person_password"`
	Permissions    []Permission `db:"-" schema:"permissions"`
	Entities       []Entity     `db:"-" schema:"entities"`
	CaptchaText    string       `db:"-" schema:"captcha_text"`
	CaptchaUID     string       `db:"-" schema:"captcha_uid"`
}

Person represent a person

func (Person) String

func (p Person) String() string

type PhysicalState

type PhysicalState struct {
	// nullable values to handle optional Product foreign key (gorilla shema nil values)
	C                  int            `db:"c" json:"c"` // not stored in db but db:"c" set for sqlx
	PhysicalStateID    sql.NullInt64  `db:"physicalstate_id" json:"physicalstate_id" schema:"physicalstate_id"`
	PhysicalStateLabel sql.NullString `db:"physicalstate_label" json:"physicalstate_label" schema:"physicalstate_label"`
}

PhysicalState is a product physical state

type PrecautionaryStatement

type PrecautionaryStatement struct {
	PrecautionaryStatementID        int    `db:"precautionarystatement_id" json:"precautionarystatement_id" schema:"precautionarystatement_id"`
	PrecautionaryStatementLabel     string `db:"precautionarystatement_label" json:"precautionarystatement_label" schema:"precautionarystatement_label"`
	PrecautionaryStatementReference string `db:"precautionarystatement_reference" json:"precautionarystatement_reference" schema:"precautionarystatement_reference"`
}

PrecautionaryStatement is a product precautionary statement

type Product

type Product struct {
	ProductID               int            `db:"product_id" json:"product_id" schema:"product_id"`
	ProductSpecificity      sql.NullString `db:"product_specificity" json:"product_specificity" schema:"product_specificity"`
	ProductMSDS             sql.NullString `db:"product_msds" json:"product_msds" schema:"product_msds"`
	ProductRestricted       sql.NullBool   `db:"product_restricted" json:"product_restricted" schema:"product_restricted"`
	ProductRadioactive      sql.NullBool   `db:"product_radioactive" json:"product_radioactive" schema:"product_radioactive"`
	ProductThreeDFormula    sql.NullString `db:"product_threedformula" json:"product_threedformula" schema:"product_threedformula"`
	ProductMolFormula       sql.NullString `db:"product_molformula" json:"product_molformula" schema:"product_molformula"`
	ProductDisposalComment  sql.NullString `db:"product_disposalcomment" json:"product_disposalcomment" schema:"product_disposalcomment"`
	ProductRemark           sql.NullString `db:"product_remark" json:"product_remark" schema:"product_remark"`
	EmpiricalFormula        `db:"empiricalformula" json:"empiricalformula" schema:"empiricalformula"`
	LinearFormula           `db:"linearformula" json:"linearformula" schema:"linearformula"`
	PhysicalState           `db:"physicalstate" json:"physicalstate" schema:"physicalstate"`
	SignalWord              `db:"signalword" json:"signalword" schema:"signalword"`
	Person                  `db:"person" json:"person" schema:"person"`
	CasNumber               `db:"casnumber" json:"casnumber" schema:"casnumber"`
	CeNumber                `db:"cenumber" json:"cenumber" schema:"cenumber"`
	Name                    `db:"name" json:"name" schema:"name"`
	ClassOfCompound         []ClassOfCompound        `db:"-" schema:"classofcompound" json:"classofcompound"`
	Synonyms                []Name                   `db:"-" schema:"synonyms" json:"synonyms"`
	Symbols                 []Symbol                 `db:"-" schema:"symbols" json:"symbols"`
	HazardStatements        []HazardStatement        `db:"-" schema:"hazardstatements" json:"hazardstatements"`
	PrecautionaryStatements []PrecautionaryStatement `db:"-" schema:"precautionarystatements" json:"precautionarystatements"`

	Bookmark *Bookmark `db:"bookmark" json:"bookmark" schema:"bookmark"` // not in db but sqlx requires the "db" entry

	// total storage count
	ProductTSC int `db:"product_tsc" json:"product_tsc" schema:"product_tsc"` // not in db but sqlx requires the "db" entry
	// storage count in the logged user entity(ies)
	ProductSC int `db:"product_sc" json:"product_sc" schema:"product_sc"` // not in db but sqlx requires the "db" entry
	// storage barecode concatenation
	ProductSL sql.NullString `db:"product_sl" json:"product_sl" schema:"product_sl"` // not in db but sqlx requires the "db" entry
	// hazard statement CMR concatenation
	HazardStatementCMR sql.NullString `db:"hazardstatement_cmr" json:"hazardstatement_cmr" schema:"hazardstatement_cmr"` // not in db but sqlx requires the "db" entry
}

Product is a chemical product card

func (Product) String

func (p Product) String() string

type SQLiteDataStore

type SQLiteDataStore struct {
	*sqlx.DB
}

SQLiteDataStore implements the Datastore interface to store data in SQLite3

func NewSQLiteDBstore

func NewSQLiteDBstore(dataSourceName string) (*SQLiteDataStore, error)

NewSQLiteDBstore returns a database connection to the given dataSourceName ie. a path to the sqlite database file

func (*SQLiteDataStore) ArchiveStorage

func (db *SQLiteDataStore) ArchiveStorage(id int) error

ArchiveStorage archives the storages with the given id

func (*SQLiteDataStore) ComputeStockEntity

func (db *SQLiteDataStore) ComputeStockEntity(p Product, r *http.Request) []StoreLocation

ComputeStockEntity returns the root store locations of the entity(ies) of the loggued user. Each store location has a Stocks []Stock field containing the stocks of the product p for each unit

func (*SQLiteDataStore) ComputeStockStorelocation

func (db *SQLiteDataStore) ComputeStockStorelocation(p Product, s *StoreLocation, u Unit) float64

ComputeStockStorelocation returns the quantity of product p in the store location s for the unit u

func (*SQLiteDataStore) ComputeStockStorelocationNoUnit

func (db *SQLiteDataStore) ComputeStockStorelocationNoUnit(p Product, s *StoreLocation) float64

ComputeStockStorelocationNoUnit returns the quantity of product p with no unit in the store location s

func (*SQLiteDataStore) CountProductStorages

func (db *SQLiteDataStore) CountProductStorages(id int) (int, error)

CountProductStorages returns the number of storages for the product with the given id

func (*SQLiteDataStore) CreateDatabase

func (db *SQLiteDataStore) CreateDatabase() error

CreateDatabase creates the database tables

func (*SQLiteDataStore) CreateEntity

func (db *SQLiteDataStore) CreateEntity(e Entity) (int, error)

CreateEntity creates the given entity

func (*SQLiteDataStore) CreatePerson

func (db *SQLiteDataStore) CreatePerson(p Person) (int, error)

CreatePerson creates the given person

func (*SQLiteDataStore) CreateProduct

func (db *SQLiteDataStore) CreateProduct(p Product) (int, error)

CreateProduct insert the new product p into the database

func (*SQLiteDataStore) CreateProductBookmark

func (db *SQLiteDataStore) CreateProductBookmark(pr Product, pe Person) error

CreateProductBookmark bookmarks the product pr for the person pe

func (*SQLiteDataStore) CreateStorage

func (db *SQLiteDataStore) CreateStorage(s Storage) (int, error)

CreateStorage creates a new storage

func (*SQLiteDataStore) CreateStorageBorrowing

func (db *SQLiteDataStore) CreateStorageBorrowing(b Borrowing) error

CreateStorageBorrowing creates the borrowing b

func (*SQLiteDataStore) CreateStoreLocation

func (db *SQLiteDataStore) CreateStoreLocation(s StoreLocation) (int, error)

CreateStoreLocation creates the given store location

func (*SQLiteDataStore) DeleteEntity

func (db *SQLiteDataStore) DeleteEntity(id int) error

DeleteEntity deletes the entity with id "id"

func (*SQLiteDataStore) DeletePerson

func (db *SQLiteDataStore) DeletePerson(id int) error

DeletePerson deletes the person with id "id"

func (*SQLiteDataStore) DeleteProduct

func (db *SQLiteDataStore) DeleteProduct(id int) error

DeleteProduct deletes the product with the given id

func (*SQLiteDataStore) DeleteProductBookmark

func (db *SQLiteDataStore) DeleteProductBookmark(pr Product, pe Person) error

DeleteProductBookmark remove the bookmark for the product pr and the person pe

func (*SQLiteDataStore) DeleteStorage

func (db *SQLiteDataStore) DeleteStorage(id int) error

DeleteStorage deletes the storages with the given id

func (*SQLiteDataStore) DeleteStorageBorrowing

func (db *SQLiteDataStore) DeleteStorageBorrowing(b Borrowing) error

DeleteStorageBorrowing deletes the borrowing b

func (*SQLiteDataStore) DeleteStoreLocation

func (db *SQLiteDataStore) DeleteStoreLocation(id int) error

DeleteStoreLocation deletes the store location with id "id"

func (*SQLiteDataStore) DoesPersonBelongsTo

func (db *SQLiteDataStore) DoesPersonBelongsTo(id int, entities []Entity) (bool, error)

DoesPersonBelongsTo returns true if the person (with id "id") belongs to the entities

func (*SQLiteDataStore) GenerateAndUpdateStorageBarecode

func (db *SQLiteDataStore) GenerateAndUpdateStorageBarecode(s *Storage) error

GenerateAndUpdateStorageBarecode generate and set a barecode for the storage s the barecode is [prefix]major.minor with prefix: extracted from the storelocation name [prefix]storelocation_name, or "" major: unique uid identical for the differents storages of the same product in an entity minor: incremental number for the differents storages of the same product in an entity

func (*SQLiteDataStore) GetAdmins

func (db *SQLiteDataStore) GetAdmins() ([]Person, error)

GetAdmins returns the administrators

func (*SQLiteDataStore) GetEntities

func (db *SQLiteDataStore) GetEntities(p helpers.DbselectparamEntity) ([]Entity, int, error)

GetEntities returns the entities matching the search criteria order, offset and limit are passed to the sql request

func (*SQLiteDataStore) GetEntity

func (db *SQLiteDataStore) GetEntity(id int) (Entity, error)

GetEntity returns the entity with id "id"

func (*SQLiteDataStore) GetEntityPeople

func (db *SQLiteDataStore) GetEntityPeople(id int) ([]Person, error)

GetEntityPeople returns the entity (with id "id") managers

func (*SQLiteDataStore) GetExposedProducts

func (db *SQLiteDataStore) GetExposedProducts() ([]Product, int, error)

GetExposedProducts return all the products

func (*SQLiteDataStore) GetOtherStorages

func (db *SQLiteDataStore) GetOtherStorages(p helpers.DbselectparamStorage) ([]Entity, int, error)

GetOtherStorages returns the entity manager(s) email of the entities storing the product with the id passed in the request parameters p

func (*SQLiteDataStore) GetPeople

func (db *SQLiteDataStore) GetPeople(p helpers.DbselectparamPerson) ([]Person, int, error)

GetPeople returns the people matching the search criteria order, offset and limit are passed to the sql request

func (*SQLiteDataStore) GetPerson

func (db *SQLiteDataStore) GetPerson(id int) (Person, error)

GetPerson returns the person with id "id"

func (*SQLiteDataStore) GetPersonByEmail

func (db *SQLiteDataStore) GetPersonByEmail(email string) (Person, error)

GetPersonByEmail returns the person with email "email"

func (*SQLiteDataStore) GetPersonEntities

func (db *SQLiteDataStore) GetPersonEntities(LoggedPersonID int, id int) ([]Entity, error)

GetPersonEntities returns the person (with id "id") entities

func (*SQLiteDataStore) GetPersonManageEntities

func (db *SQLiteDataStore) GetPersonManageEntities(id int) ([]Entity, error)

GetPersonManageEntities returns the entities the person (with id "id") if manager of

func (*SQLiteDataStore) GetPersonPermissions

func (db *SQLiteDataStore) GetPersonPermissions(id int) ([]Permission, error)

GetPersonPermissions returns the person (with id "id") permissions

func (*SQLiteDataStore) GetProduct

func (db *SQLiteDataStore) GetProduct(id int) (Product, error)

GetProduct returns the product with the given id

func (*SQLiteDataStore) GetProducts

func (db *SQLiteDataStore) GetProducts(p helpers.DbselectparamProduct) ([]Product, int, error)

GetProducts return the products matching the search criteria

func (*SQLiteDataStore) GetProductsCasNumber

func (db *SQLiteDataStore) GetProductsCasNumber(id int) (CasNumber, error)

GetProductsCasNumber return the cas numbers matching the given id

func (*SQLiteDataStore) GetProductsCasNumberByLabel

func (db *SQLiteDataStore) GetProductsCasNumberByLabel(label string) (CasNumber, error)

GetProductsCasNumberByLabel return the cas numbers matching the given cas number

func (*SQLiteDataStore) GetProductsCasNumbers

func (db *SQLiteDataStore) GetProductsCasNumbers(p helpers.Dbselectparam) ([]CasNumber, int, error)

GetProductsCasNumbers return the cas numbers matching the search criteria

func (*SQLiteDataStore) GetProductsCeNumberByLabel

func (db *SQLiteDataStore) GetProductsCeNumberByLabel(label string) (CeNumber, error)

GetProductsCeNumberByLabel return the ce numbers matching the given ce number

func (*SQLiteDataStore) GetProductsCeNumbers

func (db *SQLiteDataStore) GetProductsCeNumbers(p helpers.Dbselectparam) ([]CeNumber, int, error)

GetProductsCeNumbers return the cas numbers matching the search criteria

func (*SQLiteDataStore) GetProductsClassOfCompoundByLabel

func (db *SQLiteDataStore) GetProductsClassOfCompoundByLabel(label string) (ClassOfCompound, error)

GetProductsClassOfCompoundByLabel return the class of compounds matching the given label

func (*SQLiteDataStore) GetProductsClassOfCompounds

func (db *SQLiteDataStore) GetProductsClassOfCompounds(p helpers.Dbselectparam) ([]ClassOfCompound, int, error)

GetProductsClassOfCompounds return the classe of compounds matching the search criteria

func (*SQLiteDataStore) GetProductsEmpiricalFormula

func (db *SQLiteDataStore) GetProductsEmpiricalFormula(id int) (EmpiricalFormula, error)

GetProductsEmpiricalFormula return the formula matching the given id

func (*SQLiteDataStore) GetProductsEmpiricalFormulaByLabel

func (db *SQLiteDataStore) GetProductsEmpiricalFormulaByLabel(label string) (EmpiricalFormula, error)

GetProductsEmpiricalFormulaByLabel return the empirirical formula matching the given empirical formula

func (*SQLiteDataStore) GetProductsEmpiricalFormulas

func (db *SQLiteDataStore) GetProductsEmpiricalFormulas(p helpers.Dbselectparam) ([]EmpiricalFormula, int, error)

GetProductsEmpiricalFormulas return the empirical formulas matching the search criteria

func (*SQLiteDataStore) GetProductsHazardStatement

func (db *SQLiteDataStore) GetProductsHazardStatement(id int) (HazardStatement, error)

GetProductsHazardStatement return the HazardStatement matching the given id

func (*SQLiteDataStore) GetProductsHazardStatementByReference

func (db *SQLiteDataStore) GetProductsHazardStatementByReference(r string) (HazardStatement, error)

GetProductsHazardStatementByReference return the hazard statement matching the reference

func (*SQLiteDataStore) GetProductsHazardStatements

func (db *SQLiteDataStore) GetProductsHazardStatements(p helpers.Dbselectparam) ([]HazardStatement, int, error)

GetProductsHazardStatements return the hazard statements matching the search criteria

func (*SQLiteDataStore) GetProductsLinearFormulaByLabel

func (db *SQLiteDataStore) GetProductsLinearFormulaByLabel(label string) (LinearFormula, error)

GetProductsLinearFormulaByLabel return the linear formula matching the given linear formula

func (*SQLiteDataStore) GetProductsLinearFormulas

func (db *SQLiteDataStore) GetProductsLinearFormulas(p helpers.Dbselectparam) ([]LinearFormula, int, error)

GetProductsLinearFormulas return the empirical formulas matching the search criteria

func (*SQLiteDataStore) GetProductsName

func (db *SQLiteDataStore) GetProductsName(id int) (Name, error)

GetProductsName return the name matching the given id

func (*SQLiteDataStore) GetProductsNameByLabel

func (db *SQLiteDataStore) GetProductsNameByLabel(label string) (Name, error)

GetProductsNameByLabel return the name matching the given label

func (*SQLiteDataStore) GetProductsNames

func (db *SQLiteDataStore) GetProductsNames(p helpers.Dbselectparam) ([]Name, int, error)

GetProductsNames return the names matching the search criteria

func (*SQLiteDataStore) GetProductsPhysicalStateByLabel

func (db *SQLiteDataStore) GetProductsPhysicalStateByLabel(label string) (PhysicalState, error)

GetProductsPhysicalStateByLabel return the physical state matching the given label

func (*SQLiteDataStore) GetProductsPhysicalStates

func (db *SQLiteDataStore) GetProductsPhysicalStates(p helpers.Dbselectparam) ([]PhysicalState, int, error)

GetProductsPhysicalStates return the physical states matching the search criteria

func (*SQLiteDataStore) GetProductsPrecautionaryStatement

func (db *SQLiteDataStore) GetProductsPrecautionaryStatement(id int) (PrecautionaryStatement, error)

GetProductsPrecautionaryStatement return the PrecautionaryStatement matching the given id

func (*SQLiteDataStore) GetProductsPrecautionaryStatementByReference

func (db *SQLiteDataStore) GetProductsPrecautionaryStatementByReference(r string) (PrecautionaryStatement, error)

GetProductsPrecautionaryStatementByReference return the precautionary statement matching the reference

func (*SQLiteDataStore) GetProductsPrecautionaryStatements

func (db *SQLiteDataStore) GetProductsPrecautionaryStatements(p helpers.Dbselectparam) ([]PrecautionaryStatement, int, error)

GetProductsPrecautionaryStatements return the hazard statements matching the search criteria

func (*SQLiteDataStore) GetProductsSignalWord

func (db *SQLiteDataStore) GetProductsSignalWord(id int) (SignalWord, error)

GetProductsSignalWord return the signalword matching the given id

func (*SQLiteDataStore) GetProductsSignalWordByLabel

func (db *SQLiteDataStore) GetProductsSignalWordByLabel(label string) (SignalWord, error)

GetProductsSignalWordByLabel return the signal word matching the given label

func (*SQLiteDataStore) GetProductsSignalWords

func (db *SQLiteDataStore) GetProductsSignalWords(p helpers.Dbselectparam) ([]SignalWord, int, error)

GetProductsSignalWords return the signal words matching the search criteria

func (*SQLiteDataStore) GetProductsSymbol

func (db *SQLiteDataStore) GetProductsSymbol(id int) (Symbol, error)

GetProductsSymbol return the symbol matching the given id

func (*SQLiteDataStore) GetProductsSymbolByLabel

func (db *SQLiteDataStore) GetProductsSymbolByLabel(label string) (Symbol, error)

GetProductsSymbolByLabel return the symbol matching the given label

func (*SQLiteDataStore) GetProductsSymbols

func (db *SQLiteDataStore) GetProductsSymbols(p helpers.Dbselectparam) ([]Symbol, int, error)

GetProductsSymbols return the symbols matching the search criteria

func (*SQLiteDataStore) GetStorage

func (db *SQLiteDataStore) GetStorage(id int) (Storage, error)

GetStorage returns the storage with id "id"

func (*SQLiteDataStore) GetStorageEntity

func (db *SQLiteDataStore) GetStorageEntity(id int) (Entity, error)

GetStorageEntity returns the entity of the storage with id "id"

func (*SQLiteDataStore) GetStorages

func (db *SQLiteDataStore) GetStorages(p helpers.DbselectparamStorage) ([]Storage, int, error)

GetStorages returns the storages matching the request parameters p Only storages that the logged user can see are returned given his permissions and membership

func (*SQLiteDataStore) GetStoragesSuppliers

func (db *SQLiteDataStore) GetStoragesSuppliers(p helpers.Dbselectparam) ([]Supplier, int, error)

GetStoragesSuppliers return the suppliers matching the search criteria

func (*SQLiteDataStore) GetStoragesUnits

func (db *SQLiteDataStore) GetStoragesUnits(p helpers.Dbselectparam) ([]Unit, int, error)

GetStoragesUnits return the units matching the search criteria

func (*SQLiteDataStore) GetStoreLocation

func (db *SQLiteDataStore) GetStoreLocation(id int) (StoreLocation, error)

GetStoreLocation returns the store location with id "id"

func (*SQLiteDataStore) GetStoreLocationChildren

func (db *SQLiteDataStore) GetStoreLocationChildren(id int) ([]StoreLocation, error)

GetStoreLocationChildren returns the children of the store location with id "id"

func (*SQLiteDataStore) GetStoreLocationEntity

func (db *SQLiteDataStore) GetStoreLocationEntity(id int) (Entity, error)

GetStoreLocationEntity returns the entity of the store location with id "id"

func (*SQLiteDataStore) GetStoreLocations

GetStoreLocations returns the store locations matching the search criteria order, offset and limit are passed to the sql request

func (*SQLiteDataStore) GetWelcomeAnnounce

func (db *SQLiteDataStore) GetWelcomeAnnounce() (WelcomeAnnounce, error)

GetWelcomeAnnounce returns the welcome announce

func (*SQLiteDataStore) HasEntityNoStorelocation

func (db *SQLiteDataStore) HasEntityNoStorelocation(id int) (bool, error)

HasEntityNoStorelocation returns true is the entity has no store location

func (*SQLiteDataStore) HasPersonPermission

func (db *SQLiteDataStore) HasPersonPermission(personid int, perm string, item string, eids []int) (bool, error)

HasPersonPermission returns true if the person with id "personid" has the permission "perm" in the entities with ids "eids"

func (*SQLiteDataStore) Import

func (db *SQLiteDataStore) Import(url string) error

Import import data from another Chimithèque instance

func (*SQLiteDataStore) ImportV1

func (db *SQLiteDataStore) ImportV1(dir string) error

ImportV1 import data from CSV

func (*SQLiteDataStore) InsertCaptcha

func (db *SQLiteDataStore) InsertCaptcha(data *captcha.Data) (string, error)

InsertCaptcha generate and stores a unique captcha with a token to be validated by a user, and returns the token

func (*SQLiteDataStore) IsEntityEmpty

func (db *SQLiteDataStore) IsEntityEmpty(id int) (bool, error)

IsEntityEmpty returns true is the entity is empty

func (*SQLiteDataStore) IsPersonAdmin

func (db *SQLiteDataStore) IsPersonAdmin(id int) (bool, error)

IsPersonAdmin returns true is the person with id "id" is an admin

func (*SQLiteDataStore) IsPersonManager

func (db *SQLiteDataStore) IsPersonManager(id int) (bool, error)

IsPersonManager returns true is the person with id "id" is a manager

func (*SQLiteDataStore) IsProductBookmark

func (db *SQLiteDataStore) IsProductBookmark(pr Product, pe Person) (bool, error)

IsProductBookmark returns true if there is a bookmark for the product pr for the person pe

func (*SQLiteDataStore) IsStorageBorrowing

func (db *SQLiteDataStore) IsStorageBorrowing(b Borrowing) (bool, error)

IsStorageBorrowing returns true if there is a borrowing b in the database

func (*SQLiteDataStore) IsStoreLocationEmpty

func (db *SQLiteDataStore) IsStoreLocationEmpty(id int) (bool, error)

IsStoreLocationEmpty returns true is the store location is empty

func (*SQLiteDataStore) RestoreStorage

func (db *SQLiteDataStore) RestoreStorage(id int) error

RestoreStorage restores (unarchive) the storages with the given id

func (*SQLiteDataStore) SetPersonAdmin

func (db *SQLiteDataStore) SetPersonAdmin(id int) error

SetPersonAdmin set the person with id "id" an admin

func (*SQLiteDataStore) UnsetPersonAdmin

func (db *SQLiteDataStore) UnsetPersonAdmin(id int) error

UnsetPersonAdmin unset the person with id "id" the admin permissions

func (*SQLiteDataStore) UpdateAllQRCodes

func (db *SQLiteDataStore) UpdateAllQRCodes() error

UpdateAllQRCodes updates the storages QRCodes

func (*SQLiteDataStore) UpdateEntity

func (db *SQLiteDataStore) UpdateEntity(e Entity) error

UpdateEntity updates the given entity

func (*SQLiteDataStore) UpdatePerson

func (db *SQLiteDataStore) UpdatePerson(p Person) error

UpdatePerson updates the given person. The password is not updated.

func (*SQLiteDataStore) UpdatePersonPassword

func (db *SQLiteDataStore) UpdatePersonPassword(p Person) error

UpdatePersonPassword updates the given person password.

func (*SQLiteDataStore) UpdateProduct

func (db *SQLiteDataStore) UpdateProduct(p Product) error

UpdateProduct updates the product p into the database

func (*SQLiteDataStore) UpdateStorage

func (db *SQLiteDataStore) UpdateStorage(s Storage) error

UpdateStorage updates the storage s

func (*SQLiteDataStore) UpdateStoreLocation

func (db *SQLiteDataStore) UpdateStoreLocation(s StoreLocation) error

UpdateStoreLocation updates the given store location

func (*SQLiteDataStore) UpdateWelcomeAnnounce

func (db *SQLiteDataStore) UpdateWelcomeAnnounce(w WelcomeAnnounce) error

UpdateWelcomeAnnounce updates the main page announce

func (*SQLiteDataStore) ValidateCaptcha

func (db *SQLiteDataStore) ValidateCaptcha(token string, text string) (bool, error)

ValidateCaptcha validate the text entered for the user with the given token

type SignalWord

type SignalWord struct {
	// nullable values to handle optional Product foreign key (gorilla shema nil values)
	SignalWordID    sql.NullInt64  `db:"signalword_id" json:"signalword_id" schema:"signalword_id"`
	SignalWordLabel sql.NullString `db:"signalword_label" json:"signalword_label" schema:"signalword_label"`
}

SignalWord is a product signal word

type Stock

type Stock struct {
	Total   float64 `json:"total"`
	Current float64 `json:"current"`
	Unit    Unit    `json:"unit"`
}

Stock is a store location stock for a given product

type Storage

type Storage struct {
	StorageID               sql.NullInt64   `db:"storage_id" json:"storage_id" schema:"storage_id"`
	StorageCreationDate     time.Time       `db:"storage_creationdate" json:"storage_creationdate" schema:"storage_creationdate"`
	StorageModificationDate time.Time       `db:"storage_modificationdate" json:"storage_modificationdate" schema:"storage_modificationdate"`
	StorageEntryDate        global.NullTime `db:"storage_entrydate" json:"storage_entrydate" schema:"storage_entrydate"`
	StorageExitDate         global.NullTime `db:"storage_exitdate" json:"storage_exitdate" schema:"storage_exitdate"`
	StorageOpeningDate      global.NullTime `db:"storage_openingdate" json:"storage_openingdate" schema:"storage_openingdate"`
	StorageExpirationDate   global.NullTime `db:"storage_expirationdate" json:"storage_expirationdate" schema:"storage_expirationdate"`
	StorageComment          sql.NullString  `db:"storage_comment" json:"storage_comment" schema:"storage_comment"`
	StorageReference        sql.NullString  `db:"storage_reference" json:"storage_reference" schema:"storage_reference"`
	StorageBatchNumber      sql.NullString  `db:"storage_batchnumber" json:"storage_batchnumber" schema:"storage_batchnumber"`
	StorageQuantity         sql.NullFloat64 `db:"storage_quantity" json:"storage_quantity" schema:"storage_quantity"`
	StorageNbItem           int             `db:"-" json:"storage_nbitem" schema:"storage_nbitem"`
	StorageBarecode         sql.NullString  `db:"storage_barecode" json:"storage_barecode" schema:"storage_barecode"`
	StorageQRCode           []byte          `db:"storage_qrcode" json:"storage_qrcode" schema:"storage_qrcode"`
	StorageToDestroy        sql.NullBool    `db:"storage_todestroy" json:"storage_todestroy" schema:"storage_todestroy"`
	StorageArchive          sql.NullBool    `db:"storage_archive" json:"storage_archive" schema:"storage_archive"`
	Person                  `db:"person" json:"person" schema:"person"`
	Product                 `db:"product" json:"product" schema:"product"`
	StoreLocation           `db:"storelocation" json:"storelocation" schema:"storelocation"`
	Unit                    `db:"unit" json:"unit" schema:"unit"`
	Supplier                `db:"supplier" json:"supplier" schema:"supplier"`
	Storage                 *Storage   `db:"storage" json:"storage" schema:"storage"`       // history reference storage
	Borrowing               *Borrowing `db:"borrowing" json:"borrowing" schema:"borrowing"` // not un db but sqlx requires the "db" entry

	// storage history count
	StorageHC int `db:"storage_hc" json:"storage_hc" schema:"storage_hc"` // not in db but sqlx requires the "db" entry
}

Storage is a product storage in a store location

func (Storage) String

func (s Storage) String() string

type StoreLocation

type StoreLocation struct {
	// nullable values to handle optional StoreLocation foreign key (gorilla shema nil values)
	StoreLocationID       sql.NullInt64  `db:"storelocation_id" json:"storelocation_id" schema:"storelocation_id"`
	StoreLocationName     sql.NullString `db:"storelocation_name" json:"storelocation_name" schema:"storelocation_name"`
	StoreLocationCanStore sql.NullBool   `db:"storelocation_canstore" json:"storelocation_canstore" schema:"storelocation_canstore"`
	StoreLocationColor    sql.NullString `db:"storelocation_color" json:"storelocation_color" schema:"storelocation_color"`
	Entity                `db:"entity" json:"entity" schema:"entity"`
	StoreLocation         *StoreLocation `db:"storelocation" json:"storelocation" schema:"storelocation"`
	StoreLocationFullPath string         `db:"storelocation_fullpath" json:"storelocation_fullpath" schema:"storelocation_fullpath"`

	Children []*StoreLocation `db:"-" json:"children" schema:"-"`
	Stocks   []Stock          `db:"-" json:"stock" schema:"-"`
}

StoreLocation is where products are stored in entities

func (StoreLocation) String

func (s StoreLocation) String() string

type Supplier

type Supplier struct {
	C             int            `db:"c" json:"c"` // not stored in db but db:"c" set for sqlx
	SupplierID    sql.NullInt64  `db:"supplier_id" json:"supplier_id" schema:"supplier_id"`
	SupplierLabel sql.NullString `db:"supplier_label" json:"supplier_label" schema:"supplier_label"`
}

Supplier is a product supplier

type Symbol

type Symbol struct {
	SymbolID    int    `db:"symbol_id" json:"symbol_id" schema:"symbol_id"`
	SymbolLabel string `db:"symbol_label" json:"symbol_label" schema:"symbol_label"`
	SymbolImage string `db:"symbol_image" json:"symbol_image" schema:"symbol_image"`
}

Symbol is a product symbol

func (Symbol) String

func (s Symbol) String() string

type Unit

type Unit struct {
	UnitID         sql.NullInt64  `db:"unit_id" json:"unit_id" schema:"unit_id"`
	UnitLabel      sql.NullString `db:"unit_label" json:"unit_label" schema:"unit_label"`
	Unit           *Unit          `db:"unit" json:"unit" schema:"unit"` // reference
	UnitMultiplier int            `db:"unit_multiplier" json:"-" schema:"-"`
}

Unit is a volume or weight unit

type WelcomeAnnounce

type WelcomeAnnounce struct {
	WelcomeAnnounceID   int    `db:"welcomeannounce_id" json:"welcomeannounce_id" schema:"welcomeannounce_id"`
	WelcomeAnnounceText string `db:"welcomeannounce_text" json:"welcomeannounce_text" schema:"welcomeannounce_text"`
}

WelcomeAnnounce is the custom welcome page message

Jump to

Keyboard shortcuts

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