Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
query.h
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2016 The Earlham Institute
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16 
21 #ifndef IRODS_QUERY_H
22 #define IRODS_QUERY_H
23 
24 
25 #include <jansson.h>
26 
27 
28 #include "irods_util_library.h"
29 #include "linked_list.h"
30 
31 
32 /* forward declaration */
33 struct IRodsConnection;
34 
35 
40 typedef struct QueryResult
41 {
43  /*
44  * Due to the columnNames array being in the same file as the
45  * definition of columnName_t (rodsGenQueryNames.h) we get
46  * multiple definition errors if we try to set qr_column_p to be
47  * columnName_t, so we need to have it as void in the definition.
48  * If rodsGenQueryNames.h gets refactored or if the struct that
49  * columnName_t is a typedef of ceases to be anonymous, then we can
50  * change this.
51  */
52  const void *qr_column_p;
53  char **qr_values_pp;
54  int qr_num_values;
55 } QueryResult;
56 
57 
62 typedef struct QueryResults
63 {
66 
69 } QueryResults;
70 
71 
72 #ifdef __cplusplus
73 extern "C"
74 {
75 #endif
76 
77 
78 
86 IRODS_UTIL_API char *BuildQueryString (const char **args_ss);
87 
88 
96 IRODS_UTIL_API void FreeBuiltQueryString (char *query_s);
97 
98 
106 IRODS_UTIL_API void PrintQueryResults (FILE *out_f, const QueryResults * const result_p);
107 
108 
116 IRODS_UTIL_API void PrintQueryResult (FILE *out_f, const QueryResult * const result_p);
117 
118 
119 
127 
128 
129 IRODS_UTIL_LOCAL const char *GetColumnNameForId (const int id);
130 
131 
133 IRODS_UTIL_LOCAL void ClearQueryResult (QueryResult *result_p);
134 
135 
144 IRODS_UTIL_API json_t *GetQueryResultAsJSON (const QueryResults * const results_p);
145 
146 
155 IRODS_UTIL_API json_t *GetQueryResultAsResourcesJSON (const QueryResults * const qrs_p);
156 
157 
167 
168 
178 
179 
180 
190 IRODS_UTIL_API QueryResults *GetAllMetadataDataAttributeValues (struct IRodsConnection *connection_p, const char * const name_s);
191 
192 
201 
202 
211 
212 
223 IRODS_UTIL_LOCAL QueryResults *GetAllAttributeNames (struct IRodsConnection *connection_p, const int col_id);
224 
225 
238 IRODS_UTIL_API QueryResults *GetAllMetadataAttributeValues (struct IRodsConnection *connection_p, const int key_id, const char * const key_s, const int value_id);
239 
240 
241 
242 #ifdef __cplusplus
243 }
244 #endif
245 
246 #endif /* #ifndef IRODS_QUERY_H */
QueryResults::GetQueryResultAsResourcesJSON
json_t * GetQueryResultAsResourcesJSON(const QueryResults *const qrs_p)
Get the json representation of a QueryResults in the format of a Resource.
BuildQueryString
char * BuildQueryString(const char **args_ss)
Build a new query string to use to execute a query.
QueryResults::FreeQueryResults
void FreeQueryResults(QueryResults *result_p)
Free a QueryResults.
QueryResult
A datatype for accessing a single result of a search on an iRODS server.
Definition: query.h:40
GetAllMetadataAttributeValues
QueryResults * GetAllMetadataAttributeValues(struct IRodsConnection *connection_p, const int key_id, const char *const key_s, const int value_id)
Get all of the data attribute names within the iCAT system of an iRODS server for give column id.
GetAllMetadataUserAttributeNames
QueryResults * GetAllMetadataUserAttributeNames(struct IRodsConnection *connection_p)
Get all of the user attribute names within the iCAT system of an iRODS server.
GetAllMetadataDataAttributeValues
QueryResults * GetAllMetadataDataAttributeValues(struct IRodsConnection *connection_p, const char *const name_s)
Get all of the data attribute values for the given name within the iCAT system of an iRODS server.
IRodsConnection
This is a wrapper which hides the internals of the code and objects needed to access an iRODS system.
Definition: irods_connection.h:42
GetAllMetadataDataAttributeNames
QueryResults * GetAllMetadataDataAttributeNames(struct IRodsConnection *connection_p)
Get all of the data attribute names within the iCAT system of an iRODS server.
IRODS_UTIL_API
#define IRODS_UTIL_API
Definition: irods_util_library.h:46
QueryResults::qr_values_p
QueryResult * qr_values_p
The array of results.
Definition: query.h:68
QueryResults::PrintQueryResults
void PrintQueryResults(FILE *out_f, const QueryResults *const result_p)
Print a QueryResults to an output FILE.
QueryResults::GetQueryResultsPaths
LinkedList * GetQueryResultsPaths(const QueryResults *const qrs_p)
Get the full path to all collections and data objects in the given QueryResults.
irods_util_library.h
QueryResults::PrintQueryResult
void PrintQueryResult(FILE *out_f, const QueryResult *const result_p)
Print a QueryResult to an output FILE.
FreeBuiltQueryString
void FreeBuiltQueryString(char *query_s)
Free a previously generated query string.
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
QueryResults::GetQueryResultAsJSON
json_t * GetQueryResultAsJSON(const QueryResults *const results_p)
Get the json representation of a QueryResults.
QueryResults
A datatype for holding an array of the results of a search on an iRODS server.
Definition: query.h:62
GetAllMetadataCollectionAttributeNames
QueryResults * GetAllMetadataCollectionAttributeNames(struct IRodsConnection *connection_p)
Get all of the collection attribute names within the iCAT system of an iRODS server.
IRODS_UTIL_LOCAL
#define IRODS_UTIL_LOCAL
Definition: irods_util_library.h:47
linked_list.h
A doubly-linked list.
QueryResults::qr_num_results
int qr_num_results
The number of results in the array.
Definition: query.h:65