fixed CObject parent

This is a fix for issue #1. Seems to work ok and there are no broken tests.

Below is my test, se "parent" is the CAttribute corresponding to each CObject in the archetype.

You'll see that some paths for CAttributes are the same as the CObject path, this case is when a CObject doesn't have a nodeID. This can be an issue when traversing an archetype, see http://lists.openehr.org/pipermail/openehr-technical_lists.openehr.org/2013-August/008023.html

Reviewing the Archetype.java code, calling Archetype.node(path) will never return a CAttribute node, it only returns CObjects. I think this is a bug because IMO node() should return any kind of ArchetypeConstraint.

Carga desde: archetypes\composition\openEHR-EHR-COMPOSITION.signos.v1.adl
/ COMPOSITION
 * Parent: empty
/category DV_CODED_TEXT
 * Parent: category /category
/category/defining_code CodePhrase
 * Parent: defining_code /category/defining_code
/content[at0006] OBSERVATION
 * Parent: content /content
/content[at0006]/data[at0007] HISTORY
 * Parent: data /content[at0006]/data
/content[at0006]/data[at0007]/events[at0002] EVENT
 * Parent: events /content[at0006]/data[at0007]/events
/content[at0006]/data[at0007]/events[at0002]/data[at0003] ITEM_TREE
 * Parent: data /content[at0006]/data[at0007]/events[at0002]/data
/content[at0006]/data[at0007]/events[at0002]/data[at0003]/items[at0004] ELEMENT
 * Parent: items /content[at0006]/data[at0007]/events[at0002]/data[at0003]/items
/content[at0006]/data[at0007]/events[at0002]/data[at0003]/items[at0004]/value DvQuantity
 * Parent: value /content[at0006]/data[at0007]/events[at0002]/data[at0003]/items[at0004]/value
/content[at0006]/data[at0007]/events[at0002]/data[at0003]/items[at0005] ELEMENT
 * Parent: items /content[at0006]/data[at0007]/events[at0002]/data[at0003]/items
/content[at0006]/data[at0007]/events[at0002]/data[at0003]/items[at0005]/value DvQuantity
 * Parent: value /content[at0006]/data[at0007]/events[at0002]/data[at0003]/items[at0005]/value
/content[at0008] OBSERVATION
 * Parent: content /content
/content[at0008]/data[at0009] HISTORY
 * Parent: data /content[at0008]/data
/content[at0008]/data[at0009]/events[at0010] EVENT
 * Parent: events /content[at0008]/data[at0009]/events
/content[at0008]/data[at0009]/events[at0010]/data[at0011] ITEM_TREE
 * Parent: data /content[at0008]/data[at0009]/events[at0010]/data
/content[at0008]/data[at0009]/events[at0010]/data[at0011]/items[at0012] ELEMENT
 * Parent: items /content[at0008]/data[at0009]/events[at0010]/data[at0011]/items
/content[at0008]/data[at0009]/events[at0010]/data[at0011]/items[at0012]/value DvQuantity
 * Parent: value /content[at0008]/data[at0009]/events[at0010]/data[at0011]/items[at0012]/value
/content[at0013] OBSERVATION
 * Parent: content /content
/content[at0013]/data[at0014] HISTORY
 * Parent: data /content[at0013]/data
/content[at0013]/data[at0014]/events[at0015] EVENT
 * Parent: events /content[at0013]/data[at0014]/events
/content[at0013]/data[at0014]/events[at0015]/data[at0016] ITEM_TREE
 * Parent: data /content[at0013]/data[at0014]/events[at0015]/data
/content[at0013]/data[at0014]/events[at0015]/data[at0016]/items[at0017] ELEMENT
 * Parent: items /content[at0013]/data[at0014]/events[at0015]/data[at0016]/items
/content[at0013]/data[at0014]/events[at0015]/data[at0016]/items[at0017]/value DvQuantity
 * Parent: value /content[at0013]/data[at0014]/events[at0015]/data[at0016]/items[at0017]/value
/content[at0018] OBSERVATION
 * Parent: content /content
