/// <summary>
        /// Generates required data for a OneToMany relationship without embedded documents
        /// </summary>
        /// <returns></returns>
        public static RequiredDataContainer OneToManyNotEmbedded()
        {
            // Create ER Stuff
            Entity Person = new Entity("Person");

            Person.AddAttribute("personId");
            Person.AddAttribute("name");

            Entity Car = new Entity("Car");

            Car.AddAttribute("carId");
            Car.AddAttribute("name");
            Car.AddAttribute("year");
            Car.AddAttribute("personId");

            Relationship Drives = new Relationship("Drives");

            Drives.AddRelationshipEnd(new RelationshipEnd(Person));
            Drives.AddRelationshipEnd(new RelationshipEnd(Car));

            ERModel Model = new ERModel("PersonCarModel", new List <BaseERElement> {
                Person, Car, Drives
            });

            // Create MongoDB schema
            MongoDBCollection PersonCollection = new MongoDBCollection("Person");

            PersonCollection.DocumentSchema.AddAttribute("_id");
            PersonCollection.DocumentSchema.AddAttribute("name");

            MongoDBCollection CarCollection = new MongoDBCollection("Car");

            CarCollection.DocumentSchema.AddAttribute("_id");
            CarCollection.DocumentSchema.AddAttribute("name");
            CarCollection.DocumentSchema.AddAttribute("year");
            CarCollection.DocumentSchema.AddAttribute("personId");

            MongoSchema Schema = new MongoSchema("PersonCarSchema", new List <MongoDBCollection> {
                PersonCollection, CarCollection
            });

            // Create Map
            MapRule PersonRule = new MapRule(Model.FindByName("Person"), Schema.FindByName("Person"));

            PersonRule.AddRule("personId", "_id");
            PersonRule.AddRule("name", "name");

            MapRule CarRule = new MapRule(Model.FindByName("Car"), Schema.FindByName("Car"));

            CarRule.AddRule("carId", "_id");
            CarRule.AddRule("name", "name");
            CarRule.AddRule("year", "year");
            CarRule.AddRule("personId", "personId");

            ModelMapping Map = new ModelMapping("PersonCarMap", new List <MapRule> {
                PersonRule, CarRule
            });

            return(new RequiredDataContainer(Model, Schema, Map));
        }
        /// <summary>
        /// Test data for virtual maps
        /// </summary>
        /// <returns></returns>
        public static RequiredDataContainer VirtualMapModel()
        {
            // ER Stuff
            Entity Person = new Entity("Person");

            Person.AddAttributes("personId", "name", "age");
            Person.SetIdentifier("personId");

            Entity Pet = new Entity("Pet");

            Pet.AddAttributes("petId", "name", "type");
            Pet.SetIdentifier("petId");

            Relationship HasPet = new Relationship("HasPet");

            HasPet.AddRelationshipEnd(new RelationshipEnd(Person));
            HasPet.AddRelationshipEnd(new RelationshipEnd(Pet));

            ERModel Model = new ERModel("Model", new List <BaseERElement>()
            {
                Person, Pet, HasPet
            });

            MongoDBCollection PersonCol = new MongoDBCollection("Person");

            PersonCol.AddAttributes("_id", "name", "age");

            MongoDBCollection PetCol = new MongoDBCollection("Pet");

            PetCol.AddAttributes("_id", "name", "type", "ownerId");

            MongoSchema Schema = new MongoSchema("Schema", new List <MongoDBCollection>()
            {
                PersonCol, PetCol
            });

            MapRule PersonRules = new MapRule(Person, PersonCol);

            PersonRules.AddRule("personId", "_id");
            PersonRules.AddRule("name", "name");
            PersonRules.AddRule("age", "age");

            MapRule PetRules = new MapRule(Pet, PetCol);

            PetRules.AddRule("petId", "_id");
            PetRules.AddRule("name", "name");
            PetRules.AddRule("type", "type");

            MapRule PersonPetRule = new MapRule(Person, PetCol, false);

            PersonPetRule.AddRule("personId", "ownerId");

            ModelMapping Map = new ModelMapping("Map", new List <MapRule>()
            {
                PersonRules, PetRules, PersonPetRule
            });

            return(new RequiredDataContainer(Model, Schema, Map));
        }
        /// <summary>
        /// Generates required data to test a One To Many relationship
        /// joining one entity while the left side entity is embedded into another
        /// </summary>
        /// <returns></returns>
        public static RequiredDataContainer OneToManyLeftSideEmbedded()
        {
            Entity Car = new Entity("Car");

            Car.AddAttribute("carId");
            Car.AddAttribute("model");

            Entity Insurance = new Entity("Insurance");

            Insurance.AddAttribute("insuranceId");
            Insurance.AddAttribute("name");
            Insurance.AddAttribute("value");
            Insurance.AddAttribute("carId");

            Relationship HasInsurance = new Relationship("HasInsurance");

            HasInsurance.AddRelationshipEnd(new RelationshipEnd(Car));
            HasInsurance.AddRelationshipEnd(new RelationshipEnd(Insurance));

            ERModel Model = new ERModel("CarInsuranceModel", new List <BaseERElement> {
                Car, Insurance, HasInsurance
            });

            MongoDBCollection CarCol = new MongoDBCollection("Car");

            CarCol.DocumentSchema.AddAttribute("carId");
            CarCol.DocumentSchema.AddAttribute("model");

            MongoDBCollection InsCol = new MongoDBCollection("Insurance");

            InsCol.DocumentSchema.AddAttribute("_id");
            InsCol.DocumentSchema.AddAttribute("name");
            InsCol.DocumentSchema.AddAttribute("value");
            InsCol.DocumentSchema.AddAttribute("carId");

            MongoSchema Schema = new MongoSchema("CarInsuranceSchema", new List <MongoDBCollection> {
                CarCol, InsCol
            });

            MapRule CarRule = new MapRule(Car, CarCol);

            CarRule.AddRule("carId", "car.carId");
            CarRule.AddRule("model", "car.model");

            MapRule InsRule = new MapRule(Insurance, InsCol);

            InsRule.AddRule("insuranceId", "_id");
            InsRule.AddRule("name", "name");
            InsRule.AddRule("value", "value");
            InsRule.AddRule("carId", "carId");

            ModelMapping Map = new ModelMapping("CarInsuranceMap", new List <MapRule> {
                CarRule, InsRule
            });

            return(new RequiredDataContainer(Model, Schema, Map));
        }
