/// <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));
        }
Esempio n. 2
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));
        }
        /// <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));
        }
Esempio n. 4
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));
        }