metamod:user_database_revised

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
metamod:user_database_revised [2010-08-13 13:00:20]
egils
metamod:user_database_revised [2022-05-31 09:29:32] (current)
Line 1: Line 1:
 ====== User database revised ====== ====== User database revised ======
-**Contains suggested changes to the User database design and API that are needed for subscription information and possibly other needs. Changes to the original [[user_database]] description are rendered in bold.** +Contains changes to the User database design and API that are needed for subscription information and possibly other needs.
- +
-===== Overview ===== +
-{{:metamod:userbase.jpg}} +
- +
-===== Design =====+
  
 +2010-09-13: Changes due to the introduction of a U_loginname field.
  
 +2010-09-14: Names of various methods are changed.
  
 +**2010-09-24: Changes in the database structure. A row in the File table is now directly owned by a user. These changes are rendered in bold.**
  
 +**2010-09-28: Added the file_delete method.**
  
 +2010-11-11: Removed WMS_URL and WMS_XML entries from the InfoDS table
  
 +===== Overview =====
 +{{:metamod:userbase.jpg}}
  
 +===== Design =====
  
  
Line 18: Line 21:
 **UserTable** **UserTable**
  
-|__U_id__ |A_id |U_name |U_email |U_password |U_institution |U_telephone |U_session |+|__U_id__ |A_id |U_name |U_email |U_loginname |U_password |U_institution |U_telephone |U_session |
  
 **DataSet** **DataSet**
Line 24: Line 27:
 |__DS_id__ |U_id |A_id |DS_name | |__DS_id__ |U_id |A_id |DS_name |
  
-**Info** +**InfoDS**
- +
-|**__I_id__** |**U_id** |DS_id |I_type |I_content | +
- +
-**File** +
- +
-|__DS_id__ |__F_name__ |F_timestamp |F_size |F_status |F_errurl | +
- +
  
 +|__I_id__ |DS_id |I_type |I_content |
  
 +**InfoUDS**
  
 +|__I_id__ |U_id |DS_id |I_type |I_content |
  
 +**File**
  
 +|__U_id__ |__F_name__ |F_timestamp |F_size |F_status |F_errurl |
  
  
Line 44: Line 44:
  
 The table details are presented below: The table details are presented below:
- 
- 
- 
- 
  
  
Line 56: Line 52:
 ^U_name |User name as given in registration form | ^U_name |User name as given in registration form |
 ^U_email |User E-mail address as given in registration form | ^U_email |User E-mail address as given in registration form |
 +^U_loginname |Login name for user authentication |
 ^U_password |User password | ^U_password |User password |
 ^U_institution |User institution acronym as given in registration form | ^U_institution |User institution acronym as given in registration form |
Line 64: Line 61:
  
 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, she/he must apply for a user account in each application, and the database will contain independent rows in the user table, one for each application. 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, she/he must apply for a user account in each application, and the database will contain independent rows in the user table, one for each application.
- 
- 
- 
  
  
Line 79: Line 73:
  
  
 +==== InfoDS ====
  
 +This table is used to contain various information connected to a dataset. Each row has a serial unique identifier (I_id). The row is connected to a dataset through the DS_id foreign key.
  
 +A type tag (I_type) field tells what kind of information is contained in the row. The value is a short acronym for a limited set of information types. The piece of information is found in the I_content text field.
  
 +^I_id |Unique id (autoincremented number). Primary key |
 +^DS_id |Identifiles a dataset this info-row is connected to. |
 +^I_type |Type tag. Short acronym that identifies the information type. |
 +^I_content |The text string representing a piece of information. This can be a single entity (unstructured text) or an XML document. |
  
 +For the time being, the following information types (I_type) will be needed.
  
 +^Type ^Description ^
 +^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 directory, 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. |
 +|Additional information types may be added later, for example to implement projection information: ||
 +^PROJECTION_XML |XML document used to represent reprojection information. The document contains, among other things, each projection the user has asked for ("Lat/Long", "Stereo" etc.). Each projection contains attributes: method, projString, xAxis, yAxis and toDegree.  |
  
 +==== InfoUDS ====
  
