Creating Templates and Attributes

This article applies to P2 Server version 4.5.1 and later. For more, see Release History.

This article is about how to create templates and attributes using P2 Server Management or the Import/Export spreadsheet. For general information on templates and attributes, see:  Templates and Attributes.

A template in P2 Server is a way of defining the attributes of an entity. All entities that are assigned a template take on the attributes of that template. For example, all Oil Producing Well templates will have attributes like Tubing Head Pressure, Tubing Head Temperature, and Choke Position; whereas Water Injection Wells might have Injection Pressure, Annulus Pressure, and Water Flowrate.

Note that in common usage the meaning of template may change, depending on our frame of reference:

  • When we talk about a template in reference to a particular entity, then we are normally referring to the template instance.
  • When we otherwise talk about a template, then we are normally referring to the template definition.
BEST PRACTICE

Before you start, spend some time thinking about what this template represents, and what would be the attributes inherited by any entity that is assigned this template. Also think about the links that you want to display in the Table of Contents for any entity that has this template.


Server Management

In P2 Server Management, creating a template with some attributes requires 3 steps, all performed through the Templates menu option:

  1. Creating the template definition, by giving the template a name, description, and template group.
  2. Creating attribute definitions within the template definition.
  3. Creating attribute value definitions.

There are 3 prerequisites: you must have already created the template group that you want this template to belong to, and the links and icons you intend to assign to this template. 

Prerequisite Steps: Creating Template Groups, Creating Links, Adding Images

Once the template is created, it can be assigned to an entity - this step will also define where the attribute values will come from for that particular entity.

Follow-up step: Configuring Entities

Creating a Template Definition

1. Open P2 Server Management, and click the Configuration configurationicon icon. 

2. Click Templates.

3. Click Create New Template.

Note: If you want to edit an existing template or its attributes, select the template from the list below the Create button.

4. Give the template a Name and Description.

  • The name cannot contain any reserved characters. 
  • For the description, it’s often useful to provide a broader explanation of the purpose of the template and how it will be used. 

Related: Reserved Characters & Keywords

5. Assign a Template Group and Icon.

  • The template group and icon must already exist in the system.

Related: Creating Template Groups, Adding Images

6. Link Behaviour. By default, all links assigned to the template will be shown in Explorer's Table of Contents, regardless of whether or not it is the primary template for an entity. 
If you want only the links on the primary template to appear, select the 'Show links only when assigned as primary template' check box.

7. Visibility. By default, all templates assigned to an entity will appear in Explorer, in places such as the Hierarchy Navigator.
If you do not want the template to appear, select the 'Set as Internal' check box.

5. Assign the Links you want to associate with this template. 

  • Links will appear in the Table of Contents for any entity that has designated this template as its primary template.
  • Links must already exist in the system. If a link doesn't exist, you should add it after you have saved this template.

Related: Links and the Table of Contents

6. When you have finished, click the Save button in the top right corner.

Creating Attribute Definitions

Refresher: Where an entity defines a real world or conceptual object, it is the attributes of an entity that describe the characteristics of that object. It’s these characteristics, or attributes, that are associated with data that we generally want to model. For example, the suction pressure of a pump. We can break these attributes down even further to gain an insight into different aspects of that attribute, called attribute values. For example, the maximum allowed suction pressure. We define attributes within a template because the template models the type of entity we will assign it to.

7. After the template is saved, you will have the opportunity to create attributes and assign them to the template.

8. To assign an attribute to the template, click the "Create One Now" button.

The Attribute screen appears, which is where you create the attribute definition in the template you are editing.

9. Give the attribute a namedescription, attribute group, and data type.

  • The name cannot contain any reserved characters
  • For the description, it’s often useful to provide a broader explanation of what the attribute represents. 
  • The attribute group must already exist in the system.
  • If the attribute is coming from a dataset datasource, choose Matrix. If the attribute is coming from a tag datasource, choose TimeSeries.

Related: Data Formats and Data Types, Datasources and Adaptors

10. When you have finished, click the Save button in the top right corner.

Creating Attribute Value Definitions

After the attribute is saved, you will have the opportunity to create and assign the attribute value definition (i.e. different aspects of the attribute such as planned, actual, min, max etc).

 

11. To assign an attribute value, click the "Create One Now" button.

The Attribute Value screen appears, which is where you create the attribute value definition.

 12. When you have finished, click the Save button in the top right corner.

Done! You now have a template with assigned attributes, which you can now assign to an entity.

Tip: To navigate back to your attributes and templates, use the breadcrumb at the top of the page. The bold items are the instances that can be edited.

 


