Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
0
        public static CobieModel ImportFromTable(Stream file, ExcelTypeEnum typeEnum, out string report, ModelMapping mapping = null)
        {
            var loaded = new CobieModel();

            mapping = mapping ?? ModelMapping.Load(Properties.Resources.COBieUK2012);
            var storage = GetTableStore(loaded, mapping);

            using (var txn = loaded.BeginTransaction("Loading XLSX"))
            {
                storage.LoadFrom(file, typeEnum);
                txn.Commit();
            }

            report = storage.Log.ToString();
            return(loaded);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Assign a value to StartMap
 /// </summary>
 /// <param name="inMap"></param>
 public void SetStartMap(ModelMapping inMap)
 {
     StartMap = inMap;
 }
 /// <summary>
 /// Initialize a new instance of AlgebraOperator class
 /// </summary>
 public AlgebraOperator(ModelMapping ModelMap)
 {
     this.ModelMap = ModelMap;
 }
 /// <summary>
 /// Initialize a new OperationResult instance
 /// </summary>
 /// <param name="PipelineResult"></param>
 /// <param name="Commands"></param>
 public AlgebraOperatorResult(List <MongoDBOperator> Commands)
 {
     this.Commands = Commands;
     ResultMap     = new ModelMapping("ResultModel");
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a MongoDBSchema and Mapping the is a 1-1 map with the ER model
        /// </summary>
        /// <returns></returns>
        public static RequiredDataContainer MapEntitiesToCollections()
        {
            // Create Schema
            MongoDBCollection UserCol = new MongoDBCollection("User");

            UserCol.AddAttributes("_id", "user_name", "user_email", "user_access", "user_newsletter");

            MongoDBCollection ProductCol = new MongoDBCollection("Product");

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

            MongoDBCollection CategoryCol = new MongoDBCollection("Category");

            CategoryCol.AddAttributes("_id", "category_name");

            MongoDBCollection StoreCol = new MongoDBCollection("Store");

            StoreCol.AddAttributes("_id", "store_name", "store_logo");

            MongoSchema Schema = new MongoSchema("CMSSchema", new List <MongoDBCollection>()
            {
                UserCol, ProductCol,
                StoreCol, CategoryCol
            });

            // Retrieve ER Model
            ERModel Model = CreateERModel();

            // Build Mapping
            Entity User = (Entity)Model.FindByName("User");

            MapRule UserRules = new MapRule(User, UserCol);

            UserRules.AddRule("user_id", "_id");
            UserRules.AddRule("user_name", "user_name");
            UserRules.AddRule("user_email", "user_email");
            UserRules.AddRule("user_access", "user_access");
            UserRules.AddRule("user_newsletter", "user_newsletter");

            Entity Product = (Entity)Model.FindByName("Product");

            MapRule ProductRules = new MapRule(Product, ProductCol);

            ProductRules.AddRule("product_id", "_id");
            ProductRules.AddRule("product_title", "product_title");
            ProductRules.AddRule("product_description", "product_description");
            ProductRules.AddRule("product_short_description", "product_short_description");
            ProductRules.AddRule("product_url", "product_url");
            ProductRules.AddRule("product_category_id", "product_category_id");
            ProductRules.AddRule("product_store_id", "product_store_id");
            ProductRules.AddRule("product_user_id", "product_user_id");
            ProductRules.AddRule("product_published", "product_published");
            ProductRules.AddRule("product_image", "product_image");

            Entity Category = (Entity)Model.FindByName("Category");

            MapRule CategoryRules = new MapRule(Category, CategoryCol);

            CategoryRules.AddRule("category_id", "_id");
            CategoryRules.AddRule("category_name", "category_name");

            Entity Store = (Entity)Model.FindByName("Store");

            MapRule StoreRules = new MapRule(Store, StoreCol);

            StoreRules.AddRule("store_id", "_id");
            StoreRules.AddRule("store_name", "store_name");
            StoreRules.AddRule("store_logo", "store_logo");

            ModelMapping Map = new ModelMapping("CMSMap11", new List <MapRule>()
            {
                UserRules,
                ProductRules, CategoryRules, StoreRules
            });

            return(new RequiredDataContainer(Model, Schema, Map));
        }
Ejemplo n.º 7
0
 public static ModelMapping GetMapping()
 {
     return(ModelMapping.Load(GetCobieConfigurationXml()));
 }
        public static ModelMapping Build(HandlerAccessor handlers, SchemaExtractionResult sqlModel, MappingResolver resolver, NodeConfiguration nodeConfiguration, bool isLegacy)
        {
            var domainModel   = handlers.Domain.Model;
            var configuration = handlers.Domain.Configuration;
            var providerInfo  = handlers.ProviderInfo;

            var mapping = new ModelMapping();

            // Register persistent types

            var typesToProcess = domainModel.Types.AsEnumerable();

            if (isLegacy || configuration.IsMultidatabase)
            {
                typesToProcess = typesToProcess.Where(t => !t.IsSystem);
            }

            foreach (var type in typesToProcess)
            {
                var primaryIndex = type.Indexes.FindFirst(IndexAttributes.Real | IndexAttributes.Primary);
                if (primaryIndex == null || primaryIndex.IsAbstract)
                {
                    continue;
                }
                var reflectedType = primaryIndex.ReflectedType;
                var nodeName      = resolver.GetNodeName(reflectedType);
                var storageTable  = resolver.Resolve(sqlModel, nodeName).GetTable();
                if (storageTable == null)
                {
                    throw new DomainBuilderException(String.Format(Strings.ExTableXIsNotFound, nodeName));
                }
                mapping.Register(reflectedType, storageTable);
            }

            // Register key generators

            var keyGenerator = domainModel.Hierarchies
                               .Select(h => h.Key.Sequence)
                               .Where(s => s != null)
                               .Distinct();

            Func <MappingResolveResult, SchemaNode> nodeResolver;

            if (providerInfo.Supports(ProviderFeatures.Sequences))
            {
                nodeResolver = r => r.GetSequence();
            }
            else
            {
                nodeResolver = r => r.GetTable();
            }

            foreach (var sequence in keyGenerator)
            {
                var nodeResult = resolver.Resolve(sqlModel, resolver.GetNodeName(sequence));
                var node       = nodeResolver.Invoke(nodeResult);
                mapping.Register(sequence, node);
            }

            // Fill information for TemporaryTableManager

            var defaultSchema = resolver.ResolveSchema(sqlModel, configuration.DefaultDatabase, configuration.DefaultSchema);

            if (configuration.ShareStorageSchemaOverNodes && handlers.ProviderInfo.Supports(ProviderFeatures.Multischema))
            {
                mapping.TemporaryTableDatabase = nodeConfiguration.GetActualNameFor(defaultSchema.Catalog);
                mapping.TemporaryTableSchema   = nodeConfiguration.GetActualNameFor(defaultSchema);
            }
            else
            {
                mapping.TemporaryTableDatabase = defaultSchema.Catalog.GetNameInternal();
                mapping.TemporaryTableSchema   = defaultSchema.GetNameInternal();
            }

            if (providerInfo.Supports(ProviderFeatures.Collations))
            {
                if (!string.IsNullOrEmpty(configuration.Collation))
                {
                    // If user explicitly specified collation use that
                    mapping.TemporaryTableCollation = configuration.Collation;
                }
                else
                {
                    // Otherwise use first available collation
                    var collation = defaultSchema.Collations.FirstOrDefault();
                    mapping.TemporaryTableCollation = collation != null ? collation.Name : null;
                }
            }

            mapping.Lock();
            return(mapping);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializa a new AddFieldsOperation instance
 /// </summary>
 /// <param name="Attributes"></param>
 /// <param name="Map"></param>
 public AddFieldsOperation(Dictionary <string, JSCode> Attributes, ModelMapping Map) : base(Map)
 {
     this.Attributes = Attributes;
 }
Ejemplo n.º 10
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));
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Initialize a new instance of FromArgument class
 /// </summary>
 /// <param name="Entity"></param>
 /// <param name="MapRules"></param>
 public FromArgument(QueryableEntity Entity, ModelMapping MapRules)
 {
     this.Entity   = Entity;
     this.MapRules = MapRules;
 }
Ejemplo n.º 12
0
        public static void Main()
        {
            DataContainer data = CreateDataContainer();

            QueryableEntity Person = new QueryableEntity(data.EntityRelationshipModel.FindByName("Person"));
            QueryableEntity Car    = new QueryableEntity(data.EntityRelationshipModel.FindByName("Car"));
            Relationship    Drives = (Relationship)data.EntityRelationshipModel.FindByName("Drives");
            ModelMapping    Map    = data.ERMongoMapping;

            QueryableEntity Garage = new QueryableEntity(data.EntityRelationshipModel.FindByName("Garage"));

            RelationshipJoinOperator RJoinDrives = new RelationshipJoinOperator(
                Person,
                Drives,
                new List <QueryableEntity>()
            {
                Car
            },
                Map);

            CartesianProductOperator CartesianOp = new CartesianProductOperator(
                Person,
                Garage,
                Map);

            ProjectArgument ProjectArg1 = new ProjectArgument(Person.GetAttribute("name"), Person, new BooleanExpr(true));
            ProjectArgument ProjectArg2 = new ProjectArgument(Person.GetAttribute("surname"), Person, new BooleanExpr(true));
            ProjectArgument ProjectArg3 = new ProjectArgument(Car.GetAttribute("reg_no"), Car, new BooleanExpr(true));

            ProjectStage ProjectOp = new ProjectStage(new ProjectArgument[] { ProjectArg1, ProjectArg2, ProjectArg3 }, RJoinDrives.ComputeVirtualMap());

            MapRule        PersonRule = Map.FindMainRule(Person.Element);
            SelectArgument SelectArg  = new SelectArgument(new EqExpr($"${PersonRule.GetRuleValueForAttribute( Person.GetAttribute( "surname" ) )}", "Smith"));
            SelectStage    SelectOp   = new SelectStage(SelectArg, Map);

            //List<MongoDBOperator> Operations = RJoinDrives.Run().Commands;

            //foreach ( MongoDBOperator Op in Operations )
            //{
            //    Console.WriteLine( Op.GetType().Name );
            //    Console.WriteLine( Op.ToString() );
            //    Console.WriteLine( Op.ToJavaScript() );

            //    if ( Op is LookupOperator )
            //    {
            //        LookupOperator OpAsLookup = (LookupOperator)Op;
            //        foreach ( MongoDBOperator PipelineOp in OpAsLookup.Pipeline )
            //        {
            //            Console.WriteLine( PipelineOp.GetType().Name );
            //            Console.WriteLine( PipelineOp.ToString() );
            //            Console.WriteLine( PipelineOp.ToJavaScript() );
            //        }
            //    }
            //}

            QueryGenerator QueryGen = new QueryGenerator(new FromArgument(Person, Map), new List <AlgebraOperator>()
            {
                SelectOp
            });
            string Query = QueryGen.Run();

            Console.WriteLine($"Query: {Environment.NewLine}{Query}");

            Console.Read();
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Intialize a new FindOperation instance
 /// </summary>
 /// <param name="TargetEntity">Entity to find</param>
 /// <param name="Filters">Conditional parameters</param>
 public FindOperation(Entity TargetEntity, Dictionary <string, object> Filters, ModelMapping ModelMap) : base(ModelMap)
 {
     this.TargetEntity = TargetEntity;
     this.Filters      = Filters;
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Initialize a new FindOperation instance with no conditional filter
 /// </summary>
 /// <param name="TargetEntity">Entity to find</param>
 public FindOperation(Entity TargetEntity, ModelMapping ModelMap) : base(ModelMap)
 {
     this.TargetEntity = TargetEntity;
     Filters           = new Dictionary <string, object>();
 }
        /// <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));
        }
 /// <summary>
 /// Initialize a new instance of CartesianProductOperator
 /// </summary>
 /// <param name="SourceEntity"></param>
 /// <param name="TargetEntity"></param>
 public CartesianProductOperator(QueryableEntity SourceEntity, QueryableEntity TargetEntity, ModelMapping Map)
 {
     this.SourceEntity = SourceEntity;
     this.TargetEntity = TargetEntity;
     this.ModelMap     = Map;
 }
 public void Register(UpgradeStage stage, ModelMapping mapping)
 {
     mappings.Add(stage, 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));
        }
Ejemplo n.º 19
0
 public CrewSchedulerController(IScheduler Repo, ModelMapping ModelMapping)
 {
     _Repo         = Repo;
     _ModelMapping = ModelMapping;
 }
        /// <summary>
        /// Maps entities to collection and return all data (ERModel, MongoSchema and ModelMapping)
        /// </summary>
        /// <returns></returns>
        public static RequiredDataContainer MapEntitiesToCollections()
        {
            // Create schema
            MongoDBCollection UserCol = new MongoDBCollection("User");

            UserCol.AddAttributes("_id", "UserName", "UserEmail");

            MongoDBCollection ProductCol = new MongoDBCollection("Product");

            ProductCol.AddAttributes("_id", "Title", "Description", "CategoryID", "StoreID", "UserID");

            MongoDBCollection CategoryCol = new MongoDBCollection("Category");

            CategoryCol.AddAttributes("_id", "CategoryName");

            MongoDBCollection StoreCol = new MongoDBCollection("Store");

            StoreCol.AddAttributes("_id", "StoreName");

            MongoSchema Schema = new MongoSchema("CMSSchema", new List <MongoDBCollection>()
            {
                UserCol, ProductCol,
                StoreCol, CategoryCol
            });

            // Retrieve ER Model
            ERModel Model = GetERModel();

            // Build mapping
            Entity User = (Entity)Model.FindByName("User");

            MapRule UserRules = new MapRule(User, UserCol);

            UserRules.AddRule("UserID", "_id");
            UserRules.AddRule("UserName", "UserName");
            UserRules.AddRule("UserEmail", "UserEmail");

            Entity Product = (Entity)Model.FindByName("Product");

            MapRule ProductRules = new MapRule(Product, ProductCol);

            ProductRules.AddRule("ProductID", "_id");
            ProductRules.AddRule("Title", "Title");
            ProductRules.AddRule("Description", "Description");

            Entity Category = (Entity)Model.FindByName("Category");

            MapRule CategoryRules = new MapRule(Category, CategoryCol);

            CategoryRules.AddRule("CategoryID", "_id");
            CategoryRules.AddRule("CategoryName", "CategoryName");

            Entity Store = (Entity)Model.FindByName("Store");

            MapRule StoreRules = new MapRule(Store, StoreCol);

            StoreRules.AddRule("StoreID", "_id");
            StoreRules.AddRule("StoreName", "StoreName");

            MapRule UserProductRule = new MapRule(User, ProductCol, false);

            UserProductRule.AddRule("UserID", "UserID");

            MapRule StoreProductRule = new MapRule(Store, ProductCol, false);

            StoreProductRule.AddRule("StoreID", "StoreID");

            MapRule CategoryProductRule = new MapRule(Category, ProductCol, false);

            CategoryProductRule.AddRule("CategoryID", "CategoryID");

            ModelMapping Map = new ModelMapping("CMSMap11", new List <MapRule>()
            {
                UserRules,
                ProductRules, CategoryRules, StoreRules, UserProductRule, StoreProductRule, CategoryProductRule
            });

            return(new RequiredDataContainer(Model, Schema, Map));
        }
Ejemplo n.º 21
0
        public void ExportToTable(Stream file, ExcelTypeEnum typeEnum, out string report, ModelMapping mapping = null, Stream template = null)
        {
            mapping = mapping ?? GetMapping();
            var storage = GetTableStore(this, mapping);

            storage.Store(file, typeEnum, template);
            report = storage.Log.ToString();
        }
        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));
        }
