Skip to content

Commit

Permalink
Merge pull request #616 from tripal/427-Tv3-prop_content_types
Browse files Browse the repository at this point in the history
Overhaul of content creation for prop-based types.
  • Loading branch information
bradfordcondon committed Aug 31, 2018
2 parents ac6aa41 + 40559c6 commit 8c4e57c
Show file tree
Hide file tree
Showing 25 changed files with 1,323 additions and 870 deletions.
Binary file modified docs/user_guide/creating_content.create1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/user_guide/creating_content.create2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user_guide/creating_content.create3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user_guide/creating_content.create4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user_guide/creating_content.create5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user_guide/creating_content.create6.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user_guide/creating_content.create7.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 51 additions & 12 deletions docs/user_guide/creating_content.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,65 @@ Alternatively, you can add terms one at a time. To add a single term either from
Create a Tripal Content Type
----------------------------

Creation of a new content type requires familiarity with Chado. This is because data records used by content types must be mapped to actual data and the data lives in Chado. Tripal's interface for creating content types allows you to provide the CV term for the type and then indicate where in Chado the data is/will be stored. Chado is a flexible relational database schema. Thus, it is possible for different sites to store data in different ways. It is best practice however to follow community standards when storing data. Therefore, please review the online documentation for Chado. If you are unclear how data for your content type should be stored in Chado please consider emailing the `Chado mailing list <http://gmod.org/wiki/GMOD_Mailing_Lists>`_ to ask for help or add a request for help on the Tripal issue queue.
Creation of a new content type requires familiarity with Chado. This is because data records used by content types must be mapped to actual data and the data lives in Chado. Tripal's interface for creating content types allows you to provide the CV term for the type and then indicate where in Chado the data is/will be stored. Chado is a flexible relational database schema. Thus, it is possible for different sites to store data in different ways. It is best practice however to follow community standards when storing data. Therefore, please review the online documentation for Chado. If you are unclear how data for your content type should be stored in Chado please consider emailing the `Chado mailing list <http://gmod.org/wiki/GMOD_Mailing_Lists>`_ or posting an issue on the `Chado GitHub issue queue <https://github.com/GMOD/Chado>`_ to ask for help or add a request for help on the Tripal issue queue.

To add a new content type, start by navigating to **Structure → Tripal Content Types** and click on the **Add Tripal Content Type** link at the top. This will take you to a web form that leads you through the process of creating a custom Tripal Content Type. First, enter for the name of the term you would like to use to describe your content in the Content Type autocomplete textbox (e.g. genetic_marker). Then, click **Lookup Term**. This should bring up a list of matching terms from which you can select the specific term you would like to use. Sometimes the same term exists in multiple vocabularies and you can select the proper one.
To add a new content type, start by navigating to **Structure → Tripal Content Types** and click on the **Add Tripal Content Type** link at the top. This will take you to a web form that leads you through the process of creating a custom Tripal Content Type.

Genetic Marker Example
^^^^^^^^^^^^^^^^^^^^^^
To demonstrate how to create a new content type we will use the example of a genetic marker. First, enter for the name of the term you would like to use to describe your content in the Content Type autocomplete textbox. Then, click **Lookup Term**. This should bring up a list of matching terms from which you can select the specific term you would like to use. Sometimes the same term exists in multiple vocabularies and you can select the proper one.

.. image:: creating_content.create1.png

During content type creation there is as a section to specify which Chado tables will store your data. Chado is typically structured with primary **base** tables (e.g. organism, feature, stock, project, etc) and a set of linker and property tables that contain ancillary data related to the base records. Here you must first choose the base table where primary records for your data type are stored. For our example, because genetic markers are sequence features, they are stored in the Chado feature table. Once you select the Chado table, the form will ask additional questions to determine exactly how records of the content type can be found. Specifically, the following options are supported if the appropriate fields/tables are available:
During content type creation there is as a section to specify which Chado tables will store your data. Chado is typically structured with primary **base** tables (e.g. organism, feature, stock, project, etc) and a set of linker and property tables that contain ancillary data related to the base records. Here you must first choose the base table where primary records for your data type are stored. For our example, because genetic markers are sequence features, they are stored in the Chado **feature** table.

1. All records in the **base** table belong to the content type (e.g. tables: organism, analysis, etc.)
2. The **base** table has a **type_id** that stores the CV term and this differentiates the records. (e.g. tables: feature, stock, library, etc.).
3. The records can be differentiated by way of a property table which contains a **type_id** column for the CV term. (e.g. tables: featureprop, stockprop, libraryprop, etc.)
4. The records can be differentiated by way of a linking table that associates records in the **base** table with the CV term (e.g. tables: feature_cvterm, stock_cvterm, etc.)
.. image:: creating_content.create2.png

For our genetic marker example, we can use the Chado **feature** table and **type_id** column to differentiate which records in the feature table are genetic markers. Thus we
Next, you will be asked if all of the records in the selected table are of the desired content type. Usually the answer to this is "No", especially if the Chado table has a **type_id** column. In our case. The **feature** table does have a **type_id** column so we must select "No".

