Exemplo n.º 1
0
  @Override
  public List<TemplateTree> getTemplateTrees(int tId) {
    final StoreDB.Api api = store.getApi();
    try {
      final List<TemplateTree> fromCache = cache.getTemplateTrees(tId);
      if (fromCache != null) {
        return fromCache;
      }

      return cache.putTemplateTrees(tId, toClientTemplateTrees(api.getTemplateTrees(tId)));
    } catch (SQLException ex) {
      log.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
    } finally {
      api.close();
    }

    return new ArrayList<TemplateTree>();
  }
Exemplo n.º 2
0
  @Override
  public List<TemplateRelation> getTemplateRelations(Template t) {
    ArrayList<TemplateRelation> result = new ArrayList<TemplateRelation>();
    final StoreDB.Api api = store.getApi();
    try {
      final List<TemplateRelation> fromCache = cache.getTemplateRelations(t);
      if (fromCache != null) {
        return fromCache;
      }

      return cache.putTemplateRelations(
          t, toClientTemplateRelations(api.getTemplateRelations(t.getId())));
    } catch (SQLException ex) {
      log.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
    } finally {
      api.close();
    }

    return result;
  }
Exemplo n.º 3
0
  @Override
  public ArrayList<ApplicationTemplate> getApplicationTemplates(Application app) {
    ArrayList<ApplicationTemplate> result = new ArrayList<ApplicationTemplate>();
    final StoreDB.Api api = store.getApi();
    try {
      final ArrayList<ApplicationTemplate> fromCache =
          cacheApp.getApplicationTemplates(app.getId());
      if (fromCache != null) {
        return fromCache;
      }

      return cacheApp.putApplicationTemplates(
          app.getId(), toClientApplicationTemplates(api.getAppTemplatesByApp(app.getId())));
    } catch (SQLException ex) {
      log.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
    } finally {
      api.close();
    }

    return result;
  }