Ejemplo n.º 1
0
  @Override
  public void postToFeed(final User user, final Throwable ex) {
    LogHelper.logException(this.getClass(), ex);
    try {
      postToFeed(user, ExceptionUtils.getStackTrace(ex), FeedType.error);

    } catch (NimbitsException e) {
      LogHelper.logException(this.getClass(), e);
    }
  }
  @Override
  public void processCalculations(final User u, final Entity point, final Value value)
      throws NimbitsException {

    final List<Entity> calculations =
        EntityServiceFactory.getInstance().getEntityByTrigger(u, point, EntityType.calculation);
    for (final Entity entity : calculations) {
      Calculation c = (Calculation) entity;
      try {

        final List<Entity> target =
            EntityServiceFactory.getInstance().getEntityByKey(u, c.getTarget(), EntityType.point);
        if (target.isEmpty()) {
          log.severe("Point target was null " + c.getTarget());
          log.severe(c.getFormula());
          log.severe("trigger: " + c.getTrigger());
          disableCalc(u, c);
        } else {
          log.info("Solving calc" + c.getFormula());
          final Value result = solveEquation(u, c);
          log.info("result" + result);
          ValueServiceFactory.getInstance().recordValue(u, target.get(0), result);
        }
      } catch (NimbitsException e1) {
        LogHelper.logException(this.getClass(), e1);
        disableCalc(u, c);
      }
    }
  }
Ejemplo n.º 3
0
 @Override
 @SuppressWarnings(Const.WARNING_UNCHECKED)
 public void doGet(final HttpServletRequest req, final HttpServletResponse resp)
     throws IOException {
   // PrintWriter out;
   // out = resp.getWriter();
   try {
     processGet();
   } catch (NimbitsException e) {
     LogHelper.logException(IdlePointCron.class, e);
   }
 }
Ejemplo n.º 4
0
  protected static int processGet() throws NimbitsException {
    final List<Entity> points = EntityServiceFactory.getInstance().getIdleEntities();
    log.info("Processing " + points.size() + " potentially idle points");
    for (final Entity p : points) {
      try {
        checkIdle((Point) p);
      } catch (NimbitsException e) {

        LogHelper.logException(IdlePointCron.class, e);
      }
    }
    return points.size();
  }