/** * */ public static function exportAsRdfTurtle($dataHash, $model, $titleHelperLimit, $dimensionElementLimit) { $c = new CubeViz_ConfigurationLink($model, $titleHelperLimit, $dimensionElementLimit); $data = array(); // get all information to export list($data, $dh) = $c->read($dataHash, 'data'); $graph = new EasyRdf_Graph(); EasyRdf_Namespace::set('qb', 'http://purl.org/linked-data/cube#'); /** * selected data structure definition */ foreach ($data['dataStructureDefinitions'] as $element) { if ($data['selectedDSD']['__cv_uri'] == $element['__cv_uri']) { // go through all non-cubeviz element values foreach ($element as $predicateUri => $object) { // no cubeviz internal information, its plain from the store if (false === strstr($predicateUri, '__cv_')) { CubeViz_Exporter::handleNonCVObjects($element['__cv_uri'], $predicateUri, $object, $graph); } } } } /** * selected data set */ foreach ($data['dataSets'] as $element) { if ($data['selectedDS']['__cv_uri'] == $element['__cv_uri']) { // go through all non-cubeviz element values foreach ($element as $predicateUri => $object) { // no cubeviz internal information, its plain from the store if (false === strstr($predicateUri, '__cv_')) { CubeViz_Exporter::handleNonCVObjects($element['__cv_uri'], $predicateUri, $object, $graph); } } } } /** * selected components: component specifications of the dimensions */ foreach ($data['selectedComponents']['dimensions'] as $element) { // go through all non-cubeviz element values foreach ($element as $predicateUri => $object) { // no cubeviz internal information, its plain from the store if (false === strstr($predicateUri, '__cv_')) { CubeViz_Exporter::handleNonCVObjects($element['__cv_uri'], $predicateUri, $object, $graph); } } // dimension itself $dimension = $element['http://purl.org/linked-data/cube#dimension']; $graph->addResource($dimension, 'rdf:type', 'qb:DimensionProperty'); // dimension elements foreach ($element['__cv_elements'] as $dimension) { // go through all non-cubeviz element values foreach ($dimension as $predicateUri => $object) { // no cubeviz internal information, its plain from the store if (false === strstr($predicateUri, '__cv_')) { CubeViz_Exporter::handleNonCVObjects($element['__cv_uri'], $predicateUri, $object, $graph); } } } } /** * selected components: component specifications of the selected attribute */ if (true === isset($data['selectedComponents']['attribute']) && true === is_array($data['selectedComponents']['attribute']) && 0 < count($data['selectedComponents']['attribute'])) { foreach ($data['selectedComponents']['attribute'] as $predicateUri => $object) { // no cubeviz internal information, its plain from the store if (false === strstr($predicateUri, '__cv_')) { CubeViz_Exporter::handleNonCVObjects($data['selectedComponents']['attribute']['__cv_uri'], $predicateUri, $object, $graph); } } $unit = $data['selectedComponents']['attribute']['http://purl.org/linked-data/cube#attribute']; $graph->addResource($unit, 'rdf:type', 'qb:AttributeProperty'); } /** * selected components: component specifications of the selected measure */ foreach ($data['selectedComponents']['measure'] as $predicateUri => $object) { // no cubeviz internal information, its plain from the store if (false === strstr($predicateUri, '__cv_')) { CubeViz_Exporter::handleNonCVObjects($data['selectedComponents']['measure']['__cv_uri'], $predicateUri, $object, $graph); } } $measure = $data['selectedComponents']['measure']['http://purl.org/linked-data/cube#measure']; $graph->addResource($measure, 'rdf:type', 'qb:MeasureProperty'); /** * Observations */ foreach ($data['retrievedObservations'] as $element) { foreach ($element as $predicateUri => $object) { // no cubeviz internal information, its plain from the store if (false === strstr($predicateUri, '__cv_')) { CubeViz_Exporter::handleNonCVObjects($element['__cv_uri'], $predicateUri, $object, $graph); } } } return "#" . PHP_EOL . "# CubeViz Export of data hash " . $dataHash . PHP_EOL . "#" . PHP_EOL . PHP_EOL . $graph->serialise('turtle'); }