models

package
v0.0.0-...-34c5031 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const RecordNotFoundErrorString = "sql: no rows in result set"

RecordNotFoundErrorString is the error string returned when no matching rows exist in the database This is ugly, but the best we can do with go's Postgresql adapter

View Source
const ViolatesForeignKeyConstraint = "violates foreign key constraint"

ViolatesForeignKeyConstraint is part of the error string that is returned when postgres could not find any matching IDs for a record creating/updating

Variables

View Source
var ErrDestroyForbidden = errors.New("DESTROY_FORBIDDEN")

ErrDestroyForbidden means that a model cannot be destroyed in its current state

View Source
var ErrFetchForbidden = errors.New("FETCH_FORBIDDEN")

ErrFetchForbidden means that the record exists but that the user does not have access to it

View Source
var ErrFetchNotFound = errors.New("FETCH_NOT_FOUND")

ErrFetchNotFound means that the requested record does not exist

View Source
var ErrInvalidPatchGate = errors.New("INVALID_PATCH_GATE")

ErrInvalidPatchGate means that an attempt to patch a model was not given the correct set of fields

View Source
var ErrInvalidTransition = errors.New("INVALID_TRANSITION")

ErrInvalidTransition is an error representing an invalid state transition.

View Source
var ErrLocatorGeneration = errors.New("LOCATOR_ERRORS")

ErrLocatorGeneration means that we got errors generating the Locator

View Source
var ErrUserUnauthorized = errors.New("USER_UNAUTHORIZED")

ErrUserUnauthorized means that the user is not authorized to access a record

View Source
var ErrWriteConflict = errors.New("WRITE_CONFLICT")

ErrWriteConflict means that the record creation or update cannot be completed due to a conflict with other records

View Source
var ErrWriteForbidden = errors.New("WRITE_FORBIDDEN")

ErrWriteForbidden means that user is not permitted to write the record

Functions

func CreateElectronicOrder

func CreateElectronicOrder(ctx context.Context, dbConnection *pop.Connection, order *ElectronicOrder) (*validate.Errors, error)

CreateElectronicOrder inserts an empty set of electronic Orders into the database

func CreateElectronicOrderWithRevision

func CreateElectronicOrderWithRevision(ctx context.Context, dbConnection *pop.Connection, order *ElectronicOrder, firstRevision *ElectronicOrdersRevision) (*validate.Errors, error)

CreateElectronicOrderWithRevision inserts a new set of electronic Orders into the database with its first Revision

func CreateElectronicOrdersRevision

func CreateElectronicOrdersRevision(ctx context.Context, dbConnection *pop.Connection, revision *ElectronicOrdersRevision) (*validate.Errors, error)

CreateElectronicOrdersRevision inserts a revision into the database

func FetchElectronicOrderCountByIssuer

func FetchElectronicOrderCountByIssuer(db *pop.Connection, issuer string, startDateTime, endDateTime *string) (*int64, error)

FetchElectronicOrderCountByIssuer counts the number of orders by issuer

Types

type ClientCert

type ClientCert struct {
	ID                          uuid.UUID `json:"id" db:"id"`
	Sha256Digest                string    `db:"sha256_digest"`
	Subject                     string    `db:"subject"`
	AllowOrdersAPI              bool      `db:"allow_orders_api"`
	AllowAirForceOrdersRead     bool      `db:"allow_air_force_orders_read"`
	AllowAirForceOrdersWrite    bool      `db:"allow_air_force_orders_write"`
	AllowArmyOrdersRead         bool      `db:"allow_army_orders_read"`
	AllowArmyOrdersWrite        bool      `db:"allow_army_orders_write"`
	AllowCoastGuardOrdersRead   bool      `db:"allow_coast_guard_orders_read"`
	AllowCoastGuardOrdersWrite  bool      `db:"allow_coast_guard_orders_write"`
	AllowMarineCorpsOrdersRead  bool      `db:"allow_marine_corps_orders_read"`
	AllowMarineCorpsOrdersWrite bool      `db:"allow_marine_corps_orders_write"`
	AllowNavyOrdersRead         bool      `db:"allow_navy_orders_read"`
	AllowNavyOrdersWrite        bool      `db:"allow_navy_orders_write"`
	CreatedAt                   time.Time `db:"created_at"`
	UpdatedAt                   time.Time `db:"updated_at"`
}

ClientCert represents a known x509 Certificate in the database. It stores the SSN securely by hashing it.

func FetchClientCert