Beispiel #4
0
        public static ERModel CreateERModel()
        {
            Entity User = new Entity("User");

            User.AddAttributes("user_id", "user_name", "user_email", "user_access", "user_newsletter");

            Entity Store = new Entity("Store");

            Store.AddAttributes("store_id", "store_name", "store_logo");

            Entity Category = new Entity("Category");

            Category.AddAttributes("category_id", "category_name");

            Entity Product = new Entity("Product");

            Product.AddAttributes("product_id", "product_title", "product_description", "product_short_description", "product_url",
                                  "product_category_id", "product_store_id", "product_user_id", "product_published", "product_image");

            // User Relationships
            Relationship UserHasManyProducts = new Relationship("HasManyProducts");

            UserHasManyProducts.AddRelationshipEnd(new RelationshipEnd(User));
            UserHasManyProducts.AddRelationshipEnd(new RelationshipEnd(Product));

            // Store relationships
            Relationship StoreHasManyProducts = new Relationship("StoreHasManyProducts");

            StoreHasManyProducts.AddRelationshipEnd(new RelationshipEnd(Store));
            StoreHasManyProducts.AddRelationshipEnd(new RelationshipEnd(Product));

            // Category relationships
            Relationship CategoryHasManyProducts = new Relationship("CategoryHasManyProducts");

            CategoryHasManyProducts.AddRelationshipEnd(new RelationshipEnd(Category));
            CategoryHasManyProducts.AddRelationshipEnd(new RelationshipEnd(Product));

            return(new ERModel("CMSModel", new List <BaseERElement>()
            {
                User, Store, Category, Product,
                UserHasManyProducts, StoreHasManyProducts, CategoryHasManyProducts
            }));
        }
        /// <summary>
        /// Create ER Model
        /// </summary>
        /// <returns></returns>
        public static ERModel CreateERModel()
        {
            Entity User = new Entity("User");

            User.AddAttribute("UserID", true);
            User.AddAttributes("UserName", "UserEmail");

            Entity Store = new Entity("Store");

            Store.AddAttribute("StoreID", true);
            Store.AddAttributes("StoreName");

            Entity Category = new Entity("Category");

            Category.AddAttribute("CategoryID", true);
            Category.AddAttributes("CategoryName");

            Entity Product = new Entity("Product");

            Product.AddAttribute("ProductID", true);
            Product.AddAttributes("Title", "Description");

            Relationship UserProducts = new Relationship("UserProducts");

            UserProducts.AddRelationshipEnd(new RelationshipEnd(User));
            UserProducts.AddRelationshipEnd(new RelationshipEnd(Product));

            Relationship StoreProducts = new Relationship("StoreProducts");

            StoreProducts.AddRelationshipEnd(new RelationshipEnd(Store));
            StoreProducts.AddRelationshipEnd(new RelationshipEnd(Product));

            Relationship CategoryProducts = new Relationship("CategoryProducts");

            CategoryProducts.AddRelationshipEnd(new RelationshipEnd(Category));
            CategoryProducts.AddRelationshipEnd(new RelationshipEnd(Product));

            return(new ERModel("CMSModel", new List <BaseERElement>()
            {
                User, Store, Category, Product, UserProducts, StoreProducts, CategoryProducts
            }));
        }
