Package talkfeed.data

Examples of talkfeed.data.DataManager


   * @param id
   * @return
   */
  public boolean removeUserSubscription(long id) {

    DataManager dm = DataManagerFactory.getInstance();
    PersistenceManager pm = dm.newPersistenceManager();

    Subscription s = pm.getObjectById(Subscription.class, new Long(id));
    pm.currentTransaction().begin();
    pm.deletePersistent(s);
    pm.currentTransaction().commit();
View Full Code Here


   */
  public boolean removeUserSubscription(String email, final long blogId) {
   
    email = TextTools.cleanJID(email);
   
    DataManager dm = DataManagerFactory.getInstance();
    PersistenceManager pm = dm.newPersistenceManager();

    Query qUser = pm.newQuery(User.class);
    qUser.setFilter("id == email");
    qUser.declareParameters("String email");
    qUser.setRange(0, 1);
View Full Code Here

   * Add or create user
   * @param email
   */
  public User getOrCreateUser(){

    DataManager dm = DataManagerFactory.getInstance();

    //check is user exists, if not, create it
    //clean email
    String jid = TextTools.cleanJID(this.user);

    User user = dm.getUserFromId(getPersitence(), jid);
    if (user == null){
      user = new User();
      user.setId(jid);
      user.setDateCrea(new Date());
      user.setNextUpdate(new Date());
View Full Code Here

    //Retrieve user id
    String id = args.get("id");
    String link = args.get("link");
   
    BlogManager blogManager = BlogManager.getInstance();
    DataManager dataManager = DataManagerFactory.getInstance();
    PersistenceManager pm = dataManager.newPersistenceManager();
   
    //get user
    User user = dataManager.getUserFromId(pm , id);
   
    //check if blog exists
    Blog blog = blogManager.getOrCreateSource(link);
   
    if (blog == null){
      //blog not found or not avaiable
      TalkService.sendMessage(user.getId(),"blog not found ! :(");
      return;
    }
   
    //check subscription
    Subscription sub = dataManager.getSubscription(pm , user, blog);
   
    //create new subscription
    if (sub == null){
      sub = new Subscription();
      sub.setBlogKey(blog.getKey());
View Full Code Here

    }

    resp.addCookie(new Cookie("username", googleUser.getEmail()));
   

    DataManager dm = DataManagerFactory.getInstance();
    PersistenceManager pm = dm.newPersistenceManager();

    // fetch user
    Query qUser = pm.newQuery(talkfeed.data.User.class);
    qUser.setFilter("id == param");
    qUser.declareParameters("String param");
View Full Code Here

    }
  }

  @RequestMapping(value = "/ajax/posts.*", method = RequestMethod.GET)
  public ModelAndView ajaxLastEntries(long blogId) {
    DataManager dm = DataManagerFactory.getInstance();
    PersistenceManager pm = dm.newPersistenceManager();

    // select subscriptions
    Query q = pm.newQuery(BlogEntry.class);
    q.setOrdering("pubDate desc");
    q.setRange(0, 15);
View Full Code Here

    calLongTime.set(Calendar.YEAR, 1900);
   
    //prepare link
    link = TextTools.purgeLink(link);
   
    DataManager dm = DataManagerFactory.getInstance();
    PersistenceManager pm = dm.newPersistenceManager();
   
    //find if blog already exists in database
    Blog blog = dm.getBlogFromLink(pm , link);

    if (blog == null) {
      //blog does not exist : load content to parse it
      String content = DocumentLoader.loadPage(link);
      String rss = null;
     
      //test if given link is already RSS or Atom FEED
      if (FeedManager.isFeed(content)){
        rss = link;
      }else {
        //extract RSS link from page content
        rss = TextTools.extractRssFromPage(content);
      }

      //test if rss information hase been found
      if (rss != null){
        //check again if blog exists with given link
        blog = dm.getBlogFromLink(pm , rss);
        //actually create new blog in database
        if (blog == null){
          blog = new Blog();
          blog.setLatestEntry(calLongTime.getTime());
          blog.setNextUpdate(now);
View Full Code Here

   */
  @Deprecated
  public void updateBlogs(int nbMax){
    if (nbMax <=0) return;
   
    DataManager dm = DataManagerFactory.getInstance();
    PersistenceManager pm = dm.newPersistenceManager();
   
    //find blogs where "nextUpdate" is before now, ordered by "nextUpdate" date
    Query q = pm.newQuery(Blog.class);
    q.setRange(0, nbMax);
    q.setFilter("nextUpdate <= date");
View Full Code Here

   * Update single blog (for queued task usage)
   * @param id
   */
  public void updateBlog(long id){
   
    DataManager dm = DataManagerFactory.getInstance();
    PersistenceManager pm = dm.newPersistenceManager();
   
    //find blog
    Blog blog = pm.getObjectById(Blog.class,id);
   
    //check if blog has any updates
View Full Code Here

   * @return
   */
  public int removeBlogWithoutSubscription(){
    int nb = 0;
   
    DataManager dm = DataManagerFactory.getInstance();
   
    PersistenceManager pm = dm.newPersistenceManager();
   
    Query q = pm.newQuery(Blog.class);
   
    //fetch ALL blogs
    @SuppressWarnings("unchecked")
View Full Code Here

TOP

Related Classes of talkfeed.data.DataManager

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.