func FetchClientCert(db *pop.Connection, sha256Digest string) (*ClientCert, error)

FetchClientCert fetches and validates a client certificate by digest

func (*ClientCert) GetAllowedOrdersIssuersRead

func (c *ClientCert) GetAllowedOrdersIssuersRead() []string

GetAllowedOrdersIssuersRead returns a slice with the issuers of Orders that this ClientCert is allowed to read

func (*ClientCert) Validate

func (c *ClientCert) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.

func (*ClientCert) ValidateCreate

func (c *ClientCert) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)

ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.

func (*ClientCert) ValidateUpdate

func (c *ClientCert) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)

ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.

type ElectronicOrder

type ElectronicOrder struct {
	ID           uuid.UUID                 `json:"id" db:"id"`
	OrdersNumber string                    `json:"orders_number" db:"orders_number"`
	Edipi        string                    `json:"edipi" db:"edipi"`
	Issuer       Issuer                    `json:"issuer" db:"issuer"`
	Revisions    ElectronicOrdersRevisions `has_many:"electronic_orders_revisions" order_by:"seq_num asc"`
	CreatedAt    time.Time                 `json:"created_at" db:"created_at"`
	UpdatedAt    time.Time                 `json:"updated_at" db:"updated_at"`
}

ElectronicOrder contains the unchanging data of a set of orders across all amendments / revisions

func FetchElectronicOrderByID

func FetchElectronicOrderByID(db *pop.Connection, id uuid.UUID) (*ElectronicOrder, error)

FetchElectronicOrderByID gets all revisions of a set of Orders by their shared UUID, sorted in ascending order by their sequence number

func FetchElectronicOrderByIssuerAndOrdersNum

func FetchElectronicOrderByIssuerAndOrdersNum(db *pop.Connection, issuer string, ordersNum string) (*ElectronicOrder, error)

FetchElectronicOrderByIssuerAndOrdersNum gets all revisions of a set of Orders by the unique combination of the Orders number and the issuer.

func FetchElectronicOrdersByEdipiAndIssuers

func FetchElectronicOrdersByEdipiAndIssuers(db *pop.Connection, edipi string, issuers []string) ([]*ElectronicOrder, error)

FetchElectronicOrdersByEdipiAndIssuers gets all Orders issued to a member by EDIPI from the specified issuers

func (ElectronicOrder) String

func (e ElectronicOrder) String() string

String is not required by pop and may be deleted

func (*ElectronicOrder) Validate

func (e *ElectronicOrder) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.

func (*ElectronicOrder) ValidateCreate

func (e *ElectronicOrder) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)

ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.

func (*ElectronicOrder) ValidateUpdate

func (e *ElectronicOrder) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)

ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.

type ElectronicOrders

type ElectronicOrders []ElectronicOrder

ElectronicOrders is not required by pop and may be deleted

func (ElectronicOrders) String

func (e ElectronicOrders) String() string

String is not required by pop and may be deleted

type ElectronicOrdersAffiliation

type ElectronicOrdersAffiliation string

ElectronicOrdersAffiliation is a service member's military branch of service, or identifies a civilian

const (
	// ElectronicOrdersAffiliationAirForce captures enum value "air-force"
	ElectronicOrdersAffiliationAirForce ElectronicOrdersAffiliation = "air-force"
	// ElectronicOrdersAffiliationArmy captures enum value "army"
	ElectronicOrdersAffiliationArmy ElectronicOrdersAffiliation = "army"
	// ElectronicOrdersAffiliationCivilianAgency captures enum value "civilian-agency"
	ElectronicOrdersAffiliationCivilianAgency ElectronicOrdersAffiliation = "civilian-agency"
	// ElectronicOrdersAffiliationCoastGuard captures enum value "coast-guard"
	ElectronicOrdersAffiliationCoastGuard ElectronicOrdersAffiliation = "coast-guard"
	// ElectronicOrdersAffiliationMarineCorps captures enum value "marine-corps"
	ElectronicOrdersAffiliationMarineCorps ElectronicOrdersAffiliation = "marine-corps"
	// ElectronicOrdersAffiliationNavy captures enum value "navy"
	ElectronicOrdersAffiliationNavy ElectronicOrdersAffiliation = "navy"
)

type ElectronicOrdersRevision