Import/Export Spreadsheet

The Import/Export spreadsheet is generally only used to make bulk changes. 

For details on the spreadsheet and how to obtain it, see Exporting Your Configuration.

If you want to create templates and attributes as part of a bulk configuration, you need to use the following tabs in the Import/Export spreadsheet:

  • Template Definition
  • Attribute Definition

Note: These tabs simply define the templates and attributes, but do not associate them with entities. The entity assignment is done using the Template Instance and Attribute Value tabs, which are described in Configuring Entities.

Look for the red comment commentred icon in the row headers, to get help with each column.

DO NOT fill in or change anything in the Global Id field – this is the unique identifier for the template group that allows it to be tracked across systems, and when it is renamed. It is automatically generated by the system. 

Template Definition Tab

The screenshot below shows an example of configured template definitions (click to enlarge). The fields are the same as the ones in the first step of configuring a template definition in Server Management, using the above instructions on this page.

Dependencies

The Template Definition tab has dependencies with the following tabs: Link Group, Link, Image Group, Image, and Template Group.

Read more: Understanding Object Dependencies

Direct Dependencies

The Template Definition tab is directly dependent on 3 other tabs; Template Group, Link Group, and Link; because columns on the Template Definition tab directly reference columns on those tabs.

This column On this tab Why you need to pay attention
Name Template Group Required by the 'Template Group' column on the Template Definition tab.
Name Link Group Required by the 'Link Group' column on the Template Definition tab.
Name Link Required by the 'Link Name' column on the Template Definition tab.
Name Image Group Required by the 'Image Group' column on the Template Definition tab.
Name Image Required by the 'Image Name' column on the Template Definition tab.
Cascading Dependencies

A cascading dependency exists when a dependent tab (above) has additional dependencies.  These are the columns that you need to pay attention to:

This column On this tab Why you need to pay attention 
Name Link Group In addition to the direct dependency above, this is also required by the Link tab.
Name Image Group In addition to the direct dependency above, this is also required by the Image tab.

Here is a diagram of the dependent tabs and columns. Use this to help you visualise how the dependencies work, and ensure all required columns are completed. Use the comments inside the spreadsheet to help you.

Attribute Definition Tab

Attributes and attribute values are both assigned to templates by using the Attribute Definition tab.  

The screenshot below shows an example of a template that has some attributes and attribute values assigned (click to enlarge). 

There are 2 important parts to this tab: the Attribute Definitions and the Attribute Value Definitions.

Let's first look at the Attribute Definitions.

You can see that the Oil Producing Well template has been assigned the following attributes:

  • Choke
  • CO2 Content
  • Gas Production
  • Hrs Online
  • Mercury Content
  • Oil Flowrate
  • Oil Production
  • Status
  • THP
  • THT
  • Water Production

Each attribute is on a different row, and each attribute has a Data Type, Attribute Group, and Description.

Now, let's focus on the THP attribute on row 11, and scan across to look at columns G-J (click to enlarge). These columns define an attribute value definition for the planned THP value from the well. 

To add more attribute value definitions for an attribute, you need to add more repeating sections like G-J. If you look at columns K-N, you will see that they add another attribute value definition - this time for the Actual THP value. 

You can add as many attribute value definitions as you need to, such as Max or Min, by adding more repeating sections like columns G-J.

Note that ONE of these must be the default value (Is Default = TRUE) so that P2 Server knows what data to serve if an attribute value definition is not specified by a consuming application.

Done! You have now configured your templates with assigned attributes. You can now assign these templates to entities and pull in values for the attributes.

Dependencies

The Attribute Definition tab has dependencies with the following tabs: Link Group, Link, Image Group, Image, Template Group, Template Definition, and Attribute Group.

Direct Dependencies

The Attribute Definition tab is directly dependent on 2 other tabs, Template Definition and Attribute Group, because columns on the Attribute Definition tab directly reference columns on those tabs.

This column On this tab Why you need to pay attention
Name Template Definition Required by the 'Template Definition' column on the Attribute Definition tab.
Name Attribute Group Required by the 'Attribute Group' column on the Attribute Definition tab.
Cascading Dependencies

Because the Attribute Definition tab has a direct dependency on the Template Definition tab, all cascading dependencies from the Template Definition tab also apply to the Attribute Definition tab. See the table above for these cascading dependencies.

Here is a diagram of the dependent tabs and columns. Use this to help you visualise how the dependencies work, and ensure all required columns are completed. Use the comments inside the spreadsheet to help you.

Related: Updating the Configuration

 


Release History

Comments are closed