SelectPlease note, you may use regular expressions (see end of document) to specify your query. Common to all S3DB entities are the following attributes:
Attributes that are specific to each S3DB entity are as follows: Projects
Rules
<S3QL> Collections
<select>*</select> Items
<select>*</select> <from>items</from> <where> <collection_id>...</collection_id> </where> <select>*</select><from>items</from> <where> <collection_id>...</collection_id> <notes>myItem</notes> </where> Please note: In order to retrieve items you will need to specify the collection_id where they were created. Statements
<select>*</select> Rulelog
<select>*</select> Users
<select>*</select> Note: assigned_permissionOnEntity and effective_permissionOnEntity specifies the permission that the user asking the question has in the entity specified in the query (for example, in project_id = 126)Groups
<select>*</select> KeysNOTICE: The ability to query keys in the API was DEPRECATED for security reasons (please use apilogin.php to obtain a key using your username and password) PermissionUser Admin may perform queries on permissions.
Example Syntax: <select>*</select> <from>permission</from> <where> <uid>P123</uid> </where> Insert, UpdateUser
Example 1: Creating a new user <insert>user</insert> Example 2: Updating an existing user <update>user</update> Example 3: Giving user permission to view/edit a project <insert>user</insert> Remote UserNote: It is possible to create user Users with Accounts elsewhere. You will need to specify the S3DB where user has an account or, in case it is not S3DB but another authentication authority such as Google or LDAP, you need to specify the protocol. Use the following syntax: protocol : authority : username or email Example 4: Inserting a user with an account on google <insert>user</insert> <project_id>456</project_id> In this case, protocol is http but it can be ommited, as that is the protocol chosen by default. <insert>user</insert> Example 5: Inserting a user with an account in another s3db deployment In this case, protocol is s3db, and you must specify the name/deployment_id of the deployment where user can be authenticated. <insert>user</insert> Group
Example 1: Inserting a group <insert>group</insert> Example 2: Updating an existing group <update>group</update> Project
Example 1:Inserting a new project <insert>project</insert> Example 2: Updating an existing project <update>project</update> Collection
Example 1: Inserting a collection <insert>collection</insert> Example 2: Updating an existing collection <update>collection</update> Example 3: Inserting an existing collection in a remote project <insert>collection</insert> Item
Example 1: Inserting an item <insert>item</insert> Example 2: Inserting an existing item in a remote collection <insert>item</insert> <where> <collection_id>...</collection_id> <item_id>...</item_id> </where> Rule
Example 1: Inserting a new rule <insert>rule</insert> Example 2: Inserting an existing rule in a remote project <insert>rule</insert> Statement
Example 1: Inserting a new statement <insert>statement</insert> Example 2: Inserting an existing statement in a remote rule <insert>statement</insert> File
Example 1: Inserting a previously uploaded file - To know how to upload a file to S3DB, please see S3DB Uploads. <insert>file</insert> <insert>file</insert>
<where> <item_id>...</item_id> <rule_id>...</rule_id> <value>contents to be written to the file</value> <file_name>myfile.txt<file_name>
</where>
|
| Insert | Where (Required) | Where (Optional) |
|---|---|---|
| Key | key_id, expires, notes |
Example 1: Inserting an existing statement in a remote rule
<insert>key</insert>
<where>
<key_id>…</key_id>
<expires>…</expires>
<notes>…</notes>
</where>
In case key_id is missing, default is to generate a random key. If expiration date is missing, default is defined as 24 hour validity.
Delete
| Delete | Where (Required) | Flag (Optional) |
|---|---|---|
| resource_name | id | all/unlink |
flags: all removes all resources that are dependent of id
unlink removes user from resource identified in id
flag defaults to unlink
Project
| Delete | Where (Required) | Flag (Optional) |
|---|---|---|
| project | project_id | all/unlink |
| project | project_id, user_id | all/unlink |
| project | project_id, group_id | all/unlink |
Example 1: Removing a user access to a project
<S3QL>
<delete>project</delete>
<where>
<project_id>123</project_id>
<user_id>456</user_id>
</where>
</S3QL>
Example 2: Removing a project
<S3QL>
<delete>project</delete>
<where>
<project_id>123</project_id>
</where>
</S3QL>
Example 3: Removing a project and all rules and collections
<S3QL>
<delete>project</delete>
<where>
<project_id>123</project_id>
</where>
<flag>all</flag>
</S3QL>
Collection
Example 1: Deleting a collection from user view (leave collection available for others)
<S3QL>
<delete>collection</delete>
<where>
<collection_id>123</collection_id>
</where>
</S3QL>
Example 2: Deleting a collection from project view (leave available for others)
<S3QL>
<delete>collection</delete>
<where>
<collection_id>123</collection_id>
<project_id>10</project_id>
</where>
</S3QL>
Rule
Example 1: Deleting a rule from user view (leave available for others)
<S3QL>
<delete>rule</delete>
<where>
<rule_id>123</rule_id>
</where>
</S3QL>
Item
Example 1: Deleting an Item from user view (leave available for others)
<S3QL>
<delete>item</delete>
<where>
<item_id>123</item_id>
</where>
</S3QL>
Statement
Example 1: Deleting a statement
<S3QL>
<delete>statement</delete>
<where>
<statement_id>123</statement_id>
</where>
</S3QL>
User
Example 1: Deleting a user
<S3QL>
<delete>user</delete>
<where>
<user_id>123</user_id>
</where>
</S3QL>
Example 2: Removing a user from a group
<S3QL>
<delete>user</delete>
<where>
<group_id>456</group_id>
<user_id>123</user_id>
</where>
</S3QL>
Group
Example 1: Deleting a group
Regular Expressions
You may use regular expressions when specifying your query in any of the attributes.
Example: Matching a fraction of a collection name
<S3QL>
<delete>collection</delete>
<where>
<name>~Sample</name>
</where>
</S3QL>
Note: Regular expression syntax will be slightly different for S3DB whether you are using MySQL or PostgreSQL.
Use the syntax of the engine where you installed your S3DB.
Errors
| Error Code | Message |
|---|---|
| 0 | Successfull |
| 1 | Not a valid query |
| 2 | Unrecognized error |
| 3 | Missing information |
| 4 | Repeated action |
| 5 | No permission |
| 6 | Wrong query |
| 7 | Wrong input |
| 8 | No changes we made |
| 9 | No results from query |
| 10 | A part of the query failed |
Permission Management
Permission management of users in s3db resources is inherited from project unless a permission is specified for specific resources. Users can be added/removed to projects, rules, collections, items and statements with a level of permission for view, change and add, specified through a permission code. The syntax to sharing a resource with another user is the same for project, collection, rule, item and statement:
Example of inserting a user on a rule:
<S3QL>
<insert>user</insert>
<where>
<rule_id>...</rule_id>
<user_id>...</user_id>
<permission_level>...</permission_level> </where>
</S3QL>
In a less broad sense, any resource can be given permission on any other upper resource:
Example of sharing a rule with a project:
<S3QL>
<insert>rule</insert>
<where>
<project_id>12.</project_id>
<rule_id>13</rule_id>
</where>
</S3QL>
To un-share a rule from a project, you just need to specify the opposite query, that is, use "delete":
<S3QL>
<delete>rule</delete>
<where>
<project_id>12.</project_id>
<rule_id>13</rule_id>
</where>
</S3QL>Dictionary
A dictionary is a list of namespaces and random triples that can be added in reference to any S3DB UID. You may wish, for example, to specify the UID C186 is equivalent to a resource in a standard existing ontology, for example MGED.
You do this by inserting a "link" in the API function dictionary.php. Keep in mind that, if you are using a short namespace (for example, mged:BioSource), the qname (mged) must already exist as a namespace (use the dictionary.php to select all existing namespaces). By adding an extra argument to your S3QL query, "graph", S3DB will also query and output the dictionary terms related to the UID retrieved in your query:
Example:<S3QL>
<select>*</select>
<from>collection</from>
<where>
<collection_id>186</collection_id>
</where>
<graph>on</graph>
</S3QL>
Select Link
An alternative query specific for the Dictionary will allow faster queries without the need to write several S3QL queries:<S3QL> <select>*</select>
<from>links</from>
</S3QL>
Insert, Update, Delete Link
The dictionary can be populated with links using a syntax developed for the purpose. In order to create an entry in the dictionary, use the following arguments:Insert Where (Required) Where (Optional) link uid, relation, value (no optional arguments)
Example:
<S3QL>
<insert>link</insert>
<where>
<uid>C186</uid>
<relation>rdfs:isDefinedBy</relation>
<value>mged:BioSample</value>
</where>
</S3QL>
Similar to the rest of S3QL, you can select, update or delete a link. You will need link_id, which will be returned when you perform a query on links:Update Where (Required) Where (Optional) link link_id uid, relation, value
Example:
<S3QL>
<update>link</update >
<where>
<link_id>123</link_id>
<relation>rdfs:seeAlso</relation>
</where>
</S3QL>
Delete Where (Required) link link_id
Example:
<S3QL>
<delete>link</delete >
<where>
<link_id>123</link_id>
</where>
</S3QL>
Select Namespace
A namespace is the means by which a short syntax, for example "mged" can be used as a surrogate for a longer URL, for example "http://mged.sourceforge.net/ontologies/MGEDOntology.owl#". When a Link is inserted in Dictionary, such as in the examples above, a namespace can be used instead of the complete URL. In order to use a namespace, it must already exist in the Dictionary. Select all the namespaces in the Dictionary by using the followin syntax:From Where (Optional) namespace qname, url
Example: <S3QL>
<from>namespace</from>
<where>
<qname>mged</qname>
</where>
</S3QL>
Insert, Update, Delete Namespace
If the qname does not exist, you can create it using the following:Insert Where (Required) Where (Optional) namespace qname, url (no optional arguments)
Example:
<S3QL>
<insert>namespace</insert>
<where>
<qname>mged</qname>
<url>http://mged.sourceforge.net/ontologies/MGEDOntology.owl#</url>
</where>
</S3QL>
You may also chose to update or delete a namespace
Update Where (Required) Where (Optional) namespace namespace_id qname, url
Example:
<S3QL>
<update>namespace</update >
<where>
<qname>mged</qname>
<url>http://mged.sourceforge.net/ontologies/MGEDOntologyv3.1.owl#</url>
</where>
</S3QL>
| Delete | Where (Required) |
|---|---|
| namespace | namespace_id |
Example:
<S3QL>
<delete>namespace</delete >
<where>
<qname>abc</qname>
</where>
</S3QL>Other Options
You can use the argument "options" to perform a query after another action has been performed.
For example, if you specify in you query that options=select, then following an "Insert", S3DB will return to you information regarding the entity just inserted.
Example
<insert>item</insert>
<where>
<collection_id>1417</collection_id>
<notes>tmp</notes>
</where>
<options>select</options>For now, only "select" is supported. Others will be added in a comma-separated style.
Please note that this is only supported for output as structured formats - XML and JSON.