relativitydev / Gravity

ORM Framework for Relativity Custom Development
Other
16 stars 10 forks source link
csharp dotnet orm relativity

Gravity

Open Source Community: Gravity is an ORM framework for Relativity custom development. Using Gravity will greatly decrease the amount of time it takes to pick up Relativity development and allow you to write code that interacts with Relativity with commonly used C# syntax.

While this project is hosted on the RelativityDev account, support is only available through the Relativity developer community. You are welcome to use the code and solution as you see fit within the confines of the license it is released under. However, if you are looking for support or modifications to the solution, we suggest reaching out to a Relativity Development Partner.

Gravity was originally created by TSD Services. Through their generosity and leadership, they have released the project as open source. It is an active project and has contributions from other Relativity Development Partners. Anyone who has a need is invited to use and contribute to the project. If you are interested in contributing, check out the open issues and Wiki pages.

We would like to recognize the following Relativity Development Partners who have made significant contributions to the Gravity project:

<p align="center>

TSD Services            

This is also available as a nuget package.

Target Frameworks

Dependencies

This project requires references to Relativity's Relativity® SDK dlls, which are referenced via Nuget packages. As such, DLL versions 9.4.224.2 and up are supported.

Sample / Test Suite

Information about the demo application and accompanying integration tests is available on a separate page.

Usage Guide

Before using the CRUD/Q methods in Gravity you will have to create a model and decorate it with the appropriate attributes:

The following example demonstrates a RDO represented as a Model:

[Serializable]
[RelativityObject("0B5C62E0-2AFA-4408-B7FF-789351C9BEDC")]
public class DemoPurchaseOrder : BaseDto
{
    [RelativityObjectField("E1FA93B9-C2DB-442A-9978-84EEB6B61A3F", RdoFieldType.FixedLengthText, 255)]
    public override string Name { get; set; }

    [RelativityObjectField("37159592-B5B6-4405-AF74-10B5728890B4", RdoFieldType.WholeNumber)]
    public int OrderNumber { get; set; }

    [RelativityObjectField("37159592-B5B6-4405-AF74-10B5728890B4", RdoFieldType.FixedLengthText, 100)]
    public string CustomerName { get; set; }

    [RelativityObjectField("3BDC0971-A87C-414E-9A37-FC477279BBAD", RdoFieldType.FixedLengthText, 100)]
    public string CustomerEmail { get; set; }

    [RelativityObjectField("D0770889-8A4D-436A-9647-33419B96E37E"), RdoFieldType.MultipleObject)]
    public IList<Items> Items { get; set; }

    [RelativityObjectField("D0770889-8A4D-436A-9647-33419B96E37E"), RdoFieldType.SingleObject)]
    public Address Address { get; set; }

    [RelativityObjectField("4501A308-5E68-4314-AEDC-4DEB527F12A8", RdoFieldType.Decimal)]
    public decimal Total { get; set; }

    [RelativityObjectField("CEDB347B-679D-44ED-93D3-0B3027C7E6F5", RdoFieldType.SingleChoice)]
    public OrderType OrderType { get; set; }

    [RelativityObjectChildrenList]
    public IList<RelatedPurchase> RelatedPurchases { get; set; }
}

For Choice field you must create a enum and decorate it with the appropriate attributes:

The following example demonstrates a choice field represented as an Enum:

public enum OrderType
{
    [RelativityObject("4F04381D-F3E3-4DEE-8EF9-11F27047D9B4")]
    TypeOne = 1,

    [RelativityObject("8453BF3E-D95B-4BC5-BD68-3CF4277DD731")]
    TypeTwo = 2
}

To use Gravity for RSAPI operations, you must instantiate an RsapiDao object using the RsapiDao constructor, with IHelper and workspaceId as parameters.

Supported IGravityDao methods:

Additional methods supported by RsapiDao:

Where available, the depthLevel parameter controls whether (and how deeply) to recurse into object fields and child object lists. The recursion options are OnlyParentObject, FirstLevelOnly, and FullyRecursive.

Example

The following example demonstrates a object "Get" used in Event handler. First we instantiate RsapiDao and then we use the Gravity RSAPI Dao Get method to get the object (ObjectFieldsDepthLevel.OnlyParentObject means that we want just the object - no child object fields, multiple object fields or single object fields are populated recursively):

public override Response Execute()
{
    Response returnResponse = new Response() { Message = string.Empty, Success = true };

    RsapiDao gravityRsapiDao = new RsapiDao(this.Helper, this.Helper.GetActiveCaseID());

        DemoPurchaseOrder demoOrder =  gravityRsapiDao.Get<DemoPurchaseOrder>(1047088,
      ObjectFieldsDepthLevel.OnlyParentObject);

        return returnResponse;
}