Beispiel #6
0
        override public bool VisitRelationship(QueryBuilderMappingParser.RelationshipContext context)
        {
            if (Pass == 2)
            {
                // RelationshipCardinality deveria fazer parte de RelationshipConnection
                Relationship relationship = new Relationship(context.name.Text);

                foreach (QueryBuilderMappingParser.AttributeContext ac in context.attribute())
                {
                    relationship.AddAttribute(ac.name.Text, ac.type.Text, ac.multivalued != null, ac.primarykey != null);
                }


                foreach (var end in context.relationshipEnd())
                {
                    RelationshipEnd rend = new RelationshipEnd();
                    try
                    {
                        var target = EntityRelationshipModel.FindByName(end.name.Text);
                        if (target.GetType() != typeof(Entity))
                        {
                            Errors.Add($"Error 003: (line {end.name.Line}:{end.name.Column}): relationship end '{end.name.Text}' is not an Entity!");
                        }
                        else
                        {
                            rend.TargetEntity = (Entity)target;

                            relationship.AddRelationshipEnd(rend);
                        }
                    }
                    catch (Exception)
                    {
                        Errors.Add($"Error 004: (line {end.name.Line}:{end.name.Column}): relationship end '{end.name.Text}' not found!");
                    }
                }

                EntityRelationshipModel.Elements.Add(relationship);
            }
            return(true);
        }
        /// <summary>
        /// Generate data with a computed entity
        /// </summary>
        /// <returns></returns>
        public static RequiredDataContainer ComputedEntityData()
        {
            Entity Person = new Entity("Person");

            Person.AddAttributes("personId", "name");
            Person.SetIdentifier("personId");

            Entity Car = new Entity("Car");

            Car.AddAttributes("carId", "model", "year");
            Car.SetIdentifier("carId");

            Entity Garage = new Entity("Garage");

            Garage.AddAttributes("garageId", "name");
            Garage.SetIdentifier("garageId");

            Entity Supplier = new Entity("Supplier");

            Supplier.AddAttributes("supplierId", "name");
            Supplier.SetIdentifier("supplierId");

            Entity Insurance = new Entity("Insurance");

            Insurance.AddAttributes("insuranceId", "name", "value");
            Insurance.SetIdentifier("insuranceId");

            Entity Manufacturer = new Entity("Manufacturer");

            Manufacturer.AddAttributes("manufacturerId", "name");
            Manufacturer.SetIdentifier("manufacturerId");

            Relationship Owns = new Relationship("Owns");

            Owns.AddAttributes("ownsId");
            Owns.AddRelationshipEnd(new RelationshipEnd(Car));
            Owns.AddRelationshipEnd(new RelationshipEnd(Person));
            Owns.AddRelationshipEnd(new RelationshipEnd(Insurance));

            Relationship Repaired = new Relationship("Repaired");

            Repaired.AddAttributes("repairedId", "repaired");
            Repaired.AddRelationshipEnd(new RelationshipEnd(Car));
            Repaired.AddRelationshipEnd(new RelationshipEnd(Garage));
            Repaired.AddRelationshipEnd(new RelationshipEnd(Supplier));

            Relationship ManufacturedBy = new Relationship("ManufacturedBy");

            ManufacturedBy.AddRelationshipEnd(new RelationshipEnd(Car));
            ManufacturedBy.AddRelationshipEnd(new RelationshipEnd(Manufacturer));

            ERModel Model = new ERModel("ERModel", new List <BaseERElement> {
                Person, Car, Garage, Repaired, Supplier, Insurance, Owns, Manufacturer, ManufacturedBy
            });

            // Mongo Schema
            MongoDBCollection PersonCol = new MongoDBCollection("Person");

            PersonCol.AddAttributes("_id", "name");

            MongoDBCollection CarCol = new MongoDBCollection("Car");

            CarCol.AddAttributes("_id", "model", "year", "manufacturerId");

            MongoDBCollection GarageCol = new MongoDBCollection("Garage");

            GarageCol.AddAttributes("_id", "name");

            MongoDBCollection SupplierCol = new MongoDBCollection("Supplier");

            SupplierCol.AddAttributes("_id", "name");

            MongoDBCollection RepairedCol = new MongoDBCollection("Repaired");

            RepairedCol.AddAttributes("_id", "carId", "garageId", "supplierId", "repaired");

            MongoDBCollection InsuranceCol = new MongoDBCollection("Insurance");

            InsuranceCol.AddAttributes("_id", "name", "value");

            MongoDBCollection OwnsCol = new MongoDBCollection("Owns");

            OwnsCol.AddAttributes("_id", "personId", "carId", "insuranceId");

            MongoDBCollection ManufacturerCol = new MongoDBCollection("Manufacturer");

            ManufacturerCol.AddAttributes("_id", "name");

            MongoSchema Schema = new MongoSchema("Schema", new List <MongoDBCollection> {
                PersonCol, CarCol, GarageCol, RepairedCol, SupplierCol, InsuranceCol, OwnsCol, ManufacturerCol
            });

            // Map Rules
            MapRule PersonRule = new MapRule(Person, PersonCol);

            PersonRule.AddRule("personId", "_id");
            PersonRule.AddRule("name", "name");

            MapRule CarRule = new MapRule(Car, CarCol);

            CarRule.AddRule("carId", "_id");
            CarRule.AddRule("model", "model");
            CarRule.AddRule("year", "year");

            MapRule GarageRule = new MapRule(Garage, GarageCol);

            GarageRule.AddRule("garageId", "_id");
            GarageRule.AddRule("name", "name");

            MapRule SupplierRule = new MapRule(Supplier, SupplierCol);

            SupplierRule.AddRule("supplierId", "_id");
            SupplierRule.AddRule("name", "name");

            MapRule RepairedRule = new MapRule(Repaired, RepairedCol);

            RepairedRule.AddRule("repairedId", "_id");
            RepairedRule.AddRule("repaired", "repaired");

            MapRule InsuranceRule = new MapRule(Insurance, InsuranceCol);

            InsuranceRule.AddRule("insuranceId", "_id");
            InsuranceRule.AddRule("name", "name");
            InsuranceRule.AddRule("value", "value");

            MapRule OwnsRule = new MapRule(Owns, OwnsCol);

            OwnsRule.AddRule("ownsId", "_id");

            MapRule ManufacturerRule = new MapRule(Manufacturer, ManufacturerCol);

            ManufacturerRule.AddRule("manufacturerId", "_id");
            ManufacturerRule.AddRule("name", "name");

            MapRule PersonOwnsRule = new MapRule(Person, OwnsCol, false);

            PersonOwnsRule.AddRule("personId", "personId");

            MapRule CarOwnsRule = new MapRule(Car, OwnsCol, false);

            CarOwnsRule.AddRule("carId", "carId");

            MapRule InsuranceOwnsRule = new MapRule(Insurance, OwnsCol, false);

            InsuranceOwnsRule.AddRule("insuranceId", "insuranceId");

            MapRule CarRepairedRule = new MapRule(Car, RepairedCol, false);

            CarRepairedRule.AddRule("carId", "carId");

            MapRule GarageRepairedRule = new MapRule(Garage, RepairedCol, false);

            GarageRepairedRule.AddRule("garageId", "garageId");

            MapRule SupplierRepairedRule = new MapRule(Supplier, RepairedCol, false);

            SupplierRepairedRule.AddRule("supplierId", "supplierId");

            MapRule ManufacturerCarRule = new MapRule(Manufacturer, CarCol, false);

            ManufacturerCarRule.AddRule("manufacturerId", "manufacturerId");

            ModelMapping Map = new ModelMapping("Map", new List <MapRule> {
                PersonRule, CarRule, GarageRule, RepairedRule, SupplierRule, InsuranceRule, OwnsRule, ManufacturerRule, PersonOwnsRule, CarOwnsRule, InsuranceOwnsRule, CarRepairedRule, GarageRepairedRule, SupplierRepairedRule, ManufacturerCarRule
            });

            return(new RequiredDataContainer(Model, Schema, Map));
        }
        /// <summary>
        /// Generates required data to test a One to One relationship
        /// joining multiple entities with relationship attribute and multiple root attributes
        /// </summary>
        /// <returns></returns>
        public static RequiredDataContainer OneToOneRelationshipMultipleRootAttributes()
        {
            // Create ER Stuff
            Entity Person = new Entity("Person");

            Person.AddAttribute("personId", true);
            Person.AddAttribute("name");
            Person.AddAttribute("insuranceId");

            Entity Car = new Entity("Car");

            Car.AddAttribute("name");
            Car.AddAttribute("year");
            Car.AddAttribute("engine");
            Car.AddAttribute("fuel");

            Entity Insurance = new Entity("Insurance");

            Insurance.AddAttribute("insuranceId", true);
            Insurance.AddAttribute("name");

            Relationship HasInsurance = new Relationship("HasInsurance");

            HasInsurance.AddAttribute("insuranceValue");
            HasInsurance.AddRelationshipEnd(new RelationshipEnd(Person));
            HasInsurance.AddRelationshipEnd(new RelationshipEnd(Car));
            HasInsurance.AddRelationshipEnd(new RelationshipEnd(Insurance));

            ERModel Model = new ERModel("PersonCarModel", new List <BaseERElement> {
                Person, Car, HasInsurance, Insurance
            });

            // Create MongoDB schema
            MongoDBCollection PersonCollection = new MongoDBCollection("Person");

            PersonCollection.DocumentSchema.AddAttribute("_id");
            PersonCollection.DocumentSchema.AddAttribute("name");
            PersonCollection.DocumentSchema.AddAttribute("car.name");
            PersonCollection.DocumentSchema.AddAttribute("car.year");
            PersonCollection.DocumentSchema.AddAttribute("carDetails.engine");
            PersonCollection.DocumentSchema.AddAttribute("CarDetails.fuel");
            PersonCollection.DocumentSchema.AddAttribute("insuranceId");
            PersonCollection.DocumentSchema.AddAttribute("insuranceValue");

            MongoDBCollection InsuranceCollection = new MongoDBCollection("Insurance");

            InsuranceCollection.DocumentSchema.AddAttribute("_id");
            InsuranceCollection.DocumentSchema.AddAttribute("name");

            MongoSchema Schema = new MongoSchema("PersonCarSchema", new List <MongoDBCollection> {
                PersonCollection, InsuranceCollection
            });

            // Create Map
            MapRule PersonRule = new MapRule(Model.FindByName("Person"), Schema.FindByName("Person"));

            PersonRule.AddRule("personId", "_id");
            PersonRule.AddRule("name", "name");
            PersonRule.AddRule("carId", "carId");
            PersonRule.AddRule("insuranceId", "insuranceId");

            MapRule CarRule = new MapRule(Model.FindByName("Car"), Schema.FindByName("Person"), false);

            CarRule.AddRule("name", "car.name");
            CarRule.AddRule("year", "car.year");
            CarRule.AddRule("engine", "carDetails.engine");
            CarRule.AddRule("fuel", "carDetails.fuel");

            MapRule InsuranceRule = new MapRule(Model.FindByName("Insurance"), Schema.FindByName("Insurance"));

            InsuranceRule.AddRule("insuranceId", "_id");
            InsuranceRule.AddRule("name", "name");

            MapRule InsurancePersonRule = new MapRule(Model.FindByName("Insurance"), Schema.FindByName("Person"), false);

            InsurancePersonRule.AddRule("insuranceId", "insuranceId");

            MapRule RelationshipRule = new MapRule(Model.FindByName("HasInsurance"), Schema.FindByName("Person"), false);

            RelationshipRule.AddRule("insuranceValue", "insuranceValue");

            ModelMapping Map = new ModelMapping("PersonCarMap", new List <MapRule> {
                PersonRule, CarRule, InsuranceRule, RelationshipRule, InsurancePersonRule
            });

            return(new RequiredDataContainer(Model, Schema, Map));
        }
