Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
* before refactoring becaus
Browse files Browse the repository at this point in the history
  of anonymous instances
  • Loading branch information
festo-i40 committed Nov 1, 2023
1 parent dfcc346 commit 8782de1
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 74 deletions.
51 changes: 28 additions & 23 deletions src/AasxCore.Samm2_2_0/SammClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ public class Characteristic : ModelElement, ISammSelfDescription, ISammStructure
public string GetSelfName() => "samm-characteristic";
// public string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#Characteristic";
// FIX: seems to use bamm: instead of bamm-c: !!
public string GetSelfUrn() => "urn:bamm:io.openmanufacturing:meta-model:1.0.0#Characteristic";
public string GetSelfUrn() => "bamm:Characteristic";

// structure model
public bool IsTopElement() => false;
Expand Down Expand Up @@ -630,7 +630,7 @@ public class Trait : Characteristic, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-trait";
public new string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#Trait";
public new string GetSelfUrn() => "bamm-c:Trait";

/// <summary>
/// The Characterstic that is being constrained.
Expand All @@ -644,7 +644,7 @@ public class Trait : Characteristic, ISammSelfDescription
/// to add multiple Constraints to the base Characteristic.
/// </summary>
[SammPropertyUri("bamm-c:constraint")]
public List<Constraint>? Constraint { get; set; }
public List<SammReference>? Constraint { get; set; }
}

/// <summary>
Expand All @@ -657,7 +657,7 @@ public class Quantifiable : Characteristic, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-quantifiable";
public new string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#Quantifiable";
public new string GetSelfUrn() => "bamm-c:Quantifiable";

/// <summary>
/// Reference to a Unit as defined in the Unit catalog
Expand All @@ -675,7 +675,7 @@ public class Measurement : Characteristic, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-measurement";
public new string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#Measurement";
public new string GetSelfUrn() => "bamm-c:Measurement";

/// <summary>
/// Reference to a Unit as defined in the Unit catalog
Expand All @@ -698,7 +698,7 @@ public class Enumeration : Characteristic, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-enumeration";
public new string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#Enumeration";
public new string GetSelfUrn() => "bamm-c:Enumeration";

/// <summary>
/// List of possible values. The dataType of each of the values must match the
Expand All @@ -722,7 +722,7 @@ public class State : Enumeration, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-state";
public new string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#State";
public new string GetSelfUrn() => "bamm-c:State";

/// <summary>
/// The default value for the state.
Expand All @@ -745,7 +745,7 @@ public class Duration : Characteristic, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-duration";
public new string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#Duration";
public new string GetSelfUrn() => "bamm-c:Duration";

/// <summary>
/// Reference to a Unit as defined in the Unit catalog. The referenced unit or its referenceUnit
Expand Down Expand Up @@ -776,7 +776,7 @@ public class Collection : Characteristic, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-collection";
public new string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#Collection";
public new string GetSelfUrn() => "bamm-c:Collection";

/// <summary>
/// Reference to a Characteristic which describes the individual elements contained in the Collection.
Expand All @@ -799,7 +799,7 @@ public class List : Collection, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-list";
public new string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#List";
public new string GetSelfUrn() => "bamm-c:List";
}

/// <summary>
Expand All @@ -811,7 +811,7 @@ public class Set : Collection, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-set";
public new string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#Set";
public new string GetSelfUrn() => "bamm-c:Set";
}

/// <summary>
Expand All @@ -823,7 +823,7 @@ public class SortedSet : Collection, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-sorted-set";
public new string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#SortedSet";
public new string GetSelfUrn() => "bamm-c:SortedSet";
}

/// <summary>
Expand All @@ -835,7 +835,7 @@ public class TimeSeries : SortedSet, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-time-series";
public new string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#TimeSeries";
public new string GetSelfUrn() => "bamm-c:TimeSeries";

// For DataType
// Set to samm-e:TimeSeriesEntity. This Entity consists of two Properties, namely samm-e:timestamp
Expand All @@ -856,7 +856,7 @@ public class Code : Characteristic, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-code";
public new string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#Code";
public new string GetSelfUrn() => "bamm-c:Code";
}

/// <summary>
Expand All @@ -870,7 +870,7 @@ public class Either : Characteristic, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-either";
public new string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#Either";
public new string GetSelfUrn() => "bamm-c:Either";

/// <summary>
/// The left side of the Either. The attribute references another Characteristic which describes the value.
Expand Down Expand Up @@ -901,7 +901,7 @@ public class SingleEntity : Characteristic, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-single-entity";
public new string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#SingleEntity";
public new string GetSelfUrn() => "bamm-c:SingleEntity";
}

