Skip to content

Commit

Permalink
Merge pull request #14 from atlanhq/customMetadata-fix
Browse files Browse the repository at this point in the history
Minor Fix - CustomMetadata while using IndexSearch
  • Loading branch information
0xquark authored Apr 17, 2024
2 parents b32501f + 50cac1f commit 44a15ab
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 33 deletions.
2 changes: 1 addition & 1 deletion atlan/client/custom_metadata_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (c *CustomMetadataCache) GetAttrNameForID(setID, attrID string) (string, er
}

func (c *CustomMetadataCache) GetAttributesForSearchResults(setID string) []string {
if subMap, ok := c.MapAttrNameToID[setID]; ok {
if subMap, ok := c.MapAttrIDToName[setID]; ok {
var dotNames []string
for idstr := range subMap {
dotNames = append(dotNames, fmt.Sprintf("%s.%s", setID, idstr))
Expand Down
93 changes: 61 additions & 32 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,42 @@ package main
import (
"fmt"
"github.com/atlanhq/atlan-go/atlan/client"
"log"
)

func main() {

client.LoggingEnabled = false
client.NewContext()
client.LoggingEnabled = true
ctx := client.NewContext()

client.GetAll()
client.GetAtlanTagCache().RefreshCache()
client.GetAtlanTagCache()
a, _ := client.GetAtlanTagIDForName("PII")
fmt.Printf("ID for name is : %s\n", a)

tagName := "Hourly"
tagID, err := client.GetAtlanTagIDForName(tagName)
client.GetCustomMetadataCache().RefreshCache()
id, err := client.GetCustomMetadataCache().GetIDForName("testcmgsdk")
if err != nil {
log.Fatal(err)
fmt.Println("Error:", err)
}

fmt.Printf("Atlan tag ID for %s: %s\n", tagName, tagID)

tagID = "a3el9UemzJZqZAUFcsDjy4"
tagName, err = client.GetAtlanTagNameForID(tagID)
if err != nil {
log.Fatal(err)
name, _ := client.GetCustomMetadataCache().GetNameForID("cvhn5T7YwnsYXiMCKh9PoW")
attrID, _ := client.GetCustomMetadataCache().GetAttrIDForName("testcmgsdk", "gsdk")
attrName, _ := client.GetCustomMetadataCache().GetAttrNameForID("cvhn5T7YwnsYXiMCKh9PoW", "foYi4v02OVjKt0YzcTCKM3")
fmt.Println("ID for name is : ", id)
fmt.Println("Name fo ID is:", name)
fmt.Printf("\nAttrID for name is: %s\n", attrID)
fmt.Printf("\nAttrName for ID is: %s\n", attrName)

fmt.Println(client.GetCustomMetadataCache().GetAttributesForSearchResultsByName("testcmgsdk"))
customMetadata := client.GetCustomMetadataCache().GetAttributesForSearchResultsByName("testcmgsdk")

customMeta, _ := client.NewFluentSearch().
PageSizes(50).
ActiveAssets().
Where(ctx.Glossary.QUALIFIED_NAME.Eq("fW6NU2lWKaMy5ZyVlGYes")).
IncludeOnResults(customMetadata...).
IncludeOnResults("terms").
IncludeOnResults("tags").
Execute()

for _, entity := range customMeta[0].Entities {
fmt.Println("Entity:", *entity.DisplayName)
}

fmt.Printf("Atlan tag name for %s: %s\n", tagID, tagName)

/*
ctx := client.NewContext()
assetQualifiedName := "default/mssql/1711817247/WideWorldImporters/Purchasing/SupplierCategories_Archive"
Expand Down Expand Up @@ -275,18 +281,41 @@ func main() {
// return
//}
//client.GetCache().RefreshCache()
//client.GetCache()
//a, _ := client.GetCache().GetIDForName("PII")
//fmt.Printf("ID for name is : %s\n", a)
/*
tagName := "Hourly"
tagID, err := client.GetIDForName(tagName)
if err != nil {
log.Fatal(err)
}
client.GetAll()
client.GetAtlanTagCache().RefreshCache()
client.GetAtlanTagCache()
a, _ := client.GetAtlanTagIDForName("PII")
fmt.Printf("ID for name is : %s\n", a)
tagName := "Hourly"
tagID, err := client.GetAtlanTagIDForName(tagName)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Atlan tag ID for %s: %s\n", tagName, tagID)
tagID = "a3el9UemzJZqZAUFcsDjy4"
tagName, err = client.GetAtlanTagNameForID(tagID)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Atlan tag name for %s: %s\n", tagID, tagName)
*/
//client.GetCache().RefreshCache()
//client.GetCache()
//a, _ := client.GetCache().GetIDForName("PII")
//fmt.Printf("ID for name is : %s\n", a)
/*
tagName := "Hourly"
tagID, err := client.GetIDForName(tagName)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Atlan tag ID for %s: %s\n", tagName, tagID)
fmt.Printf("Atlan tag ID for %s: %s\n", tagName, tagID)
*/
/*
tagID = "a3el9UemzJZqZAUFcsDjy4"
Expand Down

0 comments on commit 44a15ab

Please sign in to comment.