type ElectronicOrdersRevision struct {
	ID                    uuid.UUID                   `json:"id" db:"id"`
	ElectronicOrderID     uuid.UUID                   `json:"electronic_order_id" db:"electronic_order_id"`
	ElectronicOrder       ElectronicOrder             `belongs_to:"electronic_order"`
	SeqNum                int                         `json:"seq_num" db:"seq_num"`
	GivenName             string                      `json:"given_name" db:"given_name"`
	MiddleName            *string                     `json:"middle_name" db:"middle_name"`
	FamilyName            string                      `json:"family_name" db:"family_name"`
	NameSuffix            *string                     `json:"name_suffix" db:"name_suffix"`
	Affiliation           ElectronicOrdersAffiliation `json:"affiliation" db:"affiliation"`
	Paygrade              Paygrade                    `json:"paygrade" db:"paygrade"`
	Title                 *string                     `json:"title" db:"title"`
	Status                ElectronicOrdersStatus      `json:"status" db:"status"`
	DateIssued            time.Time                   `json:"date_issued" db:"date_issued"`
	NoCostMove            bool                        `json:"no_cost_move" db:"no_cost_move"`
	TdyEnRoute            bool                        `json:"tdy_en_route" db:"tdy_en_route"`
	TourType              TourType                    `json:"tour_type" db:"tour_type"`
	OrdersType            ElectronicOrdersType        `json:"orders_type" db:"orders_type"`
	HasDependents         bool                        `json:"has_dependents" db:"has_dependents"`
	LosingUIC             *string                     `json:"losing_uic" db:"losing_uic"`
	LosingUnitName        *string                     `json:"losing_unit_name" db:"losing_unit_name"`
	LosingUnitCity        *string                     `json:"losing_unit_city" db:"losing_unit_city"`
	LosingUnitLocality    *string                     `json:"losing_unit_locality" db:"losing_unit_locality"`
	LosingUnitCountry     *string                     `json:"losing_unit_country" db:"losing_unit_country"`
	LosingUnitPostalCode  *string                     `json:"losing_unit_postal_code" db:"losing_unit_postal_code"`
	GainingUIC            *string                     `json:"gaining_uic" db:"gaining_uic"`
	GainingUnitName       *string                     `json:"gaining_unit_name" db:"gaining_unit_name"`
	GainingUnitCity       *string                     `json:"gaining_unit_city" db:"gaining_unit_city"`
	GainingUnitLocality   *string                     `json:"gaining_unit_locality" db:"gaining_unit_locality"`
	GainingUnitCountry    *string                     `json:"gaining_unit_country" db:"gaining_unit_country"`
	GainingUnitPostalCode *string                     `json:"gaining_unit_postal_code" db:"gaining_unit_postal_code"`
	ReportNoEarlierThan   *time.Time                  `json:"report_no_earlier_than" db:"report_no_earlier_than"`
	ReportNoLaterThan     *time.Time                  `json:"report_no_later_than" db:"report_no_later_than"`
	HhgTAC                *string                     `json:"hhg_tac" db:"hhg_tac"`
	HhgSDN                *string                     `json:"hhg_sdn" db:"hhg_sdn"`
	HhgLOA                *string                     `json:"hhg_loa" db:"hhg_loa"`
	NtsTAC                *string                     `json:"nts_tac" db:"nts_tac"`
	NtsSDN                *string                     `json:"nts_sdn" db:"nts_sdn"`
	NtsLOA                *string                     `json:"nts_loa" db:"nts_loa"`
	PovShipmentTAC        *string                     `json:"pov_shipment_tac" db:"pov_shipment_tac"`
	PovShipmentSDN        *string                     `json:"pov_shipment_sdn" db:"pov_shipment_sdn"`
	PovShipmentLOA        *string                     `json:"pov_shipment_loa" db:"pov_shipment_loa"`
	PovStorageTAC         *string                     `json:"pov_storage_tac" db:"pov_storage_tac"`
	PovStorageSDN         *string                     `json:"pov_storage_sdn" db:"pov_storage_sdn"`
	PovStorageLOA         *string                     `json:"pov_storage_loa" db:"pov_storage_loa"`
	UbTAC                 *string                     `json:"ub_tac" db:"ub_tac"`
	UbSDN                 *string                     `json:"ub_sdn" db:"ub_sdn"`
	UbLOA                 *string                     `json:"ub_loa" db:"ub_loa"`
	Comments              *string                     `json:"comments" db:"comments"`
	CreatedAt             time.Time                   `json:"created_at" db:"created_at"`
	UpdatedAt             time.Time                   `json:"updated_at" db:"updated_at"`
}

ElectronicOrdersRevision represents a complete amendment of one set of electronic orders

func (ElectronicOrdersRevision) String

func (e ElectronicOrdersRevision) String() string

