Example #1
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);
 }
Example #2
0
 public static function getEntity($entityname, $id)
 {
     switch (strtolower(trim($entityname))) {
         case "person":
             return EntityTypes::getPerson($id);
         case "organization":
             return EntityTypes::getOrganization($id);
         case "project":
             return EntityTypes::getProject($id);
         case "software":
             return EntityTypes::getSoftware($id);
         case "vappliance":
             return EntityTypes::getVAppliance($id);
         case "swappliance":
             return EntityTypes::getSWAppliance($id);
         default:
             return null;
     }
     return null;
 }