storage

package
v0.0.0-...-b3f093e Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const EuaIDMsg = "" /* 168-byte string literal not displayed */

EuaIDMsg is the error we see when EUA doesn't meet EUA ID constraints

View Source
const IntakeExistsMsg = "" /* 199-byte string literal not displayed */

IntakeExistsMsg is the error we see when there is no valid system intake

View Source
const UniqueIntakeMsg = "pq: duplicate key value violates unique constraint \"unique_intake_per_biz_case\""

UniqueIntakeMsg is a match for an error we see when the system intake already has a biz case

View Source
const ValidStatusMsg = "pq: invalid input value for enum business_case_status: "

ValidStatusMsg is a match for an error we see when there is no valid status

Variables

This section is empty.

Functions

This section is empty.

Types

type DBConfig

type DBConfig struct {
	Host           string
	Port           string
	Database       string
	Username       string
	Password       string
	SSLMode        string
	UseIAM         bool
	MaxConnections int
}

DBConfig holds the configurations for a database connection

type Store

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

Store performs database operations for EASi

func NewStore

func NewStore(
	config DBConfig,
	ldClient *ld.LDClient,
) (*Store, error)

NewStore creates a new Store struct The `db` property on the Store will always be a *sqlx.DB, but a notable difference in the DB is that if config.UseIAM is true, that DB instance will be backed by a custom connector in iam_db.go that generates IAM auth tokens when making new connections to the database. If config.UseIAM is false, it will connect using the "postgres" driver that SQLx registers in its init() function https://github.com/jmoiron/sqlx/blob/75a7ebf246fd757c9c7742da7dc4d26c6fdb6b5b/bind.go#L33-L40

func (*Store) Beginx

func (s *Store) Beginx() (*sqlx.Tx, error)

Beginx implements the TransactionPreparer interface Implementing the sqlutils.TransactionPreparer interfaces allows us to use a sqlx.DB or a storage.Store to create a transaction

func (*Store) CreateAction

func (s *Store) CreateAction(ctx context.Context, action *models.Action) (*models.Action, error)

CreateAction creates an Action item in the database

func (*Store) CreateBusinessCase

func (s *Store) CreateBusinessCase(ctx context.Context, businessCase *models.BusinessCase) (*models.BusinessCase, error)

CreateBusinessCase creates a business case

func (*Store) CreateCedarSystemBookmark

func (s *Store) CreateCedarSystemBookmark(ctx context.Context, cedarSystemBookmark *models.CedarSystemBookmark) (*models.CedarSystemBookmark, error)

CreateCedarSystemBookmark creates a new cedar system bookmark object in the database

func (*Store) CreateGovernanceRequestFeedback

func (s *Store) CreateGovernanceRequestFeedback(ctx context.Context, requestFeedback *models.GovernanceRequestFeedback) (*models.GovernanceRequestFeedback, error)

CreateGovernanceRequestFeedback creates a governance request feedback record in the database

func (*Store) CreateSystemIntake

func (s *Store) CreateSystemIntake(ctx context.Context, intake *models.SystemIntake) (*models.SystemIntake, error)

CreateSystemIntake creates a system intake, though without saving values for LCID-related fields

func (*Store) CreateSystemIntakeContact

func (s *Store) CreateSystemIntakeContact(ctx context.Context, systemIntakeContact *models.SystemIntakeContact) (*models.SystemIntakeContact, error)

CreateSystemIntakeContact creates a new system intake contact object in the database

func (*Store) CreateSystemIntakeDocument

func (s *Store) CreateSystemIntakeDocument(ctx context.Context, document *models.SystemIntakeDocument) (*models.SystemIntakeDocument, error)

CreateSystemIntakeDocument creates a record for a SystemIntakeDocument in our database, *after* it's been uploaded to S3

func (*Store) CreateSystemIntakeNote

func (s *Store) CreateSystemIntakeNote(ctx context.Context, note *models.SystemIntakeNote) (*models.SystemIntakeNote, error)

CreateSystemIntakeNote inserts a new note into the database

func (*Store) CreateTRBAdminNote

func (s *Store) CreateTRBAdminNote(ctx context.Context, note *models.TRBAdminNote) (*models.TRBAdminNote, error)

CreateTRBAdminNote creates a new TRB admin note record in the database

func (s *Store) CreateTRBAdminNoteTRBDocumentLinks(
	ctx context.Context,
	trbRequestID uuid.UUID,
	trbAdminNoteID uuid.UUID,
	trbRequestDocumentIDs []uuid.UUID,
) ([]*models.TRBAdminNoteTRBRequestDocumentLink, error)

Creates multiple link records relating a single TRB admin note to all TRB documents it references

