Differences
This shows you the differences between two versions of the page.
metamod:user_database [2010-03-10 11:54:50] egils |
metamod:user_database [2022-05-31 09:29:32] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== User database ====== | ||
- | Design of new user database intended for the 2.5 (CryoClim) release of METAMOD | ||
- | |||
- | ===== Design ===== | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ==== Database tables ==== | ||
- | **User** | ||
- | |||
- | |__U_id__ |A_id |U_name |U_email |U_password |U_institution |U_telephone |U_session | | ||
- | |||
- | **DataSet** | ||
- | |||
- | |__DS_id__ |U_id |A_id |DS_name | | ||
- | |||
- | **Info** | ||
- | |||
- | |__DS_id__ |__I_type__ |__I1_id__ |__I2_id__ |I_attribute |I_content | | ||
- | |||
- | **File** | ||
- | |||
- | |__DS_id__ |__F_name__ |F_timestamp |F_size |F_status |F_errurl | | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | The table details are presented below: | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ==== User ==== | ||
- | |||
- | ^U_id |Unique user id (autoincremented number). Primary key | | ||
- | ^A_id |Application id. Many METAMOD applications share the same database. This field has the same value as the APPLICATION_ID in the master_config.txt file. | | ||
- | ^U_name |User name as given in registration form | | ||
- | ^U_email |User E-mail address as given in registration form | | ||
- | ^U_password |User password | | ||
- | ^U_institution |User institution acronym as given in registration form | | ||
- | ^U_telephone |User telephone number as given in registration form | | ||
- | ^U_session |User session id. Random string generated when the user initiate a new interactive session. | | ||
- | |||
- | The U_session field is used to track the state of an interactive user session. The user may only have one interactive session active at any time. If the user initiate a new session when another session is already active, the old session disappears. If the user tries to continue the old session, an error message will be submitted. This is the same mechanism used in the old (METAMOD 2.3 and earlier) file-based version. | ||
- | |||
- | The A_id field connects the user to one of the METAMOD applications that share the same database. If the same person wants to be a user of more than one of these METAMOD applications, | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ==== DataSet ==== | ||
- | |||
- | ^DS_id |Unique dataset id (autoincremented number). Primary key. Not same number as in the Metadata Database | | ||
- | ^U_id |Identifies the user owning the dataset. | | ||
- | ^A_id |Application id. | | ||
- | ^DS_name |Dataset name. Name of dataset as provided by the user. Not the same name as in the corresponding field in the Metadata Database. But the last part of the name found in the Metadata Database field (everything after '/' | ||
- | |||
- | The combination of the '' | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ==== Info ==== | ||
- | |||
- | This table is used to contain various information about a dataset. Each piece of information is identified by the dataset it belongs to (DS_id) and a type tag (I_type) that is a short acronym for a limited set of information types. One piece of information can be contained in one or several table rows (these are all the rows identified by a DS_id, | ||
- | |||
- | Two extra identification fields are used to implement structure to each piece of information: | ||
- | |||
- | * Single entity (as described above). | ||
- | * Two-level hierarchy: Multiple entities where each entity has children or attributes. | ||
- | * Three-level hierarchy: Like a two-level hierarchy with an additional entity alone at the top. This entity may have its own attributes. | ||
- | |||
- | I1_id will always represent a consecutive set of integers starting from 0, and for each of these numbers, I2_id will comprise a similar consecutive set of integers starting from 0. The max value for I2_id will vary between different I1_id values. | ||
- | |||
- | ^DS_id |Identifiles the dataset this info-row belongs to | | ||
- | ^I_type |Type tag. Short acronym that identifies the information type. | | ||
- | ^I1_id |Major integer identifier (see above). | | ||
- | ^I2_id |Minor integer identifier (see above). | | ||
- | ^I_attribute |Attribute name. Optional acronym to identify an attribute. If found, the I_content field is interpreted as an attribute value that software may treat specially. | | ||
- | ^I_content | The actual text string representing an entity or attribute value. | | ||
- | |||
- | For the time being, the following information types (I_type) will be needed: | ||
- | |||
- | ^DSKEY |Dataset key (also called directory key or dirkey) as provided by the user. Single entity | | ||
- | ^LOCATION |Location. Single entity. Absolute path to the directory under which all files belonging to the dataset are found. The files may be found directly in the location direcory, or in any subdirectory of the location directory at any level. | | ||
- | ^CATALOG |Partial URL to a THREDDS dataset. Single entity. Combined with the file name, this URL can be used to access the content of a file through a TDS server. It can also provide the URL that points to the THREDDS catalog containing the METAMOD dataset. | | ||
- | ^WMS_URL |URL to the WMS service that can display data from the dataset. Single entity. | | ||
- | ^WMS_PARAM |Parameter. Two-level hierarchy. Each entity at the top level (I1_id >= 0, I2_id == 0) identifies a parameter that can be displayed in WMS. Each parameter may have one attribute (I1_id >= 0, I2_id == 1) representing a palette (for example “BOXFILL/ | ||
- | |||
- | Additional information types may be added later, for example to implement projection information: | ||
- | |||
- | ^PROJECTION |Three-level hierarchy used to represent reprojection information. The top level entity (identified by I1_id,I2_id == 0,0) contains attributes: urlRegex (I1_id, | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ==== File ==== | ||
- | |||
- | ^DS_id |Dataset this file belongs to. Part of primary key. | | ||
- | ^F_name |Name of file. Part of primary key. | | ||
- | ^F_timestamp |Timestamp of last change | | ||
- | ^F_size |File size (bytes) | | ||
- | ^F_status |Status (OK or errors) | | ||
- | ^F_errurl |URL to error report (if errors) | | ||
- | |||
- | This table is used to display recent changes to the data provider. It will not contain a complete inventory of files in the repository. This table will be purged (rows with old timestamps removed) periodically. | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ===== API design ===== | ||
- | This paragraph defines a set of subroutine/ | ||
- | |||
- | The functions are defined as methods in a **Userbase** class. Inside a Userbase object, there may be a current user and a current dataset. The current user will always own the current dataset. There may also be a current file that will belong to the current dataset. | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ==== Open/close functions ==== | ||
- | |||
- | ^Method ^Purpose ^Parameters ^ | ||
- | |new |Create a new Userbase object and set up a connection to the User database |OUT: Userbase object reference | | ||
- | |close |Save any pending changes to the database, and close the connection |None | | ||
- | |revert |Revert any changes to the database made by this Userbase object. Close the database connection. |None | | ||
- | |||
- | |||
- | ==== User functions ==== | ||
- | |||
- | ^Method ^Purpose ^Parameters ^ | ||
- | |user_find |Search for an existing user in the database and make him/her the current user. |IN: User E-mail address, application id (A_id). | | ||
- | |user_create |Create a new user and make it the current user. |IN: User E-mail address, application id (A_id). | | ||
- | |user_set |Set user properties for the current user |IN: Property name (one of ' | ||
- | |user_get |Get user properties for the current user. |IN: Property name (one of ' | ||
- | |user_first |Make the first user in the database the current user. |OUT: true if found, false if no users exist. | | ||
- | |user_next |Make the next user in the database the current one. |OUT: true if found, false if already last user. | | ||
- | |||
- | ==== Dataset functions ==== | ||
- | |||
- | ^Method ^Purpose ^Parameters ^ | ||
- | |dset_create |Create a new dataset and make it the current dataset. The current user will be the owner of the new dataset. |IN: Dataset name, dataset key. | | ||
- | |dset_find |Find a dataset in the database and make it the current dataset. Also make the user that owns the dataset the current user. |IN: Application id, dataset name. OUT: true if the dataset is found, false otherwise. | | ||
- | |dset_first |Make the first dataset (owned by the current user) the current dataset |OUT: true if found, false if no such dataset exists. | | ||
- | |dset_next |Make the next dataset (owned by the current user) the current dataset. |OUT: true if found, false if already last dataset. | | ||
- | |||
- | ==== Dataset information functions ==== | ||
- | |||
- | ^Method ^Purpose ^Parameters ^ | ||
- | |info_get_structure |Get an integer array describing the structure of one "piece of information" | ||
- | |info_get |Get information from the current dataset. |IN: Information type (I_type), I1 (value for the I1_id field), I2 (value for the I2_id field). OUT (array of two elements): Attribute name (empty if no attribute), entity or attribute value. | | ||
- | |info_get_by_attribute |Get information from the current dataset for a given attribute. |IN: Information type (I_type), I1 (value for the I1_id field), attribute name. OUT: attribute value, false if not found. | | ||
- | |info_put |Add or replace entities/ | ||
- | |||
- | ==== File functions ==== | ||
- | |||
- | ^Method ^Purpose ^Parameters ^ | ||
- | |file_find |Search for an existing file (owned by the curent dataset) and make it the current file. |IN: File name (F_name). OUT: true if found, false otherwise. | | ||
- | |file_create |Create a new file (for the current dataset) and make it the current file. |IN: File name (F_name) | | ||
- | |file_set |Set file properties for the current file |IN: Property name (one of ' | ||
- | |file_get |Get file properties for the current file. |IN: Property name (one of F_name', | ||
- | |file_first |Make the first file (in the current dataset) the current file. |OUT: true if found, false if no files exist. | | ||
- | |file_next |Make the next file in the database the current one. |OUT: true if found, false if already last file. | | ||