Ejemplo n.º 23
0
        public bool Excute(SuperControl.ServiceModel.ExcuteAction[] actions)
        {
            bool issuccessed            = false;
            List <ExcuteAction> retList = new List <ExcuteAction>();

            lock (s_ServiceLocker)
            {
                foreach (ExcuteAction action in actions)
                {
                    ModelBase model = action.ExcuteObject as ModelBase;
                    if (model == null)
                    {
                        continue;
                    }
                    Exception ex = null;

                    string logstring = string.Empty;
                    int    maxrid    = 0;
                    switch (action.ExcuteType)
                    {
                    case ExcuteType.Delete:
                        ModelMapping mp = new ModelMapping(model.GetType());
                        ModelFactoryCollection.DeleteModel(model, mp, out ex);
                        logstring = "delete";
                        if (ex == null)
                        {
                            ModelAccessManager.CacheManager.Remove(model);
                            retList.Add(action);
                        }
                        break;

                    case ExcuteType.Append:
                    case ExcuteType.Insert:
                        mp = new ModelMapping(model.GetType());
                        //model.Rid = ModelFactoryCollection.GetMaxRid(mp);
                        ModelFactoryCollection.InsertModel(model, mp, out ex);
                        logstring = "insert";
                        maxrid    = ModelFactoryCollection.GetMaxRid(mp);
                        if (ex == null)
                        {
                            ModelAccessManager.CacheManager.Save(model);
                            retList.Add(action);
                        }
                        break;

                    case ExcuteType.Update:
                        mp        = new ModelMapping(model.GetType());
                        logstring = "update";
                        ModelFactoryCollection.UpdateModel(model, mp, out ex);
                        if (ex == null)
                        {
                            ModelAccessManager.CacheManager.Save(model);
                            retList.Add(action);
                        }
                        break;

                    default:
                        break;
                    }
                    try
                    {
                        if (ex != null)
                        {
                            issuccessed = false;
                            m_callback.ErrorNotify("Registration", ex.Message, action.ExcuteType);
                        }
                        else
                        {
                            issuccessed = true;
                        }
                    }
                    catch (Exception e)
                    {
                        m_callback = null;
                        Console.WriteLine(e.Message);
                    }
                }
                if (retList.Count > 0)
                {
                    SendAll(retList.ToArray());
                }
            }
            return(issuccessed);
        }
