Author: sevein
Date: Mon Jun  4 20:13:10 2012
New Revision: 11728

Log:
Add some missing fields into the index to proceed with the advanced search 
(filter fields like material type or hasDigitalObject)

Modified:
   
branches/2.0/plugins/qtElasticSearchPlugin/lib/model/QubitInformationObjectMapping.class.php
   
branches/2.0/plugins/qtElasticSearchPlugin/lib/model/QubitPdoInformationObject.class.php

Modified: 
branches/2.0/plugins/qtElasticSearchPlugin/lib/model/QubitInformationObjectMapping.class.php
==============================================================================
--- 
branches/2.0/plugins/qtElasticSearchPlugin/lib/model/QubitInformationObjectMapping.class.php
        Mon Jun  4 18:17:58 2012        (r11727)
+++ 
branches/2.0/plugins/qtElasticSearchPlugin/lib/model/QubitInformationObjectMapping.class.php
        Mon Jun  4 20:13:10 2012        (r11728)
@@ -73,6 +73,14 @@
           'thumbnail_FullPath' => array(
             'type' => 'string',
             'index' => 'no'))),
+      'materialTypeId' => array(
+        'type' => 'integer',
+        'index' => 'not_analyzed',
+        'include_in_all' => false),
+      'copyrightStatusId' => array(
+        'type' => 'integer',
+        'index' => 'not_analyzed',
+        'include_in_all' => false),
       'dates' => array(
         'type' => 'object',
         'properties' => array(

Modified: 
branches/2.0/plugins/qtElasticSearchPlugin/lib/model/QubitPdoInformationObject.class.php
==============================================================================
--- 
branches/2.0/plugins/qtElasticSearchPlugin/lib/model/QubitPdoInformationObject.class.php
    Mon Jun  4 18:17:58 2012        (r11727)
+++ 
branches/2.0/plugins/qtElasticSearchPlugin/lib/model/QubitPdoInformationObject.class.php
    Mon Jun  4 20:13:10 2012        (r11728)
@@ -661,49 +661,22 @@
 
   public function getMaterialTypeId()
   {
-    $sql  = 'SELECT term.id';
-    $sql .= ' FROM '.QubitObjectTermRelation::TABLE_NAME.' otr';
-    $sql .= ' JOIN '.QubitTerm::TABLE_NAME.' term
-                ON otr.term_id = term.id';
-    $sql .= ' WHERE object_id = ?';
-    $sql .= ' AND term.taxonomy_id = ?';
-
-    $notes = array();
-
-    // Subject relations
-    if (!isset(self::$statements['note']))
+    if (!isset(self::$statements['materialType']))
     {
-      $sql  = 'SELECT
-                  i18n.content';
-      $sql .= ' FROM '.QubitNote::TABLE_NAME.' note';
-      $sql .= ' JOIN '.QubitNoteI18n::TABLE_NAME.' i18n
-                  ON note.id = i18n.id';
-      $sql .= ' WHERE note.object_id = ?
-                  AND i18n.culture = ?';
+      $sql  = 'SELECT term.id';
+      $sql .= ' FROM '.QubitObjectTermRelation::TABLE_NAME.' otr';
+      $sql .= ' JOIN '.QubitTerm::TABLE_NAME.' term
+                  ON otr.term_id = term.id';
+      $sql .= ' WHERE object_id = ?';
+      $sql .= ' AND term.taxonomy_id = '.QubitTaxonomy::MATERIAL_TYPE_ID;
 
-      self::$statements['note'] = self::$conn->prepare($sql);
+      self::$statements['materialType'] = self::$conn->prepare($sql);
     }
 
-    self::$statements['note']->execute(array(
-      $this->__get('id'),
-      $this->__get('culture')));
+    self::$statements['materialType']->execute(array(
+      $this->__get('id')));
 
-    foreach (self::$statements['note']->fetchAll(PDO::FETCH_OBJ) as $item)
-    {
-      if (0 < strlen($item->content))
-      {
-        $notes[] = $item->content;
-      }
-    }
-
-    if (0 < count($notes))
-    {
-      return implode(' ', $notes);
-    }
-
-    return QubitPdo::fetchColumn($sql, array(
-        $this->__get('id'),
-        QubitTaxonomy::MATERIAL_TYPE_ID));
+    return self::$statements['materialType']->fetchColumn(0);
   }
 
   public function getStorageNames()
@@ -743,6 +716,30 @@
     }
   }
 
+  public function getRights()
+  {
+    if (!isset(self::$statements['rights']))
+    {
+      $sql  = 'SELECT
+                  restriction,
+                  basis_id,
+                  act_id,
+                  rights_holder_id,
+                  copyright_status_id';
+      $sql .= ' FROM '.QubitRights::TABLE_NAME.' rights';
+      $sql .= ' JOIN '.QubitRelation::TABLE_NAME.' rel
+                  ON rights.id = rel.object_id';
+      $sql .= ' WHERE rel.subject_id = ?';
+      $sql .= ' AND rel.type_id = '.QubitTerm::RIGHT_ID;
+      self::$statements['rights'] = self::$conn->prepare($sql);
+    }
+
+    self::$statements['rights']->execute(array(
+      $this->__get('id')));
+
+    return self::$statements['rights']->fetchAll(PDO::FETCH_CLASS);
+  }
+
   // Serialize yaself!  Don' disrespec yaself
   public function serialize()
   {
@@ -782,6 +779,27 @@
       $serialized['hasDigitalObject'] = false;
     }
 
+    // Material type
+    if (null !== ($materialTypeId = $this->getMaterialTypeId))
+    {
+      $serialized['materialTypeId'] = $materialTypeId;
+    }
+
+    // Copyright status
+    $statusId = null;
+    foreach ($this->getRights() as $item)
+    {
+      if (isset($item->copyright_status_id))
+      {
+        $statusId = $item->copyright_status_id;
+        break;
+      }
+    }
+    if (null !== $statusId)
+    {
+      $serialized['copyrightStatusId'] = $statusId;
+    }
+
     $dates = $this->getDates('array');
     if (0 < count($dates))
     {

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to