Example #1
0
 public function testTagAssignmentRemoval()
 {
     //related to checkin #6111
     $objTag = new class_module_tags_tag();
     $objTag->setStrName(generateSystemid());
     $objTag->updateObjectToDb();
     $objAspect = new class_module_system_aspect();
     $objAspect->setStrName(generateSystemid());
     $objAspect->updateObjectToDb();
     $objTag->assignToSystemrecord($objAspect->getSystemid());
     $this->flushDBCache();
     $this->assertEquals(count($objTag->getArrAssignedRecords()), 1);
     $this->assertEquals(count(class_module_tags_tag::getTagsForSystemid($objAspect->getSystemid())), 1);
     $objTag->removeFromSystemrecord($objAspect->getSystemid(), "");
     $this->flushDBCache();
     $this->assertEquals(count($objTag->getArrAssignedRecords()), 0);
     $this->assertEquals(count(class_module_tags_tag::getTagsForSystemid($objAspect->getSystemid())), 0);
     $objTag->deleteObjectFromDatabase();
     $objAspect->deleteObjectFromDatabase();
 }
 public function testIndexEvent()
 {
     if (class_module_system_module::getModuleByName("tags") == null || class_module_system_module::getModuleByName("system") == null) {
         return;
     }
     $strSearchKey1 = generateSystemid();
     $objAspect = new class_module_system_aspect();
     $objAspect->setStrName($strSearchKey1);
     $objAspect->updateObjectToDb();
     $objSearchCommons = new class_module_search_commons();
     $objSearchParams = new class_module_search_search();
     $objSearchParams->setStrQuery($strSearchKey1);
     $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null);
     $this->assertEquals(count($arrResult), 1);
     $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objAspect->getStrSystemid());
     $strSearchKey2 = generateSystemid();
     $objTag = new class_module_tags_tag();
     $objTag->setStrName($strSearchKey2);
     $objTag->updateObjectToDb();
     $objSearchParams = new class_module_search_search();
     $objSearchParams->setStrQuery($strSearchKey2);
     $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null);
     $this->assertEquals(count($arrResult), 1);
     $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objTag->getStrSystemid());
     $objTag->assignToSystemrecord($objAspect->getStrSystemid());
     $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null);
     $this->assertEquals(count($arrResult), 2);
     $objSearchParams->setStrInternalFilterModules(_system_modul_id_);
     $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null);
     $this->assertEquals(count($arrResult), 1);
     $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objAspect->getStrSystemid());
     $objTag->removeFromSystemrecord($objAspect->getStrSystemid());
     //the aspect itself should not be found any more
     $objSearchParams = new class_module_search_search();
     $objSearchParams->setStrQuery($strSearchKey2);
     $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null);
     $this->assertEquals(count($arrResult), 1);
     $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objTag->getStrSystemid());
     $objAspect->deleteObjectFromDatabase();
     $objTag->deleteObjectFromDatabase();
 }
 /**
  * Removes a tag from the the system-record passed.
  * Please be aware of the fact, that this only deletes the assignment, not the tag itself.
  *
  * @return string
  * @permissions view
  */
 protected function actionRemoveTag()
 {
     $strReturn = "";
     $strTargetSystemid = $this->getParam("targetid");
     $strAttribute = $this->getParam("attribute");
     //load the tag itself
     $objTag = new class_module_tags_tag($this->getSystemid());
     //add the connection itself
     if ($objTag->removeFromSystemrecord($strTargetSystemid, $strAttribute != '' ? $strAttribute : null)) {
         $strReturn .= "<success>assignment removed</success>";
     } else {
         $strReturn .= "<error>assignment removal failed</error>";
     }
     return $strReturn;
 }