- +This table is used to express relationships between a dataset and a user. Each row has a serial unique identifier (I_id). The row is connected to a dataset through the DS_id foreign key, and to a user through the U_id foreign key.
- +
- +
- +
- +
- +
- +
- +
- +
- +
-==== Info ==== +
- +
-**This table is used to contain various information connected to a dataset and/or a user. Each row has a serial unique identifier (I_id). The row can be connected to a dataset through the DS_id foreign key, and to a user through the U_id foreign key. Note that all Info-rows connected to a dataset is also indirectly connected to the owner of the dataset. This is not explicitly expressed in this table. In cases where values for both U_id and DS_id exist, the U_id will usually point to a user that do not own the dataset.**+
  
 A type tag (I_type) field tells what kind of information is contained in the row. The value is a short acronym for a limited set of information types. The piece of information is found in the I_content text field. A type tag (I_type) field tells what kind of information is contained in the row. The value is a short acronym for a limited set of information types. The piece of information is found in the I_content text field.
  
-^**I_id** |**Unique id (autoincremented number). Primary key** +^I_id |Unique id (autoincremented number). Primary key | 
-^**U_id** |**Identifiles a user this info-row is connected to. Will be missing (NULL) if the information is not connected to a user** +^U_id |Identifiles a user this row is connected to. | 
-^DS_id |Identifiles a dataset this info-row is connected to. **Will be missing (NULL) if the information is not connected to a dataset** |+^DS_id |Identifiles a dataset this info-row is connected to. |
 ^I_type |Type tag. Short acronym that identifies the information type. | ^I_type |Type tag. Short acronym that identifies the information type. |
 ^I_content |The text string representing a piece of information. This can be a single entity (unstructured text) or an XML document. | ^I_content |The text string representing a piece of information. This can be a single entity (unstructured text) or an XML document. |
Line 110: Line 107:
 For the time being, the following information types (I_type) will be needed. For the time being, the following information types (I_type) will be needed.
  
-^Type ^Connected to ^Description ^ +^Type ^Description ^ 
-^DSKEY |dataset |Dataset key (also called directory key or dirkey) as provided by the user. Single entity | +^SUBSCRIPTION_XML |XML describing details of a subscription on the dataset set up by the user |
-^LOCATION |dataset |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 directory, or in any subdirectory of the location directory at any level. | +
-^CATALOG |dataset |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 |dataset |URL to the WMS service that can display data from the dataset. Single entity. | +
-^WMS_XML |dataset |XML document that describes available alternatives for displaying the dataset in WMS. For example, the parameters that can be displayed. Each parameter may have a palette (for example “BOXFILL/redblue”) found in a style element in the GetCapabilites document. If no palette is found, a default palette is used for the parameter. | +
-^SUBSCRIPTION_XML |**dataset and user** |**XML describing details of a subscription on the dataset set up by the user** | +
-|Additional information types may be added later, for example to implement projection information: ||| +
-^PROJECTION_XML |dataset |XML document used to represent reprojection information. The document contains, among other things, each projection the user has asked for ("Lat/Long", "Stereo" etc.). Each projection contains attributes: method, projString, xAxis, yAxis and toDegree. +
- +
  
  
Line 126: Line 114:
 ==== File ==== ==== File ====
  
-^DS_id |Dataset this file belongs to. Part of primary key. |+^U_id |**User that this file belongs to**. Part of primary key. |
 ^F_name |Local path to file. The full path is given by "LOCATION/F_name" where LOCATION is the dataset LOCATION found in the Info table. Part of primary key. | ^F_name |Local path to file. The full path is given by "LOCATION/F_name" where LOCATION is the dataset LOCATION found in the Info table. Part of primary key. |
 ^F_timestamp |Timestamp of last change | ^F_timestamp |Timestamp of last change |
Line 134: Line 122:
  
 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. 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.
- 
- 
- 
- 
  
  
Line 144: Line 128:
 This paragraph defines a set of subroutine/function calls that are used to read and write information to/from the user database. These functions will be implemented in PHP and/or Perl as needed.  This paragraph defines a set of subroutine/function calls that are used to read and write information to/from the user database. These functions will be implemented in PHP and/or Perl as needed. 
  
