예제 #1
0
 function generateProfileArticleRelationship($profilesToCreate)
 {
     if ($profilesToCreate) {
         // chamar serviço de associar palavras do perfil com os artigos
         // deste resultado tratar o xml para
         // gerar registros na tabela de profile_article,
         // associando perfil a PID do artigo
         $trigramaService = new TrigramaService();
         $articleDAO = new ArticleDAO();
         $profileArticleDAO = new ProfileArticleDAO();
         foreach ($profilesToCreate as $newProfile) {
             $subArea = new SubArea();
             $subArea->setID($newProfile->getSubAreaID());
             $subArea->loadSubArea();
             $grandeArea = new GrandeArea();
             $grandeArea->setLang('');
             $grandeArea->setID($newProfile->getGrandeAreaID());
             $grandeArea->loadGrandeArea();
             $trigramaString = "";
             $trigramaString .= $newProfile->getProfileText();
             $trigramaString .= " " . $subArea->getDescricao();
             $trigramaString .= " " . $grandeArea->getDescricao();
             $trigramaService->setParams($trigramaString);
             $articles = $trigramaService->getArticles();
             $profileArticleDAO->setAsDeleted($newProfile->getProfileID());
             foreach ($articles as $article) {
                 $foundArticle = $articleDAO->getArticle($article->getPID());
                 if (!$foundArticle || !$foundArticle->getPID()) {
                     $articleDAO->AddArticle($article);
                 } else {
                     $articleDAO->UpdateArticle($article);
                 }
                 $foundProfileArticle = $profileArticleDAO->getProfileArticle($article->getPID(), $newProfile->getProfileID());
                 $profileArticle = new ProfileArticle();
                 $profileArticle->setPID($article->getPID());
                 $profileArticle->setProfileID($newProfile->getProfileID());
                 $profileArticle->setRelevance($article->getRelevance());
                 if ($foundProfileArticle->getIsNew() == "3") {
                     $profileArticle->setIsNew(0);
                     $profileArticleDAO->UpdateProfileArticle($profileArticle);
                 } else {
                     $profileArticle->setIsNew(1);
                     $profileArticleDAO->AddProfileArticle($profileArticle);
                 }
             }
             $profileArticleDAO->deleteRelationship($newProfile->getProfileID());
         }
     }
 }
예제 #2
0
파일: Article.php 프로젝트: Ethennoob/Web
 function addArticle()
 {
     if (!$this->articleExists()) {
         $articleDAO = new ArticleDAO();
         $articleDAO->AddArticle($this);
     }
 }