Documentation
¶
Index ¶
- type DatabaseImport
- func (di *DatabaseImport) AddError(value string, errMsg string, columns ...string)
- func (di *DatabaseImport) New(parser *Parser, uid int, databaseName string, langIsocode string, ...) error
- func (di *DatabaseImport) ProcessDatabaseName(name string) error
- func (di *DatabaseImport) ProcessEssentialDatabaseInfos(name string, geographicalExtent string, selectedContinents []int, ...) error
- func (di *DatabaseImport) ProcessRecord(f *Fields)
- func (di *DatabaseImport) Save(filename string) (int, error)
- type DatabaseInfos
- type Fields
- type ImportError
- type Parser
- type ParserError
- type SiteRangeCharacInfos
- type UserChoices
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DatabaseImport ¶
type DatabaseImport struct {
SitesProcessed map[string]int
Database *DatabaseInfos
CurrentSite *model.SiteInfos
CurrentSiteRange *model.Site_range
CurrentSiteRangeCharac *SiteRangeCharacInfos
Tx *sqlx.Tx
Parser *Parser
Uid int
ArkeoCharacs map[string]map[string]int
//ArkeoCharacsIDs map[int][]int
NumberOfSites int
SitesWithError map[string]bool
CachedSiteRanges map[string]int
Errors []*ImportError
Md5sum string
UserLang string
}
DatabaseImport is a meta struct which stores all the informations about a site
func (*DatabaseImport) AddError ¶
func (di *DatabaseImport) AddError(value string, errMsg string, columns ...string)
AddError structures errors to be logged or returned to client
func (*DatabaseImport) New ¶
func (di *DatabaseImport) New(parser *Parser, uid int, databaseName string, langIsocode string, filehash string, tx *sqlx.Tx) error
New creates a new import process
func (*DatabaseImport) ProcessDatabaseName ¶
func (di *DatabaseImport) ProcessDatabaseName(name string) error
processDatabaseName verifies if a database name already exist for a user and create or update the sql entry
func (*DatabaseImport) ProcessEssentialDatabaseInfos ¶
func (di *DatabaseImport) ProcessEssentialDatabaseInfos(name string, geographicalExtent string, selectedContinents []int, selectedCountries []int) error
ProcessEssentialDatabaseInfos store or update informations about database defined by user at step 1
func (*DatabaseImport) ProcessRecord ¶
func (di *DatabaseImport) ProcessRecord(f *Fields)
ProcessRecord is triggered for each line of csv
type DatabaseInfos ¶
type DatabaseInfos struct {
model.Database
model.Database_tr
Authors []int
Continents []int
Countries []int
Exists bool
Init bool
}
DatabaseInfos is a meta struct which stores all the informations about a database
type Fields ¶
type Fields struct {
DATABASE_SOURCE_NAME string
SITE_SOURCE_ID string
SITE_NAME string
MAIN_CITY_NAME string
GEONAME_ID string
PROJECTION_SYSTEM string
LONGITUDE string
LATITUDE string
ALTITUDE string
STATE_OF_KNOWLEDGE string
CITY_CENTROID string
OCCUPATION string
STARTING_PERIOD string
ENDING_PERIOD string
CARAC_NAME string
CARAC_LVL1 string
CARAC_LVL2 string
CARAC_LVL3 string
CARAC_LVL4 string
CARAC_EXP string
BIBLIOGRAPHY string
COMMENTS string
}
Fields structure list all the fields we can have in the import file It is used by the Parse() function to validate the file and structure the datas for processing
type ImportError ¶
type ImportError struct {
Line int `json:"line"`
SiteCode string `json:"siteCode"`
Value string `json:"value"`
Columns []string `json:"columns"`
ErrMsg string `json:"errMsg"`
}
ImportError is the struct used to return errors, it enhances the errors struct to return more informations like line and field
func (*ImportError) Error ¶
func (e *ImportError) Error() string
The Error() func formats the error message
type Parser ¶
type Parser struct {
Filename string
HeaderFields map[int]string
UserChoices UserChoices
Line int
Lang string
UserLang string
Reader *csv.Reader
Errors []*ParserError
}
Parser type holds the informations about the parsed file and provides functions to parse and store the datas in ArkeoGIS database
func (*Parser) CheckHeader ¶
Parse is the entry point of the parsing process
func (*Parser) SetUserChoices ¶
SetUserChoices is used to configure parser
type SiteRangeCharacInfos ¶
type SiteRangeCharacInfos struct {
model.Site_range__charac
model.Site_range__charac_tr
}
CharacsInfos holds information about characs linked to site range
type UserChoices ¶
type UserChoices struct {
UseGeonames bool
}
UserChoices stores user preferences for the parsing process