use of io.atlasmap.v2.Document in project JMRI by JMRI.
the class EngineManagerXml method writeFile.
@Override
public void writeFile(String name) throws java.io.FileNotFoundException, java.io.IOException {
log.debug("writeFile {}", name);
// This is taken in large part from "Java and XML" page 368
File file = findFile(name);
if (file == null) {
file = new File(name);
}
// create root element
// NOI18N
Element root = new Element("operations-config");
// NOI18N
Document doc = newDocument(root, dtdLocation + "operations-engines.dtd");
// add XSLT processing instruction
java.util.Map<String, String> m = new java.util.HashMap<String, String>();
// NOI18N
m.put("type", "text/xsl");
// NOI18N
m.put("href", xsltLocation + "operations-engines.xsl");
// NOI18N
ProcessingInstruction p = new ProcessingInstruction("xml-stylesheet", m);
doc.addContent(0, p);
EngineModels.instance().store(root);
EngineTypes.instance().store(root);
EngineLengths.instance().store(root);
EngineManager.instance().store(root);
writeXML(file, doc);
// done - engine file now stored, so can't be dirty
setDirty(false);
}
use of io.atlasmap.v2.Document in project JMRI by JMRI.
the class OperationsSetupXml method writeFile.
@Override
public void writeFile(String name) throws java.io.FileNotFoundException, java.io.IOException {
log.debug("writeFile {}", name);
// This is taken in large part from "Java and XML" page 368
File file = findFile(name);
if (file == null) {
file = new File(name);
}
// create root element
// NOI18N
Element root = new Element("operations-config");
// NOI18N
Document doc = newDocument(root, dtdLocation + "operations-config.dtd");
// add XSLT processing instruction
java.util.Map<String, String> m = new java.util.HashMap<String, String>();
// NOI18N
m.put("type", "text/xsl");
// NOI18N
m.put("href", xsltLocation + "operations-config.xsl");
// NOI18N
ProcessingInstruction p = new ProcessingInstruction("xml-stylesheet", m);
doc.addContent(0, p);
// add top-level elements
root.addContent(Setup.store());
// add manifest header text strings
root.addContent(TrainManifestHeaderText.store());
// add manifest text strings
root.addContent(TrainManifestText.store());
// add switch list text strings
root.addContent(TrainSwitchListText.store());
// add control elements
root.addContent(Control.store());
writeXML(file, doc);
// done, so can't be dirty
setDirty(false);
}
use of io.atlasmap.v2.Document in project JMRI by JMRI.
the class TrainManagerXml method writeFile.
@Override
public void writeFile(String name) throws java.io.FileNotFoundException, java.io.IOException {
log.debug("writeFile {}", name);
// This is taken in large part from "Java and XML" page 368
File file = findFile(name);
if (file == null) {
file = new File(name);
}
// create root element
// NOI18N
Element root = new Element("operations-config");
// NOI18N
Document doc = newDocument(root, dtdLocation + "operations-trains.dtd");
// add XSLT processing instruction
java.util.Map<String, String> m = new java.util.HashMap<String, String>();
// NOI18N
m.put("type", "text/xsl");
// NOI18N
m.put("href", xsltLocation + "operations-trains.xsl");
// NOI18N
ProcessingInstruction p = new ProcessingInstruction("xml-stylesheet", m);
doc.addContent(0, p);
TrainManager.instance().store(root);
TrainScheduleManager.instance().store(root);
AutomationManager.instance().store(root);
writeXML(file, doc);
// done - train file now stored, so can't be dirty
setDirty(false);
}
use of io.atlasmap.v2.Document in project JMRI by JMRI.
the class VSDecoderPreferences method save.
public void save() {
if (prefFile == null) {
return;
}
XmlFile xf = new XmlFile() {
};
// odd syntax is due to XmlFile being abstract
xf.makeBackupFile(prefFile);
File file = new File(prefFile);
try {
//The file does not exist, create it before writing
File parentDir = file.getParentFile();
if (!parentDir.exists()) {
if (// make directory, check result
!parentDir.mkdir()) {
log.error("failed to make parent directory");
}
}
if (// create file, check result
!file.createNewFile()) {
log.error("createNewFile failed");
}
} catch (Exception exp) {
log.error("Exception while writing the new VSDecoder preferences file, may not be complete: " + exp);
}
try {
Element root = new Element("vsdecoder-preferences");
//Document doc = XmlFile.newDocument(root, XmlFile.dtdLocation+"vsdecoder-preferences.dtd");
Document doc = XmlFile.newDocument(root);
// add XSLT processing instruction
// <?xml-stylesheet type="text/xsl" href="XSLT/throttle.xsl"?>
/*TODO java.util.Map<String,String> m = new java.util.HashMap<String,String>();
m.put("type", "text/xsl");
m.put("href", jmri.jmrit.XmlFile.xsltLocation+"throttles-preferences.xsl");
ProcessingInstruction p = new ProcessingInstruction("xml-stylesheet", m);
doc.addContent(0,p);*/
root.setContent(store());
xf.writeXML(file, doc);
} catch (Exception ex) {
// TODO fix null value for Attribute
log.warn("Exception in storing vsdecoder preferences xml: " + ex);
}
}
use of io.atlasmap.v2.Document in project atlasmap by atlasmap.
the class XmlModule method processSourceFieldMapping.
@Override
public void processSourceFieldMapping(AtlasInternalSession session) throws AtlasException {
Field sourceField = session.head().getSourceField();
XmlFieldReader reader = session.getFieldReader(getDocId(), XmlFieldReader.class);
if (reader == null) {
AtlasUtil.addAudit(session, sourceField.getDocId(), String.format("Source document '%s' doesn't exist", getDocId()), sourceField.getPath(), AuditStatus.ERROR, null);
return;
}
reader.read(session);
if (sourceField.getActions() != null && sourceField.getActions().getActions() != null) {
getFieldActionService().processActions(sourceField.getActions(), sourceField);
}
if (LOG.isDebugEnabled()) {
LOG.debug("{}: processSourceFieldMapping completed: SourceField:[docId={}, path={}, type={}, value={}]", getDocId(), sourceField.getDocId(), sourceField.getPath(), sourceField.getFieldType(), sourceField.getValue());
}
}
Aggregations