/** * Normally a RAISE Factory does'nt have any parameters * The Factory normally will do his business logic in a black box. * In other words, the Factory will request the necessary data to work * through the RAISE Managers */ public function __construct() { $raiseResources = Json::getInstance()->convert(DatabaseManager::getInstance()->fetchAll(Constants::getInstance()->get('metaResourcesQuery')), new ResourceModel()); $this->addSet($raiseResources); }
/** * Normally a RAISE Factory does not have any parameters * The Factory normally will do its business logic in a black box. * In other words, the Factory will request the necessary data to work * through the RAISE Managers */ public function __construct() { $raiseMessages = Json::getInstance()->convert($this->collectData(DatabaseManager::getInstance()->fetchAll(Constants::getInstance()->get('raiseMessagesQuery'))), new MessageModel()); $this->addSet($raiseMessages); }
* @var int ACT_ID */ Constants::getInstance()->add('addServiceActionRelation', 'INSERT INTO SERVICE_ACTIONS (SRVC_ID, ACT_ID) VALUES (:SRVC_ID, :ACT_ID)'); /* Specific Queries */ /** * Get Specific Token Details * @see \UIoT\Models\TokenModel * * @var string DVC_TOKEN */ Constants::getInstance()->add('specificTokenDetailsQuery', Constants::getInstance()->get('tokenDetailsQuery') . ' WHERE DEVICE_TOKENS.DVC_TOKEN = :DVC_TOKEN'); /** * Get Specific Properties * @see \UIoT\Models\PropertyModel * * @var int RSRC_ID */ Constants::getInstance()->add('specificPropertiesQuery', Constants::getInstance()->get('metaPropertiesQuery') . ' WHERE META_PROPERTIES.RSRC_ID = :RSRC_ID'); /** * Update RAISe existent Token * @see \UIoT\Models\TokenModel * * @var string DVC_TOKEN * @var int DVC_TOKEN_EXPIRE * @var string OLD_DVC_TOKEN */ Constants::getInstance()->add('updateTokenQuery', 'UPDATE DEVICE_TOKENS SET DEVICE_TOKENS.DVC_TOKEN = :DVC_TOKEN, DEVICE_TOKENS.DVC_TOKEN_EXPIRE = :DVC_TOKEN_EXPIRE WHERE DEVICE_TOKENS.DVC_TOKEN = :OLD_DVC_TOKEN');
/** * Method that executes the Business Logic * and does all Controlling operations. * * @note Interaction is similar as a Controller * * @return void */ public function execute() { DatabaseManager::getInstance()->query(Constants::getInstance()->get('addServiceAction'), [':ACT_NAME' => $this->getRequest()->query->get('name'), ':ACT_TYPE' => $this->getRequest()->query->get('type')]); $this->setMessage('ServiceInsertion', ['item_id' => $this->getInstruction()->getInsertId(), 'action_id' => $actionId = DatabaseManager::getInstance()->getLastInsertId()]); DatabaseManager::getInstance()->query(Constants::getInstance()->get('addServiceActionRelation'), [':SRVC_ID' => $this->getInstruction()->getInsertId(), ':ACT_ID' => $actionId]); }
/** * Insert a Token in the Database * And get the Created Token * * @param int $deviceId Device Identification * @return string */ public function createToken($deviceId = 0) { DatabaseManager::getInstance()->query(Constants::getInstance()->get('addTokenQuery'), [':DVC_ID' => $deviceId, ':DVC_TOKEN' => $tokenHash = Security::getInstance()->generateSha1(), ':DVC_TOKEN_EXPIRE' => Time::getInstance()->getTime() + SettingsManager::getInstance()->getItem('security')->__get('tokenExpirationTime')]); return $tokenHash; }
/** * Normally a RAISE Factory does'nt have any parameters * The Factory normally will do his business logic in a black box. * In other words, the Factory will request the necessary data to work * through the RAISE Managers * * @param int $resourceId Resource Related Identifier */ public function __construct($resourceId = 0) { $raiseProperties = Json::getInstance()->convert(DatabaseManager::getInstance()->fetchAll(Constants::getInstance()->get('specificPropertiesQuery'), [':RSRC_ID' => $resourceId]), new PropertyModel()); $this->addSet($raiseProperties); }