public void Push(VisualElementGeneric ve) { // access if (ve == null) { return; } // for ve, try to find the AAS (in the parent hierarchy) var veAas = ve.FindAllParents((v) => { return(v is VisualElementAdminShell); }, includeThis: true).FirstOrDefault(); // for ve, find the Referable to be ve or superordinate .. var veRef = ve.FindAllParents((v) => { var derefdo = v?.GetDereferencedMainDataObject(); // success implies AdminShell.IGetReference as well return(derefdo is AdminShell.Referable); }, includeThis: true).FirstOrDefault(); // check, if ve can identify a Referable, to which a symbolic link can be done .. AdminShell.Identification aasid = null; AdminShell.Reference refref = null; if (veAas != null && veRef != null) { aasid = (veAas as VisualElementAdminShell)?.theAas?.identification; var derefdo = veRef.GetDereferencedMainDataObject(); refref = (derefdo as AdminShell.IGetReference)?.GetReference(); } // some more special cases if (refref == null && ve is VisualElementConceptDescription vecd) { refref = vecd.theCD?.GetReference(); } // found some referable Reference? if (refref == null) { return; } // in case of plug in, make it more specific if (ve is VisualElementPluginExtension vepe && vepe.theExt?.Tag != null) { refref += new AdminShell.Key(AdminShell.Key.FragmentReference, false, AdminShell.Key.Custom, "Plugin:" + vepe.theExt.Tag); } // add, only if not already there if (history.Count < 1 || history[history.Count - 1].VisualElement != ve) { history.Add(new VisualElementHistoryItem(ve, aasid, refref)); } // is enabled buttonBack.IsEnabled = true; }
public VisualElementHistoryItem(VisualElementGeneric VisualElement, AdminShell.Identification ReferableAasId = null, AdminShell.Reference ReferableReference = null) { this.VisualElement = VisualElement; this.ReferableAasId = ReferableAasId; this.ReferableReference = ReferableReference; }
/// <summary> /// Use this always to lookup node records from Indentifiable /// </summary> /// <param name="identification"></param> /// <returns></returns> public NodeRecord LookupNodeRecordFromIdentification(AdminShell.Identification identification) { var hash = identification.idType.Trim().ToUpper() + "|" + identification.id.Trim().ToUpper(); if (NodeRecordFromReferable == null || !NodeRecordFromIdentificationHash.ContainsKey(hash)) { return(null); } return(NodeRecordFromIdentificationHash[hash]); }
public AasxHttpHandleIdentification(AdminShell.Identification src, string keyPreset = null) { if (keyPreset == null) { this.Key = $"@ID{counter++:00000000}"; } else { this.Key = keyPreset; } this.ExpiresInternal = DateTime.UtcNow.AddMinutes(60); this.Expires = this.ExpiresInternal.ToString("R"); this.identification = new AdminShell.Identification(src); }
private string GenerateTopic(string template, string defaultIfNull = null, string aasIdShort = null, AdminShell.Identification aasId = null, string smIdShort = null, AdminShell.Identification smId = null, string path = null) { var res = template; if (defaultIfNull != null && res == null) { res = defaultIfNull; } if (aasIdShort != null) { res = res.Replace("{aas}", "" + aasIdShort); } if (aasId?.id != null) { res = res.Replace("{aas-id}", "" + System.Net.WebUtility.UrlEncode(aasId.id)); } if (smIdShort != null) { res = res.Replace("{sm}", "" + smIdShort); } if (smId?.id != null) { res = res.Replace("{sm-id}", "" + System.Net.WebUtility.UrlEncode(smId.id)); } if (path != null) { res = res.Replace("{path}", path); } // make sure that topic are not starting / ending with '/' res = res.Trim(' ', '/'); return(res); }
public NodeRecord(NodeState uanode, AdminShell.Identification identification) { this.uanode = uanode; this.identification = identification; }
/// <summary> /// Top level creation functions. Uses the definitions of RootAAS, RootConceptDescriptions, /// RootDataSpecifications to synthesize information model /// </summary> public void CreateAddInstanceObjects(AdminShell.AdministrationShellEnv env) { if (RootAAS == null) { return; } // CDs (build 1st to be "remembered" as targets for "HasDictionaryEntry") if (env.ConceptDescriptions != null && this.RootConceptDescriptions != null) { foreach (var cd in env.ConceptDescriptions) { this.AasTypes.ConceptDescription.CreateAddElements(this.RootConceptDescriptions, AasUaBaseEntity.CreateMode.Instance, cd); } } // AAS if (env.AdministrationShells != null) { foreach (var aas in env.AdministrationShells) { this.AasTypes.AAS.CreateAddInstanceObject(RootAAS, env, aas); } } // go through late actions foreach (var la in this.noteLateActions) { // make a Reference ?? var lax = la as NodeLateActionLinkToReference; // more simple case: AasReference between known entities if (lax != null && lax.actionType == NodeLateActionLinkToReference.ActionType.SetAasReference && lax.uanode != null && this.package != null && this.package.AasEnv != null) { // 1st, take reference and turn it into Referable var targetReferable = this.package.AasEnv.FindReferableByReference(lax.targetReference); if (targetReferable == null) { continue; } // 2nd, try to lookup the Referable and turn it into a uanode var targetNodeRec = this.LookupNodeRecordFromReferable(targetReferable); if (targetNodeRec == null || targetNodeRec.uanode == null) { continue; } // now, we have everything to formulate a reference lax.uanode.AddReference(this.AasTypes.HasAasReference.GetTypeNodeId(), false, targetNodeRec.uanode.NodeId); } // a bit more complicated: could include a "empty reference" to outside concept if (lax != null && lax.actionType == NodeLateActionLinkToReference.ActionType.SetDictionaryEntry && lax.uanode != null && this.package != null && this.package.AasEnv != null) { // tracking var foundAtAll = false; // 1st, take reference and turn it into Referable var targetReferable = this.package.AasEnv.FindReferableByReference(lax.targetReference); if (targetReferable != null) { // 2nd, try to lookup the Referable and turn it into a uanode var targetNodeRec = this.LookupNodeRecordFromReferable(targetReferable); if (targetNodeRec != null && targetNodeRec.uanode != null) { // simple case: have a target node, just make a link lax.uanode.AddReference(this.AasTypes.HasDictionaryEntry.GetTypeNodeId(), false, targetNodeRec.uanode.NodeId); foundAtAll = true; } } // make "empty reference"?? // by definition, this makes only sense if the targetReference has exactly 1 key, as we could // only have one key in a dictionary entry if (!foundAtAll && lax.targetReference.Keys.Count == 1) { // can turn the targetReference to a simple identification var targetId = new AdminShell.Identification(lax.targetReference.Keys[0].idType, lax.targetReference.Keys[0].value); // we might have such an (empty) target already available as uanode var nr = this.LookupNodeRecordFromIdentification(targetId); if (nr != null) { // just create the missing link lax.uanode.AddReference(this.AasTypes.HasDictionaryEntry.GetTypeNodeId(), false, nr.uanode?.NodeId); } else { // create NEW empty reference? if (this.RootMissingDictionaryEntries != null) { // create missing object var miss = this.CreateAddObject( this.RootMissingDictionaryEntries, AasUaBaseEntity.CreateMode.Instance, targetId.id, ReferenceTypeIds.HasComponent, this.AasTypes.ConceptDescription.GetTypeObjectFor(targetId)?.NodeId); // add the reference lax.uanode.AddReference(this.AasTypes.HasDictionaryEntry.GetTypeNodeId(), false, miss?.NodeId); // put it into the NodeRecords, that it can be re-used?? no!! this.AddNodeRecord(new AasEntityBuilder.NodeRecord(miss, targetId)); } else { // just create the missing link // TODO (MIHO, 2020-08-06): check, which namespace shall be used var missingTarget = new ExpandedNodeId("" + targetId.id, 99); lax.uanode.AddReference(this.AasTypes.HasDictionaryEntry.GetTypeNodeId(), false, missingTarget); } } } } } }
protected ContextResult CreateBodyCD( ImportCellMatchContextBase context, AdminShell.AdministrationShellEnv env) { // access if (context?.Sme == null || context?.CD == null || env == null || _options == null) { return(null); } // first test, if the CD already exists var test = env.FindConceptDescription(context.Sme.semanticId); if (test != null) { return new ContextResult() { Elem = test } } ; // a semanticId is required to link the Sme and the CD together if (context.Sme.semanticId == null || context.Sme.semanticId.Count < 1) { // generate a new one for SME + CD // this modifies the SME! var id = new AdminShell.Identification( AdminShell.Identification.IRI, AdminShellUtil.GenerateIdAccordingTemplate(_options.TemplateIdConceptDescription)); context.Sme.semanticId = new AdminShell.SemanticId( new AdminShell.Key(AdminShell.Key.ConceptDescription, true, id.idType, id.id)); } // create, add var cd = new AdminShell.ConceptDescription(context?.CD); env.ConceptDescriptions.Add(cd); var res = new ContextResult() { Elem = cd }; // link CD to SME var sid = context.Sme.semanticId.GetAsExactlyOneKey(); if (sid == null) { // should not happen, see above return(null); } cd.identification = new AdminShell.Identification(sid.idType, sid.value); // some further attributes if (!cd.idShort.HasContent()) { cd.idShort = context.Sme.idShort; } // ok return(res); }