-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. +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 may or may not own the current dataset. There may also be a current file that will belong to the current dataset.
- +
- +
- +
- +
- +
- +
- +
- +
  
  
Line 169: Line 144:
 ^Method ^Purpose ^Parameters ^ ^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_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_lfind |Search for an existing user in the database and make him/her the current user. |IN: User login name, application id (A_id). | 
-|user_set |Set user properties for the current user |IN: Property name (one of 'U_name', 'U_password', 'U_institution', 'U_telephone', 'U_session'), property value | +|user_create |Create a new user and make it the current user. |IN: User E-mail address, application id (A_id). Initially, the value of the mandatory U_loginname field will be set to the E-mail address, but this can be changed using the user_set method. | 
-|user_get |Get user properties for the current user. |IN: Property name (one of 'U_name', 'U_password', 'U_institution', 'U_telephone', 'U_session'). OUT: property value |+|user_put |Set user properties for the current user |IN: Property name (one of 'U_name', 'U_loginname', 'U_password', 'U_institution', 'U_telephone', 'U_session'), property value | 
 +|user_get |Get user properties for the current user. |IN: Property name (one of 'U_id', 'U_email', 'A_id', 'U_name', 'U_password', 'U_loginname', 'U_institution', 'U_telephone', 'U_session'). OUT: property value |
 |user_first |Make the first user in the database the current user. |OUT: TRUE if found, FALSE if no users exist. | |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. | |user_next |Make the next user in the database the current one. |OUT: TRUE if found, FALSE if already last user. |
 +|user_isync |Make the user corresponding to the current infoUDS-row (see below) the current user. |OUT: TRUE if found, FALSE on error. |
 +|user_dsync |Make the user owning the current dataset the current user. |OUT: TRUE if found, FALSE on error. |
  
 ==== Dataset functions ==== ==== Dataset functions ====
 +Methods for manipulating the DataSet table.
  
 ^Method ^Purpose ^Parameters ^ ^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_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. <del>**Also make the user that owns the dataset the current user.**</del> |IN: Application id, dataset name. OUT: true if the dataset is found, false otherwise. |+|dset_find |Find a dataset in the database and make it the current dataset. |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_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. | |dset_next |Make the next dataset (owned by the current user) the current dataset. |OUT: true if found, false if already last dataset. |
 +|dset_isync |Make the dataset corresponding to the current infoUDS-row (see below) the current dataset. |OUT: TRUE if found, FALSE on error. |
 +|dset_get |Get information from the current dataset. |IN: Information type (I_type) or one of 'ds_name', 'ds_id', 'u_id'. OUT: Value of I_content field (single entity or XML). |
 +|dset_put |Add or replace content fields in the current dataset. |IN: Information type (I_type), value of I_content field (single entity or XML). |
  
-==== Information functions ==== +==== Functions for manipulating the InfoUDS table==== 
-**Functions for reading and writing rows in the Info table. Uses the concept "current infoset"The current infoset is a subset of the rows in the Info table given by how the rows are connected to the current user and/or the current dataset. In addition, all rows in the current infoset must represent the same information type (I_type).**+Uses the concept "current set of InfoUDS rows"This set is a subset of the rows in the InfoUDS table given by how the rows are connected to the current user and/or the current dataset. In addition, all rows in the current set must represent the same information type (I_type). One of the rows in the current set may be selected as //the current infoUDS row//.
  
 ^Method ^Purpose ^Parameters ^ ^Method ^Purpose ^Parameters ^
