public void Store_Model_With_Name()
                {
                    PreferenceDataStructureEntity entity = null;

                    Gds = new PreferenceDataStructure();

                    // xml of example
                    String xml = Path.GetFullPath("./xml-descriptive/UseCase-ReadXML-Model3d.xml");

                    // class to read the descriptive xml
                    ReadDescriptiveXML descriptive = new(xml);

                    // get the information about the model
                    XmlNodeList xmlNodeList = descriptive.XmlDoc.DocumentElement.GetElementsByTagName("dsc:Model");

                    Xunit.Assert.NotNull(xmlNodeList);

                    // time start
                    Stopwatch stopWatch = new();

                    stopWatch.Start();

                    // for each model
                    foreach (XmlNode node in xmlNodeList)
                    {
                        // create the model only with its name
                        entity = Gds.Create(node.Attributes["name"].Value, "model");
                        Assert.Equal(node.Attributes["name"].Value, Gds.GetKeyEntity());
                    }

                    stopWatch.Stop();
                    Console.WriteLine("RunTime Query: " + stopWatch.Elapsed.TotalMilliseconds);
                    entity.Print();
                }
                public void Store_Model_Attributes()
                {
                    Gds = new PreferenceDataStructure();

                    // xml of example
                    String xml = Path.GetFullPath("./xml-descriptive/UseCase-ReadXML-Model3d.xml");

                    // class to read the descriptive xml
                    ReadDescriptiveXML descriptive = new(xml);

                    // get the information about the model
                    XmlNodeList xmlNodeList = descriptive.XmlDoc.DocumentElement.GetElementsByTagName("dsc:Model");

                    Assert.NotNull(xmlNodeList);

                    // time start
                    Stopwatch stopWatch = new();

                    stopWatch.Start();

                    // create the model with its attributes
                    Create_Model_And_Attributes(xmlNodeList);

                    stopWatch.Stop();

                    Console.WriteLine("RunTime Query: " + stopWatch.Elapsed.TotalMilliseconds);
                    Gds.Print();
                }
        private PreferenceDataStructure ReadData()
        {
            string xmlDescriptive = Path;

            // read the xml
            XmlDocument XmlDoc = new XmlDocument();

            XmlDoc.LoadXml(File.ReadAllText(xmlDescriptive));

            PreferenceDataStructureEntity entity = null;

            PreferenceDataStructure Data = new PreferenceDataStructure();

            // Get the information about the model
            XmlNodeList xmlNodeList = XmlDoc.DocumentElement.GetElementsByTagName(KEY_XML_MODEL);

            // Create the model with its attributes
            Create_Model_And_Attributes(xmlNodeList, ref entity, ref Data);

            // Create the definitions
            Create_Definitions(XmlDoc, TypeDefinitions.Materials, KEY_XML_MATERIAL, ref entity);

            Create_Atoms(XmlDoc, KEY_XML_PRICEDOCUMENTATION, KEY_XML_ITEM, ref entity, KEY_XML_ENDID_GROUP);

            return(Data);
        }
예제 #4
0
        /**
         * Build the essential elements to be used later during the execution of the printout process
         */
        public void Build()
        {
            // 1: Generate the template.

            // With the template we know all the elements of the model
            Template = BuildTemplate();


            /*
             * 2: Solicitamos el modelo
             *    - Lo suyo es indicarle que elementos del modelo necesitamos. Esta información estaría en las Regions del Template.
             *      Donde se especifica que tipos de elementos se necesitan del modelo. De una manera abstracta.
             *
             *    - Por simplicidad, y hasta que Carlos lo implemente solicito todo el modelo.
             *
             * NOTA 1:
             * Este punto 2. y el 3. se pueden pasar al punto 4. Es decir, solicitar los identificadores justo cuando se vayan a usar.
             * Opto por enviar todo el modelo y con el template filtrar sobre el modelo.
             * Otra opción puede ser enviar como parámetro al PreferenceIntelliTextExecutor el IObjectDataProvider
             *
             * NOTA 2:
             * Aunque es necesario tener la DataStructure porque cualquier otro sistema puede usar esta estructura.
             * Debemos pensar en que sea el DataProvider quien la retorne y no generarla en el modulo de IntelliText.
             */
            // string JSON = ...;
            Model = Data.GetObjectData(); // Data.GetObjectData(Template.getIdentifiers());


            // 3. Generate the GDS structure.
            // Model = new PreferenceGDS(JSON);
        }
