public ExportInfo getExportInfo(long exportTime) { ChromatticSession session = persister.getSession(); ExportInfoMapping eim = session.findByPath(ExportInfoMapping.class, getPathFor(exportTime)); try { if (eim != null) { return eim.toModel(null, null); } else { return null; } } finally { persister.closeSession(false); } }
public List<ExportInfo> getAvailableExportInfos() { ChromatticSession session = persister.getSession(); ExportInfosMapping exportInfosMapping = getExportInfosMapping(session); List<ExportInfoMapping> exportInfoMappings = exportInfosMapping.getExportInfos(); List<ExportInfo> exportInfos = new ArrayList<ExportInfo>(exportInfoMappings.size()); for (ExportInfoMapping eim : exportInfoMappings) { exportInfos.add(eim.toModel(null, null)); } persister.closeSession(false); exportInfosCount = exportInfos.size(); return exportInfos; }
public void add(ExportInfo info) { ChromatticSession session = persister.getSession(); ExportInfoMapping eim = session.findByPath(ExportInfoMapping.class, getChildPath(info)); long exportTime = info.getExportTime(); if (eim != null) { persister.closeSession(false); throw new IllegalArgumentException( "An ExportInfo with export time " + exportTime + " already exists!"); } else { ExportInfosMapping exportInfosMapping = getExportInfosMapping(session); String exportTimeAsString = "" + exportTime; ExportInfoMapping exportInfo = exportInfosMapping.createExportInfo(exportTimeAsString); session.persist(exportInfosMapping, exportInfo, exportTimeAsString); exportInfo.initFrom(info); persister.closeSession(true); exportInfosCount++; } }