Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nfc: extend table foreign keys to include column names #2293

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions meta/antenna.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ var InstalledAntennaTable Table = Table{
headers: installedAntennaHeaders,
primary: []string{"Make", "Model", "Serial", "Mark", "Start Date"},
native: []string{"Height", "North", "East", "Azimuth"},
foreign: map[string][]string{
"Asset": {"Make", "Model", "Serial"},
"Mark": {"Mark"},
foreign: map[string]map[string]string{
"Asset": {"Make": "Make", "Model": "Model", "Serial": "Serial"},
"Mark": {"Mark": "Mark"},
},
remap: map[string]string{
"Start Date": "Start",
Expand Down
9 changes: 5 additions & 4 deletions meta/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ var assetHeaders Header = map[string]int{
}

var AssetTable Table = Table{
name: "Asset",
headers: assetHeaders,
primary: []string{"Make", "Model", "Serial"},
foreign: map[string][]string{},
name: "Asset",
headers: assetHeaders,
primary: []string{"Make", "Model", "Serial"},
foreign: map[string]map[string]string{},
nullable: []string{"Notes", "Number"},
}

type AssetList []Asset
Expand Down
10 changes: 8 additions & 2 deletions meta/calibration.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ var CalibrationTable Table = Table{
headers: calibrationHeaders,
primary: []string{"Make", "Model", "Serial", "Number", "Start Date"},
native: []string{"Scale Factor", "Scale Bias", "Scale Absolute", "Frequency"},
foreign: map[string][]string{
"Asset": {"Make", "Model", "Serial"},
foreign: map[string]map[string]string{
"Asset": {"Make": "Make", "Model": "Model", "Serial": "Serial"},
},
nullable: []string{"Frequency"},
defaults: map[string]string{
"Scale Factor": "1.0",
"Scale Absolute": "0.0",
"Scale Bias": "0.0",
},
remap: map[string]string{
"Scale Factor": "ScaleFactor",
Expand Down
7 changes: 4 additions & 3 deletions meta/camera.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ var InstalledCameraTable Table = Table{
headers: installedCameraHeaders,
primary: []string{"Make", "Model", "Serial", "Start Date"},
native: []string{"Azimuth", "Dip", "Height", "North", "East"},
foreign: map[string][]string{
"Asset": {"Make", "Model", "Serial"},
"Mount": {"Mount"},
foreign: map[string]map[string]string{
"Asset": {"Make": "Make", "Model": "Model", "Serial": "Serial"},
"Mount": {"Mount": "Mount"},
},
nullable: []string{"Notes"},
remap: map[string]string{
"Start Date": "Start",
"End Date": "End",
Expand Down
13 changes: 6 additions & 7 deletions meta/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ var channelHeaders Header = map[string]int{
}

var ChannelTable Table = Table{
name: "Channel",
headers: channelHeaders,
primary: []string{"Make", "Model", "Number", "SamplingRate"},
native: []string{"Number", "SamplingRate"},
foreign: map[string][]string{
"Network": {"Network"},
},
name: "Channel",
headers: channelHeaders,
primary: []string{"Make", "Model", "Number", "SamplingRate"},
native: []string{"Number", "SamplingRate"},
foreign: map[string]map[string]string{},
nullable: []string{"Number", "Response"},
}

// Channel is used to describe a generic recording from a Datalogger.
Expand Down
11 changes: 6 additions & 5 deletions meta/citation.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ var citationHeaders Header = map[string]int{
}

var CitationTable Table = Table{
name: "Citation",
headers: citationHeaders,
primary: []string{"Key"},
native: []string{"Year"},
foreign: map[string][]string{},
name: "Citation",
headers: citationHeaders,
primary: []string{"Key"},
native: []string{"Year"},
foreign: map[string]map[string]string{},
nullable: []string{"DOI", "Link", "Pages", "Published", "Retrieved", "Volume"},
}

type Citation struct {
Expand Down
13 changes: 6 additions & 7 deletions meta/class.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ var classHeaders Header = map[string]int{
}

var ClassTable Table = Table{
name: "Class",
headers: classHeaders,
primary: []string{"Station"},
native: []string{"Vs30", "Basement Depth"},
foreign: map[string][]string{
"Citations": {"Citation"},
},
name: "Class",
headers: classHeaders,
primary: []string{"Station"},
native: []string{"Vs30", "Basement Depth"},
foreign: map[string]map[string]string{},
nullable: []string{"Citations", "Link", "Notes"},
remap: map[string]string{
"Site Class": "SiteClass",
"Vs30 Quality": "Vs30Quality",
Expand Down
13 changes: 6 additions & 7 deletions meta/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ var componentHeaders Header = map[string]int{
}

var ComponentTable Table = Table{
name: "Component",
headers: componentHeaders,
primary: []string{"Make", "Model", "Number", "Source", "Subsource", "Sampling Rate"},
native: []string{"Number", "Dip", "Azimuth", "Sampling Rate"},
foreign: map[string][]string{
"Asset": {"Make", "Model"},
},
name: "Component",
headers: componentHeaders,
primary: []string{"Make", "Model", "Number", "Source", "Subsource", "Sampling Rate"},
native: []string{"Number", "Dip", "Azimuth", "Sampling Rate"},
foreign: map[string]map[string]string{},
nullable: []string{"Sampling Rate", "Source", "Type"},
remap: map[string]string{
"Sampling Rate": "SamplingRate",
},
Expand Down
5 changes: 3 additions & 2 deletions meta/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ var ConnectionTable Table = Table{
name: "Connection",
headers: connectionHeaders,
primary: []string{"Station", "Location", "Place", "Number", "Start Date"},
foreign: map[string][]string{
"Site": {"Station", "Location"},
foreign: map[string]map[string]string{
"Site": {"Station": "Station", "Location": "Location"},
},
nullable: []string{"Role", "Number", "Location"},
remap: map[string]string{
"Start Date": "Start",
"End Date": "End",
Expand Down
4 changes: 2 additions & 2 deletions meta/constituent.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ var ConstituentTable Table = Table{
headers: constituentHeaders,
primary: []string{"Gauge", "Number", "Start Date"},
native: []string{"Amplitude", "Lage"},
foreign: map[string][]string{
"Gauge": {"Gauge"},
foreign: map[string]map[string]string{
"Gauge": {"Gauge": "Gauge"},
},
remap: map[string]string{
"Start Date": "Start",
Expand Down
2 changes: 1 addition & 1 deletion meta/dart.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var DartTable Table = Table{
headers: dartHeaders,
primary: []string{"Station", "Start Date"},
native: []string{},
foreign: map[string][]string{},
foreign: map[string]map[string]string{},
remap: map[string]string{
"WMO Identifier": "WmoIdentifier",
"Start Date": "Start",
Expand Down
7 changes: 4 additions & 3 deletions meta/datalogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ var DeployedDataloggerTable Table = Table{
headers: deployedDataloggerHeaders,
primary: []string{"Make", "Model", "Serial", "Place", "Role", "Start Date"},
native: []string{},
foreign: map[string][]string{
"Asset": {"Make", "Model", "Serial"},
"Connection": {"Place", "Role"},
foreign: map[string]map[string]string{
"Asset": {"Make": "Make", "Model": "Model", "Serial": "Serial"},
"Connection": {"Place": "Place", "Role": "Role"},
},
nullable: []string{"Role"},
remap: map[string]string{
"Start Date": "Start",
"End Date": "End",
Expand Down
6 changes: 3 additions & 3 deletions meta/doas.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ var InstalledDoasTable Table = Table{
headers: installedDoasHeaders,
primary: []string{"Make", "Model", "Serial", "Start Date"},
native: []string{"Azimuth", "Dip", "Height", "North", "East"},
foreign: map[string][]string{
"Asset": {"Make", "Model", "Serial"},
"Mount": {"Mount"},
foreign: map[string]map[string]string{
"Asset": {"Make": "Make", "Model": "Model", "Serial": "Serial"},
"Mount": {"Mount": "Mount"},
},
remap: map[string]string{
"Start Date": "Start",
Expand Down
5 changes: 3 additions & 2 deletions meta/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ var FeatureTable Table = Table{
name: "Feature",
headers: featureHeaders,
primary: []string{"Station", "Location", "Sublocation", "Property", "Description", "Aspect", "Start Date"},
foreign: map[string][]string{
"Site": {"Station", "Location"},
foreign: map[string]map[string]string{
"Site": {"Station": "Station", "Location": "Location"},
},
nullable: []string{"Aspect", "Description", "Location", "Sublocation"},
remap: map[string]string{
"Start Date": "Start",
"End Date": "End",
Expand Down
5 changes: 3 additions & 2 deletions meta/firmware.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ var FirmwareHistoryTable Table = Table{
headers: firmwareHistoryHeaders,
primary: []string{"Make", "Model", "Serial", "Start Date"},
native: []string{},
foreign: map[string][]string{
"Asset": {"Make", "Model", "Serial"},
foreign: map[string]map[string]string{
"Asset": {"Make": "Make", "Model": "Model", "Serial": "Serial"},
},
nullable: []string{"Notes"},
remap: map[string]string{
"Start Date": "Start",
"End Date": "End",
Expand Down
14 changes: 6 additions & 8 deletions meta/gain.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ var gainHeaders Header = map[string]int{
}

var GainTable Table = Table{
name: "Gain",
headers: gainHeaders,
primary: []string{"Station", "Location", "Sublocation", "Subsource", "Start Date"},
native: []string{"Scale Factor", "Scale Bias", "Absolute Bias"},
foreign: map[string][]string{
"Site": {"Station", "Location"},
"Feature": {"Station", "Location", "Sublocation"},
},
name: "Gain",
headers: gainHeaders,
primary: []string{"Station", "Location", "Sublocation", "Subsource", "Start Date"},
native: []string{"Scale Factor", "Scale Bias", "Absolute Bias"},
foreign: map[string]map[string]string{},
nullable: []string{"Absolute Bias", "Scale Bias", "Scale Factor", "Sublocation", "Subsource"},
remap: map[string]string{
"Scale Factor": "Factor",
"Scale Bias": "Bias",
Expand Down
4 changes: 2 additions & 2 deletions meta/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var GaugeTable Table = Table{
//TODO: the Analysis Latitude is a used to avoid an overlap clash on NZC
primary: []string{"Gauge", "Identification Number", "Analysis Latitude", "Start Date"},
native: []string{"Analysis Time Zone", "Analysis Latitude", "Analysis Longitude"},
foreign: map[string][]string{
"Network": {"Network"},
foreign: map[string]map[string]string{
"Network": {"Network": "Network"},
},
remap: map[string]string{
"Gauge": "Code",
Expand Down
4 changes: 2 additions & 2 deletions meta/mark.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ var MarkTable Table = Table{
headers: markHeaders,
primary: []string{"Mark", "Start Date"},
native: []string{"Latitude", "Longitude", "Elevation"},
foreign: map[string][]string{
"Network": {"Network"},
foreign: map[string]map[string]string{
"Network": {"Network": "Network"},
},
remap: map[string]string{
"Mark": "Code",
Expand Down
7 changes: 4 additions & 3 deletions meta/metsensor.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ var InstalledMetSensorTable Table = Table{
headers: installedMetSensorHeaders,
primary: []string{"Make", "Model", "Serial", "Start Date"},
native: []string{"Latitude", "Longitude", "Elevation", "Humidity", "Pressure", "Temperature"},
foreign: map[string][]string{
"Asset": {"Make", "Model", "Serial"},
"Mark": {"Mark"},
foreign: map[string]map[string]string{
"Asset": {"Make": "Make", "Model": "Model", "Serial": "Serial"},
"Mark": {"Mark": "Mark"},
},
nullable: []string{"IMS Comment"},
remap: map[string]string{
"IMS Comment": "IMSComment",
"Start Date": "Start",
Expand Down
5 changes: 3 additions & 2 deletions meta/monument.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ var MonumentTable Table = Table{
headers: monumentHeaders,
primary: []string{"Mark"},
native: []string{"Ground Relationship", "Foundation Depth"},
foreign: map[string][]string{
"Mark": {"Mark"},
foreign: map[string]map[string]string{
"Mark": {"Mark": "Mark"},
},
nullable: []string{"Domes Number", "Geology", "Bedrock"},
remap: map[string]string{
"Domes Number": "DomesNumber",
"Mark Type": "MarkType",
Expand Down
4 changes: 2 additions & 2 deletions meta/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ var MountTable Table = Table{
headers: mountHeaders,
primary: []string{"Mount", "Start Date"},
native: []string{"Latitude", "Longitude", "Elevation"},
foreign: map[string][]string{
"Network": {"Network"},
foreign: map[string]map[string]string{
"Network": {"Network": "Network"},
},
remap: map[string]string{
"Mount": "Code",
Expand Down
2 changes: 1 addition & 1 deletion meta/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var NetworkTable Table = Table{
headers: networkHeaders,
primary: []string{"Network"},
native: []string{},
foreign: map[string][]string{},
foreign: map[string]map[string]string{},
remap: map[string]string{
"Network": "Code",
},
Expand Down
4 changes: 2 additions & 2 deletions meta/placenames.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ var placenameHeaders Header = map[string]int{
}

var PlacenameTable Table = Table{
name: "Name",
name: "Placename",
headers: placenameHeaders,
primary: []string{"Name"},
native: []string{"Latitude", "Longitude", "Level"},
foreign: map[string][]string{},
foreign: map[string]map[string]string{},
}

// Placename is used to describe distances and azimuths to known places.
Expand Down
5 changes: 3 additions & 2 deletions meta/point.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ var PointTable Table = Table{
headers: pointHeaders,
primary: []string{"Sample", "Location", "Start Date"},
native: []string{"Latitude", "Longitude", "Elevation", "Depth"},
foreign: map[string][]string{
"Sample": {"Sample"},
foreign: map[string]map[string]string{
"Sample": {"Code": "Sample"},
},
nullable: []string{"Depth"},
remap: map[string]string{
"Start Date": "Start",
"End Date": "End",
Expand Down
5 changes: 3 additions & 2 deletions meta/polarity.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ var PolarityTable Table = Table{
primary: []string{"Station", "Location", "Sublocation", "Subsource", "Start Date"},
//native: []string{"Primary", "Reversed"},
native: []string{},
foreign: map[string][]string{
"Site": {"Station", "Location"},
foreign: map[string]map[string]string{
"Site": {"Station": "Station", "Location": "Location"},
},
nullable: []string{"Citation", "Method", "Sublocation", "Subsource"},
remap: map[string]string{
"Primary": "IsPrimary",
"Reversed": "IsReversed",
Expand Down
5 changes: 3 additions & 2 deletions meta/preamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ var PreampTable Table = Table{
headers: preampHeaders,
primary: []string{"Station", "Location", "Subsource", "Start Date"},
native: []string{"Scale Factor"},
foreign: map[string][]string{
"Site": {"Station", "Location"},
foreign: map[string]map[string]string{
"Site": {"Station": "Station", "Location": "Location"},
},
nullable: []string{"Subsource"},
remap: map[string]string{
"Scale Factor": "ScaleFactor",
"Start Date": "Start",
Expand Down
4 changes: 2 additions & 2 deletions meta/radome.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ var InstalledRadomeTable Table = Table{
headers: installedRadomeHeaders,
primary: []string{"Make", "Model", "Serial", "Start Date"},
native: []string{},
foreign: map[string][]string{
"Mark": {"Mark"},
foreign: map[string]map[string]string{
"Mark": {"Mark": "Mark"},
},
remap: map[string]string{
"Start Date": "Start",
Expand Down
6 changes: 3 additions & 3 deletions meta/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ var DeployedReceiverTable Table = Table{
headers: deployedReceiverHeaders,
primary: []string{"Make", "Model", "Serial", "Start Date"},
native: []string{},
foreign: map[string][]string{
"Asset": {"Make", "Model", "Serial"},
"Mark": {"Mark"},
foreign: map[string]map[string]string{
"Asset": {"Make": "Make", "Model": "Model", "Serial": "Serial"},
"Mark": {"Mark": "Mark"},
},
remap: map[string]string{
"Start Date": "Start",
Expand Down
Loading
Loading