Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_function_adaptor.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * afw_function_execute_* functions for Adaptor
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw_internal.h"
15 
16 
17 
18 static const afw_object_t *
19 impl_create_journal_entry(const afw_value_object_t *journal,
20  const afw_pool_t *p, afw_xctx_t *xctx)
21 {
22  const afw_object_t *journal_entry;
23  const afw_iterator_t *iterator;
24  const afw_value_t *value;
25  const afw_utf8_t *property_name;
26 
27  journal_entry = afw_object_create_managed(p, xctx);
28  if (journal) {
29  for (iterator = NULL;;) {
30  value = afw_object_get_next_property(journal->internal,
31  &iterator, &property_name, xctx);
32  if (!value) break;
33  afw_object_set_property(journal_entry, property_name, value, xctx);
34  }
35  }
36 
37  return journal_entry;
38 }
39 /* Used by retrieve_objects*() */
40 typedef struct impl_retrieve_cb_ctx_s {
41  const afw_pool_t *p;
42  const afw_list_t *list;
43  const afw_value_t *objectCallback;
44  const afw_value_t *userData;
45  const afw_object_options_t *object_options;
46  const afw_value_t *call;
47  const afw_value_t *argv[3];
49 
50 static afw_boolean_t
51 impl_retrieve_cb(const afw_object_t *object, void *context,
52  afw_xctx_t *xctx)
53 {
55  const afw_value_t *abort_value;
56  const afw_pool_t *p;
57  afw_boolean_t abort;
58 
59  abort = false;
60  if (object) {
61  p = (object->p) ? object->p : ctx->p;
63  if (ctx->list) {
64  afw_object_add_reference(object, xctx);
65  afw_list_add_value(ctx->list,
66  afw_value_create_object(object, ctx->p, xctx), xctx);
67  }
68  else {
69  ctx->argv[0] = ctx->objectCallback;
70  ctx->argv[1] = afw_value_create_object(object, p, xctx);
71  ctx->argv[2] = ctx->userData;
72  if (!ctx->call) {
73  ctx->call = afw_value_call_create(NULL,
74  2, &ctx->argv[0], ctx->p, xctx);
75  }
76  abort_value = afw_value_evaluate(ctx->call, p, xctx);
77  if (!afw_value_is_boolean(abort_value)) {
78  AFW_THROW_ERROR_Z(general,
79  "objectCallback did not return boolean", xctx);
80  }
81  abort = ((const afw_value_boolean_t *)abort_value)->internal;
82  }
83  }
84 
85  return abort;
86 }
87 
88 
89 
90 /* Used by retrieve_objects*_to_response() */
92  const afw_pool_t *p;
93  const afw_content_type_t *response_content_type;
94  const afw_object_options_t *object_options;
96 
97 static afw_boolean_t
98 impl_retrieve_to_response_cb(
99  const afw_object_t *object,
100  void *context,
101  afw_xctx_t *xctx)
102 {
105  const afw_pool_t *p;
106  const afw_value_t *object_value;
107  afw_boolean_t abort;
108  const afw_stream_t *response_stream;
109  const afw_object_t *response_object;
110 
111  abort = false;
112 
113  if (object) {
114  p = (object->p) ? object->p : ctx->p;
115  response_object = afw_object_create(p, xctx);
116  afw_object_set_property_as_boolean(response_object,
117  &afw_s_intermediate, true, xctx);
118  afw_object_set_property_as_object(response_object,
119  &afw_s_result, object, xctx);
120  object_value = afw_value_create_object(response_object, p, xctx);
121  response_stream = afw_stream_standard(response_body, xctx);
122  afw_content_type_write_value(ctx->response_content_type,
123  object_value, ctx->object_options,
124  (void *)response_stream, response_stream->write_cb,
125  p, xctx);
126  afw_stream_flush(response_stream, xctx);
127  //afw_object_release(object, xctx);
128  }
129 
130  return abort;
131 }
132 
133 
134 
135 /* Used by retrieve_objects*_to_stream() */
137  const afw_pool_t *p;
138  const afw_stream_t *stream;
139  const afw_content_type_t *response_content_type;
140  const afw_object_options_t *object_options;
142 
143 static afw_boolean_t
144 impl_retrieve_to_stream_cb(const afw_object_t *object, void *context,
145  afw_xctx_t *xctx)
146 {
149  const afw_pool_t *p;
150  const afw_value_t *object_value;
151  afw_boolean_t abort;
152 
153  abort = false;
154  if (object) {
155  p = (object->p) ? object->p : ctx->p;
156  object_value = afw_value_create_object(object, p, xctx);
157  afw_content_type_write_value(ctx->response_content_type,
158  object_value, ctx->object_options,
159  (void *)ctx->stream, ctx->stream->write_cb,
160  p, xctx);
161  afw_stream_flush(ctx->stream, xctx);
162  afw_object_release(object, xctx);
163  }
164 
165  return abort;
166 }
167 
168 
169 
170 /*
171  * Adaptive function: add_object
172  *
173  * afw_function_execute_add_object
174  *
175  * See afw_function_bindings.h for more information.
176  *
177  * Add an adaptive object to an adaptor, specified by the adaptorId, with a
178  * specified objectType. You may supply an optional objectId, if the underlying
179  * adaptorId allows it.
180  *
181  * This function is not pure, so it may return a different result
182  * given exactly the same parameters and has side effects.
183  *
184  * Declaration:
185  *
186  * ```
187  * function add_object(
188  * adaptorId: string,
189  * objectType: string,
190  * object: object,
191  * objectId?: string,
192  * journal?: object,
193  * adaptorTypeSpecific?: object
194  * ): (object _AdaptiveJournalEntry_);
195  * ```
196  *
197  * Parameters:
198  *
199  * adaptorId - (string) Id of adaptor.
200  *
201  * objectType - (string) Id of adaptive object type of object being added.
202  *
203  * object - (object) Object to add.
204  *
205  * objectId - (optional string) Optional preferred objectId of object to add.
206  * The adaptor may ignore this.
207  *
208  * journal - (optional object) The properties of this object will be added to
209  * the associated journal entry. Refer to
210  * /afw/_AdaptiveObjectType_/_AdaptiveJournalEntry_ for property names to
211  * avoid and for ones that have specific semantics.
212  *
213  * adaptorTypeSpecific - (optional object) This is an optional object
214  * parameter with an objectType determined by the adaptorType associated
215  * with the adaptorId parameter. If the adaptorType supports this
216  * parameter, adaptor afw will have an adaptive object type with an id
217  * of:
218  *
219  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_add_object
220  *
221  * where ${adaptorType} is the adaptor type id.
222  *
223  * Returns:
224  *
225  * (object _AdaptiveJournalEntry_) Resulting journal entry. Property
226  * "objectId" is the objectId assigned by the adaptor.
227  */
228 const afw_value_t *
231 {
232  const afw_value_string_t *adaptorId;
233  const afw_value_string_t *objectType;
234  const afw_value_string_t *objectId; /* Can be null. */
235  const afw_value_object_t *object;
236  const afw_value_object_t *journal;
237  const afw_value_object_t *adaptorTypeSpecific;
238  const afw_utf8_t *object_id;
239  const afw_object_t *journal_entry;
240 
244 
245  object_id = NULL;
248  object_id = &objectId->internal;
249  }
250 
251  /* Optional journal. */
252  journal = NULL;
255  }
256 
257  /* Optional adaptorTypeSpecific. */
258  adaptorTypeSpecific = NULL;
261  6, object);
262  }
263 
264  /* Create journal entry including optional properties. */
265  journal_entry = impl_create_journal_entry(journal, x->p, x->xctx);
266 
267  /* Add object. */
268  afw_adaptor_add_object(&adaptorId->internal,
269  &objectType->internal,
270  object_id, object->internal, journal_entry,
271  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal : NULL,
272  x->xctx);
273 
274  /* Return journal entry as response. */
275  return afw_value_create_object(journal_entry, x->p, x->xctx);
276 }
277 
278 
279 
280 /*
281  * Adaptive function: add_object_with_uri
282  *
283  * afw_function_execute_add_object_with_uri
284  *
285  * See afw_function_bindings.h for more information.
286  *
287  * Add an adaptive object with a given URI.
288  *
289  * This function is not pure, so it may return a different result
290  * given exactly the same parameters and has side effects.
291  *
292  * Declaration:
293  *
294  * ```
295  * function add_object_with_uri(
296  * uri: anyURI,
297  * object: object,
298  * journal?: object,
299  * adaptorTypeSpecific?: object
300  * ): (object _AdaptiveJournalEntry_);
301  * ```
302  *
303  * Parameters:
304  *
305  * uri - (anyURI) URI of object to add. If a URI begins with a single slash
306  * ('/'), it is the local object path. In the case of a local path, an
307  * optional preferred objectId of object can be including in URI which
308  * the adaptor may ignore.
309  *
310  * object - (object) Object to add.
311  *
312  * journal - (optional object) The properties of this object will be added to
313  * the associated journal entry. Refer to
314  * /afw/_AdaptiveObjectType_/_AdaptiveJournalEntry_ for property names to
315  * avoid and for ones that have specific semantics.
316  *
317  * adaptorTypeSpecific - (optional object) This is an optional object
318  * parameter with an objectType determined by the adaptorType associated
319  * with the adaptorId parameter. If the adaptorType supports this
320  * parameter, adaptor afw will have an adaptive object type with an id
321  * of:
322  *
323  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_add_object
324  *
325  * Where ${adaptorType} is the adaptor type id.
326  *
327  * Returns:
328  *
329  * (object _AdaptiveJournalEntry_) Resulting journal entry. Property
330  * "objectId" is the objectId assigned by the adaptor.
331  */
332 const afw_value_t *
335 {
336  const afw_value_anyURI_t *uri;
337  const afw_value_object_t *object;
338  const afw_value_object_t *journal;
339  const afw_value_object_t *adaptorTypeSpecific;
340  const afw_object_t *journal_entry;
341  const afw_uri_parsed_t *parsed_uri;
342 
345 
346  /* Optional journal. */
347  journal = NULL;
350  }
351 
352  /* Optional adaptorTypeSpecific. */
353  adaptorTypeSpecific = NULL;
356  4, object);
357  }
358 
359  parsed_uri = afw_uri_parse(&uri->internal, true, NULL, x->p, x->xctx);
360  if (!parsed_uri) {
361  AFW_THROW_ERROR_Z(general, "Parameter uri is not valid", x->xctx);
362  }
363 
364  if (!parsed_uri->path_parsed ||
365  parsed_uri->path_parsed->first_property_name)
366  {
367  AFW_THROW_ERROR_Z(general,
368  "Only local entity object paths are currently supported", x->xctx);
369  }
370 
371  /* Create journal entry including optional properties. */
372  journal_entry = impl_create_journal_entry(journal, x->p, x->xctx);
373 
374  /* Add object. */
376  &parsed_uri->path_parsed->adaptor_id,
377  &parsed_uri->path_parsed->object_type_id,
378  &parsed_uri->path_parsed->entity_object_id,
379  object->internal, journal_entry,
380  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
381  x->xctx);
382 
383  /* Return journal entry as response. */
384  return afw_value_create_object(journal_entry, x->p, x->xctx);
385 }
386 
387 
388 
389 /*
390  * Adaptive function: convert_AdaptiveQueryCriteria_to_query_string
391  *
392  * afw_function_execute_convert_AdaptiveQueryCriteria_to_query_string
393  *
394  * See afw_function_bindings.h for more information.
395  *
396  * This function converts an _AdaptiveQueryCriteria_ object to a query string.
397  *
398  * This function is not pure, so it may return a different result
399  * given exactly the same parameters.
400  *
401  * Declaration:
402  *
403  * ```
404  * function convert_AdaptiveQueryCriteria_to_query_string(
405  * queryCriteria: (object _AdaptiveQueryCriteria_),
406  * adaptorId?: string,
407  * objectType?: string,
408  * style?: integer
409  * ): string;
410  * ```
411  *
412  * Parameters:
413  *
414  * queryCriteria - (object _AdaptiveQueryCriteria_) An object type
415  * _AdaptiveQueryCriteria_ object.
416  *
417  * adaptorId - (optional string) This is the adaptorId of adaptor containing
418  * the objectType for validating and mapping this query. If not
419  * specified, no validation or mapping will occur.
420  *
421  * objectType - (optional string) This is the objectType used in conjunction
422  * with the adaptorId parameter. This parameter is only allowed and is
423  * required if the adaptorId parameter is specified.
424  *
425  * style - (optional integer) The style of the query string produced. All of
426  * the styles are appropriately url encoded.
427  *
428  * 0 - "name=op=value" where "=op=" will be "==", "!=", "=ge=", etc. with
429  * conjunctions "&" (and) and "|" (or). Parentheses are placed around
430  * each group of like conjunctions except for outer "&". (default)
431  *
432  * 1 - the same as 1 with "=gte=" instead of "=ge=", "=lte=" instead of
433  * "=le=", "=eq=" instead of "=", and "=ne=" instead of '!='.
434  *
435  * 2 - similar to 1 with ';' for '&' and ',' for '|'.
436  *
437  * 3 - comparisons "op(name,value)" where "op" will be "eq", "ne", "ge",
438  * ..., plus conjunctions "and(list)" and "or(list)" where "list" is a
439  * comma separated list of any comparison or conjunction.
440  *
441  * Returns:
442  *
443  * (string) Query string representation of the query criteria.
444  */
445 const afw_value_t *
448 {
449  const afw_value_object_t *queryCriteria;
450  const afw_value_string_t *adaptorId_value;
451  const afw_value_string_t *objectType_value;
452  const afw_value_integer_t *style_value;
454  const afw_query_criteria_t *criteria;
455  const afw_utf8_t *s;
456  const afw_object_type_t *object_type;
457  const afw_object_t *journal_entry;
458 
459  AFW_FUNCTION_EVALUATE_REQUIRED_DATA_TYPE_PARAMETER(queryCriteria, 1, object);
460 
461  /* Get object type, if adaptorId and objectType is specified. */
462  object_type = NULL;
465  adaptorId_value, 2, string);
467  objectType_value, 3, string);
468  journal_entry = afw_object_create_managed(x->p, x->xctx);
469  object_type = afw_adaptor_get_object_type(
470  &adaptorId_value->internal,
471  &objectType_value->internal,
472  journal_entry, x->xctx);
473  if (!object_type) {
474  AFW_THROW_ERROR_FZ(general, x->xctx,
475  "adaptorId %" AFW_UTF8_FMT
476  " objectType %" AFW_UTF8_FMT
477  " is not found or invalid",
478  AFW_UTF8_FMT_ARG(&adaptorId_value->internal),
479  AFW_UTF8_FMT_ARG(&objectType_value->internal));
480  }
481  }
482  else if (AFW_FUNCTION_PARAMETER_IS_PRESENT(3)) {
483  AFW_THROW_ERROR_Z(general,
484  "objectType parameter is required if adaptorId is specified",
485  x->xctx);
486  }
487 
488  style = afw_query_criteria_style_operator;
491  style_value, 4, integer);
492  if (style_value->internal < 0 ||
493  style_value->internal > afw_query_criteria_style_max)
494  {
495  AFW_THROW_ERROR_Z(general, "invalid value for style parameter",
496  x->xctx);
497  }
498  style = (afw_query_criteria_style_t)style_value->internal;
499  }
500 
502  queryCriteria->internal, object_type, x->p, x->xctx);
503  s = afw_query_criteria_to_query_string(criteria, style, x->p, x->xctx);
504 
505  return afw_value_create_string(s, x->p, x->xctx);
506 }
507 
508 
509 
510 /*
511  * Adaptive function: convert_query_string_to_AdaptiveQueryCriteria
512  *
513  * afw_function_execute_convert_query_string_to_AdaptiveQueryCriteria
514  *
515  * See afw_function_bindings.h for more information.
516  *
517  * This function converts a query string to an _AdaptiveQueryCriteria_ object.
518  *
519  * This function is not pure, so it may return a different result
520  * given exactly the same parameters.
521  *
522  * Declaration:
523  *
524  * ```
525  * function convert_query_string_to_AdaptiveQueryCriteria(
526  * queryString: string,
527  * adaptorId?: string,
528  * objectType?: string
529  * ): (object _AdaptiveQueryCriteria_);
530  * ```
531  *
532  * Parameters:
533  *
534  * queryString - (string) The query string to convert.
535  *
536  * adaptorId - (optional string) This is the adaptorId of adaptor containing
537  * the objectType for validating and mapping this query. If not
538  * specified, no validation or mapping will occur.
539  *
540  * objectType - (optional string) This is the objectType used in conjunction
541  * with the adaptorId parameter. This parameter is only allowed and is
542  * required if the adaptorId parameter is specified.
543  *
544  * Returns:
545  *
546  * (object _AdaptiveQueryCriteria_) An object type _AdaptiveQueryCriteria_
547  * object representing query string.
548  */
549 const afw_value_t *
552 {
553  const afw_value_string_t *queryString;
554  const afw_value_string_t *adaptorId_value;
555  const afw_value_string_t *objectType_value;
556  const afw_query_criteria_t *criteria;
557  const afw_object_t *object;
558  const afw_object_type_t *object_type;
559  const afw_object_t *journal_entry;
560 
562 
563  /* Get object type, if adaptorId and objectType is specified. */
564  object_type = NULL;
567  adaptorId_value, 2, string);
569  objectType_value, 3, string);
570  journal_entry = afw_object_create_managed(x->p, x->xctx);
571  object_type = afw_adaptor_get_object_type(
572  &adaptorId_value->internal,
573  &objectType_value->internal,
574  journal_entry, x->xctx);
575  if (!object_type) {
576  AFW_THROW_ERROR_FZ(general, x->xctx,
577  "adaptorId %" AFW_UTF8_FMT
578  " objectType %" AFW_UTF8_FMT
579  " is not found or invalid",
580  AFW_UTF8_FMT_ARG(&adaptorId_value->internal),
581  AFW_UTF8_FMT_ARG(&objectType_value->internal));
582  }
583  }
584  else if (AFW_FUNCTION_PARAMETER_IS_PRESENT(3)) {
585  AFW_THROW_ERROR_Z(general,
586  "objectType parameter is required if adaptorId is specified",
587  x->xctx);
588  }
589 
590  /* Parse and return _AdaptiveQueryCriteria_ object. */
592  &queryString->internal, object_type, x->p, x->xctx);
594  criteria, x->p, x->xctx);
595  return afw_value_create_object(object, x->p, x->xctx);
596 }
597 
598 
599 
600 /*
601  * Adaptive function: delete_object
602  *
603  * afw_function_execute_delete_object
604  *
605  * See afw_function_bindings.h for more information.
606  *
607  * Delete an adaptive object.
608  *
609  * This function is not pure, so it may return a different result
610  * given exactly the same parameters and has side effects.
611  *
612  * Declaration:
613  *
614  * ```
615  * function delete_object(
616  * adaptorId: string,
617  * objectType: string,
618  * objectId: string,
619  * journal?: object,
620  * adaptorTypeSpecific?: object
621  * ): (object _AdaptiveJournalEntry_);
622  * ```
623  *
624  * Parameters:
625  *
626  * adaptorId - (string) Id of adaptor containing object to delete.
627  *
628  * objectType - (string) Id of adaptive object type of object to delete.
629  *
630  * objectId - (string) Id of object to delete.
631  *
632  * journal - (optional object) The properties of this object will be added to
633  * the associated journal entry. Refer to
634  * /afw/_AdaptiveObjectType_/_AdaptiveJournalEntry_ for property names to
635  * avoid and for ones that have specific semantics.
636  *
637  * adaptorTypeSpecific - (optional object) This is an optional object
638  * parameter with an objectType determined by the adaptorType associated
639  * with the adaptorId parameter. If the adaptorType supports this
640  * parameter, adaptor afw will have an adaptive object type with an id
641  * of:
642  *
643  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_delete_object
644  *
645  * where ${adaptorType} is the adaptor type id.
646  *
647  * Returns:
648  *
649  * (object _AdaptiveJournalEntry_) Resulting journal entry.
650  */
651 const afw_value_t *
654 {
655  const afw_value_string_t *adaptorId;
656  const afw_value_string_t *objectType;
657  const afw_value_string_t *objectId;
658  const afw_value_object_t *journal;
659  const afw_value_object_t *adaptorTypeSpecific;
660  const afw_object_t *journal_entry;
661 
665 
666  /* Optional journal. */
667  journal = NULL;
670  }
671 
672  /* Optional adaptorTypeSpecific. */
673  adaptorTypeSpecific = NULL;
676  5, object);
677  }
678 
679  /* Create journal entry including optional properties. */
680  journal_entry = impl_create_journal_entry(journal, x->p, x->xctx);
681 
682  /* Delete object. */
683  afw_adaptor_delete_object(&adaptorId->internal, &objectType->internal,
684  &objectId->internal, journal_entry,
685  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
686  x->xctx);
687 
688  /* Return journal entry as response. */
689  return afw_value_create_object(journal_entry, x->p, x->xctx);
690 }
691 
692 
693 
694 /*
695  * Adaptive function: delete_object_with_uri
696  *
697  * afw_function_execute_delete_object_with_uri
698  *
699  * See afw_function_bindings.h for more information.
700  *
701  * Delete an adaptive object with a given URI.
702  *
703  * This function is not pure, so it may return a different result
704  * given exactly the same parameters and has side effects.
705  *
706  * Declaration:
707  *
708  * ```
709  * function delete_object_with_uri(
710  * uri: anyURI,
711  * journal?: object,
712  * adaptorTypeSpecific?: object
713  * ): (object _AdaptiveJournalEntry_);
714  * ```
715  *
716  * Parameters:
717  *
718  * uri - (anyURI) URI of object to delete. If a URI begins with a single
719  * slash ('/'), it is the local object path.
720  *
721  * journal - (optional object) The properties of this object will be added to
722  * the associated journal entry. Refer to
723  * /afw/_AdaptiveObjectType_/_AdaptiveJournalEntry_ for property names to
724  * avoid and for ones that have specific semantics.
725  *
726  * adaptorTypeSpecific - (optional object) This is an optional object
727  * parameter with an objectType determined by the adaptorType associated
728  * with the adaptorId parameter. If the adaptorType supports this
729  * parameter, adaptor afw will have an adaptive object type with an id
730  * of:
731  *
732  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_delete_object
733  *
734  * where ${adaptorType} is the adaptor type id.
735  *
736  * Returns:
737  *
738  * (object _AdaptiveJournalEntry_) Resulting journal entry.
739  */
740 const afw_value_t *
743 {
744  const afw_value_anyURI_t *uri;
745  const afw_value_object_t *journal;
746  const afw_value_object_t *adaptorTypeSpecific;
747  const afw_object_t *journal_entry;
748  const afw_uri_parsed_t *parsed_uri;
749 
751 
752  /* Optional journal. */
753  journal = NULL;
756  2, object);
757  }
758 
759  /* Optional adaptorTypeSpecific. */
760  adaptorTypeSpecific = NULL;
763  3, object);
764  }
765 
766  parsed_uri = afw_uri_parse(&uri->internal, true, NULL, x->p, x->xctx);
767  if (!parsed_uri) {
768  AFW_THROW_ERROR_Z(general, "Parameter uri is not valid", x->xctx);
769  }
770 
771  if (!parsed_uri->path_parsed ||
772  parsed_uri->path_parsed->first_property_name)
773  {
774  AFW_THROW_ERROR_Z(general,
775  "Only local entity object paths are currently supported", x->xctx);
776  }
777 
778  /* Create journal entry including optional properties. */
779  journal_entry = impl_create_journal_entry(journal, x->p, x->xctx);
780 
781  /* Delete object. */
783  &parsed_uri->path_parsed->adaptor_id,
784  &parsed_uri->path_parsed->object_type_id,
785  &parsed_uri->path_parsed->entity_object_id,
786  journal_entry,
787  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
788  x->xctx);
789 
790  /* Return journal entry as response. */
791  return afw_value_create_object(journal_entry, x->p, x->xctx);
792 }
793 
794 
795 
796 /*
797  * Adaptive function: get_object
798  *
799  * afw_function_execute_get_object
800  *
801  * See afw_function_bindings.h for more information.
802  *
803  * Get an adaptive object from the adaptor, specified by adaptorId, objectType
804  * and objectId. Optional view options and adaptor-specific options may be
805  * supplied to influence how the object is returned.
806  *
807  * This function is not pure, so it may return a different result
808  * given exactly the same parameters.
809  *
810  * Declaration:
811  *
812  * ```
813  * function get_object(
814  * adaptorId: string,
815  * objectType: string,
816  * objectId: string,
817  * options?: (object _AdaptiveObjectOptions_),
818  * adaptorTypeSpecific?: object
819  * ): object;
820  * ```
821  *
822  * Parameters:
823  *
824  * adaptorId - (string) Id of adaptor containing object to retrieve.
825  *
826  * objectType - (string) Id of adaptive object type of object to retrieve.
827  *
828  * objectId - (string) Id of object to retrieve.
829  *
830  * options - (optional object _AdaptiveObjectOptions_) Object view options.
831  * See /afw/_AdaptiveObjectType_/_AdaptiveObjectOptions_ for more
832  * information.
833  *
834  * adaptorTypeSpecific - (optional object) This is an optional object
835  * parameter with an objectType determined by the adaptorType associated
836  * with the adaptorId parameter. If the adaptorType supports this
837  * parameter, adaptor afw will have an adaptive object type with an id
838  * of:
839  *
840  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_get_object
841  *
842  * Where ${adaptorType} is the adaptor type id.
843  *
844  * Returns:
845  *
846  * (object) Object retrieved or NULL if not found.
847  */
848 const afw_value_t *
851 {
852  const afw_value_string_t *adaptorId;
853  const afw_value_string_t *objectType;
854  const afw_value_string_t *objectId;
855  const afw_value_object_t *options;
856  const afw_value_object_t *adaptorTypeSpecific;
857  const afw_object_options_t *object_options;
858  const afw_object_t *obj;
859  const afw_object_t *journal_entry;
860 
862  1, string);
864  2, string);
866  3, string);
868  4, object);
869  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
870  5, object);
871 
872  object_options = &afw_object_options_none;
873  if (options) {
874  object_options = afw_object_options_set_from_object(NULL,
875  options->internal, x->p, x->xctx);
876  }
877 
878  journal_entry = afw_object_create_managed(x->p, x->xctx);
880  &adaptorId->internal, &objectType->internal, &objectId->internal,
881  object_options, NULL, journal_entry,
882  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
883  x->p, x->xctx);
884 
885  if (!obj) {
886  AFW_THROW_ERROR_Z(not_found, "Not found", x->xctx);
887  }
888 
889  return afw_value_create_object(obj, x->p, x->xctx);
890 }
891 
892 
893 
894 /*
895  * Adaptive function: get_object_with_uri
896  *
897  * afw_function_execute_get_object_with_uri
898  *
899  * See afw_function_bindings.h for more information.
900  *
901  * Get an object with a given URI.
902  *
903  * This function is not pure, so it may return a different result
904  * given exactly the same parameters.
905  *
906  * Declaration:
907  *
908  * ```
909  * function get_object_with_uri(
910  * uri: anyURI,
911  * options?: (object _AdaptiveObjectOptions_),
912  * adaptorTypeSpecific?: object
913  * ): object;
914  * ```
915  *
916  * Parameters:
917  *
918  * uri - (anyURI) URI of object to retrieve. If a URI begins with a single
919  * slash ('/'), it is the local object path.
920  *
921  * options - (optional object _AdaptiveObjectOptions_) Object view options.
922  * See /afw/_AdaptiveObjectType_/_AdaptiveObjectOptions_ for more
923  * information.
924  *
925  * adaptorTypeSpecific - (optional object) This is an optional object
926  * parameter with an objectType determined by the adaptorType associated
927  * with the adaptorId parameter. If the adaptorType supports this
928  * parameter, adaptor afw will have an adaptive object type with an id
929  * of:
930  *
931  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_get_object
932  *
933  * where ${adaptorType} is the adaptor type id.
934  *
935  * Returns:
936  *
937  * (object) Object retrieved or NULL if not found.
938  */
939 const afw_value_t *
942 {
943  const afw_value_anyURI_t *uri;
944  const afw_value_object_t *options;
945  const afw_value_object_t *adaptorTypeSpecific;
946  const afw_object_t *obj;
947  const afw_object_t *journal_entry;
948  const afw_object_options_t *object_options;
949  const afw_uri_parsed_t *parsed_uri;
950 
952  1, anyURI);
954  2, object);
955  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
956  3, object);
957 
958  object_options = &afw_object_options_none;
959  if (options) {
960  object_options = afw_object_options_set_from_object(NULL,
961  options->internal, x->p, x->xctx);
962  }
963 
964  parsed_uri = afw_uri_parse(&uri->internal, true, NULL, x->p, x->xctx);
965  if (!parsed_uri) {
966  AFW_THROW_ERROR_Z(general, "Parameter uri is not valid", x->xctx);
967  }
968 
969  if (!parsed_uri->path_parsed ||
970  parsed_uri->path_parsed->first_property_name)
971  {
972  AFW_THROW_ERROR_Z(general,
973  "Only local entity object paths are currently supported", x->xctx);
974  }
975 
976  journal_entry = afw_object_create_managed(x->p, x->xctx);
978  &parsed_uri->path_parsed->adaptor_id,
979  &parsed_uri->path_parsed->object_type_id,
980  &parsed_uri->path_parsed->entity_object_id,
981  object_options, NULL, journal_entry,
982  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
983  x->p, x->xctx);
984 
985  if (!obj) {
986  AFW_THROW_ERROR_Z(not_found, "Not found", x->xctx);
987  }
988 
989  return afw_value_create_object(obj, x->p, x->xctx);
990 }
991 
992 
993 
994 /*
995  * Adaptive function: modify_object
996  *
997  * afw_function_execute_modify_object
998  *
999  * See afw_function_bindings.h for more information.
1000  *
1001  * Modify an adaptive object.
1002  *
1003  * This function is not pure, so it may return a different result
1004  * given exactly the same parameters and has side effects.
1005  *
1006  * Declaration:
1007  *
1008  * ```
1009  * function modify_object(
1010  * adaptorId: string,
1011  * objectType: string,
1012  * objectId: string,
1013  * entries: list,
1014  * journal?: object,
1015  * adaptorTypeSpecific?: object
1016  * ): (object _AdaptiveJournalEntry_);
1017  * ```
1018  *
1019  * Parameters:
1020  *
1021  * adaptorId - (string) Id of adaptor containing object to modify.
1022  *
1023  * objectType - (string) Id of adaptive object type of object to modify.
1024  *
1025  * objectId - (string) Id of object to modify.
1026  *
1027  * entries - (list) List of modifications. Entries are of the form:
1028  *
1029  * [
1030  * "add_value",
1031  * "property name" or ["property name", ... ],
1032  * value
1033  * ]
1034  *
1035  * [
1036  * "remove_property",
1037  * "property name" or ["property name", ... ]
1038  * ]
1039  *
1040  * [
1041  * "remove_value",
1042  * "property name" or ["property name", ... ],
1043  * value
1044  * ]
1045  *
1046  * [
1047  * "set_property",
1048  * "property name" or ["property name", ... ],
1049  * value
1050  * ].
1051  *
1052  * journal - (optional object) The properties of this object will be added to
1053  * the associated journal entry. Refer to
1054  * /afw/_AdaptiveObjectType_/_AdaptiveJournalEntry_ for property names to
1055  * avoid and for ones that have specific semantics.
1056  *
1057  * adaptorTypeSpecific - (optional object) This is an optional object
1058  * parameter with an objectType determined by the adaptorType associated
1059  * with the adaptorId parameter. If the adaptorType supports this
1060  * parameter, adaptor afw will have an adaptive object type with an id
1061  * of:
1062  *
1063  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_modify_object
1064  *
1065  * Where ${adaptorType} is the adaptor type id.
1066  *
1067  * Returns:
1068  *
1069  * (object _AdaptiveJournalEntry_) Resulting journal entry.
1070  */
1071 const afw_value_t *
1074 {
1075  const afw_value_string_t *adaptorId;
1076  const afw_value_string_t *objectType;
1077  const afw_value_string_t *objectId;
1078  const afw_value_list_t *entries;
1079  const afw_value_object_t *journal;
1080  const afw_value_object_t *adaptorTypeSpecific;
1081  const afw_object_t *journal_entry;
1082 
1084  1, string);
1086  2, string);
1088  3, string);
1090  4, list);
1092  5, object);
1093  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
1094  6, object);
1095 
1096  /* Create journal entry including optional properties. */
1097  journal_entry = impl_create_journal_entry(journal, x->p, x->xctx);
1098 
1099  /* Modify object. */
1100  afw_adaptor_modify_object(&adaptorId->internal, &objectType->internal,
1101  &objectId->internal, entries->internal, journal_entry,
1102  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
1103  x->xctx);
1104 
1105  /* Return journal entry as response. */
1106  return afw_value_create_object(journal_entry, x->p, x->xctx);
1107 }
1108 
1109 
1110 
1111 /*
1112  * Adaptive function: modify_object_with_uri
1113  *
1114  * afw_function_execute_modify_object_with_uri
1115  *
1116  * See afw_function_bindings.h for more information.
1117  *
1118  * Modify an adaptive object with a given URI.
1119  *
1120  * This function is not pure, so it may return a different result
1121  * given exactly the same parameters and has side effects.
1122  *
1123  * Declaration:
1124  *
1125  * ```
1126  * function modify_object_with_uri(
1127  * uri: anyURI,
1128  * entries: list,
1129  * journal?: object,
1130  * adaptorTypeSpecific?: object
1131  * ): (object _AdaptiveJournalEntry_);
1132  * ```
1133  *
1134  * Parameters:
1135  *
1136  * uri - (anyURI) URI of object to modify. If a URI begins with a single
1137  * slash ('/'), it is the local object path.
1138  *
1139  * entries - (list) List of asserts and modifications. Entries are of the
1140  * form:
1141  *
1142  * [
1143  * "add_value",
1144  * "property name" or ["property name", ... ],
1145  * value
1146  * ]
1147  *
1148  * [
1149  * "remove_property",
1150  * "property name" or ["property name", ... ]
1151  * ]
1152  *
1153  * [
1154  * "remove_value",
1155  * "property name" or ["property name", ... ],
1156  * value
1157  * ]
1158  *
1159  * [
1160  * "set_property",
1161  * "property name" or ["property name", ... ],
1162  * value
1163  * ].
1164  *
1165  * journal - (optional object) The properties of this object will be added to
1166  * the associated journal entry. Refer to
1167  * /afw/_AdaptiveObjectType_/_AdaptiveJournalEntry_ for property names to
1168  * avoid and for ones that have specific semantics.
1169  *
1170  * adaptorTypeSpecific - (optional object) This is an optional object
1171  * parameter with an objectType determined by the adaptorType associated
1172  * with the adaptorId parameter. If the adaptorType supports this
1173  * parameter, adaptor afw will have an adaptive object type with an id
1174  * of:
1175  *
1176  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_modify_object
1177  *
1178  * Where ${adaptorType} is the adaptor type id.
1179  *
1180  * Returns:
1181  *
1182  * (object _AdaptiveJournalEntry_) Resulting journal entry.
1183  */
1184 const afw_value_t *
1187 {
1188  const afw_value_anyURI_t *uri;
1189  const afw_value_list_t *entries;
1190  const afw_value_object_t *journal;
1191  const afw_value_object_t *adaptorTypeSpecific;
1192  const afw_object_t *journal_entry;
1193  const afw_uri_parsed_t *parsed_uri;
1194 
1196  1, anyURI);
1198  2, list);
1200  3, object);
1201  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
1202  4, object);
1203 
1204  parsed_uri = afw_uri_parse(&uri->internal, true, NULL, x->p, x->xctx);
1205  if (!parsed_uri) {
1206  AFW_THROW_ERROR_Z(general, "Parameter uri is not valid", x->xctx);
1207  }
1208 
1209  if (!parsed_uri->path_parsed ||
1210  parsed_uri->path_parsed->first_property_name)
1211  {
1212  AFW_THROW_ERROR_Z(general,
1213  "Only local entity object paths are currently supported", x->xctx);
1214  }
1215 
1216  /* Create journal entry including optional properties. */
1217  journal_entry = impl_create_journal_entry(journal, x->p, x->xctx);
1218 
1219  /* Modify object. */
1221  &parsed_uri->path_parsed->adaptor_id,
1222  &parsed_uri->path_parsed->object_type_id,
1223  &parsed_uri->path_parsed->entity_object_id,
1224  entries->internal, journal_entry,
1225  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
1226  x->xctx);
1227 
1228  /* Return journal entry as response. */
1229  return afw_value_create_object(journal_entry, x->p, x->xctx);
1230 }
1231 
1232 
1233 
1234 /*
1235  * Adaptive function: reconcile_object
1236  *
1237  * afw_function_execute_reconcile_object
1238  *
1239  * See afw_function_bindings.h for more information.
1240  *
1241  * Reconcile an adaptive object.
1242  *
1243  * This function is not pure, so it may return a different result
1244  * given exactly the same parameters and has side effects.
1245  *
1246  * Declaration:
1247  *
1248  * ```
1249  * function reconcile_object(
1250  * object: object,
1251  * checkOnly?: boolean
1252  * ): (object _AdaptiveJournalEntry_);
1253  * ```
1254  *
1255  * Parameters:
1256  *
1257  * object - (object) An object that has been retrieved with object options
1258  * reconcilable, and whose properties have been modified. A modify_object
1259  * request will be produced reflecting the difference between the
1260  * original object and this unmodified object.
1261  *
1262  * checkOnly - (optional boolean) Produce the modify_object request but don't
1263  * execute it. The returned journal enter will contain the modify_object
1264  * request.
1265  *
1266  * Returns:
1267  *
1268  * (object _AdaptiveJournalEntry_) Resulting journal entry.
1269  */
1270 const afw_value_t *
1273 {
1274  const afw_value_object_t *object;
1275  const afw_value_boolean_t *checkOnly;
1276  const afw_utf8_t *reconcilable;
1277  const afw_value_t *reconcilable_value;
1278  const afw_object_t *original;
1279  const afw_object_t *journal_entry;
1280  const afw_utf8_t *adaptor_id;
1281  const afw_utf8_t *object_type_id;
1282  const afw_utf8_t *object_id;
1283  const afw_list_t *entries;
1284 
1286  checkOnly = NULL;
1289  2, boolean);
1290  }
1291 
1293  object->internal, &afw_s_reconcilable, x->xctx);
1294  if (!reconcilable) {
1295  AFW_THROW_ERROR_Z(general,
1296  "object is not reconcilable",
1297  x->xctx);
1298  }
1299  reconcilable_value = afw_json_to_value(reconcilable, &afw_s_reconcilable,
1300  x->p, x->xctx);
1301  AFW_VALUE_ASSERT_IS_DATA_TYPE(reconcilable_value, object, x->xctx);
1302  original = ((const afw_value_object_t *)reconcilable_value)->internal;
1303 
1304  /* Create journal entry including optional properties. */
1305  journal_entry = afw_object_create_managed(x->p, x->xctx);
1306 
1307  /* Make modify needed to reconcile. */
1309  &adaptor_id, &object_type_id, &object_id, &entries,
1310  original, object->internal,
1311  journal_entry, x->p, x->xctx);
1312 
1313  /* If checkOnly, just add return journal entry with modify entries. */
1314  if (checkOnly && checkOnly->internal) {
1316  return afw_value_create_list(entries, x->p, x->xctx);
1317  }
1318 
1319 
1320  /* If not checkOnly, call modify object using entries. */
1321  else {
1323  adaptor_id, object_type_id, object_id, entries,
1324  journal_entry, NULL, x->xctx);
1325  }
1326 
1327  /* Return journal entry as response. */
1328  return afw_value_create_object(journal_entry, x->p, x->xctx);
1329 }
1330 
1331 
1332 
1333 /*
1334  * Adaptive function: replace_object
1335  *
1336  * afw_function_execute_replace_object
1337  *
1338  * See afw_function_bindings.h for more information.
1339  *
1340  * Replace an adaptive object.
1341  *
1342  * This function is not pure, so it may return a different result
1343  * given exactly the same parameters and has side effects.
1344  *
1345  * Declaration:
1346  *
1347  * ```
1348  * function replace_object(
1349  * adaptorId: string,
1350  * objectType: string,
1351  * objectId: string,
1352  * object: object,
1353  * journal?: object,
1354  * adaptorTypeSpecific?: object
1355  * ): (object _AdaptiveJournalEntry_);
1356  * ```
1357  *
1358  * Parameters:
1359  *
1360  * adaptorId - (string) Id of adaptor containing object to replace.
1361  *
1362  * objectType - (string) Id of adaptive object type of object to replace.
1363  *
1364  * objectId - (string) Id of object to replace.
1365  *
1366  * object - (object) Replacement object.
1367  *
1368  * journal - (optional object) The properties of this object will be added to
1369  * the associated journal entry. Refer to
1370  * /afw/_AdaptiveObjectType_/_AdaptiveJournalEntry_ for property names to
1371  * avoid and for ones that have specific semantics.
1372  *
1373  * adaptorTypeSpecific - (optional object) This is an optional object
1374  * parameter with an objectType determined by the adaptorType associated
1375  * with the adaptorId parameter. If the adaptorType supports this
1376  * parameter, adaptor afw will have an adaptive object type with an id
1377  * of:
1378  *
1379  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_replace_object
1380  *
1381  * Where ${adaptorType} is the adaptor type id.
1382  *
1383  * Returns:
1384  *
1385  * (object _AdaptiveJournalEntry_) Resulting journal entry.
1386  */
1387 const afw_value_t *
1390 {
1391  const afw_value_string_t *adaptorId;
1392  const afw_value_string_t *objectType;
1393  const afw_value_string_t *objectId;
1394  const afw_value_object_t *object;
1395  const afw_value_object_t *journal;
1396  const afw_value_object_t *adaptorTypeSpecific;
1397  const afw_utf8_t *id;
1398  const afw_object_t *journal_entry;
1399 
1401  1, string);
1403  2, string);
1405  3, string);
1407  4, object);
1409  5, object);
1410  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
1411  6, object);
1412 
1413  id = (objectId && objectId->internal.len > 0)
1414  ? &objectId->internal
1415  : NULL;
1416 
1417  /* Create journal entry including optional properties. */
1418  journal_entry = impl_create_journal_entry(journal, x->p, x->xctx);
1419 
1420  /* Replace object. */
1421  afw_adaptor_replace_object(&adaptorId->internal, &objectType->internal,
1422  id, object->internal, journal_entry,
1423  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
1424  x->xctx);
1425 
1426  /* Return journal entry as response. */
1427  return afw_value_create_object(journal_entry, x->p, x->xctx);
1428 }
1429 
1430 
1431 
1432 /*
1433  * Adaptive function: replace_object_with_uri
1434  *
1435  * afw_function_execute_replace_object_with_uri
1436  *
1437  * See afw_function_bindings.h for more information.
1438  *
1439  * Replace an adaptive object with a given URI.
1440  *
1441  * This function is not pure, so it may return a different result
1442  * given exactly the same parameters and has side effects.
1443  *
1444  * Declaration:
1445  *
1446  * ```
1447  * function replace_object_with_uri(
1448  * uri: anyURI,
1449  * object: object,
1450  * journal?: object,
1451  * adaptorTypeSpecific?: object
1452  * ): (object _AdaptiveJournalEntry_);
1453  * ```
1454  *
1455  * Parameters:
1456  *
1457  * uri - (anyURI) URI of object to replace. If a URI begins with a single
1458  * slash ('/'), it is the local object path.
1459  *
1460  * object - (object) Replacement object.
1461  *
1462  * journal - (optional object) The properties of this object will be added to
1463  * the associated journal entry. Refer to
1464  * /afw/_AdaptiveObjectType_/_AdaptiveJournalEntry_ for property names to
1465  * avoid and for ones that have specific semantics.
1466  *
1467  * adaptorTypeSpecific - (optional object) This is an optional object
1468  * parameter with an objectType determined by the adaptorType associated
1469  * with the adaptorId parameter. If the adaptorType supports this
1470  * parameter, adaptor afw will have an adaptive object type with an id
1471  * of:
1472  *
1473  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_replace_object
1474  *
1475  * Where ${adaptorType} is the adaptor type id.
1476  *
1477  * Returns:
1478  *
1479  * (object _AdaptiveJournalEntry_) Resulting journal entry.
1480  */
1481 const afw_value_t *
1484 {
1485  const afw_value_anyURI_t *uri;
1486  const afw_value_object_t *object;
1487  const afw_value_object_t *journal;
1488  const afw_value_object_t *adaptorTypeSpecific;
1489  const afw_object_t *journal_entry;
1490  const afw_uri_parsed_t *parsed_uri;
1491  const afw_utf8_t *id;
1492 
1494  1, anyURI);
1496  2, object);
1498  3, object);
1499  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
1500  4, object);
1501 
1502  parsed_uri = afw_uri_parse(&uri->internal, true, NULL, x->p, x->xctx);
1503  if (!parsed_uri) {
1504  AFW_THROW_ERROR_Z(general, "Parameter uri is not valid", x->xctx);
1505  }
1506 
1507  if (!parsed_uri->path_parsed ||
1508  parsed_uri->path_parsed->first_property_name)
1509  {
1510  AFW_THROW_ERROR_Z(general,
1511  "Only local entity object paths are currently supported", x->xctx);
1512  }
1513 
1514  id = (parsed_uri->path_parsed->entity_object_id.len > 0)
1515  ? &parsed_uri->path_parsed->entity_object_id
1516  : NULL;
1517 
1518  /* Create journal entry including optional properties. */
1519  journal_entry = impl_create_journal_entry(journal, x->p, x->xctx);
1520 
1521  /* Replace object. */
1523  &parsed_uri->path_parsed->adaptor_id,
1524  &parsed_uri->path_parsed->object_type_id,
1525  id, object->internal,
1526  journal_entry,
1527  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
1528  x->xctx);
1529 
1530  /* Return journal entry as response. */
1531  return afw_value_create_object(journal_entry, x->p, x->xctx);
1532 }
1533 
1534 
1535 
1536 /*
1537  * Adaptive function: retrieve_objects
1538  *
1539  * afw_function_execute_retrieve_objects
1540  *
1541  * See afw_function_bindings.h for more information.
1542  *
1543  * This function retrieves adaptive objects from an adaptor, specified by
1544  * adaptorId, which match the type specified by objectType.
1545  *
1546  * The optional queryCriteria is used to filter the adaptive objects returned.
1547  * Use the objectOptions parameter to influence how the objects are viewed.
1548  *
1549  * Options, specific to the adaptorId, can be optionally supplied.
1550  *
1551  * This function is not pure, so it may return a different result
1552  * given exactly the same parameters.
1553  *
1554  * Declaration:
1555  *
1556  * ```
1557  * function retrieve_objects(
1558  * adaptorId: string,
1559  * objectType: string,
1560  * queryCriteria?: (object _AdaptiveQueryCriteria_),
1561  * options?: (object _AdaptiveObjectOptions_),
1562  * adaptorTypeSpecific?: object
1563  * ): list;
1564  * ```
1565  *
1566  * Parameters:
1567  *
1568  * adaptorId - (string) Id of adaptor containing objects to retrieve.
1569  *
1570  * objectType - (string) Id of adaptive object type of objects to retrieve.
1571  *
1572  * queryCriteria - (optional object _AdaptiveQueryCriteria_) This is the
1573  * query criteria for objects to be retrieved. If not specified, all
1574  * objects will be retrieved.
1575  *
1576  * options - (optional object _AdaptiveObjectOptions_) Object view options.
1577  * See /afw/_AdaptiveObjectType_/_AdaptiveObjectOptions_ for more
1578  * information.
1579  *
1580  * adaptorTypeSpecific - (optional object) This is an optional object
1581  * parameter with an objectType determined by the adaptorType associated
1582  * with the adaptorId parameter. If the adaptorType supports this
1583  * parameter, adaptor afw will have an adaptive object type with an id
1584  * of:
1585  *
1586  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_retrieve_objects
1587  *
1588  * Where ${adaptorType} is the adaptor type id.
1589  *
1590  * Returns:
1591  *
1592  * (list) This is the list of objects retrieved.
1593  */
1594 const afw_value_t *
1597 {
1598  const afw_value_string_t *adaptorId;
1599  const afw_value_string_t *objectType;
1600  const afw_value_object_t *queryCriteria;
1601  const afw_value_object_t *adaptorTypeSpecific;
1602  const afw_value_object_t *options;
1603  const afw_query_criteria_t * criteria;
1604  const afw_object_t *journal_entry;
1606 
1607  criteria = NULL;
1608  afw_memory_clear(&ctx);
1609  ctx.p = x->p;
1610  ctx.list = afw_list_of_create(afw_data_type_object, x->p, x->xctx);
1611  criteria = NULL;
1612 
1614  1, string);
1616  2, string);
1618  3, object);
1620  4, object);
1621  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
1622  5, object);
1623 
1624  journal_entry = afw_object_create_managed(x->p, x->xctx);
1625 
1626  /* Optional query criteria. */
1627  if (queryCriteria) {
1629  queryCriteria->internal,
1630  &adaptorId->internal, &objectType->internal,
1631  journal_entry, x->p, x->xctx);
1632  }
1633 
1634  /* Optional options. */
1635  if (options) {
1636  ctx.object_options = afw_object_options_set_from_object(NULL,
1637  options->internal, x->p, x->xctx);
1638  }
1639 
1640  /* Retrieve objects. */
1642  &adaptorId->internal, &objectType->internal,
1643  ctx.object_options, criteria, journal_entry, (void *)&ctx,
1644  impl_retrieve_cb,
1645  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
1646  x->p, x->xctx);
1647 
1648  return afw_value_create_list(ctx.list, x->p, x->xctx);
1649 }
1650 
1651 
1652 
1653 /*
1654  * Adaptive function: retrieve_objects_to_callback
1655  *
1656  * afw_function_execute_retrieve_objects_to_callback
1657  *
1658  * See afw_function_bindings.h for more information.
1659  *
1660  * This function retrieves adaptive objects from an adaptor, specified by
1661  * adaptorId, which match the type specified by objectType.
1662  *
1663  * Each object is passed to the callback as it's retrieved.
1664  *
1665  * The optional queryCriteria is used to filter the adaptive objects returned.
1666  * Use the objectOptions parameter to influence how the objects are viewed.
1667  *
1668  * Options, specific to the adaptorId, can be optionally supplied.
1669  *
1670  * This function is not pure, so it may return a different result
1671  * given exactly the same parameters.
1672  *
1673  * Declaration:
1674  *
1675  * ```
1676  * function retrieve_objects_to_callback(
1677  * objectCallback: (function (object: object, userData: any): boolean),
1678  * userData: any,
1679  * adaptorId: string,
1680  * objectType: string,
1681  * queryCriteria?: (object _AdaptiveQueryCriteria_),
1682  * options?: (object _AdaptiveObjectOptions_),
1683  * adaptorTypeSpecific?: object
1684  * ): null;
1685  * ```
1686  *
1687  * Parameters:
1688  *
1689  * objectCallback - (function (object: object, userData: any): boolean) If
1690  * this is specified, this function is called once for each object
1691  * retrieved instead of adding the object to the return list. Parameter
1692  * object will be an object retrieved or undefined if there are no more
1693  * objects. This function should return true if it wants to abort the
1694  * retrieve request.
1695  *
1696  * userData - (any dataType) This value is passed to the objectCallback
1697  * function in the userData parameter.
1698  *
1699  * adaptorId - (string) Id of adaptor containing objects to retrieve.
1700  *
1701  * objectType - (string) Id of adaptive object type of objects to retrieve.
1702  *
1703  * queryCriteria - (optional object _AdaptiveQueryCriteria_) This is the
1704  * query criteria for objects to be retrieved. If not specified, all
1705  * objects will be retrieved.
1706  *
1707  * options - (optional object _AdaptiveObjectOptions_) Object view options.
1708  * See /afw/_AdaptiveObjectType_/_AdaptiveObjectOptions_ for more
1709  * information.
1710  *
1711  * adaptorTypeSpecific - (optional object) This is an optional object
1712  * parameter with an objectType determined by the adaptorType associated
1713  * with the adaptorId parameter. If the adaptorType supports this
1714  * parameter, adaptor afw will have an adaptive object type with an id
1715  * of:
1716  *
1717  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_retrieve_objects_to_callbac
1718  * k
1719  *
1720  * Where ${adaptorType} is the adaptor type id.
1721  *
1722  * Returns:
1723  *
1724  * (null)
1725  */
1726 const afw_value_t *
1729 {
1730  const afw_value_string_t *adaptorId;
1731  const afw_value_string_t *objectType;
1732  const afw_value_object_t *queryCriteria;
1733  const afw_value_object_t *adaptorTypeSpecific;
1734  const afw_value_object_t *options;
1735  const afw_query_criteria_t *criteria;
1736  const afw_object_t *journal_entry;
1738 
1739  afw_memory_clear(&ctx);
1740  ctx.p = x->p;
1741  criteria = NULL;
1742 
1743  AFW_FUNCTION_EVALUATE_PARAMETER(ctx.objectCallback,
1744  1);
1745  AFW_FUNCTION_EVALUATE_PARAMETER(ctx.userData,
1746  2);
1748  3, string);
1750  4, string);
1752  5, object);
1754  6, object);
1755  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
1756  7, object);
1757 
1758  journal_entry = afw_object_create_managed(x->p, x->xctx);
1759 
1760  /* Optional query criteria. */
1761  if (queryCriteria) {
1763  queryCriteria->internal,
1764  &adaptorId->internal, &objectType->internal,
1765  journal_entry, x->p, x->xctx);
1766  }
1767 
1768  /* Optional options. */
1769  if (options) {
1770  ctx.object_options = afw_object_options_set_from_object(NULL,
1771  options->internal, x->p, x->xctx);
1772  }
1773 
1774  /* Retrieve objects. */
1776  &adaptorId->internal, &objectType->internal,
1777  ctx.object_options, criteria, journal_entry, (void *)&ctx,
1778  impl_retrieve_cb,
1779  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal : NULL,
1780  x->p, x->xctx);
1781 
1782  /* Return undefined. */
1783  return NULL;
1784 }
1785 
1786 
1787 
1788 /*
1789  * Adaptive function: retrieve_objects_to_response
1790  *
1791  * afw_function_execute_retrieve_objects_to_response
1792  *
1793  * See afw_function_bindings.h for more information.
1794  *
1795  * This function retrieves adaptive objects from an adaptor, specified by
1796  * adaptorId, which match the type specified by objectType.
1797  *
1798  * This function is only allowed when called during a request with content type
1799  * "application/x-afw". An "_AdaptiveResponse_" object is written to the
1800  * request's response as each object is retrieved. This "_AdaptiveResponse_"
1801  * object has a "result" property containing the retrieved object and a
1802  * "intermediate" property set to true.
1803  *
1804  * The optional queryCriteria is used to filter the adaptive objects returned.
1805  * Use the objectOptions parameter to influence how the objects are viewed.
1806  *
1807  * Options, specific to the adaptorId, can be optionally supplied.
1808  *
1809  * This function is not pure, so it may return a different result
1810  * given exactly the same parameters.
1811  *
1812  * Declaration:
1813  *
1814  * ```
1815  * function retrieve_objects_to_response(
1816  * adaptorId: string,
1817  * objectType: string,
1818  * queryCriteria?: (object _AdaptiveQueryCriteria_),
1819  * options?: (object _AdaptiveObjectOptions_),
1820  * adaptorTypeSpecific?: object
1821  * ): null;
1822  * ```
1823  *
1824  * Parameters:
1825  *
1826  * adaptorId - (string) Id of adaptor containing objects to retrieve.
1827  *
1828  * objectType - (string) Id of adaptive object type of objects to retrieve.
1829  *
1830  * queryCriteria - (optional object _AdaptiveQueryCriteria_) This is the
1831  * query criteria for objects to be retrieved. If not specified, all
1832  * objects will be retrieved.
1833  *
1834  * options - (optional object _AdaptiveObjectOptions_) Object view options.
1835  * See /afw/_AdaptiveObjectType_/_AdaptiveObjectOptions_ for more
1836  * information.
1837  *
1838  * adaptorTypeSpecific - (optional object) This is an optional object
1839  * parameter with an objectType determined by the adaptorType associated
1840  * with the adaptorId parameter. If the adaptorType supports this
1841  * parameter, adaptor afw will have an adaptive object type with an id
1842  * of:
1843  *
1844  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_retrieve_objects
1845  *
1846  * Where ${adaptorType} is the adaptor type id.
1847  *
1848  * Returns:
1849  *
1850  * (null)
1851  */
1852 const afw_value_t *
1855 {
1856  const afw_value_string_t *adaptorId;
1857  const afw_value_string_t *objectType;
1858  const afw_value_object_t *queryCriteria;
1859  const afw_value_object_t *adaptorTypeSpecific;
1860  const afw_value_object_t *options;
1861  const afw_query_criteria_t *criteria;
1862  const afw_object_t *journal_entry;
1864 
1865  if (!x->xctx->request ||
1866  !x->xctx->request->response_content_type ||
1868  x->xctx->request->response_content_type))
1869  {
1870  AFW_THROW_ERROR_Z(general,
1871  "retrieve_objects_to_response() "
1872  "is only allowed to be called "
1873  "during a request with response content type "
1874  "\"application/x-afw\".",
1875  x->xctx);
1876  }
1877 
1878  afw_memory_clear(&ctx);
1879  ctx.p = x->p;
1880  ctx.response_content_type = x->xctx->request->response_content_type;
1881  criteria = NULL;
1882 
1886  3, object);
1888  4, object);
1889  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
1890  5, object);
1891 
1892  journal_entry = afw_object_create_managed(x->p, x->xctx);
1893 
1894  /* Optional query criteria. */
1895  if (queryCriteria) {
1897  queryCriteria->internal,
1898  &adaptorId->internal, &objectType->internal,
1899  journal_entry, x->p, x->xctx);
1900  }
1901 
1902  /* Optional options. */
1903  if (options) {
1904  ctx.object_options = afw_object_options_set_from_object(NULL,
1905  options->internal, x->p, x->xctx);
1906  }
1907 
1908  /* Retrieve objects. */
1910  &adaptorId->internal, &objectType->internal,
1911  ctx.object_options, criteria, journal_entry, (void *)&ctx,
1912  impl_retrieve_to_response_cb,
1913  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
1914  x->p, x->xctx);
1915 
1916  return NULL;
1917 }
1918 
1919 
1920 
1921 /*
1922  * Adaptive function: retrieve_objects_to_stream
1923  *
1924  * afw_function_execute_retrieve_objects_to_stream
1925  *
1926  * See afw_function_bindings.h for more information.
1927  *
1928  * This function retrieves adaptive objects from an adaptor, specified by
1929  * adaptorId, which match the type specified by objectType.
1930  *
1931  * Each object is written to the "streamId" stream as it's retrieved.
1932  *
1933  * The optional queryCriteria is used to filter the adaptive objects returned.
1934  * Use the objectOptions parameter to influence how the objects are viewed.
1935  *
1936  * Options, specific to the adaptorId, can be optionally supplied.
1937  *
1938  * This function is not pure, so it may return a different result
1939  * given exactly the same parameters.
1940  *
1941  * Declaration:
1942  *
1943  * ```
1944  * function retrieve_objects_to_stream(
1945  * streamNumber: integer,
1946  * adaptorId: string,
1947  * objectType: string,
1948  * queryCriteria?: (object _AdaptiveQueryCriteria_),
1949  * options?: (object _AdaptiveObjectOptions_),
1950  * adaptorTypeSpecific?: object
1951  * ): null;
1952  * ```
1953  *
1954  * Parameters:
1955  *
1956  * streamNumber - (integer) Stream number objects will be written to as they
1957  * are retrieved.
1958  *
1959  * adaptorId - (string) Id of adaptor containing objects to retrieve.
1960  *
1961  * objectType - (string) Id of adaptive object type of objects to retrieve.
1962  *
1963  * queryCriteria - (optional object _AdaptiveQueryCriteria_) This is the
1964  * query criteria for objects to be retrieved. If not specified, all
1965  * objects will be retrieved.
1966  *
1967  * options - (optional object _AdaptiveObjectOptions_) Object view options.
1968  * See /afw/_AdaptiveObjectType_/_AdaptiveObjectOptions_ for more
1969  * information.
1970  *
1971  * adaptorTypeSpecific - (optional object) This is an optional object
1972  * parameter with an objectType determined by the adaptorType associated
1973  * with the adaptorId parameter. If the adaptorType supports this
1974  * parameter, adaptor afw will have an adaptive object type with an id
1975  * of:
1976  *
1977  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_retrieve_objects
1978  *
1979  * Where ${adaptorType} is the adaptor type id.
1980  *
1981  * Returns:
1982  *
1983  * (null)
1984  */
1985 const afw_value_t *
1988 {
1989  const afw_value_integer_t *streamNumber;
1990  const afw_value_string_t *adaptorId;
1991  const afw_value_string_t *objectType;
1992  const afw_value_object_t *queryCriteria;
1993  const afw_value_object_t *options;
1994  const afw_value_object_t *adaptorTypeSpecific;
1995  const afw_value_string_t *contextType;
1996  const afw_query_criteria_t *criteria;
1997  const afw_object_t *adaptor_type_specific;
1998  const afw_object_t *journal_entry;
2000 
2001  afw_memory_clear(&ctx);
2002  ctx.p = x->p;
2003  criteria = NULL;
2004 
2006  1, integer);
2008  2, string);
2010  3, string);
2012  4, object);
2014  5, object);
2015  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
2016  6, object);
2017  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(contextType, 7, string);
2018 
2019  journal_entry = afw_object_create_managed(x->p, x->xctx);
2020 
2021  /* Stream. */
2022  ctx.stream = afw_stream_get_by_streamNumber(
2023  streamNumber->internal, x->xctx);
2024  if (!ctx.stream || !ctx.stream->write_cb) {
2025  AFW_THROW_ERROR_FZ(general, x->xctx,
2026  "streamNumber %" AFW_INTEGER_FMT " is not an open output stream",
2027  streamNumber->internal);
2028  }
2029 
2030  /* Optional query criteria. */
2031  if (queryCriteria) {
2033  queryCriteria->internal,
2034  &adaptorId->internal, &objectType->internal,
2035  journal_entry, x->p, x->xctx);
2036  }
2037 
2038  /* Optional options. */
2039  if (options) {
2040  ctx.object_options = afw_object_options_set_from_object(NULL,
2041  options->internal, x->p, x->xctx);
2042  }
2043 
2044  /* Optional adaptorTypeSpecific. */
2045  adaptor_type_specific = NULL;
2046  if (adaptorTypeSpecific) {
2047  adaptor_type_specific = adaptorTypeSpecific->internal;
2048  }
2049 
2050  /* Optional contentType. */
2051  if (contextType) {
2052  ctx.response_content_type = afw_environment_get_content_type(
2053  &contextType->internal, x->xctx);
2054  if (!ctx.response_content_type) {
2055  AFW_THROW_ERROR_FZ(general, x->xctx,
2056  "Unknown contentType %" AFW_UTF8_FMT,
2057  AFW_UTF8_FMT_ARG(&contextType->internal));
2058  }
2059  }
2060  else if (x->xctx->request && x->xctx->request->response_content_type)
2061  {
2062  ctx.response_content_type = x->xctx->request->response_content_type;
2063  }
2064  else {
2065  ctx.response_content_type = afw_json_content_type_get();
2066  }
2067 
2068  /* Retrieve objects. */
2070  &adaptorId->internal, &objectType->internal,
2071  ctx.object_options, criteria, journal_entry, (void *)&ctx,
2072  impl_retrieve_to_stream_cb,
2073  adaptor_type_specific,
2074  x->p, x->xctx);
2075 
2076  /* Return undefined. */
2077  return NULL;
2078 }
2079 
2080 
2081 
2082 /*
2083  * Adaptive function: retrieve_objects_with_uri
2084  *
2085  * afw_function_execute_retrieve_objects_with_uri
2086  *
2087  * See afw_function_bindings.h for more information.
2088  *
2089  * Retrieve adaptive objects with a given URI.
2090  *
2091  * The optional queryCriteria is used to filter the adaptive objects returned.
2092  * Use the objectOptions parameter to influence how the objects are viewed.
2093  *
2094  * Options, specific to the adaptorId, can be optionally supplied.
2095  *
2096  * This function is not pure, so it may return a different result
2097  * given exactly the same parameters.
2098  *
2099  * Declaration:
2100  *
2101  * ```
2102  * function retrieve_objects_with_uri(
2103  * uri: anyURI,
2104  * options?: (object _AdaptiveObjectOptions_),
2105  * adaptorTypeSpecific?: object
2106  * ): list;
2107  * ```
2108  *
2109  * Parameters:
2110  *
2111  * uri - (anyURI) URI of objects to retrieve. If a URI begins with a single
2112  * slash ('/'), it is the local object path. A query string can be
2113  * specified.
2114  *
2115  * options - (optional object _AdaptiveObjectOptions_) Object view options.
2116  * See /afw/_AdaptiveObjectType_/_AdaptiveObjectOptions_ for more
2117  * information.
2118  *
2119  * adaptorTypeSpecific - (optional object) This is an optional object
2120  * parameter with an objectType determined by the adaptorType associated
2121  * with the adaptorId parameter. If the adaptorType supports this
2122  * parameter, adaptor afw will have an adaptive object type with an id
2123  * of:
2124  *
2125  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_retrieve_objects
2126  *
2127  * Where ${adaptorType} is the adaptor type id.
2128  *
2129  * Returns:
2130  *
2131  * (list) This is the list of objects retrieved.
2132  */
2133 const afw_value_t *
2136 {
2137  const afw_value_anyURI_t *uri;
2138  const afw_value_object_t *options;
2139  const afw_value_object_t *adaptorTypeSpecific;
2140  const afw_object_t *journal_entry;
2141  const afw_uri_parsed_t *parsed_uri;
2142  const afw_query_criteria_t *criteria;
2144 
2145  afw_memory_clear(&ctx);
2146  ctx.p = x->p;
2147  ctx.list = afw_list_of_create(afw_data_type_object, x->p, x->xctx);
2148  criteria = NULL;
2149  journal_entry = afw_object_create_managed(x->p, x->xctx);
2150 
2152  1, anyURI);
2154  2, object);
2155  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
2156  3, object);
2157 
2158  /* Optional options. */
2159  if (options) {
2160  ctx.object_options = afw_object_options_set_from_object(NULL,
2161  options->internal, x->p, x->xctx);
2162  }
2163 
2164  /* Parse URI to get adaptorId and objectType. */
2165  parsed_uri = afw_uri_parse(&uri->internal, true, NULL, x->p, x->xctx);
2166  if (!parsed_uri) {
2167  AFW_THROW_ERROR_Z(general, "Parameter uri is not valid", x->xctx);
2168  }
2169  if (!parsed_uri->path_parsed ||
2170  parsed_uri->path_parsed->first_property_name)
2171  {
2172  AFW_THROW_ERROR_Z(general,
2173  "Only local entity object paths are currently supported", x->xctx);
2174  }
2175 
2176  /* Parse optional query string. */
2177  if (parsed_uri->original_query.len > 0) {
2179  &parsed_uri->original_query,
2180  &parsed_uri->path_parsed->adaptor_id,
2181  &parsed_uri->path_parsed->object_type_id,
2182  journal_entry, x->p, x->xctx);
2183  }
2184 
2185  /* Retrieve objects. */
2187  &parsed_uri->path_parsed->adaptor_id,
2188  &parsed_uri->path_parsed->object_type_id,
2189  ctx.object_options, criteria, journal_entry, (void *)&ctx,
2190  impl_retrieve_cb,
2191  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
2192  x->p, x->xctx);
2193 
2194  /* Return retrieved objects as a list. */
2195  return afw_value_create_list(ctx.list, x->p, x->xctx);
2196 }
2197 
2198 
2199 
2200 /*
2201  * Adaptive function: retrieve_objects_with_uri_to_callback
2202  *
2203  * afw_function_execute_retrieve_objects_with_uri_to_callback
2204  *
2205  * See afw_function_bindings.h for more information.
2206  *
2207  * Retrieve adaptive objects with a given URI.
2208  *
2209  * Each object is passed to the callback as it's retrieved.
2210  *
2211  * The optional queryCriteria is used to filter the adaptive objects returned.
2212  * Use the objectOptions parameter to influence how the objects are viewed.
2213  *
2214  * Options, specific to the adaptorId, can be optionally supplied.
2215  *
2216  * This function is not pure, so it may return a different result
2217  * given exactly the same parameters.
2218  *
2219  * Declaration:
2220  *
2221  * ```
2222  * function retrieve_objects_with_uri_to_callback(
2223  * objectCallback: (function (object: object, userData: any): boolean),
2224  * userData: any,
2225  * uri: anyURI,
2226  * options?: (object _AdaptiveObjectOptions_),
2227  * adaptorTypeSpecific?: object
2228  * ): null;
2229  * ```
2230  *
2231  * Parameters:
2232  *
2233  * objectCallback - (function (object: object, userData: any): boolean) If
2234  * this is specified, this function is called once for each object
2235  * retrieved instead of adding the object to the return list. Parameter
2236  * object will be an object retrieved or undefined if there are no more
2237  * objects. This function should return true if it wants to abort the
2238  * retrieve request.
2239  *
2240  * userData - (any) This is the value passed to the objectCallback function
2241  * in the userData parameter.
2242  *
2243  * uri - (anyURI) URI of objects to retrieve. If a URI begins with a single
2244  * slash ('/'), it is the local object path. A query string can be
2245  * specified.
2246  *
2247  * options - (optional object _AdaptiveObjectOptions_) Object view options.
2248  * See /afw/_AdaptiveObjectType_/_AdaptiveObjectOptions_ for more
2249  * information.
2250  *
2251  * adaptorTypeSpecific - (optional object) This is an optional object
2252  * parameter with an objectType determined by the adaptorType associated
2253  * with the adaptorId parameter. If the adaptorType supports this
2254  * parameter, adaptor afw will have an adaptive object type with an id
2255  * of:
2256  *
2257  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_retrieve_objects
2258  *
2259  * Where ${adaptorType} is the adaptor type id.
2260  *
2261  * Returns:
2262  *
2263  * (null)
2264  */
2265 const afw_value_t *
2268 {
2269  const afw_value_anyURI_t *uri;
2270  const afw_value_object_t *options;
2271  const afw_value_object_t *adaptorTypeSpecific;
2272  const afw_object_t *journal_entry;
2273  const afw_uri_parsed_t *parsed_uri;
2274  const afw_query_criteria_t *criteria;
2276 
2277  afw_memory_clear(&ctx);
2278  journal_entry = afw_object_create_managed(x->p, x->xctx);
2279  criteria = NULL;
2280  afw_memory_clear(&ctx);
2281  ctx.p = x->p;
2282 
2283  AFW_FUNCTION_EVALUATE_PARAMETER(ctx.objectCallback,
2284  1);
2285  AFW_FUNCTION_EVALUATE_PARAMETER(ctx.userData,
2286  2);
2288  3, anyURI);
2290  4, object);
2291  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
2292  5, object);
2293 
2294  /* Optional options. */
2295  if (options) {
2296  ctx.object_options = afw_object_options_set_from_object(NULL,
2297  options->internal, x->p, x->xctx);
2298  }
2299 
2300  /* Parse URI to get adaptorId and objectType. */
2301  parsed_uri = afw_uri_parse(&uri->internal, true, NULL, x->p, x->xctx);
2302  if (!parsed_uri) {
2303  AFW_THROW_ERROR_Z(general, "Parameter uri is not valid", x->xctx);
2304  }
2305  if (!parsed_uri->path_parsed ||
2306  parsed_uri->path_parsed->first_property_name)
2307  {
2308  AFW_THROW_ERROR_Z(general,
2309  "Only local entity object paths are currently supported", x->xctx);
2310  }
2311 
2312  /* Parse optional query string. */
2313  if (parsed_uri->original_query.len > 0) {
2315  &parsed_uri->original_query,
2316  &parsed_uri->path_parsed->adaptor_id,
2317  &parsed_uri->path_parsed->object_type_id,
2318  journal_entry, x->p, x->xctx);
2319  }
2320 
2321  /* Retrieve objects. */
2323  &parsed_uri->path_parsed->adaptor_id,
2324  &parsed_uri->path_parsed->object_type_id,
2325  ctx.object_options, criteria, journal_entry, (void *)&ctx,
2326  impl_retrieve_cb,
2327  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
2328  x->p, x->xctx);
2329 
2330  /* Return retrieved objects as a list. */
2331  return afw_value_create_list(ctx.list, x->p, x->xctx);
2332 }
2333 
2334 
2335 
2336 /*
2337  * Adaptive function: retrieve_objects_with_uri_to_response
2338  *
2339  * afw_function_execute_retrieve_objects_with_uri_to_response
2340  *
2341  * See afw_function_bindings.h for more information.
2342  *
2343  * This function retrieves adaptive objects with a given URI.
2344  *
2345  * This function is only allowed when called during a request with content type
2346  * "application/x-afw". An "_AdaptiveResponse_" object is written to the
2347  * request's response as each object is retrieved. This "_AdaptiveResponse_"
2348  * object has a "result" property containing the retrieved object and a
2349  * "partial" property set to true.
2350  *
2351  * The optional queryCriteria is used to filter the adaptive objects returned.
2352  * Use the objectOptions parameter to influence how the objects are viewed.
2353  *
2354  * Options, specific to the adaptorId, can be optionally supplied.
2355  *
2356  * This function is not pure, so it may return a different result
2357  * given exactly the same parameters.
2358  *
2359  * Declaration:
2360  *
2361  * ```
2362  * function retrieve_objects_with_uri_to_response(
2363  * uri: anyURI,
2364  * options?: (object _AdaptiveObjectOptions_),
2365  * adaptorTypeSpecific?: object
2366  * ): null;
2367  * ```
2368  *
2369  * Parameters:
2370  *
2371  * uri - (anyURI) URI of objects to retrieve. If a URI begins with a single
2372  * slash ('/'), it is the local object path. A query string can be
2373  * specified.
2374  *
2375  * options - (optional object _AdaptiveObjectOptions_) Object view options.
2376  * See /afw/_AdaptiveObjectType_/_AdaptiveObjectOptions_ for more
2377  * information.
2378  *
2379  * adaptorTypeSpecific - (optional object) This is an optional object
2380  * parameter with an objectType determined by the adaptorType associated
2381  * with the adaptorId parameter. If the adaptorType supports this
2382  * parameter, adaptor afw will have an adaptive object type with an id
2383  * of:
2384  *
2385  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_retrieve_objects
2386  *
2387  * Where ${adaptorType} is the adaptor type id.
2388  *
2389  * Returns:
2390  *
2391  * (null)
2392  */
2393 const afw_value_t *
2396 {
2397  const afw_value_anyURI_t *uri;
2398  const afw_value_object_t *options;
2399  const afw_value_object_t *adaptorTypeSpecific;
2400  const afw_object_t *journal_entry;
2401  const afw_uri_parsed_t *parsed_uri;
2402  const afw_query_criteria_t *criteria;
2404 
2405 
2406  if (!x->xctx->request ||
2407  !x->xctx->request->response_content_type ||
2409  x->xctx->request->response_content_type))
2410  {
2411  AFW_THROW_ERROR_Z(general,
2412  "retrieve_objects_with_uri_to_response() "
2413  "is only allowed to be called "
2414  "during a request with response content type "
2415  "\"application/x-afw\".",
2416  x->xctx);
2417  }
2418 
2419  afw_memory_clear(&ctx);
2420  ctx.p = x->p;
2421  ctx.response_content_type = x->xctx->request->response_content_type;
2422  criteria = NULL;
2423  journal_entry = afw_object_create_managed(x->p, x->xctx);
2424 
2426  1, anyURI);
2428  2, object);
2429  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
2430  3, object);
2431 
2432  /* Optional options. */
2433  if (options) {
2434  ctx.object_options = afw_object_options_set_from_object(NULL,
2435  options->internal, x->p, x->xctx);
2436  }
2437 
2438  /* Parse URI to get adaptorId and objectType. */
2439  parsed_uri = afw_uri_parse(&uri->internal, true, NULL, x->p, x->xctx);
2440  if (!parsed_uri) {
2441  AFW_THROW_ERROR_Z(general, "Parameter uri is not valid", x->xctx);
2442  }
2443  if (!parsed_uri->path_parsed ||
2444  parsed_uri->path_parsed->first_property_name)
2445  {
2446  AFW_THROW_ERROR_Z(general,
2447  "Only local entity object paths are currently supported", x->xctx);
2448  }
2449 
2450  /* Parse optional query string. */
2451  if (parsed_uri->original_query.len > 0) {
2453  &parsed_uri->original_query,
2454  &parsed_uri->path_parsed->adaptor_id,
2455  &parsed_uri->path_parsed->object_type_id,
2456  journal_entry, x->p, x->xctx);
2457  }
2458 
2459  /* Retrieve objects to response. */
2461  &parsed_uri->path_parsed->adaptor_id,
2462  &parsed_uri->path_parsed->object_type_id,
2463  ctx.object_options, criteria, journal_entry, (void *)&ctx,
2464  impl_retrieve_to_response_cb,
2465  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
2466  x->p, x->xctx);
2467 
2468  /* Return undefined. */
2469  return NULL;
2470 }
2471 
2472 
2473 
2474 /*
2475  * Adaptive function: retrieve_objects_with_uri_to_stream
2476  *
2477  * afw_function_execute_retrieve_objects_with_uri_to_stream
2478  *
2479  * See afw_function_bindings.h for more information.
2480  *
2481  * This function retrieves adaptive objects with a given URI.
2482  *
2483  * Each object is written to the "streamId" stream as it's retrieved.
2484  *
2485  * The optional queryCriteria is used to filter the adaptive objects returned.
2486  * Use the objectOptions parameter to influence how the objects are viewed.
2487  *
2488  * Options, specific to the adaptorId, can be optionally supplied.
2489  *
2490  * This function is not pure, so it may return a different result
2491  * given exactly the same parameters.
2492  *
2493  * Declaration:
2494  *
2495  * ```
2496  * function retrieve_objects_with_uri_to_stream(
2497  * streamNumber: integer,
2498  * uri: anyURI,
2499  * options?: (object _AdaptiveObjectOptions_),
2500  * adaptorTypeSpecific?: object
2501  * ): null;
2502  * ```
2503  *
2504  * Parameters:
2505  *
2506  * streamNumber - (integer) Stream number objects will be written to as they
2507  * are retrieved.
2508  *
2509  * uri - (anyURI) URI of objects to retrieve. If a URI begins with a single
2510  * slash ('/'), it is the local object path. A query string can be
2511  * specified.
2512  *
2513  * options - (optional object _AdaptiveObjectOptions_) Object view options.
2514  * See /afw/_AdaptiveObjectType_/_AdaptiveObjectOptions_ for more
2515  * information.
2516  *
2517  * adaptorTypeSpecific - (optional object) This is an optional object
2518  * parameter with an objectType determined by the adaptorType associated
2519  * with the adaptorId parameter. If the adaptorType supports this
2520  * parameter, adaptor afw will have an adaptive object type with an id
2521  * of:
2522  *
2523  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_retrieve_objects
2524  *
2525  * Where ${adaptorType} is the adaptor type id.
2526  *
2527  * Returns:
2528  *
2529  * (null)
2530  */
2531 const afw_value_t *
2534 {
2535  const afw_value_integer_t *streamNumber;
2536  const afw_value_anyURI_t *uri;
2537  const afw_value_object_t *options;
2538  const afw_value_object_t *adaptorTypeSpecific;
2539  const afw_object_t *journal_entry;
2540  const afw_uri_parsed_t *parsed_uri;
2541  const afw_query_criteria_t *criteria;
2543 
2544  afw_memory_clear(&ctx);
2545  ctx.p = x->p;
2546  criteria = NULL;
2547  journal_entry = afw_object_create_managed(x->p, x->xctx);
2548 
2550  1, integer);
2552  2, anyURI);
2554  3, object);
2555  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
2556  4, object);
2557 
2558  /* Stream. */
2559  ctx.stream = afw_stream_get_by_streamNumber(
2560  streamNumber->internal, x->xctx);
2561  if (!ctx.stream || !ctx.stream->write_cb) {
2562  AFW_THROW_ERROR_FZ(general, x->xctx,
2563  "streamNumber %" AFW_INTEGER_FMT " is not an open output stream",
2564  streamNumber->internal);
2565  }
2566 
2567  /* Optional options. */
2568  if (options) {
2569  ctx.object_options = afw_object_options_set_from_object(NULL,
2570  options->internal, x->p, x->xctx);
2571  }
2572 
2573  /* Parse URI to get adaptorId and objectType. */
2574  parsed_uri = afw_uri_parse(&uri->internal, true, NULL, x->p, x->xctx);
2575  if (!parsed_uri) {
2576  AFW_THROW_ERROR_Z(general, "Parameter uri is not valid", x->xctx);
2577  }
2578  if (!parsed_uri->path_parsed ||
2579  parsed_uri->path_parsed->first_property_name)
2580  {
2581  AFW_THROW_ERROR_Z(general,
2582  "Only local entity object paths are currently supported", x->xctx);
2583  }
2584 
2585  /* Parse optional query string. */
2586  if (parsed_uri->original_query.len > 0) {
2588  &parsed_uri->original_query,
2589  &parsed_uri->path_parsed->adaptor_id,
2590  &parsed_uri->path_parsed->object_type_id,
2591  journal_entry, x->p, x->xctx);
2592  }
2593 
2594  /* Retrieve objects to response. */
2596  &parsed_uri->path_parsed->adaptor_id,
2597  &parsed_uri->path_parsed->object_type_id,
2598  ctx.object_options, criteria, journal_entry, (void *)&ctx,
2599  impl_retrieve_to_stream_cb,
2600  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
2601  x->p, x->xctx);
2602 
2603  /* Return undefined. */
2604  return NULL;
2605 }
2606 
2607 
2608 
2609 /*
2610  * Adaptive function: update_object
2611  *
2612  * afw_function_execute_update_object
2613  *
2614  * See afw_function_bindings.h for more information.
2615  *
2616  * Update an adaptive object.
2617  *
2618  * This function is not pure, so it may return a different result
2619  * given exactly the same parameters and has side effects.
2620  *
2621  * Declaration:
2622  *
2623  * ```
2624  * function update_object(
2625  * adaptorId: string,
2626  * objectType: string,
2627  * objectId: string,
2628  * object: object,
2629  * journal?: object,
2630  * adaptorTypeSpecific?: object
2631  * ): (object _AdaptiveJournalEntry_);
2632  * ```
2633  *
2634  * Parameters:
2635  *
2636  * adaptorId - (string) Id of adaptor containing object to update.
2637  *
2638  * objectType - (string) Id of adaptive object type of object to update.
2639  *
2640  * objectId - (string) Id of object to update.
2641  *
2642  * object - (object) Object containing properties to replace in existing
2643  * object. You can use object_modify instead to update properties of
2644  * embedded objects and lists, as well as to modify individual values of
2645  * the object.
2646  *
2647  * journal - (optional object) The properties of this object will be added to
2648  * the associated journal entry. Refer to
2649  * /afw/_AdaptiveObjectType_/_AdaptiveJournalEntry_ for property names to
2650  * avoid and for ones that have specific semantics.
2651  *
2652  * adaptorTypeSpecific - (optional object) This is an optional object
2653  * parameter with an objectType determined by the adaptorType associated
2654  * with the adaptorId parameter. If the adaptorType supports this
2655  * parameter, adaptor afw will have an adaptive object type with an id
2656  * of:
2657  *
2658  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_modify_object
2659  *
2660  * Where ${adaptorType} is the adaptor type id.
2661  *
2662  * Returns:
2663  *
2664  * (object _AdaptiveJournalEntry_) Resulting journal entry.
2665  */
2666 const afw_value_t *
2669 {
2670  const afw_value_string_t *adaptorId;
2671  const afw_value_string_t *objectType;
2672  const afw_value_string_t *objectId;
2673  const afw_value_object_t *object;
2674  const afw_value_object_t *journal;
2675  const afw_value_object_t *adaptorTypeSpecific;
2676  const afw_utf8_t *id;
2677  const afw_object_t *journal_entry;
2678 
2680  1, string);
2682  2, string);
2684  3, string);
2686  4, object);
2688  5, object);
2689  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
2690  6, object);
2691 
2692  id = (objectId && objectId->internal.len > 0)
2693  ? &objectId->internal
2694  : NULL;
2695 
2696  /* Create journal entry including optional properties. */
2697  journal_entry = impl_create_journal_entry(journal, x->p, x->xctx);
2698 
2699  /* Update object. */
2701  &adaptorId->internal, &objectType->internal,
2702  id, object->internal, journal_entry,
2703  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
2704  x->xctx);
2705 
2706  /* Return journal entry as response. */
2707  return afw_value_create_object(journal_entry, x->p, x->xctx);
2708 }
2709 
2710 
2711 
2712 /*
2713  * Adaptive function: update_object_with_uri
2714  *
2715  * afw_function_execute_update_object_with_uri
2716  *
2717  * See afw_function_bindings.h for more information.
2718  *
2719  * Update an adaptive object with a given URI.
2720  *
2721  * This function is not pure, so it may return a different result
2722  * given exactly the same parameters and has side effects.
2723  *
2724  * Declaration:
2725  *
2726  * ```
2727  * function update_object_with_uri(
2728  * uri: anyURI,
2729  * object: object,
2730  * journal?: object,
2731  * adaptorTypeSpecific?: object
2732  * ): (object _AdaptiveJournalEntry_);
2733  * ```
2734  *
2735  * Parameters:
2736  *
2737  * uri - (anyURI) URI of object to update. If a URI begins with a single
2738  * slash ('/'), it is the local object path.
2739  *
2740  * object - (object) Object containing properties to replace in existing
2741  * object. You can use object_modify instead to update properties of
2742  * embedded objects and lists, as well as to modify individual values of
2743  * the object.
2744  *
2745  * journal - (optional object) The properties of this object will be added to
2746  * the associated journal entry. Refer to
2747  * /afw/_AdaptiveObjectType_/_AdaptiveJournalEntry_ for property names to
2748  * avoid and for ones that have specific semantics.
2749  *
2750  * adaptorTypeSpecific - (optional object) This is an optional object
2751  * parameter with an objectType determined by the adaptorType associated
2752  * with the adaptorId parameter. If the adaptorType supports this
2753  * parameter, adaptor afw will have an adaptive object type with an id
2754  * of:
2755  *
2756  * _AdaptiveAdaptorTypeSpecific_${adaptorType}_modify_object
2757  *
2758  * Where ${adaptorType} is the adaptor type id.
2759  *
2760  * Returns:
2761  *
2762  * (object _AdaptiveJournalEntry_) Resulting journal entry.
2763  */
2764 const afw_value_t *
2767 {
2768  const afw_value_anyURI_t *uri;
2769  const afw_value_object_t *object;
2770  const afw_value_object_t *journal;
2771  const afw_value_object_t *adaptorTypeSpecific;
2772  const afw_object_t *journal_entry;
2773  const afw_uri_parsed_t *parsed_uri;
2774  const afw_utf8_t *id;
2775 
2777  1, anyURI);
2779  2, object);
2781  3, object);
2782  AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(adaptorTypeSpecific,
2783  4, object);
2784 
2785  parsed_uri = afw_uri_parse(&uri->internal, true, NULL, x->p, x->xctx);
2786  if (!parsed_uri) {
2787  AFW_THROW_ERROR_Z(general, "Parameter uri is not valid", x->xctx);
2788  }
2789 
2790  if (!parsed_uri->path_parsed ||
2791  parsed_uri->path_parsed->first_property_name)
2792  {
2793  AFW_THROW_ERROR_Z(general,
2794  "Only local entity object paths are currently supported", x->xctx);
2795  }
2796 
2797  id = (parsed_uri->path_parsed->entity_object_id.len > 0)
2798  ? &parsed_uri->path_parsed->entity_object_id
2799  : NULL;
2800 
2801  /* Create journal entry including optional properties. */
2802  journal_entry = impl_create_journal_entry(journal, x->p, x->xctx);
2803 
2804  /* Update object. */
2806  &parsed_uri->path_parsed->adaptor_id,
2807  &parsed_uri->path_parsed->object_type_id,
2808  id, object->internal, journal_entry,
2809  (adaptorTypeSpecific) ? adaptorTypeSpecific->internal: NULL,
2810  x->xctx);
2811 
2812  /* Return journal entry as response. */
2813  return afw_value_create_object(journal_entry, x->p, x->xctx);
2814 }
2815 
2816 
2817 
2818 /*
2819  * Adaptive function: adaptor_objectCallback_signature
2820  *
2821  * afw_function_execute_adaptor_objectCallback_signature
2822  *
2823  * See afw_function_bindings.h for more information.
2824  *
2825  * This is the function signature for the objectCallback parameter in adaptor
2826  * functions. Calling this directly will throw a "Do not call directly" error.
2827  *
2828  * This function is not pure, so it may return a different result
2829  * given exactly the same parameters.
2830  *
2831  * Declaration:
2832  *
2833  * ```
2834  * function adaptor_objectCallback_signature(
2835  * object: object,
2836  * userData?: any
2837  * ): boolean;
2838  * ```
2839  *
2840  * Parameters:
2841  *
2842  * object - (object) This is the object from adaptor or undefined if there
2843  * are no more objects to return.
2844  *
2845  * userData - (optional any) This is the value of the userData parameter when
2846  * objectCallback was called.
2847  *
2848  * Returns:
2849  *
2850  * (boolean) Return true if this callback should not be called again for any
2851  * reason such a limit exceeded or the desired object being found.
2852  */
2853 const afw_value_t *
2856 {
2857  AFW_THROW_ERROR_Z(general, "Do not call directly", x->xctx);
2858 }
Adaptive Framework Core Internal.
afw_adaptor_modify_using_update_object(const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, const afw_object_t *update_object, const afw_object_t *journal_entry, const afw_object_t *adaptor_type_specific, afw_xctx_t *xctx)
Modify using update object and remove from cache.
afw_adaptor_retrieve_objects(const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_object_options_t *options, const afw_query_criteria_t *criteria, const afw_object_t *journal_entry, void *context, afw_object_cb_t callback, const afw_object_t *adaptor_type_specific, const afw_pool_t *p, afw_xctx_t *xctx)
Retrieve objects.
afw_adaptor_replace_object(const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, const afw_object_t *replacement_object, const afw_object_t *journal_entry, const afw_object_t *adaptor_type_specific, afw_xctx_t *xctx)
Replace object and remove from cache.
afw_adaptor_modify_needed_to_reconcile(const afw_utf8_t **adaptor_id, const afw_utf8_t **object_type_id, const afw_utf8_t **object_id, const afw_list_t **entries, const afw_object_t *original, const afw_object_t *modified, const afw_object_t *journal_entry, const afw_pool_t *p, afw_xctx_t *xctx)
Produce modify needed to reconcile two objects.
afw_adaptor_add_object(const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_utf8_t *suggested_object_id, const afw_object_t *object, const afw_object_t *journal_entry, const afw_object_t *adaptor_type_specific, afw_xctx_t *xctx)
Call adaptor to add object and remove from cache.
afw_adaptor_get_object_type(const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_object_t *journal_entry, afw_xctx_t *xctx)
Get and cache AdaptiveObjectType object.
Definition: afw_adaptor.c:437
afw_adaptor_modify_object(const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, const afw_list_t *entries, const afw_object_t *journal_entry, const afw_object_t *adaptor_type_specific, afw_xctx_t *xctx)
Modify object and remove from cache.
afw_adaptor_query_criteria_parse_object(const afw_object_t *query_criteria, const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_object_t *journal_entry, const afw_pool_t *p, afw_xctx_t *xctx)
Parse query criteria object appropriate for an adaptor.
Definition: afw_adaptor.c:173
afw_adaptor_get_object(const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, const afw_object_options_t *options, const afw_query_criteria_t *criteria, const afw_object_t *journal_entry, const afw_object_t *adaptor_type_specific, const afw_pool_t *p, afw_xctx_t *xctx)
Get and cache object.
afw_adaptor_delete_object(const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, const afw_object_t *journal_entry, const afw_object_t *adaptor_type_specific, afw_xctx_t *xctx)
Delete object from cache and via adaptor.
afw_adaptor_query_criteria_parse_url_encoded_rql_string(const afw_utf8_t *url_encoded_rql_string, const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_object_t *journal_entry, const afw_pool_t *p, afw_xctx_t *xctx)
Parse URL encoded RQL query string appropriate for an adaptor.
Definition: afw_adaptor.c:197
#define afw_value_is_boolean(A_VALUE)
Macro to determine if value is evaluated boolean.
afw_object_set_property_as_boolean(const afw_object_t *object, const afw_utf8_t *property_name, afw_boolean_t internal, afw_xctx_t *xctx)
Set property function for data type boolean values.
afw_value_create_list(const afw_list_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type list value.
afw_object_set_property_as_object(const afw_object_t *object, const afw_utf8_t *property_name, const afw_object_t *internal, afw_xctx_t *xctx)
Set property function for data type object values.
afw_data_type_object
Data type struct for object.
afw_value_create_object(const afw_object_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type object value.
afw_value_create_string(const afw_utf8_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type string value.
#define AFW_UTF8_FMT_ARG(A_STRING)
Convenience Macro for use with AFW_UTF8_FMT to specify arg.
Definition: afw_common.h:605
struct afw_iterator_s afw_iterator_t
#define AFW_INTEGER_FMT
Format string specifier used for afw_integer_t.
Definition: afw_common.h:326
_Bool afw_boolean_t
Definition: afw_common.h:373
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
Definition: afw_common.h:588
#define afw_content_type_write_value(instance, value, options, context, callback, p, xctx)
Call method write_value of interface afw_content_type.
#define afw_content_type_is_application_afw(instance)
Determine if content type it application/x-afw.
const afw_content_type_t * afw_environment_get_content_type(const afw_utf8_t *type, afw_xctx_t *xctx)
Get the afw_content_type struct associated with a content type.
#define AFW_THROW_ERROR_FZ(code, xctx, format_z,...)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:319
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:283
#define AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(A_RESULT, A_N, A_TYPE)
Evaluate an arg for a particular data type.
Definition: afw_function.h:261
#define AFW_FUNCTION_EVALUATE_REQUIRED_DATA_TYPE_PARAMETER(A_RESULT, A_N, A_TYPE)
Evaluate an arg for a particular data type.
Definition: afw_function.h:328
#define AFW_FUNCTION_PARAMETER_IS_PRESENT(A_N)
Determine if a specific parameter value is present.
Definition: afw_function.h:242
#define AFW_FUNCTION_EVALUATE_PARAMETER(A_RESULT, A_N)
Evaluate a parameter.
Definition: afw_function.h:279
const afw_value_t * afw_function_execute_add_object(afw_function_execute_t *x)
Adaptive Function add_object
const afw_value_t * afw_function_execute_retrieve_objects_to_stream(afw_function_execute_t *x)
Adaptive Function retrieve_objects_to_stream
const afw_value_t * afw_function_execute_adaptor_objectCallback_signature(afw_function_execute_t *x)
Adaptive Function adaptor_objectCallback_signature
const afw_value_t * afw_function_execute_update_object_with_uri(afw_function_execute_t *x)
Adaptive Function update_object_with_uri
const afw_value_t * afw_function_execute_replace_object_with_uri(afw_function_execute_t *x)
Adaptive Function replace_object_with_uri
const afw_value_t * afw_function_execute_retrieve_objects_with_uri(afw_function_execute_t *x)
Adaptive Function retrieve_objects_with_uri
const afw_value_t * afw_function_execute_delete_object(afw_function_execute_t *x)
Adaptive Function delete_object
const afw_value_t * afw_function_execute_retrieve_objects_to_response(afw_function_execute_t *x)
Adaptive Function retrieve_objects_to_response
const afw_value_t * afw_function_execute_convert_AdaptiveQueryCriteria_to_query_string(afw_function_execute_t *x)
Adaptive Function convert_AdaptiveQueryCriteria_to_query_string
const afw_value_t * afw_function_execute_convert_query_string_to_AdaptiveQueryCriteria(afw_function_execute_t *x)
Adaptive Function convert_query_string_to_AdaptiveQueryCriteria
const afw_value_t * afw_function_execute_replace_object(afw_function_execute_t *x)
Adaptive Function replace_object
const afw_value_t * afw_function_execute_reconcile_object(afw_function_execute_t *x)
Adaptive Function reconcile_object
const afw_value_t * afw_function_execute_modify_object(afw_function_execute_t *x)
Adaptive Function modify_object
const afw_value_t * afw_function_execute_retrieve_objects(afw_function_execute_t *x)
Adaptive Function retrieve_objects
const afw_value_t * afw_function_execute_get_object_with_uri(afw_function_execute_t *x)
Adaptive Function get_object_with_uri
const afw_value_t * afw_function_execute_modify_object_with_uri(afw_function_execute_t *x)
Adaptive Function modify_object_with_uri
const afw_value_t * afw_function_execute_update_object(afw_function_execute_t *x)
Adaptive Function update_object
const afw_value_t * afw_function_execute_retrieve_objects_with_uri_to_stream(afw_function_execute_t *x)
Adaptive Function retrieve_objects_with_uri_to_stream
const afw_value_t * afw_function_execute_add_object_with_uri(afw_function_execute_t *x)
Adaptive Function add_object_with_uri
const afw_value_t * afw_function_execute_get_object(afw_function_execute_t *x)
Adaptive Function get_object
const afw_value_t * afw_function_execute_retrieve_objects_with_uri_to_callback(afw_function_execute_t *x)
Adaptive Function retrieve_objects_with_uri_to_callback
const afw_value_t * afw_function_execute_retrieve_objects_to_callback(afw_function_execute_t *x)
Adaptive Function retrieve_objects_to_callback
const afw_value_t * afw_function_execute_delete_object_with_uri(afw_function_execute_t *x)
Adaptive Function delete_object_with_uri
const afw_value_t * afw_function_execute_retrieve_objects_with_uri_to_response(afw_function_execute_t *x)
Adaptive Function retrieve_objects_with_uri_to_response
#define afw_json_to_value(json, source_location, p, xctx)
Convert JSON to an adaptive value.
Definition: afw_json.h:128
afw_json_content_type_get()
Get the content type instance for json.
Definition: afw_json.c:65
afw_list_add_value(const afw_list_t *instance, const afw_value_t *value, afw_xctx_t *xctx)
Call method add_value of interface afw_list_setter.
Definition: afw_list.c:104
#define afw_list_of_create(data_type, p, xctx)
Create an list of a specific data type in memory.
Definition: afw_list.h:64
#define afw_memory_clear(to)
Clear preallocated memory for sizeof(*(to)).
Definition: afw_memory.h:47
#define afw_object_add_reference(instance, xctx)
Call method add_reference of interface afw_object.
#define afw_object_get_next_property(instance, iterator, property_name, xctx)
Call method get_next_property of interface afw_object.
#define afw_object_release(instance, xctx)
Call method release of interface afw_object.
#define afw_object_meta_get_property_as_string(instance, property_name, xctx)
Get a meta property as single string.
afw_object_options_none
Object processing options - no options set.
afw_object_options_set_from_object(const afw_object_options_t *initial_options, const afw_object_t *options_object, const afw_pool_t *p, afw_xctx_t *xctx)
Set object processing options from options object.
#define afw_object_create_managed(p, xctx)
Create an empty entity object in its own pool.
Definition: afw_object.h:913
#define afw_object_create(p, xctx)
Create an empty unmanaged object in memory.
Definition: afw_object.h:948
afw_object_set_property(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_value_t *value, afw_xctx_t *xctx)
Set the value of an object's property.
Definition: afw_object.c:46
afw_query_criteria_to_query_string(const afw_query_criteria_t *criteria, afw_query_criteria_style_t style, const afw_pool_t *p, afw_xctx_t *xctx)
Convert query criteria to query string.
afw_query_criteria_parse_AdaptiveQueryCriteria_object(const afw_object_t *query_object, const afw_object_type_t *object_type, const afw_pool_t *p, afw_xctx_t *xctx)
Parse URI encoded query string.
afw_query_criteria_style_t
Query string style.
afw_query_criteria_to_AdaptiveQueryCriteria_object(const afw_query_criteria_t *criteria, const afw_pool_t *p, afw_xctx_t *xctx)
Convert query criteria to a AdaptiveQueryCriteria object.
afw_query_criteria_parse_url_encoded_rql_string(const afw_utf8_t *url_encoded_rql_string, const afw_object_type_t *object_type, const afw_pool_t *p, afw_xctx_t *xctx)
Parse URI encoded RQL query string.
#define afw_stream_flush(instance, xctx)
Call method flush of interface afw_stream.
afw_stream_get_by_streamNumber(const afw_integer_t streamNumber, afw_xctx_t *xctx)
Get stream by streamNumber.
Definition: afw_stream.c:68
#define afw_stream_standard(enum_suffix, xctx)
Get xctx stream instance.
Definition: afw_stream.h:122
afw_uri_parse(const afw_utf8_t *uri, afw_boolean_t is_value_path, const afw_utf8_t *current_path, const afw_pool_t *p, afw_xctx_t *xctx)
Parse a URI in specific pool.
Definition: afw_uri.c:1470
#define afw_value_evaluate(value, p, xctx)
Evaluate value if needed using specific pool.
Definition: afw_value.h:841
const afw_value_t * afw_value_call_create(const afw_compile_value_contextual_t *contextual, afw_size_t argc, const afw_value_t *const *argv, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for call value.
#define AFW_VALUE_ASSERT_IS_DATA_TYPE(A_VALUE, A_DATA_TYPE, A_SCOPE)
Throw and error if A_VALUE is not evaluated data type A_DATA_TYPE.
Definition: afw_value.h:768
Interface afw_content_type public struct.
Function execute parameter.
Definition: afw_function.h:53
afw_xctx_t * xctx
The execution context (xctx) of caller.
Definition: afw_function.h:62
const afw_pool_t * p
Pool for result.
Definition: afw_function.h:59
Interface afw_list public struct.
Struct for object processing options.
Interface afw_object public struct.
Struct for afw_object_type_t.
Interface afw_pool public struct.
Parsed query criteria.
Interface afw_stream public struct.
Typedef for parsed URI returned from afw_uri_parse().
Definition: afw_uri.h:133
NFC normalized UTF-8 string.
Definition: afw_common.h:545
struct for data type anyURI values.
struct for data type boolean values.
struct for data type integer values.
struct for data type list values.
struct for data type object values.
Interface afw_value public struct.
struct for data type string values.
Interface afw_xctx public struct.