models

package
v10.48.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2018 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDB

func InitDB(dataSource string, migrationSource string, maxIdleConn int, connMaxLifetime int) (*sql.DB, error)

InitDB opens dataSource and bootstraps the database schema if it doesn't already exist.

Types

type API

type API struct {
	AllSurveysStmt                         *sql.Stmt
	GetSurveyStmt                          *sql.Stmt
	GetSurveyByShortNameStmt               *sql.Stmt
	GetSurveyByReferenceStmt               *sql.Stmt
	GetSurveyIDStmt                        *sql.Stmt
	GetClassifierTypeSelectorStmt          *sql.Stmt
	GetClassifierTypeSelectorByIDStmt      *sql.Stmt
	GetSurveyRefStmt                       *sql.Stmt
	PutSurveyDetailsBySurveyRefStmt        *sql.Stmt
	CreateSurveyStmt                       *sql.Stmt
	CreateSurveyClassifierTypeSelectorStmt *sql.Stmt
	CreateSurveyClassifierTypeStmt         *sql.Stmt
	GetLegalBasesStmt                      *sql.Stmt
	GetLegalBasisFromLongNameStmt          *sql.Stmt
	GetLegalBasisFromRefStmt               *sql.Stmt
	GetSurveyByShortnameStmt               *sql.Stmt
	GetSurveyPKByID                        *sql.Stmt
	CountMatchingClassifierTypeSelectors   *sql.Stmt
	Validator                              *validator2.Validate
	DB                                     *sql.DB
}

API contains all the pre-prepared sql statements

func NewAPI

func NewAPI(db *sql.DB) (*API, error)

NewAPI returns an API struct populated with all the created SQL statements

func (*API) AllClassifierTypeSelectors

func (api *API) AllClassifierTypeSelectors(w http.ResponseWriter, r *http.Request)

AllClassifierTypeSelectors returns all the classifier type selectors for the survey identified by the string surveyID. The classifier type selectors are returned in ascending order.

func (*API) AllLegalBases

func (api *API) AllLegalBases(w http.ResponseWriter, r *http.Request)

AllLegalBases returns details of all legal bases

func (*API) AllSurveys

func (api *API) AllSurveys(w http.ResponseWriter, r *http.Request)

AllSurveys returns summaries of all known surveys. The surveys are returned in ascending short name order.

func (*API) Close

func (api *API) Close()

Close closes all db connections on the api struct

func (*API) GetClassifierTypeSelectorByID

func (api *API) GetClassifierTypeSelectorByID(w http.ResponseWriter, r *http.Request)

GetClassifierTypeSelectorByID returns the details of the classifier type selector for the survey identified by the string surveyID and the classifier type selector identified by the string classifierTypeSelectorID.

func (*API) GetSurvey

func (api *API) GetSurvey(w http.ResponseWriter, r *http.Request)

GetSurvey returns the details of the survey identified by the string surveyID.

func (*API) GetSurveyByReference

func (api *API) GetSurveyByReference(w http.ResponseWriter, r *http.Request)

GetSurveyByReference returns the details of the survey identified by the string ref.

func (*API) GetSurveyByShortName

func (api *API) GetSurveyByShortName(w http.ResponseWriter, r *http.Request)

GetSurveyByShortName returns the details of the survey identified by the string shortName.

func (*API) Info

func (api *API) Info(w http.ResponseWriter, r *http.Request)

Info endpoint handler returns info like name, version, origin, commit, branch and built

func (*API) PostSurveyClassifiers

func (api *API) PostSurveyClassifiers(w http.ResponseWriter, r *http.Request)

PostSurveyClassifiers endpoint handler - creates a new survey classifier

func (*API) PostSurveyDetails

func (api *API) PostSurveyDetails(w http.ResponseWriter, r *http.Request)

PostSurveyDetails endpoint handler - creates a new survey based on JSON in request

func (*API) PutSurveyDetails

func (api *API) PutSurveyDetails(w http.ResponseWriter, r *http.Request)

PutSurveyDetails endpoint handler changes a survey short name using the survey reference

type ClassifierTypeSelector

type ClassifierTypeSelector struct {
	ID              string   `json:"id"`
	Name            string   `json:"name" validate:"required,min=1,max=50,no-spaces"`
	ClassifierTypes []string `json:"classifierTypes" validate:"required,min=1,dive,min=1,max=50,no-spaces"`
}

ClassifierTypeSelector represents the detail of a classifier type selector.

type ClassifierTypeSelectorSummary

type ClassifierTypeSelectorSummary struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

ClassifierTypeSelectorSummary represents a summary of a classifier type selector.

type LegalBasis

type LegalBasis struct {
	Reference string `json:"ref"`
	LongName  string `json:"longName"`
}

LegalBasis - the legal basis for a survey consisting of a short reference and a long name

type RESTError

type RESTError struct {
	Code      string `json:"code"`
	Message   string `json:"message"`
	Timestamp string `json:"timestamp"`
}

RESTError represents a client-side (HTTP 4xx) or server-side (HTTP 5xx) error. This is for compatibility with our Java microservices which expect this object.

func NewRESTError

func NewRESTError(code string, message string) RESTError

NewRESTError returns a RESTError with the Timestamp field pre-populated.

type Survey

type Survey struct {
	ID            string `json:"id"`
	ShortName     string `json:"shortName" validate:"required,no-spaces,max=20"`
	LongName      string `json:"longName" validate:"required,max=100"`
	Reference     string `json:"surveyRef" validate:"required,max=20"`
	LegalBasis    string `json:"legalBasis"`
	SurveyType    string `json:"surveyType"`
	LegalBasisRef string `json:"legalBasisRef"`
}

Survey represents the details of a survey.

type Version

type Version struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Origin  string `json:"origin"`
	Commit  string `json:"commit"`
	Branch  string `json:"branch"`
	Built   string `json:"built"`
}

Version represents the version of a service and other useful metadata.

func NewVersion

func NewVersion() Version

NewVersion returns a Version.

Jump to

Keyboard shortcuts

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