diff --git a/src/InputOutput/IHMImpl/IHMInputOutputClass.php b/src/InputOutput/IHMImpl/IHMInputOutputClass.php index d57e764..5d6b4df 100644 --- a/src/InputOutput/IHMImpl/IHMInputOutputClass.php +++ b/src/InputOutput/IHMImpl/IHMInputOutputClass.php @@ -43,10 +43,12 @@ class IHMInputOutputClass implements InputOutputInterface break; case 'request' : //plot + if (($input->{"file-format"} == "PNG") && ($input->{"file-output"} == "INTERACTIVE")) + { + //set working dir for interactive plot + $requestId = "Plot"; + } $this->inputOutput = new IHMInputOutputParamsPlotClass(); - //set working dir for interactive plot - if (($input->format == "PNG") && ($input->tabId != "")) - $requestId = "Plot".$input->tabId; break; default : throw new Exception('Params request type '.$input_request->nodeType.' not implemented for this client.'); diff --git a/src/InputOutput/IHMImpl/Params/DataMiningImpl/IHMInputOutputParamsDataMiningClass.php b/src/InputOutput/IHMImpl/Params/DataMiningImpl/IHMInputOutputParamsDataMiningClass.php index 1b2015d..2dedbcc 100644 --- a/src/InputOutput/IHMImpl/Params/DataMiningImpl/IHMInputOutputParamsDataMiningClass.php +++ b/src/InputOutput/IHMImpl/Params/DataMiningImpl/IHMInputOutputParamsDataMiningClass.php @@ -17,13 +17,14 @@ class IHMInputOutputParamsDataMiningClass extends IHMInputOutputParamsAbstractCl /* '{"id":"cond_2","name":"us44_test1","sampling":600,"gap":5,"description":"","expression":"dst>0","timesrc":"Interval","startDate":"2008-01-31T00:00:00","stopDate":"2008-02-01T00:00:00","durationDay":"0001","durationHour":"00","durationMin":"00","durationSec":"00","leaf":true,"nodeType":"condition"}' */ - $paramsNode = $this->paramsData->getRequestNode()->getParamsNode(); + $requestNode = $this->paramsData->addRequestNode(); + $paramsNode = $requestNode->getParamsNode(); //unmarshall time definition - $this->unmarshallTimeDefinition($input); + $this->unmarshallTimeDefinition($input, 0); //unmarshall data mining output definition - $outputsNode = $this->paramsData->getRequestNode()->getOutputsNode(); + $outputsNode = $requestNode->getOutputsNode(); $dataMiningNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::DATAMINING); $dataMiningNode->setTimeFormat(RequestOutputDataMiningTimeFormatEnum::ISO); diff --git a/src/InputOutput/IHMImpl/Params/DownloadImpl/IHMInputOutputParamsDownloadClass.php b/src/InputOutput/IHMImpl/Params/DownloadImpl/IHMInputOutputParamsDownloadClass.php index 1e6db99..5181791 100644 --- a/src/InputOutput/IHMImpl/Params/DownloadImpl/IHMInputOutputParamsDownloadClass.php +++ b/src/InputOutput/IHMImpl/Params/DownloadImpl/IHMInputOutputParamsDownloadClass.php @@ -18,13 +18,15 @@ class IHMInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClas // "header":"0","timesrc":"TimeTable","timeTables":[{"timeTableName":"rzerzer","id":"tt_1"},{"timeTableName":"sqsdq","id":"tt_0"}], //"list":["dst"],"milli":false,"fileformat":"ASCII","timeformat":"YYYY-MM-DDThh:mm:ss","compression":"tar+gzip","leaf":true} - $paramsNode = $this->paramsData->getRequestNode()->getParamsNode(); + $requestNode = $this->paramsData->addRequestNode(); + + $paramsNode = $requestNode->getParamsNode(); //unmarshall time definition - $this->unmarshallTimeDefinition($input); + $this->unmarshallTimeDefinition($input, 0); //unmarshall download output definition - $outputsNode = $this->paramsData->getRequestNode()->getOutputsNode(); + $outputsNode = $requestNode->getOutputsNode(); $downloadNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::DOWNLOAD); //timeformatData : [['Y-m-dTH:i:s', 'YYYY-MM-DDThh:mm:ss'], ['DD Time', 'DD Time'], ['Timestamp', 'Timestamp']], diff --git a/src/InputOutput/IHMImpl/Params/IHMInputOutputParamsAbstractClass.php b/src/InputOutput/IHMImpl/Params/IHMInputOutputParamsAbstractClass.php index e07b195..f044a98 100644 --- a/src/InputOutput/IHMImpl/Params/IHMInputOutputParamsAbstractClass.php +++ b/src/InputOutput/IHMImpl/Params/IHMInputOutputParamsAbstractClass.php @@ -52,9 +52,9 @@ abstract class IHMInputOutputParamsAbstractClass implements InputOutputInterface /* * @brief Unmarshall the time definition from the IHM request */ - protected function unmarshallTimeDefinition($input) + protected function unmarshallTimeDefinition($input, $requestIndex) { - $timesNode = $this->paramsData->getRequestNode()->getTimesNode(); + $timesNode = $this->paramsData->getRequestNodes()[$requestIndex]->getTimesNode(); switch ($input->timesrc) { diff --git a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php index dc2812f..8fd1ba9 100644 --- a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php +++ b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php @@ -9,298 +9,210 @@ define ("PLOT_RESULT_FILE_KEY","plot"); */ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass { - private $currentTabId; - private $isInterractive; - private $startTime; - private $stopTime; - /* * @brief method to unmarshall a plot request */ protected function unmarshallRequest($input) { - if (isset($input->action)) + //save request + $this->saveIHMRequest($input); + + //Request + $requestIndex = 0; + foreach ($input->tabs as $tab) { - //interactive action - $realInput = $input; - $input = $this->loadIHMRequest(); + $requestNode = $this->paramsData->addRequestNode(); + $outputsNode = $requestNode->getOutputsNode(); - if (!isset($input)) - throw new Exception('Cannot get original request data for interactive action.'); + //unmarshall time definition + $this->unmarshallTimeDefinition($input, $requestIndex); - //modify request - date_default_timezone_set('UTC'); - $intervalMove = 0.; - switch ($realInput->action->name) + $plotOutputNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::PLOT); + + switch ($input->{'file-output'}) { - case 'next' : - $intervalMove = strtotime($input->stopDate) - strtotime($input->startDate); + case 'TGZ' : + $plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::TAR); + $plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::GZIP); + break; + case 'ZIP' : + $plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::ZIP); break; - case 'halfnext' : - $intervalMove = (strtotime($input->stopDate) - strtotime($input->startDate))/2; + } + + if ($input->{'one-file-per-interval'}) + $plotOutputNode->setStructure(RequestOutputPlotStructureEnum::ONE_FILE_PER_INTERVAL); + else + $plotOutputNode->setStructure(RequestOutputPlotStructureEnum::ONE_FILE); + + //prefix + $filePrefix = ""; + if ($input->{'file-prefix'} == "") + $filePrefix = "plot"; + else + $filePrefix = $input->{'file-prefix'}; + $filePrefix .= $requestIndex; + + $plotOutputNode->setFilePrefix($filePrefix); + + //page + $pageNode = $plotOutputNode->getPage(); + + $fileFormat = RequestOutputPlotPageFormatEnum::PNG; + switch ($input->{'file-format'}) + { + case 'PNG' : + $fileFormat = RequestOutputPlotPageFormatEnum::PNG; break; - case 'back' : - $intervalMove = strtotime($input->startDate) - strtotime($input->stopDate); + case 'PDF' : + $fileFormat = RequestOutputPlotPageFormatEnum::PDF; break; - case 'halfback' : - $intervalMove = (strtotime($input->startDate) - strtotime($input->stopDate))/2; + case 'PS' : + $fileFormat = RequestOutputPlotPageFormatEnum::PS; break; + case 'SVG' : + $fileFormat = RequestOutputPlotPageFormatEnum::SVG; + break; + default: + throw new Exception('File format not implemented.'); } - //apply move - $input->startDate = date("Y-m-d\TH:i:s",strtotime($input->startDate)+$intervalMove); - $input->stopDate = date("Y-m-d\TH:i:s",strtotime($input->stopDate)+$intervalMove); - } - - //remove old result files - foreach (glob($this->getWorkingPath()."plot_*.png") as $oldfile) - { - unlink($oldfile); - } - - //Full plot request - $this->startTime = $input->startDate; - $this->stopTime = $input->stopDate; - - //save request - $this->saveIHMRequest($input); - - //TimePlot - //{"id":"","name":"","tabId":"1","outputName":"","orientation":"LANDSCAPE","format":"PNG","title":"", - //"description":"","charSize":1.3,"thickness":1,"ppp":3000,"forcedLayout":false,"forcedMulti":false, - //"children":[{"name":"Panel 1","leaf":false,"text":"","width":1,"height":0.4,"xTitle":"", - //"xRangeMin":0,"xRangeMax":0,"y1Title":"","y1RangeMin":0,"y1RangeMax":0,"y2Title":"", - //"y2RangeMin":0,"y2RangeMax":0,"plotType":"TIME", - //"children":[{"name":"imf","leaf":true,"text":"imf","paramArgs":"select...","isScatter":false, - //"needsArgs":false,"plotOnly":false,"yaxe":false}]}], - //"timesrc":"Interval","startDate":"2008-03-17T14:07:43","stopDate":"2008-03-17T15:26:18" - //"durationDay":"0000","durationHour":"01","durationMin":"18","durationSec":"35","leaf":true,"nodeType":"request"} - - - //XYPlot - //{"id":"","name":"","tabId":"1","outputName":"","orientation":"LANDSCAPE","format":"PNG","title":"", - //"description":"","charSize":1.3,"thickness":1,"ppp":3000,"forcedLayout":false,"forcedMulti":false, - //"children":[{"name":"Panel 1","leaf":false,"text":"","width":0.4,"height":0.4,"xTitle":"", - //"xRangeMin":0,"xRangeMax":0,"y1Title":"","y1RangeMin":0,"y1RangeMax":0,"y2Title":"", - //"y2RangeMin":0,"y2RangeMax":0,"plotType":"SCATTER", - //"scatterParam":{"phantom":true,"internalId":"ext-record-71","raw":{"name":"imf(1)"}, - //"data":{"id":"","name":"imf(1)"},"modified":{},"hasListeners":{},"events":{},"stores":[], - //"dirty":false,"id":"amdaModel.AmdaObject-ext-record-71"}, - //"children":[{"name":"#xmfi","leaf":true,"text":"#xmfi","paramArgs":"select...","isScatter":true, - //"needsArgs":false,"plotOnly":false,"yaxe":false}]}], - //"timesrc":"Interval","startDate":"2008-03-17T14:07:43","stopDate":"2008-03-17T15:26:18", - //"durationDay":"0000","durationHour":"01","durationMin":"18","durationSec":"35","leaf":true,"nodeType":"request"} - - $this->currentTabId = $input->tabId; - - $paramsNode = $this->paramsData->getRequestNode()->getParamsNode(); - - //unmarshall time definition - $this->unmarshallTimeDefinition($input); - - //unmarshall plot output definition - $outputsNode = $this->paramsData->getRequestNode()->getOutputsNode(); - $plotOutputNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::PLOT); - - $pageNode = $plotOutputNode->getPage(); - - //title - $pageNode->setTitle($input->description); - - //orientation = [['landscape','LANDSCAPE'], ['portrait', 'PORTRAIT']]; - $forceRotation = false; - switch (strtolower($input->orientation)) - { - case 'landscape' : - $pageNode->setOrientation(RequestOutputPlotPageOrientationEnum::LANDSCAPE); - break; - case 'portrait' : - $pageNode->setOrientation(RequestOutputPlotPageOrientationEnum::PORTRAIT); - $forceRotation = true; - break; - default : - $pageNode->setOrientation(RequestOutputPlotPageOrientationEnum::LANDSCAPE); - break; - } - - //format = [['PNG','PNG'], ['PDF', 'PDF'], ['PS', 'PostScript']]; - switch ($input->format) - { - case 'PNG' : - $pageNode->setFormat(RequestOutputPlotPageFormatEnum::PNG); - //interactive plot => disable batch mode - $this->paramsData->setBatchEnable(false); - $this->isInterractive = true; - break; - case 'PDF' : - $pageNode->setFormat(RequestOutputPlotPageFormatEnum::PDF); - $this->isInterractive = false; - break; - case 'PS' : - case 'PostScript' : - $pageNode->setFormat(RequestOutputPlotPageFormatEnum::PS); - $this->isInterractive = false; - break; - } - - //auto layout - if (count($input->children) > 1) - { - if ($input->forcedLayout) - $pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::AUTO); - else - $pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::VERTICAL); - } - $pageNode->getLayout()->setExpand("true"); - - //panels - - foreach ($input->children as $panel) - { - $panelNode = $pageNode->addPanel(); - $panelNode->setTitle($panel->name); - - //add plot element - switch ($panel->plotType) + $pageNode->setFormat($fileFormat); + + $this->unmarshallTitle($tab, 'page-title', $pageNode->getTitle()); + + switch ($tab->{'page-orientation'}) { - case "TIME" : - //time plot definition - $plotElementNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::TIMEPLOT); - //time axis definition - $timeAxisNode = $plotElementNode->getTimeAxis(); - $isXYPlot = false; + case 'landscape' : + $pageNode->setOrientation(RequestOutputPlotPageOrientationEnum::LANDSCAPE); break; - case "SCATTER" : - //XY plot definition - $plotElementNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::XYPLOT); - //x axis definition - $xAxisNode = $plotElementNode->getXAxis(); - $xAxisNode->getLegend()->setText($panel->xTitle); - if ((($panel->xRangeMin != 0) || ($panel->xRangeMax != 0)) && ($panel->xRangeMin < $panel->xRangeMax)) - $xAxisNode->getRange()->setMinMax($panel->xRangeMin, $panel->xRangeMax); - $isXYPlot = true; + case 'portrait' : + $pageNode->setOrientation(RequestOutputPlotPageOrientationEnum::PORTRAIT); break; } - - if (!isset($plotElementNode)) - //unknown plot type - continue; - - //y1 axis definition - $y1AxisNode = $plotElementNode->addYAxis("y1"); - $y1AxisNode->getLegend()->setText($panel->y1Title); - if ((($panel->y1RangeMin != 0) || ($panel->y1RangeMax != 0)) && ($panel->y1RangeMin < $panel->y1RangeMax)) - $y1AxisNode->getRange()->setMinMax($panel->y1RangeMin, $panel->y1RangeMax); - - //y2 axis definition - it will drawn only if at least one param is associated to this axis - $y2AxisNode = $plotElementNode->addYAxis("y2"); - $y2AxisNode->getLegend()->setText($panel->y2Title); - if ((($panel->y2RangeMin != 0) || ($panel->y2RangeMax != 0)) && ($panel->y2RangeMin < $panel->y2RangeMax)) - $y2AxisNode->getRange()->setMinMax($panel->y2RangeMin, $panel->y2RangeMax); - - //add xserie if XYPlot - if ($panel->plotType == "SCATTER") - { - //"scatterParam":{"phantom":true,"internalId":"ext-record-71","raw":{"name":"imf(1)"}, - //"data":{"id":"","name":"imf(1)"},"modified":{},"hasListeners":{},"events":{},"stores":[], - //"dirty":false,"id":"amdaModel.AmdaObject-ext-record-71"} - $paramInfo = $this->paramManager->addExistingParam($panel->scatterParam->data->name,$this->paramsData); - $paramsNode->addParam($paramInfo['id']); - - $paramNode = $plotElementNode->getParams()->getParamById($paramInfo['id']); - if (count($paramInfo['indexes']) == 0) - $paramNode->addXSerie($xAxisNode->getId(), -1); - else - { - $paramNode->addXSerie($xAxisNode->getId(), $paramInfo['indexes'][0]); - } + + switch ($tab->{'page-dimension'}) + { + case 'ISO A4' : + $pageNode->setDimension(RequestOutputPlotPageDimensionEnum::ISO_A4); + break; + case 'US letter' : + $pageNode->setDimension(RequestOutputPlotPageDimensionEnum::US_LETTER); + break; + default: + throw new Exception('Page dimension not implemented.'); } - //add yseries - foreach ($panel->children as $yserie) + switch ($tab->{'page-mode'}) { - //{"name":"imf","leaf":true,"text":"imf","paramArgs":"select...","isScatter":false, - //"needsArgs":false,"plotOnly":false,"yaxe":false} - - //{"name":"#xmfi","leaf":true,"text":"#xmfi","paramArgs":"select...","isScatter":true, - //"needsArgs":false,"plotOnly":false,"yaxe":false} - - $xAxis = ""; - if ($isXYPlot) - $xAxis = $xAxisNode->getId(); - - $yAxis = $y1AxisNode->getId(); - if ($yserie->yaxe) - $yAxis = $y2AxisNode->getId(); - - $paramInfo = $this->paramManager->addExistingParam($yserie->name,$this->paramsData); - $paramsNode->addParam($paramInfo['id']); - - $paramNode = $plotElementNode->getParams()->getParamById($paramInfo['id']); - if (count($paramInfo['indexes']) == 0) - { - $isSpectro = ($paramInfo['plotType'] == 'Spectra'); - if ($isSpectro && $panel->plotType == "TIME") - $paramNode->addSpectro($yAxis); - else - $paramNode->addYSerie($yAxis, -1,$xAxis); - } - else - { - foreach ($paramInfo['indexes'] as $index) - $paramNode->addYSerie($yAxis, $index,$xAxis); - } + case 'color' : + $pageNode->setMode(RequestOutputPlotPageModeEnum::COLOR); + break; + case 'grayscale' : + $pageNode->setMode(RequestOutputPlotPageModeEnum::GRAYSCALE); + break; + default: + throw new Exception('Page mode not implemented.'); } + + if ($tab->{'page-margins-activated'}) + { + $pageNode->getMargins()->setHorizontal($tab->{'page-margin-x'}); + $pageNode->getMargins()->setVertical($tab->{'page-margin-y'}); + } + + if ($tab->{'page-font-activated'}) + $this->unmarshallFont($tab, 'page', $pageNode->getFont()); + + $pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::VERTICAL); + + ++$requestIndex; } - + + $this->paramsData->setBatchEnable(!(($fileFormat == RequestOutputPlotPageFormatEnum::PNG) && ($input->{'file-output'} == 'INTERACTIVE'))); + //determine extension and add post processing if needed - $extension = ""; - switch (strtolower($pageNode->getFormat())) - { - case RequestOutputPlotPageFormatEnum::PNG : - $extension = ".png"; - break; - case RequestOutputPlotPageFormatEnum::PS : - $extension = ".ps"; - break; - case RequestOutputPlotPageFormatEnum::PDF : - $extension = ".pdf"; - break; - } - - $compression = ""; - if ($pageNode->getFormat() != RequestOutputPlotPageFormatEnum::PNG) + return $this->paramsData; + } + + protected function unmarshallTitle($inputData, $keyPrefix, $titleNode) + { + if ($inputData->{$keyPrefix.'-text'} != '') { - //one file per interval - $plotOutputNode->setStructure(RequestOutputPlotStructureEnum::ONE_FILE_PER_INTERVAL); - //auto compression if not PNG format - $compression = ".tar.gz"; - $plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::TAR); - $plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::GZIP); + $titleNode->setText($inputData->{$keyPrefix.'-text'}); + + switch ($inputData->{$keyPrefix.'-position'}) + { + case 'top' : + $titleNode->setPosition(RequestOutputPlotTitlePosition::TOP); + break; + case 'bottom' : + $titleNode->setPosition(RequestOutputPlotTitlePosition::BOTTOM); + break; + } + + switch ($inputData->{$keyPrefix.'-alignment'}) + { + case 'center' : + $titleNode->setAlign(RequestOutputPlotTitleAlign::CENTER); + break; + case 'left' : + $titleNode->setAlign(RequestOutputPlotTitleAlign::LEFT); + break; + case 'right' : + $titleNode->setAlign(RequestOutputPlotTitleAlign::RIGHT); + break; + } + + if ($inputData->{$keyPrefix.'-color'} != '') + $titleNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix.'-color'})); + + $this->unmarshallLabel($inputData, $keyPrefix, $titleNode); } - - //Set post command to retrieve request result file - //Use a cache killer (ie - random string in file name) - $resultFile = "plot_".CommonClass::generateRandomString(6); - $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY, $resultFile); - - if ($pageNode->getFormat() != RequestOutputPlotPageFormatEnum::PNG) + } + + protected function unmarshallLabel($inputData, $keyPrefix, $labelNode) + { + if ($inputData->{$keyPrefix.'-font-activated'}) { - $postProcessCmd = "mv plot_*".$compression; - $postProcessCmd .= " ".$resultFile.$extension.$compression; + $labelNode->setFontName($inputData->{$keyPrefix.'-font-name'}); + $labelNode->setFontSize($inputData->{$keyPrefix.'-font-size'}); + $style = ""; + if ($inputData->{$keyPrefix.'-font-bold'}) + { + if ($style != "") + $style .= ","; + $style .= "bold"; + } + if ($inputData->{$keyPrefix.'-font-italic'}) + { + if ($style != "") + $style .= ","; + $style .= "italic"; + } + if ($style != "") + $labelNode->setFontStyle($style); } - else + + } + + protected function unmarshallFont($inputData, $keyPrefix, $fontNode) + { + if ($inputData->{$keyPrefix.'-font-activated'}) { - $postProcessCmd = "mv plot_*"; - $postProcessCmd .= $extension; - $postProcessCmd .= " ".$resultFile.$extension; - if ($forceRotation) - $postProcessCmd .= " | convert ".$resultFile.$extension." -rotate -90 ".$resultFile.$extension; + $fontNode->setFontName($inputData->{$keyPrefix.'-font-name'}); + $fontNode->setSize($inputData->{$keyPrefix.'-font-size'}); + + if ($inputData->{$keyPrefix.'-font-italic'}) + $fontNode->setStyle(RequestOutputPlotFontStyle::ITALIC); + else + $fontNode->setStyle(RequestOutputPlotFontStyle::UPRIGHT); + + if ($inputData->{$keyPrefix.'-font-bold'}) + $fontNode->setWeight(RequestOutputPlotFontWeight::BOLD); + else + $fontNode->setWeight(RequestOutputPlotFontWeight::MEDIUM); } - - $this->paramsData->setPostCmd($postProcessCmd); - - return $this->paramsData; } /* @@ -351,6 +263,16 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass } } + private function hexColor2KernelColor($hex) { + $hex = str_replace("#", "", $hex); + + $r = hexdec(substr($hex,0,2)); + $g = hexdec(substr($hex,2,2)); + $b = hexdec(substr($hex,4,2)); + + return "[".$r.",".$g.",".$b."]"; + } + private function saveIHMRequest($input) { $path = $this->getWorkingPath()."ihm.request"; diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputDownloadNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputDownloadNodeClass.php index 1b1b8cf..f13c656 100644 --- a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputDownloadNodeClass.php +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputDownloadNodeClass.php @@ -146,7 +146,7 @@ class RequestOutputDownloadNodeClass extends NodeClass public function getFileName() { - $node = $this->getChildInstanceByName(REQUESTOUTPUTDOWNLOAD_FILEFORMAT); + $node = $this->getChildInstanceByName(REQUESTOUTPUTDOWNLOAD_FILENAME); return (($node == NULL) ? "" : $node->getValue()); } diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotFontNameEnumClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotFontNameEnumClass.php new file mode 100644 index 0000000..7fed42a --- /dev/null +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotFontNameEnumClass.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotFontNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotFontNodeClass.php new file mode 100644 index 0000000..4c06675 --- /dev/null +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotFontNodeClass.php @@ -0,0 +1,77 @@ +setAttribute(REQUESTOUTPUTPLOTFONT_NAME, $fontName); + } + + public function getFontName() + { + return $this->getAttribute(REQUESTOUTPUTPLOTFONT_NAME); + } + + public function setSize($size) + { + $this->setAttribute(REQUESTOUTPUTPLOTFONT_SIZE, $size); + } + + public function getSize() + { + return $this->getAttribute(REQUESTOUTPUTPLOTFONT_SIZE); + } + + public function setStyle($style) + { + $this->setAttribute(REQUESTOUTPUTPLOTFONT_STYLE, $style); + } + + public function getStyle() + { + return $this->getAttribute(REQUESTOUTPUTPLOTFONT_STYLE); + } + + public function setWeight($weight) + { + $this->setAttribute(REQUESTOUTPUTPLOTFONT_WEIGHT, $weight); + } + + public function getWeight() + { + return $this->getAttribute(REQUESTOUTPUTPLOTFONT_WEIGHT); + } +} + +?> \ No newline at end of file diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotMarginsNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotMarginsNodeClass.php new file mode 100644 index 0000000..f8acc58 --- /dev/null +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotMarginsNodeClass.php @@ -0,0 +1,42 @@ + + +setAttribute(REQUESTOUTPUTPLOTMARGINS_HORIZONTAL, $horizontal); + } + + public function getHorizontal() + { + return $this->getAttribute(REQUESTOUTPUTPLOTMARGINS_HORIZONTAL); + } + + public function setVertical($vertical) + { + $this->setAttribute(REQUESTOUTPUTPLOTMARGINS_VERTIVAL, $vertical); + } + + public function getVertical() + { + return $this->getAttribute(REQUESTOUTPUTPLOTMARGINS_VERTIVAL); + } +} + +?> \ No newline at end of file diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotNodeClass.php index 06062e3..92e09ab 100644 --- a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotNodeClass.php +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotNodeClass.php @@ -5,6 +5,7 @@ require_once("RequestOutputPostProcessingNodeClass.php"); define ("REQUESTOUTPUTPLOT_NAME", "plot"); define ("REQUESTOUTPUTPLOT_STRUCTURE", "outputStructure"); +define ("REQUESTOUTPUTPLOT_FILEPREFIX", "filePrefix"); abstract class RequestOutputPlotStructureEnum { @@ -24,6 +25,8 @@ class RequestOutputPlotNodeClass extends NodeClass parent::__construct(REQUESTOUTPUTPLOT_NAME); //default properties $this->setStructure(RequestOutputPlotStructureEnum::ONE_FILE); + //default prefix + $this->setFilePrefix("plot"); //force page construction $this->getPage(); } @@ -40,6 +43,18 @@ class RequestOutputPlotNodeClass extends NodeClass return (($node == NULL) ? RequestOutputPlotStructureEnum::ONE_FILE : $node->getValue()); } + public function setFilePrefix($prefix) + { + $node = $this->getChildInstanceByName(REQUESTOUTPUTPLOT_FILEPREFIX, true); + $node->setValue($prefix); + } + + public function getFilePrefix() + { + $node = $this->getChildInstanceByName(REQUESTOUTPUTPLOT_FILEPREFIX); + return (($node == NULL) ? "" : $node->getValue()); + } + public function getPage() { $node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTPAGE_NAME); diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotPageNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotPageNodeClass.php index fd4fa60..3ed3248 100644 --- a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotPageNodeClass.php +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotPageNodeClass.php @@ -53,21 +53,44 @@ class RequestOutputPlotPageNodeClass extends NodeClass $this->setMode(RequestOutputPlotPageModeEnum::COLOR); } - public function setTitle($title) + public function getTitle() { - $node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTPAGE_TITLE, true); - $node->setValue($title); + $node = $this->getFirstChildByName(REQUESTOUTPUTPLOTPAGE_TITLE); + + if (!isset($node)) + { + $node = new RequestOutputPlotTitleNodeClass(); + $this->addChild($node); + } + + return $node; } - public function getTitle() + public function getMargins() { - $node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTPAGE_TITLE); - return (($node == NULL) ? "" : $node->getValue()); + $node = $this->getFirstChildByName(REQUESTOUTPUTPLOTMARGINS_NAME); + + if (!isset($node)) + { + $node = new RequestOutputPlotMarginsNodeClass(); + $this->addChild($node); + } + + return $node; + } + + public function getFont() + { + $node = $this->getFirstChildByName(REQUESTOUTPUTPLOTFONT_NODENAME); + + if (!isset($node)) + { + $node = new RequestOutputPlotFontNodeClass(); + $this->addChild($node); + } + + return $node; } - - /* ToDo margin */ - - /* ToDo font */ public function getLayout() { @@ -82,8 +105,6 @@ class RequestOutputPlotPageNodeClass extends NodeClass return $node; } - /* ToDo panelDefaults */ - public function addPanel() { $node = new RequestOutputPlotPanelNodeClass(); @@ -135,8 +156,6 @@ class RequestOutputPlotPageNodeClass extends NodeClass { return $this->getAttribute(REQUESTOUTPUTPLOTPAGE_MODE); } - - /* ToDo plot size and margins */ } ?> \ No newline at end of file diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotTitleNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotTitleNodeClass.php new file mode 100644 index 0000000..ffb8e8d --- /dev/null +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotTitleNodeClass.php @@ -0,0 +1,120 @@ +setValue($text); + } + + public function getText() + { + return $this->getValue(); + } + + public function setPosition($position) + { + $this->setAttribute(REQUESTOUTPUTPLOTTITLE_POSITION, $position); + } + + public function getPosition() + { + return $this->getAttribute(REQUESTOUTPUTPLOTTITLE_POSITION); + } + + public function setAlign($align) + { + $this->setAttribute(REQUESTOUTPUTPLOTTITLE_ALIGN, $align); + } + + public function getAlign() + { + return $this->getAttribute(REQUESTOUTPUTPLOTTITLE_ALIGN); + } + + public function setFontName($fontName) + { + $this->setAttribute(REQUESTOUTPUTPLOTTITLE_FONTNAME, $fontName); + } + + public function getFontName() + { + return $this->getAttribute(REQUESTOUTPUTPLOTTITLE_FONTNAME); + } + + public function setFontSize($fontSize) + { + $this->setAttribute(REQUESTOUTPUTPLOTTITLE_FONTSIZE, $fontSize); + } + + public function getFontSize() + { + return $this->getAttribute(REQUESTOUTPUTPLOTTITLE_FONTSIZE); + } + + public function setFontStyle($style) + { + $this->setAttribute(REQUESTOUTPUTPLOTTITLE_STYLE, $style); + } + + public function getFontStyle() + { + return $this->getAttribute(REQUESTOUTPUTPLOTTITLE_STYLE); + } + + public function setColor($color) + { + $this->setAttribute(REQUESTOUTPUTPLOTTITLE_COLOR, $color); + } + + public function getColor() + { + return $this->getAttribute(REQUESTOUTPUTPLOTTITLE_COLOR); + } + + public function setColorMapIndex($colorMapIndex) + { + $this->setAttribute(REQUESTOUTPUTPLOTTITLE_COLORMAPINDEX, $colorMapIndex); + } + + public function getColorMapIndex() + { + return $this->getAttribute(REQUESTOUTPUTPLOTTITLE_COLORMAPINDEX); + } +} + +?> \ No newline at end of file diff --git a/src/Request/ParamsRequestImpl/ParamsRequestClass.php b/src/Request/ParamsRequestImpl/ParamsRequestClass.php index 6f2d2dd..991c004 100644 --- a/src/Request/ParamsRequestImpl/ParamsRequestClass.php +++ b/src/Request/ParamsRequestImpl/ParamsRequestClass.php @@ -19,7 +19,16 @@ class ParamsRequestClass extends ProcessRequestClass switch ($this->requestData->getRequestType()) { case ParamsRequestTypeEnumClass::XMLREQUEST : - $this->requestData->setCmd(KernelConfigClass::getKernelBinPath()."amdaXMLRequestorTool ".$this->getRequestFilePath()); + $cmd = ""; + $requestIndex = 0; + foreach ($this->requestData->getRequestNodes() as $requestNode) + { + if ($cmd != "") + $cmd .= " && "; + $cmd .= KernelConfigClass::getKernelBinPath()."amdaXMLRequestorTool ".$this->getRequestFilePath($requestIndex); + ++$requestIndex; + } + $this->requestData->setCmd($cmd); break; case ParamsRequestTypeEnumClass::PARAMGEN : $this->requestData->setCmd(KernelConfigClass::getKernelBinPath()."amdaParameterGenerator -p ".$this->requestData->getParamId()); @@ -50,29 +59,35 @@ class ParamsRequestClass extends ProcessRequestClass if ($this->requestData->getRequestType() == ParamsRequestTypeEnumClass::XMLREQUEST) { - //create XML request file - $doc = new DOMDocument("1.0", "UTF-8"); - $doc->preserveWhiteSpace = false; - $doc->formatOutput = true; - - if (!$xmlNode = $this->requestData->getRequestNode()->toXMLNode($doc)) + $requestIndex = 0; + foreach ($this->requestData->getRequestNodes() as $requestNode) { - $this->requestData->setLastErrorMessage('Cannot create params request XML file'); - return false; - } + //create XML request file + $doc = new DOMDocument("1.0", "UTF-8"); + $doc->preserveWhiteSpace = false; + $doc->formatOutput = true; + + if (!$xmlNode = $requestNode->toXMLNode($doc)) + { + $this->requestData->setLastErrorMessage('Cannot create params request XML file for request '.$requestIndex); + return false; + } - $doc->appendChild($xmlNode); - - if (!$doc->schemaValidate(KernelConfigClass::getXSDRequestFilePath())) - { - $this->requestData->setLastErrorMessage('Params request XML file not valid'); - return false; - } - - if (!$doc->save($this->getRequestFilePath())) - { - $this->requestData->setLastErrorMessage('Cannot save params request XML file'); - return false; + $doc->appendChild($xmlNode); + + if (!$doc->schemaValidate(KernelConfigClass::getXSDRequestFilePath())) + { + $this->requestData->setLastErrorMessage('Params request XML file not valid for request '.$requestIndex); + return false; + } + + if (!$doc->save($this->getRequestFilePath($requestIndex))) + { + $this->requestData->setLastErrorMessage('Cannot save params request XML file for request '.$requestIndex); + return false; + } + + ++$requestIndex; } } @@ -168,9 +183,9 @@ class ParamsRequestClass extends ProcessRequestClass /* * @brief Get the request file path for AMDA_Kernel */ - private function getRequestFilePath() + private function getRequestFilePath($requestIndex) { - return $this->requestData->getWorkingPath()."request.xml"; + return $this->requestData->getWorkingPath()."request_".$requestIndex.".xml"; } } ?> diff --git a/src/Request/ParamsRequestImpl/ParamsRequestDataClass.php b/src/Request/ParamsRequestImpl/ParamsRequestDataClass.php index 2201d6b..4f342e6 100644 --- a/src/Request/ParamsRequestImpl/ParamsRequestDataClass.php +++ b/src/Request/ParamsRequestImpl/ParamsRequestDataClass.php @@ -20,7 +20,7 @@ abstract class ParamsRequestTypeEnumClass class ParamsRequestDataClass extends ProcessRequestDataClass { private $requestType = ParamsRequestTypeEnumClass::XMLREQUEST; - private $requestNode = null; + private $requestNodes = array(); private $compilationPath = ""; private $localBasePath = ""; private $waitingResults = array(); @@ -32,7 +32,6 @@ class ParamsRequestDataClass extends ProcessRequestDataClass function __construct() { parent::__construct(); - $this->requestNode = new RequestNodeClass(); } public function getCompilationPath() @@ -65,9 +64,16 @@ class ParamsRequestDataClass extends ProcessRequestDataClass $this->requestType = $requestType; } - public function getRequestNode() + public function addRequestNode() { - return $this->requestNode; + $newRequestNode = new RequestNodeClass(); + $this->requestNodes[] = $newRequestNode; + return $newRequestNode; + } + + public function getRequestNodes() + { + return $this->requestNodes; } public function getWaitingResult($key) diff --git a/src/Request/ProcessRequestImpl/Process/ProcessManagerClass.php b/src/Request/ProcessRequestImpl/Process/ProcessManagerClass.php index c9d5e42..7728d5a 100644 --- a/src/Request/ProcessRequestImpl/Process/ProcessManagerClass.php +++ b/src/Request/ProcessRequestImpl/Process/ProcessManagerClass.php @@ -202,7 +202,7 @@ class ProcessManagerClass $node = $dom->createElement($name); $parentNode->appendChild($node); } - $node->nodeValue = $value; + $node->nodeValue = htmlspecialchars($value); return $node; } diff --git a/test/debug_request.php b/test/debug_request.php new file mode 100644 index 0000000..de522be --- /dev/null +++ b/test/debug_request.php @@ -0,0 +1,9 @@ + $debug_1); + +?> + + diff --git a/test/test.php b/test/test.php index 9e22334..d36684c 100644 --- a/test/test.php +++ b/test/test.php @@ -10,14 +10,18 @@ require(__DIR__.'/../config/AMDAIntegrationConfig.php'); define("NEWKERNEL_DEBUG",true); define("NEWKERNEL_DEBUG_USER","test-integration"); +define('BASE_PATH', IHM_SRC_DIR); +define('DATAPATH', BASE_PATH.'generic_data/'); + //define test suite -require_once(__DIR__."/US42/test_us42.php"); +/*require_once(__DIR__."/US42/test_us42.php"); require_once(__DIR__."/US44/test_us44.php"); require_once(__DIR__."/US43/test_us43.php"); require_once(__DIR__."/US78/test_us78.php"); -require_once(__DIR__."/LocalParam/test_localparam.php"); +require_once(__DIR__."/LocalParam/test_localparam.php");*/ +require_once(__DIR__."/debug_request.php"); -$testSuite = array($us42,$us44,$us43,$us78,$localparam); +$testSuite = array($debug)/*$us42,$us44,$us43,$us78,$localparam)*/; //include required IHM source require_once(IHM_SRC_DIR."php/classes/AmdaAction.php"); -- libgit2 0.21.2