[Fusionforge-commits] r15905 - in branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application: controllers views/scripts/fusionforgecm

Olivier Berger olberger at fusionforge.org
Fri Jun 29 17:24:23 CEST 2012


Author: olberger
Date: 2012-06-29 17:24:22 +0200 (Fri, 29 Jun 2012)
New Revision: 15905

Added:
   branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/read-resource-collection.atom.phtml
Modified:
   branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/controllers/CmController.php
   branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php
   branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/_resource_xml.php
   branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/read-resource-collection.xml.phtml
Log:
Add RDF and separate ATOM from RDF for resourcecollection action (query all tickets)

Modified: branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/controllers/CmController.php
===================================================================
--- branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/controllers/CmController.php	2012-06-29 09:06:45 UTC (rev 15904)
+++ branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/controllers/CmController.php	2012-06-29 15:24:22 UTC (rev 15905)
@@ -87,6 +87,7 @@
 
 							'readResource'=> array(
 								'application/x-oslc-cm-change-request+xml' => 'xml',
+								'application/rdf+xml' => 'xml',
 								'application/xml' => 'xml',
 								'text/xml' => 'xml',
 				 				'application/json' => 'json',
@@ -94,8 +95,9 @@
 								),
 
 							'readResourceCollection' => array(
-								'application/atom+xml' => 'xml',
 								'application/xml' => 'xml',
+								'application/rdf+xml' => 'xml',
+								'application/atom+xml' => 'atom',
 								'application/json' => 'json'
 								),
 

Modified: branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php
===================================================================
--- branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php	2012-06-29 09:06:45 UTC (rev 15904)
+++ branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php	2012-06-29 15:24:22 UTC (rev 15905)
@@ -102,6 +102,14 @@
 
 		$contextSwitch = $this->_helper->getHelper('contextSwitch');
 
+		// add an atom context
+                $atomContextSpec = array(
+					 'suffix'        => 'atom',
+					 );
+                if (! $contextSwitch->hasContext('atom')) {     
+		  $contextSwitch->addContext('atom', $atomContextSpec);
+		}
+
 		// we'll handle JSON ourselves
 		$contextSwitch->setAutoJsonSerialization(false);
 		$types = array();

Modified: branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/_resource_xml.php
===================================================================
--- branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/_resource_xml.php	2012-06-29 09:06:45 UTC (rev 15904)
+++ branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/_resource_xml.php	2012-06-29 15:24:22 UTC (rev 15905)
@@ -32,7 +32,7 @@
 	}
 }
 
-function createRessourceCollectionView($view){
+function createRessourceCollectionAtomView($view){
 	$feedcharset = 'UTF-8';
 	$feedauthor = 'FusionForge OSLC-CM plugin';
 
@@ -89,6 +89,38 @@
 	return $doc->saveXML();
 }
 
+function createRessourceCollectionRdfView($view){
+	$doc = new DOMDocument();
+	$doc->formatOutput = true;
+
+	$root = $doc->createElementNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf:RDF");
+	$root = $doc->appendChild($root);
+	$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
+	$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:rdfs', 'http://www.w3.org/2000/01/rdf-schema#');
+	$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:dcterms', 'http://purl.org/dc/terms/');
+	$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:oslc', 'http://open-services.net/ns/core#');
+
+	$responseInfo = $doc->createElement("oslc:ResponseInfo");
+	$responseInfo->setAttribute("rdf:about", $view->id);
+
+	$titlenode = $doc->createElement("dcterms:title", TRACKER_TYPE.' OSLC-CM ChangeRequests found in Tracker'. $view->tracker);
+	$responseInfo->appendChild($titlenode);
+
+	$root->appendChild($responseInfo);
+	
+	$rdfDescription = $doc->createElement("rdf:Description");
+	$rdfDescription->setAttribute("rdf:about", $view->id);
+
+	foreach ($view->collection as $entry) {
+	  $member = $doc->createElement("rdfs:member");
+	  $member->setAttribute("rdf:resource", $entry['id']);
+	  $rdfDescription->appendChild($member);
+	}
+	$root->appendChild($rdfDescription);
+
+	return $doc->saveXML();
+}
+
 function createResourceView($view)
 {
 	$doc = new DOMDocument();
@@ -103,6 +135,7 @@
 	$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:foaf', 'http://http://xmlns.com/foaf/0.1/');
 	$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:oslc', 'http://open-services.net/ns/core#');
 	$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:oslc_cm', 'http://open-services.net/ns/cm#');
+	$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:helios_bt', 'http://heliosplatform.sourceforge.net/ontologies/2010/05/helios_bt.owl#');
 
 	$child = $doc->createElement("oslc_cm:ChangeRequest");
 	$changerequest = $ressource->appendChild($child);

Copied: branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/read-resource-collection.atom.phtml (from rev 15902, branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/read-resource-collection.xml.phtml)
===================================================================
--- branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/read-resource-collection.atom.phtml	                        (rev 0)
+++ branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/read-resource-collection.atom.phtml	2012-06-29 15:24:22 UTC (rev 15905)
@@ -0,0 +1,22 @@
+<?php
+
+/*
+ * This file is (c) Copyright 2009 by Olivier BERGER, Institut
+ * TELECOM
+ *
+ * Use, modification, redistribution of this software are subject to
+ * the terms of the NEW BSD License, whose text can be found in the
+ * 'COPYING' file that is distributed along with the software archive.
+ *
+ * Thus you may use it at your own risk, of course !
+ *
+ * This program has been developed in the frame of the HELIOS
+ * project with financial support of its funders.
+ *
+ */
+
+/* $Id$ */
+
+require_once('_resource_xml.php');
+
+print createRessourceCollectionAtomView($this);
\ No newline at end of file

Modified: branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/read-resource-collection.xml.phtml
===================================================================
--- branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/read-resource-collection.xml.phtml	2012-06-29 09:06:45 UTC (rev 15904)
+++ branches/Branch_5_2/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecm/read-resource-collection.xml.phtml	2012-06-29 15:24:22 UTC (rev 15905)
@@ -19,4 +19,4 @@
 
 require_once('_resource_xml.php');
 
-print createRessourceCollectionView($this);
\ No newline at end of file
+print createRessourceCollectionRdfView($this);
\ No newline at end of file




More information about the Fusionforge-commits mailing list