Compartir a través de


TypeProjection

Represents a type definition across a class type and its related class types.

Warning

This element applies to Management Pack Schema 2.0 only.

Schema Hierarchy

ManagementPack
  TypeDefinitions
    EntityTypes
      TypeProjections
        TypeProjection

Syntax

<TypeProjection ID=”id” Comment=”string” Accessibility=”Internal/Public” Type=”classtypeid>
  <Component Path=”string” Alias=”string”></Component>
</TypeProjection>

Attributes and Elements

The following sections describe attributes, child elements, and the parent element for the TypeProjection element.

Attributes

Attribute Description

ID

Required attribute. Represents the identity of the type projection.

Comment

Optional attribute. Represents commentary by the management pack author.

Accessibility

Required attribute. Defines the visibility of the type projection.

Type

Required attribute. Represents the ID of the class type that is the root of the type projection.

Accessibility Attribute Values

Value Description

Public

Indicates that this type projection is visible to external management packs.

Internal

Indicates that external management packs cannot reference this type projection.

Child Elements

Element Description

Component

Optional element. Represents a class type within the type projection relationship hierarchy.

Parent Elements

Element Description

TypeProjections

Contains type projection definitions used to collect a class type and related types together.

Remarks

Type projections allow you to create virtual objection collections through the relationships that are defined between class types. Type projections are generally used when designing Views. A view that is designed over just a single class type will not be able to expose the properties of any if its related class types. However, by defining a type projection that consolidates the single class type (the root class type) and other class types that are within its relationship hierarchy, the view can surface properties both of the root class type and specified instances of its related class types.

You can define type projection templates to supply default property values to instances of any type projection in the system. For more information, see ObjectTemplate.

The Type attribute must refer to a defined class type ID. That class type is referred to as being the “root” of the type projection. All elements that are defined within the type projection are included in the type projection in virtue of their inclusion in the relationship hierarchy of the root class type of the type projection.

Important

When you specify a class type ID for the Type attribute, all instances of that class type, as well as all instances that derive from that class type, will represent type projection root instances.

Example

The following XML samples illustrate the definition type projection within a management pack.

The first sample illustrates how to define a type projection in a management pack. The type projection is designed to consolidate property data regarding review activity. The TypeProjection element defines the root class type of the type projection.


<TypeProjections>
  <TypeProjection ID="System.WorkItem.Activity.ReviewActivityViewProjection" Accessibility="Public" Type="CoreActivity!System.WorkItem.Activity.ReviewActivity">
    <Component Alias="Reviewer" Path="$Target/Path[Relationship='CoreActivity!System.ReviewActivityHasReviewer']$">
      <Component Alias="User" Path="$Target/Path[Relationship='CoreActivity!System.ReviewerIsUser']$" />
    </Component>
  </TypeProjection>
</TypeProjections>

The definition of the System.WorkItem.Activity.ReviewActivity class type is the following:

/* root class type definition */
<ClassType ID="System.WorkItem.Activity.ReviewActivity" Accessibility="Public" Base="System.WorkItem.Activity" Hosted="false" Abstract="false">
  <Property ID="ApprovalCondition" Type="enum" EnumType="ApprovalEnum" />
  <Property ID="ApprovalPercentage" Type="int" />
  <Property ID="Comments" Type="string" />
  <Property ID="LineManagerShouldReview" Type="bool" DefaultValue="false"/>
  <Property ID="OwnersOfConfigItemShouldReview" Type="bool" DefaultValue="false"/>
</ClassType>

To consolidate property data of both the reviewer and the user into System.WorkItem.Activity.ReviewActivity property data, you want to associate related class types that are in a relationship type definition with the root class type. In this case, you are interested in including two relationship type definitions, System.ReviewActivityHasReviewer and System.ReviewerIsUser. The System.ReviewActivityHasReviewer relationship type definition includes a target class type called System.Reviewer. The System.ReviewerIsUser relationship type definition includes a target called System.User. Note that the User element of the type definition is a child of the Reviewer element because the System.User class type is in a relationship with the System.Reviewer class type and not with the System.WorkItem.Activity type. Elements can be added all the way down the relationship hierarchy tree. Each parent element is called the “seed’ of its child components.

<RelationshipType ID="System.ReviewActivityHasReviewer" Base="System!System.Membership" Abstract="false" Accessibility="Public">
  <Source ID="ParticipatesInReviewActivity" Type="System.WorkItem.Activity" />
  <Target ID="Reviewer" Type="System.Reviewer" />
</RelationshipType>
<RelationshipType ID="System.ReviewerIsUser" Base="System!System.Reference" Abstract="false" Accessibility="Public">
  <Source ID="Reviewer" Type="System.Reviewer" />
  <Target ID="User" Type="System!System.User" MaxCardinality="1" />
</RelationshipType>

Now that the type projection has been defined the management pack, it is possible for the user to create or use a view over this type projection. That view will surface the properties of the root class type and all the class types that are in the relationiship hierarchy of the root class type and are referenced by paths of the type projection definition.

See Also

Reference

ClassType
RelationshipType