0010142: add etag to event model
authorPhilipp Schüle <p.schuele@metaways.de>
Fri, 8 Aug 2014 11:30:47 +0000 (13:30 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 4 Sep 2014 09:26:39 +0000 (11:26 +0200)
https://forge.tine20.org/mantisbt/view.php?id=10142

Change-Id: I730e76f9dfb320506f85c6c7faecbbec019baeae
Reviewed-on: http://gerrit.tine20.com/customers/952
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Calendar/JsonTests.php
tine20/Calendar/Model/Event.php
tine20/Calendar/Model/EventFilter.php
tine20/Calendar/Setup/Update/Release8.php
tine20/Calendar/Setup/setup.xml

index aa239d8..b1cb11f 100644 (file)
@@ -65,11 +65,13 @@ class Calendar_JsonTests extends Calendar_TestCase
             'note_type_id' => Tinebase_Notes::getInstance()->getNoteTypes()->getFirstRecord()->getId(),
         ));
         $eventData['notes'] = array($note->toArray());
+        $eventData['etag'] = Tinebase_Record_Abstract::generateUID();
         
         $persistentEventData = $this->_uit->saveEvent($eventData);
         $loadedEventData = $this->_uit->getEvent($persistentEventData['id']);
         
         $this->_assertJsonEvent($eventData, $loadedEventData, 'failed to create/load event');
+        $this->assertEquals($eventData['etag'], $loadedEventData['etag']);
         
         $contentSeqAfter = Tinebase_Container::getInstance()->getContentSequence($scleverDisplayContainerId);
         $this->assertEquals($contentSeqBefore + 1, $contentSeqAfter,
index 7cd2b58..cf30d74 100644 (file)
@@ -5,7 +5,7 @@
  * @package     Calendar
  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
  * @author      Cornelius Weiss <c.weiss@metaways.de>
- * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2009-2014 Metaways Infosystems GmbH (http://www.metaways.de)
  *
  */
 
@@ -31,6 +31,7 @@
  * @property string originator_tz
  * @property string seq
  * @property string uid
+ * @property string etag
  * @property int container_id
  */
 class Calendar_Model_Event extends Tinebase_Record_Abstract
@@ -105,6 +106,7 @@ class Calendar_Model_Event extends Tinebase_Record_Abstract
         'summary'              => array(Zend_Filter_Input::ALLOW_EMPTY => true          ),
         'url'                  => array(Zend_Filter_Input::ALLOW_EMPTY => true          ),
         'uid'                  => array(Zend_Filter_Input::ALLOW_EMPTY => true          ),
+        'etag'                 => array(Zend_Filter_Input::ALLOW_EMPTY => true          ),
         // ical common fields with multiple appearance
         //'attach'                => array(Zend_Filter_Input::ALLOW_EMPTY => true         ),
         'attendee'              => array(Zend_Filter_Input::ALLOW_EMPTY => true         ), // RecordSet of Calendar_Model_Attender
index 62817c7..6dd0fe4 100644 (file)
@@ -39,6 +39,7 @@ class Calendar_Model_EventFilter extends Tinebase_Model_Filter_FilterGroup
     protected $_filterModel = array(
         'id'                    => array('filter' => 'Tinebase_Model_Filter_Id', 'options' => array('modelName' => 'Calendar_Model_Event')),
         'uid'                   => array('filter' => 'Tinebase_Model_Filter_Text'),
+        'etag'                  => array('filter' => 'Tinebase_Model_Filter_Text'),
         'container_id'          => array('filter' => 'Calendar_Model_CalendarFilter', 'options' => array('applicationName' => 'Calendar')),
         'query'                 => array('filter' => 'Tinebase_Model_Filter_Query', 'options' => array('fields' => array('summary', 'description', 'location'))),
         'period'                => array('filter' => 'Calendar_Model_PeriodFilter'),
index 6155bd7..98edcdc 100644 (file)
@@ -163,4 +163,32 @@ class Calendar_Setup_Update_Release8 extends Setup_Update_Abstract
         
         $this->setApplicationVersion('Calendar', '8.3');
     }
+    
+    /**
+     * update to 8.4
+     * 
+     * - adds etag column
+     */
+    public function update_3()
+    {
+        $declaration = new Setup_Backend_Schema_Field_Xml('
+            <field>
+                <name>etag</name>
+                <type>text</type>
+                <length>60</length>
+            </field>');
+        $this->_backend->addCol('cal_events', $declaration);
+        
+        $declaration = new Setup_Backend_Schema_Index_Xml('
+            <index>
+                <name>etag</name>
+                <field>
+                    <name>etag</name>
+                </field>
+            </index>');
+        $this->_backend->addIndex('cal_events', $declaration);
+        
+        $this->setTableVersion('cal_events', 7);
+        $this->setApplicationVersion('Calendar', '8.4');
+    }
 }
index 31c1158..3d8388f 100644 (file)
@@ -2,14 +2,14 @@
 <application>
     <name>Calendar</name>
     <!-- gettext('Calendar') -->   
-    <version>8.3</version>
+    <version>8.4</version>
     <order>15</order>
     <status>enabled</status>
     <tables>
         <!-- events -->
         <table>
             <name>cal_events</name>
-            <version>6</version>
+            <version>7</version>
             <declaration>
                 <field>
                     <name>id</name>
                     <notnull>true</notnull>
                 </field>
                 <field>
+                    <name>etag</name>
+                    <type>text</type>
+                    <length>60</length>
+                </field>
+                <field>
                     <name>dtstart</name>
                     <type>datetime</type>
                 </field>
                     </field>
                 </index>
                 <index>
+                    <name>etag</name>
+                    <field>
+                        <name>etag</name>
+                    </field>
+                </index>
+                <index>
                     <name>rrule_until</name>
                     <field>
                         <name>rrule_until</name>