Exemplo n.º 1
0
        public void SetUp()
        {
            entities = new EntitySetImpl();

            entity1 = new EntityImpl("Entity1");
            entity1.AddProperty(new PropertyImpl("PrimaryKey")
            {
                Type = "System.Int32", IsKeyProperty = true
            });
            entity1.AddProperty(new PropertyImpl("Property")
            {
                Type = "bool"
            });

            entity2 = new EntityImpl("Entity2");
            entity2.AddProperty(new PropertyImpl("PrimaryKey")
            {
                Type = "System.Int32", IsKeyProperty = true
            });

            entities.AddEntity(entity1);
            entities.AddEntity(entity2);

            reference = entity1.CreateReferenceTo(entity2);
            reference.Cardinality1 = Cardinality.One;
            reference.Cardinality2 = Cardinality.One;
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            entities = new EntitySetImpl();

            personEntity = new EntityImpl("Person");
            personEntity.AddProperty(new PropertyImpl("ID")
            {
                Type = "int", IsKeyProperty = true
            });
            personEntity.AddProperty(new PropertyImpl("Name")
            {
                Type = "string", ValidationOptions = new ValidationOptions {
                    MaximumLength = 50
                }
            });
            personEntity.AddProperty(new PropertyImpl("Salary")
            {
                Type = "int"
            });

            managerEntity        = new EntityImpl("Manager");
            managerEntity.Parent = personEntity;

            entities.AddEntity(personEntity);
            entities.AddEntity(managerEntity);

            reference              = managerEntity.CreateReferenceTo(personEntity);
            reference.End1Enabled  = true; reference.End2Enabled = true;
            reference.End1Name     = "Subordinates"; reference.End2Name = "Manager";
            reference.Cardinality1 = Cardinality.Many; reference.Cardinality2 = Cardinality.One;
        }
Exemplo n.º 3
0
        public static Entity AddRowsPage(this Entity entity, Page pagination)
        {
            var exists = (entity.Properties?[PaginationProperty]?.Value != null);

            if (exists)
            {
                entity.Properties.Remove(PaginationProperty);
            }

            if (pagination.IsLimitSet)
            {
                entity.AddProperty($"{PaginationProperty}.Limit", pagination.Limit);
            }
            else
            {
                entity.AddProperty($"{PaginationProperty}.PageSize", pagination.Size);
            }

            if (pagination.IsOffsetSet)
            {
                entity.AddProperty($"{PaginationProperty}.Offset", pagination.Offset);
            }
            else
            {
                entity.AddProperty($"{PaginationProperty}.Page", pagination.Number);
            }
            return(entity);
        }
Exemplo n.º 4
0
        public void CanAddPropertiesToEntity()
        {
            var entity = new Entity(Guid.NewGuid(), "Touchpoint");

            entity.AddProperty(new Property("Name", typeof(string)));
            entity.AddProperty(new Property("Description", typeof(string)));

            Assert.AreEqual(2, entity.Properties.Count);
        }
Exemplo n.º 5
0
    public Entity GetEntity()
    {
        Entity e = new Entity(id_entity, nome);

        e.AddProperty("poder", poder);
        e.AddProperty("peso", peso);

        return(e);
    }
