Data cache service

From Catglobe Wiki
Revision as of 17:54, 14 October 2009 by Catglobe (talk | contribs)
Jump to: navigation, search

Introduction

When working on solutions for clients it is not always enough to report on the collected data, in some cases the client also wants to get access to the raw data directly.

Normally this can be handled by exporting the data, but in some cases the client is looking for an automated approach, where they can develop a data consumer, thus we have created a service from which we provide access to data from data caches.

The raw data has also shown to be useful when setting up dashboards, where access to the raw data from an RCS for instance allows us to make very advanced solutions such as our CRM solution.

Service APIs

The data cache service consists of two APIs; an external API allowing external applications to retrieve data from a data cache through SOAP calls, and an internal API that gives access to data from a data cache through JavaScript, which can be used from dashboards for example.

Requests using the internal API happens in a stateful context contrary to the external API where requests happen in a stateless context. Thus the primary difference between the two APIs is that the external API requires username and password each time a request is made.

The user requesting data from a data cache must have minimum observer access to the data cache specification, no matter if the external or internal API is used.

External API

/// <summary>
/// Gets the number of rows of a data cache
/// </summary>
/// <param name="username">Username for the user account used to access Catglobe</param>
/// <param name="password">Password for the user account used to access Catglobe</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <returns>Returns the number of rows in the data cache</returns>
int GetRowCount(string username, string password, int resourceId);

/// <summary>
/// Gets all rows from a data cache, with data from a selection of columns
/// </summary>
/// <param name="username">Username for the user account used to access Catglobe</param>
/// <param name="password">Password for the user account used to access Catglobe</param>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <returns>Returns the data cache containing all rows of data for the selected columns</returns>
DataCacheDto GetData(string username, string password, string[] columns, int dcsResourceId);

/// <summary>
/// Gets all rows from a data cache, with data from a selection of columns
/// </summary>
/// <param name="username">Username for the user account used to access Catglobe</param>
/// <param name="password">Password for the user account used to access Catglobe</param>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <param name="orderByColumns">Order the result by these columns</param>
/// <param name="sortOrder">Order the rows ascending or descending</param>
/// <returns>Returns the data cache containing all rows of data for the selected columns</returns>
DataCacheDto GetDataSorted(string username, string password, string[] columns, int dcsResourceId, string[] orderByColumns, DataCacheSortOrderEnum sortOrder);

/// <summary>
/// Gets all rows from a data cache starting from a row index and returning rows as requested
/// </summary>
/// <param name="username">Username for the user account used to access Catglobe</param>
/// <param name="password">Password for the user account used to access Catglobe</param>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <param name="rowIndex"></param>
/// <param name="rowCount"></param>
DataCacheDto GetDataRows(string username, string password, string[] columns, int dcsResourceId, int rowIndex, int rowCount);

/// <summary>
/// Gets all rows from a data cache starting from a row index and returning rows as requested
/// </summary>
/// <param name="username">Username for the user account used to access Catglobe</param>
/// <param name="password">Password for the user account used to access Catglobe</param>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <param name="orderByColumns"></param>
/// <param name="sortOrder"></param>
/// <param name="orderByColumns">Order the result by these columns</param>
/// <param name="sortOrder">Order the rows ascending or descending</param>
/// <param name="rowIndex"></param>
/// <param name="rowCount"></param>
DataCacheDto GetDataRowsSorted(string username, string password, string[] columns, int dcsResourceId, string[] orderByColumns, DataCacheSortOrderEnum sortOrder, int rowIndex, int rowCount);

/// <summary>
/// Gets the top N rows from a data cache, with data from a selection of columns, ordered by some column.
/// Rows with no values will be excluded, meaning that the data cache returned might contain fewer rows,
/// than indicated by N
/// </summary>
/// <param name="username">Username for the user account used to access Catglobe</param>
/// <param name="password">Password for the user account used to access Catglobe</param>
/// <param name="top">The top N rows to return</param>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <returns>Returns the data cache containing N rows of data for the selected columns</returns>
DataCacheDto GetDataTop(string username, string password, int top, string[] columns, int dcsResourceId);

/// <summary>
/// Gets the top N rows from a data cache, with data from a selection of columns, ordered by some column.
/// Rows with no values will be excluded, meaning that the data cache returned might contain fewer rows,
/// than indicated by N
/// </summary>
/// <param name="username">Username for the user account used to access Catglobe</param>
/// <param name="password">Password for the user account used to access Catglobe</param>
/// <param name="top">The top N rows to return</param>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <param name="orderByColumns">Order the result by these columns</param>
/// <param name="sortOrder">Order the rows ascending or descending</param>
/// <returns>Returns the data cache containing N rows of data for the selected columns</returns>
DataCacheDto GetDataTopSorted(string username, string password, int top, string[] columns, int dcsResourceId, string[] orderByColumns, DataCacheSortOrderEnum sortOrder);

/// <summary>
/// Gets all rows from a data cache, with data from a selection of columns, belonging to a selection of users
/// </summary>
/// <param name="username">Username for the user account used to access Catglobe</param>
/// <param name="password">Password for the user account used to access Catglobe</param>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <param name="users">The user ids for which data is requested</param>
/// <returns>Returns the data cache containing only data for the logged in user</returns>
DataCacheDto GetDataForUsers(string username, string password, string[] columns, int dcsResourceId, int[] users);

