/** * Get TableDesc by name */ public TableDesc getTableDesc(String tableName, String prj) { try (AutoLock lock = srcTableMapLock.lockForWrite()) { return getProjectSpecificTableDesc(getTableIdentity(tableName), prj); } }
public Map<String, TableDesc> getAllTablesMap(String prj) { // avoid cyclic locks ProjectInstance project = (prj == null) ? null : ProjectManager.getInstance(config).getProject(prj); try (AutoLock lock = srcTableMapLock.lockForWrite()) { //TODO prj == null case is now only used by test case and CubeMetaIngester //should refactor these test case and tool ASAP and stop supporting null case if (prj == null) { Map<String, TableDesc> globalTables = new LinkedHashMap<>(); for (TableDesc t : srcTableMap.values()) { globalTables.put(t.getIdentity(), t); } return globalTables; } Set<String> prjTableNames = project.getTables(); Map<String, TableDesc> ret = new LinkedHashMap<>(); for (String tableName : prjTableNames) { String tableIdentity = getTableIdentity(tableName); ret.put(tableIdentity, getProjectSpecificTableDesc(tableIdentity, prj)); } return ret; } }
/** * the project-specific table desc will be expand by computed columns from the projects' models * when the projects' model list changed, project-specific table should be reset and get expanded * again */ public void resetProjectSpecificTableDesc(String prj) throws IOException { // avoid cyclic locks ProjectInstance project = ProjectManager.getInstance(config).getProject(prj); try (AutoLock lock = srcTableMapLock.lockForWrite()) { for (String tableName : project.getTables()) { String tableIdentity = getTableIdentity(tableName); String key = mapKey(tableIdentity, prj); TableDesc originTableDesc = srcTableMap.get(key); if (originTableDesc == null) { continue; } if (originTableDesc.isBorrowedFromGlobal()) { srcTableMap.removeLocal(key);//delete it so that getProjectSpecificTableDesc will create again } else { srcTableCrud.reload(key); } } } }
/** * Get TableDesc by name */ public TableDesc getTableDesc(String tableName, String prj) { try (AutoLock lock = srcTableMapLock.lockForWrite()) { return getProjectSpecificTableDesc(getTableIdentity(tableName), prj); } }
public Map<String, TableDesc> getAllTablesMap(String prj) { // avoid cyclic locks ProjectInstance project = (prj == null) ? null : ProjectManager.getInstance(config).getProject(prj); try (AutoLock lock = srcTableMapLock.lockForWrite()) { //TODO prj == null case is now only used by test case and CubeMetaIngester //should refactor these test case and tool ASAP and stop supporting null case if (prj == null) { Map<String, TableDesc> globalTables = new LinkedHashMap<>(); for (TableDesc t : srcTableMap.values()) { globalTables.put(t.getIdentity(), t); } return globalTables; } Set<String> prjTableNames = project.getTables(); Map<String, TableDesc> ret = new LinkedHashMap<>(); for (String tableName : prjTableNames) { String tableIdentity = getTableIdentity(tableName); ret.put(tableIdentity, getProjectSpecificTableDesc(tableIdentity, prj)); } return ret; } }
/** * the project-specific table desc will be expand by computed columns from the projects' models * when the projects' model list changed, project-specific table should be reset and get expanded * again */ public void resetProjectSpecificTableDesc(String prj) throws IOException { // avoid cyclic locks ProjectInstance project = ProjectManager.getInstance(config).getProject(prj); try (AutoLock lock = srcTableMapLock.lockForWrite()) { for (String tableName : project.getTables()) { String tableIdentity = getTableIdentity(tableName); String key = mapKey(tableIdentity, prj); TableDesc originTableDesc = srcTableMap.get(key); if (originTableDesc == null) { continue; } if (originTableDesc.isBorrowedFromGlobal()) { srcTableMap.removeLocal(key);//delete it so that getProjectSpecificTableDesc will create again } else { srcTableCrud.reload(key); } } } }