DetaDBBufferCacheManager, 数据类 package MS.OP.SM.AOP.MEC.SIQ.cache; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.concurrent.ConcurrentHashMap; import OP.SM.AOP.MEC.SIQ.SM.reflection.Base; import OP.SM.AOP.MEC.SIQ.SM.reflection.Cell; import OP.SM.AOP.MEC.SIQ.SM.reflection.DB; import OP.SM.AOP.MEC.SIQ.SM.reflection.Row; import OP.SM.AOP.MEC.SIQ.SM.reflection.Spec; import OP.SM.AOP.MEC.SIQ.SM.reflection.Table; import PEU.P.cache.*; @SuppressWarnings("unused") public class DetaDBBufferCache_M { public static DB db = new DB(); public static boolean dbCache = false; private DetaDBBufferCache_M() { super(); } public static void reflection() throws IOException { ConcurrentHashMap bases= new ConcurrentHashMap<>(); db.I_Bases(bases); //1 获取 db 路径; String dBPath= Cache_M.getCacheInfo("DBPath").getValue().toString(); File fileDBPath= new File(dBPath); if (fileDBPath.isDirectory()) { String[] baseNames= fileDBPath.list(); for(int i= 0; i< baseNames.length; i++) { loopBases(db, dBPath, baseNames[i]); } } dbCache = true; } private static void loopBases(DB db, String dBPath, String baseName) throws IOException{Base base = new Base(); ConcurrentHashMap tables= new ConcurrentHashMap<>(); base.I_Tables(tables); String dBasePath = dBPath + "/" + baseName; //DNA 元基催化与肽计算,第四次修订版本 402 //get base File fileDBasePath = new File(dBasePath); if (fileDBasePath.isDirectory()) { ConcurrentHashMap tableMap= new ConcurrentHashMap<>();//get tables String[] tableNames = fileDBasePath.list(); for(int i = 0; i < tableNames.length; i++) { loopTables(base, dBasePath, tableNames[i]); } } db.putBase(baseName, base); } private static void loopTables(Base base, String dBasePath, String tableName) throwsIOException { Table table = new Table(); String tablePath = dBasePath + "/" + tableName; File fileTablePath = new File(tablePath); if (fileTablePath.isDirectory()) { String specPath = tablePath + "/spec"; String rowsPath = tablePath + "/rows"; loopSpec(table,specPath); loopRows(table,rowsPath); } base.putTable(tableName, table); } private static void loopSpec(Table table, String specPath) throws IOException{ Spec spec = new Spec(); ConcurrentHashMap culumnTypes = new ConcurrentHashMap<>(); spec.I_CulumnTypes(culumnTypes); File fileSpecPath = new File(specPath); if (fileSpecPath.isDirectory()) { String[] specs = fileSpecPath.list(); for(int i = 0; i < specs.length; i++) { String specCulumnPath = specPath + "/" + specs[i]; String specCulumnValuePath = specCulumnPath + "/value.lyg"; //if get BufferedReader reader = new BufferedReader(new FileReader(specCulumnPath+"/" + "value.lyg")); String temp = ""; String tempString = ""; while ((tempString = reader.readLine()) != null) { temp += tempString; } reader.close(); spec.I_CulumnType(specs[i], temp); } } table.I_Spec(spec); } private static void loopRows(Table table, String rowsPath) throws IOException{ ConcurrentHashMap rows = new ConcurrentHashMap<>(); //DNA 元基催化与肽计算,第四次修订版本 403 table.I_Rows(rows); File fileRowsPath = new File(rowsPath); if (fileRowsPath.isDirectory()) { String[] rowIndex = fileRowsPath.list(); for(int i = 0; i < rowIndex.length; i++) { loopRow(table, fileRowsPath, rowIndex[i]); } } } private static void loopRow(Table table, File fileRowsPath, String rowIndex) throwsIOException { Row row = new Row(); ConcurrentHashMap cells = new ConcurrentHashMap<>(); row.I_Cells(cells); String rowIndexPath = fileRowsPath + "/" + rowIndex; File fileRowPath = new File(rowIndexPath); if (fileRowPath.isDirectory()) { String[] culumns = fileRowPath.list(); for(int i = 0; i < culumns.length; i++) { String rowCulumnPath = rowIndexPath + "/" + culumns[i]; String rowCulumnValuePath = rowCulumnPath + "/value.lyg"; //if get if(!culumns[i].contains("is_delete")) { BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(rowCulumnValuePath));}catch(Exception e){ e.printStackTrace(); } String temp = ""; String tempString = ""; while ((tempString = reader.readLine()) != null) { temp += tempString; } reader.close(); Cell cell = new Cell(); cell.I_CellValue(temp); row.putCell(culumns[i], cell); }else { Cell cell = new Cell(); cell.I_CellValue(""); row.putCell(culumns[i], cell); } } } table.putRow(rowIndex, row);; } }