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()); } } }
function loadArticle() { $articleDAO = new ArticleDAO(); $a = $articleDAO->getArticle($this->getPID()); $this->setPID($a->getPID()); $this->setURL($a->getURL()); $this->setTitle($a->getTitle()); $this->setSerial($a->getSerial()); $this->setVolume($a->getVolume()); $this->setNumber($a->getNumber()); $this->setSuppl($a->getSuppl()); $this->setYear($a->getYear()); $this->setAuthorXML($a->getAuthorXML()); $this->setKeywordXML($a->getKeywordXML()); $this->setAbstractXML($a->getAbstractXML()); }