Skip to content

Commit

Permalink
Merge pull request #1174 from atlanhq/FT-858
Browse files Browse the repository at this point in the history
Fixes typedef toolkit to generate appropriate AttributeDefs on RelationshipDefs
  • Loading branch information
cmgrote authored Dec 24, 2024
2 parents 557d142 + b863d99 commit 42edf23
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ testng = "7.10.2"
log4j = "2.24.3"
wiremock = "3.10.0"
jnanoid = "2.0.0"
awssdk = "2.29.39"
awssdk = "2.29.40"
gcs = "26.51.0"
system-stubs = "2.1.7"
fastcsv = "3.4.0"
Expand Down
5 changes: 3 additions & 2 deletions samples/typedefs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ tasks {
pkl {
evaluators {
register("genPklTypedefs") {
sourceModules.add("src/main/resources/MultiDimensionalDataset.pkl")
sourceModules.add("src/main/resources/DataModel.pkl")
sourceModules.add("src/main/resources/Application.pkl")
sourceModules.add("src/main/resources/Custom.pkl")
sourceModules.add("src/main/resources/DataModel.pkl")
sourceModules.add("src/main/resources/MultiDimensionalDataset.pkl")
modulePath.from(file("../../typedef-toolkit/model/src/main/resources"))
outputFormat.set("json")
multipleFileOutputDir.set(layout.projectDirectory.dir("build"))
Expand Down
80 changes: 80 additions & 0 deletions samples/typedefs/src/main/resources/Custom.pkl
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* SPDX-License-Identifier: Apache-2.0
Copyright 2024 Atlan Pte. Ltd. */
amends "modulepath:/Model.pkl"

t = "Custom"
a = t.decapitalize()

shared {
supertypeDefinition {
name = t
description = "Base class for all \(t) types."
superTypes { "Catalog" }
attributes {}
}
}

customTypes {
["\(t)Entity"] {
label = "Custom"
icon = entityIcon
description = "Instances of \(t)Entity in Atlan."
relationships {
["\(a)EntityAggregation"] {
description = "Containment relationship between two custom entities."
parent {
type = "\(t)Entity"
attribute = "\(a)ChildEntities"
description = "Custom entities contained within this entity."
}
children {
type = "\(t)Entity"
attribute = "\(a)ParentEntity"
description = "Custom entity that contains this entity."
}
relationshipAttributes {
["\(a)EntityChildrenLabel"] {
type = "string"
description = "Name for the relationship when referring from the parent entity to its children entities."
}
["\(a)EntityParentLabel"] {
type = "string"
description = "Name for the relationship when referring from a child entity to its parent entity."
}
}
}
["\(a)EntityAssociation"] {
description = "Inter-relationship between two custom assets."
peers {
new {
type = "\(t)Entity"
attribute = "\(a)RelatedToEntities"
description = "Target custom entity indicating where the relationship is directed."
}
new {
type = "\(t)Entity"
attribute = "\(a)RelatedFromEntities"
description = "Source custom entity indicating where the relationship originates."
}
}
relationshipAttributes {
["\(a)EntityToLabel"] {
type = "string"
description = "Name for the relationship when referring from endDef1 entity to endDef2 entity."
}
["\(a)EntityFromLabel"] {
type = "string"
description = "Name for the relationship when referring from endDef2 entity to endDef1 entity."
}
}
}
}
}
}

local entityIcon = new Icon {
name = "EntityGray"
nameActive = "Entity"
svg = "entity-gray.svg"
svgActive = "entity.svg"
}
2 changes: 1 addition & 1 deletion typedef-toolkit/model/src/main/resources/Model.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ class RelationshipDef extends TypeDef {
else "ASSOCIATION"

/// Generated list of [relationship attributes][RelationshipAttributeDef] for the type definition.
fixed relationshipAttributeDefs: List<RelationshipAttributeDef>? = relationshipAttributes?.fold(List(), (acc: List<RelationshipAttributeDef>, key, value) ->
fixed attributeDefs: List<AttributeDef>? = relationshipAttributes?.fold(List(), (acc: List<RelationshipAttributeDef>, key, value) ->
let (attrDef =
(value) {
name = key // Set the name from the map's key
Expand Down

0 comments on commit 42edf23

Please sign in to comment.