/// <summary>
/// Gets all rows from a data cache, with data from a selection of columns, belonging to a selection of users
/// </summary>
/// <param name="username">Username for the user account used to access Catglobe</param>
/// <param name="password">Password for the user account used to access Catglobe</param>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <param name="users">The user ids for which data is requested</param>
/// <param name="orderByColumns">Order the result by these columns</param>
/// <param name="sortOrder">Order the rows ascending or descending</param>
/// <returns>Returns the data cache containing only data for the logged in user</returns>
DataCacheDto GetDataForUsersSorted(string username, string password, string[] columns, int dcsResourceId, int[] users, string[] orderByColumns, DataCacheSortOrderEnum sortOrder);

Internal API

/// <summary>
/// Gets the number of rows of a data cache
/// </summary>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <returns>Returns the number of rows in the data cache</returns>
int GetRowCount(int resourceId);

/// <summary>
/// Gets all rows from a data cache, with data from a selection of columns
/// </summary>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <returns>Returns the data cache containing all rows of data for the selected columns</returns>
DataCacheDto GetData(string[] columns, int dcsResourceId);

/// <summary>
/// Gets all rows from a data cache, with data from a selection of columns
/// </summary>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <param name="orderByColumns">Order the result by these columns</param>
/// <param name="sortOrder">Order the rows ascending or descending</param>
/// <returns>Returns the data cache containing all rows of data for the selected columns</returns>
DataCacheDto GetDataSorted(string[] columns, int dcsResourceId, string[] orderByColumns, DataCacheSortOrderEnum sortOrder);

/// <summary>
/// Gets all rows from a data cache starting from a row index and returning rows as requested
/// </summary>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <param name="rowIndex"></param>
/// <param name="rowCount"></param>
DataCacheDto GetDataRows(string[] columns, int dcsResourceId, int rowIndex, int rowCount);

/// <summary>
/// Gets all rows from a data cache starting from a row index and returning rows as requested
/// </summary>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <param name="orderByColumns"></param>
/// <param name="sortOrder"></param>
/// <param name="orderByColumns">Order the result by these columns</param>
/// <param name="sortOrder">Order the rows ascending or descending</param>
/// <param name="rowIndex"></param>
/// <param name="rowCount"></param>
DataCacheDto GetDataRowsSorted(string[] columns, int dcsResourceId, string[] orderByColumns, DataCacheSortOrderEnum sortOrder, int rowIndex, int rowCount);

/// <summary>
/// Gets the top N rows from a data cache, with data from a selection of columns, ordered by some column.
/// Rows with no values will be excluded, meaning that the data cache returned might contain fewer rows,
/// than indicated by N
/// </summary>
/// <param name="top">The top N rows to return</param>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <returns>Returns the data cache containing N rows of data for the selected columns</returns>
DataCacheDto GetDataTop(int top, string[] columns, int dcsResourceId);

/// <summary>
/// Gets the top N rows from a data cache, with data from a selection of columns, ordered by some column.
/// Rows with no values will be excluded, meaning that the data cache returned might contain fewer rows,
/// than indicated by N
/// </summary>
/// <param name="top">The top N rows to return</param>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <param name="orderByColumns">Order the result by these columns</param>
/// <param name="sortOrder">Order the rows ascending or descending</param>
/// <returns>Returns the data cache containing N rows of data for the selected columns</returns>
DataCacheDto GetDataTopSorted(int top, string[] columns, int dcsResourceId, string[] orderByColumns, DataCacheSortOrderEnum sortOrder);

/// <summary>
/// Gets all rows from a data cache, with data from a selection of columns, belonging to a selection of users
/// </summary>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <param name="users">The user ids for which data is requested</param>
/// <returns>Returns the data cache containing only data for the logged in user</returns>
DataCacheDto GetDataForUsers(string[] columns, int dcsResourceId, int[] users);

/// <summary>
/// Gets all rows from a data cache, with data from a selection of columns, belonging to a selection of users
/// </summary>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <param name="users">The user ids for which data is requested</param>
/// <param name="orderByColumns">Order the result by these columns</param>
/// <param name="sortOrder">Order the rows ascending or descending</param>
/// <returns>Returns the data cache containing only data for the logged in user</returns>
DataCacheDto GetDataForUsersSorted(string[] columns, int dcsResourceId, int[] users, string[] orderByColumns, DataCacheSortOrderEnum sortOrder);

/// <summary>
/// Gets all rows from a data cache,with data from a selection of columns, belonging to a logged in user.
/// 
/// This method can only be used from client-side where the user is already authenticated.
/// </summary>
/// <param name="dcsResourceId">The resource id for the data cache specification which contains the data</param>
/// <param name="columns">The columns for which data is requested</param>
/// <param name="dataViewUser">The GUID for a user which have minimum observer access to the data cache specification</param>
DataCacheDto GetDataForLoggedInUser(string[] columns, int dcsResourceId, Guid dataViewUser);

Data structures

Error handling

Examples