Search in sources :

Example 36 with Image

use of ai.elimu.model.content.multimedia.Image in project webapp by elimu-ai.

the class BaseDaoTest method testCreate.

@Test
public void testCreate() {
    Image image1 = new Image();
    image1.setTitle("Title1");
    imageDao.create(image1);
    assertNotNull(image1.getId());
    Image image2 = new Image();
    image2.setTitle("Title1");
    imageDao.create(image2);
    assertNotNull(image2.getId());
}
Also used : Image(ai.elimu.model.content.multimedia.Image) Test(org.junit.Test)

Example 37 with Image

use of ai.elimu.model.content.multimedia.Image in project webapp by elimu-ai.

the class ImageDaoTest method testReadAllLabeled.

@Test
public void testReadAllLabeled() {
    Word wordDog = new Word();
    wordDog.setText("dog");
    wordDao.create(wordDog);
    Word wordCat = new Word();
    wordCat.setText("cat");
    wordDao.create(wordCat);
    List<Image> images = imageDao.readAllLabeled(wordCat);
    assertThat(images.size(), is(0));
    Set<Word> words = new HashSet<>();
    words.add(wordCat);
    Image image = new Image();
    image.setTitle("image");
    image.setWords(words);
    imageDao.create(image);
    images = imageDao.readAllLabeled(wordDog);
    assertThat(images.size(), is(0));
    images = imageDao.readAllLabeled(wordCat);
    assertThat(images.size(), is(1));
    assertThat(images.get(0).getWords().size(), is(1));
    words.add(wordDog);
    image.setWords(words);
    imageDao.update(image);
    images = imageDao.readAllLabeled(wordCat);
    assertThat(images.size(), is(1));
    assertThat(images.get(0).getWords().size(), is(2));
}
Also used : Word(ai.elimu.model.content.Word) Image(ai.elimu.model.content.multimedia.Image) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 38 with Image

use of ai.elimu.model.content.multimedia.Image in project webapp by elimu-ai.

the class ImageCreateController method handleRequest.

@RequestMapping(method = RequestMethod.GET)
public String handleRequest(Model model) {
    logger.info("handleRequest");
    Image image = new Image();
    model.addAttribute("image", image);
    model.addAttribute("contentLicenses", ContentLicense.values());
    model.addAttribute("literacySkills", LiteracySkill.values());
    model.addAttribute("numeracySkills", NumeracySkill.values());
    model.addAttribute("timeStart", System.currentTimeMillis());
    return "content/multimedia/image/create";
}
Also used : Image(ai.elimu.model.content.multimedia.Image) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Image (ai.elimu.model.content.multimedia.Image)38 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)31 StoryBook (ai.elimu.model.content.StoryBook)11 Word (ai.elimu.model.content.Word)11 Contributor (ai.elimu.model.Contributor)8 IOException (java.io.IOException)8 Audio (ai.elimu.model.content.multimedia.Audio)7 StoryBookChapter (ai.elimu.model.content.StoryBookChapter)5 StoryBookParagraph (ai.elimu.model.content.StoryBookParagraph)5 StoryBookContributionEvent (ai.elimu.model.contributor.StoryBookContributionEvent)5 ArrayList (java.util.ArrayList)5 Letter (ai.elimu.model.content.Letter)4 Language (ai.elimu.model.v2.enums.Language)4 Test (org.junit.Test)4 Syllable (ai.elimu.model.content.Syllable)3 ImageContributionEvent (ai.elimu.model.contributor.ImageContributionEvent)3 HashSet (java.util.HashSet)3 Emoji (ai.elimu.model.content.Emoji)2 Number (ai.elimu.model.content.Number)2 AudioContributionEvent (ai.elimu.model.contributor.AudioContributionEvent)2