/
nea
/
androidGroupBuilder
Обзор
Документация
Войти
/
nea
/
androidGroupBuilder
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
app/src/main/java/com/ea/groupbuilder/classForResearch.java
317 строк
16 KB
ea
Группа Автоморфизмов отлажено 23_04_2026
23 апр 2026, 17:08
23 апр 2026, 17:08
4513276
Код
Авторство
О чём код?
package com.ea.groupbuilder; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.util.Log; import java.util.Calendar; public class classForResearch { // работа с Sn // private static final String TAG = "GRUGRA_RESECH"; final static private boolean DISPLAYLOG = false; public mAplication mApp; static public substitutionS classSubs; static public SQLiteDatabase db; public void f_generator(mAplication mApp_, int rejm, String sylow_num) { // заполняет mApp.activityMain.adapterCreater (обрызующие) для построения новой группы // rejm = 0 - p-группу по sylow_num, 1 - по p-подгруппа Sn mApp = mApp_; db = DbHelper.db; DbHelper dbH = mApp_.dbH; classSubs = mApp.classSubs; if (DISPLAYLOG) Log.e(TAG, " f_generator f_calcPrim = " + mApp.whatRun + " rejm = "+rejm + " sylow_num = "+ sylow_num + " faktSnLen = " + DbHelper.faktSnLen); int iDeg, id, iId; String formg; // заполняю поле forming в elements и в temp_pe заношу id_s (с повторениями), строит табл generators_element substitutionS.newSubsMas.clear(); // сюда заносятся все исходные подстановки для построения группы final String ssql [] ={ "delete from generators_test;", "UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='generators_test';", "insert into generators_test (id_s, ciklos, substitution) select _id, ciklos, substitution from elements order by _id asc;" }; db.beginTransaction(); try { // сохранит для сверки существующую группу в generators_test for(id = 0; id < ssql.length; id++) db.execSQL(ssql[id]); if (DISPLAYLOG) { iDeg = dbH.f_getCount("select count(*) as ccc from generators_test;"); Log.e(TAG, " f_generator generators_test = " + iDeg); iDeg = dbH.f_getCount("select count(*) as ccc from elements;"); Log.e(TAG, " f_generator elements = " + iDeg); } // заношу в substitutionS.newSubsMas генераторы String sqL = "select E._id _id, ciklos\n" + " from elements E \n" + " where pe > 0 and E.sylow_num = '"+ sylow_num +"';"; if (rejm > 0 ) sqL ="select E._id _id, ciklos\n" + // или элементы р подгруппы " from elements_n E \n" + " where pe > 0 and E.sylow_num = '"+ sylow_num +"';"; Cursor curAdpForm = db.rawQuery(sqL, null); curAdpForm.moveToFirst(); if (curAdpForm.getCount() > 0) { iDeg = curAdpForm.getColumnIndex("ciklos"); iId = curAdpForm.getColumnIndex("_id"); do { id = curAdpForm.getInt(iId); formg = curAdpForm.getString(iDeg); mApp.activityMain.adapterCreater.add( new ClassNewSubs("G" + id, formg, false)); // Log.e(TAG, "f_generator new rejm=" + rejm + " id = " + id + " sylow_num= " + sylow_num + " sqL = " + sqL ); } while (curAdpForm.moveToNext()); } curAdpForm.close(); } catch (Exception e) { Log.e(TAG, "Error f_generator " + e.getMessage() ); DbHelper.err += "Error f_generator " + e.getMessage(); mApp.curExeption = e; } if (mApp.whatRun != -1 && DbHelper.err.length() == 0) { db.setTransactionSuccessful(); } db.endTransaction(); if (DbHelper.err.length() > 0) mApp.f_messError(0,"f_generator", true); else mApp.kakBuildid = true; } public void f_testGenerator(mAplication mApp_) { // сравнивает построенную по генераторам группу elements и сохраненную исходную в generators_test mApp = mApp_; db = DbHelper.db; classSubs = mApp.classSubs; DbHelper dbH = mApp_.dbH; final String sqlTest = "select count(ciklos) as ccc from (\n" + "select T.ciklos ciklos from generators_test T where T.substitution not in (\n" + " select M.substitution from elements M) \n" + " Union all \n" + "select M.ciklos ciklos from elements M where M.substitution not in (\n" + " select T.substitution from generators_test T));"; // сравнение int iDeg = dbH.f_getCount(sqlTest); if (iDeg > 0) { Log.e(TAG, "f_calcPrim Новая группа не совпадает со старой, ошибок " + iDeg ); mApp.putProt("Новая группа не совпадает со старой, ошибок " + iDeg); } else { Log.e(TAG, "f_calcPrim Новая группа совпадает со старой, ошибок " + iDeg ); mApp.putProt("Новая группа совпадает со старой, ошибок " + iDeg); } } public void f_resech(mAplication mApp_) { // сохранить группу в таблицах *_n для исследования (Sn) mApp = mApp_; db = DbHelper.db; classSubs = mApp.classSubs; DbHelper dbH = mApp_.dbH; if (DISPLAYLOG) Log.e(TAG, " classForResearch = "+ mApp.whatRun + " faktSnLen = " + DbHelper.faktSnLen); String sw = "", sq; final String str1[] = { "drop table if exists subgrups_n;", "drop table if exists tmp_tab_correction_n;", "CREATE TABLE if not exists subgrups_n as select * from subgrups;", "CREATE TABLE if not exists tmp_tab_correction_n as select * from tmp_tab_correction;", "insert into sylov_common_n (pe, id_s, count_id, parity) " + "select pe, id_s, count_id, parity from sylov_common; ", "insert into accordance_n (pe, num_old, num) " + "select pe, num_old, num from accordance; ", "insert into soc_list_n (nrow, ncol, num, dubl_flag, comm_level, soc_level, centr_flag, even_flag, " + " sylow_num, connon_sylow, summa_num, epi_pe, num_klass, count_klass, deg, sostav, sostav_type, sostav_count) " + "select nrow, ncol, num, dubl_flag, comm_level, soc_level, centr_flag, even_flag," + " sylow_num, connon_sylow, summa_num, epi_pe, num_klass, count_klass, deg, sostav, sostav_type, sostav_count from soc_list; ", "insert into soc_subs_n (num_maim, num_subs) " + "select num_maim, num_subs from soc_subs; ", "insert into addition_n (main_id, clength, substitution, deg, cykl, stabilizer, parity) " + "select main_id, clength, substitution, deg, cykl, stabilizer, parity from addition; ", "insert into sylow_attachments_n (pe, main_lelel, mail_num, att_level, att_num, att_order, att_index) " + "select pe, main_lelel, mail_num, att_level, att_num, att_order, att_index from sylow_attachments; ", "insert into sylow_conj_n (pe, num1, num2, id_conj, id_reverse, count_element) " + "select pe, num1, num2, id_conj, id_reverse, count_element from sylow_conj; ", "insert into pairing_area_n (class_area, num, id_subs, cykl_len, dubl) " + "select class_area, num, id_subs, cykl_len, dubl from pairing_area; ", "insert into centralizer_n (class_pair, id_imagine, id_subs) " + "select class_pair, id_imagine, id_subs from centralizer; ", "insert into normal_subgroup_n (num_maim, order_main, num_sub, order_sub) " + "select num_maim, order_main, num_sub, order_sub from normal_subgroup; ", "insert into exponent_n (pe, val_exp) " + "select pe, val_exp from exponent; ", "insert into normalizer_n (pe, id_s, num) " + "select pe, id_s, num from normalizer; ", "insert into inputpods_n (name, substitution, iteration, rever) " + "select name, substitution, iteration, rever from inputpods; ", "insert into sub_structure_n (num_maim, num_subs, deg) " + "select num_maim, num_subs, deg from sub_structure; ", "insert into sylov_com_grup_n (pe, sylow_zag, id_s, nomer1, nomer2) " + "select pe, sylow_zag, id_s, nomer1, nomer2 from sylov_com_grup; ", "insert into temp_multiplication_n (idproiz, idleft, idright, name, name_old, txt, iteration, deg) " + " select idproiz, idleft, idright, name, name_old, txt, iteration, deg from temp_multiplication; ", "insert into sylow_attachments_n (pe, main_lelel, mail_num, att_level, att_num, att_order, att_index) " + "select pe, main_lelel, mail_num, att_level, att_num, att_order, att_index from sylow_attachments; ", "insert into elements_n (id_true, name, substitution, ciklos, deg, pairing_num, sylow_num, primitiv, forming, \n" + "switchboard_num, center_num, stabilizer, cykl_len, pe, iteration, parity, nomer_soc) \n" + " select _id, name, substitution, ciklos, deg, pairing_num, sylow_num, primitiv, forming, \n" + " switchboard_num, center_num, stabilizer, cykl_len, pe, iteration, parity, nomer_soc \n " + " from elements; ", "update elements_n set link_to_elements = null;", "update elements_n set link_to_elements = (\n" + "select _id from elements" + " where elements_n.ciklos = elements.ciklos);", "insert into sylov_table_n (pe, num, id_main, id_s, effort, parity) \n" + " select pe, num, id_main, id_s, effort, parity from sylov_table;", "update sylov_table_n set num_resech = null, id_resech = null;", "update sylov_table_n set num_resech = (\n" + // номер подгруппы в sylov_table " select A.num from sylov_table A, elements AA, elements_n BB\n" + " where AA.ciklos = BB.ciklos and AA._id = A.id_s and BB.id_true = sylov_table_n.id_s);", "update sylov_table_n set id_resech = (\n" + // _id подстановки сил подгруппы созданной ргуппы (не Sn) " select distinct A.id_s from sylov_table A, elements AA, elements_n BB\n" + " where AA.ciklos = BB.ciklos and AA._id = A.id_s and BB.id_true = sylov_table_n.id_s " + ");", "insert into switchboard_n (id_switch, id_pair, id_left, id_right, txt_pair, txt_switch, work_field) \n" + " select id_switch, id_pair, id_left, id_right, txt_pair, txt_switch, work_field from switchboard;", "insert into pairing_area_n (class_area, num, id_subs, cykl_len) \n" + " select class_area, num, id_subs, cykl_len from pairing_area;", "insert into epimorphism_n (id_element, id_obraz, pe, substitution, ciklos, cykl_len, deg, adjacent) \n" + " select id_element, id_obraz, pe, substitution, ciklos, cykl_len, deg, adjacent from epimorphism;", "insert into generators_element_n (id_s, sylow_num, pe) \n" + " select id_s, sylow_num, pe from generators_element;", "insert into exponent_n (pe, val_exp) \n" + " select pe, val_exp from exponent;", "insert into sub_scribe_n (id_s, text_sub) \n" + " select id_s, text_sub from sub_scribe;" }; int i, j; // окончание параметра зависит от группы db.beginTransaction(); try { for (String s : DbHelper.tblMainName) { if (! s.equals("params")) { db.execSQL("delete from " + s + "_n;"); db.execSQL("UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='" + s + "_n';"); if (DISPLAYLOG) Log.d(TAG, "f_resech delete from " + s + "_n"); } } for (String s : str1) { db.execSQL(s); if (DISPLAYLOG) Log.d(TAG, "f_resech " + s); } db.execSQL("delete from params where substr(parm, length(parm) - 1) = '_n'"); // Log.e(TAG, "f_resech vidWgrup = delete from params where substr(parm, length(parm) - 1) = '_n'" ); // сохраняю параметры ..._n для Sn в params (параметры dbH.f_getParm) // faktSubsLen sq = "insert into params (parm, ind, val, val_txt) select substr(parm, 1, length(parm) - 1) || 'n', ind, val, val_txt \n" + " from params where substr(parm, length(parm) - 1) = '_g';"; db.execSQL(sq); if (DISPLAYLOG) Log.d(TAG, "sw " + sw + " sq = " + sq); // проставляю for_n = подстановки для 1,... // подгруппа Sk есть where for_n <= k for (i = 3; i <= DbHelper.faktSnLen; i++) { sw = ""; for (j = i; j <= DbHelper.faktSnLen; j++) { sw += ", " + j; } sw += "]"; sq = "update elements_n set for_n = " + (i - 1) + " where instr(substitution, '" + sw + "') > 0 and for_n is null; "; db.execSQL(sq); if (DISPLAYLOG) Log.d(TAG, "sw " + sw + " sq = " + sq); } sq = "update elements_n set for_n = " + DbHelper.faktSnLen + " where for_n is null; "; db.execSQL(sq); } catch (Exception e) { Log.e(TAG, "Error f_resech " + e.getMessage() ); DbHelper.err += "Error f_resech " + e.getMessage(); mApp.curExeption = e; } if (mApp.whatRun != -1 && DbHelper.err.length() == 0) { db.setTransactionSuccessful(); } db.endTransaction(); if (DbHelper.err.length() > 0) mApp.f_messError(0,"f_resech", true); else { Calendar now = Calendar.getInstance(); // было построение Sn - заменить значение String sdt = now.getTime().toString(); DbHelper.saveSnLen = DbHelper.faktSnLen; db.execSQL("DELETE FROM params where parm = 'saveSnLen';"); // Log.e(TAG, "saveSnLen vidWgrup = " ); db.execSQL("insert into params (parm, ind, val_txt) values ('saveSnLen', "+ DbHelper.saveSnLen + ", '" + sdt + "' );"); mApp.putProt("Группа " + mApp.groupName + " для n = "+ DbHelper.saveSnLen + " сохранена в базе и в дальнейшем может быть использована"); } } } //----------------------------