TermStore TermStore TermStore Class

Definition

Represents a store that contains metadata within child Group objects, TermSet objects, and Term objects.

public ref class TermStore sealed
[Microsoft.SharePoint.Client.ClientCallableType(ClientLibraryTargets=Microsoft.SharePoint.Client.ClientLibraryTargets.NonRESTful, FactoryType=typeof(Microsoft.SharePoint.Taxonomy.Internal.TaxonomyClientObjectFactory), ObjectIdentityPropertyName="CanonicalId", ServerTypeId="9D8A8884-B1DC-4dbc-81C5-DDEA8AD3184C")]
public sealed class TermStore
Public NotInheritable Class TermStore
Inheritance
TermStoreTermStoreTermStore
Attributes
Microsoft.SharePoint.Client.ClientCallableTypeAttribute

Examples

<p>The following example demonstrates creating a sample term set.</p>
<pre><code>using System;

using Microsoft.SharePoint; using Microsoft.SharePoint.Taxonomy; using Microsoft.SharePoint.Publishing.Navigation;

namespace NavigationDemos { public class Class1 { public static readonly Guid NavTermSetId = new Guid("&lt;GUID&gt;"); public static readonly Guid TaggingTermSetId = new Guid("&lt;GUID&gt;");

    //Creates the sample term set. If it exists, it will be deleted
    public static NavigationTermSet RecreateSampleNavTermSet(TaxonomySession taxonomySession, SPWeb web)
    {
        // Use the first TermStore in the list
        if (taxonomySession.TermStores.Count == 0)
            throw new InvalidOperationException("The Taxonomy Service is offline or missing");

        TermStore termStore = taxonomySession.TermStores[0];

        // Does the TermSet already exist?
        TermSet existingTermSet = termStore.GetTermSet(NavTermSetId);

        if (existingTermSet != null)
        {
            //If the TermSet exists, delete it.
            existingTermSet.Delete();
            termStore.CommitAll();
        }

        // Create a new TermSet
        Group siteCollectionGroup = termStore.GetSiteCollectionGroup(web.Site);
        TermSet termSet = siteCollectionGroup.CreateTermSet("Navigation Demo", NavTermSetId);
        NavigationTermSet navTermSet = NavigationTermSet.GetAsResolvedByWeb(termSet, web,
            StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider);
        navTermSet.IsNavigationTermSet = true;
        navTermSet.TargetUrlForChildTerms.Value = "~site/Pages/Topics/Topic.aspx";
        NavigationTerm term1 = navTermSet.CreateTerm("Term 1", NavigationLinkType.SimpleLink);
        term1.SimpleLinkUrl = "http://www.bing.com/";
        NavigationTerm term2 = navTermSet.CreateTerm("Term 2", NavigationLinkType.FriendlyUrl);
        NavigationTerm term2a = term2.CreateTerm("Term 2 A", NavigationLinkType.FriendlyUrl);
        NavigationTerm term2b = term2.CreateTerm("Term 2 B", NavigationLinkType.FriendlyUrl);
        NavigationTerm term3 = navTermSet.CreateTerm("Term 3", NavigationLinkType.FriendlyUrl);
        termStore.CommitAll();
        return navTermSet;
    }
}

}

Remarks

A TermStore contains zero or more Group objects, which are used to organize Terms within TermSets. Access the groups through the Groups property.

The TermStore class also provides methods for creating new child Group objects, getting and setting TermStore Administrator permissions on the term store, and checking permissions. Additionally, it provides properties that are used to get and set values of the TermStore object such as the set of working languages, and access to the keyword and orphaned term TermSet objects.

Use methods of the the TermStore class such as the GetTerms(String, Boolean) and GetTermSets(String, Int32) to search for and get TermSet and Term objects across all child groups

Finally, the TermStore provides the CommitAll() method and the RollbackAll() method to commit or roll back changes to the database These methods are the only way to persist changes to the database when updates are made in child objects such as Group, TermSet, and Term.

Properties

ContentTypePublishingHub ContentTypePublishingHub ContentTypePublishingHub

Gets the URI of the SPSite object used as the content type syndication hub, if it exists.

DefaultLanguage DefaultLanguage DefaultLanguage

Gets or sets the LCID of the default working language for the current TermStore object.

Groups Groups Groups

Gets a collection of the child Group objects of this TermStore object

HashTagsTermSet HashTagsTermSet HashTagsTermSet

Gets the HashTagsTermSet for a TermStore object that contains the set of #tags.

Id Id Id

Gets the unique identifier of the TermStore object.

IsOnline IsOnline IsOnline

Indicates whether this term store is currently online (available).

KeywordsTermSet KeywordsTermSet KeywordsTermSet

Gets the TermSet object for this TermStore object.

Languages Languages Languages

Gets an integer collection of LCIDs.

Name Name Name

Gets the name of the current TermStore object.

OrphanedTermsTermSet OrphanedTermsTermSet OrphanedTermsTermSet