Ejemplo n.º 24
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));
        }
Ejemplo n.º 25
0
        public void ExportToTable(Stream file, ExcelTypeEnum typeEnum, out string report, ModelMapping mapping = null)
        {
            mapping = mapping ?? ModelMapping.Load(Properties.Resources.COBieUK2012);
            var storage = GetTableStore(this, mapping);

            storage.Store(file, typeEnum);
            report = storage.Log.ToString();
        }
Ejemplo n.º 26
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));
        }
        /// <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
        /// without an embedded document
        /// </summary>
        /// <returns></returns>
        public static RequiredDataContainer OneToOneNotEmbedded()
        {
            // Create ER Stuff
            Entity Person = new Entity("Person");

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

            Entity Car = new Entity("Car");

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

            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");
            PersonCollection.DocumentSchema.AddAttribute("carId");

            MongoDBCollection CarCollection = new MongoDBCollection("Car");

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

            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");
            PersonRule.AddRule("carId", "carId");

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

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

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

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

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

            return(new RequiredDataContainer(Model, Schema, Map));
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Initializes a new RequiredDataContainer instance
 /// </summary>
 /// <param name="EntityRelationshipModel"></param>
 /// <param name="MongoDBSchema"></param>
 /// <param name="ERMongoMapping"></param>
 public RequiredDataContainer(ERModel EntityRelationshipModel, MongoSchema MongoDBSchema, ModelMapping ERMongoMapping)
 {
     this.EntityRelationshipModel = EntityRelationshipModel;
     this.MongoDBSchema           = MongoDBSchema;
     this.ERMongoMapping          = ERMongoMapping;
 }
 private static ModelMapping GetCobieMapping()
 {
     return(ModelMapping.Load(CobieExpress.IO.Properties.Resources.COBieUK2012));
 }