public void MainFunction()
        {
            var frm = new frmModelCreator();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                SchemaItem.Clear();
                _tableCode  = frm.TableCode;
                _columnCode = frm.ColumnCode;
                _dataTypes  = frm.DataTypes;
                _schemaCode = frm.SchemaText;

                _splitTableCode = SplitStringToList(_tableCode, "\r\n");
                _listOfLinks    = GetListOfLinks(_tableCode);

                CreateTypesDictionary();
                var i = 0;
                foreach (var item in _listOfLinks)
                {
                    i++;
                    //ProcessTables(item, SchemaItem.Count+1);
                    ProcessTables(item);
                    //if (i == 4)
                    //    break;
                }
            }
        }
Exemple #2
0
        private static void Flush(Schema list, StringBuilder sb)
        {
            if (sb.Length == 0)
            {
                return;
            }

            var result = new SchemaItem();
            var c      = sb[0];

            if (char.IsDigit(c))
            {
                result.TrimCount = byte.Parse(c.ToString());
                result.Postfix   = sb.ToString().Substring(1);
            }
            else
            if (c == '-')
            {
                result.TrimCount = 0;
                result.Postfix   = null;
            }
            else
            if (c == '*')
            {
                result.TrimCount = 255;
                result.Postfix   = sb.ToString().Substring(1);
            }

            list.items.Add(result);
            sb.Length = 0;
        }
Exemple #3
0
        public SchemaItem GetPropertyTypeSchema(SchemaElementComplex parentComplexProperty, EventAdapterService eventAdapterService)
        {
            Property             lastProperty   = null;
            SchemaElementComplex complexElement = parentComplexProperty;

            for (var en = Properties.EnumerateWithLookahead(); en.HasNext();)
            {
                Property property = en.Next();
                lastProperty = property;

                if (en.HasNext())
                {
                    SchemaItem childSchemaItem = property.GetPropertyTypeSchema(complexElement, eventAdapterService);
                    if (childSchemaItem == null)
                    {
                        // if the property is not valid, return null
                        return(null);
                    }

                    if ((childSchemaItem is SchemaItemAttribute) || (childSchemaItem is SchemaElementSimple))
                    {
                        return(null);
                    }

                    complexElement = (SchemaElementComplex)childSchemaItem;
                }
            }

            return(lastProperty.GetPropertyTypeSchema(complexElement, eventAdapterService));
        }
 protected override void Context()
 {
     _context    = A.Fake <IExecutionContext>();
     _schemaItem = A.Fake <SchemaItem>();
     _schema     = A.Fake <Schema>();
     sut         = new AddSchemaItemToSchemaCommand(_schemaItem, _schema, _context);
 }
        /// <summary>
        /// This method returns the Schemas found in the supplied project type (mostly Schema projects)
        /// </summary>
        /// <param name="btsProject">Project object referring to a project</param>
        /// <param name="schemaList">Reference to a list of schemas</param>
        private static void GetSchemasFromProject(Project btsProject, List <SchemaItem> schemaList)
        {
            const string METHOD_NAME = "GetSchemasFromProject";

            Logging.LogMessage(CLASS_NAME, METHOD_NAME, "Begin");

            // Input validatation
            if (btsProject == null || schemaList == null)
            {
                return;
            }

            // Go over every item and store the Schemas
            foreach (ProjectItem item in btsProject.ProjectItems)
            {
                // Scan only the Schemas, which end with 'xsd'
                if (item.Name.EndsWith(".xsd"))
                {
                    // Get the path, necessary for Unit testing
                    string schemaItemPath = item.Properties.Item("FullPath").Value as string;

                    // Get the namespace, also necessery for Unit testing
                    XmlDocument schemaDoc = new XmlDocument();
                    schemaDoc.Load(schemaItemPath);
                    string schemaTargetNamespace = schemaDoc.DocumentElement.Attributes["targetNamespace"].Value;

                    // Create a new SchemaItem object, the name is without .xsd
                    SchemaItem newSchema = new SchemaItem(schemaTargetNamespace, item.Name.Substring(0, item.Name.Length - 4), item.Name, schemaItemPath);

                    // Add the found Schema to the list of Schemas
                    AddSchemaToList(schemaList, newSchema);
                }
            }
            Logging.LogMessage(CLASS_NAME, METHOD_NAME, "End");
        }