Beispiel #9
0
        /// <summary>
        /// Generates data to test a query in which the target entity is embedded in the middle collection
        /// </summary>
        /// <returns></returns>
        public static RequiredDataContainer ManyToManyEmbeddedTarget()
        {
            // ER Model
            Entity Person = new Entity("Person");

            Person.AddAttribute("personId", true);
            Person.AddAttributes("name", "age");

            Entity Car = new Entity("Car");

            Car.AddAttribute("carId", true);
            Car.AddAttributes("model", "year");

            Relationship Drives = new Relationship("Drives");

            Drives.AddAttribute("something");

            Drives.AddRelationshipEnd(new RelationshipEnd(Person));
            Drives.AddRelationshipEnd(new RelationshipEnd(Car));

            ERModel Model = new ERModel("Model", new List <BaseERElement>()
            {
                Person, Car, Drives
            });

            // Mongo Schema
            MongoDBCollection PersonCol = new MongoDBCollection("Person");

            PersonCol.AddAttributes("_id", "name", "age");

            MongoDBCollection DrivesCol = new MongoDBCollection("Drives");

            DrivesCol.AddAttributes("_id", "something", "car.carId", "car.model", "car.year");

            MongoSchema Schema = new MongoSchema("Schema", new List <MongoDBCollection>()
            {
                PersonCol, DrivesCol
            });

            // Map
            MapRule PersonRule = new MapRule(Person, PersonCol);

            PersonRule.AddRule("personId", "_id");
            PersonRule.AddRule("name", "name");
            PersonRule.AddRule("age", "age");

            MapRule CarRule = new MapRule(Car, DrivesCol, false);

            CarRule.AddRule("carId", "car.carId");
            CarRule.AddRule("model", "car.model");
            CarRule.AddRule("year", "car.year");

            MapRule DrivesRule = new MapRule(Drives, DrivesCol);

            DrivesRule.AddRule("something", "something");

            MapRule PersonDrivesRule = new MapRule(Person, DrivesCol, false);

            PersonDrivesRule.AddRule("personId", "personId");

            ModelMapping Map = new ModelMapping("Map", new List <MapRule>()
            {
                PersonRule, CarRule, DrivesRule, PersonDrivesRule
            });

            return(new RequiredDataContainer(Model, Schema, Map));
        }
