Documentation
¶
Index ¶
- Constants
- Variables
- func Init()
- func PathToJobFile(user, job, file string) string
- func PathToJobsDir(user string) string
- func PathToUserDir(user string) string
- func PathToUserFile(user, file string) string
- type Access
- type AccessPath
- type IndexElement
- type Job
- type JobStatus
- type LocalDatabase
- func (db *LocalDatabase) Create(user *User) error
- func (db *LocalDatabase) DeleteJob(user, job string) error
- func (db *LocalDatabase) Get(username string) (*User, error)
- func (db *LocalDatabase) GetEcoParams(user string) (*params.EcoParams, error)
- func (db *LocalDatabase) GetIndexParams(user string) (*params.MasterParams, error)
- func (db *LocalDatabase) GetJobFilename(user, job, file string) string
- func (db *LocalDatabase) ListJobs(user string) []string
- func (db *LocalDatabase) SetEcoParams(user string, ep *params.EcoParams) error
- func (db *LocalDatabase) SetMasterParams(user string, ip *params.MasterParams) error
- func (db *LocalDatabase) Update(user *User) error
- type User
- func (u *User) Bytes() ([]byte, error)
- func (u *User) ComparePassword(password string) error
- func (u *User) CreateJob(name string, ip *params.MasterParams, ep *params.EcoParams) (*Job, error)
- func (u *User) DeleteJob(name string) error
- func (u *User) Exists() bool
- func (u *User) Get() (*User, error)
- func (u *User) GetAllJobs() ([]*Job, error)
- func (u *User) GetEcoParams() (*params.EcoParams, error)
- func (u *User) GetIndexParams() (*params.MasterParams, error)
- func (u *User) GetJob(name string) (*Job, error)
- func (u *User) GetJobParams(name string) (*params.MasterParams, *params.EcoParams, error)
- func (u *User) ListJobs() []string
- func (u *User) Save() error
- func (u *User) SaveEcoParams(ep *params.EcoParams) error
- func (u *User) SaveMasterParams(ip *params.MasterParams) error
- func (u *User) SetJobParamsAsActive(name string) error
- func (u *User) String() string
- func (u *User) ToMap(m map[string]interface{}) map[string]interface{}
- func (u *User) Update() error
- func (u *User) ValidateAndHashPassword(password string) (err error)
Constants ¶
const ( PrefixUsers = "users/" PrefixJobs = "jobs/" FileProfileFilename = "profile.hjson" FileMasterFilename = "masterParams.hjson" FileEcoFilename = "ecoParams.hjson" FileJobOutput = "output.hjson" //FileJobOutput = "output.json" FileJobProcessingFlag = ".processing" )
Prefixes for file structure of iGenDec
const ( TraitWW = trait("WW") TraitMW = trait("MW") TraitSTAY = trait("STAY") TraitCD = trait("CD") TraitHP = trait("HP") )
Types of traits
const ( ComponentDirect = component("D") ComponentMaternal = component("M") )
Types of components
const ( PasswordMinLength = 8 PasswordMaxLength = 64 )
Password variables
Variables ¶
var ( ErrUserExists = errors.New("user exists") ErrUserDoesntExist = errors.New("user does not exist") )
Database errors
var ( ErrInvalidPassword = errors.New("Invalid password") ErrIncorrectPassword = errors.New("Incorrect password") ErrUserHasNoPassword = errors.New("User does not have a password") )
Password errors
var UsersPath string
Functions ¶
func PathToJobFile ¶
PathToJobFile returns the path to a job file for a user If you want the general path, pass in empty string for jobfile parameter
func PathToJobsDir ¶
PathToJobsDir returns the path to the directory where we keep all of the jobs
func PathToUserDir ¶
PathToUserDir returns the path to a directory for a user
func PathToUserFile ¶
PathToUserFile returns the path to a general file for a user
Types ¶
type Access ¶
type Access []AccessPath
type AccessPath ¶
type IndexElement ¶
type IndexElement struct { Trait trait `json:"trait"` Component component `json:"component"` MarginalEconomicValue float64 `json:"mev"` Emphasis float64 `json:"emphasis"` Correlation float64 `json:"correlation"` GeneticStdDev float64 `json:"geneticStdDev"` DisplayMEV string }
IndexElement holds the details of a trait thats output from iGenDec
func (IndexElement) Key ¶
func (ic IndexElement) Key() string
Key returns the trait and component joined by a comma to conform to how we otherwise find this
type Job ¶
type Job struct { Name string Status JobStatus Endpoint string Output []IndexElement `json:"indexElement"` Comment string TargetDatabase string // contains filtered or unexported fields }
Job holds information on a job run through create page
type LocalDatabase ¶
type LocalDatabase struct {
// contains filtered or unexported fields
}
LocalDatabase structure is an implementation of Database interface for keeping files in local tree
func NewLocalDatabase ¶
func NewLocalDatabase(root string) *LocalDatabase
NewLocalDatabase returns a new local implementation of Database
func (*LocalDatabase) Create ¶
func (db *LocalDatabase) Create(user *User) error
Create makes a new user
func (*LocalDatabase) DeleteJob ¶
func (db *LocalDatabase) DeleteJob(user, job string) error
DeleteJob will remove the given job if it exists
func (*LocalDatabase) Get ¶
func (db *LocalDatabase) Get(username string) (*User, error)
Get returns a user
func (*LocalDatabase) GetEcoParams ¶
func (db *LocalDatabase) GetEcoParams(user string) (*params.EcoParams, error)
GetEcoParams returns ecoParams.hjson file for the user
func (*LocalDatabase) GetIndexParams ¶
func (db *LocalDatabase) GetIndexParams(user string) (*params.MasterParams, error)
GetIndexParams returns indexParams.hjson file for the user
func (*LocalDatabase) GetJobFilename ¶
func (db *LocalDatabase) GetJobFilename(user, job, file string) string
GetJobFilename returns the path to the given job file
func (*LocalDatabase) ListJobs ¶
func (db *LocalDatabase) ListJobs(user string) []string
ListJobs returns a list of the jobs a user has
func (*LocalDatabase) SetEcoParams ¶
func (db *LocalDatabase) SetEcoParams(user string, ep *params.EcoParams) error
SetEcoParams writes the given eco params to the database
func (*LocalDatabase) SetMasterParams ¶
func (db *LocalDatabase) SetMasterParams(user string, ip *params.MasterParams) error
SetMasterParams writes the given index params to the database
func (*LocalDatabase) Update ¶
func (db *LocalDatabase) Update(user *User) error
Update takes in the details of a user and overwrites the current profile entry
type User ¶
type User struct { Firstname string Surname string Email string Location string Username string // Password - hashed and salted Password []byte // Access is an array of paths we can use // to define what datasets the user has access to. // Each path should directly correlate with the // structure of the epds directory Access Access }
User has the fields a user needs
func NewUser ¶
NewUser returns a new user with only the Username field filled in Use 'user.NewUser(username).Get()' to get a user from the database
func NewUserFromBytes ¶
NewUserFromBytes returns a new user by parsing the bytes with JSON
func (*User) ComparePassword ¶
ComparePassword returns true if the password is this users, false otherwise If the user doesn't have a password, returns false
func (*User) CreateJob ¶
CreateJob creates a job out of the current context, saves it and returns the job
func (*User) GetAllJobs ¶
GetAllJobs gets every job this user has
func (*User) GetEcoParams ¶
GetEcoParams gets the ecoParams.hjson file from the server for this user
func (*User) GetIndexParams ¶
func (u *User) GetIndexParams() (*params.MasterParams, error)
GetIndexParams gets the indexParams.hjson file from the server for this user If it doesn't exist, will return default struct
func (*User) GetJob ¶
GetJob returns a job object that has the basic output and the status of the given job. If something unknown is queried will return a job with a failed status
func (*User) GetJobParams ¶
GetJobParams will return the parameters used in the given job Will return error if the job doesn't exist or parameter files can't be loaded
func (*User) ListJobs ¶
ListJobs returns a list of the jobs the user has stored in the database Forwards the database function
func (*User) Save ¶
Save the user to the database This is a create operation, to update use user.Update()
func (*User) SaveEcoParams ¶
SaveEcoParams will overwrite the current eco params file for this user with the given params Wraps database method
func (*User) SaveMasterParams ¶
func (u *User) SaveMasterParams(ip *params.MasterParams) error
SaveMasterParams will overwrite the current index params file for this user with the given params Wraps database method
func (*User) SetJobParamsAsActive ¶
SetJobParamsAsActive will set this jobs indexparams and ecoparams as the active index/eco params
func (*User) Update ¶
Update the users details in the database This will fail if the user doesn't exist
func (*User) ValidateAndHashPassword ¶
ValidateAndHashPassword validates and hashes the provided password and saves it to the user struct