Exemple #6
0
        protected override Task Context()
        {
            _parameterMapper  = A.Fake <ParameterMapper>();
            _schemaItemMapper = A.Fake <SchemaItemMapper>();
            _schemaFactory    = A.Fake <ISchemaFactory>();

            sut = new SchemaMapper(_parameterMapper, _schemaItemMapper, _schemaFactory);

            _schemaItem = new SchemaItem().WithName("Item1");
            _schema     = new Schema
            {
                Description = "Hello",
                Name        = "Tralala"
            };
            _schema.AddSchemaItem(_schemaItem);

            _parameter = DomainHelperForSpecs.ConstantParameterWithValue(3).WithName("Param1");
            //Schema item parameters that have a value IsDefault true should still be saved to snapshot
            _parameter1 = DomainHelperForSpecs.ConstantParameterWithValue(1, isDefault: true).WithName(Constants.Parameters.START_TIME);
            _parameter2 = DomainHelperForSpecs.ConstantParameterWithValue(2, isDefault: true).WithName(CoreConstants.Parameters.NUMBER_OF_REPETITIONS);
            _parameter3 = DomainHelperForSpecs.ConstantParameterWithValue(3, isDefault: true).WithName(CoreConstants.Parameters.TIME_BETWEEN_REPETITIONS);
            _schema.Add(_parameter);
            _schema.Add(_parameter1);
            _schema.Add(_parameter2);
            _schema.Add(_parameter3);

            A.CallTo(() => _parameterMapper.MapToSnapshot(_parameter)).Returns(new Snapshots.Parameter().WithName(_parameter.Name));
            A.CallTo(() => _parameterMapper.MapToSnapshot(_parameter1)).Returns(new Snapshots.Parameter().WithName(_parameter1.Name));
            A.CallTo(() => _parameterMapper.MapToSnapshot(_parameter2)).Returns(new Snapshots.Parameter().WithName(_parameter2.Name));
            A.CallTo(() => _parameterMapper.MapToSnapshot(_parameter3)).Returns(new Snapshots.Parameter().WithName(_parameter3.Name));

            A.CallTo(() => _schemaItemMapper.MapToSnapshot(_schemaItem)).Returns(new Snapshots.SchemaItem().WithName(_schemaItem.Name));

            return(Task.FromResult(true));
        }
        protected override Task Context()
        {
            _parameterMapper  = A.Fake <ParameterMapper>();
            _schemaItemMapper = A.Fake <SchemaItemMapper>();
            _schemaFactory    = A.Fake <ISchemaFactory>();

            sut = new SchemaMapper(_parameterMapper, _schemaItemMapper, _schemaFactory);

            _schemaItem = new SchemaItem().WithName("Item1");
            _schema     = new Schema
            {
                Description = "Hello",
                Name        = "Tralala"
            };
            _schema.AddSchemaItem(_schemaItem);

            _parameter = DomainHelperForSpecs.ConstantParameterWithValue(3).WithName("Param1");
            _schema.Add(_parameter);

            A.CallTo(() => _parameterMapper.MapToSnapshot(_parameter)).Returns(new Snapshots.Parameter().WithName(_parameter.Name));

            A.CallTo(() => _schemaItemMapper.MapToSnapshot(_schemaItem)).Returns(new Snapshots.SchemaItem().WithName(_schemaItem.Name));

            return(Task.FromResult(true));
        }
