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.
crop.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  * crop.h
18  *
19  * Created on: 12 Apr 2019
20  * Author: billy
21  */
22 
23 #ifndef SERVICES_FIELD_TRIALS_INCLUDE_CROP_H_
24 #define SERVICES_FIELD_TRIALS_INCLUDE_CROP_H_
25 
28 
29 #include "jansson.h"
30 
34 typedef struct Crop
35 {
36  bson_oid_t *cr_id_p;
37 
38  char *cr_name_s;
39 
41 
43 
44  /*
45  * A NULL-terminated array of synonyms for this crop variety.
46  * This can be NULL meaning there are no synonyms.
47  */
49 
50 } Crop;
51 
52 
53 #ifndef DOXYGEN_SHOULD_SKIP_THIS
54 
55 #ifdef ALLOCATE_CROP_TAGS
56  #define CROP_PREFIX DFW_FIELD_TRIAL_SERVICE_LOCAL
57  #define CROP_VAL(x) = x
58  #define CROP_CONCAT_VAL(x,y) = x y
59 #else
60  #define CROP_PREFIX extern
61  #define CROP_VAL(x)
62  #define CROP_CONCAT_VAL(x,y)
63 #endif
64 
65 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
66 
67 
68 CROP_PREFIX const char *CR_NAME_S CROP_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "name");
69 
70 CROP_PREFIX const char *CR_AGROVOC_URL_S CROP_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "url");
71 
72 CROP_PREFIX const char *CR_AGROVOC_PREFERRED_TERM_S CROP_VAL ("preferred_term");
73 
74 CROP_PREFIX const char *CR_SYNONYMS_S CROP_VAL ("synonyms");
75 
76 
77 #ifdef __cplusplus
78 extern "C"
79 {
80 #endif
81 
82 
83 DFW_FIELD_TRIAL_SERVICE_LOCAL Crop *AllocateCrop (bson_oid_t *id_p, const char *name_s, const char *argovoc_preferred_term_s, const char *agrovoc_uri_s, char **synonyms_ss);
84 
85 
87 
88 
89 DFW_FIELD_TRIAL_SERVICE_LOCAL json_t *GetCropAsJSON (Crop *crop_p, const ViewFormat format, const FieldTrialServiceData *data_p);
90 
91 
92 DFW_FIELD_TRIAL_SERVICE_LOCAL Crop *GetCropFromJSON (const json_t *crop_json_p, const FieldTrialServiceData *data_p);
93 
94 
96 
97 
99 
100 
101 DFW_FIELD_TRIAL_SERVICE_LOCAL Crop *GetCropById (const bson_oid_t *id_p, const FieldTrialServiceData *data_p);
102 
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #endif /* SERVICES_FIELD_TRIALS_INCLUDE_CROP_H_ */
GetCropFromJSON
Crop * GetCropFromJSON(const json_t *crop_json_p, const FieldTrialServiceData *data_p)
Crop
Definition: crop.h:34
FreeCrop
void FreeCrop(Crop *crop_p)
Crop::cr_id_p
bson_oid_t * cr_id_p
Definition: crop.h:36
SaveCrop
bool SaveCrop(Crop *crop_p, const FieldTrialServiceData *data_p)
CROP_VAL
const CROP_PREFIX char *CR_AGROVOC_PREFERRED_TERM_S CROP_VAL("preferred_term")
CROP_CONCAT_VAL
const CROP_PREFIX char *CR_NAME_S CROP_CONCAT_VAL(CONTEXT_PREFIX_SCHEMA_ORG_S, "name")
dfw_field_trial_service_library.h
AllocateCrop
Crop * AllocateCrop(bson_oid_t *id_p, const char *name_s, const char *argovoc_preferred_term_s, const char *agrovoc_uri_s, char **synonyms_ss)
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
GetCropByIdString
Crop * GetCropByIdString(const char *id_s, const FieldTrialServiceData *data_p)
GetCropAsJSON
json_t * GetCropAsJSON(Crop *crop_p, const ViewFormat format, const FieldTrialServiceData *data_p)
Crop::cr_name_s
char * cr_name_s
Definition: crop.h:38
dfw_field_trial_service_data.h
Crop::cr_agrovoc_uri_s
char * cr_agrovoc_uri_s
Definition: crop.h:42
GetCropById
Crop * GetCropById(const bson_oid_t *id_p, const FieldTrialServiceData *data_p)
Crop::cr_argovoc_preferred_term_s
char * cr_argovoc_preferred_term_s
Definition: crop.h:40
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
Crop::cr_synonyms_ss
char ** cr_synonyms_ss
Definition: crop.h:48