/// <summary> /// Returns XML string with all occurences of Active element "Attribute". /// </summary> /// <param name="index">index of data source in FEplugin data sources table</param> /// <returns>XML string</returns> public static string getList(int index) { string resultString = ""; // result XML string // loading DTD to resultString try { resultString = XMLHelper.loadDTD(); } catch (Exception e) { #if (LADENI) MessageBox.Show("error while loading DTD: " + e.Message); #endif return(resultString); } // root element resultString += "<active_list>"; string ErrStr = ""; // error report #region A) searching all boxes - Attributes (DataMiningCommon.Attributes.Attribute) IBoxModule[] AttrBoxes = BoxesHelper.ListBoxesWithID(CFEsourcesTab.Sources[index] as CFEsource, "DataMiningCommon.Attributes.Attribute"); // processing of each box - searching all Attributes foreach (IBoxModule ABox in AttrBoxes) { try { Rec_attribute rAttr = new Rec_attribute(); // setting ID attribute rAttr.id = "Attr" + ABox.ProjectIdentifier.ToString(); // searching name of literal rAttr.attr_name = ABox.GetPropertyString("NameInLiterals"); // searching data source name (database) IBoxModule[] db_names = BoxesHelper.ListAncestBoxesWithID(ABox, "DataMiningCommon.Database"); if (db_names.GetLength(0) != 1) // searched more than one data source or neither one { throw new System.Exception("found " + db_names.GetLength(0).ToString() + " databases"); } rAttr.db_name = (db_names[0].GetPropertyOther("DatabaseName") as StringT).stringValue; // searching data matrix name IBoxModule[] matrix_names = BoxesHelper.ListAncestBoxesWithID(ABox, "DataMiningCommon.DataMatrix"); if (matrix_names.GetLength(0) != 1) // searched more than one data source or neither one { throw new System.Exception("found " + matrix_names.GetLength(0).ToString() + " data matrixes"); } rAttr.matrix_name = (matrix_names[0].GetPropertyOther("Name") as StringT).stringValue; // searching name of source column or manner of derivation IBoxModule[] col_names = BoxesHelper.ListDirectAncestBoxesWithID(ABox, "DataMiningCommon.Column"); if (col_names.GetLength(0) != 1 && col_names.GetLength(0) != 0) // incorrect number of source columns found { throw new System.Exception("found " + col_names.GetLength(0).ToString() + " zdrojovych sloupcu"); } if (col_names.GetLength(0) == 1) { rAttr.creation = col_names[0].GetPropertyString("Name"); } IBoxModule[] dercol_names = BoxesHelper.ListDirectAncestBoxesWithID(ABox, "DataMiningCommon.DerivedColumn"); if (dercol_names.GetLength(0) != 1 && dercol_names.GetLength(0) != 0) // incorrect number of source columns found { throw new System.Exception("found " + dercol_names.GetLength(0).ToString() + " zdrojovych odvozenych sloupcu"); } if (dercol_names.GetLength(0) == 1) { rAttr.creation = dercol_names[0].GetPropertyString("Formula"); } // searching number of categories rAttr.ctgr_count = ABox.GetPropertyLong("CountOfCategories"); // searching the category "missisng value" string nul_cat = ABox.GetPropertyString("IncludeNullCategory"); List <Rec_missing_value> MisVal_list = new List <Rec_missing_value>(); // array of records with missing values if (!String.IsNullOrEmpty(nul_cat)) { Rec_missing_value MisVal = new Rec_missing_value(); MisVal.name = nul_cat; MisVal_list.Add(MisVal); } // searching category names and their frequencies List <Rec_ctgr> cat_list = new List <Rec_ctgr>(); // list of categories CategoriesStruct cat_str = (ABox.GetPropertyOther("Categories") as CategoriesT).categoriesValue; // long intervals foreach (string key in cat_str.longIntervals.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (if possible) //KODY 27.11.2006 - not possible to gain attribute frequencies directly from Ferda. Can be resolved via creating CF task new_li.name = key; cat_list.Add(new_li); } // float intervals foreach (string key in cat_str.floatIntervals.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (if possible) new_li.name = key; cat_list.Add(new_li); } // date time intervals foreach (string key in cat_str.dateTimeIntervals.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (if possible) new_li.name = key; cat_list.Add(new_li); } // enums foreach (string key in cat_str.enums.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (if possible) new_li.name = key; cat_list.Add(new_li); } #region Generating of one attribute to XML string string oneAttrString = ""; // generating hypotheses to XML if (MisVal_list.Count == 0 && cat_list.Count == 0) { oneAttrString += rAttr.ToXML(); } else { oneAttrString += rAttr.ToXML(cat_list, MisVal_list); } resultString += oneAttrString; #endregion } catch (System.Exception e) { ErrStr += "Box ProjectIdentifier=" + ABox.ProjectIdentifier.ToString() + ": " + e.Message + "\n"; } } #endregion // root element resultString += "</active_list>"; #if (LADENI) // generating of error message: if (!String.IsNullOrEmpty(ErrStr)) { MessageBox.Show("Pri nacitani category doslo k chybam:\n" + ErrStr, "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error); } // Kody - storing output to file "XMLAttrExample.xml" in directory XMLHelper.saveXMLexample(resultString, "../XML/XMLAttrExample.xml"); #endif return(resultString); } // TODO: Attributes v krabickach EachValueOneCategory, Equidistant, Equifrequency???
// ==================== Atribut ================================ public static string fFEAttribute(int index) { string resultString = ""; // vysledny XML string // nacteni DTD do resultStringu try { resultString = XMLHelper.loadDTD(); } catch (Exception e) { MessageBox.Show("Chyba pri nacitani DTD: " + e.Message); return resultString; } // korenovy element resultString += "<active_list>"; string ErrStr = ""; // zaznam o chybach #region A) nalezeni vsech krabicek Atributu (DataMiningCommon.Attributes.Attribute) IBoxModule[] AttrBoxes = BoxesHelper.ListBoxesWithID(CFEsourcesTab.Sources[index] as CFEsource, "DataMiningCommon.Attributes.Attribute"); // zpracovani kazde krabicky - ziskani z ni vsechny Atributy foreach (IBoxModule ABox in AttrBoxes) { Rec_attribute rAttr = new Rec_attribute(); // nastaveni ID atributu rAttr.id = "Attr" + ABox.ProjectIdentifier.ToString(); // zjisteni jmena literalu rAttr.attr_name = ABox.GetPropertyString("NameInLiterals"); // nalezeni jmena datoveho zdroje (databaze) IBoxModule[] db_names = BoxesHelper.ListAncestBoxesWithID(ABox, "DataMiningCommon.Database"); if (db_names.GetLength(0) != 1) // byl nalezen pocet datovych zdroju ruzny od jedne throw new System.Exception("bylo nalezeno " + db_names.GetLength(0).ToString() + " databazi"); rAttr.db_name = (db_names[0].GetPropertyOther("DatabaseName") as StringT).stringValue; // nalezeni jmena datove matice IBoxModule[] matrix_names = BoxesHelper.ListAncestBoxesWithID(ABox, "DataMiningCommon.DataMatrix"); if (matrix_names.GetLength(0) != 1) // byl nalezen pocet datovych matic ruzny od jedne throw new System.Exception("bylo nalezeno " + matrix_names.GetLength(0).ToString() + " datovych matic"); rAttr.matrix_name = (matrix_names[0].GetPropertyOther("Name") as StringT).stringValue; // nalezeni jmena zdrojoveho sloupce nebo zpusobu odvozeni IBoxModule[] col_names = BoxesHelper.ListDirectAncestBoxesWithID(ABox, "DataMiningCommon.Column"); if (col_names.GetLength(0) != 1 && col_names.GetLength(0) != 0) // byl nalezen chybny pocet zdrojovych sloupcu throw new System.Exception("bylo nalezeno " + col_names.GetLength(0).ToString() + " zdrojovych sloupcu"); if(col_names.GetLength(0) == 1) rAttr.creation = col_names[0].GetPropertyString("Name"); IBoxModule[] dercol_names = BoxesHelper.ListDirectAncestBoxesWithID(ABox, "DataMiningCommon.DerivedColumn"); if (dercol_names.GetLength(0) != 1 && dercol_names.GetLength(0) != 0) // byl nalezen chybny pocet zdrojovych sloupcu throw new System.Exception("bylo nalezeno " + dercol_names.GetLength(0).ToString() + " zdrojovych odvozenych sloupcu"); if (dercol_names.GetLength(0) == 1) rAttr.creation = dercol_names[0].GetPropertyString("Formula"); // nalezeni poctu kategorii rAttr.ctgr_count = ABox.GetPropertyLong("CountOfCategories"); // zjisteni kategorie "chybejici hodnota" string nul_cat = ABox.GetPropertyString("IncludeNullCategory"); List<Rec_missing_value> MisVal_list = new List<Rec_missing_value>(); // pole recordu chybejicich hodnot if (!String.IsNullOrEmpty(nul_cat)) { Rec_missing_value MisVal = new Rec_missing_value(); MisVal.name = nul_cat; MisVal_list.Add(MisVal); } // nalezeni nazvu kategorii a jejich frekvenci List<Rec_ctgr> cat_list = new List<Rec_ctgr>(); // seznam kategorii CategoriesStruct cat_str = (ABox.GetPropertyOther("Categories") as CategoriesT).categoriesValue; // long intervals foreach (string key in cat_str.longIntervals.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (doimplementovat, bude-li mozno) new_li.name = key; cat_list.Add(new_li); } // float intervals foreach (string key in cat_str.floatIntervals.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (doimplementovat, bude-li mozno) new_li.name = key; cat_list.Add(new_li); } // date time intervals foreach (string key in cat_str.dateTimeIntervals.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (doimplementovat, bude-li mozno) new_li.name = key; cat_list.Add(new_li); } // enums foreach (string key in cat_str.enums.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (doimplementovat, bude-li mozno) new_li.name = key; cat_list.Add(new_li); } #region Vypsani jednoho Atributu do XML stringu string oneAttrString = ""; // vypsani hypotezy do XML if (MisVal_list.Count == 0 && cat_list.Count == 0) oneAttrString += rAttr.ToXML(); else oneAttrString += rAttr.ToXML(cat_list, MisVal_list); resultString += oneAttrString; #endregion } #endregion // korenovy element resultString += "</active_list>"; // Kody - ulozeni vystupu do souboru "XMLAttrExample.xml" v adresari XMLHelper.saveXMLexample(resultString, "../XML/XMLAttrExample.xml"); return resultString; }
// ==================== Atribut ================================ public static string fFEAttribute(int index) { string resultString = ""; // vysledny XML string // nacteni DTD do resultStringu try { resultString = XMLHelper.loadDTD(); } catch (Exception e) { MessageBox.Show("Chyba pri nacitani DTD: " + e.Message); return(resultString); } // korenovy element resultString += "<active_list>"; string ErrStr = ""; // zaznam o chybach #region A) nalezeni vsech krabicek Atributu (DataMiningCommon.Attributes.Attribute) IBoxModule[] AttrBoxes = BoxesHelper.ListBoxesWithID(CFEsourcesTab.Sources[index] as CFEsource, "DataMiningCommon.Attributes.Attribute"); // zpracovani kazde krabicky - ziskani z ni vsechny Atributy foreach (IBoxModule ABox in AttrBoxes) { Rec_attribute rAttr = new Rec_attribute(); // nastaveni ID atributu rAttr.id = "Attr" + ABox.ProjectIdentifier.ToString(); // zjisteni jmena literalu rAttr.attr_name = ABox.GetPropertyString("NameInLiterals"); // nalezeni jmena datoveho zdroje (databaze) IBoxModule[] db_names = BoxesHelper.ListAncestBoxesWithID(ABox, "DataMiningCommon.Database"); if (db_names.GetLength(0) != 1) // byl nalezen pocet datovych zdroju ruzny od jedne { throw new System.Exception("bylo nalezeno " + db_names.GetLength(0).ToString() + " databazi"); } rAttr.db_name = (db_names[0].GetPropertyOther("DatabaseName") as StringT).stringValue; // nalezeni jmena datove matice IBoxModule[] matrix_names = BoxesHelper.ListAncestBoxesWithID(ABox, "DataMiningCommon.DataMatrix"); if (matrix_names.GetLength(0) != 1) // byl nalezen pocet datovych matic ruzny od jedne { throw new System.Exception("bylo nalezeno " + matrix_names.GetLength(0).ToString() + " datovych matic"); } rAttr.matrix_name = (matrix_names[0].GetPropertyOther("Name") as StringT).stringValue; // nalezeni jmena zdrojoveho sloupce nebo zpusobu odvozeni IBoxModule[] col_names = BoxesHelper.ListDirectAncestBoxesWithID(ABox, "DataMiningCommon.Column"); if (col_names.GetLength(0) != 1 && col_names.GetLength(0) != 0) // byl nalezen chybny pocet zdrojovych sloupcu { throw new System.Exception("bylo nalezeno " + col_names.GetLength(0).ToString() + " zdrojovych sloupcu"); } if (col_names.GetLength(0) == 1) { rAttr.creation = col_names[0].GetPropertyString("Name"); } IBoxModule[] dercol_names = BoxesHelper.ListDirectAncestBoxesWithID(ABox, "DataMiningCommon.DerivedColumn"); if (dercol_names.GetLength(0) != 1 && dercol_names.GetLength(0) != 0) // byl nalezen chybny pocet zdrojovych sloupcu { throw new System.Exception("bylo nalezeno " + dercol_names.GetLength(0).ToString() + " zdrojovych odvozenych sloupcu"); } if (dercol_names.GetLength(0) == 1) { rAttr.creation = dercol_names[0].GetPropertyString("Formula"); } // nalezeni poctu kategorii rAttr.ctgr_count = ABox.GetPropertyLong("CountOfCategories"); // zjisteni kategorie "chybejici hodnota" string nul_cat = ABox.GetPropertyString("IncludeNullCategory"); List <Rec_missing_value> MisVal_list = new List <Rec_missing_value>(); // pole recordu chybejicich hodnot if (!String.IsNullOrEmpty(nul_cat)) { Rec_missing_value MisVal = new Rec_missing_value(); MisVal.name = nul_cat; MisVal_list.Add(MisVal); } // nalezeni nazvu kategorii a jejich frekvenci List <Rec_ctgr> cat_list = new List <Rec_ctgr>(); // seznam kategorii CategoriesStruct cat_str = (ABox.GetPropertyOther("Categories") as CategoriesT).categoriesValue; // long intervals foreach (string key in cat_str.longIntervals.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (doimplementovat, bude-li mozno) new_li.name = key; cat_list.Add(new_li); } // float intervals foreach (string key in cat_str.floatIntervals.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (doimplementovat, bude-li mozno) new_li.name = key; cat_list.Add(new_li); } // date time intervals foreach (string key in cat_str.dateTimeIntervals.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (doimplementovat, bude-li mozno) new_li.name = key; cat_list.Add(new_li); } // enums foreach (string key in cat_str.enums.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (doimplementovat, bude-li mozno) new_li.name = key; cat_list.Add(new_li); } #region Vypsani jednoho Atributu do XML stringu string oneAttrString = ""; // vypsani hypotezy do XML if (MisVal_list.Count == 0 && cat_list.Count == 0) { oneAttrString += rAttr.ToXML(); } else { oneAttrString += rAttr.ToXML(cat_list, MisVal_list); } resultString += oneAttrString; #endregion } #endregion // korenovy element resultString += "</active_list>"; // Kody - ulozeni vystupu do souboru "XMLAttrExample.xml" v adresari XMLHelper.saveXMLexample(resultString, "../XML/XMLAttrExample.xml"); return(resultString); } // TODO: atributy v krabickach EachValueOneCategory, Equidistant, Equifrequency???
/// <summary> /// Returns XML string with all occurences of Active element "Attribute". /// </summary> /// <param name="index">index of data source in FEplugin data sources table</param> /// <returns>XML string</returns> public static string getList(int index) { string resultString = ""; // result XML string // loading DTD to resultString try { resultString = XMLHelper.loadDTD(); } catch (Exception e) { #if (LADENI) MessageBox.Show("error while loading DTD: " + e.Message); #endif return resultString; } // root element resultString += "<active_list>"; string ErrStr = ""; // error report #region A) searching all boxes - Attributes (DataMiningCommon.Attributes.Attribute) IBoxModule[] AttrBoxes = BoxesHelper.ListBoxesWithID(CFEsourcesTab.Sources[index] as CFEsource, "DataMiningCommon.Attributes.Attribute"); // processing of each box - searching all Attributes foreach (IBoxModule ABox in AttrBoxes) { try { Rec_attribute rAttr = new Rec_attribute(); // setting ID attribute rAttr.id = "Attr" + ABox.ProjectIdentifier.ToString(); // searching name of literal rAttr.attr_name = ABox.GetPropertyString("NameInLiterals"); // searching data source name (database) IBoxModule[] db_names = BoxesHelper.ListAncestBoxesWithID(ABox, "DataMiningCommon.Database"); if (db_names.GetLength(0) != 1) // searched more than one data source or neither one throw new System.Exception("found " + db_names.GetLength(0).ToString() + " databases"); rAttr.db_name = (db_names[0].GetPropertyOther("DatabaseName") as StringT).stringValue; // searching data matrix name IBoxModule[] matrix_names = BoxesHelper.ListAncestBoxesWithID(ABox, "DataMiningCommon.DataMatrix"); if (matrix_names.GetLength(0) != 1) // searched more than one data source or neither one throw new System.Exception("found " + matrix_names.GetLength(0).ToString() + " data matrixes"); rAttr.matrix_name = (matrix_names[0].GetPropertyOther("Name") as StringT).stringValue; // searching name of source column or manner of derivation IBoxModule[] col_names = BoxesHelper.ListDirectAncestBoxesWithID(ABox, "DataMiningCommon.Column"); if (col_names.GetLength(0) != 1 && col_names.GetLength(0) != 0) // incorrect number of source columns found throw new System.Exception("found " + col_names.GetLength(0).ToString() + " zdrojovych sloupcu"); if (col_names.GetLength(0) == 1) rAttr.creation = col_names[0].GetPropertyString("Name"); IBoxModule[] dercol_names = BoxesHelper.ListDirectAncestBoxesWithID(ABox, "DataMiningCommon.DerivedColumn"); if (dercol_names.GetLength(0) != 1 && dercol_names.GetLength(0) != 0) // incorrect number of source columns found throw new System.Exception("found " + dercol_names.GetLength(0).ToString() + " zdrojovych odvozenych sloupcu"); if (dercol_names.GetLength(0) == 1) rAttr.creation = dercol_names[0].GetPropertyString("Formula"); // searching number of categories rAttr.ctgr_count = ABox.GetPropertyLong("CountOfCategories"); // searching the category "missisng value" string nul_cat = ABox.GetPropertyString("IncludeNullCategory"); List<Rec_missing_value> MisVal_list = new List<Rec_missing_value>(); // array of records with missing values if (!String.IsNullOrEmpty(nul_cat)) { Rec_missing_value MisVal = new Rec_missing_value(); MisVal.name = nul_cat; MisVal_list.Add(MisVal); } // searching category names and their frequencies List<Rec_ctgr> cat_list = new List<Rec_ctgr>(); // list of categories CategoriesStruct cat_str = (ABox.GetPropertyOther("Categories") as CategoriesT).categoriesValue; // long intervals foreach (string key in cat_str.longIntervals.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (if possible) //KODY 27.11.2006 - not possible to gain attribute frequencies directly from Ferda. Can be resolved via creating CF task new_li.name = key; cat_list.Add(new_li); } // float intervals foreach (string key in cat_str.floatIntervals.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (if possible) new_li.name = key; cat_list.Add(new_li); } // date time intervals foreach (string key in cat_str.dateTimeIntervals.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (if possible) new_li.name = key; cat_list.Add(new_li); } // enums foreach (string key in cat_str.enums.Keys) { Rec_ctgr new_li = new Rec_ctgr(); new_li.freq = "N/A"; // Not Available - TODO (if possible) new_li.name = key; cat_list.Add(new_li); } #region Generating of one attribute to XML string string oneAttrString = ""; // generating hypotheses to XML if (MisVal_list.Count == 0 && cat_list.Count == 0) oneAttrString += rAttr.ToXML(); else oneAttrString += rAttr.ToXML(cat_list, MisVal_list); resultString += oneAttrString; #endregion } catch (System.Exception e) { ErrStr += "Box ProjectIdentifier=" + ABox.ProjectIdentifier.ToString() + ": " + e.Message + "\n"; } } #endregion // root element resultString += "</active_list>"; #if (LADENI) // generating of error message: if (!String.IsNullOrEmpty(ErrStr)) MessageBox.Show("Pri nacitani category doslo k chybam:\n" + ErrStr, "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error); // Kody - storing output to file "XMLAttrExample.xml" in directory XMLHelper.saveXMLexample(resultString, "../XML/XMLAttrExample.xml"); #endif return resultString; }