Skip to content

Commit

Permalink
Add a few more pieces of missing metadata (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
einarmo authored Sep 1, 2023
1 parent 0175254 commit 3c48611
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Extractor/Nodes/UAReferenceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ namespace Cognite.OpcUa.Nodes
public class ReferenceTypeAttributes : BaseNodeAttributes
{
public string? InverseName { get; set; }
public bool IsAbstract { get; set; }
public ReferenceTypeAttributes() : base(NodeClass.ReferenceType)
{
}

public override IEnumerable<uint> GetAttributeSet(FullConfig config)
{
yield return Attributes.InverseName;
yield return Attributes.IsAbstract;
foreach (var attr in base.GetAttributeSet(config)) yield return attr;
}

Expand All @@ -44,6 +46,9 @@ public override void LoadAttribute(DataValue value, uint attributeId, TypeManage
case Attributes.InverseName:
InverseName = value.GetValue<LocalizedText?>(null)?.Text;
break;
case Attributes.IsAbstract:
IsAbstract = value.GetValue(false);
break;
default:
base.LoadAttribute(value, attributeId, typeManager);
break;
Expand All @@ -53,6 +58,7 @@ public override void LoadAttribute(DataValue value, uint attributeId, TypeManage
public void LoadFromNodeState(ReferenceTypeState state)
{
InverseName = state.InverseName?.Text;
IsAbstract = state.IsAbstract;
LoadFromBaseNodeState(state);
}
}
Expand Down
7 changes: 7 additions & 0 deletions Extractor/Pushers/FDM/BaseDataModelDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ public static ContainerCreate ReferenceType(string space)
UsedFor = UsedFor.node,
Properties = new Dictionary<string, ContainerPropertyDefinition>
{
{ "IsAbstract", new ContainerPropertyDefinition
{
Type = BasePropertyType.Create(PropertyTypeVariant.boolean),
Nullable = false,
Name = "IsAbstract",
DefaultValue = new RawPropertyValue<bool>(false)
} },
{ "InverseName", new ContainerPropertyDefinition
{
Type = BasePropertyType.Text(),
Expand Down
3 changes: 3 additions & 0 deletions Extractor/Pushers/FDM/InstanceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,13 @@ class ReferenceTypeData
[JsonPropertyName("InverseName")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public string? InverseName { get; }
[JsonPropertyName("IsAbstract")]
public bool IsAbstract { get; }

public ReferenceTypeData(UAReferenceType node)
{
InverseName = node.FullAttributes.InverseName;
IsAbstract = node.FullAttributes.IsAbstract;
}
}

Expand Down
2 changes: 2 additions & 0 deletions Extractor/Pushers/FDM/TypeMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class PropertyNode
public string? ReferenceType { get; set; }
public string? DisplayName { get; set; }
public string? ExternalId { get; set; }
public string? Description { get; set; }
public bool IsTimeseries { get; set; }
}


Expand Down
4 changes: 3 additions & 1 deletion Extractor/Pushers/FDM/Types/NodeTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public TypeMetadata GetTypeMetadata()
IsMandatory = pair.mandatory,
ReferenceType = pair.reference.Type.Id.ToString(),
DisplayName = pair.node.Name ?? "",
ExternalId = FDMUtils.SanitizeExternalId(pair.node.Name ?? "")
ExternalId = FDMUtils.SanitizeExternalId(pair.node.Name ?? ""),
IsTimeseries = !pair.node.IsRawProperty && pair.node.NodeClass == NodeClass.Variable,
Description = pair.node.Attributes.Description
};
if (pair.node is UAVariable nVar)
Expand Down

0 comments on commit 3c48611

Please sign in to comment.