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.
dfw_field_trial_service_data.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 /*
22  * dfw_field_trial_service_data.h
23  *
24  * Created on: 8 Jul 2018
25  * Author: tyrrells
26  */
27 
28 #ifndef DFW_FIELD_TRIAL_SERVICE_DATA_H_
29 #define DFW_FIELD_TRIAL_SERVICE_DATA_H_
30 
32 #include "jansson.h"
33 
34 #include "service.h"
35 #include "mongodb_tool.h"
36 //#include "sqlite_tool.h"
37 #include "view_format.h"
38 
39 
40 typedef enum
41 {
47 /* DFTD_ROW, */
58 
59 
60 
61 
62 
63 /*
64  Crop Ontology Scale Class types
65 
66 1. Date
67 The date class is for events expressed in a time format, e.g. “yyyymmdd hh:mm:ss –
68 UTC” or “dd-mm-yy”. A good practice recommended by the Breeding API (BrAPI) is to
69 use the Date and timestamp fields coded in the ISO 8601 standard, extended format.
70 Check
71 https://github.com/plantbreeding/API/blob/master/Specification/GeneralInfo/Date_Time
72 _Encoding.md)
73 
74 2. Duration
75 The duration class is for time elapsed between two events expressed in a time format,
76 e.g. “days”, “hours”, “months”.
77 
78 3. Nominal
79 Categorical scale that can take one of a limited number of categories. There is no
80 intrinsic ordering to the categories e.g. r=“red”, g=“green”, p=“purple”.
81 
82 4. Numerical
83 Numerical scales express the trait with real numbers. The numerical scale defines the
84 unit e.g. centimetre, ton per hectare, number of branches.
85 
86 5. Ordinal
87 Ordinal scales are composed of ordered and fixed number of categories e.g. 1=low,
88 2=moderate, 3=high
89 
90 6. Text
91 A free text is used to express the scale value. Also known as Character variable
92 (varchar)
93 e.g. “Preferred when slightly undercooked”.
94 
95 7. Code
96 This scale class is exceptionally used to express complex traits. Code is a nominal
97 scale that combines the expressions of the different traits composing the complex trait.
98 For example, a disease related code might be expressed by a 2-digit code for intensity
99 and 2-character code for severity. The first 2 digits are the proportion of plants affected
100 by a fungus and the 2 characters refer to the severity, e.g. “75HD” means “75% of the
101 plants are infected and plants are highly damaged”. It is recommended to create
102 variables for every component of the code.
103 */
104 
105 typedef struct ScaleClass
106 {
107  const char *sc_name_s;
109 } ScaleClass;
110 
111 
118 typedef struct /*DFW_FIELD_TRIAL_SERVICE_LOCAL*/ FieldTrialServiceData
119 {
122 
123 
129  MongoTool *dftsd_mongo_p;
130 
131 
137  const char *dftsd_database_s;
138 
144  const char *dftsd_collection_ss [DFTD_NUM_TYPES];
145 
152  const char *dftsd_backup_collection_ss [DFTD_NUM_TYPES];
153 
154 
160  const char *dftsd_facet_key_s;
161 
162 
168  const char *dftsd_study_cache_path_s;
169 
170 
177  const char *dftsd_wastebasket_path_s;
178 
179 
185  const char *dftsd_plots_uploads_path_s;
186 
193  const char *dftsd_assets_path_s;
194 
201  const char *dftsd_fd_url_s;
202 
203 
210  const char *dftsd_view_study_url_s;
211 
212 
219  const char *dftsd_view_trial_url_s;
220 
227  const char *dftsd_view_location_url_s;
228 
229 
236  const char *dftsd_view_programme_url_s;
237 
238 
245  const char *dftsd_view_plots_url_s;
246 
247 
248 
249 
255  const char *dftsd_latex_commmand_s;
256 
257 
259 
260 
262 
263 
270  const char *dftsd_geoapify_key_s;
271 
273 
274 
276 
277 
284  const char *dftsd_phenotype_images_path_s;
285 
287 
288 
289 
290 #ifndef DOXYGEN_SHOULD_SKIP_THIS
291 
292 #ifdef ALLOCATE_DFW_FIELD_TRIAL_SERVICE_TAGS
293  #define DFW_FIELD_TRIAL_PREFIX DFW_FIELD_TRIAL_SERVICE_API
294  #define DFW_FIELD_TRIAL_VAL(x) = x
295  #define DFW_FIELD_TRIAL_STRUCT_VAL(x,y) = { x, y }
296  #define DFW_FIELD_TRIAL_CONCAT_VAL(x,y) = x y
297 #else
298  #define DFW_FIELD_TRIAL_PREFIX extern
299  #define DFW_FIELD_TRIAL_VAL(x)
300  #define DFW_FIELD_TRIAL_STRUCT_VAL(x,y)
301  #define DFW_FIELD_TRIAL_CONCAT_VAL(x,y) = x y
302 
303 #endif
304 
305 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
306 
307 
308 
314 DFW_FIELD_TRIAL_PREFIX const char *DFT_PROGRAM_S DFW_FIELD_TRIAL_VAL ("Programs");
315 
316 DFW_FIELD_TRIAL_PREFIX const char *DFT_PROGRAM_BACKUP_S DFW_FIELD_TRIAL_VAL ("Programs_versions");
317 
318 
324 DFW_FIELD_TRIAL_PREFIX const char *DFT_FIELD_TRIALS_S DFW_FIELD_TRIAL_VAL ("FieldTrials");
325 
326 DFW_FIELD_TRIAL_PREFIX const char *DFT_FIELD_TRIALS_BACKUP_S DFW_FIELD_TRIAL_VAL ("FieldTrials_versions");
327 
333 DFW_FIELD_TRIAL_PREFIX const char *DFT_STUDIES_S DFW_FIELD_TRIAL_VAL ("Studies");
334 
335 DFW_FIELD_TRIAL_PREFIX const char *DFT_STUDIES_BACKUP_S DFW_FIELD_TRIAL_VAL ("Studies_versions");
336 
342 DFW_FIELD_TRIAL_PREFIX const char *DFT_LOCATION_S DFW_FIELD_TRIAL_VAL ("Locations");
343 
344 DFW_FIELD_TRIAL_PREFIX const char *DFT_LOCATION_BACKUP_S DFW_FIELD_TRIAL_VAL ("Locations_versions");
345 
351 DFW_FIELD_TRIAL_PREFIX const char *DFT_PLOT_S DFW_FIELD_TRIAL_VAL ("Plots");
352 
353 DFW_FIELD_TRIAL_PREFIX const char *DFT_PLOT_BACKUP_S DFW_FIELD_TRIAL_VAL ("Plots_versions");
354 
360 DFW_FIELD_TRIAL_PREFIX const char *DFT_DRILLING_S DFW_FIELD_TRIAL_VAL ("Drillings");
361 
362 DFW_FIELD_TRIAL_PREFIX const char *DFT_DRILLING_BACKUP_S DFW_FIELD_TRIAL_VAL ("Drillings_versions");
363 
364 
370 DFW_FIELD_TRIAL_PREFIX const char *DFT_MATERIAL_S DFW_FIELD_TRIAL_VAL ("Materials");
371 
372 DFW_FIELD_TRIAL_PREFIX const char *DFT_MATERIAL_BACKUP_S DFW_FIELD_TRIAL_VAL ("Materials_versions");
373 
379 DFW_FIELD_TRIAL_PREFIX const char *DFT_PHENOTYPE_S DFW_FIELD_TRIAL_VAL ("Phenotypes");
380 
381 DFW_FIELD_TRIAL_PREFIX const char *DFT_PHENOTYPE_BACKUP_S DFW_FIELD_TRIAL_VAL ("Phenotypes_versions");
382 
388 DFW_FIELD_TRIAL_PREFIX const char *DFT_OBSERVATION_S DFW_FIELD_TRIAL_VAL ("Observations");
389 
390 DFW_FIELD_TRIAL_PREFIX const char *DFT_OBSERVATION_BACKUP_S DFW_FIELD_TRIAL_VAL ("Observations_versions");
391 
397 DFW_FIELD_TRIAL_PREFIX const char *DFT_INSTRUMENT_S DFW_FIELD_TRIAL_VAL ("Instruments");
398 
399 DFW_FIELD_TRIAL_PREFIX const char *DFT_INSTRUMENT_BACKUP_S DFW_FIELD_TRIAL_VAL ("Instruments_versions");
400 
406 DFW_FIELD_TRIAL_PREFIX const char *DFT_GENE_BANK_S DFW_FIELD_TRIAL_VAL ("GeneBanks");
407 
408 DFW_FIELD_TRIAL_PREFIX const char *DFT_GENE_BANK_BACKUP_S DFW_FIELD_TRIAL_VAL ("GeneBanks_versions");
409 
410 
416 //DFW_FIELD_TRIAL_PREFIX const char *DFT_ROW_S DFW_FIELD_TRIAL_VAL ("Rows");
417 
418 
424 DFW_FIELD_TRIAL_PREFIX const char *DFT_CROP_S DFW_FIELD_TRIAL_VAL ("Crops");
425 
426 DFW_FIELD_TRIAL_PREFIX const char *DFT_CROP_BACKUP_S DFW_FIELD_TRIAL_VAL ("Crops_versions");
427 
433 DFW_FIELD_TRIAL_PREFIX const char *DFT_TREATMENT_S DFW_FIELD_TRIAL_VAL ("Treatments");
434 
435 DFW_FIELD_TRIAL_PREFIX const char *DFT_TREATMENT_BACKUP_S DFW_FIELD_TRIAL_VAL ("Treatments_versions");
436 
437 
444 DFW_FIELD_TRIAL_PREFIX const char *DFT_SELECTED_S DFW_FIELD_TRIAL_VAL ("selected");
445 
446 
447 
448 DFW_FIELD_TRIAL_PREFIX const char DFT_DEFAULT_COLUMN_DELIMITER DFW_FIELD_TRIAL_VAL (',');
449 
450 DFW_FIELD_TRIAL_PREFIX const char *DFT_BACKUPS_ID_KEY_S DFW_FIELD_TRIAL_VAL ("original_id");
451 
452 
454 #define DFT_GROUP_ALIAS_PREFIX_S "field_trial"
455 
456 
457 
458 DFW_FIELD_TRIAL_PREFIX const ScaleClass SCALE_DURATION DFW_FIELD_TRIAL_STRUCT_VAL("Duration", PT_SIGNED_REAL);
459 DFW_FIELD_TRIAL_PREFIX const ScaleClass SCALE_NOMINAL DFW_FIELD_TRIAL_STRUCT_VAL ("Nominal", PT_STRING);
460 DFW_FIELD_TRIAL_PREFIX const ScaleClass SCALE_NUMERICAL DFW_FIELD_TRIAL_STRUCT_VAL ("Numerical", PT_SIGNED_REAL);
461 DFW_FIELD_TRIAL_PREFIX const ScaleClass SCALE_CODE DFW_FIELD_TRIAL_STRUCT_VAL ("Code", PT_STRING);
462 DFW_FIELD_TRIAL_PREFIX const ScaleClass SCALE_ORDINAL DFW_FIELD_TRIAL_STRUCT_VAL ("Ordinal", PT_UNSIGNED_INT);
463 DFW_FIELD_TRIAL_PREFIX const ScaleClass SCALE_TEXT DFW_FIELD_TRIAL_STRUCT_VAL ("Text", PT_STRING);
464 DFW_FIELD_TRIAL_PREFIX const ScaleClass SCALE_DATE DFW_FIELD_TRIAL_STRUCT_VAL ("Date", PT_TIME);
465 
466 
467 /*
468  * forward declarations
469  */
470 struct MeasuredVariable;
471 struct Treatment;
472 
473 #ifdef __cplusplus
474 extern "C"
475 {
476 #endif
477 
479 
480 
482 
483 
485 
486 
488 
489 
491 
492 
494 
495 
496 DFW_FIELD_TRIAL_SERVICE_LOCAL const char *GetImageForDatatype (const FieldTrialServiceData *data_p, const char *data_type_s);
497 
498 
500 
501 
503 
504 
506 
507 
509 
510 
512 
513 
515 
516 
518 
519 
521 
522 
524 
525 
527 
528 
530 
531 
533 
534 
535 DFW_FIELD_TRIAL_SERVICE_LOCAL char *GetFullCacheFilename (const char *name_s, const FieldTrialServiceData *data_p);
536 
537 
538 #ifdef __cplusplus
539 }
540 #endif
541 
542 
543 #endif /* DFW_FIELD_TRIAL_SERVICE_DATA_H_ */
DFTD_FIELD_TRIAL
Definition: dfw_field_trial_service_data.h:43
DFW_FIELD_TRIAL_STRUCT_VAL
const DFW_FIELD_TRIAL_PREFIX ScaleClass SCALE_DURATION DFW_FIELD_TRIAL_STRUCT_VAL("Duration", PT_SIGNED_REAL)
GetDatatypeDescriptionAsString
const char * GetDatatypeDescriptionAsString(const FieldTrialDatatype data_type)
ScaleClass::sc_type
ParameterType sc_type
Definition: dfw_field_trial_service_data.h:108
ClearTreatmentsCache
void ClearTreatmentsCache(FieldTrialServiceData *data_p)
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
FieldTrialServiceData::dftsd_measured_variables_cache_p
LinkedList * dftsd_measured_variables_cache_p
Definition: dfw_field_trial_service_data.h:258
DFTD_CROP
Definition: dfw_field_trial_service_data.h:54
DFTD_TREATMENT
Definition: dfw_field_trial_service_data.h:55
ParameterType
ParameterType
The different types that a Parameter can take.
Definition: parameter_type.h:35
service.h
ClearMeasuredVariablesCache
void ClearMeasuredVariablesCache(FieldTrialServiceData *data_p)
FieldTrialDatatype
FieldTrialDatatype
Definition: dfw_field_trial_service_data.h:40
DFTD_PLOT
Definition: dfw_field_trial_service_data.h:46
PT_STRING
A c-style string.
Definition: parameter_type.h:58
GetDatatypeFromString
FieldTrialDatatype GetDatatypeFromString(const char *type_s)
Treatment
A treatment defines an experimental process that can be applied.
Definition: treatment.h:40
DFTD_PROGRAMME
Definition: dfw_field_trial_service_data.h:42
RemoveCachedMeasuredVariableByName
bool RemoveCachedMeasuredVariableByName(FieldTrialServiceData *data_p, const char *name_s)
AddMeasuredVariableToCache
bool AddMeasuredVariableToCache(FieldTrialServiceData *data_p, struct MeasuredVariable *mv_p, MEM_FLAG mf)
FreeFieldTrialServiceData
void FreeFieldTrialServiceData(FieldTrialServiceData *data_p)
FieldTrialServiceData::dftsd_map_tile_width_s
const char * dftsd_map_tile_width_s
Definition: dfw_field_trial_service_data.h:272
DFTD_LOCATION
Definition: dfw_field_trial_service_data.h:45
GetDatatypeAsString
const char * GetDatatypeAsString(const FieldTrialDatatype data_type)
dfw_field_trial_service_library.h
EnableTreatmentsCache
bool EnableTreatmentsCache(FieldTrialServiceData *data_p)
GetImageForDatatype
const char * GetImageForDatatype(const FieldTrialServiceData *data_p, const char *data_type_s)
MongoTool
A MongoTool is a datatype that allows access to the data stored within a MongoDB instance.
Definition: mongodb_tool.h:159
DFW_FIELD_TRIAL_SERVICE_LOCAL
#define DFW_FIELD_TRIAL_SERVICE_LOCAL
Definition: dfw_field_trial_service_library.h:43
MeasuredVariable
Definition: measured_variable.h:39
DFTD_NUM_TYPES
Definition: dfw_field_trial_service_data.h:56
EnableMeasuredVariablesCache
bool EnableMeasuredVariablesCache(FieldTrialServiceData *data_p)
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
DFTD_MATERIAL
Definition: dfw_field_trial_service_data.h:48
GetCachedMeasuredVariableByName
struct MeasuredVariable * GetCachedMeasuredVariableByName(FieldTrialServiceData *data_p, const char *name_s)
FieldTrialServiceData::dftsd_map_tile_height_s
const char * dftsd_map_tile_height_s
Definition: dfw_field_trial_service_data.h:275
PT_SIGNED_REAL
A real number.
Definition: parameter_type.h:52
GrassrootsServer
Definition: grassroots_server.h:45
ConfigureFieldTrialService
bool ConfigureFieldTrialService(FieldTrialServiceData *data_p, GrassrootsServer *grassroots_p)
FieldTrialServiceData::dftsd_base_data
ServiceData dftsd_base_data
The base ServiceData.
Definition: dfw_field_trial_service_data.h:121
DFTD_DRILLING
Definition: dfw_field_trial_service_data.h:49
AddTreatmentToCache
bool AddTreatmentToCache(FieldTrialServiceData *data_p, struct Treatment *treatment_p, MEM_FLAG mf)
AllocateFieldTrialServiceData
FieldTrialServiceData * AllocateFieldTrialServiceData(void)
PT_TIME
A struct tm representing a time and date.
Definition: parameter_type.h:111
DFTD_MEASURED_VARIABLE
Definition: dfw_field_trial_service_data.h:50
DFTD_INSTRUMENT
Definition: dfw_field_trial_service_data.h:52
DFTD_GENE_BANK
Definition: dfw_field_trial_service_data.h:53
ServiceData
A datatype for holding the configuration data for a Service.
Definition: service.h:126
ScaleClass
Definition: dfw_field_trial_service_data.h:105
FieldTrialServiceData::dftsd_treatments_cache_p
LinkedList * dftsd_treatments_cache_p
Definition: dfw_field_trial_service_data.h:261
FieldTrialServiceData
The configuration data used by the DFW Field Trial Service.
Definition: dfw_field_trial_service_data.h:118
HasTreatmentCache
bool HasTreatmentCache(FieldTrialServiceData *data_p)
DFW_FIELD_TRIAL_VAL
const DFW_FIELD_TRIAL_PREFIX char *DFT_PROGRAM_S DFW_FIELD_TRIAL_VAL("Programs")
The key for specifying the object containing the fields data.
ScaleClass::sc_name_s
const char * sc_name_s
Definition: dfw_field_trial_service_data.h:107
GetCachedMeasuredVariableById
struct MeasuredVariable * GetCachedMeasuredVariableById(FieldTrialServiceData *data_p, const char *mv_id_s)
mongodb_tool.h
GetCachedTreatmentByURL
struct Treatment * GetCachedTreatmentByURL(FieldTrialServiceData *data_p, const char *url_s)
DFTD_STUDY
Definition: dfw_field_trial_service_data.h:44
DFTD_OBSERVATION
Definition: dfw_field_trial_service_data.h:51
HasMeasuredVariableCache
bool HasMeasuredVariableCache(FieldTrialServiceData *data_p)
view_format.h
PT_UNSIGNED_INT
A non-negative 32-bit integer.
Definition: parameter_type.h:44
GetFullCacheFilename
char * GetFullCacheFilename(const char *name_s, const FieldTrialServiceData *data_p)