예제 #5
0
        /**
         * Get the description of the template
         *
         * @param preference's entity that contain the model
         * @param target's audience for the description
         *
         * @return the description (text) of the model
         */
        public IDescriptionModel GetDescriptions(PreferenceDataStructure model, TextSettings settings)
        {
            // We need to keep the attributes OrderVertical and OrderHorizontal in the interface IDescription. To sort the elements

            // if there is not language at the beginning
            if (settings.Culture == null)
            {
                // default language
                string language = CommonVariables.KEY_DEFAULT_LANGUAGE;

                // identify the language with the target audience, if there is one.
                IDictionary <string, object> audience = FindTargetAudience(settings.Audience);
                if (audience != null && audience.ContainsKey(CommonVariables.KEY_JSON_TEMPLATES_LANGUAGE_TEXT))
                {
                    language = (string)audience[CommonVariables.KEY_JSON_TEMPLATES_LANGUAGE_TEXT];
                }

                settings.Culture = new System.Globalization.CultureInfo(language, false);
            }

            List <IDescriptionModel> ListDescriptionsByRegion = new();

            // for each region
            foreach (ITemplate region in Regions)
            {
                // add the list description of the region
                ListDescriptionsByRegion.Add(region.GetDescriptions(model, settings));
            }

            // store the atributes and the list of text generated of the sequence
            IDescriptionModel descriptions = new DescriptionModelSequence(Attributes, ListDescriptionsByRegion);

            // return description model of the sequence
            return(descriptions);
        }
 /**
  * Constructor of the class
  *
  * @param model  Entity that represents a preference Scene. It can be a model, window or any piece. It is our data structure
  * @param template Template to filter the information
  * @param render printout text to a given format
  */
 public PreferenceIntelliTextExecutor(PreferenceDataStructure model, ITemplate template, IPreferenceRender render, TextSettings settings)
 {
     Model    = model;
     Template = template;
     Render   = render;
     Settings = settings;
 }
예제 #7
0
                private PreferenceDataStructureEntity Create_Exahustive_ModelGDS()
                {
                    Atom atom;

                    Gds = new PreferenceDataStructure();
                    PreferenceDataStructureEntity entity = Gds.Create("M01", "model");

                    Random rnd   = new(3173);
                    int    total = 3;

                    // create the list of materials
                    for (int i = 0; i < total; ++i)
                    {
                        atom = entity.AddAtomDefinition("KEY_MATERIAL_" + i, TypeDefinitions.Materials);
                        atom.AddAttribute("Description", "Description of the material");
                        atom.AddAttribute("Order", rnd.Next(total));
                    }


                    total = 2000;

                    // create the list of glasses
                    for (int i = 0; i < total; ++i)
                    {
                        atom = entity.AddAtomDefinition("KEY_GLASS_" + i, TypeDefinitions.Glasses);
                        atom.AddAttribute("Description", "Description of the glass");
                        atom.AddAttribute("Order", rnd.Next(total));

                        bool assignMaterial = (rnd.Next(0, 2) == 1);

                        if (assignMaterial)
                        {
                            atom.AddAttribute("Material", "KEY_MATERIAL_" + rnd.Next(entity.Definitions[TypeDefinitions.Materials].Count));
                        }

                        entity.AddChildren(atom);
                    }

                    // logic relationships
                    entity.AddChildren("KEY_GLASS_0", "KEY_GLASS_5");
                    entity.AddChildren("KEY_GLASS_0", "KEY_GLASS_10");
                    entity.AddChildren("KEY_GLASS_0", "KEY_GLASS_12");

                    entity.AddChildren("KEY_GLASS_5", "KEY_GLASS_16");
                    entity.AddChildren("KEY_GLASS_16", "KEY_GLASS_17");
                    entity.AddChildren("KEY_GLASS_17", "KEY_GLASS_19");

                    entity.AddCopyOf("KEY_GLASS_2", "KEY_GLASS_0");

                    return(entity);
                }