func (s *Store) CreateTRBAdminNoteTRBRecommendationLinks(
	ctx context.Context,
	trbRequestID uuid.UUID,
	trbAdminNoteID uuid.UUID,
	trbAdviceLetterRecommendationIDs []uuid.UUID,
) ([]*models.TRBAdminNoteTRBAdviceLetterRecommendationLink, error)

Creates multiple link records relating a single TRB admin note to all TRB advice letter recommendations it references

func (*Store) CreateTRBAdviceLetter

func (s *Store) CreateTRBAdviceLetter(ctx context.Context, createdBy string, trbRequestID uuid.UUID) (*models.TRBAdviceLetter, error)

CreateTRBAdviceLetter creates an advice letter for a TRB request, in the "In Progress" status

func (*Store) CreateTRBAdviceLetterRecommendation

func (s *Store) CreateTRBAdviceLetterRecommendation(
	ctx context.Context,
	recommendation *models.TRBAdviceLetterRecommendation,
) (*models.TRBAdviceLetterRecommendation, error)

CreateTRBAdviceLetterRecommendation creates a new TRB advice letter recommendation record in the database. This recommendation will be positioned at the end of the advice letter upon creation.

func (*Store) CreateTRBLeadOption

func (s *Store) CreateTRBLeadOption(ctx context.Context, leadOption *models.TRBLeadOption) (*models.TRBLeadOption, error)

CreateTRBLeadOption creates a new TRB lead option record in the database

func (*Store) CreateTRBRequest

func (s *Store) CreateTRBRequest(ctx context.Context, np sqlutils.NamedPreparer, trb *models.TRBRequest) (*models.TRBRequest, error)

CreateTRBRequest creates a new TRBRequest record Note this will be refactored to not use the store, but is left now for organization

func (*Store) CreateTRBRequestAttendee

func (s *Store) CreateTRBRequestAttendee(ctx context.Context, np sqlutils.NamedPreparer, attendee *models.TRBRequestAttendee) (*models.TRBRequestAttendee, error)

CreateTRBRequestAttendee creates a new TRB request attendee record in the database Note this will be refactored to not use the store, but is left now for organization

func (*Store) CreateTRBRequestDocument

func (s *Store) CreateTRBRequestDocument(ctx context.Context, document *models.TRBRequestDocument) (*models.TRBRequestDocument, error)

CreateTRBRequestDocument creates a record for a TRBRequestDocument in our database, *after* it's been uploaded to S3

func (*Store) CreateTRBRequestFeedback

func (s *Store) CreateTRBRequestFeedback(ctx context.Context, feedback *models.TRBRequestFeedback, formToUpdate *models.TRBRequestForm) (*models.TRBRequestFeedback, error)

CreateTRBRequestFeedback creates a new TRB request feedback record in the database

func (*Store) CreateTRBRequestForm

func (s *Store) CreateTRBRequestForm(ctx context.Context, np sqlutils.NamedPreparer, form *models.TRBRequestForm) (*models.TRBRequestForm, error)

CreateTRBRequestForm creates a new TRBRequestForm record Note this will be refactored to not use the store, but is left now for organization

func (*Store) CreateTRBRequestSystemIntakes

func (s *Store) CreateTRBRequestSystemIntakes(ctx context.Context, trbRequestID uuid.UUID, systemIntakeIDs []uuid.UUID) ([]*models.TRBRequestSystemIntake, error)

CreateTRBRequestSystemIntakes deletes all TRB Intake relations for the given trbRequestID and recreates them

func (*Store) DeleteCedarSystemBookmark

func (s *Store) DeleteCedarSystemBookmark(ctx context.Context, cedarSystemBookmark *models.CedarSystemBookmark) (*models.CedarSystemBookmark, error)

DeleteCedarSystemBookmark deletes an existing cedar system bookmark object in the database

func (*Store) DeleteSystemIntakeContact

func (s *Store) DeleteSystemIntakeContact(ctx context.Context, systemIntakeContact *models.SystemIntakeContact) (*models.SystemIntakeContact, error)

DeleteSystemIntakeContact deletes an existing system intake contact object in the database

func (*Store) DeleteSystemIntakeDocument

func (s *Store) DeleteSystemIntakeDocument(ctx context.Context, id uuid.UUID) (*models.SystemIntakeDocument, error)

DeleteSystemIntakeDocument deletes an existing SystemIntakeDocument, given its ID

func (*Store) DeleteTRBAdviceLetterRecommendation

func (s *Store) DeleteTRBAdviceLetterRecommendation(ctx context.Context, id uuid.UUID) (*models.TRBAdviceLetterRecommendation, error)

DeleteTRBAdviceLetterRecommendation deletes an existing TRB advice letter recommendation record in the database

