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.
|
Go to the documentation of this file.
28 #ifndef SERVICE_JOB_H_
29 #define SERVICE_JOB_H_
48 #ifndef DOXYGEN_SHOULD_SKIP_THIS
50 #ifdef ALLOCATE_SERVICE_JOB_TAGS
51 #define SERVICE_JOB_PREFIX GRASSROOTS_SERVICE_API
52 #define SERVICE_JOB_VAL(x) = x
54 #define SERVICE_JOB_PREFIX extern GRASSROOTS_SERVICE_API
55 #define SERVICE_JOB_VAL(x)
OperationStatus GetCachedServiceJobStatus(const ServiceJob *job_p)
Get the last retrieved OperationStatus of a ServiceJob.
ServiceJob * sjn_job_p
The ServiceJob.
Definition: service_job.h:175
A datatype used to store a ServiceJob within a ServceJobSet using a LinkedList.
Definition: service_job.h:169
void FreeServiceJobNode(ListItem *service_job_node_p)
Free a ServiceJobNode.
json_t * GetServiceJobSetAsJSON(const ServiceJobSet *jobs_p, bool omit_results_flag)
Get the json representation of a ServiceJobSet.
bool CalculateServiceJobResult(ServiceJob *job_p)
Calculate the results for the given ServiceJob.
char * sj_name_s
The name of the ServiceJob.
Definition: service_job.h:87
bool AddCompoundErrorToServiceJob(ServiceJob *job_p, const char *param_s, const ParameterType param_type, json_t *error_details_p)
Add a key-value pair error statement to a ServiceJob.
ParameterType
The different types that a Parameter can take.
Definition: parameter_type.h:35
void ClearServiceJob(ServiceJob *job_p)
Clear a Service Job ready for reuse.
A datatype to represent a running task.
Definition: service_job.h:72
#define GRASSROOTS_SERVICE_API
Definition: grassroots_service_library.h:49
char * sj_description_s
The description of the ServiceJob.
Definition: service_job.h:90
char * sj_url_s
Any user-facing URL for showing results of running this ServiceJob.
Definition: service_job.h:93
bool SetServiceJobURL(ServiceJob *job_p, const char *const url_s)
Set the description of ServiceJob.
void SetServiceJobFreeFunction(ServiceJob *job_p, void(*free_fn)(ServiceJob *job_p))
Set the function that a ServiceJob will use to free itself.
bool AddGeneralErrorMessageToServiceJob(ServiceJob *job_p, const char *const value_s)
Add a key-value pair error statement to a ServiceJob.
bool CloseServiceJob(ServiceJob *job_p)
Close a ServiceJob.
void SetServiceJobUUID(ServiceJob *job_p, const uuid_t new_job_id)
Replace the uuid for a given ServiceJob.
uuid_t sj_id
The unique identifier for this job.
Definition: service_job.h:78
bool AddResultToServiceJob(ServiceJob *job_p, json_t *result_p)
Add a result to ServiceJob.
void ClearServiceJobResults(ServiceJob *job_p, bool free_memory_flag)
Clear the results associated with a ServiceJob.
struct Service * sj_service_p
The Service that is running this job.
Definition: service_job.h:75
void FreeBaseServiceJob(ServiceJob *job_p)
Free a ServiceJob ignoring if it is a subclass.
#define GRASSROOTS_SERVICE_LOCAL
Definition: grassroots_service_library.h:50
bool RemoveServiceJobFromServiceJobSet(ServiceJobSet *job_set_p, ServiceJob *job_p)
Remove a ServiceJob from a ServiceJobSet.
struct Service * sjs_service_p
The Service that is running these jobs.
Definition: service_job.h:188
void SetServiceJobStatus(ServiceJob *job_p, OperationStatus status)
Set the current OperationStatus for a given ServiceJob.
void MergeServiceJobStatus(ServiceJob *job_p, OperationStatus status)
For a given ServiceJob that is running multiple tasks, update its status to reflect the given status ...
bool sj_is_updating_flag
Is this ServiceJob in the process of updating itself?
Definition: service_job.h:149
bool AddLinkedServiceToServiceJob(ServiceJob *job_p, struct LinkedService *linked_service_p)
Add a LinkedService to ServiceJob.
A datatype which defines an available service, its capabilities and its parameters.
Definition: service.h:153
struct Service * GetServiceFromServiceJob(ServiceJob *job_p)
Get the owning Service for a given ServiceJob.
void FreeServiceJob(ServiceJob *job_p)
Free a ServiceJob.
uint32 GetNumberOfServiceJobResults(const ServiceJob *job_p)
Get the number of results stored on a ServiceJob.
bool SetServiceJobName(ServiceJob *job_p, const char *const name_s)
Set the name of ServiceJob.
bool InitServiceJobFromResultsJSON(ServiceJob *job_p, const json_t *results_p, struct Service *service_p, const char *name_s, const char *description_s, OperationStatus status, const char *job_type_s)
Fill in the data for a ServiceJob from a given JSON fragement.
bool CopyServiceJob(const ServiceJob *src_p, ServiceJob *dest_p)
Make a deep copy of one ServiceJob to another.
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
bool AddParameterErrorMessageToServiceJob(ServiceJob *job_p, const char *const param_s, const ParameterType param_type, const char *const value_s)
Add a key-value pair error statement to a ServiceJob.
ServiceJobNode * FindServiceJobNodeInServiceJobSet(const ServiceJobSet *job_set_p, const ServiceJob *job_p)
Find the ServiceJobNode for a given ServiceJob within a ServiceJobSet.
This datatype stores the data needed to get the required information from the output of one Service t...
Definition: linked_service.h:50
bool InitServiceJobFromJSON(ServiceJob *job_p, const json_t *json_p, struct Service *service_p, GrassrootsServer *grassroots_p)
Get a ServiceJob from a json_t object.
OperationStatus
The current status of an Operation.
Definition: operation.h:96
json_t * sj_linked_services_p
A JSON array where each object contains the details of running a different Service based upon the res...
Definition: service_job.h:117
LinkedList * sjs_jobs_p
The ServiceJobs that are in use for the Service.
Definition: service_job.h:191
ListItem sjn_node
The node used to hold this in a LinkedList.
Definition: service_job.h:172
bool AddTabularParameterErrorMessageToServiceJob(ServiceJob *job_p, const char *const param_s, const ParameterType param_type, const char *const value_s, const uint32 row, const char *column_s)
Definition: grassroots_server.h:45
A datatype to represent a collection of ServiceJobs.
Definition: service_job.h:185
ServiceJobNode * FindServiceJobNodeByUUIDInServiceJobSet(const ServiceJobSet *job_set_p, const uuid_t job_id)
Find the ServiceJobNode for a ServiceJob with a given uuid within a ServiceJobSet.
ServiceJob * GetServiceJobFromServiceJobSetById(const ServiceJobSet *jobs_p, const uuid_t job_id)
Search a ServiceJobSet for ServiceJob.
ServiceJobSet * AllocateSimpleServiceJobSet(struct Service *service_p, const char *job_name_s, const char *job_description_s)
Allocate a ServiceJobSet and populate it with a single ServiceJob.
ServiceJob * CreateServiceJobFromResultsJSON(const json_t *results_p, struct Service *service_p, const char *name_s, const char *description_s, OperationStatus status, const char *job_type_s)
Create a ServiceJob from a JSON Resource fragment.
void ProcessLinkedServices(ServiceJob *job_p)
Attempt to extract the relevant data for all LinkedServices that the ServiceJob's Service has and sto...
bool IsServiceJobInServiceJobSet(const ServiceJobSet *job_set_p, const ServiceJob *job_p)
OperationStatus GetServiceJobStatus(ServiceJob *job_p)
Get the Current OperationStatus of a ServiceJob.
bool SetServiceJobDescription(ServiceJob *job_p, const char *const description_s)
Set the description of ServiceJob.
ServiceJob * CloneServiceJob(const ServiceJob *src_p)
Create a deep copy of a ServiceJob.
json_t * sj_metadata_p
The JSON fragment for any extra information for this ServiceJob.
Definition: service_job.h:103
char * sj_type_s
The type of ServiceJob.
Definition: service_job.h:158
bool UpdateServiceJob(ServiceJob *job_p)
Update, if appropriate, a given ServiceJob.
json_t * sj_result_p
The JSON fragment for the results of this ServiceJob.
Definition: service_job.h:98
json_t * sj_errors_p
The JSON fragment for any errors that have occurred whilst running this ServiceJob.
Definition: service_job.h:109
bool(* sj_calculate_result_fn)(struct ServiceJob *job_p)
The callback function to use when a ServiceJob needs to generate its results This is useful for subcl...
Definition: service_job.h:142
void SetServiceJobUpdateFunction(ServiceJob *job_p, bool(*update_fn)(ServiceJob *job_p))
Set the function that a ServiceJob will use to update itself.
ServiceJob * AllocateServiceJob(struct Service *service_p, const char *job_name_s, const char *job_description_s, bool(*update_fn)(struct ServiceJob *job_p), bool(*calculate_results_fn)(struct ServiceJob *job_p), void(*free_job_fn)(struct ServiceJob *job_p), const char *job_type_s)
Allocate a ServiceJob.
uint32 GetServiceJobSetSize(const ServiceJobSet *const jobs_p)
Get the number of ServiceJobs in a ServiceJobSet.
ServiceJobNode * AllocateServiceJobNode(ServiceJob *job_p)
Allocate a ServiceJobNode.
ServiceJob * CreateServiceJobFromJSON(const json_t *job_json_p, GrassrootsServer *grassroots_p)
Create a ServiceJob from a json_t object.
void FreeServiceJobSet(ServiceJobSet *job_set_p)
Free a ServiceJobSet.
json_t * GetServiceJobAsJSON(ServiceJob *const job_p, bool omit_results_flag)
Get a ServiceJob as JSON.
ServiceJobSet * AllocateServiceJobSet(struct Service *service_p)
Allocate a ServiceJobSet.
char * SerialiseServiceJobToJSON(ServiceJob *const job_p, bool omit_results_flag)
Save the ServiceJob to a persistent format that allows the ServiceJob to be recreated in a potentiall...
enum OperationStatus sj_status
Is the service currently in an open state?
Definition: service_job.h:81
json_t * GetServiceJobStatusAsJSON(ServiceJob *job_p, bool omit_results_flag)
Get the Current OperationStatus of a ServiceJob as JSON.
void SetServiceJobCalculateResultFunction(ServiceJob *job_p, bool(*calculate_fn)(ServiceJob *job_p))
Set the function that a ServiceJob will use to calculate its results.
void(* sj_free_fn)(struct ServiceJob *job_p)
The callback function to use when freeing this ServiceJob.
Definition: service_job.h:133
ServiceJob * CreateAndAddServiceJobToService(struct Service *service_p, const char *job_name_s, const char *job_description_s, bool(*update_fn)(struct ServiceJob *job_p), bool(*calculate_results_fn)(struct ServiceJob *job_p), void(*free_job_fn)(struct ServiceJob *job_p))
Allocate a ServiceJob and add it to a ServiceJobSet.
bool(* sj_update_fn)(struct ServiceJob *job_p)
The callback function to use when checking the status of this ServiceJob.
Definition: service_job.h:125
const char * GetServiceJobName(const ServiceJob *job_p)
Get the name of ServiceJob.
bool InitServiceJob(ServiceJob *job_p, struct Service *service_p, const char *job_name_s, const char *job_description_s, bool(*update_fn)(struct ServiceJob *job_p), bool(*calculate_results_fn)(struct ServiceJob *job_p), void(*free_job_fn)(struct ServiceJob *job_p), uuid_t *id_p, const char *job_type_s)
Initialise a ServiceJob.
const SERVICE_JOB_PREFIX char * SJ_DEFAULT_TYPE_S
The default type id for ServiceJobs.
Definition: service_job.h:62
ServiceJob * GetServiceJobFromServiceJobSet(const ServiceJobSet *jobs_p, const uint32 index)
Get the ServiceJob at a particular position in a ServiceJobSet.
bool ProcessServiceJobSet(ServiceJobSet *jobs_p, json_t *res_p)
Process all ServiceJobs within a ServiceJobSet.
bool ReplaceServiceJobResults(ServiceJob *job_p, json_t *results_p)
Replace the set of results for a given ServiceJob.
bool RemoveServiceJobByUUIDFromServiceJobSet(ServiceJobSet *job_set_p, uuid_t job_id)
Remove a ServiceJob with a given uuid from a ServiceJobSet.
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43
Definition: windows_uuid.h:43
char * sj_service_name_s
The name of the Service that this ServiceJob is for.
Definition: service_job.h:84