Пример #1
0
 public List<Statistic> fromEntity(Collection<Entity> col) {
   List<Statistic> list = new ArrayList<Statistic>();
   Statistic st;
   for (Entity e : col) {
     st = new Statistic();
     //			st.setName((String) e.getProperty("name"));
     //			st.setMomin((String) e.getProperty("momin"));
     st.setKey((String) e.getProperty("key"));
     st.setSerializedData((String) e.getProperty("serializedData"));
     list.add(st);
     st.getSerializedData().length();
   }
   return list;
 }
Пример #2
0
  public void saveStat(Statistic stat) {

    stat.setUpdate(new Date().getTime());

    em.getTransaction().begin();
    if (stat.getKey() == null) {
      Calendar cal = Calendar.getInstance();
      cal.setFirstDayOfWeek(Calendar.SUNDAY);
      cal.setTime(stat.getDate());

      String key =
          stat.getMomin()
              + "$"
              + stat.getName()
              + "$"
              + cal.get(Calendar.YEAR)
              + "$"
              + cal.get(Calendar.WEEK_OF_YEAR);
      stat.setKey(key);
      em.persist(stat);
    } else em.merge(stat);
    em.getTransaction().commit();
  }