{"id":1550,"date":"2020-05-07T11:35:11","date_gmt":"2020-05-07T11:35:11","guid":{"rendered":"https:\/\/wetransform.eu\/?post_type=news-and-events&#038;p=1550"},"modified":"2022-07-28T08:03:54","modified_gmt":"2022-07-28T08:03:54","slug":"mapping-attributes-type-level","status":"publish","type":"news-and-events","link":"https:\/\/wetransform.to\/de\/news-and-events\/mapping-attributes-type-level\/","title":{"rendered":"Groovy Week 2020: Mapping Attributes on the Type Level to Split a Feature"},"content":{"rendered":"<p>In our fourth installment of the 2020 Groovy Week, we are going to take a look at how to map attributes in Groovy type transformation functions and how to use that to create multiple target objects for a single source object. Like in the previous Groovy Week posts, note that this article assumes you have working knowledge of hale\u00bbstudio and know the terminology.<\/p>\n<h2>Thursday's Script: Mapping Attributes on the Type Level to Split a Feature (Florian)<\/h2>\n<p>The normal approach to map values of source attributes to the target is to invoke an attribute transformation function like <code>Rename<\/code>, <code>Classification<\/code> or <code>Groovy Script<\/code>. These attribute-level functions let you create a target value based on the value(s) of the source attribute(s). Here is an example for a simple <code>Rename<\/code> that maps the source <code>description<\/code> attribute to the target attribute of the same name. The function is part of the <code>Retype<\/code> of the source type <code>River<\/code> to the target type <code>Watercourse<\/code>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/wetransform.eu\/wp-content\/uploads\/2022\/05\/river-description-rename.png\" alt=\"hale\u00bbstudio simple mapping of a property\" \/><\/p>\n<p>If we replace the type transformation function <code>Retype<\/code> by a <code>Groovy Retype<\/code>, we can achieve the same result as with the <code>Rename<\/code> function by using the <code>_target<\/code> instruction in the script:<\/p>\n<p><script src=\"https:\/\/gist.github.com\/JBoudewijn\/a6d99b876695f871ee48bf544892795e.js\"><\/script><\/p>\n<p><a href=\"https:\/\/github.com\/wetransform-os\/website-examples\/blob\/af7108ee8f5a838327c3e4b871850212c399e37c\/news\/resources\/assignDescription.groovy\" title=\"Download\">Download<\/a><\/p>\n<p>A typical use case for this is if you need to split one feature into more than one target object with different target attribute values. Here is an example from an <a href=\"https:\/\/inspire.ec.europa.eu\/Themes\/116\/2892\">INSPIRE Hydrography<\/a> alignment where one target instance is created for every source geometry:<\/p>\n<p><script src=\"https:\/\/gist.github.com\/JBoudewijn\/c0ae45f482f0a174dfc09173a8c5e9b0.js\"><\/script><\/p>\n<p><a href=\"https:\/\/github.com\/wetransform-os\/website-examples\/blob\/af7108ee8f5a838327c3e4b871850212c399e37c\/news\/resources\/createDamOrWeir.groovy\" title=\"Download\">Download<\/a><\/p>\n<p>You can download the script snippets and import them in hale studio as a Groovy snippet by going to File -&gt; Import -&gt; Groovy Snippet. Please note that some scripts use protected functions, so you might need to &quot;Lift Groovy Restrictions&quot; to execute the script. Make sure you replace the placeholder attribute names with your own attribute names.<\/p>\n<p>Happy transforming!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our fourth installment of the 2020 Groovy Week, we are going to take a look at how to map attributes in Groovy type transformation functions and how to use that to create multiple target objects for a single source object. Like in the previous Groovy Week posts, note that this article assumes you have [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[48],"tags":[47,21,46],"class_list":["post-1550","news-and-events","type-news-and-events","status-publish","hentry","category-tutorials","tag-groovy","tag-halestudio","tag-tutorial"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.6 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Groovy Week 2020: Mapping Attributes on the Type Level to Split a Feature - wetransform<\/title>\n<meta name=\"description\" content=\"We take a look at how to map attributes and how to use that to create multiple target objects for a single source object.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wetransform.to\/de\/news-and-events\/mapping-attributes-type-level\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Groovy Week 2020: Mapping Attributes on the Type Level to Split a Feature\" \/>\n<meta property=\"og:description\" content=\"We take a look at how to map attributes and how to use that to create multiple target objects for a single source object.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wetransform.to\/de\/news-and-events\/mapping-attributes-type-level\/\" \/>\n<meta property=\"og:site_name\" content=\"wetransform\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-28T08:03:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wetransform.eu\/wp-content\/uploads\/2022\/05\/river-description-rename.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@wetransformto\" \/>\n<meta name=\"twitter:label1\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data1\" content=\"2\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wetransform.to\\\/de\\\/news-and-events\\\/mapping-attributes-type-level\\\/\",\"url\":\"https:\\\/\\\/wetransform.to\\\/de\\\/news-and-events\\\/mapping-attributes-type-level\\\/\",\"name\":\"Groovy Week 2020: Mapping Attributes on the Type Level to Split a Feature - wetransform\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/wetransform.to\\\/de\\\/news-and-events\\\/mapping-attributes-type-level\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/wetransform.to\\\/de\\\/news-and-events\\\/mapping-attributes-type-level\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wetransform.eu\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/river-description-rename.png\",\"datePublished\":\"2020-05-07T11:35:11+00:00\",\"dateModified\":\"2022-07-28T08:03:54+00:00\",\"description\":\"We take a look at how to map attributes and how to use that to create multiple target objects for a single source object.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wetransform.to\\\/de\\\/news-and-events\\\/mapping-attributes-type-level\\\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wetransform.to\\\/de\\\/news-and-events\\\/mapping-attributes-type-level\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\\\/\\\/wetransform.to\\\/de\\\/news-and-events\\\/mapping-attributes-type-level\\\/#primaryimage\",\"url\":\"https:\\\/\\\/wetransform.eu\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/river-description-rename.png\",\"contentUrl\":\"https:\\\/\\\/wetransform.eu\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/river-description-rename.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wetransform.to\\\/de\\\/news-and-events\\\/mapping-attributes-type-level\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/wetransform.to\\\/de\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"News & Events\",\"item\":\"https:\\\/\\\/wetransform.to\\\/de\\\/news-and-events\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Groovy Week 2020: Mapping Attributes on the Type Level to Split a Feature\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#website\",\"url\":\"http:\\\/\\\/wetransform.to\\\/de\\\/\",\"name\":\"wetransform\",\"description\":\"Making environmental data useful and accessible\",\"publisher\":{\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\\\/\\\/wetransform.to\\\/de\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de\"},{\"@type\":\"Organization\",\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#organization\",\"name\":\"wetransform\",\"url\":\"http:\\\/\\\/wetransform.to\\\/de\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/wetransform.to\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/large-logo-whitebg.png\",\"contentUrl\":\"https:\\\/\\\/wetransform.to\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/large-logo-whitebg.png\",\"width\":1024,\"height\":1024,\"caption\":\"wetransform\"},\"image\":{\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/wetransformto\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/wetransform-gmbh\\\/\"]}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Groovy Week 2020: Mapping Attributes on the Type Level to Split a Feature - wetransform","description":"We take a look at how to map attributes and how to use that to create multiple target objects for a single source object.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wetransform.to\/de\/news-and-events\/mapping-attributes-type-level\/","og_locale":"de_DE","og_type":"article","og_title":"Groovy Week 2020: Mapping Attributes on the Type Level to Split a Feature","og_description":"We take a look at how to map attributes and how to use that to create multiple target objects for a single source object.","og_url":"https:\/\/wetransform.to\/de\/news-and-events\/mapping-attributes-type-level\/","og_site_name":"wetransform","article_modified_time":"2022-07-28T08:03:54+00:00","og_image":[{"url":"https:\/\/wetransform.eu\/wp-content\/uploads\/2022\/05\/river-description-rename.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@wetransformto","twitter_misc":{"Gesch\u00e4tzte Lesezeit":"2\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/wetransform.to\/de\/news-and-events\/mapping-attributes-type-level\/","url":"https:\/\/wetransform.to\/de\/news-and-events\/mapping-attributes-type-level\/","name":"Groovy Week 2020: Mapping Attributes on the Type Level to Split a Feature - wetransform","isPartOf":{"@id":"http:\/\/wetransform.to\/de\/#website"},"primaryImageOfPage":{"@id":"https:\/\/wetransform.to\/de\/news-and-events\/mapping-attributes-type-level\/#primaryimage"},"image":{"@id":"https:\/\/wetransform.to\/de\/news-and-events\/mapping-attributes-type-level\/#primaryimage"},"thumbnailUrl":"https:\/\/wetransform.eu\/wp-content\/uploads\/2022\/05\/river-description-rename.png","datePublished":"2020-05-07T11:35:11+00:00","dateModified":"2022-07-28T08:03:54+00:00","description":"We take a look at how to map attributes and how to use that to create multiple target objects for a single source object.","breadcrumb":{"@id":"https:\/\/wetransform.to\/de\/news-and-events\/mapping-attributes-type-level\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wetransform.to\/de\/news-and-events\/mapping-attributes-type-level\/"]}]},{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/wetransform.to\/de\/news-and-events\/mapping-attributes-type-level\/#primaryimage","url":"https:\/\/wetransform.eu\/wp-content\/uploads\/2022\/05\/river-description-rename.png","contentUrl":"https:\/\/wetransform.eu\/wp-content\/uploads\/2022\/05\/river-description-rename.png"},{"@type":"BreadcrumbList","@id":"https:\/\/wetransform.to\/de\/news-and-events\/mapping-attributes-type-level\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wetransform.to\/de\/"},{"@type":"ListItem","position":2,"name":"News & Events","item":"https:\/\/wetransform.to\/de\/news-and-events\/"},{"@type":"ListItem","position":3,"name":"Groovy Week 2020: Mapping Attributes on the Type Level to Split a Feature"}]},{"@type":"WebSite","@id":"http:\/\/wetransform.to\/de\/#website","url":"http:\/\/wetransform.to\/de\/","name":"wetransform","description":"Making environmental data useful and accessible","publisher":{"@id":"http:\/\/wetransform.to\/de\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/wetransform.to\/de\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":"Organization","@id":"http:\/\/wetransform.to\/de\/#organization","name":"wetransform","url":"http:\/\/wetransform.to\/de\/","logo":{"@type":"ImageObject","inLanguage":"de","@id":"http:\/\/wetransform.to\/de\/#\/schema\/logo\/image\/","url":"https:\/\/wetransform.to\/wp-content\/uploads\/2022\/07\/large-logo-whitebg.png","contentUrl":"https:\/\/wetransform.to\/wp-content\/uploads\/2022\/07\/large-logo-whitebg.png","width":1024,"height":1024,"caption":"wetransform"},"image":{"@id":"http:\/\/wetransform.to\/de\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/wetransformto","https:\/\/www.linkedin.com\/company\/wetransform-gmbh\/"]}]}},"_links":{"self":[{"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/news-and-events\/1550","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/news-and-events"}],"about":[{"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/types\/news-and-events"}],"author":[{"embeddable":true,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/comments?post=1550"}],"version-history":[{"count":4,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/news-and-events\/1550\/revisions"}],"predecessor-version":[{"id":3751,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/news-and-events\/1550\/revisions\/3751"}],"wp:attachment":[{"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/media?parent=1550"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/categories?post=1550"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/tags?post=1550"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}