uuid_id | R Documentation |
Return the ResourceID of a feature in a Resource Model (ex: an Heritage Place, a Connected Component) from its EAMENA ID, or the opposite: the ResourceID from the EAMENA ID, and store these ID into a hash() object. A connection with the EAMENA database is needed. The ResourceID is a UUID. This function uses the 'ref_ids()' one for interoperability purposes.
uuid_id( db.con = NA, d = NA, id = NA, field.id = "id", field.uuid = "uuid", id.prj.patt = "^EAMENA-", rm = "hp", disconn = TRUE, verbose = TRUE )
db.con |
a 'dbConnect' connection to the database. |
d |
a hash() object (a Python-like dictionary). |
id |
a project ID (eg. "EAMENA-0187363") or a ResourceID (eg. "12053a2b-9127-47a4-990f-7f5279cd89da"). |
field.id |
the name of the field that will be created in the a hash() object for the EAMENA ID. By default 'id'. |
field.uuid |
the name of the field that will be created in the a hash() object for the UUID. By default 'uuid'. |
id.prj.patt |
a regex matching with the project IDs, by default '"^EAMENA-"'. |
rm |
the Resource Model (ex: HP, connected components). The available values are: "hp" for Heritage places, "cc" for connected compobents (ex: Built component). By default "hp". |
disconn |
if TRUE (default) will disconnect from the DB once done. If FALSE, the user has to disconnect (eg. DBI::dbDisconnect(my_con)). |
verbose |
if TRUE (by default) verbose. |
a hash() object (a Python-like dictionary) with EAMENA ID and ResourceID. If a given ID doesn't exist, will fill the value of the hash dictionary with NA.
d <- hash::hash() my_con <- RPostgres::dbConnect(drv = RPostgres::Postgres(), user = 'xxx', password = 'xxx', dbname = 'eamena', host = 'ec2-54-155-109-226.eu-west-1.compute.amazonaws.com', port = 5432) ## Heritage places # from the EAMENA ID to the UUID d <- uuid_id(db.con = my_con, d = d, id = "EAMENA-0187363", disconn = FALSE) d$uuid # [1] "12053a2b-9127-47a4-990f-7f5279cd89da" # from the UUID to the EAMENA ID d <- hash::hash() d <- uuid_id(db.con = my_con, d = d, id = "12053a2b-9127-47a4-990f-7f5279cd89da", disconn = FALSE) # [1] "EAMENA-0187363" ## Built Components d <- hash::hash() # from the COMPONENT ID to the UUID d <- uuid_id(db.con = my_con, d = d, id = "COMPONENT-0000141", id.prj.patt = "^COMPONENT-", rm = "cc", disconn = FALSE) d$uuid # [1] "90400bb6-ff54-4afd-8183-65c67fa97448" # from the UUID to the COMPONENT ID d <- hash::hash() d <- uuid_id(db.con = my_con, d = d, id = "90400bb6-ff54-4afd-8183-65c67fa97448", rm = "cc", disconn = TRUE) d$id # [1] "COMPONENT-0000141"