Gets the TermSet for this TermStore which contains the set of Orphaned Term objects.

SystemGroup SystemGroup SystemGroup

Gets the Group object for this TermStore object. which contains the set of System TermSets (Keywords and Orphaned Terms)

TermStoreAdministrators TermStoreAdministrators TermStoreAdministrators

Returns the SPAcl indicating the users who are Term Store Administrators for this TermStore object.

WorkingLanguage WorkingLanguage WorkingLanguage

Gets or sets the current working language of the TermStore object.

Methods

AddLanguage(Int32) AddLanguage(Int32) AddLanguage(Int32)

Adds a working language to the TermStore object.

AddTermStoreAdministrator(String) AddTermStoreAdministrator(String) AddTermStoreAdministrator(String)

Adds a Term Store Administrator to the TermStore object.

CommitAll() CommitAll() CommitAll()

Commits all updates to the database that have occurred since the last commit or rollback.

CreateGroup(String) CreateGroup(String) CreateGroup(String)

Creates a new Group object in this TermStore.

CreateGroup(String, Guid) CreateGroup(String, Guid) CreateGroup(String, Guid)

Creates a new Group object in a TermStore.

DeleteLanguage(Int32) DeleteLanguage(Int32) DeleteLanguage(Int32)

Deletes a working language from the TermStore object.

DeleteTermStoreAdministrator(String) DeleteTermStoreAdministrator(String) DeleteTermStoreAdministrator(String)

Deletes a Term Store Administrator from the TermStore.

DoesUserHavePermissions(TaxonomyRights) DoesUserHavePermissions(TaxonomyRights) DoesUserHavePermissions(TaxonomyRights)

Verifies whether the current user has the permissions specified in the TermStore object.

FlushCache() FlushCache() FlushCache()

Flushes the cache so that the most recent changes to the TermStore object will be viewed.

GetChanges(DateTime, ChangedItemType, ChangedOperationType) GetChanges(DateTime, ChangedItemType, ChangedOperationType) GetChanges(DateTime, ChangedItemType, ChangedOperationType)

Gets a collection of ChangedItem objects that represent changes to this TermStore since a specified time, restricted by item type and operation type.

GetChanges(DateTime, ChangedItemType) GetChanges(DateTime, ChangedItemType) GetChanges(DateTime, ChangedItemType)

Gets a collection of ChangedItem objects that represent changes to this TermStore since a specified time, restricted by item type.

GetChanges(TimeSpan) GetChanges(TimeSpan) GetChanges(TimeSpan)

Gets a collection of ChangedItem objects that represent changes to this Microsoft.SharePoint.TermStore object in a recent span of time.

GetChanges(DateTime) GetChanges(DateTime) GetChanges(DateTime)

Gets a collection of ChangedItem objects that represent changes to this TermStore since a specified time.

GetGroup(Guid) GetGroup(Guid) GetGroup(Guid)

Gets a Group object based on the ID of the Group.

GetImportManager() GetImportManager() GetImportManager()

Gets the ImportManager object for this TermStore object.

GetSiteCollectionGroup(SPSite) GetSiteCollectionGroup(SPSite) GetSiteCollectionGroup(SPSite)

Returns associated site collection group for the SPSite object.

GetSiteCollectionGroup(SPSite, Boolean) GetSiteCollectionGroup(SPSite, Boolean) GetSiteCollectionGroup(SPSite, Boolean)

Returns the associated site collection group for the SPSite.

GetTerm(Guid) GetTerm(Guid) GetTerm(Guid)

Gets a Term based on its ID.

GetTerm(Guid, Guid) GetTerm(Guid, Guid) GetTerm(Guid, Guid)

Gets a Term object that is based on the ID of the TermSet object and the ID of the Term.

GetTerms(Guid[]) GetTerms(Guid[]) GetTerms(Guid[])

Gets a collection of Term objects based on the ID of the Term.

GetTerms(String, Boolean) GetTerms(String, Boolean) GetTerms(String, Boolean)

Returns a collection of all Term objects from all TermSet objects in this TermStore that the current user has permissions to read with a Label object that matches the string provided in any LCID.

GetTerms(String, Int32, Boolean) GetTerms(String, Int32, Boolean) GetTerms(String, Int32, Boolean)

Returns a collection of all Term objects from all TermSet objects in this TermStore that the current user has permissions to read with a label in the provided LCID matching the string provided.

GetTerms(String, Boolean, StringMatchOption, Int32, Boolean) GetTerms(String, Boolean, StringMatchOption, Int32, Boolean) GetTerms(String, Boolean, StringMatchOption, Int32, Boolean)

Gets a collection of all Term objects from all TermSet objects in this TermStore that the current user has permissions to read with a Label object that matches the string provided in any LCID, with an option to only search default labels.

