| 292 | | == XML Format == |
| 293 | | |
| 294 | | {{{ |
| 295 | | <s3xrc> |
| 296 | | |
| 297 | | <resource <-- a record in the database --> |
| 298 | | created_on="2009-10-02 08:55:11" <-- date/time when the record was created --> |
| 299 | | modified_on="2009-10-02 08:56:03" <-- date/time when the record was last modified --> |
| 300 | | uuid="6e6e76dc-8ed7-408c-bb09-54476e3944ae" <-- UUID of the record (if present in DB) --> |
| 301 | | created_by="None" <-- Author --> |
| 302 | | modified_by="Dominic" <-- Last Author --> |
| 303 | | name="pr_person"> <-- Resource Name --> |
| 304 | | |
| 305 | | <reference <-- Reference Field (foreign key) in the record --> |
| 306 | | field="pr_pe_id" <-- Field name --> |
| 307 | | resource="pr_pentity" <-- Name of the referenced resource --> |
| 308 | | uuid="6e6e76dc-8ed7-408c-bb09-54476e3944ae"/> <-- UUID of the referenced entry --> |
| 309 | | |
| 310 | | <data field="pr_pe_label">730421</data> <-- A field in the record --> |
| 311 | | <data field="first_name">Dominic</data> |
| 312 | | <data field="middle_name"/> |
| 313 | | <data field="last_name">König</data> |
| 314 | | <data field="preferred_name"/> |
| 315 | | <data field="local_name"/> |
| 316 | | <data field="opt_pr_gender" value="3">male</data> |
| 317 | | <data field="opt_pr_age_group" value="5">Adult (21-50)</data> |
| 318 | | <data field="email">dominic@nursix.org</data> |
| 319 | | <data field="mobile_phone"/> |
| 320 | | <data field="date_of_birth">1973-04-21</data> |
| 321 | | <data field="opt_pr_nationality" value="65">Germany</data> |
| 322 | | <data field="opt_pr_country" value="167">Sweden</data> |
| 323 | | <data field="opt_pr_religion" value="1">none</data> |
| 324 | | <data field="opt_pr_marital_status" value="3">married</data> |
| 325 | | <data field="occupation">Nurse</data> |
| 326 | | <data field="comment"/> |
| 327 | | |
| 328 | | <resource <-- A sub-resource (joined resource) of the record --> |
| 329 | | created_on="2009-10-02 11:34:34" |
| 330 | | modified_on="2009-10-02 11:34:34" |
| 331 | | uuid="89217054-3c10-4f5d-959a-420254243498" |
| 332 | | name="pr_address"> |
| 333 | | |
| 334 | | <data |
| 335 | | field="opt_pr_address_type" <-- field name --> |
| 336 | | value="1"> <-- original value in the database --> |
| 337 | | Home Address <-- value represented for human readability --> |
| 338 | | </data> |
| 339 | | <data field="co_name"/> |
| 340 | | <data field="street1">Lundgatan</data> |
| 341 | | <data field="street2"/> |
| 342 | | <data field="postcode">38031</data> |
| 343 | | <data field="city">Läckeby</data> |
| 344 | | <data field="state"/> |
| 345 | | <data field="opt_pr_country" value="167">Sweden</data> |
| 346 | | <data field="lat">56.78042</data> |
| 347 | | <data field="lon">16.27914</data> |
| 348 | | <data field="comment"/> |
| 349 | | </resource> |
| 350 | | </resource> |
| 351 | | </s3xrc> |
| 352 | | }}} |
| 353 | | |
| 354 | | * [wiki:UUID] - how we handle Unique IDs for records across heterogeneous systems |
| 355 | | |
| 356 | | == JSON Format == |
| 357 | | |
| 358 | | The data structure of the JSON format is equivalent to the XML format (=element trees) - except that markup elements are represented by prefixes: |
| 359 | | |
| 360 | | {{{ |
| 361 | | { |
| 362 | | "@domain": "yana", // Server name |
| 363 | | "@url": "http://127.0.0.1:8000/eden" // Server URL |
| 364 | | "$_pr_person": { // Resource, prefix: $_ |
| 365 | | "@uuid": "44fc762e-02df-44e0-8bd1-9b58e3132894", // Resource attribute, prefix: @ |
| 366 | | "@url": "http://127.0.0.1:8000/eden/pr/person/1", |
| 367 | | "@created_on": "2009-11-16 22:33:35", |
| 368 | | "@created_by": "None", |
| 369 | | "@modified_on": "2009-11-19 21:32:19", |
| 370 | | "@modified_by": "Dominic", |
| 371 | | "first_name": "Dominic", // Data field, no prefix |
| 372 | | "last_name": "K\u00f6nig", |
| 373 | | "email": "dominic@nursix.org", |
| 374 | | "opt_pr_age_group": {"@value": "1", "$": "unknown"}, // Data field with textual representation: |
| 375 | | "opt_pr_religion": {"@value": "1", "$": "none"}, // @value=Value, $=TextualRepresentation |
| 376 | | "opt_pr_gender": {"@value": "1", "$": "unknown"}, |
| 377 | | "opt_pr_nationality": {"@value": "999", "$": "unknown"}, |
| 378 | | "opt_pr_country": {"@value": "999", "$": "unknown"}, |
| 379 | | "opt_pr_marital_status": {"@value": "1", "$": "unknown"}, |
| 380 | | "$k_pr_pe_id": { // External Reference (Key), prefix: $k_ |
| 381 | | "@resource": "pr_pentity", // Key resource name |
| 382 | | "@uuid": "a2a945bd-4f43-41da-bcdb-e2e638a987ea", // UUID of the key record |
| 383 | | "$": "Dominic K\u00f6nig [no label] (Person)" // Textual representation of the reference |
| 384 | | }, |
| 385 | | "$_pr_presence": { // Joined Resource (Component): |
| 386 | | "@uuid": "14af2751-7277-4e90-b42b-0d0430684561", // appears as component within the resource |
| 387 | | "@created_on": "2009-11-19 19:42:46", |
| 388 | | "@modified_on": "2009-11-19 19:42:46" |
| 389 | | "@url": "http://127.0.0.1:8000/eden/pr/person/1/presence/1", |
| 390 | | "opt_pr_presence_condition": {"@value": "4", "$": "Found"}, |
| 391 | | "time": {"@value": "2009-11-19 18:42:00 +0000", "$": "2009-11-19 20:42:00"}, |
| 392 | | "$k_reporter": { |
| 393 | | "@resource": "pr_person", |
| 394 | | "@uuid": "44fc762e-02df-44e0-8bd1-9b58e3132894", |
| 395 | | "$": "Dominic K\u00f6nig" |
| 396 | | }, |
| 397 | | } |
| 398 | | }, |
| 399 | | } |
| 400 | | }}} |
| 401 | | |
| 402 | | '''JSON format characteristics:''' |
| 403 | | |
| 404 | | * The JSON output contains _no_ whitespace between elements, it's just added here by hand for better readability |
| 405 | | |
| 406 | | * The outermost structure is always a JSON object (not a list) |
| 407 | | * All data is represented as strings (for security reasons) |
| 408 | | |
| 409 | | * If @value is sent for a field, it overrides the element text ($) at import |
| 410 | | * however, the use of @value is not mandatory, data can simply be placed instead of element text |
| 411 | | * Note that there is no automatic data encoding: data must be sent in DB-encoded format |
| 412 | | * @resource, @name and @uuid attributes are mandatory at input, other attributes can be omitted |
| 413 | | |
| 414 | | * Multiple records of the same resource will be aggregated as lists like: |
| 415 | | |
| 416 | | {{{ |
| 417 | | { |
| 418 | | $_my_resource: [ |
| 419 | | { |
| 420 | | // record1 of my_resource |
| 421 | | } |
| 422 | | { |
| 423 | | // record2 of my_resource |
| 424 | | } |
| 425 | | ] |
| 426 | | } |
| 427 | | }}} |
| 428 | | |