Exemplo n.º 1
0
  @Override
  public void postToFeed(final User user, final String message, final FeedType type)
      throws NimbitsException {
    final Point point = getFeedPoint(user);

    if (point != null) {
      final String shortened = message.length() > LENGTH ? message.substring(0, LENGTH) : message;

      final String finalMessage;
      try {
        finalMessage = generatePostToFeedHtml(shortened, message, type);
      } catch (UnsupportedEncodingException e) {
        throw new NimbitsException(e);
      }

      final FeedValue feedValue = new FeedValueModel(finalMessage, "", type);
      final String json = GsonFactory.getSimpleInstance().toJson(feedValue);
      final Value value =
          ValueModelFactory.createValueModel(
              0.0, 0.0, Const.CONST_IGNORED_NUMBER_VALUE, new Date(), "", json);
      final Value v = ValueModelFactory.createValueModel(value, json);

      RecordedValueServiceFactory.getInstance().recordValue(user, point, v, false);
    }
  }
Exemplo n.º 2
0
  @Override
  public List<FeedValue> getFeed(final int count, final String relationshipEntityKey)
      throws NimbitsException {

    final User loggedInUser = getUser();
    final User feedUser = getFeedUser(relationshipEntityKey, loggedInUser);

    if (feedUser != null) {

      final Point point = getFeedPoint(feedUser);
      if (point == null) {
        return new ArrayList<FeedValue>(0);
      } else {
        final List<Value> values =
            RecordedValueServiceFactory.getInstance().getTopDataSeries(point, count, new Date());
        final List<FeedValue> retObj = new ArrayList<FeedValue>(values.size());

        for (final Value v : values) {
          if (!Utils.isEmptyString(v.getData())) {
            try {
              retObj.add(GsonFactory.getInstance().fromJson(v.getData(), FeedValueModel.class));
            } catch (JsonSyntaxException ignored) {

            }
          }
        }
        return retObj;
      }
    } else {
      return new ArrayList<FeedValue>(0);
    }
  }
Exemplo n.º 3
0
 @Override
 public void postToFeed(
     final User user,
     final Entity entity,
     final Point originalPoint,
     final Value value,
     final FeedType type)
     throws NimbitsException {
   final Point point = getFeedPoint(user);
   if (point != null) {
     final FeedValue feedValue =
         new FeedValueModel(valueToHtml(entity, originalPoint, value), value.getData(), type);
     final String json = GsonFactory.getSimpleInstance().toJson(feedValue);
     final Value v = ValueModelFactory.createValueModel(value, json);
     RecordedValueServiceFactory.getInstance().recordValue(user, point, v, false);
   }
 }