public boolean isAvailableExportInfosEmpty() { if (exportInfosCount == -1) { ChromatticSession session = persister.getSession(); ExportInfosMapping mappings = getExportInfosMapping(session); exportInfosCount = mappings.getExportInfos().size(); persister.closeSession(false); } return exportInfosCount == 0; }
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 ExportInfo remove(ExportInfo info) { if (persister.delete(info, this)) { exportInfosCount--; return info; } else { return null; } }
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++; } }