/content[at0018]/data[at0019] HISTORY
 * Parent: data /content[at0018]/data
/content[at0018]/data[at0019]/events[at0020] EVENT
 * Parent: events /content[at0018]/data[at0019]/events
/content[at0018]/data[at0019]/events[at0020]/data[at0021] ITEM_TREE
 * Parent: data /content[at0018]/data[at0019]/events[at0020]/data
/content[at0018]/data[at0019]/events[at0020]/data[at0021]/items[at0022] ELEMENT
 * Parent: items /content[at0018]/data[at0019]/events[at0020]/data[at0021]/items
/content[at0018]/data[at0019]/events[at0020]/data[at0021]/items[at0022]/value DvQuantity
 * Parent: value /content[at0018]/data[at0019]/events[at0020]/data[at0021]/items[at0022]/value
/content[at0023] OBSERVATION
 * Parent: content /content
/content[at0023]/data[at0024] HISTORY
 * Parent: data /content[at0023]/data
/content[at0023]/data[at0024]/events[at0025] EVENT
 * Parent: events /content[at0023]/data[at0024]/events
/content[at0023]/data[at0024]/events[at0025]/data[at0026] ITEM_TREE
 * Parent: data /content[at0023]/data[at0024]/events[at0025]/data
/content[at0023]/data[at0024]/events[at0025]/data[at0026]/items[at0027] ELEMENT
 * Parent: items /content[at0023]/data[at0024]/events[at0025]/data[at0026]/items
/content[at0023]/data[at0024]/events[at0025]/data[at0026]/items[at0027]/value DvQuantity
 * Parent: value /content[at0023]/data[at0024]/events[at0025]/data[at0026]/items[at0027]/value
/content[at0028] OBSERVATION
 * Parent: content /content
/content[at0028]/data[at0029] HISTORY
 * Parent: data /content[at0028]/data
/content[at0028]/data[at0029]/events[at0030] EVENT
 * Parent: events /content[at0028]/data[at0029]/events
/content[at0028]/data[at0029]/events[at0030]/data[at0031] ITEM_TREE
 * Parent: data /content[at0028]/data[at0029]/events[at0030]/data
/content[at0028]/data[at0029]/events[at0030]/data[at0031]/items[at0032] ELEMENT
 * Parent: items /content[at0028]/data[at0029]/events[at0030]/data[at0031]/items
/content[at0028]/data[at0029]/events[at0030]/data[at0031]/items[at0032]/value DvQuantity
 * Parent: value /content[at0028]/data[at0029]/events[at0030]/data[at0031]/items[at0032]/value
/context EVENT_CONTEXT
 * Parent: context /context
/context/other_context[at0001] ITEM_TREE
 * Parent: other_context /context/other_context


This is my test archetype:

archetype (adl_version=1.4)
	openEHR-EHR-COMPOSITION.signos.v1

concept
	[at0000]	-- Signos
language
	original_language = <[ISO_639-1::es]>
description
	original_author = <
		["name"] = <"">
	>
	details = <
		["es"] = <
			language = <[ISO_639-1::es]>
			purpose = <"Signos">
			use = <"">
			misuse = <"">
			copyright = <"">
		>
	>
	lifecycle_state = <"0">
	other_contributors = <>
	other_details = <
		["MD5-CAM-1.0.1"] = <"CA0D9C5FC48EAAEBF0DDCCC29CE382D6">
	>