String is not required by pop and may be deleted

func (*ElectronicOrdersRevision) Validate

Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.

func (*ElectronicOrdersRevision) ValidateCreate

func (e *ElectronicOrdersRevision) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)

ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.

func (*ElectronicOrdersRevision) ValidateUpdate

func (e *ElectronicOrdersRevision) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)

ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.

type ElectronicOrdersRevisions

type ElectronicOrdersRevisions []ElectronicOrdersRevision

ElectronicOrdersRevisions is not required by pop and may be deleted

func (ElectronicOrdersRevisions) String

func (e ElectronicOrdersRevisions) String() string

String is not required by pop and may be deleted

type ElectronicOrdersStatus

type ElectronicOrdersStatus string

ElectronicOrdersStatus indicates whether these Orders are authorized, RFO (Request For Orders), or canceled. An RFO is not sufficient to authorize moving expenses; only authorized Orders can do that.

const (
	// ElectronicOrdersStatusAuthorized captures enum value "authorized"
	ElectronicOrdersStatusAuthorized ElectronicOrdersStatus = "authorized"
	// ElectronicOrdersStatusRfo captures enum value "rfo"
	ElectronicOrdersStatusRfo ElectronicOrdersStatus = "rfo"
	// ElectronicOrdersStatusCanceled captures enum value "canceled"
	ElectronicOrdersStatusCanceled ElectronicOrdersStatus = "canceled"
)

type ElectronicOrdersType

type ElectronicOrdersType string

ElectronicOrdersType is the type of travel or move for a set of Orders

const (
	// ElectronicOrdersTypeAccession captures enum value "accession"
	ElectronicOrdersTypeAccession ElectronicOrdersType = "accession"
	// ElectronicOrdersTypeBetweenDutyStations captures enum value "between-duty-stations"
	ElectronicOrdersTypeBetweenDutyStations ElectronicOrdersType = "between-duty-stations"
	// ElectronicOrdersTypeBrac captures enum value "brac"
	ElectronicOrdersTypeBrac ElectronicOrdersType = "brac"
	// ElectronicOrdersTypeCot captures enum value "cot"
	ElectronicOrdersTypeCot ElectronicOrdersType = "cot"
	// ElectronicOrdersTypeEmergencyEvac captures enum value "emergency-evac"
	ElectronicOrdersTypeEmergencyEvac ElectronicOrdersType = "emergency-evac"
	// ElectronicOrdersTypeIpcot captures enum value "ipcot"
	ElectronicOrdersTypeIpcot ElectronicOrdersType = "ipcot"
	// ElectronicOrdersTypeLowCostTravel captures enum value "low-cost-travel"
	ElectronicOrdersTypeLowCostTravel ElectronicOrdersType = "low-cost-travel"
	// ElectronicOrdersTypeOperational captures enum value "operational"
	ElectronicOrdersTypeOperational ElectronicOrdersType = "operational"
	// ElectronicOrdersTypeOteip captures enum value "oteip"
	ElectronicOrdersTypeOteip ElectronicOrdersType = "oteip"
	// ElectronicOrdersTypeRotational captures enum value "rotational"
	ElectronicOrdersTypeRotational ElectronicOrdersType = "rotational"
	// ElectronicOrdersTypeSeparation captures enum value "separation"
	ElectronicOrdersTypeSeparation ElectronicOrdersType = "separation"
	// ElectronicOrdersTypeSpecialPurpose captures enum value "special-purpose"
	ElectronicOrdersTypeSpecialPurpose ElectronicOrdersType = "special-purpose"
	// ElectronicOrdersTypeTraining captures enum value "training"
	ElectronicOrdersTypeTraining ElectronicOrdersType = "training"
	// ElectronicOrdersTypeUnitMove captures enum value "unit-move"
	ElectronicOrdersTypeUnitMove ElectronicOrdersType = "unit-move"
)

type Issuer

type Issuer string

Issuer is the organization that issues orders.

const (
	// IssuerArmy captures enum value "army"
	IssuerArmy Issuer = "army"
	// IssuerNavy captures enum value "navy"
	IssuerNavy Issuer = "navy"
	// IssuerAirForce captures enum value "air-force"
	IssuerAirForce Issuer = "air-force"
	// IssuerMarineCorps captures enum value "marine-corps"
	IssuerMarineCorps Issuer = "marine-corps"
	// IssuerCoastGuard captures enum value "coast-guard"
	IssuerCoastGuard Issuer = "coast-guard"
)

type Paygrade