Beispiel #10
0
        /// <summary>
        /// Generates data to test a many to many relationship join with multiple entities
        /// and relationship attributes
        /// </summary>
        /// <returns></returns>
        public static RequiredDataContainer ManyToManyRelationshipAttributeMultipleEntities()
        {
            Entity Person = new Entity("Person");

            Person.AddAttribute("personId", true);
            Person.AddAttribute("name");

            Entity Car = new Entity("Car");

            Car.AddAttribute("carId", true);
            Car.AddAttribute("name");
            Car.AddAttribute("year");

            Entity InsCompany = new Entity("InsCompany");

            InsCompany.AddAttribute("companyId", true);
            InsCompany.AddAttribute("name");

            Relationship Insurance = new Relationship("Insurance");

            Insurance.AddAttribute("insuranceId");
            Insurance.AddAttribute("insuranceValue");
            Insurance.AddAttribute("aRandomValue");
            Insurance.AddRelationshipEnd(new RelationshipEnd(Person));
            Insurance.AddRelationshipEnd(new RelationshipEnd(Car));
            Insurance.AddRelationshipEnd(new RelationshipEnd(InsCompany));

            ERModel Model = new ERModel("PersonCar", new List <BaseERElement> {
                Person, Car, Insurance, InsCompany
            });

            // MongoDB Schema
            MongoDBCollection PersonCol = new MongoDBCollection("Person");

            PersonCol.DocumentSchema.AddAttribute("_id");
            PersonCol.DocumentSchema.AddAttribute("name");

            MongoDBCollection CarCol = new MongoDBCollection("Car");

            CarCol.DocumentSchema.AddAttribute("_id");
            CarCol.DocumentSchema.AddAttribute("name");
            CarCol.DocumentSchema.AddAttribute("year");

            MongoDBCollection InsuranceCol = new MongoDBCollection("Insurance");

            InsuranceCol.DocumentSchema.AddAttribute("_id");
            InsuranceCol.DocumentSchema.AddAttribute("personId");
            InsuranceCol.DocumentSchema.AddAttribute("carId");
            InsuranceCol.DocumentSchema.AddAttribute("companyId");
            InsuranceCol.DocumentSchema.AddAttribute("insuranceValue");
            InsuranceCol.DocumentSchema.AddAttribute("aRandomValue");

            MongoDBCollection InsCompanyCol = new MongoDBCollection("InsCompany");

            InsCompanyCol.DocumentSchema.AddAttribute("_id");
            InsCompanyCol.DocumentSchema.AddAttribute("name");

            MongoSchema DBSchema = new MongoSchema("PersonCarSchema",
                                                   new List <MongoDBCollection> {
                PersonCol, CarCol, InsuranceCol, InsCompanyCol
            });

            // Map
            MapRule PersonRule = new MapRule(Person, PersonCol);

            PersonRule.AddRule("personId", "_id");
            PersonRule.AddRule("name", "name");

            MapRule CarRule = new MapRule(Car, CarCol);

            CarRule.AddRule("carId", "_id");
            CarRule.AddRule("name", "name");
            CarRule.AddRule("year", "year");

            MapRule InsuranceRule = new MapRule(Insurance, InsuranceCol);

            InsuranceRule.AddRule("insuranceId", "_id");
            InsuranceRule.AddRule("insuranceValue", "insuranceValue");
            InsuranceRule.AddRule("aRandomValue", "aRandomValue");

            MapRule InsCompanyRule = new MapRule(InsCompany, InsCompanyCol);

            InsCompanyRule.AddRule("companyId", "_id");
            InsCompanyRule.AddRule("name", "name");

            MapRule PersonInsuranceRule = new MapRule(Person, InsuranceCol, false);

            PersonInsuranceRule.AddRule("personId", "personId");

            MapRule CarInsuranceRule = new MapRule(Car, InsuranceCol, false);

            CarInsuranceRule.AddRule("carId", "carId");

            MapRule InsCompanyInsuranceRule = new MapRule(InsCompany, InsuranceCol, false);

            InsCompanyInsuranceRule.AddRule("companyId", "companyId");

            ModelMapping Map = new ModelMapping("PersonCarMap", new List <MapRule> {
                PersonRule,
                CarRule, InsuranceRule, InsCompanyRule, PersonInsuranceRule, CarInsuranceRule, InsCompanyInsuranceRule
            });

            return(new RequiredDataContainer(Model, DBSchema, Map));
        }
        public static DataContainer CreateDataContainer()
        {
            Entity Person = new Entity("Person");

            Person.AddAttribute("personId", true);
            Person.AddAttribute("name");

            Entity Car = new Entity("Car");

            Car.AddAttribute("carId", true);
            Car.AddAttributes("plate", "color");

            Relationship Drives = new Relationship("Drives");

            Drives.AddAttribute("note");
            Drives.AddRelationshipEnd(new RelationshipEnd(Person));
            Drives.AddRelationshipEnd(new RelationshipEnd(Car));

            ERModel Model = new ERModel("Model", new List <BaseERElement>()
            {
                Person, Car, Drives
            });

            MongoDBCollection PersonCol = new MongoDBCollection("Person");

            PersonCol.AddAttributes("_id", "name", "cars_multivalued_.id", "cars_multivalued_.note");

            MongoDBCollection CarCol = new MongoDBCollection("Car");

            CarCol.AddAttributes("_id", "plate", "color");

            MongoSchema Schema = new MongoSchema("Schema", new List <MongoDBCollection>()
            {
                PersonCol, CarCol
            });

            MapRule PersonRule = new MapRule(Person, PersonCol);

            PersonRule.AddRule("personId", "_id");
            PersonRule.AddRule("name", "name");

            MapRule CarRule = new MapRule(Car, CarCol);

            CarRule.AddRule("carId", "_id");
            CarRule.AddRule("plate", "plate");
            CarRule.AddRule("color", "color");

            MapRule CarPersonRule = new MapRule(Car, PersonCol, false);

            CarPersonRule.AddRule("carId", "cars_multivalued_.id");

            MapRule DrivesPersonRule = new MapRule(Drives, PersonCol, false);

            DrivesPersonRule.AddRule("note", "cars_multivalued_.note");

            ModelMapping Map = new ModelMapping("Map", new List <MapRule>()
            {
                PersonRule, CarRule, CarPersonRule, DrivesPersonRule
            });

            return(new DataContainer(Model, Schema, Map));
        }
        /// <summary>
        /// Data for a computed entity test starting from a one to many relationship
        /// </summary>
        /// <returns></returns>
        public static RequiredDataContainer OneToManyComputedEntity()
        {
            Entity Person = new Entity("Person");

            Person.AddAttributes("personId", "name", "insuranceId");

            Entity Car = new Entity("Car");

            Car.AddAttributes("carId", "model", "year", "driverId");

            Entity Garage = new Entity("Garage");

            Garage.AddAttributes("garageId", "name");

            Entity Supplier = new Entity("Supplier");

            Supplier.AddAttributes("supplierId", "name");

            Entity Insurance = new Entity("Insurance");

            Insurance.AddAttributes("insuranceId", "name", "value");

            Relationship Drives = new Relationship("Drives");

            Drives.AddRelationshipEnd(new RelationshipEnd(Person));
            Drives.AddRelationshipEnd(new RelationshipEnd(Car));

            Relationship Repaired = new Relationship("Repaired");

            Repaired.AddAttributes("repairedId", "carId", "garageId", "supplierId", "repaired");
            Repaired.AddRelationshipEnd(new RelationshipEnd(Car));
            Repaired.AddRelationshipEnd(new RelationshipEnd(Garage));
            Repaired.AddRelationshipEnd(new RelationshipEnd(Supplier));;

            Relationship HasInsurance = new Relationship("HasInsurance");

            HasInsurance.AddRelationshipEnd(new RelationshipEnd(Person));
            HasInsurance.AddRelationshipEnd(new RelationshipEnd(Insurance));

            ERModel Model = new ERModel("ERModel", new List <BaseERElement> {
                Person, Car, Garage, Drives, Repaired, Supplier, Insurance, HasInsurance
            });

            // Mongo Schema
            MongoDBCollection PersonCol = new MongoDBCollection("Person");

            PersonCol.AddAttributes("_id", "name", "insuranceId");

            MongoDBCollection CarCol = new MongoDBCollection("Car");

            CarCol.AddAttributes("_id", "model", "year", "driverId");

            MongoDBCollection GarageCol = new MongoDBCollection("Garage");

            GarageCol.AddAttributes("_id", "name");

            MongoDBCollection SupplierCol = new MongoDBCollection("Supplier");

            SupplierCol.AddAttributes("_id", "name");

            MongoDBCollection RepairedCol = new MongoDBCollection("Repaired");

            RepairedCol.AddAttributes("_id", "carId", "garageId", "supplierId", "repaired");

            MongoDBCollection InsuranceCol = new MongoDBCollection("Insurance");

            InsuranceCol.AddAttributes("_id", "name", "value");

            MongoSchema Schema = new MongoSchema("Schema", new List <MongoDBCollection> {
                PersonCol, CarCol, GarageCol, RepairedCol, SupplierCol, InsuranceCol
            });

            // Map Rules
            MapRule PersonRule = new MapRule(Person, PersonCol);

            PersonRule.AddRule("personId", "_id");
            PersonRule.AddRule("name", "name");
            PersonRule.AddRule("insuranceId", "insuranceId");

            MapRule CarRule = new MapRule(Car, CarCol);

            CarRule.AddRule("carId", "_id");
            CarRule.AddRule("model", "model");
            CarRule.AddRule("year", "year");
            CarRule.AddRule("driverId", "driverId");

            MapRule GarageRule = new MapRule(Garage, GarageCol);

            GarageRule.AddRule("garageId", "_id");
            GarageRule.AddRule("name", "name");

            MapRule SupplierRule = new MapRule(Supplier, SupplierCol);

            SupplierRule.AddRule("supplierId", "_id");
            SupplierRule.AddRule("name", "name");

            MapRule RepairedRule = new MapRule(Repaired, RepairedCol);

            RepairedRule.AddRule("repairedId", "_id");
            RepairedRule.AddRule("carId", "carId");
            RepairedRule.AddRule("garageId", "garageId");
            RepairedRule.AddRule("supplierId", "supplierId");
            RepairedRule.AddRule("repaired", "repaired");

            MapRule InsuranceRule = new MapRule(Insurance, InsuranceCol);

            InsuranceRule.AddRule("insuranceId", "_id");
            InsuranceRule.AddRule("name", "name");
            InsuranceRule.AddRule("value", "value");

            ModelMapping Map = new ModelMapping("Map", new List <MapRule> {
                PersonRule, CarRule, GarageRule, RepairedRule, SupplierRule, InsuranceRule
            });

            return(new RequiredDataContainer(Model, Schema, Map));
        }
