Association Roles
Association Roles definieren die Beziehungstypen zwischen Entitäten. Jede Role legt die Multiplizität und Benennung für beide Richtungen der Beziehung fest (inbound und outbound).
Association Roles auflisten
Alle Association Roles abrufen:
query getCkAssociationRoles($after: String, $first: Int, $ckModelIds: [String]) {
constructionKit {
associationRoles(after: $after, first: $first, ckModelIds: $ckModelIds) {
totalCount
items {
ckAssociationRoleId {
fullName
semanticVersionedFullName
}
}
}
}
}
Antwort
{
"data": {
"constructionKit": {
"associationRoles": {
"totalCount": 12,
"items": [
{
"ckAssociationRoleId": {
"fullName": "System-1.0.3/Parent-1",
"semanticVersionedFullName": "System/Parent"
}
},
{
"ckAssociationRoleId": {
"fullName": "EnergyCommunity-1.0.0/AssociatedCustomer-1",
"semanticVersionedFullName": "EnergyCommunity/AssociatedCustomer"
}
}
]
}
}
}
}
Nach Modell filtern
Association Roles aus bestimmten Modellen abrufen:
query {
constructionKit {
associationRoles(ckModelIds: ["EnergyCommunity-1"]) {
totalCount
items {
ckAssociationRoleId {
fullName
}
}
}
}
}
Details einer Association Role
Detaillierte Informationen zu einer bestimmten Association Role abrufen:
query getCkAssociationRoleDetails($roleId: String) {
constructionKit {
associationRoles(ckId: $roleId) {
totalCount
items {
ckAssociationRoleId {
fullName
semanticVersionedFullName
}
description
inboundMultiplicity
inboundName
outboundMultiplicity
outboundName
}
}
}
}
Variablen:
{
"roleId": "EnergyCommunity-1.0.0/AssociatedCustomer-1"
}
Antwort
{
"data": {
"constructionKit": {
"associationRoles": {
"totalCount": 1,
"items": [
{
"ckAssociationRoleId": {
"fullName": "EnergyCommunity-1.0.0/AssociatedCustomer-1",
"semanticVersionedFullName": "EnergyCommunity/AssociatedCustomer"
},
"description": "Links customers to their operating facilities",
"inboundMultiplicity": "N",
"inboundName": "customers",
"outboundMultiplicity": "N",
"outboundName": "facilities"
}
]
}
}
}
}
Assoziationsrichtungen verstehen
Eine Association Role definiert eine Beziehung, die in zwei Richtungen navigiert werden kann:
┌──────────────┐ ┌─────────────────────┐
│ Customer │ ──── facilities ────────► │ OperatingFacility │
│ │ ◄──── customers ───────── │ │
└──────────────┘ └─────────────────────┘
│ │
│ │
OUTBOUND INBOUND
(source) (target)
| Richtung | Property-Name | Von Entität | Zu Entität | Multiplizität |
|---|---|---|---|---|
| Outbound | facilities | Customer | OperatingFacility | N |
| Inbound | customers | OperatingFacility | Customer | N |
Association Roles durchsuchen
Rollen anhand ihres Namens suchen:
query {
constructionKit {
associationRoles(
searchFilter: {
searchTerm: "Customer"
type: ATTRIBUTE_FILTER
attributePaths: ["ckAssociationRoleId.fullName"]
}
) {
items {
ckAssociationRoleId {
fullName
}
inboundName
outboundName
}
}
}
}
Typ-Assoziationen ansehen
Um zu sehen, welche Association Roles von einem bestimmten Typ verwendet werden, fragen Sie die Assoziationen des Typs ab:
query {
constructionKit {
types(ckId: "EnergyCommunity-1.0.0/Customer-1") {
items {
ckTypeId {
fullName
}
associations {
out {
owned {
roleId {
fullName
}
navigationPropertyName
multiplicity
targetCkTypeId {
fullName
}
}
}
in {
owned {
roleId {
fullName
}
navigationPropertyName
multiplicity
originCkTypeId {
fullName
}
}
}
}
}
}
}
}
Weitere Details zum Abfragen von Typ-Assoziationen finden Sie unter Types.
Felder einer Association Role
CkAssociationRole
| Feld | Typ | Beschreibung |
|---|---|---|
ckAssociationRoleId | CkAssociationRoleId | Der Identifier der Association Role |
description | String | Beschreibung der Beziehung |
inboundMultiplicity | Multiplicity | Kardinalität von Ziel zu Quelle |
inboundName | String | Name des Navigations-Property für die Inbound-Richtung |
outboundMultiplicity | Multiplicity | Kardinalität von Quelle zu Ziel |
outboundName | String | Name des Navigations-Property für die Outbound-Richtung |
Multiplicity
| Wert | Beschreibung |
|---|---|
ZERO_OR_ONE | Optionale einzelne Beziehung (0..1) |
ONE | Erforderliche einzelne Beziehung (1) |
N | Mehrfache Beziehungen (0..*) |
Gängige Assoziationsmuster
Parent-Child (Komposition)
Eine starke Ownership-Beziehung, bei der Kinder ohne ihren Parent nicht existieren können:
{
"ckAssociationRoleId": { "fullName": "System-1.0.3/Parent-1" },
"inboundMultiplicity": "N",
"inboundName": "children",
"outboundMultiplicity": "ZERO_OR_ONE",
"outboundName": "parent"
}
Many-to-Many
Eine lose Beziehung, bei der beide Seiten mehrere Assoziationen haben können:
{
"ckAssociationRoleId": { "fullName": "EnergyCommunity-1.0.0/AssociatedCustomer-1" },
"inboundMultiplicity": "N",
"inboundName": "customers",
"outboundMultiplicity": "N",
"outboundName": "facilities"
}
One-to-Many
Eine Entität besitzt mehrere zugehörige Entitäten:
{
"ckAssociationRoleId": { "fullName": "Basic-1.0.0/Owner-1" },
"inboundMultiplicity": "N",
"inboundName": "ownedItems",
"outboundMultiplicity": "ONE",
"outboundName": "owner"
}