/// <summary>
Expand All @@ -916,7 +916,7 @@ public class StructuredValue: Characteristic, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-structured-value";
public new string GetSelfUrn() => "urn:bamm:io.openmanufacturing:characteristic:1.0.0#StructuredValue";
public new string GetSelfUrn() => "bamm-c:StructuredValue";

/// <summary>
/// The regular expression used to deconstruct the value into parts that are mapped to separate
Expand Down Expand Up @@ -950,7 +950,7 @@ public class Property : ModelElement, ISammSelfDescription, ISammStructureModel
{
// self description
public string GetSelfName() => "samm-property";
public string GetSelfUrn() => "urn:bamm:io.openmanufacturing:meta-model:1.0.0#Property";
public string GetSelfUrn() => "bamm:Property";

// structure model
public bool IsTopElement() => false;
Expand Down Expand Up @@ -988,7 +988,7 @@ public class Entity : ModelElement, ISammSelfDescription, ISammStructureModel
{
// self description
public string GetSelfName() => "samm-entity";
public string GetSelfUrn() => "urn:bamm:io.openmanufacturing:meta-model:1.0.0#Entity";
public string GetSelfUrn() => "bamm:Entity";

// structure model
public bool IsTopElement() => false;
Expand Down Expand Up @@ -1018,7 +1018,7 @@ public class Aspect : ModelElement, ISammSelfDescription, ISammStructureModel
{
// self description
public string GetSelfName() => "samm-aspect";
public string GetSelfUrn() => "urn:bamm:io.openmanufacturing:meta-model:1.0.0#Aspect";
public string GetSelfUrn() => "bamm:Aspect";

// structure model
public bool IsTopElement() => true;
Expand Down Expand Up @@ -1066,7 +1066,7 @@ public class Unit : ModelElement, ISammSelfDescription
{
// self description
public string GetSelfName() => "samm-unit";
public string GetSelfUrn() => "urn:bamm:io.openmanufacturing:meta-model:1.0.0#Unit";
public string GetSelfUrn() => "bamm:Unit";

/// <summary>
/// Normalized short code for unit; please refer to the original
Expand Down Expand Up @@ -1435,8 +1435,13 @@ static Util()
if (Activator.CreateInstance(st, new object[] { }) is ISammSelfDescription ssd)
{
// assumption: RDF matching is case sensitive?!
SammUrnToType.Add(ssd.GetSelfUrn(), st);
SammTypeToName.Add(st, "" + ssd.GetSelfName());
var fullUri = Constants.SelfNamespaces.ExtendUri(ssd.GetSelfUrn());

if (fullUri != null)
{
SammUrnToType.Add(fullUri, st);
SammTypeToName.Add(st, "" + ssd.GetSelfName());
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/AasxPackageExplorer/debug.MIHO.script
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
// Select("Submodel", "Next");
// Tool("exportsmtasciidoc", "File", "C:\\HOMI\\Develop\\Aasx\\repo\\new.zip", "ExportHtml", "true");
// Tool("Exit");
Tool("sammaspectimport", "File", "C:\\HOMI\\Develop\\Aasx\\repo\\BatteryPass-spiel.ttl");
Tool("sammaspectimport", "File", "C:\\HOMI\\Develop\\Aasx\\repo\\BatteryPass-spiel-short.ttl");
116 changes: 66 additions & 50 deletions src/AasxPackageLogic/DispEditHelperModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2565,8 +2565,10 @@ public AnyUiLambdaActionBase SammExtensionHelperSammReferenceAction<T>(
var newSammExt = new Aas.Extension(
name: "" + newSammSsd?.GetSelfName(),
semanticId: new Aas.Reference(ReferenceTypes.ExternalReference,
(new[] { new Aas.Key(KeyTypes.GlobalReference,
newSammSsd.GetSelfUrn()) })
(new[] {
new Aas.Key(KeyTypes.GlobalReference,
"" + Samm.Constants.SelfNamespaces.ExtendUri(newSammSsd.GetSelfUrn()))
})
.Cast<Aas.IKey>().ToList()),
value: "");
newCD.Extensions = new List<IExtension> { newSammExt };
Expand Down Expand Up @@ -2958,9 +2960,11 @@ public void DisplayOrEditEntitySammExtensions(
new Aas.Extension(
name: ssd.GetSelfName(),
semanticId: new Aas.Reference(ReferenceTypes.ExternalReference,
(new[] { new Aas.Key(KeyTypes.GlobalReference,
ssd.GetSelfUrn()) })
.Cast<Aas.IKey>().ToList()),
(new[] {
new Aas.Key(KeyTypes.GlobalReference,
"" + Samm.Constants.SelfNamespaces.ExtendUri(ssd.GetSelfUrn()))
})
.Cast<Aas.IKey>().ToList()),
value: ""));
}
Expand Down Expand Up @@ -3370,50 +3374,60 @@ public static List<T> ImportSammModelParseRdfCollection<T>(

var lsr = new List<T>();
INode collPtr = collectionStart;
while (collPtr != null && collPtr.NodeType == NodeType.Blank)
{
// the collection pointer needs to have a first relationship
var firstRel = g.GetTriplesWithSubjectPredicate(
subj: collPtr,
pred: new UriNode(new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#first")))
.FirstOrDefault();
if (firstRel?.Object == null)
break;

// investigate, if first.object is a automatic/composite or an end node
if (firstRel.Object.NodeType == NodeType.Uri
|| firstRel.Object.NodeType == NodeType.Literal)
{
// first.object is something tangible
lsr.Add(createInstance?.Invoke(firstRel.Object.ToSafeString(), false));
}
else
{
// crawl firstRel.Object further to get individual end notes
string propElem = null;
bool? optional = null;

foreach (var x3 in g.GetTriplesWithSubject(firstRel.Object))
{
if (x3.Predicate.Equals(new UriNode(
new Uri("urn:bamm:io.openmanufacturing:meta-model:1.0.0#property"))))
propElem = x3.Object.ToSafeString();
if (x3.Predicate.Equals(
new UriNode(new Uri("urn:bamm:io.openmanufacturing:meta-model:1.0.0#optional"))))
optional = x3.Object.ToSafeString() == "true^^http://www.w3.org/2001/XMLSchema#boolean";
}
if (collPtr != null && (collPtr.NodeType == NodeType.Uri || collPtr.NodeType == NodeType.Literal))
{
// only a single member is given
lsr.Add(createInstance?.Invoke(RdfHelper.GetLiteralStrValue(collPtr), false));
}
else
{
// a chain of instances is given
while (collPtr != null && collPtr.NodeType == NodeType.Blank)
{
// the collection pointer needs to have a first relationship
var firstRel = g.GetTriplesWithSubjectPredicate(
subj: collPtr,
pred: new UriNode(new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#first")))
.FirstOrDefault();
if (firstRel?.Object == null)
break;

// investigate, if first.object is a automatic/composite or an end node
if (firstRel.Object.NodeType == NodeType.Uri
|| firstRel.Object.NodeType == NodeType.Literal)
{
// first.object is something tangible
lsr.Add(createInstance?.Invoke(firstRel.Object.ToSafeString(), false));
}
else
{
// crawl firstRel.Object further to get individual end notes
string propElem = null;
bool? optional = null;

if (propElem != null)
lsr.Add(createInstance?.Invoke(propElem, optional.Value));
}
foreach (var x3 in g.GetTriplesWithSubject(firstRel.Object))
{
if (x3.Predicate.Equals(new UriNode(
new Uri("urn:bamm:io.openmanufacturing:meta-model:1.0.0#property"))))
propElem = x3.Object.ToSafeString();
if (x3.Predicate.Equals(
new UriNode(new Uri("urn:bamm:io.openmanufacturing:meta-model:1.0.0#optional"))))
optional = x3.Object.ToSafeString() == "true^^http://www.w3.org/2001/XMLSchema#boolean";
}

// iterate further
var restRel = g.GetTriplesWithSubjectPredicate(
subj: collPtr,
pred: new UriNode(new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#rest")))
.FirstOrDefault();
collPtr = restRel?.Object;
}
if (propElem != null)
lsr.Add(createInstance?.Invoke(propElem, optional.Value));
}

// iterate further
var restRel = g.GetTriplesWithSubjectPredicate(
subj: collPtr,
pred: new UriNode(new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#rest")))
.FirstOrDefault();
collPtr = restRel?.Object;
}
}

return lsr;
}
Expand Down Expand Up @@ -3640,16 +3654,18 @@ public static void ImportSammModelToConceptDescriptions(
var newCD = new Aas.ConceptDescription(
id: newId,
idShort: newIdShort,
description: cdDesc.Cast<Aas.ILangStringTextType>().ToList());
description: cdDesc?.Cast<Aas.ILangStringTextType>().ToList());

// create new SAMM element
var newSammSsd = sammInst as Samm.ISammSelfDescription;
var newSammExt = new Aas.Extension(
name: "" + newSammSsd?.GetSelfName(),
semanticId: new Aas.Reference(ReferenceTypes.ExternalReference,
(new[] { new Aas.Key(KeyTypes.GlobalReference,
newSammSsd.GetSelfUrn()) })
.Cast<Aas.IKey>().ToList()),
(new[] {
new Aas.Key(KeyTypes.GlobalReference,
"" + Samm.Constants.SelfNamespaces.ExtendUri(newSammSsd.GetSelfUrn()))
})
.Cast<Aas.IKey>().ToList()),
value: "");
newCD.Extensions = new List<IExtension> { newSammExt };

Expand Down

0 comments on commit 8782de1

Please sign in to comment.