Beispiel #13
0
        public static DataContainer CreateDataContainer()
        {
            // ER MODEL
            Entity Person = new Entity("Person");

            Person.AddAttribute("id", true);
            Person.AddAttributes("name", "surname", "salary");

            Entity Car = new Entity("Car");

            Car.AddAttribute("id", true);
            Car.AddAttributes("reg_no");

            Entity InsuranceCompany = new Entity("InsuranceCompany");

            InsuranceCompany.AddAttribute("id", true);
            InsuranceCompany.AddAttributes("name");

            Entity Garage = new Entity("Garage");

            Garage.AddAttribute("id", true);
            Garage.AddAttributes("name", "phone");

            Relationship Insurance = new Relationship("Insurance");

            Insurance.AddAttributes("contract");
            Insurance.AddRelationshipEnd(new RelationshipEnd(Person));
            Insurance.AddRelationshipEnd(new RelationshipEnd(Car));
            Insurance.AddRelationshipEnd(new RelationshipEnd(InsuranceCompany));

            Relationship Drives = new Relationship("Drives");

            Drives.AddRelationshipEnd(new RelationshipEnd(Person));
            Drives.AddRelationshipEnd(new RelationshipEnd(Car));

            Relationship Repaired = new Relationship("Repaired");

            Repaired.AddAttributes("date");
            Repaired.AddRelationshipEnd(new RelationshipEnd(Car));
            Repaired.AddRelationshipEnd(new RelationshipEnd(Garage));

            ERModel Model = new ERModel("SampleModel", new List <BaseERElement>()
            {
                Person, Car, InsuranceCompany, Garage, Insurance, Drives, Repaired
            });

            // SCHEMA
            MongoDBCollection PersonCol = new MongoDBCollection("PersonCollection");

            PersonCol.AddAttributes("_id", "fName", "fSurname", "fSalary");

            MongoDBCollection CarCol = new MongoDBCollection("CarCollection");

            CarCol.AddAttributes("_id", "fReg_no");

            MongoDBCollection InsuranceCompanyCol = new MongoDBCollection("InsuranceCompanyCollection");

            InsuranceCompanyCol.AddAttributes("_id", "fName");

            MongoDBCollection GarageCol = new MongoDBCollection("GarageCollection");

            GarageCol.AddAttributes("_id", "fName", "fPhone");

            MongoDBCollection InsuranceCol = new MongoDBCollection("InsuranceCollection");

            InsuranceCol.AddAttributes("contract");

            MongoDBCollection DrivesCol = new MongoDBCollection("DrivesCollection");

            DrivesCol.AddAttributes("fPersonId", "fCarId");

            MongoDBCollection RepairedCol = new MongoDBCollection("RepairedCollection");

            RepairedCol.AddAttributes("fCarId", "fGarageId", "fDate");

            MongoSchema Schema = new MongoSchema("SampleSchema", new List <MongoDBCollection>()
            {
                PersonCol, CarCol, InsuranceCompanyCol, GarageCol, InsuranceCol, DrivesCol, RepairedCol
            });

            // Mapping
            MapRule PersonRule = new MapRule(Person, PersonCol);

            PersonRule.AddRule("id", "_id");
            PersonRule.AddRule("name", "fName");
            PersonRule.AddRule("surname", "fSurname");
            PersonRule.AddRule("salary", "fSalary");

            MapRule CarRule = new MapRule(Car, CarCol);

            CarRule.AddRule("id", "_id");
            CarRule.AddRule("reg_no", "fReg_no");

            MapRule InsCompanyRule = new MapRule(InsuranceCompany, InsuranceCompanyCol);

            InsCompanyRule.AddRule("id", "_id");
            InsCompanyRule.AddRule("name", "fName");

            MapRule GarageRule = new MapRule(Garage, GarageCol);

            GarageRule.AddRule("id", "_id");
            GarageRule.AddRule("name", "fName");
            GarageRule.AddRule("phone", "fPhone");

            MapRule InsuranceRule = new MapRule(Insurance, InsuranceCol);

            InsuranceRule.AddRule("contract", "contract");

            MapRule PersonInsuranceRule = new MapRule(Person, InsuranceCol, false);

            PersonInsuranceRule.AddRule("id", "fPersonId");

            MapRule CarInsuranceRule = new MapRule(Car, InsuranceCol, false);

            CarInsuranceRule.AddRule("id", "fCarId");

            MapRule InsCompanyInsuranceRule = new MapRule(InsuranceCompany, InsuranceCol, false);

            InsCompanyInsuranceRule.AddRule("id", "fInsCoId");

            MapRule DrivesRule = new MapRule(Drives, DrivesCol);

            MapRule PersonDrivesRule = new MapRule(Person, DrivesCol, false);

            PersonDrivesRule.AddRule("id", "fPersonId");

            MapRule CarDrivesRule = new MapRule(Car, DrivesCol, false);

            CarDrivesRule.AddRule("id", "fCarId");

            MapRule RepairedRule = new MapRule(Repaired, RepairedCol);

            RepairedRule.AddRule("date", "fDate");

            MapRule CarRepairedRule = new MapRule(Car, RepairedCol, false);

            CarRepairedRule.AddRule("id", "fCarId");

            MapRule GarageRepairedRule = new MapRule(Garage, RepairedCol, false);

            GarageRepairedRule.AddRule("id", "fGarageId");

            ModelMapping Mapping = new ModelMapping("SampleMapping", new List <MapRule>()
            {
                PersonRule, CarRule, InsCompanyRule, GarageRule, InsuranceRule, PersonInsuranceRule, CarInsuranceRule, InsCompanyInsuranceRule, DrivesRule, PersonDrivesRule, CarDrivesRule, RepairedRule, CarRepairedRule, GarageRepairedRule
            });

            return(new DataContainer(Model, Schema, Mapping));
        }
