コード例 #1
0
  public boolean isAvailableExportInfosEmpty() {
    if (exportInfosCount == -1) {
      ChromatticSession session = persister.getSession();
      ExportInfosMapping mappings = getExportInfosMapping(session);
      exportInfosCount = mappings.getExportInfos().size();
      persister.closeSession(false);
    }

    return exportInfosCount == 0;
  }
コード例 #2
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);
    }
  }
コード例 #3
0
  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;
  }
コード例 #4
0
 public ExportInfo remove(ExportInfo info) {
   if (persister.delete(info, this)) {
     exportInfosCount--;
     return info;
   } else {
     return null;
   }
 }
コード例 #5
0
  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++;
    }
  }