Exemplo n.º 6
0
        private Entity CreateEntity()
        {
            Entity obj = new Entity();

            obj.Description     = "Reading model for an account";
            obj.Name            = "Account";
            obj.CheckStatus     = CheckStatus.Default;
            obj.FromMetadata    = true;
            obj.IsDataWarehouse = false;
            obj.Guid            = Guid.Parse("836ba28e-e640-405b-aff8-29c137005344");
            obj.SingularName    = "050c3c81-2a72-4960-ad98-92f220328630";
            obj.PluralName      = "3ddad1ed-255a-4fd0-a5a6-1501f68d17cb";
            obj.TableName       = "Accounts";

            Property fr = new Property();

            fr.Name             = "AccountTypeCode";
            fr.Guid             = Guid.Parse("c00a0b9c-0fdb-416f-8584-a42746189d45");
            fr.ColumnName       = "AccountTypeCode";
            fr.DataType         = PropertyDataType.String;
            fr.Help             = "Gets or sets the account type code.";
            fr.IsActiveProperty = false;
            fr.IsCustomField    = false;
            fr.IsDataWarehouse  = false;
            fr.IsIndex          = false;
            fr.IsPrimaryKey     = false;
            fr.IsReadOnly       = false;
            fr.IsRequiered      = false;
            fr.IsVisible        = true;
            fr.Lenght           = 50;
            fr.Precision        = 0;
            fr.Title            = "f694d499-822e-4df1-93fe-b5f5b3273162";

            obj.AddProperty(fr);

            fr                  = new Property();
            fr.Name             = "AccountTypeId";
            fr.Guid             = Guid.Parse("c00a0b9c-0fdb-416f-8584-a42746189d45");
            fr.ColumnName       = "AccountTypeId";
            fr.DataType         = PropertyDataType.Guid;
            fr.Help             = "Gets or sets the account type identifier.";
            fr.IsActiveProperty = false;
            fr.IsCustomField    = false;
            fr.IsDataWarehouse  = false;
            fr.IsIndex          = false;
            fr.IsPrimaryKey     = false;
            fr.IsReadOnly       = false;
            fr.IsRequiered      = false;
            fr.IsVisible        = false;
            fr.Lenght           = 16;
            fr.Precision        = 0;
            fr.Title            = "c66fda6e-49cf-47ff-b855-922928fbdfaf";

            obj.AddProperty(fr);
            return(obj);
        }
Exemplo n.º 7
0
        private static Entity GetSchemaEntity(TableColumnsMetadataItem mapper)
        {
            var entity = new Entity();

            entity.AddProperty("EntitySet", mapper.EntitySet);
            entity.AddProperty("Column", mapper.Column);
            entity.AddProperty("ColumnSemantic", mapper.ColumnSemantic);
            entity.AddProperty("ColumnNamespace", mapper.ColumnNamespace);
            entity.AddProperty("ColumnDescription", mapper.ColumnDescription);

            return(entity);
        }
Exemplo n.º 8
0
        private static Entity GetSchemaEntity(string entitySet, string entityKind, PropertyToTypeMapper mapper)
        {
            var entity = new Entity();

            entity.AddProperty(DataLoaderConstants.PropNameEntitySet, entitySet);
            entity.AddProperty(DataLoaderConstants.PropNameEntityKind, entityKind);

            foreach (var p in mapper.GetProperties())
            {
                entity.AddProperty(p.Key, GetPropertyType(p.Value));
            }

            return(entity);
        }
Exemplo n.º 9
0
        private static void RenderProperties(IPaper paper, Entity entity, PaperContext ctx)
        {
            if (!paper._Has("GetProperties"))
            {
                return;
            }

            var properties = paper._Call("GetProperties");

            if (properties == null)
            {
                return;
            }

            var dataTable = properties as DataTable;

            if (dataTable != null)
            {
                if (dataTable.Rows.Count > 0)
                {
                    DataRow row = dataTable.Rows[0];
                    foreach (DataColumn col in dataTable.Columns)
                    {
                        var key   = Conventions.MakeName(col);
                        var value = row[col];
                        entity.AddProperty(key, value);
                    }
                }
                return;
            }

            var dictionary = properties as IDictionary;

            if (dictionary != null)
            {
                foreach (string key in dictionary.Keys)
                {
                    var value = dictionary[key];
                    entity.AddProperty(key, value);
                }
                return;
            }

            foreach (var key in properties._GetPropertyNames())
            {
                var value = properties._Get(key);
                entity.AddProperty(key, value);
            }
        }
Exemplo n.º 10
0
        private static Entity GetSchemaEntity(DbDataReader reader, string entitySet, string entityKind)
        {
            reader.Read();

            var entity = new Entity();

            entity.AddProperty(DataLoaderConstants.PropNameEntitySet, entitySet);
            entity.AddProperty(DataLoaderConstants.PropNameEntityKind, entityKind);
            for (int i = 0; i < reader.FieldCount; ++i)
            {
                entity.AddProperty(reader.GetName(i), reader.GetFieldType(i).ToString());
            }

            return(entity);
        }
