protected function selectBoundary4CubeRequest(DataControllerCallContext $callcontext, AbstractCubeQueryRequest $request, $datasetName, $columnName) { $isSortAscending = $this->isSortAscending(); $resultColumnName = NULL; // preparing new cube meta data $expressionRequest = new CubeQueryRequest($request->getCubeName()); // needs to be called before any additional methods are called $expressionRequest->addOptions($request->options); // copying ONLY some query objects (excluding at least a reference to this operator) // -- dimension queries $dimensionQueries = $request->findDimensionQueries(); if (isset($dimensionQueries)) { foreach ($dimensionQueries as $query) { foreach ($query->columns as $queryColumn) { foreach ($queryColumn->values as $value) { if ($this->shouldValueBeSkipped($value)) { continue; } // updating request configuration for the value supported by this class if ($this->operatorHandler === $value) { $resultColumnName = ParameterNameHelper::assemble($query->name, $queryColumn->name); // returning only observing column of the dimension $expressionRequest->addDimensionColumn(0, $query->name, $queryColumn->name); // ... and excluding NULL values from evaluation $expressionRequest->addDimensionColumnQueryValue( $query->name, $queryColumn->name, OperatorFactory::getInstance()->initiateHandler(NotEqualOperatorHandler::OPERATOR__NAME, NULL)); // sorting data $expressionRequest->addOrderByColumn( ColumnBasedComparator_AbstractSortingConfiguration::assembleDirectionalColumnName($resultColumnName, $isSortAscending)); } else { $expressionRequest->addDimensionColumnQueryValue($query->name, $queryColumn->name, $value); } } } } } // -- facts dataset column queries $factsDatasetColumnQueries = $request->findFactsDatasetColumnQueries(); if (isset($factsDatasetColumnQueries)) { foreach ($factsDatasetColumnQueries as $query) { $values = NULL; foreach ($query->values as $value) { if ($this->shouldValueBeSkipped($value)) { continue; } if ($this->operatorHandler === $value) { $metamodel = data_controller_get_metamodel(); $cube = $metamodel->getCube($expressionRequest->getCubeName()); // finding dimension associated with this fact column $selectedDimension = NULL; if (isset($cube->dimensions)) { foreach ($cube->dimensions as $dimension) { if ($dimension->attributeColumnName == $query->name) { $selectedDimension = $dimension; break; } } } if (!isset($selectedDimension)) { throw new IllegalArgumentException(t( 'Boundary-related operator cannot be applied to the facts dataset column: %columnName', array('%columnName' => $query->name))); } $resultColumnName = ParameterNameHelper::assemble($selectedDimension->name); // returning only observing column from facts dataset $expressionRequest->addDimension(0, $selectedDimension->name); // ... and excluding NULL values from evaluation $expressionRequest->addFactsDatasetColumnQueryValue( $query->name, OperatorFactory::getInstance()->initiateHandler(NotEqualOperatorHandler::OPERATOR__NAME, NULL)); // sorting data $expressionRequest->addOrderByColumn( ColumnBasedComparator_AbstractSortingConfiguration::assembleDirectionalColumnName($resultColumnName, $isSortAscending)); } else { $values[] = $value; } } if (isset($values)) { $expressionRequest->addFactsDatasetColumnQueryValues($query->name, $values); } } } // -- measure queries $measureQueries = $request->findMeasureQueries(); if (isset($measureQueries)) { foreach ($measureQueries as $query) { foreach ($query->values as $value) { if ($this->shouldValueBeSkipped($value)) { throw new IllegalArgumentException(t('Boundary-related operator cannot be applied to measures')); } } $expressionRequest->queries[] = clone $query; } } // limiting response to one record $expressionRequest->setPagination(1, 0); return $this->processCubeExpressionRequest($callcontext, $expressionRequest, $resultColumnName); }
protected function selectBoundary4CubeRequest(DataControllerCallContext $callcontext, CubeQueryRequest $request, $datasetName, $columnName) { $isSortAscending = $this->isSortAscending(); $resultColumnName = NULL; // preparing new cube meta data $expressionRequest = new CubeQueryRequest($request->getCubeName()); // copying ONLY some query objects (excluding at least a reference to this operator) // -- dimension queries $dimensionQueries = $request->findDimensionQueries(); if (isset($dimensionQueries)) { foreach ($dimensionQueries as $query) { foreach ($query->values as $propertyValue) { foreach ($propertyValue->values as $value) { if ($value->isSubsetBased()) { // skipping other instances which are based on subset of data if their weight is greater than of this operator if (isset($value->weight) && $value->weight > $this->operatorHandler->weight) { continue; } } // updating request configuration for the value supported by this class if ($this->operatorHandler === $value) { $resultColumnName = ParameterHelper::assembleParameterName($query->dimensionName, $query->levelName, $propertyValue->name); // returning only observing property of the dimension level $expressionRequest->addDimensionLevelProperty(0, $query->dimensionName, $query->levelName, $propertyValue->name); // ... and excluding NULL values from evaluation $expressionRequest->addDimensionLevelPropertyQueryValue($query->dimensionName, $query->levelName, $propertyValue->name, data_controller_get_operator_factory_instance()->initiateHandler(NotEqualOperatorHandler::$OPERATOR__NAME, NULL)); // sorting data $expressionRequest->addOrderByColumn(PropertyBasedComparator_DefaultSortingConfiguration::assembleDirectionalPropertyName($resultColumnName, $isSortAscending)); } else { $expressionRequest->addDimensionLevelPropertyQueryValue($query->dimensionName, $query->levelName, $propertyValue->name, $value); } } } } } // -- source dataset property queries $sourceDatasetPropertyQueries = $request->findSourceDatasetPropertyQueries(); if (isset($sourceDatasetPropertyQueries)) { foreach ($sourceDatasetPropertyQueries as $query) { foreach ($query->values as $value) { if ($value->isSubsetBased()) { throw new UnsupportedOperationException(t('Boundary-related operator cannot filter cube source dataset property values yet')); } } $expressionRequest->queries[] = clone $query; } } // -- measure queries $measureQueries = $request->findMeasureQueries(); if (isset($measureQueries)) { foreach ($measureQueries as $query) { foreach ($query->values as $value) { if ($value->isSubsetBased()) { throw new UnsupportedOperationException(t('Boundary-related operator cannot filter measure values yet')); } } $expressionRequest->queries[] = clone $query; } } // limiting response to one record $expressionRequest->setPagination(1, 0); return $this->processCubeExpressionRequest($callcontext, $expressionRequest, $resultColumnName); }