Package com.apress.prospring3.springblog

Examples of com.apress.prospring3.springblog.JpaEntryTest


    String subject = "%";
    String categoryId = "Spring";
    DateTime fromPostDate = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime("1900-01-01");
    DateTime toPostDate = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime("2011-12-18");
   
    SearchCriteria searchCriteria = new SearchCriteria();
    searchCriteria.setSubject(subject);
    searchCriteria.setCategoryId(categoryId);
    searchCriteria.setFromPostDate(fromPostDate);
    searchCriteria.setToPostDate(toPostDate);
   
    Page<Entry> entries = entryService.findEntryByCriteria(searchCriteria, pageRequest);
    System.out.println("No. of entries:" + entries.getNumberOfElements());
   
    //Page<Entry> entries = entryService.findAllByPage(pageRequest);
View Full Code Here


    if (toPostDateString == null) {
      toPostDate = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime("2200-12-31");
    } else {
      toPostDate = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(toPostDateString);
   
    SearchCriteria searchCriteria = new SearchCriteria();
    searchCriteria.setSubject(subject);
    searchCriteria.setCategoryId(categoryId);
    searchCriteria.setFromPostDate(fromPostDate);
    searchCriteria.setToPostDate(toPostDate);
   
    // Process order by
    Sort sort = null;
    String orderBy = sortBy;
    if (orderBy != null && orderBy.equals("postDateString")) orderBy = "postDate";
View Full Code Here

    String subject = searchCriteria.getSubject();
    String categoryId = searchCriteria.getCategoryId();
    DateTime fromPostDate = searchCriteria.getFromPostDate();
    DateTime toPostDate = searchCriteria.getToPostDate();
   
    SearchCriteriaPage searchCriteriaPage = new SearchCriteriaPage();
    searchCriteriaPage.setCategoryId(categoryId);
    searchCriteriaPage.setSubject(subject);
    searchCriteriaPage.setFromPostDate(fromPostDate);
    searchCriteriaPage.setToPostDate(toPostDate);
   
    int offset = pageable.getPageNumber() * pageable.getPageSize();
    int limit = pageable.getPageSize();
    searchCriteriaPage.setOffset(offset);
    searchCriteriaPage.setPageSize(limit);
   
    List<Entry> entries = entryMapper.findEntryByCriteria(searchCriteriaPage);
   
    int totalRecordCount = entryMapper.findEntryCountByCriteria(searchCriteriaPage);
   
View Full Code Here

    ctx.load("classpath:mybatis-app-context.xml");
    ctx.refresh();
   
    System.out.println("App context initialized successfully");       

    CategoryService categoryService = ctx.getBean("categoryService", CategoryService.class);
   
    List<Category> categories = categoryService.findAll();
   
    for (Category category: categories) System.out.println("Category: " + category.getCategoryId());
   
    List<Category> parentCategories = categoryService.findAllParentCategory();
   
    List<Category> subCategories;
    for (Category category: parentCategories) {
      System.out.println("Parent Category: " + category.getCategoryId());
     
      subCategories = categoryService.findAllSubCategory(category.getCategoryId());
      for (Category categoryTemp: subCategories) System.out.println("--->Sub Category: " + categoryTemp.getCategoryId());
    }
  }
View Full Code Here

    ctx.load("classpath:jpa-app-context.xml");
    ctx.refresh();
   
    System.out.println("App context initialized successfully");
   
    CategoryService categoryService = ctx.getBean("categoryService", CategoryService.class);
   
    List<Category> categories = categoryService.findAllParentCategory();
   
    for (Category category: categories) {
      System.out.println("Category id: " + category.getCategoryId());
      List<Category> subCategories = categoryService.findAllSubCategory(category.getCategoryId());
      for (Category subCategory: subCategories) {
        System.out.println("Sub-category id: " + subCategory.getCategoryId());
      }
    }
  }
View Full Code Here

    ctx.load("classpath:jpa-app-context.xml");
    ctx.refresh();
   
    System.out.println("App context initialized successfully");
   
    CommentService commentService = ctx.getBean("commentService", CommentService.class);
   
    List<Comment> comments = commentService.findByEntryId(1l);
   
    System.out.println("No of comments: " + comments.size());
   
    for (Comment comment: comments) {
      System.out.println(comment.getPostBy());
    }
   
    List<String> replyTos = commentService.findReplyToByEntryId(3l);
   
    for (String replyTo: replyTos) {
      System.out.println(replyTo);
    }
  }
View Full Code Here

    ctx.load("classpath:jpa-app-context.xml");
    ctx.refresh();
   
    System.out.println("App context initialized successfully");
   
    EntryAuditService entryAuditService = ctx.getBean("entryAuditService", EntryAuditService.class);
 
    List<Entry> entries = entryAuditService.findAuditById(1l);
   
    for (Entry entry: entries) {
      System.out.println(entry);
    }
   