func (*Store) DeleteTRBLeadOption

func (s *Store) DeleteTRBLeadOption(ctx context.Context, euaID string) (*models.TRBLeadOption, error)

DeleteTRBLeadOption deletes an existing TRB lead option record in the database

func (*Store) DeleteTRBRequestAttendee

func (s *Store) DeleteTRBRequestAttendee(ctx context.Context, id uuid.UUID) (*models.TRBRequestAttendee, error)

DeleteTRBRequestAttendee deletes an existing TRB request attendee record in the database

func (*Store) DeleteTRBRequestDocument

func (s *Store) DeleteTRBRequestDocument(ctx context.Context, id uuid.UUID) (*models.TRBRequestDocument, error)

DeleteTRBRequestDocument sets the deleted_at property on an existing TRBRequestDocument, given its ID

func (*Store) DeleteTRBRequestForm

func (s *Store) DeleteTRBRequestForm(ctx context.Context, trbRequestID uuid.UUID) (*models.TRBRequestForm, error)

DeleteTRBRequestForm deletes an existing TRB request form record in the database

func (*Store) DeleteTRBRequestFundingSources

func (s *Store) DeleteTRBRequestFundingSources(
	ctx context.Context,
	trbRequestID uuid.UUID,
	fundingNumber string,
) ([]*models.TRBFundingSource, error)

DeleteTRBRequestFundingSources deletes all funding sources from a TRB Request Form by funding number

func (*Store) FetchBusinessCaseByID

func (s *Store) FetchBusinessCaseByID(ctx context.Context, businessCaseID uuid.UUID) (*models.BusinessCase, error)

FetchBusinessCaseByID queries the DB for a business case matching the given ID

func (*Store) FetchBusinessCaseBySystemIntakeID

func (s *Store) FetchBusinessCaseBySystemIntakeID(ctx context.Context, systemIntakeID uuid.UUID) (*models.BusinessCase, error)

FetchBusinessCaseBySystemIntakeID queries the DB for a business case matching the given ID of the System Intake

func (*Store) FetchCedarSystemBookmarks

func (s *Store) FetchCedarSystemBookmarks(ctx context.Context) ([]*models.CedarSystemBookmark, error)

FetchCedarSystemBookmarks queries the DB for all the cedar system bookmarks matching the given user's EUA ID

func (*Store) FetchNotesBySystemIntakeID

func (s *Store) FetchNotesBySystemIntakeID(ctx context.Context, id uuid.UUID) ([]*models.SystemIntakeNote, error)

FetchNotesBySystemIntakeID retrieves all (non archived/deleted) Notes associated with a specific SystemIntake

func (*Store) FetchOpenBusinessCaseByIntakeID

func (s *Store) FetchOpenBusinessCaseByIntakeID(ctx context.Context, intakeID uuid.UUID) (*models.BusinessCase, error)

FetchOpenBusinessCaseByIntakeID queries the DB for an open business case matching the given intake ID

func (*Store) FetchSystemIntakeByID

func (s *Store) FetchSystemIntakeByID(ctx context.Context, id uuid.UUID) (*models.SystemIntake, error)

FetchSystemIntakeByID serves as a wrapper for FetchSystemIntakeByIDNP, which is the actual implementation for fetching System Intakes by ID.

This method only exists to provide a transactional wrapper around the actual implementation, as a vast majority of the codebase was written before the introduction of transactions in the storage layer. This method should eventually be removed in favor of using FetchSystemIntakeByIDNP directly (and that function renamed).

func (*Store) FetchSystemIntakeByIDNP

func (s *Store) FetchSystemIntakeByIDNP(ctx context.Context, np sqlutils.NamedPreparer, id uuid.UUID) (*models.SystemIntake, error)

FetchSystemIntakeByIDNP queries the DB for a system intake matching the given ID

The "NP" suffix stands for "NamedPreparer", as this function was written to avoid the need to update all of the existing code that uses FetchSystemIntakeByID to use a transactional wrapper.

func (*Store) FetchSystemIntakeContactsBySystemIntakeID

func (s *Store) FetchSystemIntakeContactsBySystemIntakeID(ctx context.Context, systemIntakeID uuid.UUID) ([]*models.SystemIntakeContact, error)

FetchSystemIntakeContactsBySystemIntakeID queries the DB for all the system intake contacts matching the given system intake ID

func (*Store) FetchSystemIntakeFundingSourcesByIntakeID

func (s *Store) FetchSystemIntakeFundingSourcesByIntakeID(ctx context.Context, systemIntakeID uuid.UUID) ([]*models.SystemIntakeFundingSource, error)

FetchSystemIntakeFundingSourcesByIntakeID fetches all funding sources for a system intake

