示例#1
0
 /**
 * Carrega nos campos da classe os valores que estão armazenados no Banco de Dados
 * @param integer $ID IDentificador do usuário
 * @returns integer $sucess 1 em caso de sucesso, 0 em caso de erro
 */
 function load($p)
 {
     $profile_article = new ProfileArticle();
     $profile_article->setPID($p['PID']);
     $profile_article->setProfileID($p['profile_id']);
     $profile_article->setPublicationDate($p['process_date']);
     $profile_article->setRelevance($p['relevance']);
     $profile_article->setIsNew($p['is_new']);
     return $profile_article;
 }
示例#2
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());
         }
     }
 }