Exemplo n.º 11
0
        private async Task SubmitAsync()
        {
            try
            {
                var formData = new Entity();
                formData.AddClass(Class.FormData);

                foreach (var widget in pnContent.Controls.OfType <IWidget>())
                {
                    if (widget.Value != null)
                    {
                        var name = widget.Name;
                        var text = Change.To <string>(widget.Value);
                        formData.AddProperty(name, text);
                    }
                }

                var route  = action.Href;
                var method = action.Method ?? MethodNames.Post;

                await MediaClient.Current.TransferAsync(route, method, formData);
            }
            catch (Exception ex)
            {
                ex.Trace();
                MessageBox.Show(this, ex.Message, "Falha", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void UpdateProperties(int i, Entity newEntity)
        {
            List <string> checkedColumnNames = new List <string>();

            for (int rowIndex = 3; rowIndex < advTree1.Nodes.Count; rowIndex++)
            {
                string          columnName       = advTree1.Nodes[rowIndex].Text;
                List <Property> mappedProperties = newEntity.Properties.Where(p => p.MappedColumn() != null && p.MappedColumn().Name == columnName).ToList();

                if (advTree1.Nodes[rowIndex].Cells[i].Checked)
                {
                    if (mappedProperties.Count == 0)
                    {
                        IColumn  column      = Table.Columns.Single(c => c.Name == columnName);
                        Property newProperty = ArchAngel.Providers.EntityModel.Controller.MappingLayer.OneToOneEntityProcessor.CreatePropertyFromColumn(column);
                        newEntity.AddProperty(newProperty);
                    }
                }
                else
                {
                    for (int propIndex = mappedProperties.Count - 1; propIndex >= 0; propIndex--)
                    {
                        newEntity.RemoveProperty(mappedProperties[propIndex]);
                    }
                }
            }
        }
Exemplo n.º 13
0
        public void SetUp()
        {
            mainPanel = MockRepository.GenerateStub <IMainPanel>();
            form      = MockRepository.GenerateMock <IEntityForm>();
            ms        = MockRepository.GenerateStub <MappingSet>();

            Property  property = new PropertyImpl("Prop1");
            EntityKey key      = new EntityKeyImpl();

            entity = new EntityImpl("Entity1")
            {
                Key = key
            };
            entity.AddProperty(property);
            key.AddProperty(property);

            mapping = new MappingImpl();
            form.Stub(f => f.Mappings).Return(new List <Mapping> {
                mapping
            });

            EntitySet es = new EntitySetImpl();

            es.AddEntity(entity);
            ms.EntitySet  = es;
            es.MappingSet = ms;
            ms.Stub(m => m.GetMappingsContaining(entity)).Return(new List <Mapping>());

            var presenter = new EntityPresenter(mainPanel, form);

            presenter.AttachToModel(entity);
        }
Exemplo n.º 14
0
        public void SetUp()
        {
            entities = new EntitySetImpl();

            entityParent = new EntityImpl("EntityParent");
            entityParent.AddProperty(new PropertyImpl("PrimaryKey")
            {
                Type = "int", IsKeyProperty = true
            });

            entityChild = new EntityImpl("EntityChild");
            entityParent.AddChild(entityChild);
            entityChild.CopyPropertyFromParent(entityParent.ConcreteProperties[0]);
            entityChild.AddProperty(new PropertyImpl("ActualProperty")
            {
                Type = "string"
            });

            entities.AddEntity(entityParent);
            entities.AddEntity(entityChild);

            var proc = new MappingProcessor(new OneToOneEntityProcessor());

            mappingSet = proc.CreateOneToOneMapping(entities);
        }
Exemplo n.º 15
0
        public void SetUp()
        {
            entities = new EntitySetImpl();

            entity1 = new EntityImpl("Entity1");
            entity1.AddProperty(new PropertyImpl("PrimaryKey")
            {
                Type = "System.Int32", IsKeyProperty = true
            });

            entity2 = new EntityImpl("Entity2");
            entity2.AddProperty(new PropertyImpl("PrimaryKey")
            {
                Type = "System.Int32", IsKeyProperty = true
            });

            entities.AddEntity(entity1);
            entities.AddEntity(entity2);

            reference = entity1.CreateReferenceTo(entity2);
            reference.Cardinality1 = Cardinality.Many;
            reference.Cardinality2 = Cardinality.Many;

            var proc = new MappingProcessor(new OneToOneEntityProcessor());

            mappingSet = proc.CreateOneToOneMapping(entities);
        }
Exemplo n.º 16
0
        private void slyceGrid1_NewRowAdded(out object newObject)
        {
            Property property = new PropertyImpl("NewProperty")
            {
                Type           = "System.String",
                NHibernateType = "String",
                Entity         = this.Entity,
                IsKeyProperty  = false,
                ReadOnly       = false
            };

            property.ValidationOptions.FractionalDigits = 0;
            property.ValidationOptions.FutureDate       = false;
            property.ValidationOptions.IntegerDigits    = 0;
            property.ValidationOptions.MaximumLength    = 0;
            property.ValidationOptions.MaximumValue     = 0;
            property.ValidationOptions.MinimumLength    = 0;
            property.ValidationOptions.MinimumValue     = 0;
            property.ValidationOptions.NotEmpty         = false;
            property.ValidationOptions.Nullable         = false;
            property.ValidationOptions.PastDate         = false;
            property.ValidationOptions.RegexPattern     = "";
            property.ValidationOptions.Validate         = false;

            Entity.AddProperty(property);
            newObject = property;

            bool hasMultiSchemas = MappedTables.Select(t => t.Schema).Distinct().Count() > 1;

            AddPropertyToPropertiesGrid(property, hasMultiSchemas);
        }
Exemplo n.º 17
0
            public void Overridden_Properties_Are_Marked_As_Inherited()
            {
                var property1 = new PropertyImpl {
                    Name = "Prop1"
                };

                Assert.That(property1.IsInherited, Is.False);
                Assert.That(property.IsOverridden, Is.False);
                entity.AddProperty(property1);

                Assert.That(property.IsOverridden, Is.True);
                Assert.That(property1.IsInherited, Is.True);

                Assert.That(entity.Properties.Count(), Is.EqualTo(2));
                Assert.That(entity.Properties.Contains(property), "Parent property missing");
                Assert.That(entity.Properties.Contains(property1), "Child property missing");
            }
 public StaticRenderable(Entity ent, String name) : base(ent, name)
 {
     m_Position = Entity.AddProperty <Vector3>("Position", Vector3.Zero);
     m_Origin   = Entity.AddProperty <Vector2>("Origin", Vector2.Zero);
     m_Bounds   = Entity.AddProperty <Vector2>("Bounds", Vector2.Zero);
     m_Rotation = Entity.AddProperty <float>("Rotation", 0.0f);
     m_Scale    = Entity.AddProperty <float>("Scale", 1.0f);
 }
Exemplo n.º 19
0
 public void SetUp()
 {
     entity = new EntityImpl("Entity1");
     entity.AddProperty(new PropertyImpl("Property1")
     {
         Type = "System.Int32", IsKeyProperty = true
     });
     entity.AddProperty(new PropertyImpl("Property2")
     {
         Type = "bool"
     });
     entity.AddProperty(new PropertyImpl("Property3")
     {
         Type = "string", ValidationOptions = new ValidationOptions {
             MaximumLength = 50
         }
     });
 }
Exemplo n.º 20
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem != null)
            {
                SelectedTable = (ITable)listBox1.SelectedItem;
                HashSet <ITable> tables = new HashSet <ITable>();

                foreach (ListViewItem item in listViewColumns.CheckedItems)
                {
                    tables.Add(((IColumn)item.Tag).Parent);
                }

                StringBuilder sb = new StringBuilder(100);

                for (int i = 0; i < tables.Count; i++)
                {
                    sb.Append(tables.ElementAt(i).Name);

                    if (i < tables.Count - 1)
                    {
                        sb.Append(", ");
                    }
                }
                if (MessageBox.Show(this, string.Format("Delete all entities currently mapped to this tables [{0}]?", sb), "Delete mapped entities?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    foreach (var table in tables)
                    {
                        var entities = table.MappedEntities().ToList();

                        for (int i = entities.Count - 1; i >= 0; i--)
                        {
                            var entity = entities[i];
                            entity.DeleteSelf();
                        }
                    }
                }
                foreach (ListViewItem item in listViewColumns.CheckedItems)
                {
                    IColumn  column      = (IColumn)item.Tag;
                    Property newProperty = Controller.MappingLayer.OneToOneEntityProcessor.CreatePropertyFromColumn(column);
                    newProperty.Name = newProperty.Name.GetNextName(Entity.Properties.Select(p => p.Name));
                    Entity.AddProperty(newProperty);
                    newProperty.SetMappedColumn(column);
                }
                //if (checkBoxAddReferences.Checked)
                //{
                //    var mappedEntities = SelectedTable.MappedEntities();

                //    if (mappedEntities.Count() == 1)
                //    {
                //        if (mappedEntities.ElementAt(0).MappedTables().Count() == 1)
                //    }
                //}
            }
            Close();
        }
        public SelectionBox(Entity ent, String name)
            : base(ent, name)
        {
            m_Position = Entity.AddProperty <Vector3>("Position", Vector3.Zero);
            m_InputObj = XNAGame.Instance.GetBroadphase <Broadphases.Input>("Input");

            m_InputObj.ButtonClicked  += new Broadphases.MouseEventHandler(ButtonClicked);
            m_InputObj.ButtonHeld     += new Broadphases.MouseEventHandler(ButtonHeld);
            m_InputObj.ButtonReleased += new Broadphases.MouseEventHandler(ButtonReleased);
        }
Exemplo n.º 22
0
        public void AddTileGroup(string groupId_, string itemId_, float xpos_, float itemY_)
        {
            float height = 96;

            if (ticktock == 20)
            {
                ticktock = 0;
            }
            List <Entity> ents = new List <Entity>();

            if (addCeiling)
            {
                ents.Add(ebuilder.CreateEntity("tile", GetDrawerCollection(6), new Vector2(xpos_, 0), new List <Property>()
                {
                    new Property("isTile", "isTile", "isTile")
                }, "tile"));
            }
            addCeiling = !addCeiling;
            switch (groupId_)
            {
            case "basic":
                if (ticktock == 0)
                {
                    ents.Add(ebuilder.CreateEntity("tile", GetDrawerCollection(12), new Vector2(xpos_, height), new List <Property>()
                    {
                        new Property("isTile", "isTile", "isTile")
                    }, "tile"));
                }
                break;

            case "void":
                if (nextFloorType == "rand")
                {
                    nextFloorType = "void2";
                }
                else if (int.Parse(nextFloorType.Substring(4)) < 10)
                {
                    nextFloorType = "void" + (int.Parse(nextFloorType.Substring(4)) + 1).ToString();
                }
                else
                {
                    nextFloorType = "rand"; groupCooldowns[1] = 20;
                }
                break;
            }
            if (itemId_ != "none")
            {
                Entity ent = Assembler.GetEnt(ElementCollection.GetEntRef(itemId_), new Vector2(xpos_, itemY_), content, ebuilder, false);
                ent.AddProperty(new Property("isCollectible", "isCollectible", "isCollectible"));
                ents.Add(ent);
                itemCount++;
            }
            EntityCollection.AddEntities(ents);
            ticktock++;
        }
Exemplo n.º 23
0
        void form_AddNewProperty(object sender, EventArgs e)
        {
            string name     = "New_Property".GetNextName(entity.Properties.Select(p => p.Name));
            var    property = new PropertyImpl(name);

            entity.AddProperty(property);

            form.SetProperties(entity.ConcreteProperties);
            form.Mappings = entity.Mappings();
            form.SetSelectedPropertyName(property);
        }
Exemplo n.º 24
0
            public void Setup()
            {
                entity = new EntityImpl("Child");
                parent = new EntityImpl("Parent");
                parent.AddChild(entity);

                property = new PropertyImpl {
                    Name = "Prop1"
                };
                parent.AddProperty(property);
            }
Exemplo n.º 25
0
        /// <summary>
        /// Renderizando dados e cabeçalhos básicos
        /// </summary>
        private static void AddData(IPaper paper, Entity entity, PaperContext ctx, DataWrapper data)
        {
            foreach (var key in data.EnumerateKeys())
            {
                var value = data.GetValue(key);
                entity.AddProperty(key, value);

                var header = data.GetHeader(key);
                entity.AddDataHeader(header);
            }
        }
Exemplo n.º 26
0
        public KeyboardController(Entity ent, String name) : base(ent, name)
        {
            m_InputObj = XNAGame.Instance.GetBroadphase <Broadphases.Input>("Input");
            m_Position = Entity.AddProperty <Vector3>("Position", Vector3.Zero);

            Entity.AddEvent("SetActive", (o) => this.IsActive   = true);
            Entity.AddEvent("SetInactive", (o) => this.IsActive = false);

            IsActive = true;
            Speed    = 0.5f;
        }
Exemplo n.º 27
0
        public void PropertiesBuilder_Test()
        {
            ModelRoot modelRoot = new ModelRoot();
            Func <Guid, IDomainType> getDomainType = modelRoot.GetDomainType;

            Interface IEntity = new Interface(modelRoot, "IEntity");

            IEntity.AddProperty(new ScalarProperty("Id", getDomainType(SystemPrimitiveTypesConverter.TYPE_ID_INT32)));
            IEntity.AddProperty(new ScalarProperty("OId", getDomainType(SystemPrimitiveTypesConverter.TYPE_ID_BYTE)));

            Entity EntityBase = new Entity(modelRoot, "EntityBase");

            EntityBase.SetInheritance(IEntity);
            ScalarProperty propertyId = new ScalarProperty("Id", getDomainType(SystemPrimitiveTypesConverter.TYPE_ID_INT32));

            propertyId.IsInherited = true;
            EntityBase.AddProperty(propertyId);
            ScalarProperty propertyOId = new ScalarProperty("OId", getDomainType(SystemPrimitiveTypesConverter.TYPE_ID_BYTE));

            propertyOId.IsInherited = true;
            EntityBase.AddProperty(propertyOId);
            EntityBase.AddProperty(new ScalarProperty("Age", getDomainType(SystemPrimitiveTypesConverter.TYPE_ID_STRING)));
            EntityBase.AddProperty(new ScalarProperty("ScalarProperty4", getDomainType(SystemPrimitiveTypesConverter.TYPE_ID_STRING)));

            Entity Car = new Entity(modelRoot, "Car");

            Car.SetInheritance(EntityBase);
            Car.AddProperty(new ScalarProperty("SuperKey", getDomainType(SystemPrimitiveTypesConverter.TYPE_ID_INT32)));
            Car.AddProperty(new NavigationProperty("SimilarCars"));

            modelRoot.UpdateTopHierarchyTypes(Car);

            PropertiesBuilderContext.Initialize(modelRoot);
            var carPropertiesBuilder = PropertiesBuilderContext.Current.Get(Car);
            var inheritedProperties  = carPropertiesBuilder.GetInheritedProperties();
        }
Exemplo n.º 28
0
        /// <summary>
        /// Fired when entity is spawned.
        /// </summary>
        public override void OnSpawn()
        {
            Game game = Engine3D.Source as Game;

            Rend = new EntitySimple3DRenderableModelProperty()
            {
                EntityModel    = game.Client.Models.Cylinder,
                Scale          = new Location(0.1, 0.1, 1),
                DiffuseTexture = game.Client.Textures.White,
                Color          = Color4F.Blue,
                IsVisible      = false
            };
            Entity.AddProperty(Rend);
            Entity.OnTick += Tick;
        }
Exemplo n.º 29
0
        public Selectable(Entity ent, String name) : base(ent, name)
        {
            m_Selected = Entity.AddProperty <bool>("Selected", false);
            m_Position = Entity.AddProperty <Vector3>("Position", Vector3.Zero);
            m_Origin   = Entity.AddProperty <Vector2>("Origin", Vector2.Zero);
            m_Bounds   = Entity.AddProperty <Vector2>("Bounds", Vector2.Zero);
            m_Scale    = Entity.AddProperty <float>("Scale", 0.0f);

            m_Position.ValueChanged += new ValueChanged <Vector3>(PositionChanged);
            m_Bounds.ValueChanged   += new ValueChanged <Vector2>(BoundsChanged);
            m_Scale.ValueChanged    += new ValueChanged <float>(ScaleChanged);

            Entity.AddEvent("Select", (o) => ChangeSelect(true));
            Entity.AddEvent("Deselect", (o) => ChangeSelect(false));
        }
Exemplo n.º 30
0
        public LocationType ConvertToLocationType()
        {
            LocationType Entity;

            if (this.Key != Guid.Empty)
            {
                //Lookup existing entity
                Entity = Repositories.LocationTypeRepo.GetByKey(this.Key);

                if (Entity == null)
                {
                    Entity = this.CreateNew();
                }
            }
            else
            {
                Entity = this.CreateNew();
            }

            //Update LT properties as needed
            Entity.Name        = this.Name;
            Entity.Description = this.Description;
            Entity.Icon        = this.Icon;

            //match up child properties
            foreach (var JsonProp in this.Properties.OrderBy(p => p.SortOrder))
            {
                //lookup existing property
                var Prop = Entity.Properties.Where(p => p.Key == JsonProp.Key).FirstOrDefault();

                if (Prop != null)
                {
                    Prop.Alias      = JsonProp.PropAlias;
                    Prop.Name       = JsonProp.PropName;
                    Prop.DataTypeId = JsonProp.PropType;
                    Prop.SortOrder  = JsonProp.SortOrder;
                    Repositories.LocationTypePropertyRepo.Update(Prop);
                }
                else
                {
                    //Add new property
                    Entity.AddProperty(JsonProp.PropAlias, JsonProp.PropName, JsonProp.PropType);
                }
            }

            return(Entity);
        }
Exemplo n.º 31
0
            public void Setup()
            {
                entity = new EntityImpl("Child");
                parent = new EntityImpl("Parent");
                parent.AddChild(entity);

                property = new PropertyImpl { Name = "Prop1"};
                parent.AddProperty(property);
            }
 public void SetUp()
 {
     entity = new EntityImpl("Entity1");
     entity.AddProperty(new PropertyImpl("Property1") { Type = "System.Int32", IsKeyProperty = true });
     entity.AddProperty(new PropertyImpl("Property2") { Type = "bool" });
     entity.AddProperty(new PropertyImpl("Property3") { Type = "string", ValidationOptions = new ValidationOptions {MaximumLength = 50} });
 }
        public void SetUp()
        {
            entities = new EntitySetImpl();

            entity1 = new EntityImpl("Entity1");
            entity1.AddProperty(new PropertyImpl("PrimaryKey") { Type = "System.Int32", IsKeyProperty = true });
            entity1.AddProperty(new PropertyImpl("Property") { Type = "bool" });

            entity2 = new EntityImpl("Entity2");
            entity2.AddProperty(new PropertyImpl("PrimaryKey") { Type = "System.Int32", IsKeyProperty = true });

            entities.AddEntity(entity1);
            entities.AddEntity(entity2);

            reference = entity1.CreateReferenceTo(entity2);
            reference.Cardinality1 = Cardinality.One;
            reference.Cardinality2 = Cardinality.One;
        }
        public void SetUp()
        {
            entities = new EntitySetImpl();

            entity1 = new EntityImpl("Entity1");
            entity1.AddProperty(new PropertyImpl("PrimaryKey") { Type = "System.Int32", IsKeyProperty = true });

            entity2 = new EntityImpl("Entity2");
            entity2.AddProperty(new PropertyImpl("PrimaryKey") { Type = "System.Int32", IsKeyProperty = true });

            entities.AddEntity(entity1);
            entities.AddEntity(entity2);

            reference = entity1.CreateReferenceTo(entity2);
            reference.Cardinality1 = Cardinality.Many;
            reference.Cardinality2 = Cardinality.Many;

            var proc = new MappingProcessor(new OneToOneEntityProcessor());
            mappingSet = proc.CreateOneToOneMapping(entities);
        }
        public void SetUp()
        {
            entities = new EntitySetImpl();

            entityParent = new EntityImpl("EntityParent");
            entityParent.AddProperty(new PropertyImpl("PrimaryKey") { Type = "int", IsKeyProperty = true });

            entityChild = new EntityImpl("EntityChild");
            entityParent.AddChild(entityChild);
            entityChild.CopyPropertyFromParent(entityParent.ConcreteProperties[0]);
            entityChild.AddProperty(new PropertyImpl("ActualProperty"){ Type = "string" });

            entities.AddEntity(entityParent);
            entities.AddEntity(entityChild);

            var proc = new MappingProcessor(new OneToOneEntityProcessor());
            mappingSet = proc.CreateOneToOneMapping(entities);
        }
        public void SetUp()
        {
            entities = new EntitySetImpl();

            personEntity = new EntityImpl("Person");
            personEntity.AddProperty(new PropertyImpl("ID") { Type = "int", IsKeyProperty = true });
            personEntity.AddProperty(new PropertyImpl("Name") { Type = "string", ValidationOptions = new ValidationOptions {MaximumLength = 50} });
            personEntity.AddProperty(new PropertyImpl("Salary") { Type = "int" });

            managerEntity = new EntityImpl("Manager");
            managerEntity.Parent = personEntity;

            entities.AddEntity(personEntity);
            entities.AddEntity(managerEntity);

            reference = managerEntity.CreateReferenceTo(personEntity);
            reference.End1Enabled = true; reference.End2Enabled = true;
            reference.End1Name = "Subordinates"; reference.End2Name = "Manager";
            reference.Cardinality1 = Cardinality.Many; reference.Cardinality2 = Cardinality.One;
        }