public function save(Default_Model_Context $value)
 {
     global $application;
     $data = array();
     if (!isnull($value->getId())) {
         $data['id'] = $value->getId();
     }
     if (!isnull($value->getApplicationID())) {
         $data['appid'] = $value->getApplicationID();
     }
     if (!isnull($value->getAddedbyID())) {
         $data['addedby'] = $value->getAddedbyID();
     }
     if (!isnull($value->getAddedon())) {
         $data['addedon'] = $value->getAddedon();
     }
     if (!isnull($value->getGuID())) {
         $data['guid'] = $value->getGuID();
     }
     if (!isnull($value->getLastupdatedbyID())) {
         $data['lastupdatedby'] = $value->getLastupdatedbyID();
     }
     if (!isnull($value->getLastupdatedon())) {
         $data['lastupdatedon'] = $value->getLastupdatedon();
     }
     if (!isnull($value->getVersion())) {
         $data['version'] = $value->getVersion();
     }
     if (!isnull($value->getDescription())) {
         $data['description'] = $value->getDescription();
     }
     $q1 = 'id = ?';
     $q2 = $value->id;
     if (null === ($id = $value->id)) {
         unset($data['id']);
         $value->id = $this->getDbTable()->insert($data);
     } else {
         $s = $this->getDbTable()->getAdapter()->quoteInto($q1, $q2);
         $this->getDbTable()->update($data, $s);
     }
 }
Example #2
0
 public static function initContextualization($app, $user = null)
 {
     $swapp = null;
     $person = null;
     //Get Software appliance
     if ($app instanceof Default_Model_Application) {
         $swapp = $app;
     } else {
         $swapp = EntityTypes::getEntity("swappliance", $app);
     }
     if ($swapp === null) {
         return null;
     }
     //Get user actor
     if ($user instanceof Default_Model_Researcher) {
         $person = $user;
     } else {
         $ps = new Default_Model_Researchers();
         if (is_numeric($user)) {
             $ps->filter->id->numequals($user);
         } else {
             if (is_string($user)) {
                 $ps->filter->guid->equals($user);
             }
         }
         if (count($ps->items) > 0) {
             $person = $ps->items[0];
         }
     }
     //Check if software appliance has associated contextualization
     //If NOT create a new entry and return its Contextualization
     //class instance
     $context = self::getContextualizationForSWAppliance($swapp);
     if ($context === null) {
         $context = new Default_Model_Context();
         $context->applicationID = $swapp->id;
         if ($person !== null) {
             $context->addedbyID = $person->id;
         }
         $context->save();
     }
     return new Contextualization($context, $person);
 }