Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 38 additions & 14 deletions howso/hierarchy.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
; type "assoc"
; description "The map showing the full hierarchy of the Trainee and all of its subtrainees."
; }
(assoc)
(assoc
;{type "list" values "string"}
;path to this trainee as a list of path labels
path_list []
)
(call !Return (assoc payload (call !GetHierarchy) ))
)

Expand Down Expand Up @@ -845,22 +849,42 @@
;method to recurse down the the hierarchy to output the currently contained hierarchy as a nested assoc
;with (false) for trainees that are stored independently
#!GetHierarchy
(let
(assoc children (indices !childTraineeIsContainedMap))

(zip
children
(map
(lambda
(if (get !childTraineeIsContainedMap (current_value))
(get (call_entity (list !traineeContainer (current_value 1)) "get_hierarchy") (list 1 "payload"))
(append
!metaData
(assoc
"id" (retrieve_from_entity "!traineeId")
"path" path_list
"contained" (true)
"children"
(map
(lambda
(if (get !childTraineeIsContainedMap (current_value))
(get
(call_entity (list !traineeContainer (current_value 1)) "get_hierarchy" (assoc
path_list
(if (size path_list)
(append path_list (current_value 1))
(current_value 1)
)
))
[1 "payload"]
)

;can't traverse down trainees that are stored externally
(false)
;can't traverse down trainees that are stored externally
(assoc
"id" (get !containedTraineeNameToIdMap (current_value 1))
"path"
(if (size path_list)
(append path_list (current_value 1))
(current_value 1)
)
"contained" (false)
"children" []
)
)
)
(indices !childTraineeIsContainedMap)
)
children
)
)
)

Expand Down
227 changes: 197 additions & 30 deletions unit_tests/ut_h_hierarchy_by_id.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,56 @@

(print "Renames and copies: ")
(call assert_same (assoc
unordered (true)
obs result
exp
(assoc
AA (assoc
b (assoc)
big_C (assoc e (assoc))
)
c_copy (assoc e (assoc))
)
{
contained (true)
id "model"
path []
children [
{
children [
{
children [
{
children []
contained (true)
id "e3"
path ["AA" "big_C" "e"]
}
]
contained (true)
id "c2"
path ["AA" "big_C"]
}
{
children []
contained (true)
id "b2"
path ["AA" "b"]
}
]
contained (true)
id "A1"
path ["AA"]
}
{
children [
{
children []
contained (true)
id "e3"
path ["c_copy" "e"]
}
]
contained (true)
id "deleteme"
path ["c_copy"]
}
]

}
))

(call exit_if_failures (assoc msg "Renaming."))
Expand Down Expand Up @@ -266,15 +307,48 @@
(call keep_result_payload)
(print "Updated is_contained_map has all the c_copy trainees as not contained: ")
(call assert_same (assoc
unordered (true)
obs result
exp
(assoc
AA (assoc
b (assoc)
big_C (assoc e (assoc))
)
c_copy (false)
)
{
children [
{
children [
{
children [
{
children []
contained (true)
id "e3"
path ["AA" "big_C" "e"]
}
]
contained (true)
id "c2"
path ["AA" "big_C"]
}
{
children []
contained (true)
id "b2"
path ["AA" "b"]
}
]
contained (true)
id "A1"
path "AA"
}
{
children []
contained (false)
id "deleteme"
path "c_copy"
}
]
contained (true)
id "model"
path []
}
))

;load into trainee AA
Expand Down Expand Up @@ -331,16 +405,71 @@

(print "Hierarchy for model after save and load is correct: ")
(call assert_same (assoc
unordered (true)
obs result
exp
(assoc
AA (assoc
b (assoc child_of_b (false))
big_C (assoc e (assoc))
loaded (assoc e (assoc))
)
c_copy (false)
)
{
children [
{
children [
{
children [
{
children []
contained (true)
id "e3"
path ["AA" "big_C" "e"]
}
]
contained (true)
id "c2"
path ["AA" "big_C"]
}
{
children [
{
children []
contained (true)
id "e3"
path ["AA" "loaded" "e"]
}
]
contained (true)
id "deleteme"
path ["AA" "loaded"]
}
{
children [
{
children []
contained (false)
id "deleteme2"
path ["AA" "b" "child_of_b"]
}
]
contained (true)
id "b2"
path ["AA" "b"]
}
]
contained (true)
id "A1"
path "AA"
}
{
children []
contained (false)
id "deleteme"
path "c_copy"
}
]
contained (true)
id "model"
path
;{type "string"}
;path to this trainee as a list of path labels
[]
}
))

;cleanup saved test model
Expand Down Expand Up @@ -408,16 +537,54 @@

(print "Hierarchy for model after deletion: ")
(call assert_same (assoc
unordered (true)
obs result
exp
(assoc
AA (assoc
b (assoc)
big_C (assoc e (assoc))
loaded (assoc)
)
c_copy (false)
)
{
children [
{
children [
{
children [
{
children []
contained (true)
id "e3"
path ["AA" "big_C" "e"]
}
]
contained (true)
id "c2"
path ["AA" "big_C"]
}
{
children []
contained (true)
id "deleteme"
path ["AA" "loaded"]
}
{
children []
contained (true)
id "b2"
path ["AA" "b"]
}
]
contained (true)
id "A1"
path "AA"
}
{
children []
contained (false)
id "deleteme"
path "c_copy"
}
]
contained (true)
id "model"
path []
}
))

(call exit_if_failures (assoc msg "delete trainees." ))
Expand Down
Loading