use of com.manydesigns.portofino.model.Model in project Portofino by ManyDesigns.
the class Persistence method loadXmlModel.
// **************************************************************************
// Model loading
// **************************************************************************
public synchronized void loadXmlModel() {
try {
JAXBContext jc = createModelJAXBContext();
Unmarshaller um = jc.createUnmarshaller();
FileObject appModelFile = getModelFile();
if (appModelFile.exists()) {
logger.info("Loading legacy xml model from file: {}", appModelFile.getName().getPath());
try (InputStream inputStream = appModelFile.getContent().getInputStream()) {
model = (Model) um.unmarshal(inputStream);
} catch (Exception e) {
String msg = "Cannot load/parse model: " + appModelFile;
logger.error(msg, e);
}
} else {
logger.info("Loading model from directory: {}", getModelDirectory().getName().getPath());
model = new Model();
}
FileObject modelDir = getModelDirectory();
if (modelDir.exists()) {
for (FileObject databaseDir : modelDir.getChildren()) {
loadXmlDatabase(um, model, databaseDir);
}
}
initModel();
} catch (Exception e) {
logger.error("Cannot load/parse model", e);
}
}
Aggregations