Exemple #8
0
        private ISchemaItem mapFrom(FlatSchemaItem flatSchemaItem)
        {
            var schemaItem = new SchemaItem();

            schemaItem.Name            = flatSchemaItem.Name;
            schemaItem.ApplicationType = ApplicationTypes.ByName(flatSchemaItem.ApplicationType);

            // temporarily create parent container hierarchy of the
            //schema item container in order to retrieve parameters from the DB
            FlatContainerId flatContainer = flatSchemaItem;
            IContainer      container     = schemaItem;

            while (_flatContainerRepo.ParentContainerFrom(flatContainer.Id) != null)
            {
                var flatParentContainer = _flatContainerRepo.ParentContainerFrom(flatContainer.Id);
                container.ParentContainer = new Container {
                    Name = flatParentContainer.Name
                };

                container     = container.ParentContainer;
                flatContainer = flatParentContainer;
            }

            // now parameters can be added
            _parameterContainerTask.AddSchemaItemParametersTo(schemaItem);

            return(schemaItem);
        }
Exemple #9
0
        protected override void Context()
        {
            _cloneManager = new DummyCloneManager();
            sut           = new Schema();
            //2 hours delay
            sut.Add(DomainHelperForSpecs.ConstantParameterWithValue(120).WithName(Constants.Parameters.START_TIME));
            //6hours between repetitions
            sut.Add(DomainHelperForSpecs.ConstantParameterWithValue(360).WithName(CoreConstants.Parameter.TIME_BETWEEN_REPETITIONS));
            //repeat the schema 4 times
            sut.Add(DomainHelperForSpecs.ConstantParameterWithValue(4).WithName(CoreConstants.Parameter.NUMBER_OF_REPETITIONS));


            var schemaItem1 = new SchemaItem().WithName("SchemaItem1");

            schemaItem1.Add(DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(Constants.Parameters.START_TIME));
            schemaItem1.Add(DomainHelperForSpecs.ConstantParameterWithValue(1).WithName(CoreConstants.Parameter.INPUT_DOSE));
            schemaItem1.ApplicationType = ApplicationTypes.Intravenous;

            var schemaItem2 = new SchemaItem().WithName("SchemaItem2");

            schemaItem2.Add(DomainHelperForSpecs.ConstantParameterWithValue(180).WithName(Constants.Parameters.START_TIME));
            schemaItem2.Add(DomainHelperForSpecs.ConstantParameterWithValue(2).WithName(CoreConstants.Parameter.INPUT_DOSE));
            schemaItem2.ApplicationType = ApplicationTypes.Intravenous;


            sut.AddSchemaItem(schemaItem1);
            sut.AddSchemaItem(schemaItem2);
        }
Exemple #10
0
 protected override void Context()
 {
     base.Context();
     _schemaItem = A.Fake <SchemaItem>();
     _schema     = A.Fake <Schema>();
     A.CallTo(() => _schema.SchemaItems).Returns(new[] { _schemaItem });
 }