func (*Store) FetchSystemIntakeMetrics

func (s *Store) FetchSystemIntakeMetrics(ctx context.Context, startTime time.Time, endTime time.Time) (models.SystemIntakeMetrics, error)

FetchSystemIntakeMetrics gets a metrics digest for system intake

func (*Store) FetchSystemIntakeNoteByID

func (s *Store) FetchSystemIntakeNoteByID(ctx context.Context, id uuid.UUID) (*models.SystemIntakeNote, error)

FetchSystemIntakeNoteByID retrieves a single Note by its primary key identifier

func (*Store) FetchSystemIntakes

func (s *Store) FetchSystemIntakes(ctx context.Context) (models.SystemIntakes, error)

FetchSystemIntakes queries the DB for all system intakes

func (*Store) FetchSystemIntakesByEuaID

func (s *Store) FetchSystemIntakesByEuaID(ctx context.Context, euaID string) (models.SystemIntakes, error)

FetchSystemIntakesByEuaID queries the DB for system intakes matching the given EUA ID

func (*Store) FetchSystemIntakesByStateForAdmins

func (s *Store) FetchSystemIntakesByStateForAdmins(ctx context.Context, state models.SystemIntakeState) ([]*models.SystemIntake, error)

FetchSystemIntakesByStateForAdmins queries the DB for all system intakes with a matching state The intent of this query is to return all intakes that are in a state that is relevant to admins (i.e. not in a draft state, not archived)

func (*Store) GenerateLifecycleID

func (s *Store) GenerateLifecycleID(ctx context.Context) (string, error)

GenerateLifecycleID returns what the next LCID is expected to be for the current date

The expected format is a 6-digit number in the form of "YYdddP" where
	YY - the 2-digit YEAR
	ddd - the 3-digit ORDINAL DATE, e.g. the number of days elapsed in the given year
	P - the 1-digit count of how many LCIDs already generated for the given day
This routine assumes the LCIDs are being generated in Eastern Time Zone
(FYI - the "YYddd" construct is referred to as the "Julian Day" in mainframe
programmer circles, though this term seems to be a misappropriation of what
astronomers use to mean a count of days since 24 Nov in the year 4714 BC.)

func (*Store) GetActionsByRequestID

func (s *Store) GetActionsByRequestID(ctx context.Context, id uuid.UUID) ([]models.Action, error)

GetActionsByRequestID fetches actions for a particular request

func (*Store) GetAttendeeComponentByEUA

func (s *Store) GetAttendeeComponentByEUA(ctx context.Context, euaID string, trbRequestID uuid.UUID) (*string, error)

GetAttendeeComponentByEUA attempts to retrieve the component of a given EUA user ID and TRB Request ID

func (*Store) GetFundingSourcesByRequestID

func (s *Store) GetFundingSourcesByRequestID(ctx context.Context, trbRequestID uuid.UUID) ([]*models.TRBFundingSource, error)

GetFundingSourcesByRequestID queries the DB for all the TRB request form funding sources matching the given TRB request ID

func (*Store) GetGovernanceRequestFeedbacksByIntakeID

func (s *Store) GetGovernanceRequestFeedbacksByIntakeID(ctx context.Context, intakeID uuid.UUID) ([]*models.GovernanceRequestFeedback, error)

GetGovernanceRequestFeedbacksByIntakeID returns all governance request feedback items for a given system intake

func (*Store) GetMyTRBRequests

func (s *Store) GetMyTRBRequests(ctx context.Context, archived bool) ([]*models.TRBRequest, error)

GetMyTRBRequests returns the collection of TRB requests that belong to the user in the context

func (*Store) GetNewestTRBRequestFeedbackByTRBRequestID

func (s *Store) GetNewestTRBRequestFeedbackByTRBRequestID(ctx context.Context, trbRequestID uuid.UUID) (*models.TRBRequestFeedback, error)

GetNewestTRBRequestFeedbackByTRBRequestID queries the DB the newest TRB request feedback record matching the given TRB request ID

func (*Store) GetSystemIntakeDocumentsByRequestID

func (s *Store) GetSystemIntakeDocumentsByRequestID(ctx context.Context, systemIntakeRequestID uuid.UUID) ([]*models.SystemIntakeDocument, error)

GetSystemIntakeDocumentsByRequestID queries the DB for all documents attached to the system intake with the given ID

func (*Store) GetSystemIntakesWithLCIDs

func (s *Store) GetSystemIntakesWithLCIDs(ctx context.Context) ([]*models.SystemIntake, error)

GetSystemIntakesWithLCIDs retrieves all LCIDs that are in use

func (*Store) GetTRBAdminNoteByID

