private static RelationshipElement setRealtionshipElement(UANode node) { //RelationshipElement // -> First (Reference) // -> Second (Reference) RelationshipElement elem = new RelationshipElement(); foreach (Reference _ref in node.References) { if (_ref.ReferenceType != "HasTypeDefinition") { UAVariable var = (UAVariable)findNode(_ref.Value); if (var.BrowseName == "1:First") { elem.first = createReference(var.Value.InnerText); } if (var.BrowseName == "1:Second") { elem.second = createReference(var.Value.InnerText); } } } return(elem); }
public MetadataEntityComplexProperty(string name, string associationName, string from, string to) : base(name) { if(string.IsNullOrWhiteSpace(associationName)) throw new ArgumentNullException("associationName"); _relationship = new RelationshipElement(this, associationName, from, to); }
public MetadataEntityComplexProperty(string name, string associationName, string from, string to) : base(name) { if (string.IsNullOrWhiteSpace(associationName)) { throw new ArgumentNullException("associationName"); } _relationship = new RelationshipElement(this, associationName, from, to); }
private void AddPartyElementToList(PartyElement partyElement, RelationshipElement relationshipElement, Presence presence = null) { var party = GwupeClientAppContext.CurrentAppContext.PartyManager.AddUpdatePartyFromElement(partyElement); // Make sure we update the relationship GwupeClientAppContext.CurrentAppContext.RelationshipManager.AddUpdateRelationship(party.Username, new Relationship(relationshipElement)); // This is to update the party in the background (avatar) ThreadPool.QueueUserWorkItem(state => GwupeClientAppContext.CurrentAppContext.PartyManager.GetParty(partyElement.user, true)); // Now add it to the list AddPartyToList(party, presence); }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (RelationshipElement != null) { result.AddRange(RelationshipElement.Validate()); } if (Target != null) { Target.ForEach(elem => result.AddRange(elem.Validate())); } return(result); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as RelatedEntryComponent; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (RelationshipElement != null) { dest.RelationshipElement = (Code <Hl7.Fhir.Model.CatalogEntry.CatalogEntryRelationType>)RelationshipElement.DeepCopy(); } if (Target != null) { dest.Target = (Hl7.Fhir.Model.ResourceReference)Target.DeepCopy(); } return(dest); }
public void InitRelationship(RelationshipElement relationshipElement) { IHaveUnattendedAccess = relationshipElement.ihaveUnattendedAccess; TheyHaveUnattendedAccess = relationshipElement.theyHaveUnattendedAccess; }
public Relationship(RelationshipElement relationshipElement) { InitRelationship(relationshipElement); }
public static ISubmodelElement ToSubmodelElement(this SubmodelElementType_V1_0 envSubmodelElement, List <IConceptDescription> conceptDescriptions) { if (envSubmodelElement == null) { logger.Warn("EnvironmentSubmodelElement is null"); return(null); } ModelType modelType = envSubmodelElement.ModelType; if (modelType == null) { logger.Warn("ModelType of Element " + envSubmodelElement.IdShort + " is null"); return(null); } SubmodelElement submodelElement = null; if (modelType == ModelType.Property && envSubmodelElement is Property_V1_0 castedProperty) { Property property; if (DataObjectType.TryParse(castedProperty.ValueType, out DataObjectType dataObjectType)) { property = new Property(new DataType(dataObjectType)); } else { logger.Warn("Unable to parse ValueType of Property " + castedProperty.IdShort + " - ValueType: " + castedProperty.ValueType); property = new Property(); } property.Value = castedProperty.Value; property.ValueId = castedProperty.ValueId?.ToReference_V1_0(); submodelElement = property; } else if (modelType == ModelType.File && envSubmodelElement is File_V1_0 castedFile) { File file = new File { MimeType = castedFile.MimeType, Value = castedFile.Value }; submodelElement = file; } else if (modelType == ModelType.Blob && envSubmodelElement is Blob_V1_0 castedBlob) { Blob blob = new Blob { MimeType = castedBlob.MimeType, Value = Convert.FromBase64String(castedBlob.Value) }; submodelElement = blob; } else if (modelType == ModelType.RelationshipElement && envSubmodelElement is RelationshipElement_V1_0 castedRelationshipElement) { RelationshipElement relationshipElement = new RelationshipElement { First = castedRelationshipElement.First?.ToReference_V1_0 <IReferable>(), Second = castedRelationshipElement.Second?.ToReference_V1_0 <IReferable>() }; submodelElement = relationshipElement; } else if (modelType == ModelType.ReferenceElement && envSubmodelElement is ReferenceElement_V1_0 castedReferenceElement) { ReferenceElement referenceElement = new ReferenceElement { Value = castedReferenceElement.Value?.ToReference_V1_0() }; submodelElement = referenceElement; } else if (modelType == ModelType.Event && envSubmodelElement is Event_V1_0 castedEvent) { Event eventable = new Event(); submodelElement = eventable; } else if (modelType == ModelType.Operation && envSubmodelElement is Operation_V1_0 castedOperation) { Operation operation = new Operation { InputVariables = new OperationVariableSet(), OutputVariables = new OperationVariableSet() }; var operationInElements = castedOperation.In?.ConvertAll(c => c.Value?.submodelElement?.ToSubmodelElement(conceptDescriptions)); if (operationInElements?.Count > 0) { foreach (var element in operationInElements) { operation.InputVariables.Add(element); } } var operationOutElements = castedOperation.Out?.ConvertAll(c => c.Value?.submodelElement?.ToSubmodelElement(conceptDescriptions)); if (operationOutElements?.Count > 0) { foreach (var element in operationOutElements) { operation.OutputVariables.Add(element); } } submodelElement = operation; } else if (modelType == ModelType.SubmodelElementCollection && envSubmodelElement is SubmodelElementCollection_V1_0 castedSubmodelElementCollection) { SubmodelElementCollection submodelElementCollection = new SubmodelElementCollection(); if (castedSubmodelElementCollection.Value?.Count > 0) { submodelElementCollection.Value = new ElementContainer <ISubmodelElement>(); List <ISubmodelElement> smElements = castedSubmodelElementCollection.Value?.ConvertAll(c => c.submodelElement?.ToSubmodelElement(conceptDescriptions)); foreach (var smElement in smElements) { submodelElementCollection.Value.Add(smElement); } } submodelElement = submodelElementCollection; } if (submodelElement == null) { logger.Warn("SubmodelElement " + envSubmodelElement.IdShort + " is still null"); return(null); } submodelElement.Category = envSubmodelElement.Category; submodelElement.Description = envSubmodelElement.Description; submodelElement.IdShort = envSubmodelElement.IdShort; submodelElement.Kind = envSubmodelElement.Kind; submodelElement.SemanticId = envSubmodelElement.SemanticId?.ToReference_V1_0(); submodelElement.Constraints = null; string semanticId = envSubmodelElement.SemanticId?.Keys?.FirstOrDefault()?.Value; if (!string.IsNullOrEmpty(semanticId)) { submodelElement.ConceptDescription = conceptDescriptions.Find(f => f.Identification.Id == semanticId); submodelElement.EmbeddedDataSpecifications = submodelElement.ConceptDescription?.EmbeddedDataSpecifications; } return(submodelElement); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as SpecimenSourceComponent; if (dest != null) { base.CopyTo(dest); if (RelationshipElement != null) { dest.RelationshipElement = (Code <Hl7.Fhir.Model.Specimen.HierarchicalRelationshipType>)RelationshipElement.DeepCopy(); } if (Target != null) { dest.Target = new List <Hl7.Fhir.Model.ResourceReference>(Target.DeepCopy()); } return(dest); } else { throw new ArgumentException("Can only copy to an object of the same type", "other"); } }
public static ISubmodelElement ToSubmodelElement(this SubmodelElementType_V2_0 envSubmodelElement, List <IConceptDescription> conceptDescriptions) { if (envSubmodelElement == null) { return(null); } ModelType modelType = envSubmodelElement.ModelType; if (modelType == null) { return(null); } SubmodelElement submodelElement = null; if (modelType == ModelType.Property && envSubmodelElement is Property_V2_0 castedProperty) { DataObjectType dataObjectType; if (string.IsNullOrEmpty(castedProperty.ValueType)) { dataObjectType = DataObjectType.None; } else if (!DataObjectType.TryParse(castedProperty.ValueType, out dataObjectType)) { return(null); } Property property = new Property(new DataType(dataObjectType)) { Value = castedProperty.Value, ValueId = castedProperty.ValueId?.ToReference_V2_0() }; submodelElement = property; } else if (modelType == ModelType.MultiLanguageProperty && envSubmodelElement is MultiLanguageProperty_V2_0 castedMultiLanguageProperty) { MultiLanguageProperty multiLanguageProperty = new MultiLanguageProperty { Value = castedMultiLanguageProperty.Value, ValueId = castedMultiLanguageProperty.ValueId?.ToReference_V2_0() }; submodelElement = multiLanguageProperty; } else if (modelType == ModelType.Range && envSubmodelElement is Range_V2_0 castedRange) { if (!DataObjectType.TryParse(castedRange.ValueType, out DataObjectType dataObjectType)) { return(null); } Range range = new Range() { Min = new ElementValue(castedRange.Min, new DataType(dataObjectType)), Max = new ElementValue(castedRange.Max, new DataType(dataObjectType)), ValueType = new DataType(dataObjectType) }; submodelElement = range; } else if (modelType == ModelType.File && envSubmodelElement is File_V2_0 castedFile) { File file = new File { MimeType = castedFile.MimeType, Value = castedFile.Value }; submodelElement = file; } else if (modelType == ModelType.Blob && envSubmodelElement is Blob_V2_0 castedBlob) { Blob blob = new Blob { MimeType = castedBlob.MimeType, Value = Convert.FromBase64String(castedBlob.Value) }; submodelElement = blob; } else if (modelType == ModelType.RelationshipElement && envSubmodelElement is RelationshipElement_V2_0 castedRelationshipElement) { RelationshipElement relationshipElement = new RelationshipElement { First = castedRelationshipElement.First?.ToReference_V2_0 <IReferable>(), Second = castedRelationshipElement.Second?.ToReference_V2_0 <IReferable>() }; submodelElement = relationshipElement; } else if (modelType == ModelType.AnnotatedRelationshipElement && envSubmodelElement is AnnotatedRelationshipElement_V2_0 castedAnnotatedRelationshipElement) { AnnotatedRelationshipElement annotatedRelationshipElement = new AnnotatedRelationshipElement() { First = castedAnnotatedRelationshipElement.First?.ToReference_V2_0 <IReferable>(), Second = castedAnnotatedRelationshipElement.Second?.ToReference_V2_0 <IReferable>(), Annotation = castedAnnotatedRelationshipElement.Annotation?.ToReference_V2_0 <ISubmodelElement>() }; submodelElement = annotatedRelationshipElement; } else if (modelType == ModelType.ReferenceElement && envSubmodelElement is ReferenceElement_V2_0 castedReferenceElement) { ReferenceElement referenceElement = new ReferenceElement { Value = castedReferenceElement.Value?.ToReference_V2_0() }; submodelElement = referenceElement; } else if (modelType == ModelType.Event && envSubmodelElement is Event_V2_0 castedEvent) { Event eventable = new Event(); submodelElement = eventable; } else if (modelType == ModelType.BasicEvent && envSubmodelElement is BasicEvent_V2_0 castedBasicEvent) { BasicEvent basicEvent = new BasicEvent() { Observed = castedBasicEvent.Observed.ToReference_V2_0 <IReferable>() }; submodelElement = basicEvent; } else if (modelType == ModelType.Entity && envSubmodelElement is Entity_V2_0 castedEntity) { Entity entity = new Entity() { EntityType = (EntityType)Enum.Parse(typeof(EntityType), castedEntity.EntityType.ToString()), Asset = castedEntity.AssetReference.ToReference_V2_0 <IAsset>() }; var statements = castedEntity.Statements?.ConvertAll(c => c.submodelElement.ToSubmodelElement(conceptDescriptions)); if (statements?.Count > 0) { foreach (var element in statements) { entity.Statements.Add(element); } } submodelElement = entity; } else if (modelType == ModelType.Operation && envSubmodelElement is Operation_V2_0 castedOperation) { Operation operation = new Operation { InputVariables = new OperationVariableSet(), OutputVariables = new OperationVariableSet(), InOutputVariables = new OperationVariableSet() }; var operationInElements = castedOperation.InputVariables?.ConvertAll(c => c.Value?.submodelElement?.ToSubmodelElement(conceptDescriptions)); if (operationInElements?.Count > 0) { foreach (var element in operationInElements) { operation.InputVariables.Add(element); } } var operationOutElements = castedOperation.OutputVariables?.ConvertAll(c => c.Value?.submodelElement?.ToSubmodelElement(conceptDescriptions)); if (operationOutElements?.Count > 0) { foreach (var element in operationOutElements) { operation.OutputVariables.Add(element); } } var operationInOutElements = castedOperation.InOutputVariables?.ConvertAll(c => c.Value?.submodelElement?.ToSubmodelElement(conceptDescriptions)); if (operationInOutElements?.Count > 0) { foreach (var element in operationInOutElements) { operation.InOutputVariables.Add(element); } } submodelElement = operation; } else if (modelType == ModelType.SubmodelElementCollection && envSubmodelElement is SubmodelElementCollection_V2_0 castedSubmodelElementCollection) { SubmodelElementCollection submodelElementCollection = new SubmodelElementCollection(); if (castedSubmodelElementCollection.Value?.Count > 0) { submodelElementCollection.Value = new ElementContainer <ISubmodelElement>(); List <ISubmodelElement> smElements = castedSubmodelElementCollection.Value?.ConvertAll(c => c.submodelElement?.ToSubmodelElement(conceptDescriptions)); foreach (var smElement in smElements) { submodelElementCollection.Value.Add(smElement); } } submodelElement = submodelElementCollection; } if (submodelElement == null) { return(null); } submodelElement.Category = envSubmodelElement.Category; submodelElement.Description = envSubmodelElement.Description; submodelElement.IdShort = envSubmodelElement.IdShort; submodelElement.Kind = envSubmodelElement.Kind; submodelElement.SemanticId = envSubmodelElement.SemanticId?.ToReference_V2_0(); submodelElement.Parent = string.IsNullOrEmpty(envSubmodelElement.Parent) ? null : new Reference( new Key(KeyElements.AssetAdministrationShell, KeyType.IRI, envSubmodelElement.Parent, true)); submodelElement.Constraints = null; string semanticId = envSubmodelElement.SemanticId?.Keys?.FirstOrDefault()?.Value; if (!string.IsNullOrEmpty(semanticId)) { submodelElement.ConceptDescription = conceptDescriptions.Find(f => f.Identification.Id == semanticId); submodelElement.EmbeddedDataSpecifications = submodelElement.ConceptDescription?.EmbeddedDataSpecifications; } return(submodelElement); }