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.
programme.h
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2018 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 /*
17  * program.h
18  *
19  * Created on: 19 Dec 2018
20  * Author: billy
21  */
22 
23 #ifndef SERVICES_FIELD_TRIALS_INCLUDE_PROGRAM_H_
24 #define SERVICES_FIELD_TRIALS_INCLUDE_PROGRAM_H_
25 
26 
27 #include <time.h>
28 
31 #include "field_trial.h"
32 #include "location.h"
33 #include "jansson.h"
34 
35 #include "typedefs.h"
36 #include "person.h"
37 #include "permission.h"
38 
39 
46 typedef struct Programme
47 {
48  bson_oid_t *pr_id_p;
49 
50 
52 
57 
59 
64 
65 
70 
75 
80 
84  char *pr_name_s;
85 
90 
95 
102 
103 
108 
109 
114 
119 
120 } Programme;
121 
122 
123 typedef struct ProgrammeNode
124 {
127 } ProgrammeNode;
128 
129 
130 #ifndef DOXYGEN_SHOULD_SKIP_THIS
131 
132 #ifdef ALLOCATE_PROGRAMME_TAGS
133  #define PROGRAMME_PREFIX DFW_FIELD_TRIAL_SERVICE_API
134  #define PROGRAMME_VAL(x) = x
135  #define PROGRAMME_CONCAT_VAL(x,y) = x y
136 #else
137  #define PROGRAMME_PREFIX extern
138  #define PROGRAMME_VAL(x)
139  #define PROGRAMME_CONCAT_VAL(x,y)
140 #endif
141 
142 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
143 
144 
145 
146 PROGRAMME_PREFIX const char *PR_NAME_S PROGRAMME_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "name");
147 
148 PROGRAMME_PREFIX const char *PR_OBJECTIVE_S PROGRAMME_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "description");
149 
150 PROGRAMME_PREFIX const char *PR_ID_S PROGRAMME_VAL ("_id");
151 
152 PROGRAMME_PREFIX const char *PR_TRIALS_S PROGRAMME_VAL ("trials");
153 
154 PROGRAMME_PREFIX const char *PR_DOCUMENTATION_URL_S PROGRAMME_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "url");
155 
156 PROGRAMME_PREFIX const char *PR_PI_S PROGRAMME_VAL ("principal_investigator");
157 
158 PROGRAMME_PREFIX const char *PR_CROP_S PROGRAMME_VAL ("crop");
159 
160 PROGRAMME_PREFIX const char *PR_ABBREVIATION_S PROGRAMME_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "alternateName");
161 
162 PROGRAMME_PREFIX const char *PR_LOGO_S PROGRAMME_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "image");
163 
164 
165 PROGRAMME_PREFIX const char *PR_FD_NAME_S PROGRAMME_VAL ("name");
166 
167 PROGRAMME_PREFIX const char *PR_FUNDERS_S PROGRAMME_VAL("funders");
168 
169 PROGRAMME_PREFIX const char *PR_CODE_S PROGRAMME_VAL("code");
170 
171 
172 PROGRAMME_PREFIX const char *PR_FUNDING_IDENTIFIER_S PROGRAMME_VAL("identifier");
173 PROGRAMME_PREFIX const char *PR_FUNDING_ORG_NAME_S PROGRAMME_VAL("name");
174 PROGRAMME_PREFIX const char *PR_GRANT_FUNDER_S PROGRAMME_VAL("funder");
175 PROGRAMME_PREFIX const char *PR_FUNDING_S PROGRAMME_VAL("funding");
176 
177 #ifdef __cplusplus
178 extern "C"
179 {
180 #endif
181 
182 
183 DFW_FIELD_TRIAL_SERVICE_LOCAL Programme *AllocateProgramme (bson_oid_t *id_p, User *user_p, PermissionsGroup *permissions_group_p, const bool owns_user_flag, const char *abbreviation_s, Crop *crop_p, const char *documentation_url_s, const char *name_s, const char *objective_s, Person *pi_p, const char *logo_url_s, const char *funders_s, const char *project_code_s, const char *timestamp_s);
184 
192 
193 
195 
196 
198 
199 
200 DFW_FIELD_TRIAL_SERVICE_LOCAL void SetProgrammeUser (Programme *programme_p, User *user_p, bool owns_user_flag);
201 
202 
204 
205 
207 
208 
209 DFW_FIELD_TRIAL_SERVICE_LOCAL json_t *GetProgrammeAsJSON (Programme *programme_p, const ViewFormat format, const FieldTrialServiceData *data_p);
210 
211 
212 DFW_FIELD_TRIAL_SERVICE_LOCAL Programme *GetProgrammeFromJSON (const json_t *json_p, const ViewFormat format, const FieldTrialServiceData *data_p);
213 
214 
215 DFW_FIELD_TRIAL_SERVICE_LOCAL bool AddFieldTrialsToProgrammeJSON (Programme *programme_p, json_t *program_json_p, const ViewFormat format, FieldTrialServiceData *data_p);
216 
217 
219 
220 
221 DFW_FIELD_TRIAL_SERVICE_LOCAL Programme *GetProgrammeById (const bson_oid_t *id_p, const ViewFormat format, const FieldTrialServiceData *data_p);
222 
223 
224 DFW_FIELD_TRIAL_SERVICE_LOCAL Programme *GetProgrammeByIdString (const char *program_id_s, const ViewFormat format, const FieldTrialServiceData *data_p);
225 
226 
228 
229 
230 
242 
243 
244 DFW_FIELD_TRIAL_SERVICE_LOCAL LinkedList *GetProgrammesByName (const char * const programme_s, const FieldTrialServiceData *data_p);
245 
246 
247 DFW_FIELD_TRIAL_SERVICE_LOCAL Programme *GetVersionedProgramme (const char *programme_id_s, const char *timestamp_s, const ViewFormat format, const FieldTrialServiceData *data_p);
248 
249 
250 #ifdef __cplusplus
251 }
252 #endif
253 
254 
255 #endif /* SERVICES_FIELD_TRIALS_INCLUDE_PROGRAM_H_ */
256 
257 
258 
259 
GetProgrammeAsJSON
json_t * GetProgrammeAsJSON(Programme *programme_p, const ViewFormat format, const FieldTrialServiceData *data_p)
GetNumberOfProgrammeFieldTrials
uint32 GetNumberOfProgrammeFieldTrials(const Programme *programme_p)
GetProgrammeFromJSON
Programme * GetProgrammeFromJSON(const json_t *json_p, const ViewFormat format, const FieldTrialServiceData *data_p)
Programme::pr_documentation_url_s
char * pr_documentation_url_s
The web address for any documentaion about this Programme.
Definition: programme.h:79
MEM_FLAG
MEM_FLAG
An enum specifying the particular status of a piece of dynamically allocated memory for a particular ...
Definition: memory_allocations.h:38
Crop
Definition: crop.h:34
ServiceJob
A datatype to represent a running task.
Definition: service_job.h:72
Programme::pr_timestamp_s
char * pr_timestamp_s
The time when this Field Trial was saved.
Definition: programme.h:63
Programme::pr_abbreviation_s
char * pr_abbreviation_s
The abbreviation for this Programme.
Definition: programme.h:69
Programme::pr_owns_user_flag
bool pr_owns_user_flag
Definition: programme.h:58
GetProgrammesByName
LinkedList * GetProgrammesByName(const char *const programme_s, const FieldTrialServiceData *data_p)
Programme::pr_trials_p
LinkedList * pr_trials_p
A LinkedList of FieldTrialNodes for all of the FieldTrials in this Programme.
Definition: programme.h:101
Programme::pr_funding_organisation_s
char * pr_funding_organisation_s
The name of the funding organisation.
Definition: programme.h:113
AllocateProgrammeNode
ProgrammeNode * AllocateProgrammeNode(Programme *programme_p)
PROGRAMME_VAL
const PROGRAMME_PREFIX char *PR_ID_S PROGRAMME_VAL("_id")
GetProgrammeByIdString
Programme * GetProgrammeByIdString(const char *program_id_s, const ViewFormat format, const FieldTrialServiceData *data_p)
dfw_field_trial_service_library.h
FreeProgramme
void FreeProgramme(Programme *programme_p)
Free a given Programme.
PROGRAMME_CONCAT_VAL
const PROGRAMME_PREFIX char *PR_NAME_S PROGRAMME_CONCAT_VAL(CONTEXT_PREFIX_SCHEMA_ORG_S, "name")
permission.h
DFW_FIELD_TRIAL_SERVICE_LOCAL
#define DFW_FIELD_TRIAL_SERVICE_LOCAL
Definition: dfw_field_trial_service_library.h:43
CONTEXT_PREFIX_SCHEMA_ORG_S
#define CONTEXT_PREFIX_SCHEMA_ORG_S
Definition: schema_keys.h:103
Programme::pr_project_code_s
char * pr_project_code_s
The programme's pproject or grant code.
Definition: programme.h:118
FieldTrial
A datatype that represents a Field Trial that can contain one or more Studies.
Definition: field_trial.h:50
PermissionsGroup
Definition: permission.h:41
typedefs.h
AllocateProgramme
Programme * AllocateProgramme(bson_oid_t *id_p, User *user_p, PermissionsGroup *permissions_group_p, const bool owns_user_flag, const char *abbreviation_s, Crop *crop_p, const char *documentation_url_s, const char *name_s, const char *objective_s, Person *pi_p, const char *logo_url_s, const char *funders_s, const char *project_code_s, const char *timestamp_s)
field_trial.h
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
Programme::pr_permissions_p
PermissionsGroup * pr_permissions_p
Definition: programme.h:51
RemoveProgrammeFieldTrial
bool RemoveProgrammeFieldTrial(Programme *programme_p, FieldTrial *trial_p)
Remove a FieldTrial from a given Programme.
Programme::pr_crop_p
Crop * pr_crop_p
The Crop that this Programme is researching.
Definition: programme.h:74
OperationStatus
OperationStatus
The current status of an Operation.
Definition: operation.h:96
Programme
Definition: programme.h:46
ProgrammeNode::pn_programme_p
Programme * pn_programme_p
Definition: programme.h:126
Programme::pr_logo_url_s
char * pr_logo_url_s
Web address of on optional logo.
Definition: programme.h:107
GetVersionedProgramme
Programme * GetVersionedProgramme(const char *programme_id_s, const char *timestamp_s, const ViewFormat format, const FieldTrialServiceData *data_p)
Programme::pr_id_p
bson_oid_t * pr_id_p
Definition: programme.h:48
GetProgrammeById
Programme * GetProgrammeById(const bson_oid_t *id_p, const ViewFormat format, const FieldTrialServiceData *data_p)
location.h
Programme::pr_objective_s
char * pr_objective_s
The objective of this Programme.
Definition: programme.h:89
AddFieldTrialsToProgrammeJSON
bool AddFieldTrialsToProgrammeJSON(Programme *programme_p, json_t *program_json_p, const ViewFormat format, FieldTrialServiceData *data_p)
Person
Definition: person.h:51
SaveProgramme
OperationStatus SaveProgramme(Programme *programme_p, ServiceJob *job_p, FieldTrialServiceData *data_p)
User
A datatype to store user credentials.
Definition: user_details.h:40
Programme::pr_pi_p
Person * pr_pi_p
The Person leading the Programme.
Definition: programme.h:94
FreeProgrammeNode
void FreeProgrammeNode(ListItem *node_p)
dfw_field_trial_service_data.h
Programme::pr_user_p
User * pr_user_p
The User that saved this version of the Programme.
Definition: programme.h:56
SetProgrammeUser
void SetProgrammeUser(Programme *programme_p, User *user_p, bool owns_user_flag)
Programme::pr_name_s
char * pr_name_s
The name of this Programme.
Definition: programme.h:84
AddProgrammeFieldTrial
bool AddProgrammeFieldTrial(Programme *programme_p, FieldTrial *trial_p, MEM_FLAG mf)
FieldTrialServiceData
The configuration data used by the DFW Field Trial Service.
Definition: dfw_field_trial_service_data.h:118
ViewFormat
ViewFormat
An indicator of what the output destination is for the JSON data values.
Definition: view_format.h:19
ProgrammeNode::pn_node
ListItem pn_node
Definition: programme.h:125
ProgrammeNode
Definition: programme.h:123
person.h
ListItem
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43
GetUniqueProgrammeBySearchString
Programme * GetUniqueProgrammeBySearchString(const char *programme_s, const ViewFormat format, const FieldTrialServiceData *data_p)