func (s *Store) GetTRBAdminNoteByID(ctx context.Context, id uuid.UUID) (*models.TRBAdminNote, error)

GetTRBAdminNoteByID retrieves a single admin note by its ID

func (*Store) GetTRBAdminNotesByTRBRequestID

func (s *Store) GetTRBAdminNotesByTRBRequestID(ctx context.Context, trbRequestID uuid.UUID) ([]*models.TRBAdminNote, error)

GetTRBAdminNotesByTRBRequestID returns all notes for a given TRB request

func (*Store) GetTRBAdviceLetterByTRBRequestID

func (s *Store) GetTRBAdviceLetterByTRBRequestID(ctx context.Context, trbRequestID uuid.UUID) (*models.TRBAdviceLetter, error)

GetTRBAdviceLetterByTRBRequestID fetches a TRB advice letter record by its associated request's ID

func (*Store) GetTRBAdviceLetterRecommendationByID

func (s *Store) GetTRBAdviceLetterRecommendationByID(ctx context.Context, id uuid.UUID) (*models.TRBAdviceLetterRecommendation, error)

GetTRBAdviceLetterRecommendationByID retrieves a TRB advice letter recommendation record from the database It will not return any entities that have a deleted_at value

func (*Store) GetTRBAdviceLetterRecommendationsByTRBRequestID

func (s *Store) GetTRBAdviceLetterRecommendationsByTRBRequestID(ctx context.Context, trbRequestID uuid.UUID) ([]*models.TRBAdviceLetterRecommendation, error)

GetTRBAdviceLetterRecommendationsByTRBRequestID queries the DB for all the TRB advice letter recommendations, filtering by the given TRB request ID and ordered in the user-specified positions

func (*Store) GetTRBAdviceLetterRecommendationsSharingTRBRequestID

func (s *Store) GetTRBAdviceLetterRecommendationsSharingTRBRequestID(ctx context.Context, recommendationID uuid.UUID) ([]*models.TRBAdviceLetterRecommendation, error)

GetTRBAdviceLetterRecommendationsSharingTRBRequestID queries the DB for all TRB advice letter recommendations with the same TRB request ID as the given recommendation It will not return any entities that have a deleted_at value

func (*Store) GetTRBLeadOptions

func (s *Store) GetTRBLeadOptions(ctx context.Context) ([]*models.TRBLeadOption, error)

GetTRBLeadOptions retrieves all TRB lead option records from the database

func (*Store) GetTRBRecommendationsByAdminNoteID

func (s *Store) GetTRBRecommendationsByAdminNoteID(ctx context.Context, adminNoteID uuid.UUID) ([]*models.TRBAdviceLetterRecommendation, error)

GetTRBRecommendationsByAdminNoteID fetches all TRB advice letter documents linked to a TRB admin note This function specifically fetches all recommendations (even deleted ones), as this function is called by the resolver for TRB Admin Notes, which need to display previously deleted recommendation titles

func (*Store) GetTRBRequestAttendeesByTRBRequestID

func (s *Store) GetTRBRequestAttendeesByTRBRequestID(ctx context.Context, trbRequestID uuid.UUID) ([]*models.TRBRequestAttendee, error)

GetTRBRequestAttendeesByTRBRequestID queries the DB for all the TRB request attendee records matching the given TRB request ID

func (*Store) GetTRBRequestByID

func (s *Store) GetTRBRequestByID(ctx context.Context, id uuid.UUID) (*models.TRBRequest, error)

GetTRBRequestByID takes in a NamedPreparer (db, tx) and returns an TRBRequest from the db for a given id

func (*Store) GetTRBRequestByIDNP

func (s *Store) GetTRBRequestByIDNP(ctx context.Context, np sqlutils.NamedPreparer, id uuid.UUID) (*models.TRBRequest, error)

GetTRBRequestByIDNP returns an TRBRequest from the db for a given id

func (*Store) GetTRBRequestDocumentsByAdminNoteID

func (s *Store) GetTRBRequestDocumentsByAdminNoteID(ctx context.Context, adminNoteID uuid.UUID) ([]*models.TRBRequestDocument, error)

GetTRBRequestDocumentsByAdminNoteID fetches all TRB request documents linked to a TRB admin note This function specifically fetches all documents (even deleted ones), as this function is called by the resolver for TRB Admin Notes, which need to display previously deleted document names

func (*Store) GetTRBRequestDocumentsByRequestID

func (s *Store) GetTRBRequestDocumentsByRequestID(ctx context.Context, trbRequestID uuid.UUID) ([]*models.TRBRequestDocument, error)

GetTRBRequestDocumentsByRequestID queries the DB for all documents attached to the TRB request with the given ID It will NOT return any items that have been soft-deleted (deleted_at NOT NULL)

