Interface IObjectService
Represents the service that interacts with object manager API.
Namespace: Relativity.Testing.Framework.Api.ObjectManagement
Assembly: Relativity.Testing.Framework.Api.dll
Syntax
public interface IObjectService
Examples
IObjectService _objectService = relativityFacade.Resolve<IObjectService>();
Methods
| Improve this Doc View SourceCreate<TObject>(Int32, TObject)
Creates the specified entity of TObject
type.
Declaration
TObject Create<TObject>(int workspaceId, TObject entity)
where TObject : Artifact
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The ArtifactID of the workspace where you want to create the object, use -1 for administrator level context. |
TObject | entity | The entity to create. |
Returns
Type | Description |
---|---|
TObject | Returns the created |
Type Parameters
Name | Description |
---|---|
TObject | The type of the object to create. |
Examples
This example shows how to create object using a data model with ObjectTypeName attribute and existing object type name.
[ObjectTypeName("Dashboard)]
internal class TestModel : NamedArtifact
{
public string TestProperty { get; set; }
}
...
int workspaceArtifactID = 1015427;
TestModel objectToCreate = new TestModel
{
Name = "Test Model Name",
TestProperty = "Test Property Value"
};
TestModel createdObject = _objectService.Create(workspaceArtifactID, objectToCreate);
|
Improve this Doc
View Source
Create<TObject>(Int32, IEnumerable<TObject>)
Creates the specified workspace entities of TObject
type.
Declaration
List<int> Create<TObject>(int workspaceId, IEnumerable<TObject> entities)
where TObject : Artifact
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The ArtifactID of the workspace where you want to create the object. |
System.Collections.Generic.IEnumerable<TObject> | entities | The array of entities to create. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.Int32> | Returns the list with ArtifactIDs of created entities. |
Type Parameters
Name | Description |
---|---|
TObject | The type of the objects to create. |
Examples
This example shows how to mass create objects using a data model with ObjectTypeName attribute and existing object type name.
[ObjectTypeName("Dashboard)]
internal class TestModel : NamedArtifact
{
public string TestProperty { get; set; }
}
...
int workspaceArtifactID = 1015427;
List<TestModel> objectsToCreate = new List<TestModel>
{
new TestModel
{
Name = "Test Model Name",
TestProperty = "Test Property Value"
},
new TestModel
{
Name = "Other Test Model Name"
TestProperty = "Other Test Property Value",
},
};
List<TestModel> createdObjects = _objectService.Create(workspaceArtifactID, objectsToCreate);
|
Improve this Doc
View Source
Delete(Int32, IEnumerable<Int32>)
Deletes the workspace entities by the specified ArtifactIDs of workspace and entities.
Declaration
void Delete(int workspaceId, IEnumerable<int> entityIds)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The workspace ArtifactID. |
System.Collections.Generic.IEnumerable<System.Int32> | entityIds | The entity ArtifactIDs. |
Examples
int workspaceArtifactID = 1017850;
var existingEntitiesArtifactIDs = new List<int> { 1039664, 1039689 };
_objectService.Delete(workspaceArtifactID, existingEntitiesArtifactIDs);
|
Improve this Doc
View Source
Delete(Int32, Int32)
Deletes the workspace entity by the specified IDs of workspace and entity.
Declaration
void Delete(int workspaceId, int entityId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The workspace ArtifactID. |
System.Int32 | entityId | The entity ArtifactID. |
Examples
int workspaceArtifactID = 1017850;
int existingEntityArtifactID = 1039664;
_objectService.Delete(workspaceArtifactID, existingEntityArtifactID);
|
Improve this Doc
View Source
GetAll<TObject>()
Gets all objects of TObject
type.
Declaration
TObject[] GetAll<TObject>()
Returns
Type | Description |
---|---|
TObject[] | The collection of |
Type Parameters
Name | Description |
---|---|
TObject | The type of the object. |
Examples
This example shows how to get all entities of GroupObjectType with Object Type Name "Group".
[ObjectTypeName("Group")]
internal class GroupObject
{
public int ArtifactID { get; set; }
public string Name { get; set; }
}
GroupObject[] groups = _objectService.GetAll<GroupObject>();
|
Improve this Doc
View Source
GetAll<TObject>(Expression<Func<TObject, Object>>, Object)
Gets all objects of TObject
type matching specified property filter.
Declaration
TObject[] GetAll<TObject>(Expression<Func<TObject, object>> wherePropertySelector, object whereValue)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<TObject, System.Object>> | wherePropertySelector | The filter property selector. |
System.Object | whereValue | The filter property value. |
Returns
Type | Description |
---|---|
TObject[] | The collection of |
Type Parameters
Name | Description |
---|---|
TObject | The type of the object. |
Examples
This example shows how to get all entities of GroupObjectType with Object Type Name "Group" which have "System Administrators" name.
[ObjectTypeName("Group")]
internal class GroupObject
{
public int ArtifactID { get; set; }
public string Name { get; set; }
}
GroupObject[] groups = _objectService.GetAll<GroupObject>(group => group.Name, "System Administrators");
|
Improve this Doc
View Source
Query<TObject>()
Gets a query to enumerate TObject
objects.
Declaration
ObjectQuery<TObject> Query<TObject>()
Returns
Type | Description |
---|---|
ObjectQuery<TObject> | The ObjectQuery<TObject> object. |
Type Parameters
Name | Description |
---|---|
TObject | The type of the object. |
Examples
This example shows how to query for entities of Field type for workspace with specified ArtifactID.
int workspaceArtifactID = 1017850;
List<Field> fields = _objectService.Query<Field>().For(workspaceArtifactID).ToList();
|
Improve this Doc
View Source
Update(Int32, MassUpdateByObjectIdentifiersRequest)
Updates specified fields on a list of Documents or Relativity Dynamic Objects (RDOs) that match a set of identifiers by setting the fields to the same value.
Declaration
void Update(int workspaceId, MassUpdateByObjectIdentifiersRequest massRequestByObjectIdentifiers)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The ArtifactID of the workspace where you want to update the object, use -1 for administrator level context. |
MassUpdateByObjectIdentifiersRequest | massRequestByObjectIdentifiers | A request to update multiple Documents or Relativity Dynamic Objects (RDOs) that have the specified identifiers. |
Remarks
A MassUpdateByObjectIdentifiersRequest object specifies the identifiers used to select a list of objects with the same type for updating. It also includes the same values for all object fields that are to be updated. In the Relativity UI, this update operation is equivalent to the user selecting the Checked or These option in the mass operations bar on a list page. Process halts at first failure with no rollback.
Examples
This shows how to mass update the value of the field 'Extracted Text' on the Documents.
int workspaceArtifactID = 1017850;
string extractedTextValueToUpdate = "Updated Extracted Text Value";
List<FieldRefValuePair> fieldValues = new List<FieldRefValuePair>
{
new FieldRefValuePair
{
Field = new FieldRef
{
Name = "Extracted Text"
},
Value = extractedTextValueToUpdate
}
};
Document[] documentsToUpdate = relativityFacade.Resolve<IDocumentService>().GetAll().Take(2);
MassUpdateByObjectIdentifiersRequest massRequestByObjectIdentifiers = new MassUpdateByObjectIdentifiersRequest
{
Objects = documentsToUpdate,
FieldValues = fieldValues
};
_objectService.Update(workspaceArtifactID, massRequestByObjectIdentifiers);
|
Improve this Doc
View Source
Update(Int32, Int32, IList<FieldRefValuePair>)
Updates the specified workspace entity fields.
Declaration
void Update(int workspaceId, int entityId, IList<FieldRefValuePair> fieldValues)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The workspace ID. |
System.Int32 | entityId | The ArtifactID of the entity to update. |
System.Collections.Generic.IList<FieldRefValuePair> | fieldValues | List of Field Reference and Value for updating entity. |
Examples
This shows how to update the values of the 'Extracted Text','Group Identifier' and 'Confidential Designation' fields on the Document.
int workspaceArtifactID = 1017850;
int existingDocumentToUpdateArtifactID = 1039664;
int existingConfidentialDesignationChoiceArtifactID = 1038092;
var fieldsToUpdate = new List<FieldRefValuePair>
{
new FieldRefValuePair
{
Field = new FieldRef
{
Name = "Group Identifier"
},
Value = "Updated Group Identifier"
},
new FieldRefValuePair
{
Field = new FieldRef
{
Name = "Extracted Text"
},
Value = "Updated Extracted Text"
},
new FieldRefValuePair
{
Field = new FieldRef
{
Name = "Confidential Designation"
},
Value = new NamedArtifact
{
ArtifactID = existingConfidentialDesignationChoiceArtifactID
}
}
};
_objectService.Update(workspaceArtifactID, existingDocumentToUpdateArtifactID, fieldsToUpdate);
This shows how to update the values of the fields with known ArtifactIDs on the Document.
int workspaceArtifactID = 1017850;
int existingDocumentToUpdateArtifactID = 1039664;
int existingDocumentStringFieldArtifactID = 5345435;
int existingDocumentBoolFieldArtifactID = 478324;
int existingDocumentSingleChoiceFieldArtifactID = 1038055; // ArtifactID of the 'Confidential Designation' Single Choice Field
int existingDocumentSingleChoiceChoiceArtifactID = 1038092; // ArtifactID of the Choice 'Attorneys' Eyes Only' for 'Confidential Designation' Field
var fieldsToUpdate = new List<FieldRefValuePair>
{
new FieldRefValuePair
{
Field = new FieldRef
{
ArtifactID = existingDocumentStringFieldArtifactID
},
Value = "Some updated value of text field"
},
new FieldRefValuePair
{
Field = new FieldRef
{
ArtifactID = existingDocumentBoolFieldArtifactID
},
Value = bool
},
new FieldRefValuePair
{
Field = new FieldRef
{
ArtifactID = existingDocumentSingleChoiceFieldArtifactID
},
Value = new NamedArtifact
{
ArtifactID = existingDocumentSingleChoiceChoiceArtifactID
}
},
};
_objectService.Update(workspaceArtifactID, existingDocumentToUpdateArtifactID, fieldsToUpdate);
|
Improve this Doc
View Source
Update<TObject>(Int32, TObject)
Updates the specified workspace entity of TObject
type.
Declaration
void Update<TObject>(int workspaceId, TObject entity)
where TObject : Artifact
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The workspace ArtifactID. |
TObject | entity | The entity to update. |
Type Parameters
Name | Description |
---|---|
TObject | The type of the object. |
Examples
This shows how to update the value of the SingleChoiceField 'Confidential Designation' on the Document.
[ObjectTypeName("Document")]
internal class DocumentWithSingleChoice : Document
{
public Artifact ConfidentialDesignation { get; set; }
}
...
int workspaceArtifactID = 1017850;
int existingDocumentArtifactID = 1039664;
DocumentWithSingleChoice documentToUpdate = _objectService.GetAll<DocumentWithSingleChoice>(d => d.ArtifactID, documentArtifactID).FirstOrDefault();
_objectService.Update(workspaceArtifactID, documentToUpdate);
This shows how to update the value of the field for which DTO model exists in RTF (Document).
int workspaceArtifactID = 1017850;
string existingDocumentName = "Some Existing Document Name";
Document documentToUpdate = relativityFacade.Resolve<IDocumentService>().Get(workspaceArtifactID, existingDocumentName);
_objectService.Update(workspaceArtifactID, documentToUpdate);