Package com.madgnome.jira.plugins.jirachievements.data.ao

Examples of com.madgnome.jira.plugins.jirachievements.data.ao.UserStatistic


  @Override
  public UserStatistic createOrUpdate(StatisticRefEnum statRef, UserWrapper userWrapper, int value)
  {
    StatisticRef statisticRef = statisticRefDaoService.get(statRef);

    UserStatistic userStatistic = null;
    if (statisticRef != null)
    {
      userStatistic = getOrCreate(statisticRef, userWrapper);
      userStatistic.setValue(value);
      userStatistic.save();
    }

    return userStatistic;
  }
View Full Code Here


  @Override
  public UserStatistic incrementStatistic(StatisticRefEnum statRef, UserWrapper userWrapper, int threshold)
  {
    StatisticRef statisticRef = statisticRefDaoService.get(statRef);

    UserStatistic userStatistic = null;
    if (statisticRef != null)
    {
      userStatistic = getOrCreate(statisticRef, userWrapper);
      userStatistic.setValue(userStatistic.getValue() + threshold);
      userStatistic.save();
    }

    return userStatistic;
  }
View Full Code Here

    return userStatistics.length != 0 ? userStatistics[0] : getOrCreate(statisticRef, userWrapper, 5);
  }

  private UserStatistic getOrCreate(StatisticRef statisticRef, UserWrapper userWrapper, int remainingTry)
  {
    UserStatistic userStatistic;
    try
    {
      userStatistic = create(statisticRef, userWrapper);
    }
    catch (Exception e)
View Full Code Here

    return userStatistic;
  }

  private UserStatistic create(StatisticRef statisticRef, UserWrapper userWrapper)
  {
    UserStatistic userStatistic = ao.create(UserStatistic.class, new DBParam("KEY", KeyableUtils.buildKey(statisticRef, userWrapper)));
    userStatistic.setStatisticRef(statisticRef);
    userStatistic.setUserWrapper(userWrapper);
    userStatistic.save();

    return userStatistic;
  }
View Full Code Here

  {
    StatisticRefEnum statRef = StatisticRefEnum.CREATED_ISSUE_COUNT;
    createStatisticRef(statRef);
    UserWrapper userWrapper = createUserWrapper();

    UserStatistic userStatistic = daoService.get(userWrapper, statRef);
    assertNotNull(userStatistic);
    assertEquals(0, userStatistic.getValue());
  }
View Full Code Here

    createStatisticRef(statRef);
    UserWrapper userWrapper = createUserWrapper();

    int value = 1;
    daoService.createOrUpdate(statRef, userWrapper, value);
    UserStatistic userStatistic = daoService.get(userWrapper, statRef);
    assertNotNull(userStatistic);
    assertEquals(value, userStatistic.getValue());
  }
View Full Code Here

    UserWrapper userWrapper = createUserWrapper();

    int value = 2;
    daoService.createOrUpdate(statRef, userWrapper, 1);
    daoService.createOrUpdate(statRef, userWrapper, value);
    UserStatistic userStatistic = daoService.get(userWrapper, statRef);
    assertNotNull(userStatistic);
    assertEquals(value, userStatistic.getValue());
  }
View Full Code Here

TOP

Related Classes of com.madgnome.jira.plugins.jirachievements.data.ao.UserStatistic

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.