| modeltype BUILD uses "http://www.eclipse.org/amalgam/2008/build"; |
| modeltype PRODUCT uses "http://www.eclipse.org/amalgam/2008/product"; |
| |
| transformation processbuild(in inProduct : PRODUCT, in inBuild : BUILD, out outProduct : PRODUCT, out outBuild : BUILD); |
| |
| configuration property date : String; |
| configuration property time : String; |
| |
| main() { |
| inBuild.rootObjects()[Build].map toBuild(); |
| inProduct.rootObjects()[product::Product].map toProduct(); |
| outProduct.rootObjects()[product::Product].features.map toFeatures(); |
| } |
| |
| mapping product::Product::toProduct() : product::Product@outProduct { |
| init { |
| result := self.deepclone().oclAsType(product::Product); |
| var v : String := self.version; |
| if (v.endsWith('qualifier')) then { |
| v := self.version.substringBefore('qualifier') + 'v' + this.date + this.time; |
| } endif; |
| } |
| version := v; |
| -- features := object product::Features { |
| -- feature += outBuild.rootObjects()![Build].contributions.features->select(f | f.inProduct)->map toFeature(); |
| -- } |
| end { |
| outBuild.rootObjects()[Build].map updateProductReference(); |
| } |
| } |
| |
| mapping build::Build::toBuild() : build::Build@outBuild { |
| init { |
| result := self.deepclone().oclAsType(Build); |
| } |
| date := this.date; |
| time := this.time; |
| } |
| |
| mapping inout build::Build::updateProductReference() { |
| product := outProduct.rootObjects()![product::Product]; |
| } |
| |
| mapping inout product::Features::toFeatures() { |
| feature += outBuild.rootObjects()[Build].contributions.features->select(f | f.inProduct)->map toFeature(); |
| } |
| |
| mapping build::Feature::toFeature() : product::Feature { |
| id := self.id; |
| version := self.version; |
| } |