/** * Execute the insert operation. */ public Record executeInsert(XMLFileInteractionSpec spec, File file, EISDOMRecord input) throws Exception { // Write input record dom to file, or insert dom node. EISDOMRecord outputToFile = input; // If xpath, parse, insert node, then write back if (spec.getXPath() != null) { // If the file exists get tx dom. outputToFile = connection.getXMLFileTransaction().retrieveDOMRecord(file); outputToFile.add(buildField(spec), input); } return null; }
/** * Execute the insert operation. */ public Record executeInsert(XMLFileInteractionSpec spec, File file, EISDOMRecord input) throws Exception { // Write input record dom to file, or insert dom node. EISDOMRecord outputToFile = input; // If xpath, parse, insert node, then write back if (spec.getXPath() != null) { // If the file exists get tx dom. outputToFile = connection.getXMLFileTransaction().retrieveDOMRecord(file); outputToFile.add(buildField(spec), input); } return null; }
/** * Execute the read operation. */ public Record executeRead(XMLFileInteractionSpec spec, File file) throws Exception { // Parse file and return document, or xpath/xquery result from dom. if (!file.exists()) { return null; } EISDOMRecord fileRecord = connection.getXMLFileTransaction().retrieveDOMRecord(file); // Check for and process XPath or XQuery if (spec.getXPath() != null) { // Either a value/string or list of element records is returned Object result = fileRecord.getValues(buildField(spec)); EISDOMRecord output = new EISDOMRecord(); if (result instanceof List) { List results = (List)result; output.setDOM(output.createNewDocument("results")); for (int index = 0; index < results.size(); index++) { output.add(new DatabaseField("result"), results.get(index)); } } else { output.setDOM(output.createNewDocument("results")); output.add(new DatabaseField("result"), result); } return output; } else { return fileRecord; } }