use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class CQBGroupNodePersistManager method fix.
/**
* To fix when it has crashed group information
*/
public void fix() {
List<CubridDatabase> dbs = CQBDBNodePersistManager.getInstance().getAllDatabase();
if (dbs == null)
return;
List<ICubridNode> cnodes = new ArrayList<ICubridNode>();
try {
List<CubridGroupNode> gnodes = getAllGroupNodes();
for (int i = 0; i < gnodes.size(); i++) {
CubridGroupNode node = gnodes.get(i);
List<ICubridNode> snode = node.getChildren();
for (int j = 0; j < snode.size(); j++) {
cnodes.add(snode.get(j));
}
}
} catch (Exception e) {
e.printStackTrace();
}
try {
for (int i = 0; i < dbs.size(); i++) {
CubridDatabase db = dbs.get(i);
String gid = db.getName() + "/" + db.getName();
boolean exists = false;
for (int j = 0; j < cnodes.size(); j++) {
ICubridNode cnode = cnodes.get(j);
if (cnode.getId() != null && cnode.getId().equals(gid)) {
exists = true;
break;
}
}
if (!exists) {
getDefaultGroup().addChild(db);
}
}
} catch (Exception e) {
e.printStackTrace();
}
saveAllGroupNode();
}
Aggregations