Exemple #11
0
 private void IterateOverChildren(SchemaItem item, Dictionary <int, TypeMapping> typeMappings, Type rootSourceType, GeneratedMethod parentMethod)
 {
     foreach (var child in item.children)
     {
         GenerateMappingForItem(typeMappings, child, parentMethod, rootSourceType);
     }
 }
        /// <summary>
        /// Adds columns from the list to the EasyObject WHERE clause
        /// </summary>
        /// <param name="obj">The EasyObject to add the filters to</param>
        /// <param name="filters">A list of filters to add to the query</param>
        public static void AddFilters(EasyObject obj, List <QueryFilter> filters)
        {
            // Apply the query filters
            if (filters != null)
            {
                foreach (QueryFilter filter in filters)
                {
                    //ModuleSchema schema = new ModuleSchema();
                    //SchemaItem si = schema.FindSchemaItem(filter.FieldName);
                    SchemaItem si = null;
                    for (int i = 0; i < obj.SchemaEntries.Count; i++)
                    {
                        SchemaItem si2 = (SchemaItem)obj.SchemaEntries[i];
                        if (si2.FieldName == filter.FieldName)
                        {
                            si = si2;
                            break;
                        }
                    }

                    if (si == null)
                    {
                        throw new ArgumentException(string.Format("Invalid filter column '{0}'.", filter.FieldName));
                    }

                    WhereParameter wp = new WhereParameter(si);
                    wp.Operator = (WhereParameter.Operand)filter.Operand;
                    wp.Value    = filter.Value;
                    obj.Query.AddWhereParameter(wp);
                }
            }
        }
        /// <summary>
        /// This method returns the Schemas found in the project folder named Schemas
        /// First the correct project has to be found and then the correct folder
        /// </summary>
        /// <param name="btsProjectFolder">Project folder</param>
        /// <param name="schemaList">Reference to a list of schemas</param>
        private static void GetSchemasFromProjectFolder(DTE dteObject, List <SchemaItem> schemaList)
        {
            const string METHOD_NAME = "GetSchemasFromProjectFolder";

            Logging.LogMessage(CLASS_NAME, METHOD_NAME, "Begin");

            // Input validatation
            if (dteObject == null || schemaList == null || dteObject.Solution == null)
            {
                return;
            }

            // Go over every project in the DTE object and find the BizTalk typed projects
            // With DTE the counter starts at 1 instead of 0
            int projCounter = dteObject.Solution.Projects.Count;

            for (int i = 1; i <= projCounter; i++)
            {
                if (dteObject.Solution.Projects.Item(i) != null)
                {
                    // Found a BizTalk project?
                    //if (dteObject.Solution.Projects.Item(i).Kind == BusinessComponents.Constants.BizTalkProjectType)
                    //{
                    // Try to find a 'Schemas' folder
                    // Directly calling '....ProjectItems.Item("Schemas")' failed for the multi project solution.
                    // Instead of catching an Argument exception, I decided to add another foreach
                    int projItemCounter = dteObject.Solution.Projects.Item(i).ProjectItems.Count;
                    for (int j = 1; j <= projItemCounter; j++)
                    {
                        if (dteObject.Solution.Projects.Item(i).ProjectItems.Item(j).Name == "Schemas")
                        {
                            // Go over every item and store the Schemas
                            foreach (ProjectItem item in dteObject.Solution.Projects.Item(i).ProjectItems.Item("Schemas").ProjectItems)
                            {
                                // Scan only the Schemas, which end with 'xsd'
                                if (item.Name.EndsWith(".xsd"))
                                {
                                    // Get the path, necessary for Unit testing
                                    string schemaItemPath = item.Properties.Item("FullPath").Value as string;

                                    // Get the namespace, also necessery for Unit testing
                                    XmlDocument schemaDoc = new XmlDocument();
                                    schemaDoc.Load(schemaItemPath);
                                    string schemaTargetNamespace = schemaDoc.DocumentElement.Attributes["targetNamespace"].Value;

                                    // Create a new SchemaItem object, the name is without .xsd
                                    SchemaItem newSchema = new SchemaItem(schemaTargetNamespace, item.Name.Substring(0, item.Name.Length - 4), item.Name, schemaItemPath);

                                    // Add the found Schema to the list of Schemas
                                    AddSchemaToList(schemaList, newSchema);
                                }
                            }
                        }
                    }
                    //}
                }
            }
            Logging.LogMessage(CLASS_NAME, METHOD_NAME, "End");
        }
        /// <summary>
        /// Builds a provider-specific UPDATE query against the <see cref="EasyObject.QuerySource"/>.
        /// <seealso cref="EasyObject.QuerySource"/>
        /// </summary>
        /// <param name="db">A database object from the Enterprise Library</param>
        /// <param name="dbCommand">A wrapper for an Enterprise Library command object</param>
        /// <param name="conjunction">The conjunction to use between multiple <see cref="WhereParameter"/>s</param>
        protected override void BuildUpdateQuery(Database db, DbCommand dbCommand, string conjunction)
        {
            ArgumentValidation.CheckForEmptyString(this.UpdateColumns, "Update Columns");
            ArgumentValidation.CheckForNullReference(this.ParameterValues, "Update Values");

            StringBuilder query           = new StringBuilder();
            StringBuilder computedColumns = new StringBuilder();
            StringBuilder keyColumns      = new StringBuilder();

            query.Append("BEGIN ");
            query.AppendFormat("UPDATE {0}", this.TableNameWithSchema);
            query.Append(" SET ");
            query.Append(this.UpdateColumns);

            foreach (ValueParameter param in this.ParameterValues)
            {
                db.AddInParameter(dbCommand, ParameterToken + param.SchemaItem.FieldName, param.SchemaItem.DBType, param.Value);
            }

            BuildWhereClause(db, dbCommand, conjunction, query);
            query.Append("; ");

            // Check for concurrency violation
            query.Append("IF SQL%ROWCOUNT = 0 THEN ");
            query.Append("Raise_application_error(-20101, 'NO RECORDS WERE UPDATED'); ");
            query.Append("END IF; ");

            foreach (object entry in this._entity.SchemaEntries)
            {
                SchemaItem item = (SchemaItem)entry;

                if (item.IsComputed)
                {
                    computedColumns.AppendFormat("{0}{1} = {2}, ", ParameterToken, item.FieldName, string.Format(this.FieldFormat, item.FieldName));
                }
                else if (item.IsInPrimaryKey)
                {
                    keyColumns.AppendFormat("{0} = {1}{2} AND ", string.Format(this.FieldFormat, item.FieldName), ParameterToken, item.FieldName);
                }
                else if (item.IsRowID)
                {
                    query.AppendFormat("{0}{1} := {0}{1} + 1; ", this.ParameterToken, item.FieldName);
                }
            }

            if (computedColumns.Length > 0)
            {
                // Get rid of trailing separators
                computedColumns.Length -= 2;
                keyColumns.Length      -= 5;

                query.AppendFormat(" SELECT {0} FROM {1}", computedColumns.ToString(), this.TableNameWithSchema);
                query.AppendFormat(" WHERE {0};", keyColumns.ToString());
            }

            query.Append("END;");

            dbCommand.CommandText = query.ToString();
        }
            public ISchemaItem Create()
            {
                var schemaItem = new SchemaItem().WithName(Guid.NewGuid().ToString());

                schemaItem.Add(DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(Constants.Parameters.START_TIME));
                schemaItem.Add(DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameter.INPUT_DOSE));
                return(schemaItem);
            }
        public SchemaItemDTO MapFrom(SchemaItem schemaItem)
        {
            var schemaItemDTO = new SchemaItemDTO(schemaItem);

            schemaItemDTO.DoseParameter      = _parameterDTOMapper.MapFrom(schemaItem.Dose, schemaItemDTO, x => x.Dose, x => x.DoseParameter);
            schemaItemDTO.StartTimeParameter = _parameterDTOMapper.MapFrom(schemaItem.StartTime, schemaItemDTO, x => x.StartTime, x => x.StartTimeParameter);
            return(schemaItemDTO);
        }
