Esempio n. 1
0
  private Point createFeedPoint(final User user) throws NimbitsException {

    final EntityName name =
        CommonFactoryLocator.getInstance().createName(Const.TEXT_DATA_FEED, EntityType.point);

    final Entity entity =
        EntityModelFactory.createEntity(
            name,
            "",
            EntityType.feed,
            ProtectionLevel.onlyConnection,
            user.getKey(),
            user.getKey(),
            UUID.randomUUID().toString());
    // final Entity r = EntityServiceFactory.getInstance().addUpdateEntity(user, entity);

    Point point = PointModelFactory.createPointModel(entity);

    final Point result = (Point) EntityServiceFactory.getInstance().addUpdateEntity(point);

    postToFeed(
        user,
        "A new data point has been created for your data feed. Your data feed is just "
            + "a data point. Points are capable of storing numbers, text, json and xml data. Nimbits uses "
            + "a single data point to drive this feed.",
        FeedType.info);
    return result;
  }
Esempio n. 2
0
  private Point getFeedPoint(final User user) throws NimbitsException {
    final Point point;
    final Map<String, Entity> map =
        EntityServiceFactory.getInstance().getEntityMap(user, EntityType.feed, 1);

    if (map.isEmpty()) {
      point = createFeedPoint(user);
    } else {
      return (Point) map.values().iterator().next();
    }
    return point;
  }