예제 #8
0
                private PreferenceDataStructureEntity Create_Exahustive_ModelGDS()
                {
                    Atom atom;

                    Gds = new PreferenceDataStructure();
                    PreferenceDataStructureEntity entity = Gds.Create("M01", "model");


                    Random rnd   = new(3173);
                    int    total = 3;

                    // create the list of materials
                    for (int i = 0; i < total; ++i)
                    {
                        atom = entity.AddAtomDefinition("KEY_MATERIAL_" + i, TypeDefinitions.Materials);
                        atom.AddAttribute("Description", "Description of the material");
                        atom.AddAttribute("Order", rnd.Next(total));
                    }

                    atom = entity.AddAtomDefinition("KEY_PROFILE_0", TypeDefinitions.Profiles);
                    atom.AddAttribute("Description", "Description of the profile");
                    atom.AddAttribute("Order", rnd.Next(total));
                    atom.AddAttribute("Material", "KEY_MATERIAL_0");
                    atom.AddAttribute("Material_interior", "KEY_MATERIAL_1");
                    atom.AddAttribute("Material_exterior", "KEY_MATERIAL_2");
                    atom.AddAttribute("Longitud", 1000);
                    atom.AddAttribute("Others1", "Any other value");
                    atom.AddAttribute("Others2", "Any other value");
                    atom.AddAttribute("Others3", "Any other value");
                    atom.AddAttribute("Others4", "Any other value");
                    atom.AddAttribute("Others5", "Any other value");
                    entity.AddChildren(atom);


                    total = 10000;

                    // create the two more profiles
                    for (int i = 1; i < total; ++i)
                    {
                        atom = entity.CreateAtomAsCopyOf("KEY_PROFILE_" + i, "KEY_PROFILE_0");

                        atom.AddAttribute("Order", 51); //  rnd.Next(total));
                        atom.AddAttribute("Longitud", 200);

                        entity.AddChildren(atom);
                    }

                    return(entity);
                }
예제 #9
0
                private PreferenceDataStructureEntity Create_Simple_ModelGDS()
                {
                    Atom atom;

                    Gds = new PreferenceDataStructure();
                    PreferenceDataStructureEntity entity = Gds.Create("M01", "model");

                    Random rnd   = new(3173);
                    int    total = 3;

                    // create the list of materials
                    for (int i = 0; i < total; ++i)
                    {
                        atom = entity.AddAtomDefinition("KEY_MATERIAL_" + i, TypeDefinitions.Materials);
                        atom.AddAttribute("Description", "Description of the material");
                        atom.AddAttribute("Order", rnd.Next(total));
                    }



                    total = 4;

                    // create the list of glasses
                    for (int i = 0; i < total; ++i)
                    {
                        atom = entity.AddAtomDefinition("KEY_GLASS_" + i, TypeDefinitions.Glasses);
                        atom.AddAttribute("Description", "Description of the glass");
                        atom.AddAttribute("Order", rnd.Next(total));

                        bool assignMaterial = (rnd.Next(0, 2) == 1);

                        if (assignMaterial)
                        {
                            atom.AddAttribute("Material", "KEY_MATERIAL_" + rnd.Next(entity.Definitions[TypeDefinitions.Materials].Count));
                        }
                    }

                    // create the children of the model. Assume two glass
                    entity.AddChildren("KEY_GLASS_0", "KEY_GLASS_1");
                    entity.AddChildren("KEY_GLASS_0", "KEY_GLASS_3");

                    entity.AddChildren("KEY_GLASS_2");
                    entity.AddChildren("KEY_GLASS_0");

                    return(entity);
                }
        private void Create_Model_And_Attributes(XmlNodeList xmlNodeList, ref PreferenceDataStructureEntity entity, ref PreferenceDataStructure Gds)
        {
            // for each model
            foreach (XmlNode node in xmlNodeList)
            {
                // create the model with its name and the type of model
                entity = Gds.Create(node.Attributes[KEY_XML_NAME].Value, node.Attributes[KEY_XML_PREFSUITEITEM].Value);

                // for each attribute
                foreach (XmlAttribute atr in node.Attributes)
                {
                    // get the name of the attribute and its value
                    string key = atr.Name;

                    // if the attribute is the name and prefSuiteItem we skip them since they were previously stored
                    if (key.Equals(KEY_XML_NAME) || key.Equals(KEY_XML_PREFSUITEITEM))
                    {
                        continue;
                    }

                    // store the attribute
                    entity.AddAttribute(key, atr.Value);
                }
            }
        }
        public PreferenceFileDataProvider(string path)
        {
            Path = path;

            Data = ReadData();
        }