コード例 #1
0
    private static List<String> getMemberIndividuals(String concept_uri) throws Exception {

      List<String> members = new ArrayList<String>();
      IDaoManager daoManager = PersistenceUtil.getDaoManager();

      try {

        IConceptDao conceptDao = daoManager.getConceptDao();
        INamedConcept namedConcept = conceptDao.findByUri(concept_uri);
        IIndividualDao individualDao = daoManager.getIndividualDao();

        if (namedConcept != null) {

          Set<IIndividual> memberIndividuals = individualDao.findMemberIndividuals(namedConcept);

          for (IIndividual member : memberIndividuals) {
            members.add(member.toString());
          }
        }
      } catch (DaoUnavailableException e) {
        s_log.debug("DaoUnavailableException: Error while trying to get daos ...");
        e.printStackTrace();
      }

      return members;
    }
コード例 #2
0
    private ArrayList<String> findNewsArticles(ArrayList<String> keywords) {

      ArrayList<String> matches = new ArrayList<String>();

      //			retrieve all news article ...

      if (m_allNews == null) {

        m_allNews = new ArrayList<String>();
        IDaoManager daoManager = PersistenceUtil.getDaoManager();

        try {

          IConceptDao conceptDao = daoManager.getConceptDao();
          INamedConcept namedConcept = conceptDao.findByUri(m_news_uri);
          IIndividualDao individualDao = daoManager.getIndividualDao();
          Set<IIndividual> memberIndividuals = individualDao.findMemberIndividuals(namedConcept);

          for (IIndividual member : memberIndividuals) {
            m_allNews.add(member.toString());
          }
        } catch (DaoUnavailableException e) {
          e.printStackTrace();
        }
      }

      //			scan all news articles for given keywords

      boolean is_match = true;

      for (String article : m_allNews) {

        is_match = true;

        for (String keyword : keywords) {

          if (!article.toLowerCase().contains(keyword)) {
            is_match = false;
            break;
          }
        }

        if (is_match) {
          matches.add(article);
        }
      }

      return matches;
    }