Walk a tree of imported meta

This commit is contained in:
Dan Hawkins 2021-12-13 22:56:07 +00:00
commit 4132c4d470

View file

@ -930,7 +930,36 @@ class MetaInfo extends GISJsonSerialised {
return releasemetaversionuniquecollection
}
def walkrelated(ArrayList<MetaInfo> metacollection, String comment = '', int level = 0) {
def openchildmeta(String gatheredpath, RelatedMetaInfo relatedmetainfo) {
MetaInfo mi = new MetaInfot(script)
String nextpath
if (gatheredpath) {
nextpath = relatedmetainfo.offsetpath
} else {
nextpath = gatheredpath + '/' + relatedmetainfo.offsetpath
}
def importedmetafile = nextpath + '/' + METAFILENAME
def boolean next
if (script.fileExists(importedmetafile)) {
script.echo("Deserialising meta at file: ${importedmetafile}")
mi.deserialiseJson(importedmetafile)
next = true
} else {
script.echo("Could not deserialise meta at file: ${importedmetafile} - Does not exist")
next = false
}
def childmetainfo = [
next: next
nextpath: nextpath,
childmeta: mi
]
return childmetainfo
}
def walkrelated(ArrayList<MetaInfo> metacollection, String comment = '', int level = 0, String gatheredpath = '') {
def results = [
'metacollection' : metacollection,
'comment': comment
@ -938,8 +967,10 @@ class MetaInfo extends GISJsonSerialised {
results.metacollection.add(this)
results.comment += "${level} ".padRight(level * 4) + globalreleasetag() + '\n'
for (relatedmetainfo in associatedmeta) {
MetaInfo othermeta = relatedmetainfo.meta
results = othermeta.walkrelated(results.metacollection, results.comment, level + 1)
def childmetainfo = openchildmeta(gatheredpath, relatedmetainfo)
if (childmetainfo.next) {
results = childmetainfo.mi.walkrelated(results.metacollection, results.comment, level + 1, childmetainfo.nextpath)
}
}
return [ 'metacollection' : results.metacollection, 'comment': results.comment ]
}