Zum Hauptinhalt springen

Attributes

Attribute sind wiederverwendbare Property-Definitionen, die auf Typen angewendet werden können. Jedes Attribut besitzt einen Wertetyp und optionale Einschränkungen.

Attribute auflisten​

Alle Attribute abrufen:

query getCkAttributes($after: String, $first: Int, $ckModelIds: [String]) {
constructionKit {
attributes(after: $after, first: $first, ckModelIds: $ckModelIds) {
totalCount
items {
ckAttributeId {
fullName
semanticVersionedFullName
}
attributeValueType
}
}
}
}

Antwort​

{
"data": {
"constructionKit": {
"attributes": {
"totalCount": 25,
"items": [
{
"ckAttributeId": {
"fullName": "Basic-1.0.0/Name-1",
"semanticVersionedFullName": "Basic/Name"
},
"attributeValueType": "STRING"
},
{
"ckAttributeId": {
"fullName": "Industry.Energy-1.0.0/Voltage-1",
"semanticVersionedFullName": "Industry.Energy/Voltage"
},
"attributeValueType": "DOUBLE"
}
]
}
}
}
}

Nach Modell filtern​

Attribute aus bestimmten Modellen abrufen:

query {
constructionKit {
attributes(ckModelIds: ["Industry.Energy-1"]) {
totalCount
items {
ckAttributeId {
fullName
}
attributeValueType
}
}
}
}

Details eines Attributs​

Detaillierte Informationen zu einem bestimmten Attribut abrufen:

query getCkAttributeDetails($attributeId: String) {
constructionKit {
attributes(ckId: $attributeId) {
items {
ckAttributeId {
fullName
semanticVersionedFullName
}
description
attributeValueType
defaultValues
ckEnum {
ckEnumId {
fullName
semanticVersionedFullName
}
useFlags
isExtensible
values {
key
name
description
isExtension
}
}
ckRecord {
ckRecordId {
fullName
semanticVersionedFullName
}
isAbstract
isFinal
}
}
}
}
}

Variablen:

{
"attributeId": "Industry.Energy-1.0.0/State-1"
}

Antwort für ein Enum-Attribut​

{
"data": {
"constructionKit": {
"attributes": {
"items": [
{
"ckAttributeId": {
"fullName": "Industry.Energy-1.0.0/State-1",
"semanticVersionedFullName": "Industry.Energy/State"
},
"description": "The operational state of the energy meter",
"attributeValueType": "ENUM",
"defaultValues": null,
"ckEnum": {
"ckEnumId": {
"fullName": "Industry.Energy-1.0.0/EnergyMeterState-1",
"semanticVersionedFullName": "Industry.Energy/EnergyMeterState"
},
"useFlags": false,
"isExtensible": false,
"values": [
{ "key": 0, "name": "OFF", "description": "Meter is off", "isExtension": false },
{ "key": 1, "name": "ON", "description": "Meter is on", "isExtension": false },
{ "key": 2, "name": "STANDBY", "description": "Meter is in standby", "isExtension": false }
]
},
"ckRecord": null
}
]
}
}
}
}

Antwort für ein Record-Attribut​

{
"data": {
"constructionKit": {
"attributes": {
"items": [
{
"ckAttributeId": {
"fullName": "Basic-1.0.0/Contact-1",
"semanticVersionedFullName": "Basic/Contact"
},
"description": "Contact information",
"attributeValueType": "RECORD",
"defaultValues": null,
"ckEnum": null,
"ckRecord": {
"ckRecordId": {
"fullName": "Basic-1.0.0/Contact-1",
"semanticVersionedFullName": "Basic/Contact"
},
"isAbstract": false,
"isFinal": false
}
}
]
}
}
}
}

Attribute durchsuchen​

Attribute anhand ihres Namens suchen:

query {
constructionKit {
attributes(
searchFilter: {
searchTerm: "voltage"
type: ATTRIBUTE_FILTER
attributePaths: ["ckAttributeId.fullName"]
}
) {
items {
ckAttributeId {
fullName
}
attributeValueType
}
}
}
}