-|**info_set** |**Define the current infoset** |**IN: 1. Information type. 2. Keyword that tells how the infoset shall relate to the current user and/or current dataset (values: USER, DATASET, USER_AND_DATASET). 3. Optional parameter that tells if the current user or the current dataset should be synchronized with the user/dataset that the infoset represents. TRUE or FALSE (defaults to FALSE). OUT: Number of rows (N) in the infoset, or FALSE indicating error.** +|infoUDS_set |Define the current set of rows and set the first row in as the current row. |IN: 1. Information type. 2. Keyword that tells how the set shall relate to the current user and/or current dataset (values: USER, DATASET, USER_AND_DATASET).  OUT: Number of rows (N) in the set, or FALSE indicating an empty set or error. | 
-|info_get |Get information from the current **infoset**. |**IN: Index into the infoset (0 to N-1).** OUT: Value of I_content field (single entity or XML). | +|infoUDS_get |Get information from the current row in the current set. |OUT: Value of I_content field (single entity or XML). | 
-|info_put |Add or replace content fields in the current **infoset**. |IN: 1. Value of I_content field (single entity or XML). **2Index into the infoset (0 to N-1). If this parameter is missing, a new row in the infoset is createdThis row is given the index Nafter which N is incremented.** |+|infoUDS_put |Replace the content field in the current row. |IN: Value of I_content field (single entity or XML). 
 +|infoUDS_next |Define the next row in the set as the current row|OUT: TRUE on success, FALSE if no more rows in the set. | 
 +|infoUDS_new |Create a new row in the set and define it as the current row. The row will belong to the user and/or dataset that defines the set. If the set is only defined by userthe current dataset will be used to connect the row to dataset. Similarly, if the set is only defined by dataset, the current user will be used. NOTE: The new row will be set up as the last row in the current setUsed inside a loop with infoUDS_next, this method will accordingly break out of the sequential visiting of rows from the set. |IN: Value of I_content field (single entity or XML). OUT: TRUE on successFALSE on error. | 
 +|infoUDS_delete |Delete the current row. |OUT: TRUE or FALSE indicating success or error. |
  
 ==== File functions ==== ==== File functions ====
  
 ^Method ^Purpose ^Parameters ^ ^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_find |Search for an existing file (**owned by the curent user**) 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_create |Create a new file (**for the current user**) 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 'F_size', 'F_status', 'F_errurl'), property value |+|file_put |Set file properties for the current file |IN: Property name (one of 'F_size', 'F_status', 'F_errurl'), property value |
 |file_get |Get file properties for the current file. |IN: Property name (one of F_name', 'F_size', 'F_status', 'F_errurl', 'F_timestamp'). OUT: property value | |file_get |Get file properties for the current file. |IN: Property name (one of F_name', 'F_size', 'F_status', 'F_errurl', 'F_timestamp'). OUT: property value |
-|file_first |Make the first file (in the current dataset) the current file. |OUT: true if found, false if no files exist. |+|file_first |Make the first file (**owned by the current user**) 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. | |file_next |Make the next file in the database the current one. |OUT: true if found, false if already last file. |
 +|**file_delete** |**Delete the current file entry from the database.** |**OUT: true if the entry was deleted, false on error.** |
 +
 +==== Example usecase ====
 +A dataset (D) has recently been updated, and a check is needed to see if this must be followed up by sending the dataset to external users as a consequence of subscriptions set up on the dataset:
 +
 +<code>
 +
 +new;                                 # Open new UserBase object
 +
 +dset_find D                          # Find dataset D in the database
 +                                     # (= current dataset)
 +
 +infoUDS_set SUBSCRIPTION_XML DATASET # Define the current set of rows as
 +                                     # all SUBSCRIPTION_XMLs for the 
 +                                     # current dataset. Make the first 
 +                                     # row current.
 +
 +Loop over the current set of rows:
 +
 +    user_isync                    # Make the current user correspond
 +                                  # to the user in the current infoUDS row
 +
 +#    All information on the subscripion, the user that owns the
 +#    subscription, as well as the dataset that is subscribed to, are
 +#    now readily available as current elements.
 +    
 +    Make necessary actions to satisfy the subscription
 +    
 +    infoUDS_next
 +    
 +End loop when infoUDS_next returns FALSE
 +
 +close                             # Close the userbase object
 +</code>
  
  • metamod/user_database_revised.1281704420.txt.gz
  • Last modified: 2022-05-31 09:23:19
  • (external edit)