}
+ public void loadBluePrint(){
+ try{
+ InputStream in = this.getClass().getClassLoader().getResourceAsStream("BluePrintCache.dat");
+ if(in!=null){
+ this.bluePrint = XSQLBluePrint.load(in);
+ }
+ in.close();
+ }catch(Exception err){
+ err.printStackTrace();
+ }
+ }
+
public static XSQLAdapter getInstance() {
return a;
}
return this.bluePrint;
}
- public List<Object> collectModuleRoots(XSQLBluePrintNode table) {
+ public List<Object> collectModuleRoots(XSQLBluePrintNode table,LogicalDatastoreType type) {
if (table.getParent().isModule()) {
try {
List<Object> result = new LinkedList<Object>();
.toInstance();
DOMDataReadTransaction t = this.domDataBroker
.newReadOnlyTransaction();
- Object node = t.read(LogicalDatastoreType.OPERATIONAL,
+ Object node = t.read(type,
instanceIdentifier).get();
+
node = XSQLODLUtils.get(node, "reference");
if (node == null) {
return result;
XSQLAdapter.log(err);
}
} else {
- return collectModuleRoots(table.getParent());
+ return collectModuleRoots(table.getParent(),type);
}
return null;
}
public void execute(JDBCResultSet rs) {
+ if(this.domDataBroker==null){
+ rs.setFinished(true);
+ return;
+ }
List<XSQLBluePrintNode> tables = rs.getTables();
- List<Object> roots = collectModuleRoots(tables.get(0));
+ List<Object> roots = collectModuleRoots(tables.get(0),LogicalDatastoreType.OPERATIONAL);
+ roots.addAll(collectModuleRoots(tables.get(0),LogicalDatastoreType.CONFIGURATION));
+ if(roots.isEmpty()){
+ rs.setFinished(true);
+ }
XSQLBluePrintNode main = rs.getMainTable();
List<NETask> tasks = new LinkedList<XSQLAdapter.NETask>();
sout.close();
} catch (Exception err) {
}
+ } else if (input.equals("save")) {
+ XSQLBluePrint.save(this.bluePrint);
} else if (input.equals("tocsv")) {
toCsv = !toCsv;
sout.println("to csv file is " + toCsv);
out.print(prompt);
char c = 0;
byte data[] = new byte[1];
- while (c != '\n') {
+ while (!socket.isClosed() && socket.isConnected() && !socket.isInputShutdown() && c != '\n') {
try {
in.read(data);
c = (char) data[0];
inputString.append(c);
} catch (Exception err) {
err.printStackTrace(out);
+ stopped = true;
+ break;
}
}