From ebb151dceaa14f4ab1f8c8d513d15f557a771c10 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 21 Dec 2021 16:10:31 +0000 Subject: [PATCH 01/17] Add a unique id to each product --- meta/folder.groovy | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index f72b502..071ec9d 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -24,16 +24,18 @@ class ProductInfo extends GISJsonSerialised { private String productname private String subcomponentname private String variant + private String uniqueid - ProductInfo(script, productname = "", subcomponentname = "", variant = "") { + ProductInfo(script, String productname = '', String subcomponentname = '', String variant = '') { super(script) this.format = '0.1' this.productname = productname this.subcomponentname = subcomponentname this.variant = variant + this.uniqueid = UUID.randomUUID().toString() } - void set(String productname, String subcomponentname, String variant = '') { + void set(String productname, String subcomponentname, String variant = '', ) { // Make sure the fields can be used in git tags def int pstatus = 0 if (script.isUnix()) { @@ -76,13 +78,15 @@ class ProductInfo extends GISJsonSerialised { this.productname = otherinfo.productname this.subcomponentname = otherinfo.subcomponentname this.variant = otherinfo.variant + this.uniqueid = otherinfo.uniqueid } void deserialiseJson(rawmeta) { //format = rawmeta['format'] productname = rawmeta['productname'] subcomponentname = rawmeta['subcomponentname'] - variant = rawmeta['variant'] ?: "" + variant = rawmeta['variant'] ?: '' + uniqueid = rawmeta['uniqueid'] ?: uniqueid } LinkedHashMap serialisationdata() { @@ -91,6 +95,7 @@ class ProductInfo extends GISJsonSerialised { 'productname' : productname, 'subcomponentname' : subcomponentname, 'variant' : variant, + 'uniqueid': uniqueid, ] return data } @@ -104,7 +109,7 @@ class GitInfo extends GISJsonSerialised { private String remoteurl private String remoteinfo - GitInfo(script, sourcepath = "", sourcerevision = "", gitrevision = "", remoteurl = "", remoteinfo = "") { + GitInfo(script, sourcepath = '', sourcerevision = '', gitrevision = '', remoteurl = '', remoteinfo = '') { super(script) this.format = '0.1' this.sourcepath = sourcepath @@ -204,7 +209,7 @@ class JenkinsBuildInfo extends GISJsonSerialised { private ArrayList parameters private boolean isfullbuild - JenkinsBuildInfo(script, String buildjobname = "", int buildnumber = 0, String buildmachine = "", String builddate = "", boolean isfullbuild = true) { + JenkinsBuildInfo(script, String buildjobname = '', int buildnumber = 0, String buildmachine = '', String builddate = '', boolean isfullbuild = true) { super(script) this.format = '0.1' this.buildjobname = buildjobname @@ -370,7 +375,7 @@ class ReleaseInfo extends GISJsonSerialised { private ArrayList releaseitems private boolean released - ReleaseInfo(script, String releaserepoURL = "", boolean released = false) { + ReleaseInfo(script, String releaserepoURL = '', boolean released = false) { super(script) this.format = '0.1' this.releaserepoURL = releaserepoURL @@ -378,7 +383,7 @@ class ReleaseInfo extends GISJsonSerialised { this.released = released } - void set(String releaserepoURL = "") { + void set(String releaserepoURL = '') { this.releaserepoURL = releaserepoURL } @@ -426,7 +431,7 @@ class ConfigurationInfo extends GISJsonSerialised { private String configurationversion private String configurationSHA - ConfigurationInfo(script, configurationname = "", configurationURL = "", configurationversion = "", configurationSHA = "") { + ConfigurationInfo(script, configurationname = '', configurationURL = '', configurationversion = '', configurationSHA = '') { super(script) this.configurationname = configurationname this.configurationURL = configurationURL @@ -456,7 +461,7 @@ class ChecksumPair extends GISJsonSerialised { private String filepath private String sum - ChecksumPair(script, String filepath = "", String sum = "") { + ChecksumPair(script, String filepath = '', String sum = '') { super(script) this.filepath = filepath this.sum = sum @@ -481,7 +486,7 @@ class ChecksumSet extends GISJsonSerialised { private String artifactpath private ArrayList checksumpairs - ChecksumSet(script, artifactpath = "") { + ChecksumSet(script, artifactpath = '') { super(script) this.format = '0.1' this.artifactpath = artifactpath @@ -566,7 +571,7 @@ class PublishableInfo extends GISJsonSerialised { private String format private String filepath - PublishableInfo(script, String filepath = "") { + PublishableInfo(script, String filepath = '') { super(script) this.format = '0.1' this.filepath = filepath @@ -613,7 +618,7 @@ class MetaInfo extends GISJsonSerialised { private MetaInfo meta private String offsetpath - RelatedMetaInfo_v0_1(script, offsetpath = "", MetaInfo meta = null) { + RelatedMetaInfo_v0_1(script, offsetpath = '', MetaInfo meta = null) { super(script, '0.1') this.offsetpath = offsetpath this.meta = meta @@ -639,7 +644,7 @@ class MetaInfo extends GISJsonSerialised { private String importpath private String offsetpath - RelatedMetaInfo_v0_2(script, importpath = "", offsetpath = "") { + RelatedMetaInfo_v0_2(script, importpath = '', offsetpath = '') { super(script, '0.2') this.importpath = importpath this.offsetpath = offsetpath @@ -1106,13 +1111,13 @@ MetaInfo metareset(script) { return mi } -MetaInfo metafromfolder(String folder = "") { +MetaInfo metafromfolder(String folder = '') { MetaInfo buildmeta = new MetaInfo(this) buildmeta.deserialiseJson("${folder}/${MetaInfo.metafilepath()}") return buildmeta } -MetaInfo metafromfolderSlurper(String folder = "") { +MetaInfo metafromfolderSlurper(String folder = '') { MetaInfo buildmeta = new MetaInfo(this) buildmeta.deserialiseJsonSlurper("${folder}/${MetaInfo.metafilepath()}") return buildmeta From 71a3a926722ab833fe54cd9c5f73f04476f29c94 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 21 Dec 2021 16:12:21 +0000 Subject: [PATCH 02/17] Add a unique id to each product --- meta/folder.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index 071ec9d..4193f7e 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -35,7 +35,7 @@ class ProductInfo extends GISJsonSerialised { this.uniqueid = UUID.randomUUID().toString() } - void set(String productname, String subcomponentname, String variant = '', ) { + void set(String productname, String subcomponentname, String variant = '') { // Make sure the fields can be used in git tags def int pstatus = 0 if (script.isUnix()) { From 902ec6591ad3e778a04956124a7ae6f0408bc516 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 21 Dec 2021 17:14:26 +0000 Subject: [PATCH 03/17] Use an iteration variable in walker --- meta/folder.groovy | 143 +++++++++++++++++++++++++-------------------- 1 file changed, 80 insertions(+), 63 deletions(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index 4193f7e..163ff2a 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -925,11 +925,41 @@ class MetaInfo extends GISJsonSerialised { } } - def openchildmeta(String gatheredpath, String gatheredmetapath, RelatedMetaInfo relatedmetainfo) { + class IterationInfo { + private ArrayList metacollection + private String comment + private int level + private String gatheredpath + private String gatheredmetapath + private boolean limiteddepth + private int maxdepth + + IterationInfo(ArrayList metacollection = new ArrayList(), + String comment = '', + int level = 0, + String gatheredpath = '', + String gatheredmetapath = '', + boolean limiteddepth = false, + int maxdepth = 0) { + this.metacollection = metacollection + this.comment = comment + this.level = level + this.gatheredpath = gatheredpath + this.gatheredmetapath = gatheredmetapath + this.limiteddepth = limiteddepth + this.maxdepth = maxdepth + } + + String show() { + return "Iteration:\nLevel: ${level}\nGathered path: ${gatheredpath}\nGathered meta path: ${gatheredmetapath}\nLimited depth: ${limiteddepth}\nMax depth: ${maxdepth}" + } + } + + def openchildmeta(IterationInfo ii, RelatedMetaInfo relatedmetainfo) { def MetaInfo mi = new MetaInfo(script) - def String nextgatheredpath = (gatheredpath == '' ? relatedmetainfo.offsetpath : "${gatheredpath}/${relatedmetainfo.offsetpath}") - def String nextgatheredmetapath = (gatheredmetapath == '' ? "${relatedmetainfo.offsetpath}/${METAFOLDERNAME}" : "${gatheredmetapath}/${relatedmetainfo.offsetpath}") + def String nextgatheredpath = (ii.gatheredpath == '' ? relatedmetainfo.offsetpath : "${ii.gatheredpath}/${relatedmetainfo.offsetpath}") + def String nextgatheredmetapath = (ii.gatheredmetapath == '' ? "${relatedmetainfo.offsetpath}/${METAFOLDERNAME}" : "${ii.gatheredmetapath}/${relatedmetainfo.offsetpath}") def importedmetafile = "${nextgatheredmetapath}/${METAFILENAME}" def boolean imported if (script.fileExists(importedmetafile)) { @@ -949,92 +979,79 @@ class MetaInfo extends GISJsonSerialised { return childmetainfo } - def walkrelated_v0_1(ArrayList 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(new CollectedMeta(this, gatheredpath, gatheredmetapath)) - results.comment += "${level} ".padRight(level * 4) + globalreleasetag() + '\n' + def walkrelated_v0_1(IterationInfo ii) { + script.echo("Walk related v0.1: ${ii.show()}") + if (!ii.limiteddepth || ii.maxdepth > 0) { + ii.metacollection.add(new CollectedMeta(this, ii.gatheredpath, ii.gatheredmetapath)) + ii.comment += "${ii.level} ".padRight(ii.level * 4) + globalreleasetag() + '\n' for (relatedmetainfo in associatedmeta) { if (!relatedmetainfo.format || relatedmetainfo.format == '0.1') { def MetaInfo othermeta = relatedmetainfo.meta - def String nextgatheredpath = (gatheredpath == '' ? relatedmetainfo.offsetpath : "${gatheredpath}/${relatedmetainfo.offsetpath}") - def String nextgatheredmetapath = (gatheredmetapath == '' ? relatedmetainfo.offsetpath : "${gatheredmetapath}/${relatedmetainfo.offsetpath}") - results = othermeta.walkrelated_v0_1(results.metacollection, - results.comment, - level + 1, - nextgatheredpath, - nextgatheredmetapath, - limiteddepth, - maxdepth - 1) + def String nextgatheredpath = (ii.gatheredpath == '' ? relatedmetainfo.offsetpath : "${ii.gatheredpath}/${relatedmetainfo.offsetpath}") + def String nextgatheredmetapath = (ii.gatheredmetapath == '' ? relatedmetainfo.offsetpath : "${ii.gatheredmetapath}/${relatedmetainfo.offsetpath}") + def nextii = new IterationInfo(ii.metacollection, + ii.comment, + ii.level + 1, + nextgatheredpath, + nextgatheredmetapath, + ii.limiteddepth + ii.maxdepth - 1) + def results = othermeta.walkrelated_v0_1(nextii) + ii.metacollection = results.metacollection + ii.comment = results.comment } else { script.error("There is non v0.1 format related meta info under v0.1 related meta info") } } } - return [ 'metacollection' : results.metacollection, 'comment': results.comment ] + return [ 'metacollection' : ii.metacollection, 'comment': ii.comment ] } - def walkrelated(ArrayList 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(new CollectedMeta(this, gatheredpath, gatheredmetapath)) - results.comment += "${level} ".padRight(level * 4) + globalreleasetag() + '\n' + def walkrelated(IterationInfo ii) { + script.echo("Walk related: ${ii.show()}") + if (!ii.limiteddepth || ii.maxdepth > 0) { + ii.metacollection.add(new CollectedMeta(this, ii.gatheredpath, ii.gatheredmetapath)) + ii.comment += "${ii.level} ".padRight(ii.level * 4) + globalreleasetag() + '\n' for (relatedmetainfo in associatedmeta) { script.echo("Related meta info: ${relatedmetainfo.offsetpath} format: ${relatedmetainfo.format}") if (relatedmetainfo.format == '0.2') { - def childmetainfo = openchildmeta(gatheredpath, gatheredmetapath, relatedmetainfo) + def childmetainfo = openchildmeta(ii, relatedmetainfo) if (childmetainfo.imported) { - results = childmetainfo.childmeta.walkrelated(results.metacollection, - results.comment, - level + 1, - childmetainfo.nextgatheredpath, - childmetainfo.nextgatheredmetapath, - limiteddepth, - maxdepth - 1) + def nextii = new IterationInfo(ii.metacollection, + ii.comment, + ii.level + 1, + childmetainfo.nextgatheredpath, + childmetainfo.nextgatheredmetapath, + ii.limiteddepth + ii.maxdepth - 1) + def results = childmetainfo.childmeta.walkrelated(nextii) + ii.metacollection = results.metacollection + ii.comment = results.comment } } else if (!relatedmetainfo.format || relatedmetainfo.format == '0.1') { def MetaInfo othermeta = relatedmetainfo.meta - results = othermeta.walkrelated_v0_1(results.metacollection, - results.comment, - level + 1, - gatheredpath, - gatheredmetapath, - limiteddepth, - maxdepth - 1) + def nextii = new IterationInfo(ii.metacollection, + ii.comment, + ii.level + 1, + ii.gatheredpath, + ii.gatheredmetapath, + ii.limiteddepth + ii.maxdepth - 1) + def results = othermeta.walkrelated_v0_1(nextii) + ii.metacollection = results.metacollection + ii.comment = results.comment } } } - return [ 'metacollection' : results.metacollection, 'comment': results.comment ] + return [ 'metacollection' : ii.metacollection, 'comment': ii.comment ] } def allrelatedmeta(String metapath = '') { - ArrayList metacollection = new ArrayList() - return walkrelated(metacollection, '', 0, '', metapath) + return walkrelated(new IterationInfo(metacollection, '', 0, '', metapath)) } ArrayList releasewalker(int maxdepth, String startpath = '', String startmetapath = '') { - def ArrayList metacollection = new ArrayList() - def results = walkrelated(metacollection, 'meta', 0, startpath, startmetapath, true, maxdepth) + def results = walkrelated(new IterationInfo(metacollection, 'meta', 0, startpath, startmetapath, true, maxdepth)) return results.metacollection } From bfb7d9fa4c96196dd7e532b4469bd4b149776656 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 21 Dec 2021 17:17:36 +0000 Subject: [PATCH 04/17] Use an iteration variable in walker --- meta/folder.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index 163ff2a..71277e5 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -994,7 +994,7 @@ class MetaInfo extends GISJsonSerialised { ii.level + 1, nextgatheredpath, nextgatheredmetapath, - ii.limiteddepth + ii.limiteddepth, ii.maxdepth - 1) def results = othermeta.walkrelated_v0_1(nextii) ii.metacollection = results.metacollection @@ -1022,7 +1022,7 @@ class MetaInfo extends GISJsonSerialised { ii.level + 1, childmetainfo.nextgatheredpath, childmetainfo.nextgatheredmetapath, - ii.limiteddepth + ii.limiteddepth, ii.maxdepth - 1) def results = childmetainfo.childmeta.walkrelated(nextii) ii.metacollection = results.metacollection @@ -1035,7 +1035,7 @@ class MetaInfo extends GISJsonSerialised { ii.level + 1, ii.gatheredpath, ii.gatheredmetapath, - ii.limiteddepth + ii.limiteddepth, ii.maxdepth - 1) def results = othermeta.walkrelated_v0_1(nextii) ii.metacollection = results.metacollection From 0122ee498c220a9213ab1cc4e038c946b5debdac Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 21 Dec 2021 17:26:36 +0000 Subject: [PATCH 05/17] Use an iteration variable in walker --- meta/folder.groovy | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index 71277e5..e29f8ff 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -927,6 +927,7 @@ class MetaInfo extends GISJsonSerialised { class IterationInfo { private ArrayList metacollection + private Map() metamap private String comment private int level private String gatheredpath @@ -935,6 +936,7 @@ class MetaInfo extends GISJsonSerialised { private int maxdepth IterationInfo(ArrayList metacollection = new ArrayList(), + Map metamap = new Map(), String comment = '', int level = 0, String gatheredpath = '', @@ -942,6 +944,7 @@ class MetaInfo extends GISJsonSerialised { boolean limiteddepth = false, int maxdepth = 0) { this.metacollection = metacollection + this.metamap = metamap this.comment = comment this.level = level this.gatheredpath = gatheredpath @@ -990,6 +993,7 @@ class MetaInfo extends GISJsonSerialised { def String nextgatheredpath = (ii.gatheredpath == '' ? relatedmetainfo.offsetpath : "${ii.gatheredpath}/${relatedmetainfo.offsetpath}") def String nextgatheredmetapath = (ii.gatheredmetapath == '' ? relatedmetainfo.offsetpath : "${ii.gatheredmetapath}/${relatedmetainfo.offsetpath}") def nextii = new IterationInfo(ii.metacollection, + ii.metamap, ii.comment, ii.level + 1, nextgatheredpath, @@ -1018,6 +1022,7 @@ class MetaInfo extends GISJsonSerialised { def childmetainfo = openchildmeta(ii, relatedmetainfo) if (childmetainfo.imported) { def nextii = new IterationInfo(ii.metacollection, + ii.metamap, ii.comment, ii.level + 1, childmetainfo.nextgatheredpath, @@ -1031,6 +1036,7 @@ class MetaInfo extends GISJsonSerialised { } else if (!relatedmetainfo.format || relatedmetainfo.format == '0.1') { def MetaInfo othermeta = relatedmetainfo.meta def nextii = new IterationInfo(ii.metacollection, + ii.metamap, ii.comment, ii.level + 1, ii.gatheredpath, @@ -1046,12 +1052,13 @@ class MetaInfo extends GISJsonSerialised { return [ 'metacollection' : ii.metacollection, 'comment': ii.comment ] } - def allrelatedmeta(String metapath = '') { - return walkrelated(new IterationInfo(metacollection, '', 0, '', metapath)) + def allrelatedmeta(String metapath = '') {, + Map metamap = + return walkrelated(new IterationInfo(new ArrayList(), new Map(), '', 0, '', metapath)) } ArrayList releasewalker(int maxdepth, String startpath = '', String startmetapath = '') { - def results = walkrelated(new IterationInfo(metacollection, 'meta', 0, startpath, startmetapath, true, maxdepth)) + def results = walkrelated(new IterationInfo(new ArrayList(), new Map(), 'meta', 0, startpath, startmetapath, true, maxdepth)) return results.metacollection } From 72b5f6de79a844fec715fba67bc3decc0e738253 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 21 Dec 2021 17:30:16 +0000 Subject: [PATCH 06/17] Use an iteration variable in walker --- meta/folder.groovy | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index e29f8ff..f8f7cd2 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -927,7 +927,7 @@ class MetaInfo extends GISJsonSerialised { class IterationInfo { private ArrayList metacollection - private Map() metamap + private Map metamap private String comment private int level private String gatheredpath @@ -1002,13 +1002,14 @@ class MetaInfo extends GISJsonSerialised { ii.maxdepth - 1) def results = othermeta.walkrelated_v0_1(nextii) ii.metacollection = results.metacollection + ii.metamap = results.metamap ii.comment = results.comment } else { script.error("There is non v0.1 format related meta info under v0.1 related meta info") } } } - return [ 'metacollection' : ii.metacollection, 'comment': ii.comment ] + return [ 'metacollection' : ii.metacollection, 'metamap' : ii.metamap, 'comment': ii.comment ] } def walkrelated(IterationInfo ii) { @@ -1031,6 +1032,7 @@ class MetaInfo extends GISJsonSerialised { ii.maxdepth - 1) def results = childmetainfo.childmeta.walkrelated(nextii) ii.metacollection = results.metacollection + ii.metamap = results.metamap ii.comment = results.comment } } else if (!relatedmetainfo.format || relatedmetainfo.format == '0.1') { @@ -1045,11 +1047,12 @@ class MetaInfo extends GISJsonSerialised { ii.maxdepth - 1) def results = othermeta.walkrelated_v0_1(nextii) ii.metacollection = results.metacollection + ii.metamap = results.metamap ii.comment = results.comment } } } - return [ 'metacollection' : ii.metacollection, 'comment': ii.comment ] + return [ 'metacollection' : ii.metacollection, 'metamap' : ii.metamap, 'comment': ii.comment ] } def allrelatedmeta(String metapath = '') {, From fd8a3824bd51dca279f02e37b5d703a42de9c150 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 21 Dec 2021 17:35:42 +0000 Subject: [PATCH 07/17] Use an iteration variable in walker --- meta/folder.groovy | 1 - 1 file changed, 1 deletion(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index f8f7cd2..7046bcf 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -1056,7 +1056,6 @@ class MetaInfo extends GISJsonSerialised { } def allrelatedmeta(String metapath = '') {, - Map metamap = return walkrelated(new IterationInfo(new ArrayList(), new Map(), '', 0, '', metapath)) } From 345d6f2e8ce4f67d0108d972bfb720575cb017f4 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 21 Dec 2021 17:36:45 +0000 Subject: [PATCH 08/17] Use an iteration variable in walker --- meta/folder.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index 7046bcf..e1549fd 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -1055,7 +1055,7 @@ class MetaInfo extends GISJsonSerialised { return [ 'metacollection' : ii.metacollection, 'metamap' : ii.metamap, 'comment': ii.comment ] } - def allrelatedmeta(String metapath = '') {, + def allrelatedmeta(String metapath = '') { return walkrelated(new IterationInfo(new ArrayList(), new Map(), '', 0, '', metapath)) } From 904e2cc20fa6228c2cddd16d47c4b16f768a3eb5 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 21 Dec 2021 17:41:59 +0000 Subject: [PATCH 09/17] Use an iteration variable in walker --- meta/folder.groovy | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index e1549fd..ac8fa23 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -935,8 +935,8 @@ class MetaInfo extends GISJsonSerialised { private boolean limiteddepth private int maxdepth - IterationInfo(ArrayList metacollection = new ArrayList(), - Map metamap = new Map(), + IterationInfo(ArrayList metacollection, + Map metamap, String comment = '', int level = 0, String gatheredpath = '', @@ -1056,11 +1056,15 @@ class MetaInfo extends GISJsonSerialised { } def allrelatedmeta(String metapath = '') { - return walkrelated(new IterationInfo(new ArrayList(), new Map(), '', 0, '', metapath)) + def ArrayList metacollection = new ArrayList() + def Map metamap = new Map() + return walkrelated(new IterationInfo(metacollection, metamap, '', 0, '', metapath)) } ArrayList releasewalker(int maxdepth, String startpath = '', String startmetapath = '') { - def results = walkrelated(new IterationInfo(new ArrayList(), new Map(), 'meta', 0, startpath, startmetapath, true, maxdepth)) + def ArrayList metacollection = new ArrayList() + def Map metamap = new Map() + def results = walkrelated(new IterationInfo(metacollection, metamap, 'meta', 0, startpath, startmetapath, true, maxdepth)) return results.metacollection } From 27298b99745681a7cc3ccd4b47620aeda8247b42 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 21 Dec 2021 17:44:28 +0000 Subject: [PATCH 10/17] Use an iteration variable in walker --- meta/folder.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index ac8fa23..8325a89 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -1057,13 +1057,13 @@ class MetaInfo extends GISJsonSerialised { def allrelatedmeta(String metapath = '') { def ArrayList metacollection = new ArrayList() - def Map metamap = new Map() + def Map metamap = new LinkedHashMap() return walkrelated(new IterationInfo(metacollection, metamap, '', 0, '', metapath)) } ArrayList releasewalker(int maxdepth, String startpath = '', String startmetapath = '') { def ArrayList metacollection = new ArrayList() - def Map metamap = new Map() + def Map metamap = new LinkedHashMap() def results = walkrelated(new IterationInfo(metacollection, metamap, 'meta', 0, startpath, startmetapath, true, maxdepth)) return results.metacollection } From f21873bfcec1493c700023b7717a2186cef14014 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 21 Dec 2021 18:21:37 +0000 Subject: [PATCH 11/17] Optimise reading in of meta from files --- meta/folder.groovy | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index 8325a89..5861293 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -600,6 +600,7 @@ class MetaInfo extends GISJsonSerialised { interface IRelatedMetaInfo { abstract void deserialiseJson(rawmeta) abstract LinkedHashMap serialisationdata() + abstract String getuniqueid() } abstract class RelatedMetaInfo extends GISJsonSerialised implements IRelatedMetaInfo { @@ -612,20 +613,24 @@ class MetaInfo extends GISJsonSerialised { abstract void deserialiseJson(rawmeta) abstract LinkedHashMap serialisationdata() + abstract String getuniqueid() } class RelatedMetaInfo_v0_1 extends RelatedMetaInfo { private MetaInfo meta private String offsetpath + private String uniqueid - RelatedMetaInfo_v0_1(script, offsetpath = '', MetaInfo meta = null) { + RelatedMetaInfo_v0_1(script, String offsetpath = '', MetaInfo meta = null, String uniqueid = UUID.randomUUID().toString()) { super(script, '0.1') this.offsetpath = offsetpath + this.uniqueid = uniqueid this.meta = meta } void deserialiseJson(rawmeta) { offsetpath = rawmeta['offsetpath'] + uniqueid = rawmata['uniqueid'] ?: uniqueid meta = new MetaInfo(script) meta.deserialiseJson(rawmeta['meta']) } @@ -634,34 +639,47 @@ class MetaInfo extends GISJsonSerialised { def data = [ 'format' : format, 'offsetpath' : offsetpath, + 'uniqueid' : uniqueid, 'meta' : meta.serialisationdata(), ] return data } + + String getuniqueid() { + return uniqueid; + } } class RelatedMetaInfo_v0_2 extends RelatedMetaInfo { private String importpath private String offsetpath + private String uniqueid - RelatedMetaInfo_v0_2(script, importpath = '', offsetpath = '') { + RelatedMetaInfo_v0_2(script, String importpath = '', String offsetpath = '', String uniqueid = UUID.randomUUID().toString()) { super(script, '0.2') this.importpath = importpath this.offsetpath = offsetpath + this.uniqueid = uniqueid } void deserialiseJson(rawmeta) { //format = rawmeta['format'] offsetpath = rawmeta['offsetpath'] + uniqueid = rawmata['uniqueid'] } LinkedHashMap serialisationdata() { def data = [ 'format' : format, 'offsetpath' : offsetpath, + 'uniqueid' : uniqueid ] return data } + + String getuniqueid() { + return uniqueid; + } } private ProductInfo productinfo @@ -831,7 +849,7 @@ class MetaInfo extends GISJsonSerialised { script.echo("Deserialising meta at file: ${importedmetafile} (destpath: ${destpath})") mi.deserialiseJson(importedmetafile) - RelatedMetaInfo rmi = new RelatedMetaInfo_v0_2(script, importedmetafile, adjustedpath) + RelatedMetaInfo rmi = new RelatedMetaInfo_v0_2(script, importedmetafile, adjustedpath, mi.productinfo.uniqueid) if (appendtoparentmeta) { associatedmeta.add(rmi) } @@ -956,6 +974,13 @@ class MetaInfo extends GISJsonSerialised { String show() { return "Iteration:\nLevel: ${level}\nGathered path: ${gatheredpath}\nGathered meta path: ${gatheredmetapath}\nLimited depth: ${limiteddepth}\nMax depth: ${maxdepth}" } + + void add(CollectedMeta item) { + metacollection.add(item) + metamap.put(item.metainfo.productinfo.uniqueid, item) + } + + CollectedMeta } def openchildmeta(IterationInfo ii, RelatedMetaInfo relatedmetainfo) { @@ -965,7 +990,11 @@ class MetaInfo extends GISJsonSerialised { def String nextgatheredmetapath = (ii.gatheredmetapath == '' ? "${relatedmetainfo.offsetpath}/${METAFOLDERNAME}" : "${ii.gatheredmetapath}/${relatedmetainfo.offsetpath}") def importedmetafile = "${nextgatheredmetapath}/${METAFILENAME}" def boolean imported - if (script.fileExists(importedmetafile)) { + // If this has already been read in from a file + if (relatedmetainfo.uniqueid() in ii.metamap) { + mi = metamap[relatedmetainfo.uniqueid()].metainfo + imported = true + } else if (script.fileExists(importedmetafile)) { mi.deserialiseJson(importedmetafile) imported = true } else { @@ -985,7 +1014,7 @@ class MetaInfo extends GISJsonSerialised { def walkrelated_v0_1(IterationInfo ii) { script.echo("Walk related v0.1: ${ii.show()}") if (!ii.limiteddepth || ii.maxdepth > 0) { - ii.metacollection.add(new CollectedMeta(this, ii.gatheredpath, ii.gatheredmetapath)) + ii.add(new CollectedMeta(this, ii.gatheredpath, ii.gatheredmetapath)) ii.comment += "${ii.level} ".padRight(ii.level * 4) + globalreleasetag() + '\n' for (relatedmetainfo in associatedmeta) { if (!relatedmetainfo.format || relatedmetainfo.format == '0.1') { @@ -1015,7 +1044,7 @@ class MetaInfo extends GISJsonSerialised { def walkrelated(IterationInfo ii) { script.echo("Walk related: ${ii.show()}") if (!ii.limiteddepth || ii.maxdepth > 0) { - ii.metacollection.add(new CollectedMeta(this, ii.gatheredpath, ii.gatheredmetapath)) + ii.add(new CollectedMeta(this, ii.gatheredpath, ii.gatheredmetapath)) ii.comment += "${ii.level} ".padRight(ii.level * 4) + globalreleasetag() + '\n' for (relatedmetainfo in associatedmeta) { script.echo("Related meta info: ${relatedmetainfo.offsetpath} format: ${relatedmetainfo.format}") From a2ebb9623443225c1ef60ee2060e0a966925de05 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 21 Dec 2021 18:22:45 +0000 Subject: [PATCH 12/17] Optimise reading in of meta from files --- meta/folder.groovy | 2 -- 1 file changed, 2 deletions(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index 5861293..4dc8337 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -979,8 +979,6 @@ class MetaInfo extends GISJsonSerialised { metacollection.add(item) metamap.put(item.metainfo.productinfo.uniqueid, item) } - - CollectedMeta } def openchildmeta(IterationInfo ii, RelatedMetaInfo relatedmetainfo) { From cfa543970d6062177e2593db4e5dcf08dee0b86f Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 21 Dec 2021 18:32:13 +0000 Subject: [PATCH 13/17] Optimise reading in of meta from files --- meta/folder.groovy | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index 4dc8337..1816835 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -597,13 +597,7 @@ class MetaInfo extends GISJsonSerialised { private static String METAARTIFACTS = "${METAFOLDERNAME}/**" private static String format = '0.2' - interface IRelatedMetaInfo { - abstract void deserialiseJson(rawmeta) - abstract LinkedHashMap serialisationdata() - abstract String getuniqueid() - } - - abstract class RelatedMetaInfo extends GISJsonSerialised implements IRelatedMetaInfo { + abstract class RelatedMetaInfo extends GISJsonSerialised { String format RelatedMetaInfo(script, format) { @@ -646,7 +640,7 @@ class MetaInfo extends GISJsonSerialised { } String getuniqueid() { - return uniqueid; + return uniqueid } } @@ -678,7 +672,7 @@ class MetaInfo extends GISJsonSerialised { } String getuniqueid() { - return uniqueid; + return uniqueid } } From d7965ea280c368a8cdb4de816f97ce2cb03c84d0 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 21 Dec 2021 18:39:13 +0000 Subject: [PATCH 14/17] Optimise reading in of meta from files --- meta/folder.groovy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index 1816835..e28d28c 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -607,7 +607,7 @@ class MetaInfo extends GISJsonSerialised { abstract void deserialiseJson(rawmeta) abstract LinkedHashMap serialisationdata() - abstract String getuniqueid() + abstract String getrelatedid() } class RelatedMetaInfo_v0_1 extends RelatedMetaInfo { @@ -639,7 +639,7 @@ class MetaInfo extends GISJsonSerialised { return data } - String getuniqueid() { + String getrelatedid() { return uniqueid } } @@ -671,7 +671,7 @@ class MetaInfo extends GISJsonSerialised { return data } - String getuniqueid() { + String getrelatedid() { return uniqueid } } @@ -983,8 +983,8 @@ class MetaInfo extends GISJsonSerialised { def importedmetafile = "${nextgatheredmetapath}/${METAFILENAME}" def boolean imported // If this has already been read in from a file - if (relatedmetainfo.uniqueid() in ii.metamap) { - mi = metamap[relatedmetainfo.uniqueid()].metainfo + if (relatedmetainfo.getrelatedid() in ii.metamap) { + mi = metamap[relatedmetainfo.getrelatedid()].metainfo imported = true } else if (script.fileExists(importedmetafile)) { mi.deserialiseJson(importedmetafile) From 88ca474a706f0444c9751b1e947b0e9385fa8418 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Wed, 22 Dec 2021 09:44:35 +0000 Subject: [PATCH 15/17] Optimise reading in of meta from files --- meta/folder.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index e28d28c..112f3d6 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -624,7 +624,7 @@ class MetaInfo extends GISJsonSerialised { void deserialiseJson(rawmeta) { offsetpath = rawmeta['offsetpath'] - uniqueid = rawmata['uniqueid'] ?: uniqueid + uniqueid = rawmeta['uniqueid'] ?: uniqueid meta = new MetaInfo(script) meta.deserialiseJson(rawmeta['meta']) } @@ -659,7 +659,7 @@ class MetaInfo extends GISJsonSerialised { void deserialiseJson(rawmeta) { //format = rawmeta['format'] offsetpath = rawmeta['offsetpath'] - uniqueid = rawmata['uniqueid'] + uniqueid = rawmeta['uniqueid'] } LinkedHashMap serialisationdata() { From 984d996d88828f0db5ae9fbe032b13e7af3c03d9 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Wed, 22 Dec 2021 11:57:56 +0000 Subject: [PATCH 16/17] Optimise reading in of meta from files --- meta/folder.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index 112f3d6..faface8 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -984,7 +984,8 @@ class MetaInfo extends GISJsonSerialised { def boolean imported // If this has already been read in from a file if (relatedmetainfo.getrelatedid() in ii.metamap) { - mi = metamap[relatedmetainfo.getrelatedid()].metainfo + script.echo("Could not deserialise meta at file: ${importedmetafile} - Does not exist") + mi = ii.metamap[relatedmetainfo.getrelatedid()].metainfo imported = true } else if (script.fileExists(importedmetafile)) { mi.deserialiseJson(importedmetafile) From 85dd6534c6c4db549aaa3cf1ce86377e476b79ad Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Wed, 22 Dec 2021 12:20:28 +0000 Subject: [PATCH 17/17] Optimise reading in of meta from files --- meta/folder.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/folder.groovy b/meta/folder.groovy index faface8..8b3c22d 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -984,7 +984,7 @@ class MetaInfo extends GISJsonSerialised { def boolean imported // If this has already been read in from a file if (relatedmetainfo.getrelatedid() in ii.metamap) { - script.echo("Could not deserialise meta at file: ${importedmetafile} - Does not exist") + script.echo("Already read in meta associated with uniqueid: ${relatedmetainfo.getrelatedid()} - Using it") mi = ii.metamap[relatedmetainfo.getrelatedid()].metainfo imported = true } else if (script.fileExists(importedmetafile)) {