Beispiel #14
0
        /// <summary>
        /// Generates data to test a RJOIN operation with a one to one relationship
        /// connecting to a composition of two other entities
        /// </summary>
        /// <returns></returns>
        public static RequiredDataContainer OneToOneComputedEntity()
        {
            Entity Person = new Entity("Person");

            Person.AddAttribute("personId", true);
            Person.AddAttributes("name");

            Entity Car = new Entity("Car");

            Car.AddAttribute("carId", true);
            Car.AddAttributes("model", "year");

            Entity Garage = new Entity("Garage");

            Garage.AddAttribute("garageId", true);
            Garage.AddAttributes("name");

            Relationship Drives = new Relationship("Drives");

            Drives.AddRelationshipEnd(new RelationshipEnd(Person));
            Drives.AddRelationshipEnd(new RelationshipEnd(Car));

            Relationship Repaired = new Relationship("Repaired");

            Repaired.AddRelationshipEnd(new RelationshipEnd(Car));
            Repaired.AddRelationshipEnd(new RelationshipEnd(Garage));
            Repaired.AddAttribute("repairedId", true);
            Repaired.AddAttributes("repaired");

            ERModel Model = new ERModel("ERModel", new List <BaseERElement> {
                Person, Car, Garage, Drives, Repaired
            });

            // Mongo Schema
            MongoDBCollection PersonCol = new MongoDBCollection("Person");

            PersonCol.AddAttributes("_id", "name", "carId");

            MongoDBCollection CarCol = new MongoDBCollection("Car");

            CarCol.AddAttributes("_id", "model", "year");

            MongoDBCollection GarageCol = new MongoDBCollection("Garage");

            GarageCol.AddAttributes("_id", "name");

            MongoDBCollection RepairedCol = new MongoDBCollection("Repaired");

            RepairedCol.AddAttributes("_id", "carId", "garageId", "repaired");

            MongoSchema Schema = new MongoSchema("Schema", new List <MongoDBCollection> {
                PersonCol, CarCol, GarageCol, RepairedCol
            });

            // Map Rules
            MapRule PersonRule = new MapRule(Person, PersonCol);

            PersonRule.AddRule("personId", "_id");
            PersonRule.AddRule("name", "name");

            MapRule CarRule = new MapRule(Car, CarCol);

            CarRule.AddRule("carId", "_id");
            CarRule.AddRule("model", "model");
            CarRule.AddRule("year", "year");

            MapRule GarageRule = new MapRule(Garage, GarageCol);

            GarageRule.AddRule("garageId", "_id");
            GarageRule.AddRule("name", "name");

            MapRule RepairedRule = new MapRule(Repaired, RepairedCol);

            RepairedRule.AddRule("repairedId", "_id");
            RepairedRule.AddRule("repaired", "repaired");

            MapRule CarPersonRule = new MapRule(Car, PersonCol, false);

            CarPersonRule.AddRule("carId", "carId");

            MapRule CarRepairedRule = new MapRule(Car, RepairedCol, false);

            CarRepairedRule.AddRule("carId", "carId");

            MapRule GarageRepairedRule = new MapRule(Garage, RepairedCol, false);

            GarageRepairedRule.AddRule("garageId", "garageId");

            ModelMapping Map = new ModelMapping("Map", new List <MapRule> {
                PersonRule, CarRule, GarageRule, RepairedRule, CarPersonRule, CarRepairedRule, GarageRepairedRule
            });

            return(new RequiredDataContainer(Model, Schema, Map));
        }