GetTerms(String, Int32, Boolean, StringMatchOption, Int32, Boolean, Boolean, Boolean) GetTerms(String, Int32, Boolean, StringMatchOption, Int32, Boolean, Boolean, Boolean) GetTerms(String, Int32, Boolean, StringMatchOption, Int32, Boolean, Boolean, Boolean)

Gets a collection of all Term objects from all TermSet objects in this TermStore object that the current user has permissions to read with a Label matching the string provided in any LCID, with an option to only search default labels, and options to trim certain terms.

GetTermSet(Guid) GetTermSet(Guid) GetTermSet(Guid)

This method retrieves a TermSet object based on a TermSet ID.

GetTermSets(String[]) GetTermSets(String[]) GetTermSets(String[])

Gets a collection of all TermSet objects in this Microsoft.SharePoint.TaxonomyTermStore object that the current user has permissions to read that contain terms with labels matching or starting with each of the specified strings.

GetTermSets(String, Int32) GetTermSets(String, Int32) GetTermSets(String, Int32)

This method retrieves a collection of all TermSets in this TermStore that the current user has permissions to read that have a matching TermSet name in the provided LCID

GetTermSets(String[], Int32) GetTermSets(String[], Int32) GetTermSets(String[], Int32)

This method retrieves a collection of all TermSets in this TermStore that the current user has permissions to read that contain terms with labels matching or starting with each of the specified strings for a specified LCID.

GetTermSetsWithCustomProperty(String) GetTermSetsWithCustomProperty(String) GetTermSetsWithCustomProperty(String)

Searches TermSet objects that have a custom property with the provided name in a TermStore.

GetTermSetsWithCustomProperty(String, String) GetTermSetsWithCustomProperty(String, String) GetTermSetsWithCustomProperty(String, String)

Searches TermSet objects that have a custom property with the provided name and the provided value in a TermStore.

GetTermSetsWithCustomProperty(String, String, StringMatchOption) GetTermSetsWithCustomProperty(String, String, StringMatchOption) GetTermSetsWithCustomProperty(String, String, StringMatchOption)

Searches TermSet objects that have a custom property with the provided name and the provided value in a TermStore.

GetTermSetsWithCustomProperty(String, String, StringMatchOption, Int32) GetTermSetsWithCustomProperty(String, String, StringMatchOption, Int32) GetTermSetsWithCustomProperty(String, String, StringMatchOption, Int32)

Searches TermSet objects that have a custom property with the provided name and the provided value in a TermStore.

GetTermsWithCustomProperty(String, Boolean) GetTermsWithCustomProperty(String, Boolean) GetTermsWithCustomProperty(String, Boolean)

This method retrieves a collection of all Term objects, from all TermSets in this TermStore that the current user has permissions to read, that have a custom property with the provided property name.

GetTermsWithCustomProperty(String, Int32, Boolean) GetTermsWithCustomProperty(String, Int32, Boolean) GetTermsWithCustomProperty(String, Int32, Boolean)

This method retrieves a collection of all Term objects, from all TermSets in this TermStore that the current user has permissions to read, that have a custom property with the provided property name.

GetTermsWithCustomProperty(String, String, Boolean) GetTermsWithCustomProperty(String, String, Boolean) GetTermsWithCustomProperty(String, String, Boolean)

Gets a collection of all Term objects, from all TermSet objects in this TermStore object that the current user has permissions to read, that have a custom property with the specified property name and the specified property value.

GetTermsWithCustomProperty(String, String, StringMatchOption, Boolean) GetTermsWithCustomProperty(String, String, StringMatchOption, Boolean) GetTermsWithCustomProperty(String, String, StringMatchOption, Boolean)

Gets a collection of all Term objects, from all TermSet objects in this TermStore that the current user has permissions to read, that have a custom property starting with or matching the provided property name and the provided property value.

GetTermsWithCustomProperty(String, String, StringMatchOption, Int32, Boolean) GetTermsWithCustomProperty(String, String, StringMatchOption, Int32, Boolean) GetTermsWithCustomProperty(String, String, StringMatchOption, Int32, Boolean)

Gets a collection of all of the Term objects, from all T:Microsoft.SharePoint.TaxonomyTermSets in this TermStore that the current user has permissions to read, that have a custom property starting with or matching the provided property name and the provided property value.

ResyncHiddenList(SPSite) ResyncHiddenList(SPSite) ResyncHiddenList(SPSite)

This method is used to update the term store with the currently used terms on a specified site.

RollbackAll() RollbackAll() RollbackAll()

Discards all updates that have occurred since the last commit or rollback.

UpdateCache() UpdateCache() UpdateCache()

Forces the Taxonomy cache to communicate with the managed metadata service to check for changes to any taxonomy objects in a TermStore.

UpdateUsedTermsOnSite(SPSite) UpdateUsedTermsOnSite(SPSite) UpdateUsedTermsOnSite(SPSite)

This method makes sure that the current TermStore object is aware of all child Term object that are used in the requested site collection.

Extension Methods

ToJson(Object) ToJson(Object) ToJson(Object)

Applies to