type Paygrade string

Paygrade is the "rank" of a member. Some of these paygrades will have identical entitlements.

const (
	// PaygradeAviationCadet captures enum value "aviation-cadet"
	PaygradeAviationCadet Paygrade = "aviation-cadet"
	// PaygradeCadet captures enum value "cadet"
	PaygradeCadet Paygrade = "cadet"
	// PaygradeCivilian captures enum value "civilian"
	PaygradeCivilian Paygrade = "civilian"
	// PaygradeE1 captures enum value "e-1"
	PaygradeE1 Paygrade = "e-1"
	// PaygradeE2 captures enum value "e-2"
	PaygradeE2 Paygrade = "e-2"
	// PaygradeE3 captures enum value "e-3"
	PaygradeE3 Paygrade = "e-3"
	// PaygradeE4 captures enum value "e-4"
	PaygradeE4 Paygrade = "e-4"
	// PaygradeE5 captures enum value "e-5"
	PaygradeE5 Paygrade = "e-5"
	// PaygradeE6 captures enum value "e-6"
	PaygradeE6 Paygrade = "e-6"
	// PaygradeE7 captures enum value "e-7"
	PaygradeE7 Paygrade = "e-7"
	// PaygradeE8 captures enum value "e-8"
	PaygradeE8 Paygrade = "e-8"
	// PaygradeE9 captures enum value "e-9"
	PaygradeE9 Paygrade = "e-9"
	// PaygradeMidshipman captures enum value "midshipman"
	PaygradeMidshipman Paygrade = "midshipman"
	// PaygradeO1 captures enum value "o-1"
	PaygradeO1 Paygrade = "o-1"
	// PaygradeO2 captures enum value "o-2"
	PaygradeO2 Paygrade = "o-2"
	// PaygradeO3 captures enum value "o-3"
	PaygradeO3 Paygrade = "o-3"
	// PaygradeO4 captures enum value "o-4"
	PaygradeO4 Paygrade = "o-4"
	// PaygradeO5 captures enum value "o-5"
	PaygradeO5 Paygrade = "o-5"
	// PaygradeO6 captures enum value "o-6"
	PaygradeO6 Paygrade = "o-6"
	// PaygradeO7 captures enum value "o-7"
	PaygradeO7 Paygrade = "o-7"
	// PaygradeO8 captures enum value "o-8"
	PaygradeO8 Paygrade = "o-8"
	// PaygradeO9 captures enum value "o-9"
	PaygradeO9 Paygrade = "o-9"
	// PaygradeO10 captures enum value "o-10"
	PaygradeO10 Paygrade = "o-10"
	// PaygradeW1 captures enum value "w-1"
	PaygradeW1 Paygrade = "w-1"
	// PaygradeW2 captures enum value "w-2"
	PaygradeW2 Paygrade = "w-2"
	// PaygradeW3 captures enum value "w-3"
	PaygradeW3 Paygrade = "w-3"
	// PaygradeW4 captures enum value "w-4"
	PaygradeW4 Paygrade = "w-4"
	// PaygradeW5 captures enum value "w-5"
	PaygradeW5 Paygrade = "w-5"
)

type StringIsNilOrNotBlank

type StringIsNilOrNotBlank struct {
	Name  string
	Field *string
}

StringIsNilOrNotBlank validates OptionalString fields, which we represent as *string.

func (*StringIsNilOrNotBlank) IsValid

func (v *StringIsNilOrNotBlank) IsValid(errors *validate.Errors)

IsValid adds an error if the pointer is not nil and also an empty string.

type TourType

type TourType string

TourType indicates whether the travel is Accompanied or Unaccompanied; i.e., are dependents authorized to accompany the service member on the move. For certain OCONUS destinations, the tour type affects the member's entitlement. Otherwise, it doesn't matter.

const (
	// TourTypeAccompanied captures enum value "accompanied"
	TourTypeAccompanied TourType = "accompanied"
	// TourTypeUnaccompanied captures enum value "unaccompanied"
	TourTypeUnaccompanied TourType = "unaccompanied"
	// TourTypeUnaccompaniedDependentsRestricted captures enum value "unaccompanied-dependents-restricted"
	TourTypeUnaccompaniedDependentsRestricted TourType = "unaccompanied-dependents-restricted"
)

type ValidateableModel

type ValidateableModel interface {
	Validate(*pop.Connection) (*validate.Errors, error)
}

ValidateableModel is here simply because `validateable` is private to `pop`

Jump to

Keyboard shortcuts

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