Package es.udc.tfg.journals.model.keyword

Examples of es.udc.tfg.journals.model.keyword.Keyword


  @Before
  public void setUp() throws Exception {
    journalService.createJournal(new Journal("", null, null, null, null));
    keywordService.createKeywordWeightJournal(new KeywordWeightJournal(
        new KeywordWeight(10, new Keyword("etiqueta")), journalService
            .findJournalByName("")));
  }
View Full Code Here


  }

  @Test
  public void testCreateKeywordAndFindKeyword()
      throws InstanceNotFoundException, DuplicateInstanceException {
    Keyword keyword = keywordService.createKeyword(new Keyword(
        "primera etiqueta"));

    Keyword keyword2 = keywordService.findKeywordByName("primera etiqueta");

    assertEquals(keyword, keyword2);

    keyword2 = keywordService.findKeyword(keyword.getKeywordId());

    assertEquals(keyword, keyword2);

    keyword2 = keywordService
        .createKeyword(new Keyword("primera etiqueta"));

    assertEquals(keyword, keyword2);

  }
View Full Code Here

    Journal j = new Journal("journal test", "jo tes", "http://url.test",
        50, 20);
    journalService.createJournal(j);

    Keyword k = new Keyword("etiqueta test");

    KeywordWeight kw = new KeywordWeight(0, user, k);

    KeywordWeightJournal kwj = new KeywordWeightJournal(kw, j);

    keywordService.createKeywordWeightJournal(kwj);

    Keyword k3 = keywordService.findKeywordByName("etiqueta test");

    assertEquals(k, k3);

  }
View Full Code Here

    Journal j2 = new Journal("journal test 2", "jo tes",
        "http://url.test2", 30, 60);
    journalService.createJournal(j1);
    journalService.createJournal(j2);

    Keyword k1 = new Keyword("etiqueta test comun");
    Keyword k2 = new Keyword("etiqueta test 2 journal");
    Keyword k3 = new Keyword("etiqueta 3 primera");

    KeywordWeight kw1 = new KeywordWeight(0, user, k1);
    KeywordWeight kw2 = new KeywordWeight(100, user, k2);
    KeywordWeight kw3 = new KeywordWeight(50, user, k3);
View Full Code Here

    Journal j1 = new Journal("journal test 1", "jo tes",
        "http://url.test1", 50, 20);
    journalService.createJournal(j1);

    Keyword k1 = new Keyword("etiqueta test comun");
    Keyword k2 = new Keyword("etiqueta test 2 journal");

    KeywordWeight kw1 = new KeywordWeight(0, user, k1);
    KeywordWeight kw2 = new KeywordWeight(100, user, k2);
    KeywordWeight kw3 = new KeywordWeight(50, user, k1);

    KeywordWeightJournal kwj1 = new KeywordWeightJournal(kw1, j1);
    KeywordWeightJournal kwj2 = new KeywordWeightJournal(kw2, j1);
    KeywordWeightJournal kwj3 = new KeywordWeightJournal(kw3, j1);

    keywordService.createKeywordWeightJournal(kwj1);
    keywordService.createKeywordWeightJournal(kwj2);
    keywordService.createKeywordWeightJournal(kwj3);

    List<String> keywords = keywordService.findKeywordsByJournal(j1
        .getJournalId());
    assertEquals(2, keywords.size());

    assertTrue(keywords.contains(WordUtils.capitalize(k1.getName())));
    assertTrue(keywords.contains(WordUtils.capitalize(k2.getName())));
  }
View Full Code Here

    // Revista null
    Journal jnull = new Journal("", null, null, null, null);
    journalService.createJournal(jnull);
    keywordService.createKeywordWeightJournal(new KeywordWeightJournal(
        new KeywordWeight(1, user1, new Keyword("aditional keyword")),
        jnull));
  }
View Full Code Here

  }

  public void createListOfKeywords(String[] keys, User user, Journal journal,
      int weight) throws InstanceNotFoundException,
      DuplicateInstanceException {
    Keyword keyword;
    Map<Long, KeywordWeight> keywordWeightsMap = keywordWeightJournalDao
        .findKeywordWeighJournalsByJournalAndKeyword(journal
            .getJournalId());
    for (String key : keys) {
      key = key.toLowerCase().trim();
      try {
        keyword = keywordDao.findByName(key);
        // If the keyword already exists is modified
        KeywordWeight kw = keywordWeightsMap
            .get(keyword.getKeywordId());
        if (kw == null) {
          throw new InstanceNotFoundException("", null);
        }

        if (kw.getUsers().contains(user)) {
          // TODO: Sumar siempre? (si aparece en domain y en subdomain
          // serian 50.000
          if (!user.admin()) {
            throw new DuplicateInstanceException(key,
                KeywordWeight.class.getName());
          }
        }
        weight += kw.getWeight();
        kw.setWeight(weight);
        kw.addUser(user);
      } catch (InstanceNotFoundException e) {
        keyword = new Keyword(key);
        KeywordWeight kw = new KeywordWeight(weight, user, keyword);
        KeywordWeightJournal kwj = new KeywordWeightJournal(kw, journal);
        createKeywordWeightJournal(kwj);
      }
    }
View Full Code Here

  }

  public void createListOfKeywords(HashMap<String, Integer> keywords,
      User user, Journal journal) throws InstanceNotFoundException,
      DuplicateInstanceException {
    Keyword keyword;
    String key;
    int weight;

    List<String> s = new ArrayList<String>();
    for (String aux : keywords.keySet()) {
      s.add(aux);
    }
    Map<String, Keyword> keywordsMap = keywordDao.findKeywords(s);
    Map<Long, KeywordWeight> keywordWeightsMap = keywordWeightJournalDao
        .findKeywordWeighJournalsByJournalAndKeyword(journal
            .getJournalId());

    for (Map.Entry<String, Integer> entry : keywords.entrySet()) {
      key = entry.getKey();
      key = key.toLowerCase().trim();
      try {
        keyword = keywordsMap.get(key);
        if (keyword == null) {
          throw new InstanceNotFoundException("", null);
        }
        // If the keyword already exists is modified
        KeywordWeight kw = keywordWeightsMap
            .get(keyword.getKeywordId());
        if (kw == null) {
          throw new InstanceNotFoundException("", null);
        }

        if (kw.getUsers().contains(user)) {
          if (!user.admin()) {
            throw new DuplicateInstanceException(key,
                KeywordWeight.class.getName());
          }
        }
        weight = entry.getValue();
        weight += kw.getWeight();
        kw.setWeight(weight);
        kw.addUser(user);
      } catch (InstanceNotFoundException e) {
        keyword = new Keyword(key);
        weight = entry.getValue();
        KeywordWeight kw = new KeywordWeight(weight, user, keyword);
        KeywordWeightJournal kwj = new KeywordWeightJournal(kw, journal);
        createKeywordWeightJournal(kwj);
      }
View Full Code Here

    }
  }

  Object onAddRow() {
    KeywordWeight kw;
    kw = new KeywordWeight(1, new Keyword());

    keywordwlist.add(kw);
    return kw;
  }
View Full Code Here

TOP

Related Classes of es.udc.tfg.journals.model.keyword.Keyword

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.