Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.Text


      String value) {
    if (value == null) {
      entity.setProperty(name, null);
    }
    else {
      entity.setProperty(name, new Text(value));
    }
  }
View Full Code Here


          if (fieldClass == Json.class) {
            value = value.toString();
          } else if (value instanceof String) {
            String s = (String) value;
            if (s.length() > 500)
              value = new Text(s);
          } else if (value instanceof byte[]) {
            byte[] arr = (byte[]) value;
            // GAE Blob doesn't accept more than 1MB
            if (arr.length < 1000000)
              value = new Blob(arr);
            else
              value = new Blob(Arrays.copyOf(arr, 1000000));
          }
          else if (ClassInfo.isEmbedded(field)) {
            Embedded embed = field.getAnnotation(Embedded.class);
            switch(embed.mode()){
            case SERIALIZE_JSON:
              value = JsonSerializer.serialize(value).toString();
              String s = (String) value;
              if (s.length() > 500)
                value = new Text(s);
              break;
            case SERIALIZE_JAVA:
              // this embedding mode doesn't manage @EmbedIgnores
              try {
                byte[] b = JavaSerializer.serialize(value);
View Full Code Here

        if (fieldClass == Json.class) {
          propValue = propValue.toString();
        } else if (propValue instanceof String) {
          String s = (String) propValue;
          if (s.length() > 500)
            propValue = new Text(s);
        } else if (propValue instanceof byte[]) {
          byte[] arr = (byte[]) propValue;
          // GAE Blob doesn't accept more than 1MB
          if (arr.length < 1000000)
            propValue = new Blob(arr);
          else
            propValue = new Blob(Arrays.copyOf(arr, 1000000));
        }
        else if (ClassInfo.isEmbedded(f)) {
          Embedded embed = f.getAnnotation(Embedded.class);
          switch(embed.mode()){
          case SERIALIZE_JSON:
            propValue = JsonSerializer.serialize(propValue).toString();
            String s = (String) propValue;
            if (s.length() > 500)
              propValue = new Text(s);
            break;
          case SERIALIZE_JAVA:
            // this embedding mode doesn't manage @EmbedIgnores
            try {
              byte[] b = JavaSerializer.serialize(propValue);
View Full Code Here

      return false;
    Key sender_key = sender_entity.getKey();
    Transaction txn = datastore.beginTransaction();
    Entity sender_feed = new Entity(FEED_KIND, sender_key);
    sender_feed.setProperty(FEED_READ_STATUS_PROPERTY, false);
    sender_feed.setProperty(FEED_MESSAGE_PROPERTY, new Text(message));
    sender_feed.setProperty(FEED_TIMESTAMP_PROPERTY, new Date());
    datastore.put(sender_feed);
    txn.commit();
    return true;
  }
View Full Code Here

      q_feed.addFilter(FEED_READ_STATUS_PROPERTY, FilterOperator.EQUAL, false);
    PreparedQuery pq_feed = datastore.prepare(q_feed);
    List<Entity> entityList = pq_feed.asList(FetchOptions.Builder.withDefaults());
    for(Iterator<Entity> i = entityList.iterator(); i.hasNext();) {
      Entity e_feed = i.next();
      Text feed_message_t = (Text)e_feed.getProperty(FEED_MESSAGE_PROPERTY);
      String feed_message = feed_message_t.getValue();
      boolean feed_read = (Boolean)e_feed.getProperty(FEED_READ_STATUS_PROPERTY);
      Date feed_timestamp = (Date)e_feed.getProperty(FEED_TIMESTAMP_PROPERTY);
      feeds.add(new SubscriptionFeedObject(feed_read, feed_message, feed_timestamp));
      if(setRead) {
        e_feed.setProperty(FEED_READ_STATUS_PROPERTY, true);
View Full Code Here

   */
  public void transformHalfVideoEntry(VideoEntry entry) {
    this.tubeId = (entry.getMediaGroup().getVideoId());
    if (entry.getMediaGroup().getThumbnails() != null
        && entry.getMediaGroup().getThumbnails().size() > 1) {
      this.thumbImageUrl = (new Text(entry.getMediaGroup()
          .getThumbnails().get(1).getUrl()));
    }
    this.title = (new Text(entry.getMediaGroup().getTitle()
        .getPlainTextContent()));

    if (entry.getMediaGroup().getDescription() != null) {
      this.description = (new Text(entry.getMediaGroup().getDescription()
          .getPlainTextContent()));
    }
    this.alias = (new Text(StringHelper.getAliasByLanguage(this.getTitle()
        .getValue())));

    this.authorUrl = (entry.getAuthors().get(0).getUri());
    if (entry.getStatistics() != null) {
      this.viewCount = entry.getStatistics().getViewCount();
    }
    if (entry.getMediaGroup().getDuration() != null) {
      Long duration = entry.getMediaGroup().getDuration();
      int hours = (int) (duration / 3600);
      int remainder = (int) (duration - hours * 3600);
      int minutes = remainder / 60;
      remainder = remainder - minutes * 60;
      int second = remainder;
      this.duration = (duration);
      this.totalTime = (new Text(((hours > 0) ? (hours + ":") : "")
          + ((minutes > 9) ? minutes : ("0" + minutes)) + ":"
          + ((second > 9) ? second : ("0" + second))));
    }
  }
View Full Code Here

      throws MalformedURLException, IOException, ServiceException {
    // core.
    this.tubeId = (videoEntry.getMediaGroup().getVideoId());
    if (videoEntry.getMediaGroup().getThumbnails() != null
        && videoEntry.getMediaGroup().getThumbnails().size() > 1) {
      this.thumbImageUrl = (new Text(videoEntry.getMediaGroup()
          .getThumbnails().get(1).getUrl()));
    }
    this.title = (new Text(videoEntry.getMediaGroup().getTitle()
        .getPlainTextContent()));
    if (videoEntry.getMediaGroup().getDescription() != null) {
      this.description = (new Text(videoEntry.getMediaGroup()
          .getDescription().getPlainTextContent()));
    }
    this.alias = (new Text(StringHelper.getAliasByLanguage(this.getTitle()
        .getValue())));

    this.authorUrl = (videoEntry.getAuthors().get(0).getUri());
    if (videoEntry.getStatistics() != null) {
      this.viewCount = videoEntry.getStatistics().getViewCount();
    }
    if (videoEntry.getMediaGroup().getDuration() != null) {
      Long duration = videoEntry.getMediaGroup().getDuration();
      int hours = (int) (duration / 3600);
      int remainder = (int) (duration - hours * 3600);
      int minutes = remainder / 60;
      remainder = remainder - minutes * 60;
      int second = remainder;
      this.duration = (duration);
      this.totalTime = (new Text(((hours > 0) ? (hours + ":") : "")
          + ((minutes > 9) ? minutes : ("0" + minutes)) + ":"
          + ((second > 9) ? second : ("0" + second))));
    }

    // advanced.

    this.published = (new Date(videoEntry.getPublished().getValue()));
    CacheHelper.initCache();
    if (videoEntry.getMediaGroup().getKeywords() != null) {
      List<Text> listKey = new ArrayList<Text>();
      for (String keyword : videoEntry.getMediaGroup().getKeywords()
          .getKeywords()) {
        Tag tmpTag = null;
        listKey.add(new Text(keyword));
        String tagAlias = keyword;
        tmpTag = TagModel.getByAlias(tagAlias);
        List<Text> listTubeId = new ArrayList<Text>();
        if (tmpTag != null) {
          tmpTag.setCount(tmpTag.getCount() + 1);
          listTubeId.addAll(tmpTag.getListTubeId());
          listTubeId.add(new Text(this.tubeId));
          tmpTag.setListTubeId(listTubeId);
          TagModel.update(tmpTag);
          TagModel.closePM();
        } else {
          tmpTag = new Tag();
          listTubeId.add(new Text(this.tubeId));
          tmpTag.setListTubeId(listTubeId);
          tmpTag.setAlias(tagAlias);
          tmpTag.setCount(1);
          tmpTag.setTitle(new Text(tagAlias));
          TagModel.add(tmpTag);
        }
      }
      this.keywords = listKey;
      CacheHelper.addKeywords(listKey);
View Full Code Here

    if (tmp != null) {
      this.alias = (tmp.text());
    }
    tmp = doc.select("thumbImageUrl");
    if (tmp != null) {
      this.thumbImageUrl = (new Text(tmp.text()));
    }
    tmp = doc.select("title");
    if (tmp != null) {
      this.title = (new Text(tmp.text()));
    }
  }
View Full Code Here

    // if (user != null) {
    String action = req.getParameter("action");
    if (action.equalsIgnoreCase("create")) {
      Category cate = new Category();
      if (req.getParameter("title") != null) {
        cate.setTitle(new Text(req.getParameter("title")));
      }
      if (req.getParameter("description") != null) {
        cate.setDescription(new Text(req.getParameter("description")));
      }
      Map<String, List<BlobKey>> blobs = blobstoreService.getUploads(req);
      List<BlobKey> blobKeys = blobs.get("myFile");
      if (blobKeys != null && blobKeys.size() > 0) {
        cate.setThumbImageUrl(new Text("/image?key="
            + blobKeys.get(0).getKeyString()));
      }
      cate.setCount(0);
      cate.setStatus(1);
      cate.setAlias(StringHelper.getAliasByLanguage(cate.getTitle()
View Full Code Here

      List<String> cachedKeywords = (List<String>) cache
          .get("cachedKeywords");
      Random rand = new Random();
      if (cachedKeywords.size() > 0) {
        for (int i = 0; i < 30; i++) {
          Text toAdd = new Text(cachedKeywords.get(rand
              .nextInt(cachedKeywords.size())));
          if (!result.contains(toAdd)) {
            result.add(toAdd);
          }
          if (result.size() == 16) {
View Full Code Here

TOP

Related Classes of com.google.appengine.api.datastore.Text

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.