<?php
/**
 * gtcTask business
 *
 * @author Luiz Gilberto Gregory F [luiz@solis.coop.br]
 *
 * @version $Id$
 *
 * \b Maintainers \n
 * Eduardo Bonfandini [eduardo@solis.coop.br]
 * Jamiel Spezia [jamiel@solis.coop.br]
 * Luiz Gregory Filho [luiz@solis.coop.br]
 * Moises Heberle [moises@solis.coop.br]
 * Sandro Roberto Weisheimer [sandrow@solis.coop.br]
 *
 * @since
 * Class created on 06/08/2009
 *
 * \b Organization: \n
 * SOLIS - Cooperativa de Solucoes Livres \n
 * The Gnuteca3 Development Team
 *
 * \b CopyLeft: \n
 * CopyLeft (L) 2008 SOLIS - Cooperativa de Solucoes Livres \n
 *
 * \b License: \n
 * Licensed under GPL (for further details read the COPYING file or http://www.gnu.org/copyleft/gpl.html )
 *
 * \b History: \n
 * See history in SVN repository: http://gnuteca.solis.coop.br
 */


class BusinessGnuteca3BusSoapAccess extends GnutecaBusiness
{
    public  $webServiceId, $soapClientId;

    public $columns,
           $table       = 'gtcSoapAccess';


    public $busWebService, $busSoapClient;

    public function __construct()
    {
        parent::__construct($this->table, "webServiceId, soapClientId");

        $this->busWebService = $this->MIOLO->getBusiness($this->module, 'BusWebService');
        $this->busSoapClient = $this->MIOLO->getBusiness($this->module, 'BusSoapClient');
    }


    public function checkAccess($webServiceId, $soapClientId)
    {
        $this->clear();
        $this->setColumns("1");
        $this->setTables($this->table);
        $this->setWhere('webServiceId = ? AND soapClientId = ?');
        $sql = $this->select(array($webServiceId, $soapClientId));
        $rs = $this->query($sql);
        return isset($rs[0][0]) && $rs[0][0] == '1';
    }


    /**
     * Retorna um determiando servico pelo id
     *
     * @param integer $webServiceId
     */
    public function getWebService($webServiceId)
    {

    }


    /**
     * Retorna um determiando servico pelo id
     *
     * @param integer $webServiceId
     */
    public function getWebServiceByClassAndMethod($className, $methodRequest)
    {
        return $this->busWebService->getWebServiceByClassAndMethod($className, $methodRequest);
    }


    /**
     * Autentica um cliente
     *
     * @param integer $clientId
     * @param string $clientPassword
     */
    public function authenticate($clientId, $clientPassword)
    {
        return $this->busSoapClient->authenticate($clientId, $clientPassword);
    }


    /**
     * retorna o objeto de uma cliente
     *
     * @param integer $clientId
     */
    public function getClient($clientId)
    {
        return $this->busSoapClient->getSoapClient($clientId);
    }
}
?>