definition
	COMPOSITION[at0000] matches {	-- Signos
		category matches {
			DV_CODED_TEXT matches {
				defining_code matches {[openehr::433]}
			}
		}
		context matches {
			EVENT_CONTEXT matches {
				other_context matches {
					ITEM_TREE[at0001] matches {*}
				}
			}
		}
		content cardinality matches {0..*; unordered} matches {
			
			OBSERVATION[at0006] matches {	-- Presión Arterial
				data matches {
					HISTORY[at0007] matches {	-- Event Series
						events cardinality matches {1..*; unordered} matches {
							EVENT[at0002] occurrences matches {0..1} matches {	-- Cualquier evento
								data matches {
									ITEM_TREE[at0003] matches {	-- Arbol
										items cardinality matches {0..*; unordered} matches {
											ELEMENT[at0004] occurrences matches {0..1} matches {	-- Sistólica
												value matches {
													C_DV_QUANTITY <
														property = <[openehr::125]>
														list = <
															["1"] = <
																units = <"mm[Hg]">
																magnitude = <|0.0..400.0|>
															>
														>
													>
												}
											}
											ELEMENT[at0005] occurrences matches {0..1} matches {	-- Diastólica
												value matches {
													C_DV_QUANTITY <
														property = <[openehr::125]>
														list = <
															["1"] = <
																units = <"mm[Hg]">
																magnitude = <|0.0..400.0|>
															>
														>
													>
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			
			OBSERVATION[at0008] matches {	-- Temperatura corporal
				data matches {
					HISTORY[at0009] matches {	-- Event Series
						events cardinality matches {1..*; unordered} matches {
							EVENT[at0010] occurrences matches {0..1} matches {	-- Cualquier evento
								data matches {
									ITEM_TREE[at0011] matches {	-- Arbol
										items cardinality matches {0..*; unordered} matches {
											ELEMENT[at0012] occurrences matches {0..1} matches {	-- Temperatura
												value matches {
													C_DV_QUANTITY <
														property = <[openehr::127]>
														list = <
															["1"] = <
																units = <"ºC">
																magnitude = <|0.0..50.0|>
															>
															["2"] = <
																units = <"ºF">
																magnitude = <|32.0..122.0|>
															>
														>
													>
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
	
			OBSERVATION[at0013] matches {	-- Frecuencia cardiaca
				data matches {
					HISTORY[at0014] matches {	-- Event Series
						events cardinality matches {1..*; unordered} matches {
							EVENT[at0015] occurrences matches {0..1} matches {	-- Cualquier evento
								data matches {
									ITEM_TREE[at0016] matches {	-- Arbol
										items cardinality matches {0..*; unordered} matches {
											ELEMENT[at0017] occurrences matches {0..1} matches {	-- Frecuencia Cardiaca
												value matches {
													C_DV_QUANTITY <
														property = <[openehr::382]>
														list = <
															["1"] = <
																units = <"/min">
															>
														>
													>
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			

			OBSERVATION[at0018] matches {	-- Frecuencia respiratoria
				data matches {
					HISTORY[at0019] matches {	-- Event Series
						events cardinality matches {1..*; unordered} matches {
							EVENT[at0020] occurrences matches {0..1} matches {	-- Cualquier evento
								data matches {
									ITEM_TREE[at0021] matches {	-- Arbol
										items cardinality matches {0..*; unordered} matches {
											ELEMENT[at0022] occurrences matches {0..1} matches {	-- Frecuencia Respiratoria
												value matches {
													C_DV_QUANTITY <
														property = <[openehr::382]>
														list = <
															["1"] = <
																units = <"/min">
															>
														>
													>
												}
											}
										}
									}
								}
							}
						}
					}
				}
			} -- frec resp
			
			
			OBSERVATION[at0023] matches {	-- Peso corporal
				data matches {
					HISTORY[at0024] matches {	-- Event Series
						events cardinality matches {1..*; unordered} matches {
							EVENT[at0025] occurrences matches {0..1} matches {	-- Cualquier evento
								data matches {
									ITEM_TREE[at0026] matches {	-- Arbol
										items cardinality matches {0..*; unordered} matches {
											ELEMENT[at0027] occurrences matches {0..1} matches {	-- Peso
												value matches {
													C_DV_QUANTITY <
														property = <[openehr::124]>
														list = <
															["1"] = <
																units = <"kg">
																magnitude = <|0.0..400.0|>
															>
														>
													>
												}
											}
										}
									}
								}
							}
						}
					}
				}
			} -- peso
			
			OBSERVATION[at0028] matches {	-- Estatura
				data matches {
					HISTORY[at0029] matches {	-- Event Series
						events cardinality matches {1..*; unordered} matches {
							EVENT[at0030] occurrences matches {0..1} matches {	-- Cualquier evento
								data matches {
									ITEM_TREE[at0031] matches {	-- Arbol
										items cardinality matches {0..*; unordered} matches {
											ELEMENT[at0032] occurrences matches {0..1} matches {	-- Estatura
												value matches {
													C_DV_QUANTITY <
														property = <[openehr::122]>
														list = <
															["1"] = <
																units = <"cm">
																magnitude = <|0.0..250.0|>
															>
														>
													>
												}
											}
										}
									}
								}
							}
						}
					}
				}
			} -- estatura / talla
		}
	}

ontology
	term_definitions = <
		["es"] = <
			items = <
				["at0000"] = <
					text = <"Signos">
					description = <"Registro de signos">
				>
				["at0001"] = <
					text = <"Arbol">
					description = <"@ internal @">
				>
				
				-- presion arterial
				["at0006"] = <
					text = <"Presión Arterial">
					description = <"unknown">
				>
				["at0007"] = <
					text = <"Event Series">
					description = <"@ internal @">
				>
				["at0002"] = <
					text = <"Cualquier evento">
					description = <"*">
				>
				["at0003"] = <
					text = <"Arbol">
					description = <"@ internal @">
				>
				["at0004"] = <
					text = <"Sistólica">
					description = <"*">
				>
				["at0005"] = <
					text = <"Diastólica">
					description = <"*">
				>
				-- presion arterial
				
				-- temperatura
				["at0008"] = <
					text = <"Temperatura corporal">
					description = <"unknown">
				>
				["at0009"] = <
					text = <"Event Series">
					description = <"@ internal @">
				>
				["at0010"] = <
					text = <"Cualquier evento">
					description = <"*">
				>
				["at0011"] = <
					text = <"Arbol">
					description = <"@ internal @">
				>
				["at0012"] = <
					text = <"Temperatura">
					description = <"*">
				>
				-- temperatura
				
				-- frec cardiaca
				["at0013"] = <
					text = <"Frecuencia cardiaca">
					description = <"unknown">
				>
				["at0014"] = <
					text = <"Event Series">
					description = <"@ internal @">
				>
				["at0015"] = <
					text = <"Cualquier evento">
					description = <"*">
				>
				["at0016"] = <
					text = <"Arbol">
					description = <"@ internal @">
				>
				["at0017"] = <
					text = <"Frecuencia Cardiaca">
					description = <"*">
				>
				-- frec cardiaca
				
				-- frec resp
				["at0018"] = <
					text = <"Frecuencia respiratoria">
					description = <"unknown">
				>
				["at0019"] = <
					text = <"Event Series">
					description = <"@ internal @">
				>
				["at0020"] = <
					text = <"Cualquier evento">
					description = <"*">
				>
				["at0021"] = <
					text = <"Arbol">
					description = <"@ internal @">
				>
				["at0022"] = <
					text = <"Frecuencia Respiratoria">
					description = <"*">
				>
				-- frec resp
				
				-- peso
				["at0023"] = <
					text = <"Peso corporal">
					description = <"unknown">
				>
				["at0024"] = <
					text = <"Event Series">
					description = <"@ internal @">
				>
				["at0025"] = <
					text = <"Cualquier evento">
					description = <"*">
				>
				["at0026"] = <
					text = <"Arbol">
					description = <"@ internal @">
				>
				["at0027"] = <
					text = <"Peso">
					description = <"*">
				>
				-- peso
				
				-- estatura / talla
				["at0028"] = <
					text = <"Estatura">
					description = <"unknown">
				>
				["at0029"] = <
					text = <"Event Series">
					description = <"@ internal @">
				>
				["at0030"] = <
					text = <"Cualquier evento">
					description = <"*">
				>
				["at0031"] = <
					text = <"Arbol">
					description = <"@ internal @">
				>
				["at0032"] = <
					text = <"Estatura">
					description = <"*">
				>
				-- estatura / talla
			>
		>
	>