func (*Store) GetTRBRequestFeedbackByTRBRequestID

func (s *Store) GetTRBRequestFeedbackByTRBRequestID(ctx context.Context, trbRequestID uuid.UUID) ([]*models.TRBRequestFeedback, error)

GetTRBRequestFeedbackByTRBRequestID queries the DB for all the TRB request feedback records matching the given TRB request ID

func (*Store) GetTRBRequestFormByTRBRequestID

func (s *Store) GetTRBRequestFormByTRBRequestID(ctx context.Context, trbRequestID uuid.UUID) (*models.TRBRequestForm, error)

GetTRBRequestFormByTRBRequestID queries the DB for all the TRB request form records matching the given TRB request ID

func (*Store) GetTRBRequestSystemIntakesByTRBRequestID

func (s *Store) GetTRBRequestSystemIntakesByTRBRequestID(ctx context.Context, trbRequestID uuid.UUID) ([]*models.SystemIntake, error)

GetTRBRequestSystemIntakesByTRBRequestID retrieves all system intakes that have been related to a given TRB request ID

func (*Store) GetTRBRequests

func (s *Store) GetTRBRequests(ctx context.Context, archived bool) ([]*models.TRBRequest, error)

GetTRBRequests returns the collection of TRB requests

func (*Store) PrepareNamed

func (s *Store) PrepareNamed(query string) (*sqlx.NamedStmt, error)

