Make the walkers carry more meta data

This commit is contained in:
Dan Hawkins 2021-12-16 15:39:32 +00:00
commit ece2670365

View file

@ -914,16 +914,32 @@ class MetaInfo extends GISJsonSerialised {
return buildstampinfo.buildstamp + "-" + jenkinsbuildinfo.buildnumber
}
def openchildmeta(String gatheredpath, RelatedMetaInfo relatedmetainfo) {
class CollectedMeta {
private MetaInfo metainfo
private String accumulatedpath
CollectedMeta(MetaInfo metainfo, String accumulatedpath = '') {
this.metainfo = metainfo
this.accumulatedpath = accumulatedpath
}
}
def openchildmeta(String gatheredpath, String gatheredmetapath, RelatedMetaInfo relatedmetainfo) {
def MetaInfo mi = new MetaInfo(script)
def String nextpath
def String nextgatheredpath
if (gatheredpath == '') {
nextpath = "${relatedmetainfo.offsetpath}/${METAFOLDERNAME}"
nextgatheredpath = "${relatedmetainfo.offsetpath}"
} else {
nextpath = "${gatheredpath}/${relatedmetainfo.offsetpath}"
nextgatheredpath = "${gatheredpath}/${relatedmetainfo.offsetpath}"
}
def importedmetafile = "${nextpath}/${METAFILENAME}"
def String nextgatheredmetapath
if (gatheredmetapath == '') {
nextgatheredmetapath = "${relatedmetainfo.offsetpath}/${METAFOLDERNAME}"
} else {
nextgatheredmetapath = "${gatheredmetapath}/${relatedmetainfo.offsetpath}"
}
def importedmetafile = "${nextgatheredmetapath}/${METAFILENAME}"
def boolean imported
if (script.fileExists(importedmetafile)) {
mi.deserialiseJson(importedmetafile)
@ -935,25 +951,38 @@ class MetaInfo extends GISJsonSerialised {
def childmetainfo = [
'imported': imported,
'nextpath': nextpath,
'nextgatheredpath': nextgatheredpath,
'nextgatheredmetapath': nextgatheredmetapath,
'childmeta': mi
]
return childmetainfo
}
def walkrelated_v0_1(ArrayList<MetaInfo> metacollection, String comment = '', int level = 0, boolean limiteddepth = false, int maxdepth = 0) {
script.echo("walkrelated_v0_1 Iteration:\nLevel: ${level}\nLimited depth: ${limiteddepth}\nMax depth: ${maxdepth}")
def walkrelated_v0_1(ArrayList<CollectedMeta> metacollection,
String comment = '',
int level = 0,
String gatheredpath = '',
String gatheredmetapath = '',
boolean limiteddepth = false,
int maxdepth = 0) {
script.echo("walkrelated_v0_1 Iteration:\nLevel: ${level}\nGathered path: ${gatheredpath}\nGathered meta path: ${gatheredmetapath}\nLimited depth: ${limiteddepth}\nMax depth: ${maxdepth}")
def results = [
'metacollection' : metacollection,
'comment': comment
]
if (!limiteddepth || maxdepth > 0) {
results.metacollection.add(this)
results.metacollection.add(new CollectedMeta(this, gatheredpath))
results.comment += "${level} ".padRight(level * 4) + globalreleasetag() + '\n'
for (relatedmetainfo in associatedmeta) {
if (!relatedmetainfo.format || relatedmetainfo.format == '0.1') {
def MetaInfo othermeta = relatedmetainfo.meta
results = othermeta.walkrelated_v0_1(results.metacollection, results.comment, level + 1, limiteddepth, maxdepth - 1)
results = othermeta.walkrelated_v0_1(results.metacollection,
results.comment,
level + 1,
"${gatheredpath}/${relatedmetainfo.offsetpath}",
"${gatheredmetapath}/${relatedmetainfo.offsetpath}",
limiteddepth,
maxdepth - 1)
} else {
script.error("There is non v0.1 format related meta info under v0.1 related meta info")
}
@ -962,24 +991,36 @@ class MetaInfo extends GISJsonSerialised {
return [ 'metacollection' : results.metacollection, 'comment': results.comment ]
}
def walkrelated(ArrayList<MetaInfo> metacollection, String comment = '', int level = 0, String gatheredpath = '', boolean limiteddepth = false, int maxdepth = 0) {
script.echo("walkrelated Iteration:\nLevel: ${level}\nGathered path: ${gatheredpath}\nLimited depth: ${limiteddepth}\nMax depth: ${maxdepth}")
def walkrelated(ArrayList<CollectedMeta> metacollection,
String comment = '',
int level = 0,
String gatheredpath = '',
String gatheredmetapath = '',
boolean limiteddepth = false,
int maxdepth = 0) {
script.echo("walkrelated Iteration:\nLevel: ${level}\nGathered path: ${gatheredpath}\nGathered meta path: ${gatheredmetapath}\nLimited depth: ${limiteddepth}\nMax depth: ${maxdepth}")
def results = [
'metacollection' : metacollection,
'comment': comment
]
if (!limiteddepth || maxdepth > 0) {
results.metacollection.add(this)
results.metacollection.add(new CollectedMeta(this, gatheredpath))
results.comment += "${level} ".padRight(level * 4) + globalreleasetag() + '\n'
for (relatedmetainfo in associatedmeta) {
if (relatedmetainfo.format == '0.2') {
def childmetainfo = openchildmeta(gatheredpath, relatedmetainfo)
def childmetainfo = openchildmeta(gatheredpath, gatheredmetapath, relatedmetainfo)
if (childmetainfo.imported) {
results = childmetainfo.childmeta.walkrelated(results.metacollection, results.comment, level + 1, childmetainfo.nextpath, limiteddepth, maxdepth - 1)
results = childmetainfo.childmeta.walkrelated(results.metacollection,
results.comment,
level + 1,
childmetainfo.nextgatheredpath
childmetainfo.nextgatheredmetapath,
limiteddepth,
maxdepth - 1)
}
} else if (relatedmetainfo.format == '0.1') {
def MetaInfo othermeta = relatedmetainfo.meta
results = othermeta.walkrelated_v0_1(results.metacollection, results.comment, level + 1, limiteddepth, maxdepth - 1)
results = othermeta.walkrelated_v0_1(results.metacollection, results.comment, level + 1, gatheredpath, gatheredmetapath, limiteddepth, maxdepth - 1)
}
}
}
@ -987,23 +1028,23 @@ class MetaInfo extends GISJsonSerialised {
}
def allrelatedmeta() {
ArrayList<MetaInfo> metacollection = new ArrayList<MetaInfo>()
ArrayList<CollectedMeta> metacollection = new ArrayList<CollectedMeta>()
return walkrelated(metacollection)
}
ArrayList<MetaInfo> releasewalker(int maxdepth, String startpath = '') {
def ArrayList<MetaInfo> metacollection = new ArrayList<MetaInfo>()
def results = walkrelated(metacollection, 'meta', 0, startpath, true, maxdepth)
ArrayList<CollectedMeta> releasewalker(int maxdepth, String startpath = '', String startmetapath = '') {
def ArrayList<CollectedMeta> metacollection = new ArrayList<CollectedMeta>()
def results = walkrelated(metacollection, 'meta', 0, startpath, startmetapath, true, maxdepth)
return results.metacollection
}
Map<String, MetaInfo> releasewalkerversionunique(int maxdepth, String startpath = '') {
def ArrayList<MetaInfo> metacollection = releasewalker(maxdepth, "${startpath}/${METAFOLDERNAME}")
Map<String, CollectedMeta> releasewalkerversionunique(int maxdepth, String startpath = '', String startmetapath = '') {
def ArrayList<CollectedMeta> metacollection = releasewalker(maxdepth, "${startpath}/${METAFOLDERNAME}", startmetapath)
def Map<String, MetaInfo> versionuniquecollection = new LinkedHashMap<String, MetaInfo>()
for (metainfo in metacollection) {
def String uniquestring = metainfo.componentversionuniqueidentifier()
versionuniquecollection.put(uniquestring, metainfo)
def Map<String, CollectedMeta> versionuniquecollection = new LinkedHashMap<String, CollectedMeta>()
for (metaitem in metacollection) {
def String uniquestring = metaitem.metainfo.componentversionuniqueidentifier()
versionuniquecollection.put(uniquestring, metaitem)
}
return versionuniquecollection
@ -1013,9 +1054,9 @@ class MetaInfo extends GISJsonSerialised {
def ArrayList<MetaInfo> metacollection = releasewalker(maxdepth, "${startpath}/${METAFOLDERNAME}")
def Map<String, MetaInfo> uniquecollection = new LinkedHashMap<String, MetaInfo>()
for (metainfo in metacollection) {
def String uniquestring = metainfo.componentidentifier()
uniquecollection.put(uniquestring, metainfo)
for (metaitem in metacollection) {
def String uniquestring = metaitem.metainfo.componentidentifier()
uniquecollection.put(uniquestring, metaitem)
}
return uniquecollection
@ -1027,15 +1068,15 @@ class MetaInfo extends GISJsonSerialised {
def findAssociatedMeta(String productname, String subcomponentname) {
def results = [
'matchedmeta' : getNewMetaObject(this),
'matchedmetaitem' : new CollectedMeta(this),
'matchfound' : false
]
def walkresults = allrelatedmeta()
for (dependentmeta in walkresults.metacollection) {
if (dependentmeta.productinfo.productname == productname &&
dependentmeta.productinfo.subcomponentname == subcomponentname) {
script.echo("Found matching component: ${dependentmeta.globalreleasetag()}")
results.matchedmeta = dependentmeta
for (dependentmetaitem in walkresults.metacollection) {
if (dependentmetaitem.metainfo.productinfo.productname == productname &&
dependentmetaitem.metainfo.productinfo.subcomponentname == subcomponentname) {
script.echo("Found matching component: ${dependentmetaitem.metainfo.globalreleasetag()}")
results.matchedmetaitem = dependentmetaitem
results.matchfound = true
break
}