示例#1
0
  public static void savePictureData(
      String url,
      String styles,
      String colors,
      String length,
      String brands,
      String salonKey,
      String stylistUsername,
      String userUsername) {

    Picture pic = Picture.read(url);

    pic.styles = Tag.convertStringListToTagList(Arrays.asList(styles.split("\\s*,\\s*")));
    pic.colors = Tag.convertStringListToTagList(Arrays.asList(colors.split("\\s*,\\s*")));
    pic.length = Tag.convertStringListToTagList(Arrays.asList(length.split("\\s*,\\s*")));
    pic.brands = Tag.convertStringListToTagList(Arrays.asList(brands.split("\\s*,\\s*")));

    pic.salon = Salon.read(salonKey);
    pic.stylist = Stylist.readByUsername(stylistUsername);
    pic.user = User.read(userUsername);

    pic.salonKey = salonKey;
    pic.stylistUsername = stylistUsername;
    pic.userUsername = userUsername;

    pic.save();
  }
示例#2
0
 @Test
 public void findRepostByTags_Entity_複数_00() {
   Tag tag1 = Tag.findBySerialCode("tag-goro-red").first();
   Tag tag2 = Tag.findBySerialCode("tag-jiro-hello").first();
   List<RepostBase> lst = RepostBase.findRepostByTags(tag1, tag2).fetch();
   assertThat(lst.size(), is(5));
   // DBからの取得リストの並び保証なし
 }
示例#3
0
 @Test
 public void findRepostByTags_Entity_複数_投稿者_00() {
   Tag tag1 = Tag.findBySerialCode("tag-goro-red").first();
   Tag tag2 = Tag.findBySerialCode("tag-jiro-hello").first();
   Account acnt = Account.findByLoginName("goro_san").first();
   List<RepostBase> lst = RepostBase.findRepostByTags(tag1, tag2).contributor(acnt).fetch();
   assertThat(lst.size(), is(3));
   // DBからの取得リストの並び保証なし
 }
示例#4
0
 public void putNewTagsInTagList() {
   List<String> tags = Picture.listtags();
   Iterator<String> itr = tags.iterator();
   while (itr.hasNext()) {
     String value = itr.next();
     Tag tag = new Tag(value);
     tag.save();
   }
 }
示例#5
0
 @Test
 public void findRepostByTags_Entity_複数_投稿者_降順_00() {
   Tag tag1 = Tag.findBySerialCode("tag-goro-red").first();
   Tag tag2 = Tag.findBySerialCode("tag-jiro-hello").first();
   Account acnt = Account.findByLoginName("goro_san").first();
   List<RepostBase> lst =
       RepostBase.findRepostByTags(tag1, tag2)
           .contributor(acnt)
           .orderBy(RepostBase.OrderBy.DATE_OF_REPOST_DESC)
           .fetch();
   assertThat(lst.size(), is(3));
   assertThat(lst.get(0).getLabel().serialCode, is("tag-goro-red"));
 }
示例#6
0
  @Test
  public void testTags() {

    // Create a new user and save it
    User bob = new User("*****@*****.**", "secret", "Bob").save();

    // Create a new post
    Post bobPost = new Post(bob, "My first post", "Hello world").save();
    Post anotherBobPost = new Post(bob, "Hop", "Hello world").save();

    // Well
    assertEquals(0, Post.findTaggedWith("Red").size());

    // Tag it now
    bobPost.tagItWith("Red").tagItWith("Blue").save();
    anotherBobPost.tagItWith("Red").tagItWith("Green").save();

    // Check
    assertEquals(2, Post.findTaggedWith("Red").size());
    assertEquals(1, Post.findTaggedWith("Blue").size());
    assertEquals(1, Post.findTaggedWith("Green").size());

    // Check for multiple tags
    assertEquals(1, Post.findTaggedWith("Red", "Blue").size());
    assertEquals(1, Post.findTaggedWith("Red", "Green").size());
    assertEquals(0, Post.findTaggedWith("Red", "Green", "Blue").size());
    assertEquals(0, Post.findTaggedWith("Green", "Blue").size());

    // Check for tag cloud
    List<Map> cloud = Tag.getCloud();
    assertEquals(
        "[{tag=Blue, pound=1}, {tag=Green, pound=1}, {tag=Red, pound=2}]", cloud.toString());
  }
示例#7
0
 public static Tag findOrCreateByName(String name) {
   Tag tag = Tag.find("byName", name).first();
   if (tag == null) {
     tag = new Tag(name);
   }
   return tag;
 }
示例#8
0
文件: Admin.java 项目: nateki/yabe
 public static void save(Long id, String title, String content, String tags) {
   Post post;
   if (id == null) {
     // Create post
     User author = User.find("byEmail", Security.connected()).first();
     post = new Post(author, title, content);
   } else {
     // Retrieve post
     post = Post.findById(id);
     // Edit
     post.title = title;
     post.content = content;
     post.tags.clear();
   }
   // Set tags list
   for (String tag : tags.split("\\s+")) {
     if (tag.trim().length() > 0) {
       post.tags.add(Tag.findOrCreateByName(tag));
     }
   }
   // Validate
   validation.valid(post);
   if (validation.hasErrors()) {
     render("@form", post);
   }
   // Save
   post.save();
   index();
 }
示例#9
0
 public static List<Map> getCloud() {
   List<Map> result =
       models.Tag.find(
               "select new map(t.name as tag, count(p.id) as pound) from Post p join p.tags as t group by t.name order by t.name")
           .fetch();
   return result;
 }
示例#10
0
文件: Admin.java 项目: phaus/agora
 public static void index() {
   if (activeUser.isAdmin()) {
     Map<String, Long> stats = new TreeMap<String, Long>();
     stats.put("Dates", DateDim.count());
     stats.put("Sections", Section.count());
     stats.put("Forums", Forum.count());
     stats.put("Entries", Entry.count());
     stats.put("Threads", Thread.count());
     stats.put("Posts", Post.count());
     stats.put("Users", User.count());
     stats.put("Tags", Tag.count());
     render(stats);
   } else {
     forbidden();
   }
 }
示例#11
0
 public Post tagItWith(String name) {
   this.tags.add(Tag.findOrCreateByName(name));
   return this;
 }
示例#12
0
 public void tagWith(String tag) {
   tags.add(Tag.findOrCreateByName(tag));
 }