Felder eines Attributs​

CkAttribute​

FeldTypBeschreibung
ckAttributeIdCkAttributeIdDer Identifier des Attributs
descriptionStringBeschreibung des Attributs
attributeValueTypeStringDer Datentyp (STRING, INT32, ENUM, RECORD usw.)
defaultValues[SimpleScalar]Standardwerte für das Attribut
ckEnumCkEnumEnum-Definition (falls attributeValueType ENUM ist)
ckRecordCkRecordRecord-Definition (falls attributeValueType RECORD ist)

Attribut-Wertetypen​

WertBeschreibungGraphQL InputGraphQL Output
STRINGTextwertStringString
STRING_ARRAYArray von Textwerten[String][String]
INT3232-Bit-GanzzahlIntInt
INT32_ARRAYArray von 32-Bit-Ganzzahlen[Int][Int]
INT6464-Bit-GanzzahlLongLong
FLOATGleitkommazahlFloatFloat
DOUBLEGleitkommazahl mit doppelter GenauigkeitDecimalDecimal
BOOLEANWahr/Falsch-WertBooleanBoolean
DATE_TIMEDatums- und ZeitwertDateTimeDateTime
DATE_TIME_OFFSETDatum/Zeit mit Zeitzonen-OffsetDateTimeOffsetDateTimeOffset
TIME_SPANDauer/Zeitintervall (in Sekunden)Decimal (Sekunden)Decimal (Sekunden)
BINARYInline-Binärdaten (Byte-Array)[Int] (0-255)[Int] (0-255)
BINARY_LINKEDReferenz auf eine externe Binärdateiüber REST-APILargeBinaryInfo
OBJECT_IDMongoDB-ObjectId-ReferenzOctoObjectIdOctoObjectId
ENUMEnumerationswert (siehe verknüpftes ckEnum)Generated EnumGenerated Enum
RECORDEinzelner eingebetteter Record (siehe verknüpftes ckRecord)Generated InputGenerated Type
RECORD_ARRAYArray eingebetteter Records[Generated Input][Generated Type]
GEOSPATIAL_POINTGeospatiale PunktkoordinatenPointInputRtGeospatialValue

Spezielle Skalar-Typen​

TimeSpan-Attribute​

TimeSpan-Attribute speichern Werte für Dauer/Zeitintervalle. In GraphQL werden TimeSpan-Werte als Sekunden (Dezimalzahl) dargestellt.

YAML-Definition:

attributes:
- id: DataTransmissionInterval
valueType: TimeSpan
description: "Interval between data transmissions"

Query-Beispiel:

query {
constructionKit {
attributes(ckId: "OctoSdkDemo-1.0.0/DataTransmissionInterval-1") {
items {
ckAttributeId {
fullName
}
attributeValueType # Returns "TIME_SPAN"
description
}
}
}
}

Runtime-Abfrage:

TimeSpan-Werte werden als Sekunden zurückgegeben:

query {
runtime {
octoSdkDemoMeteringPoints(first: 10) {
items {
rtId
meteringPointNumber
dataTransmissionInterval # Returns seconds as decimal
}
}
}
}

Antwort:

{
"data": {
"runtime": {
"octoSdkDemoMeteringPoints": {
"items": [
{
"rtId": "693c5b93464d7d9e1396cf1c",
"meteringPointNumber": "MP-001",
"dataTransmissionInterval": 900.0
}
]
}
}
}
}

Gängige TimeSpan-Werte:

DauerSekunden
1 Minute60
5 Minuten300
15 Minuten900
1 Stunde3600
1 Tag86400
1 Woche604800

Komplexe Attributtypen​

Record-Attribute​

Record-Attribute betten strukturierte Daten in eine Entität ein. Die Record-Struktur wird separat im Construction Kit definiert.

YAML-Definition:

attributes:
- id: MainSpecification
valueType: Record
valueCkRecordId: ${this}/Specification
description: "Main specification of the product"

Query-Beispiel:

query {
constructionKit {
attributes(ckId: "MyModel-1.0.0/MainSpecification-1") {
items {
ckAttributeId {
fullName
}
attributeValueType
ckRecord {
ckRecordId {
fullName
}
attributes {
items {
attributeName
attributeValueType
}
}
}
}
}
}
}

RecordArray-Attribute​

RecordArray-Attribute speichern Arrays strukturierter Records – nützlich für Listen von Spezifikationen, Kontakten oder anderen sich wiederholenden Datenstrukturen.

YAML-Definition:

attributes:
- id: TechnicalSpecifications
valueType: RecordArray
valueCkRecordId: ${this}/Specification
description: "List of technical specifications"

Query-Beispiel:

query {
constructionKit {
attributes(ckId: "MyModel-1.0.0/TechnicalSpecifications-1") {
items {
ckAttributeId {
fullName
}
attributeValueType # Returns "RECORD_ARRAY"
ckRecord {
ckRecordId {
fullName
}
}
}
}
}
}

Binary-Attribute​

Binary-Attribute speichern kleine Binärdaten direkt in der Entität als Inline-Byte-Arrays. Das ist ideal für kleine Dateien wie Profilbilder, Icons oder zwischengespeicherte Daten, bei denen eine externe Dateispeicherung übertrieben wäre.

YAML-Definition:

attributes:
- id: ProfilePicture
valueType: Binary
description: "Profile picture stored inline"

Query-Beispiel:

query {
constructionKit {
attributes(ckId: "MyModel-1.0.0/ProfilePicture-1") {
items {
ckAttributeId {
fullName
}
attributeValueType # Returns "BINARY"
description
}
}
}
}

Runtime-Abfrage – Binary-Ausgabe:

Binärdaten werden als Array von Byte-Werten (Ganzzahlen 0-255) zurückgegeben:

query {
runtime {
octoSdkDemoCustomers(first: 10) {
items {
rtId
contact {
firstName
lastName
}
profilePicture # Returns [137, 80, 78, 71, ...]
}
}
}
}

Antwort:

{
"data": {
"runtime": {
"octoSdkDemoCustomers": {
"items": [
{
"rtId": "693c5b93464d7d9e1396cf1c",
"contact": {
"firstName": "John",
"lastName": "Doe"
},
"profilePicture": [137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13]
}
]
}
}
}
}
Binary vs BinaryLinked
  • Binary: Kleine Daten inline gespeichert (< 16MB), sofortiger Zugriff, kein separater Download
  • BinaryLinked: Große Dateien extern gespeichert, erfordert einen Download über die REST-API

BinaryLinked-Attribute​

BinaryLinked-Attribute speichern Referenzen auf externe Binärdateien (Bilder, Dokumente, PDFs usw.). Dateien werden über einen GraphQL Multipart Request hochgeladen und über die REST-API heruntergeladen. Die Entität speichert nur die Referenz-Metadaten.

YAML-Definition:

attributes:
- id: ProductImage
valueType: BinaryLinked
description: "Product image file"

- id: ProductDatasheet
valueType: BinaryLinked
description: "Product datasheet document"

Query-Beispiel:

query {
constructionKit {
attributes(ckId: "MyModel-1.0.0/ProductImage-1") {
items {
ckAttributeId {
fullName
}
attributeValueType # Returns "BINARY_LINKED"
description
}
}
}
}

Runtime-Abfrage – BinaryLinked-Ausgabe:

Beim Abfragen von Entitäten mit BinaryLinked-Attributen erhalten Sie Metadaten über die Binärdaten:

query {
runtime {
products(first: 10) {
items {
productImage {
binaryId
filename
contentType
size
downloadUri
}
}
}
}
}

LargeBinaryInfo-Felder:

FeldTypBeschreibung
binaryIdOctoObjectIdEindeutiger Identifier der Binärdaten
filenameStringUrsprünglicher Dateiname
contentTypeStringMIME-Typ (z. B. image/png)
sizeLongDateigröße in Bytes
downloadUriStringURI zum Herunterladen des Binärinhalts
tipp

Zum Erstellen und Aktualisieren von Entitäten mit komplexen Attributtypen siehe: