--- a/Controller/WikiTagController.php Thu Nov 17 12:07:53 2011 +0100
+++ b/Controller/WikiTagController.php Thu Nov 17 16:48:19 2011 +0100
@@ -147,7 +147,9 @@
$id_tag = $this->getRequest()->request->get('tag_id');
// We get the DocumentTag meant to be deleted, and remove it.
$em = $this->getDoctrine()->getEntityManager();
- $dt = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOneBy(array('tag' => $id_tag, 'document' => $id_doc));
+ //TODO: use external id
+
+ $dt = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOneByDocumentExternalId($id_doc, array('tag' => $id_tag));
$em->remove($dt);
$em->flush();
@@ -167,16 +169,16 @@
if($tag_label!=$moved_tag->getLabel()){
// We get the DocumentTags
$em = $this->getDoctrine()->getEntityManager();
- $tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findBy(array('document' => $id_doc));
- $nb_tags = count($tags);
+
+ $tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findByDocumentExternalId($id_doc);
$found = false;
- $i = 0;
- while($i<$nb_tags && $found==false){
- $dt = $tags[$i];
- if($dt->getTag()->getLabel()==$tag_label){
+ foreach ($tags as $dt)
+ {
+ if($dt->getTag()->getLabel()===$tag_label)
+ {
$found = true;
+ break;
}
- $i++;
}
// If the label was found, we sent a bad request
if($found==true){
@@ -189,11 +191,12 @@
$created = $ar[2];
// We get the DocumentTag and change its tag
- $dt = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOneBy(array('document' => $id_doc, 'tag' => $id_moved_tag));
+
+ $dt = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOneByDocumentExternalId($id_doc, array('tag' => $id_moved_tag));
$dt->setTag($tag);
$dt->setWikipediaRevisionId($revision_id);
- $score_res = $this->container->get('wiki_tag.search')->search($tag_label, array("id"=>$id_doc));
+ $score_res = $this->container->get('wiki_tag.search')->search($tag_label, array("externalId"=>$id_doc));
if(count($score_res)>0)
{
@@ -225,6 +228,7 @@
{
$id_doc = $this->getRequest()->request->get('wikitag_document_id');
$res = $this->getDoctrine()->getRepository('WikiTagBundle:Document');
+
$doc = $res->findOneByExternalId($id_doc);
$doc->setManualOrder(false);
$this->getDoctrine()->getEntityManager()->persist($doc);
@@ -285,7 +289,6 @@
$new_DT->setOriginalOrder($new_order);
$new_DT->setTagOrder($new_order);
$new_DT->setWikipediaRevisionId($revision_id);
- //TODO ; calculate score
$em->persist($new_DT);
$em->flush();
}
@@ -328,8 +331,7 @@
if($id_doc && $id_doc!=""){
// We associate the unsemantized tag to the DocumentTag and save datas
- // TODO: do the request on external id of document
- $dt = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOneBy(array('document' => $id_doc, 'tag' => $id_tag));
+ $dt = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOneByDocumentExternalId($id_doc, array('tag' => $id_tag));
$dt->setTag($un_tag);
$em->flush();
return $this->renderDocTags($id_doc);