Example #1
0
 public function save(Default_Model_VAList $value)
 {
     global $application;
     $data = array();
     if (!isnull($value->getId())) {
         $data['id'] = $value->getId();
     }
     if (!isnull($value->getVappversionID())) {
         $data['vappversionid'] = $value->getVappversionID();
     }
     if (!isnull($value->getVmiinstanceID())) {
         $data['vmiinstanceid'] = $value->getVmiinstanceID();
     }
     $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 function setupVAppList($vappversion, $vmiinstances = array())
 {
     $versionid = $vappversion->id;
     $instids = array();
     //Get stored vmi instances in vapplists for specific version
     $vapplists = new Default_Model_VALists();
     $vapplists->filter->vappversionid->equals($versionid);
     if (count($vapplists->items) > 0) {
         for ($i = 0; $i < count($vapplists->items); $i += 1) {
             $inst = $vapplists->items[$i];
             $instids[] = $inst->vmiinstanceid;
         }
     }
     //store new vmi instances in vapplists
     for ($i = 0; $i < count($vmiinstances); $i += 1) {
         $item = $vmiinstances[$i];
         if (in_array($item->id, $instids) === false) {
             $listitem = new Default_Model_VAList();
             $listitem->vappversionid = $versionid;
             $listitem->vmiinstanceid = $item->id;
             $listitem->save();
         }
     }
 }