View Full Code Here

    ctx.load("classpath:mybatis-app-context.xml");
    ctx.refresh();
   
    System.out.println("App context initialized successfully");   
   
    EntryService entryService = ctx.getBean("entryService", EntryService.class);
   
    List<Entry> entries = entryService.findByCategoryId("Spring");
   
    for (Entry entry: entries) {
      System.out.println(entry);
   
   
    System.out.println("Finding entry with id 1");
    Entry entry = entryService.findById(1l);
    System.out.println(entry)
   
    // insert entry
    entry = new Entry();
    entry.setSubject("Testing entry clarence");
    entry.setBody("Testing entry clarence");
    entry.setPostDate(new DateTime());
    entry.setCategoryId("Spring");
    entry.setCreatedBy("clarence");
    DateTime currentDateTime = new DateTime();
    entry.setCreatedDate(currentDateTime);
    entry.setLastModifiedBy("clarence");
    entry.setLastModifiedDate(currentDateTime);
    entryService.save(entry);
    System.out.println("New entry insert successfully");
   
        entries = entryService.findByCategoryId("Spring");
   
    for (Entry entryTemp: entries) {
      System.out.println(entryTemp);
    }
   
    // Delete entry
    System.out.println("Deleting entry with id 2");
    entry = entryService.findById(2l);
    entryService.delete(entry);
   
        entries = entryService.findByCategoryId("Spring");
   
    for (Entry entryTemp: entries) {
      System.out.println(entryTemp);
   
   
    // Update entry
    System.out.println("Updating entry with id 1");
    entry = entryService.findById(1l);
    entry.setSubject("Updated entry subject crap");
    currentDateTime = new DateTime();
    entry.setLastModifiedDate(currentDateTime);
    entryService.save(entry);
    System.out.println("Entry updated successfully");
   
        entries = entryService.findByCategoryId("Spring");
   
    for (Entry entryTemp: entries) {
      System.out.println(entryTemp);
    }     
View Full Code Here

    ctx.load("classpath:jpa-app-context.xml");
    ctx.refresh();
   
    System.out.println("App context initialized successfully");
   
    EntryService entryService = ctx.getBean("entryService", EntryService.class);
   
    PageRequest pageRequest = new PageRequest(0, 10);

    String subject = "%";
    String categoryId = "Spring";
    DateTime fromPostDate = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime("1900-01-01");
    DateTime toPostDate = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime("2011-12-18");
   
    SearchCriteria searchCriteria = new SearchCriteria();
    searchCriteria.setSubject(subject);
    searchCriteria.setCategoryId(categoryId);
    searchCriteria.setFromPostDate(fromPostDate);
    searchCriteria.setToPostDate(toPostDate);
   
    Page<Entry> entries = entryService.findEntryByCriteria(searchCriteria, pageRequest);
    System.out.println("No. of entries:" + entries.getNumberOfElements());
   
    //Page<Entry> entries = entryService.findAllByPage(pageRequest);
    //System.out.println("No. of entries:" + entries.getNumberOfElements());
   
View Full Code Here

    ctx.load("classpath:jpa-app-context.xml");
    ctx.refresh();
   
    System.out.println("App context initialized successfully");
   
    EntryService entryService = ctx.getBean("entryService", EntryService.class);
   
    List<Entry> entries = entryService.findByCategoryId("Spring");
   
    for (Entry entry: entries) {
      System.out.println(entry);
    }
   
    System.out.println("Finding entry with id 1");
    Entry entry = entryService.findById(1l);
    System.out.println(entry);
   
    // insert entry
    entry = new Entry();
    //entry.setSubject("Testing entry clarence");
    entry.setSubject("Testing");
    entry.setBody("Testing entry clarence");
    entry.setPostDate(new DateTime());
    entry.setCategoryId("Spring");
    entryService.save(entry);
    System.out.println("New entry insert successfully");
   
        entries = entryService.findByCategoryId("Spring");
   
    for (Entry entryTemp: entries) {
      System.out.println(entryTemp);
    }   
   
    // Delete entry
    System.out.println("Deleting entry with id 2");
    entry = entryService.findById(2l);
    entryService.delete(entry);
   
        entries = entryService.findByCategoryId("Spring");
   
    for (Entry entryTemp: entries) {
      System.out.println(entryTemp);
   
   
    // Update entry
    System.out.println("Updating entry with id 1");
    entry = entryService.findById(1l);
    entry.setSubject("Updated entry subject crap");
    entryService.save(entry);
    System.out.println("Entry updated successfully");
   
        entries = entryService.findByCategoryId("Spring");
   
    for (Entry entryTemp: entries) {
      System.out.println(entryTemp);
      for (EntryAttachment attachment: entryTemp.getAttachments()) {
        System.out.println(attachment);
View Full Code Here

TOP

Related Classes of com.apress.prospring3.springblog.JpaEntryTest

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.