Exemple #17
0
        /// <summary>
        /// Reconstructs table name
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        private string GetTableName(string text)
        {
            var tableName = text.ToLower().Singularize();
            var table     = SchemaItem
                            .Select(x => x.TableName).FirstOrDefault(x => x.ToLower() == tableName);

            return(table);
        }
Exemple #18
0
        private void MainFunction()
        {
            _table        = Singularize(Input, PreserveTableName());
            _tableContext = "_context." + Input;

            _sortColumns = GetSortColumns(_table);
            var relatedTables = SchemaItem
                                .Where(e => (e.RelatedTable != null &&
                                             (e.TableName == Singularize(_table, PreserveTableName())) &&
                                             (e.RelatedTable != _table) &&
                                             (e.IsPrimaryKey != e.IsForeignKey)));

            _classname = "IndexModel";

            CanSort          = _sortColumns.Any();
            HasRelatedTables = relatedTables.Any();
            tableIq          = _table.ToLower() + "Iq";

            AppendText();
            BuildSnippet(null);

            //BuildSnippet("namespace " + GetDefaultNameSpace() + ".Pages." + _table.Pluralize(), 0);
            //BuildSnippet("{", 0);
            var indent = 4;

            //BuildSnippet(_public + "class " + _classname + " : PageModel", indent);
            //BuildSnippet("{", indent);
            indent += 4;
            BuildSnippet("private readonly " + GetDbContext() + " _context;", indent);
            BuildSnippet("");

            BuildSnippet("[TempData]");
            BuildSnippet("public string Message { get; set; }");
            BuildSnippet("");

            BuildSnippet(_public + _classname + "(" + GetDbContext() + " context) => _context = context;", indent);
            BuildSnippet("");
            BuildSnippet(_public + "string CurrentFilter" + _getSet, indent);
            BuildSnippet(_public + "string CurrentSort" + _getSet, indent);
            if (CanSort)
            {
                foreach (var column in _sortColumns)
                {
                    BuildSnippet(_public + "string " + GetSortName(column.ColumnName) + _getSet, indent);
                }

                //BuildSnippet("IQueryable<"+_table+"> studentIQ = from s in _context.Student")
            }

            BuildSnippet(_public + "PaginatedList<" + _table + "> " + _table + _getSet, indent);
            BuildSnippet("");
            OnGetAsyncMethod(indent, relatedTables);
            //BuildSnippet("}", indent - 4);

            //BuildSnippet("}", 0);

            AppendText(BuildSnippet(), "");
        }
