databaseimport

package
v0.0.0-...-896db50 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

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

func (*DatabaseImport) Save

func (di *DatabaseImport) Save(filename string) (int, error)

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 NewParser

func NewParser(filename string, langIsocode string, userLangIsocode string) (*Parser, error)

NewParser open csv file and return a *Parser

func (*Parser) AddError

func (p *Parser) AddError(errMsg string, columns ...string)

func (*Parser) CheckHeader

func (p *Parser) CheckHeader() error

Parse is the entry point of the parsing process

func (*Parser) HasError

func (p *Parser) HasError() bool

func (*Parser) Parse

func (p *Parser) Parse(fn func(r *Fields)) error

Parse is the entry point of the parsing process

func (*Parser) SetUserChoices

func (p *Parser) SetUserChoices(item string, val bool)

SetUserChoices is used to configure parser

type ParserError

type ParserError struct {
	Columns []string `json:"columns"`
	ErrMsg  string   `json:"errMsg"`
}

Handle errors

func (*ParserError) Error

func (e *ParserError) Error() string

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

Jump to

Keyboard shortcuts

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