PrepareNamed implements the NamedPreparer interface Implementing the sqlutils.NamedPreparer interface allows us to use a sqlx.Tx or a storage.Store as a parameter in our DB calls (the former for when we want to implement transactions, the latter for when we don't)

func (*Store) SetSystemIntakeContractNumbers

func (s *Store) SetSystemIntakeContractNumbers(ctx context.Context, tx *sqlx.Tx, systemIntakeID uuid.UUID, contractNumbers []string) error

SetSystemIntakeContractNumbers links given Contract Numbers to given System Intake ID This function opts to take a *sqlx.Tx instead of a NamedPreparer because the SQL calls inside this function are heavily intertwined, and we never want to call them outside the scope of a transaction

func (*Store) SetSystemIntakeSystems

func (s *Store) SetSystemIntakeSystems(ctx context.Context, tx *sqlx.Tx, systemIntakeID uuid.UUID, systemIDs []string) error

SetSystemIntakeSystems links given System IDs to given System Intake ID This function opts to take a *sqlx.Tx instead of a NamedPreparer because the SQL calls inside this function are heavily intertwined, and we never want to call them outside the scope of a transaction

func (*Store) SetTRBAdminNoteArchived

func (s *Store) SetTRBAdminNoteArchived(ctx context.Context, id uuid.UUID, isArchived bool, modifiedBy string) (*models.TRBAdminNote, error)

SetTRBAdminNoteArchived sets whether a TRB admin note is archived (soft-deleted) It takes a modifiedBy argument because it doesn't take a full TRBAdminNote as an argument, and ModifiedBy fields are usually set by the resolver.

func (*Store) SetTRBRequestContractNumbers

func (s *Store) SetTRBRequestContractNumbers(ctx context.Context, tx *sqlx.Tx, trbRequestID uuid.UUID, contractNumbers []string) error

SetTRBRequestContractNumbers links given Contract Numbers to given TRB Request ID This function opts to take a *sqlx.Tx instead of a NamedPreparer because the SQL calls inside this function are heavily intertwined, and we never want to call them outside the scope of a transaction

func (*Store) SetTRBRequestSystems

func (s *Store) SetTRBRequestSystems(ctx context.Context, tx *sqlx.Tx, trbRequestID uuid.UUID, systemIDs []string) error

SetTRBRequestSystems links given System IDs to given TRB Request ID This function opts to take a *sqlx.Tx instead of a NamedPreparer because the SQL calls inside this function are heavily intertwined, and we never want to call them outside the scope of a transaction

func (*Store) SystemIntakeContractNumbersBySystemIntakeIDLOADER

func (s *Store) SystemIntakeContractNumbersBySystemIntakeIDLOADER(ctx context.Context, paramTableJSON string) (map[string][]*models.SystemIntakeContractNumber, error)

SystemIntakeContractNumbersBySystemIntakeIDLOADER gets multiple groups of Contract Numbers by System Intake ID

func (*Store) SystemIntakeSystemsBySystemIntakeIDLOADER

func (s *Store) SystemIntakeSystemsBySystemIntakeIDLOADER(ctx context.Context, paramTableJSON string) (map[string][]*models.SystemIntakeSystem, error)

SystemIntakeSystemsBySystemIntakeIDLOADER gets multiple groups of system ids by System Intake ID

func (*Store) TRBRequestContractNumbersByTRBRequestIDLOADER

func (s *Store) TRBRequestContractNumbersByTRBRequestIDLOADER(ctx context.Context, paramTableJSON string) (map[string][]*models.TRBRequestContractNumber, error)

TRBRequestContractNumbersByTRBRequestIDLOADER gets multiple groups of Contract Numbers by TRB Request ID

func (*Store) TRBRequestSystemsByTRBRequestIDLOADER

func (s *Store) TRBRequestSystemsByTRBRequestIDLOADER(ctx context.Context, paramTableJSON string) (map[string][]*models.TRBRequestSystem, error)

TRBRequestSystemsByTRBRequestIDLOADER gets multiple groups of system ids by TRB Request ID

func (*Store) TruncateAllTablesDANGEROUS

func (s *Store) TruncateAllTablesDANGEROUS(logger *zap.Logger) error

TruncateAllTablesDANGEROUS is a function to reset all tables in the DB. It should only be called within test code. this list of tables should match the list of tables in scripts/dev's db:clean task

func (*Store) UpdateAdminLead

func (s *Store) UpdateAdminLead(ctx context.Context, id uuid.UUID, adminLead string) (string, error)

UpdateAdminLead updates the admin lead for an intake

func (*Store) UpdateBusinessCase

func (s *Store) UpdateBusinessCase(ctx context.Context, businessCase *models.BusinessCase) (*models.BusinessCase, error)

UpdateBusinessCase creates a business case

func (*Store) UpdateReviewDates

func (s *Store) UpdateReviewDates(ctx context.Context, id uuid.UUID, grbDate *time.Time, grtDate *time.Time) (*models.SystemIntake, error)

UpdateReviewDates updates the admin lead for an intake

func (*Store) UpdateSystemIntake

func (s *Store) UpdateSystemIntake(ctx context.Context, intake *models.SystemIntake) (*models.SystemIntake, error)

UpdateSystemIntake serves as a wrapper for UpdateSystemIntakeNP, which is the actual implementation for updating System Intakes.

This method only exists to provide a transactional wrapper around the actual implementation, as a vast majority of the codebase was written before the introduction of transactions in the storage layer. This method should eventually be removed in favor of using UpdateSystemIntakeNP directly (and that function renamed).

func (*Store) UpdateSystemIntakeContact

func (s *Store) UpdateSystemIntakeContact(ctx context.Context, systemIntakeContact *models.SystemIntakeContact) (*models.SystemIntakeContact, error)

UpdateSystemIntakeContact updates a system intake contact object in the database

func (*Store) UpdateSystemIntakeFundingSources

func (s *Store) UpdateSystemIntakeFundingSources(ctx context.Context, systemIntakeID uuid.UUID, fundingSources []*models.SystemIntakeFundingSource) ([]*models.SystemIntakeFundingSource, error)

func (*Store) UpdateSystemIntakeFundingSourcesNP

func (s *Store) UpdateSystemIntakeFundingSourcesNP(ctx context.Context, tx *sqlx.Tx, systemIntakeID uuid.UUID, fundingSources []*models.SystemIntakeFundingSource) ([]*models.SystemIntakeFundingSource, error)

UpdateSystemIntakeFundingSources clears and updates the funding sources of a system intake

func (*Store) UpdateSystemIntakeLinkedCedarSystem

func (s *Store) UpdateSystemIntakeLinkedCedarSystem(ctx context.Context, id uuid.UUID, cedarSystemID null.String) (*models.SystemIntake, error)

UpdateSystemIntakeLinkedCedarSystem updates the CEDAR system ID that is linked to a system intake

func (*Store) UpdateSystemIntakeNP

func (s *Store) UpdateSystemIntakeNP(ctx context.Context, np sqlutils.NamedPreparer, intake *models.SystemIntake) (*models.SystemIntake, error)

UpdateSystemIntakeNP does an upsert for a system intake The caller is responsible for setting intake.UpdatedAt if they want to update that field

The "NP" suffix stands for "NamedPreparer", as this function was written to avoid the need to update all of the existing code that uses UpdateSystemIntake to use a transactional wrapper.

func (*Store) UpdateSystemIntakeNote

func (s *Store) UpdateSystemIntakeNote(ctx context.Context, note *models.SystemIntakeNote) (*models.SystemIntakeNote, error)

UpdateSystemIntakeNote updates all of a IT governance admin note's mutable fields. The note's IsArchived field _can_ be set, though SetNoteArchived() should be used when archiving a note.

func (*Store) UpdateTRBAdviceLetter

func (s *Store) UpdateTRBAdviceLetter(ctx context.Context, letter *models.TRBAdviceLetter) (*models.TRBAdviceLetter, error)

UpdateTRBAdviceLetter updates all of a TRB advice letter's mutable fields. The letter's status _can_ be set, though UpdateTRBAdviceLetterStatus() should be used when setting a letter ready for review or sending a letter.

func (*Store) UpdateTRBAdviceLetterRecommendation

func (s *Store) UpdateTRBAdviceLetterRecommendation(ctx context.Context, recommendation *models.TRBAdviceLetterRecommendation) (*models.TRBAdviceLetterRecommendation, error)

UpdateTRBAdviceLetterRecommendation updates an existing TRB advice letter recommendation record in the database This purposely does not update the position_in_letter column - to update that, use UpdateTRBAdviceLetterRecommendationOrder()

func (*Store) UpdateTRBAdviceLetterRecommendationOrder

func (s *Store) UpdateTRBAdviceLetterRecommendationOrder(
	ctx context.Context,
	trbRequestID uuid.UUID,
	newOrder []uuid.UUID,
) ([]*models.TRBAdviceLetterRecommendation, error)

UpdateTRBAdviceLetterRecommendationOrder updates the ordering of recommendations for a given advice letter, using the order of the recommendation IDs passed in as newOrder. No other recommendation columns/fields are updated.

func (*Store) UpdateTRBAdviceLetterStatus

func (s *Store) UpdateTRBAdviceLetterStatus(ctx context.Context, id uuid.UUID, status models.TRBAdviceLetterStatus) (*models.TRBAdviceLetter, error)

UpdateTRBAdviceLetterStatus sets the status of a TRB advice letter, for setting the letter as ready to review or sending the letter. When it sends the letter, it also updates the DateSent field.

func (*Store) UpdateTRBRequest

func (s *Store) UpdateTRBRequest(ctx context.Context, trbRequest *models.TRBRequest) (*models.TRBRequest, error)

UpdateTRBRequest returns an TRBRequest from the db for a given id

func (*Store) UpdateTRBRequestAttendee

func (s *Store) UpdateTRBRequestAttendee(ctx context.Context, attendee *models.TRBRequestAttendee) (*models.TRBRequestAttendee, error)

UpdateTRBRequestAttendee updates a TRB request attendee record in the database

func (*Store) UpdateTRBRequestForm

func (s *Store) UpdateTRBRequestForm(ctx context.Context, form *models.TRBRequestForm) (*models.TRBRequestForm, error)

UpdateTRBRequestForm updates a TRB request form record in the database

func (*Store) UpdateTRBRequestFundingSources

func (s *Store) UpdateTRBRequestFundingSources(
	ctx context.Context,
	trbRequestID uuid.UUID,
	fundingNumber string,
	fundingSources []*models.TRBFundingSource,
) ([]*models.TRBFundingSource, error)

UpdateTRBRequestFundingSources upserts a list of funding sources to a TRB Request Form by funding number

func (*Store) UpdateTRBRequestNP

func (s *Store) UpdateTRBRequestNP(ctx context.Context, np sqlutils.NamedPreparer, trb *models.TRBRequest) (*models.TRBRequest, error)

UpdateTRBRequestNP takes in a NamedPreparer (db, tx) and returns an TRBRequest from the db for a given id

func (*Store) UserAccountCreate

func (s *Store) UserAccountCreate(np sqlutils.NamedPreparer, userAccount *authentication.UserAccount) (*authentication.UserAccount, error)

UserAccountCreate creates a new user account for a given username

func (*Store) UserAccountGetByCommonName

func (s *Store) UserAccountGetByCommonName(commonName string) (*authentication.UserAccount, error)

UserAccountGetByCommonName gets a user account by a give username

func (*Store) UserAccountGetByID

func (s *Store) UserAccountGetByID(np sqlutils.NamedPreparer, id uuid.UUID) (*authentication.UserAccount, error)

UserAccountGetByID gets a User account from the database by its internal id.

func (*Store) UserAccountGetByIDLOADER

func (s *Store) UserAccountGetByIDLOADER(
	_ *zap.Logger,
	paramTableJSON string,
) ([]*authentication.UserAccount, error)

UserAccountGetByIDLOADER gets multiple User account from the database by its internal id.

func (*Store) UserAccountGetByUsername

func (s *Store) UserAccountGetByUsername(username string) (*authentication.UserAccount, error)

UserAccountGetByUsername gets a user account by a give username

func (*Store) UserAccountUpdateByUserName

func (s *Store) UserAccountUpdateByUserName(np sqlutils.NamedPreparer, userAccount *authentication.UserAccount) (
	*authentication.UserAccount,
	error,
)

UserAccountUpdateByUserName updates an existing user account for a given username

Jump to

Keyboard shortcuts

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