public async Task <AttachedAttrData> GetAttachedAttribute(IAttachedProperty <IAttr> attr) { var plainAttr = await attr.GetProperty(); var required = await attr.IsRequired(); var cardinality = await attr.GetCardinality(); var mutable = await attr.GetMutability(); var permission = await attr.GetPermission(); var provider = await GetProvider(attr.AttachmentID); var attrData = await AttrData.Instantiate(plainAttr); var defaultValue = await attr.GetDefaultValue(); IBoxedValue boxedDefaultValue = null; if (null != defaultValue) { var shownValue = attrData.Values.Where(a => a.EventID.ToString() == defaultValue).SingleOrDefault(); boxedDefaultValue = new BoxedValueData(defaultValue, shownValue?.Value ?? defaultValue); } return(new AttachedAttrData(attrData, required, cardinality, mutable, permission, boxedDefaultValue, provider, attr.Conditions, attr.AttachmentID)); }
public PropertyContainerData(PropertyProviderData provider, IBoxedValue value = null, bool fixedValue = false) { this.provider = provider; Value = value; Fixed = fixedValue; attributes = new Dictionary <int, IEnumerable <PropertyContainerData> >(); relations = new Dictionary <int, IEnumerable <PropertyContainerData> >(); Initialize(); }
public AttachedAttrData( AttrData attr, bool required, int cardinality, bool mutable, int?permission, IBoxedValue defaultValue, ConditionRule conditions ) : this(attr, required, cardinality, mutable, permission, defaultValue, conditions, null) { PropertyProvider = new PropertyProviderData(); AttachmentID = null; }
public AttachedAttrData( AttrData attr, bool required, int cardinality, bool mutable, int?permission, IBoxedValue defaultValue, PropertyProviderData provider, ConditionRule conditions, int attachmentID ) : this(attr, required, cardinality, mutable, permission, defaultValue, conditions, provider) { AttachmentID = attachmentID; }
public PropertyContainerData( PropertyProviderData provider, Dictionary <int, IEnumerable <PropertyContainerData> > attributes, Dictionary <int, IEnumerable <PropertyContainerData> > relations, int containerID, string actorName, IBoxedValue value = null ) { this.provider = provider; Value = value; ActorName = actorName; this.attributes = attributes; this.relations = relations; this.ContainerID = containerID; Initialize(); }
public void AddRelationValue(int relationID, IBoxedValue value) { if (!Relations.ContainsKey(relationID)) { relations.Add(relationID, new List <PropertyContainerData>()); } var list = (List <PropertyContainerData>)relations[relationID]; var subProvider = provider.Relations[relationID].PropertyProvider; if (provider.Relations[relationID].Mutable) { list.Clear(); } list.Add(new PropertyContainerData(subProvider, value)); }
public void AddAttributeValue(int attributeID, IBoxedValue value, bool fixedValue = false) { if (!Attributes.ContainsKey(attributeID)) { attributes.Add(attributeID, new List <PropertyContainerData>()); } var list = (List <PropertyContainerData>)attributes[attributeID]; var subProvider = provider.Attributes[attributeID].PropertyProvider; if (provider.Attributes[attributeID].Mutable) { list.Clear(); } list.Add(new PropertyContainerData(subProvider, value, fixedValue)); }
public async Task <IBoxedValue> SetAttributeValue(AttachedAttrData attr, IBoxedValue value) { var parameters = new ModalParameters(); parameters.Add("ModelAttr", attr); parameters.Add("Value", value); var modal = instance.Show <SetAttributeValue>("Set attribute", parameters); var result = await modal.Result; if (result.Data is IBoxedValue resultValue) { return(resultValue); } else { return(null); } }
private AttachedAttrData( AttrData attr, bool required, int cardinality, bool mutable, int?permission, IBoxedValue defaultValue, ConditionRule conditions, PropertyProviderData provider ) { Attribute = attr; Required = required; Cardinality = cardinality; Mutable = mutable; Permission = permission; Conditions = conditions; DefaultValue = defaultValue; PropertyProvider = provider; }
public void SetValue(IBoxedValue value) { Value = value; }
private async Task CreatePropertyConstraints(int assignationID, int propertyID, bool required, int cardinality, bool mutable, int?permission, IBoxedValue defaultValue) { if (Const.DefaultRequired != required) { await tx.AssignPropertyValueRequirement(assignationID, propertyID, required); } if (Const.DefaultCardinality != cardinality) { await tx.AssignPropertyValueCardinality(assignationID, propertyID, cardinality); } if (Const.DefaultMutability != mutable) { await tx.AssignPropertyValueMutability(assignationID, propertyID, mutable); } if (permission.HasValue) { await tx.AssignPropertyValuePermission(assignationID, propertyID, permission.Value); } if (null != defaultValue) { await tx.AssignPropertyValueSet(assignationID, propertyID, defaultValue.PlainValue); } }
public async Task <IBoxedValue> SetRelationValue(AttachedRelationData relation, IBoxedValue value) { var parameters = new ModalParameters(); parameters.Add("ModelRelation", relation); parameters.Add("Value", value); var modal = instance.Show <SetRelationValue>("Set relation", parameters); var result = await modal.Result; if (result.Data is IBoxedValue resultValue) { return(resultValue); } else { return(null); } }
public async Task <PropertyContainerData> GetPropertyContainer(int containerID, IBoxedValue value = null) { var container = await storage.GetPropertyContainer(containerID); var plainAttributes = await container.GetAttributes(); var plainRelations = await container.GetRelations(); var resultAttributes = new Dictionary <int, IEnumerable <PropertyContainerData> >(); var resultRelations = new Dictionary <int, IEnumerable <PropertyContainerData> >(); var containerEvent = await storage.GetEvent(containerID); var actorEvent = await storage.GetEvent(containerEvent.EventValue.ActorEventID); var parentEvent = await storage.GetEvent(containerEvent.EventValue.BaseEventID); var providerEvent = await parentEvent.GetConditionEvent(); var provider = await propertyProvider.GetProvider(providerEvent.EventValue.ID); foreach (var kv in plainAttributes) { var newValues = await Task.WhenAll( kv.Value.Select(async v => await GetPropertyContainer(v.AssignationID, v) ) ); resultAttributes.Add(kv.Key, newValues); } foreach (var kv in plainRelations) { var newValues = await Task.WhenAll( kv.Value.Select(async v => await GetPropertyContainer(v.AssignationID, v) ) ); resultRelations.Add(kv.Key, newValues); } return(new PropertyContainerData( provider, resultAttributes, resultRelations, containerID, actorEvent.EventValue.Value, value )); }