Exemple #19
0
        public IPKSimCommand RemoveSchemaItemFrom(SchemaItem schemaItemToDelete, Schema schema)
        {
            if (schema.SchemaItems.Count() <= 1)
            {
                throw new CannotDeleteSchemaItemException();
            }

            return(new RemoveSchemaItemFromSchemaCommand(schemaItemToDelete, schema, _executionContext).Run(_executionContext));
        }
 protected override void Context()
 {
     base.Context();
     _container         = new Container();
     _schemaItemToClone = A.Fake <SchemaItem>();
     _clone             = A.Fake <SchemaItem>();
     A.CallTo(() => _cloner.Clone(_schemaItemToClone)).Returns(_clone);
     A.CallTo(_containerTask).WithReturnType <string>().Returns("NEW NAME");
 }
        protected override void Context()
        {
            base.Context();
            _schemaItem = new SchemaItem {
                ApplicationType = ApplicationTypes.UserDefined, TargetOrgan = "Liv", TargetCompartment = "Cell"
            };

            _schemaItemDTO = new SchemaItemDTO(_schemaItem);
        }
        /// <summary>
        /// This method scans an assembly for BizTalk Schemas and adds them to the supplied Schema List
        /// </summary>
        /// <param name="assemblyPath"></param>
        /// <param name="schemaList"></param>
        public static void GetSchemasFromAssembly(string assemblyPath, List <SchemaItem> schemaList)
        {
            const string METHOD_NAME = "GetSchemasFromAssembly";

            Logging.LogMessage(CLASS_NAME, METHOD_NAME, "Begin");

            if (string.IsNullOrEmpty(assemblyPath))
            {
                return;
            }

            try
            {
                // Load the assembly from the path specified
                Assembly schemaAssembly = Assembly.LoadFrom(assemblyPath);

                // See if it is a BizTalk Assembly
                if (IsBizTalkAssembly(schemaAssembly))
                {
                    // It is a BizTalk Assembly, is it a Schema assembly?
                    foreach (Type type in schemaAssembly.GetTypes())
                    {
                        // Check if the current assembly is of a Schema type and not a property schema
                        if (IsBizTalkSchemaType(type) && !IsBizTalkPropertySchema(type))
                        {
                            // Valid Schema found. Find out if it contains a multi rooted schema
                            object[] assemblyAttributes = type.GetCustomAttributes(typeof(SchemaRootsAttribute), false);
                            if (assemblyAttributes != null && assemblyAttributes.Length > 0)
                            {
                                // Schema found, add the rootnode of the schema
                                SchemaBase sba = Activator.CreateInstance(type) as SchemaBase;

                                // Iterate over the root nodes and add them to the list
                                foreach (string rootNode in sba.RootNodes)
                                {
                                    Logging.LogMessage(CLASS_NAME, METHOD_NAME, string.Format("Schema '{0}' found with rootnode '{1}', add it to the list", type.FullName, rootNode));

                                    // Create a new SchemaItem object, the name is including the rootnode
                                    // The path can be empty, it is not relevant for schema assemblies
                                    SchemaItem newSchema = new SchemaItem(type.Namespace, type.Name, rootNode, null);

                                    // Add the found Schema to the list of Schemas
                                    AddSchemaToList(schemaList, newSchema);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.LogMessage(CLASS_NAME, METHOD_NAME, ex.Message);
            }

            Logging.LogMessage(CLASS_NAME, METHOD_NAME, "End");
        }
        private void HasPrimaryKey(string table, bool createkey = false)
        {
            var primarykey = table + Constants.KeySuffix;
            var result     = SchemaItem.First(t => (t.TableName == table && t.ColumnName == primarykey && t.IsPrimaryKey == true));

            if (result == null && createkey)
            {
                SchemaItemUpdater(CreatePrimaryKeyEntry(table));
            }
        }
        void SetItemName()
        {
            if (SchemaItemId != -1)
            {
                SchemaItem item = new SchemaItem();
                item.Get(SchemaItemId);

                // show item description
                TextBoxItemName.Text = item[SchemaItem.ItemDescription].ToString();
            }
        }
Exemple #25
0
        protected override void Context()
        {
            _simulation = new IndividualSimulation
            {
                Properties         = new SimulationProperties(),
                SimulationSettings = new SimulationSettings(),
                ModelConfiguration = new ModelConfiguration()
            };
            _individual        = new Individual().WithName("MyIndividual");
            _speciesPopulation = new SpeciesPopulation();

            _individual.OriginData = new OriginData {
                SpeciesPopulation = _speciesPopulation
            };
            _compound    = A.Fake <Compound>().WithName("MyCompound");
            _protocol    = A.Fake <SimpleProtocol>().WithName("MyProtocol");
            _formulation = A.Fake <Formulation>().WithName("Formulation");

            _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("Individual", PKSimBuildingBlockType.Individual)
            {
                BuildingBlock = _individual
            });
            _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("Compound", PKSimBuildingBlockType.Compound)
            {
                BuildingBlock = _compound
            });
            _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("Protocol", PKSimBuildingBlockType.Protocol)
            {
                BuildingBlock = _protocol
            });
            _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("Formulation", PKSimBuildingBlockType.Formulation)
            {
                BuildingBlock = _formulation
            });

            _protocolToProtocolSchemaItemMapper = A.Fake <IProtocolToSchemaItemsMapper>();
            sut = new SimulationConfigurationValidator(_protocolToProtocolSchemaItemMapper);

            _speciesPopulation.IsHeightDependent = false;
            _schemaItem = A.Fake <SchemaItem>();
            _doseUnit   = A.Fake <Unit>();
            _schemaItem.Dose.DisplayUnit = _doseUnit;

            _protocolProperties = new ProtocolProperties();
            _formulationMapping = new FormulationMapping {
                FormulationKey = "F1", Formulation = _formulation
            };
            _simulation.Properties.AddCompoundProperties(new CompoundProperties
            {
                Compound           = _compound,
                ProtocolProperties = _protocolProperties
            });
            A.CallTo(() => _protocolToProtocolSchemaItemMapper.MapFrom(_protocol)).Returns(new [] { _schemaItem });
        }
Exemple #26
0
        public string[] apply(SchemaItem prefab)
        {
            if (prefab.craft_type != null)
            {
                craft_type = prefab.craft_type;
            }

            class_flags |= prefab.class_flags;

            return(prefab.prefabs);
        }
Exemple #27
0
        /// <summary>
        /// Builds a provider-specific UPDATE query against the <see cref="EasyObject.TableName"/>.
        /// <seealso cref="EasyObject.TableName"/>
        /// </summary>
        /// <param name="dbCommandWrapper">An wrapper for an Enterprise Library command object</param>
        /// <param name="conjunction">The conjunction to use between multiple <see cref="WhereParameter"/>s</param>
        protected override void BuildUpdateQuery(DBCommandWrapper dbCommandWrapper, string conjunction)
        {
            ArgumentValidation.CheckForEmptyString(this.UpdateColumns, "Update Columns");
            ArgumentValidation.CheckForNullReference(this.ParameterValues, "Update Values");

            StringBuilder query           = new StringBuilder("UPDATE ");
            StringBuilder computedColumns = new StringBuilder();
            StringBuilder keyColumns      = new StringBuilder();

            query.AppendFormat(FieldFormat, this._entity.TableName);
            query.Append(" SET ");
            query.Append(this.UpdateColumns);

            foreach (ValueParameter param in this.ParameterValues)
            {
                dbCommandWrapper.AddInParameter(ParameterToken + param.SchemaItem.FieldName, param.SchemaItem.DBType, param.Value);
            }

            BuildWhereClause(dbCommandWrapper, conjunction, query);

            foreach (object entry in this._entity.SchemaEntries)
            {
                SchemaItem item = (SchemaItem)entry;

                if (item.IsComputed)
                {
                    computedColumns.AppendFormat("{0}{1} = {2}, ", ParameterToken, item.FieldName, string.Format(this.FieldFormat, item.FieldName));
                }
                else if (item.IsInPrimaryKey)
                {
                    keyColumns.AppendFormat("{0} = {1}{2} AND ", string.Format(this.FieldFormat, item.FieldName), ParameterToken, item.FieldName);
                }
            }

            if (computedColumns.Length > 0)
            {
                // Get rid of trailing separators
                computedColumns.Length -= 2;
                keyColumns.Length      -= 5;

                query.AppendFormat(" SELECT {0} FROM ", computedColumns.ToString());

                if (this._entity.SchemaTableView.Length > 0)
                {
                    query.AppendFormat(FieldFormat, this._entity.SchemaTableView);
                    query.Append(this.SchemaSeparator);
                }

                query.AppendFormat(FieldFormat, this._entity.TableName);
                query.AppendFormat(" WHERE {1};", keyColumns.ToString());
            }

            dbCommandWrapper.Command.CommandText = query.ToString();
        }
 protected override void Context()
 {
     base.Context();
     _schemaItem = A.Fake <SchemaItem>();
     _schema     = A.Fake <Schema>();
     _schemaDTO  = A.Fake <SchemaDTO>();
     A.CallTo(() => _schemaDTO.Schema).Returns(_schema);
     A.CallTo(() => _advancedProtocol.Contains(_schema)).Returns(false);
     _allSchemas.Add(_schema);
     A.CallTo(() => _schemaDTOMapper.MapFrom(_schema)).Returns(_schemaDTO);
     sut.EditProtocol(_advancedProtocol);
 }
        private void HasIndex(string table)
        {
            var indexColumns = SchemaItem
                               .Where(x => x.TableName == table && x.IndexName != null)
                               .Where(p => p.IsPrimaryKey == false)
                               .ToList();

            foreach (var column in indexColumns)
            {
                BuildSnippet("entity.HasIndex(e => e." + column.ColumnName + ")" +
                             ".HasName(" + column.IndexName.AddQuotes() + ");", 16);
            }
        }
        private new int GetPrimaryKey(string table)
        {
            var row = SchemaItem.FirstOrDefault(t => (t.TableName == table && t.ColumnName == table + Constants.KeySuffix && t.IsPrimaryKey));

            if (row != null)
            {
                return(row.SchemaItemId);
            }
            else
            {
                return(-1);
            }
        }