- Select "No" not all records in the feature table are genetic markers
- Type Column: type_id
.. image:: creating_content.create3.png

Then click Create Content Type to create a custom genetic marker content type.
If all of the records in the selected table do not belong to the content type then the form knows enough about each Chado table to offer you appropriate options for how to store data for your content type. The form knows that the **feature** table has a **type_id** column so it asks if we can differentiate records for our content type using the **type_id** field. For our example genetic marker we can do so.

.. image:: creating_content.create2.png
.. image:: creating_content.create4.png

Just prior to creating our content type we are provided a summary of our selection to review:


.. image:: creating_content.create5.png

Finally, click the **Create Content Type** to create a custom genetic marker content type. We are provided with a message indicating that a job has been added for creation of the content type. Depending how large the Chado database is, creation of a contnet type may take awhile, hence we must run it as a job.

.. image:: creating_content.create6.png

Once the content type is created, you can create pages for site visitors. This will be described later in this User's Guide. In short, you can manually create new records through brand new web forms that are created automatically for your content type, or you can use a data loader to import your data directly to Chado, then **Publish** those records through the Tripal interface.

.. note::

Each time you create a new content type, you get several new things:

- A new search tool will be created automatically for the content type.
- A new set of permissions to help you control access is created.

SNP Example
^^^^^^^^^^^
Perhaps we want to be more specific with our genetic marker pages and create pages for each type of genetic marker (e.g. SNP, RFLP, etc. pages). Suppose for this example that we continue to store genetic markes in the feature table and use the genetic_marker term in **type_id** as in the previous example. To differentiate between different markers, we store a record in the **featureprop** table where the **featureprop.type_id** indicates the that the property provides the marker type and the **featureprop.value** column houses the string for the marker type (e.g. "SNP"). Thus, any genetic marker that has a property with this type of featureprop should form part of our SNP content type.

To accomplish this we can walk through the content type creation form and set the following values:

.. csv-table::
:header: 'Field', 'Value'

"Content Type", "SNP (SO:0000694)"
"Storage Backend", "Chado"
"Chado Table", "feature"
"Are all records in the 'feature' table of type 'genetic_marker'?", "No"
"Type column", "--None--",
"Do you want to use the 'featureprop' table to distinguish between content types?", "Yes"
"Base Type", "genetic_marker (SO:0001645)"
"Property Type", "type (rdfs:type)"
"Property Value", "SNP"

.. image:: creating_content.create7.png

After clicking the **Create content type** button a job will be submitted and we will have a new SNP content type whose data is saved to both the feature and featureprop tables.
25 changes: 12 additions & 13 deletions tripal/api/tripal.entities.api.inc
Original file line number Diff line number Diff line change
Expand Up @@ -380,15 +380,14 @@ function tripal_load_bundle_entity($values) {
*/
function tripal_add_notification($title, $details, $type, $actions, $submitter_id) {
$transaction = db_transaction();

// Check the notification isn't already in the admin notification table.
$dedup = db_select('tripal_admin_notfications', 'tan')
->fields('tan')
->condition('submitter_id', $submitter_id, '=')
->execute()->fetchAll();

if (empty($dedup)) {
try {
try {
// Check the notification isn't already in the admin notification table.
$dedup = db_select('tripal_admin_notfications', 'tan')
->fields('tan')
->condition('submitter_id', $submitter_id, '=')
->execute()->fetchAll();

if (empty($dedup)) {
$record = new stdClass;
$record->details = $details;
$record->title = $title;
Expand All @@ -398,10 +397,10 @@ function tripal_add_notification($title, $details, $type, $actions, $submitter_i
$record->type = $type;
$success = drupal_write_record('tripal_admin_notfications', $record);
}
catch (Exception $e) {
$transaction->rollback();
watchdog('tripal_cron', 'Could not write notification to database.');
}
}
catch (Exception $e) {
$transaction->rollback();
watchdog('tripal_cron', 'Could not write notification to database.');
}
}

Expand Down
11 changes: 5 additions & 6 deletions tripal/api/tripal.importer.api.inc
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,9 @@ function tripal_run_importer($import_id, TripalJob $job = NULL) {
*/
function tripal_run_importer_run($loader, $job) {

// begin the transaction
$transaction = db_transaction();
try {
// begin the transaction
$transaction = db_transaction();

$loader->run();

if ($job) {
Expand Down Expand Up @@ -244,9 +243,9 @@ function tripal_run_importer_run($loader, $job) {
* @ingroup tripal_importer_api
*/
function tripal_run_importer_post_run($loader, $job) {
try {
// the transaction
$transaction = db_transaction();
// the transaction
$transaction = db_transaction();
try {
$loader->postRun();
}
catch (Exception $e) {
Expand Down

0 comments on commit 8c4e57c

Please sign in to comment.