mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 23:32:17 +02:00
- Migrating from SibusQL to OQL...
SVN:code[20]
This commit is contained in:
@@ -87,9 +87,9 @@ switch($operation)
|
|||||||
$sGroupBy = utils::ReadParam('group_by', '');
|
$sGroupBy = utils::ReadParam('group_by', '');
|
||||||
if ($sFilter != '')
|
if ($sFilter != '')
|
||||||
{
|
{
|
||||||
if ($sEncoding == 'sibusql')
|
if ($sEncoding == 'oql')
|
||||||
{
|
{
|
||||||
$oFilter = CMDBSearchFilter::FromSibusQL($sFilter);
|
$oFilter = CMDBSearchFilter::FromOQL($sFilter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -109,9 +109,9 @@ switch($operation)
|
|||||||
$aParams = utils::ReadParam('params', array());
|
$aParams = utils::ReadParam('params', array());
|
||||||
if ($sFilter != '')
|
if ($sFilter != '')
|
||||||
{
|
{
|
||||||
if ($sEncoding == 'sibusql')
|
if ($sEncoding == 'oql')
|
||||||
{
|
{
|
||||||
$oFilter = CMDBSearchFilter::FromSibusQL($sFilter);
|
$oFilter = CMDBSearchFilter::FromOQL($sFilter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,32 +22,41 @@ $oP = null;
|
|||||||
|
|
||||||
if (!empty($sExpression))
|
if (!empty($sExpression))
|
||||||
{
|
{
|
||||||
$oFilter = DBObjectSearch::FromSibusQL($sExpression);
|
try
|
||||||
if ($oFilter)
|
|
||||||
{
|
{
|
||||||
$oSet = new CMDBObjectSet($oFilter);
|
$oFilter = DBObjectSearch::FromOQL($sExpression);
|
||||||
switch($sFormat)
|
if ($oFilter)
|
||||||
{
|
{
|
||||||
case 'html':
|
$oSet = new CMDBObjectSet($oFilter);
|
||||||
$oP = new web_page("iTop - Export");
|
switch($sFormat)
|
||||||
cmdbAbstractObject::DisplaySet($oP, $oSet);
|
{
|
||||||
break;
|
case 'html':
|
||||||
|
$oP = new web_page("iTop - Export");
|
||||||
case 'csv':
|
cmdbAbstractObject::DisplaySet($oP, $oSet);
|
||||||
$oP = new CSVPage("iTop - Export");
|
break;
|
||||||
cmdbAbstractObject::DisplaySetAsCSV($oP, $oSet);
|
|
||||||
break;
|
case 'csv':
|
||||||
|
$oP = new CSVPage("iTop - Export");
|
||||||
case 'xml':
|
cmdbAbstractObject::DisplaySetAsCSV($oP, $oSet);
|
||||||
$oP = new XMLPage("iTop - Export");
|
break;
|
||||||
cmdbAbstractObject::DisplaySetAsXML($oP, $oSet);
|
|
||||||
break;
|
case 'xml':
|
||||||
|
$oP = new XMLPage("iTop - Export");
|
||||||
default:
|
cmdbAbstractObject::DisplaySetAsXML($oP, $oSet);
|
||||||
$oP = new web_page("iTop - Export");
|
break;
|
||||||
$oP->add("Unsupported format '$sFormat'. Possible values are: html, csv or xml.");
|
|
||||||
|
default:
|
||||||
|
$oP = new web_page("iTop - Export");
|
||||||
|
$oP->add("Unsupported format '$sFormat'. Possible values are: html, csv or xml.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
$oP = new web_page("iTop - Export");
|
||||||
|
$oP->p("Error the query can not be executed.");
|
||||||
|
$oP->p($e->GetHtmlDesc());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!$oP)
|
if (!$oP)
|
||||||
{
|
{
|
||||||
@@ -55,7 +64,7 @@ if (!$oP)
|
|||||||
$oP = new web_page("iTop - Export");
|
$oP = new web_page("iTop - Export");
|
||||||
$oP->p("<strong>General purpose export page.</strong>");
|
$oP->p("<strong>General purpose export page.</strong>");
|
||||||
$oP->p("<strong>Parameters:</strong>");
|
$oP->p("<strong>Parameters:</strong>");
|
||||||
$oP->p("<ul><li>expression: a SibusQL expression</li>
|
$oP->p("<ul><li>expression: an OQL expression (URL encoded if needed)</li>
|
||||||
<li>format: (optional, default is html) the desired output format. Can be one of 'html', 'csv' or 'xml'</li>
|
<li>format: (optional, default is html) the desired output format. Can be one of 'html', 'csv' or 'xml'</li>
|
||||||
</ul>");
|
</ul>");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,15 +17,15 @@ $oP = new iTopWebPage("iTop - Expression Evaluation", $currentOrganization);
|
|||||||
|
|
||||||
// Main program
|
// Main program
|
||||||
$sExpression = utils::ReadParam('expression', '');
|
$sExpression = utils::ReadParam('expression', '');
|
||||||
$sEncoding = utils::ReadParam('encoding', 'sibusql');
|
$sEncoding = utils::ReadParam('encoding', 'oql');
|
||||||
|
|
||||||
if ($sEncoding == 'crypted')
|
if ($sEncoding == 'crypted')
|
||||||
{
|
{
|
||||||
// Translate $sExpression into a sibusql expression
|
// Translate $sExpression into a oql expression
|
||||||
$sClearText = base64_decode($sExpression);
|
$sClearText = base64_decode($sExpression);
|
||||||
echo "<strong>FYI: '$sClearText'</strong><br/>\n";
|
echo "<strong>FYI: '$sClearText'</strong><br/>\n";
|
||||||
$oFilter = DBObjectSearch::unserialize($sExpression);
|
$oFilter = DBObjectSearch::unserialize($sExpression);
|
||||||
$sExpression = $oFilter->ToSibusQL();
|
$sExpression = $oFilter->ToOQL();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -35,16 +35,16 @@ else
|
|||||||
|
|
||||||
$oP->add('<form method="get">'."\n");
|
$oP->add('<form method="get">'."\n");
|
||||||
$oP->add('Expression to evaluate:<br/>'."\n");
|
$oP->add('Expression to evaluate:<br/>'."\n");
|
||||||
$oP->add('<textarea cols="50" rows="20" name="expression">'.$sExpression.'</textarea>'."<p> Example:<br/>bizPerson: name Contains 'A'</p>\n");
|
$oP->add('<textarea cols="50" rows="20" name="expression">'.$sExpression.'</textarea>'."<p> Example:<br/>SELECT bizPerson AS B WHERE B.name LIKE '%A%'</p>\n");
|
||||||
$oP->add('<input type="submit" value=" Evaluate ">'."\n");
|
$oP->add('<input type="submit" value=" Evaluate ">'."\n");
|
||||||
$oP->add('</form>'."\n");
|
$oP->add('</form>'."\n");
|
||||||
|
|
||||||
if (!empty($sExpression))
|
if (!empty($sExpression))
|
||||||
{
|
{
|
||||||
$oFilter = DBObjectSearch::FromSibusQL($sExpression);
|
$oFilter = DBObjectSearch::FromOQL($sExpression);
|
||||||
if ($oFilter)
|
if ($oFilter)
|
||||||
{
|
{
|
||||||
$oP->p('Query expression: '.$oFilter->ToSibusQL());
|
$oP->p('Query expression: '.$oFilter->ToOQL());
|
||||||
$oP->p('Serialized filter: '.$oFilter->serialize());
|
$oP->p('Serialized filter: '.$oFilter->serialize());
|
||||||
|
|
||||||
$oSet = new CMDBObjectSet($oFilter);
|
$oSet = new CMDBObjectSet($oFilter);
|
||||||
|
|||||||
Reference in New Issue
Block a user