Adicion de end point para REPORT TABLES
This commit is contained in:
@@ -108,12 +108,12 @@ class AdditionalTables extends BaseAdditionalTables
|
||||
$oDataset = FieldsPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($oDataset->next()) {
|
||||
$auxField = $oDataset->getRow();
|
||||
if ($auxField['FLD_TYPE'] == 'TIMESTAMP') {
|
||||
$auxField['FLD_TYPE'] = 'DATETIME';
|
||||
}
|
||||
$this->fields[] = $auxField;
|
||||
while ($oDataset->next()) {
|
||||
$auxField = $oDataset->getRow();
|
||||
if ($auxField['FLD_TYPE'] == 'TIMESTAMP') {
|
||||
$auxField['FLD_TYPE'] = 'DATETIME';
|
||||
}
|
||||
$this->fields[] = $auxField;
|
||||
}
|
||||
|
||||
return $this->fields;
|
||||
@@ -263,6 +263,27 @@ class AdditionalTables extends BaseAdditionalTables
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* verify if Additional Table row specified in [sUID] exists.
|
||||
*
|
||||
* @param string $sUID the uid of the additional table
|
||||
*/
|
||||
public function exists ($sUID)
|
||||
{
|
||||
$con = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$oPro = AdditionalTablesPeer::retrieveByPk($sUID);
|
||||
if (is_object($oPro) && get_class($oPro) == 'AdditionalTables') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAll($id)
|
||||
{
|
||||
//deleting pm table
|
||||
@@ -390,34 +411,34 @@ class AdditionalTables extends BaseAdditionalTables
|
||||
$cont = 0;
|
||||
$fieldAppUid = '';
|
||||
foreach ($fieldsTable as $value) {
|
||||
if ($value != 'APP_UID') {
|
||||
if (($cont+1) == $countField) {
|
||||
if ($aData['FIELDS'][$cont]['FLD_TYPE'] == 'VARCHAR') {
|
||||
$stringOr .= '$oCriteria->getNewCriterion(' . $sClassPeerName . '::' . strtoupper($value) . ', "%' . $filter . '%", Criteria::LIKE)';
|
||||
} else {
|
||||
$stringOr .= '$oCriteria->getNewCriterion(' . $sClassPeerName . '::' . strtoupper($value) . ', "' . $filter . '", Criteria::LIKE)';
|
||||
}
|
||||
} else {
|
||||
if ($aData['FIELDS'][$cont]['FLD_TYPE'] == 'VARCHAR') {
|
||||
$stringOr .= '$oCriteria->getNewCriterion(' . $sClassPeerName . '::' . strtoupper($value) . ', "%' . $filter . '%", Criteria::LIKE)->addOr(';
|
||||
} else {
|
||||
$stringOr .= '$oCriteria->getNewCriterion(' . $sClassPeerName . '::' . strtoupper($value) . ', "' . $filter . '", Criteria::LIKE)->addOr(';
|
||||
}
|
||||
}
|
||||
if ($value != 'APP_UID') {
|
||||
if (($cont+1) == $countField) {
|
||||
if ($aData['FIELDS'][$cont]['FLD_TYPE'] == 'VARCHAR') {
|
||||
$stringOr .= '$oCriteria->getNewCriterion(' . $sClassPeerName . '::' . strtoupper($value) . ', "%' . $filter . '%", Criteria::LIKE)';
|
||||
} else {
|
||||
$stringOr .= '$oCriteria->getNewCriterion(' . $sClassPeerName . '::' . strtoupper($value) . ', "' . $filter . '", Criteria::LIKE)';
|
||||
}
|
||||
} else {
|
||||
if ($aData['FIELDS'][$cont]['FLD_TYPE'] == 'VARCHAR') {
|
||||
$stringOr .= '$oCriteria->getNewCriterion(' . $sClassPeerName . '::' . strtoupper($value) . ', "%' . $filter . '%", Criteria::LIKE)->addOr(';
|
||||
} else {
|
||||
$stringOr .= '$oCriteria->getNewCriterion(' . $sClassPeerName . '::' . strtoupper($value) . ', "' . $filter . '", Criteria::LIKE)->addOr(';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$fieldAppUid = $cont;
|
||||
}
|
||||
$cont++;
|
||||
}
|
||||
for ($c = 0; $c < $countField-1; $c++) {
|
||||
for ($c = 0; $c < $countField-1; $c++) {
|
||||
if ($fieldAppUid !== $c) {
|
||||
$stringOr .= ')';
|
||||
$stringOr .= ')';
|
||||
}
|
||||
}
|
||||
$stringOr .= ');';
|
||||
eval($stringOr);
|
||||
|
||||
$oCriteriaCount = clone $oCriteria;
|
||||
$oCriteriaCount = clone $oCriteria;
|
||||
eval('$count = ' . $sClassPeerName . '::doCount($oCriteria);');
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ class DataBaseConnection
|
||||
} else {
|
||||
// TEST CONNECTION
|
||||
$allData = $this->getDataBaseConnection($pro_uid, $dataDBConnection['DBS_UID']);
|
||||
$dataTest = array_merge($allData, $dataDBConnection);
|
||||
$dataTest = array_merge($allData, $dataDBConnection, array('DBS_PASSWORD' => $passOrigin));
|
||||
$resTest = $this->testConnection($dataTest);
|
||||
if (!$resTest['resp']) {
|
||||
throw (new \Exception($resTest['message']));
|
||||
|
||||
@@ -45,14 +45,14 @@ class ReportTable
|
||||
*/
|
||||
public function getReportTable($pro_uid, $rep_uid, $validate = true)
|
||||
{
|
||||
$repData = array();
|
||||
//VALIDATION
|
||||
|
||||
if ($validate) {
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
$rep_uid = $this->validateRepUid($rep_uid);
|
||||
$repData['PRO_UID'] = $pro_uid;
|
||||
}
|
||||
|
||||
$repData = array();
|
||||
$additionalTables = new AdditionalTables();
|
||||
|
||||
// REPORT TABLE PROPERTIES
|
||||
@@ -81,6 +81,46 @@ class ReportTable
|
||||
return $repData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data for ReportTable
|
||||
* @var string $pro_uid. Uid for Process
|
||||
* @var string $rep_uid. Uid for Report Table
|
||||
* @var string $validate. Flag for validate
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDataReportTableData($pro_uid, $rep_uid)
|
||||
{
|
||||
//VALIDATION
|
||||
if ($validate) {
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
$rep_uid = $this->validateRepUid($rep_uid);
|
||||
$repData['PRO_UID'] = $pro_uid;
|
||||
}
|
||||
|
||||
$additionalTables = new AdditionalTables();
|
||||
$table = $additionalTables->load($rep_uid, true);
|
||||
$result = $additionalTables->getAllData($rep_uid);
|
||||
$primaryKeys = $additionalTables->getPrimaryKeys();
|
||||
if (is_array($result['rows'])) {
|
||||
foreach ($result['rows'] as $i => $row) {
|
||||
$result['rows'][$i] = array_change_key_case($result['rows'][$i], CASE_LOWER);
|
||||
$primaryKeysValues = array ();
|
||||
foreach ($primaryKeys as $key) {
|
||||
$primaryKeysValues[] = isset( $row[$key['FLD_NAME']] ) ? $row[$key['FLD_NAME']] : '';
|
||||
}
|
||||
|
||||
$result['rows'][$i]['__index__'] = G::encrypt( implode( ',', $primaryKeysValues ), 'pmtable' );
|
||||
}
|
||||
} else {
|
||||
$result['rows'] = array();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Data for Report Table
|
||||
* @var string $pro_uid. Uid for Process
|
||||
@@ -269,7 +309,7 @@ class ReportTable
|
||||
);
|
||||
$oFields->create( $field );
|
||||
}
|
||||
$this->generateDataReport($pro_uid, $rep_uid);
|
||||
$this->generateDataReport($pro_uid, $rep_uid, false);
|
||||
if ($createRep) {
|
||||
return $this->getReportTable($pro_uid, $rep_uid, false);
|
||||
}
|
||||
@@ -287,6 +327,9 @@ class ReportTable
|
||||
*/
|
||||
public function updateReportTable($pro_uid, $rep_data)
|
||||
{
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
$rep_uid = $this->validateRepUid($rep_uid);
|
||||
|
||||
$rep_uid = trim($rep_data['rep_uid']);
|
||||
$dataValidate = array();
|
||||
|
||||
@@ -322,6 +365,9 @@ class ReportTable
|
||||
*/
|
||||
public function deleteReportTable($pro_uid, $rep_uid)
|
||||
{
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
$rep_uid = $this->validateRepUid($rep_uid);
|
||||
|
||||
$at = new AdditionalTables();
|
||||
$table = $at->load( $rep_uid );
|
||||
|
||||
@@ -346,7 +392,13 @@ class ReportTable
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function generateDataReport($pro_uid, $rep_uid) {
|
||||
public function generateDataReport($pro_uid, $rep_uid, $validate = true) {
|
||||
if ($validate) {
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
$rep_uid = $this->validateRepUid($rep_uid);
|
||||
G::loadClass('pmTable');
|
||||
}
|
||||
|
||||
$additionalTables = new AdditionalTables();
|
||||
$table = $additionalTables->load($rep_uid);
|
||||
$additionalTables->populateReportTable(
|
||||
@@ -582,6 +634,27 @@ class ReportTable
|
||||
return $pro_uid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Report Table Uid
|
||||
* @var string $rep_uid. Uid for report table
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function validateRepUid ($rep_uid) {
|
||||
$rep_uid = trim($rep_uid);
|
||||
if ($rep_uid == '') {
|
||||
throw (new \Exception("The report table with rep_uid: '', does not exist."));
|
||||
}
|
||||
$oAdditionalTables = new \AdditionalTables();
|
||||
if (!($oAdditionalTables->exists($rep_uid))) {
|
||||
throw (new \Exception("The report table with rep_uid: '$rep_uid', does not exist."));
|
||||
}
|
||||
return $rep_uid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Report Table Name
|
||||
* @var string $rep_tab_name. Name for report table
|
||||
@@ -713,7 +786,7 @@ class ReportTable
|
||||
break;
|
||||
}
|
||||
|
||||
G::loadClass( 'pmTable' );
|
||||
G::loadClass('pmTable');
|
||||
|
||||
$columnsTypes = \PmTable::getPropelSupportedColumnTypes();
|
||||
$res = array_search($fld_type, $columnsTypes);
|
||||
|
||||
@@ -54,6 +54,46 @@ class ReportTable extends Api
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prj_uid {@min 1} {@max 32}
|
||||
* @param string $rep_uid {@min 1} {@max 32}
|
||||
* @return array
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /:prj_uid/report-table/:rep_uid/populate
|
||||
*/
|
||||
public function doGetPopulateReportTable($prj_uid, $rep_uid)
|
||||
{
|
||||
try {
|
||||
$oReportTable = new \BusinessModel\ReportTable();
|
||||
$response = $oReportTable->generateDataReport($prj_uid, $rep_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prj_uid {@min 1} {@max 32}
|
||||
* @param string $rep_uid {@min 1} {@max 32}
|
||||
* @return array
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /:prj_uid/report-table/:rep_uid/data
|
||||
*/
|
||||
public function doGetReportTableData($prj_uid, $rep_uid)
|
||||
{
|
||||
try {
|
||||
$oReportTable = new \BusinessModel\ReportTable();
|
||||
$response = $oReportTable->getDataReportTableData($prj_uid, $rep_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prj_uid {@min 1} {@max 32}
|
||||
* @param array $request_data
|
||||
|
||||
Reference in New Issue
Block a user