Commit da78a05f authored by Olivier Lequeux's avatar Olivier Lequeux
Browse files

add xsd options to entries class

parent b49bdf77
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns="https://gitlab.in2p3.fr/opsportal/lavoisierquery/raw/master/ex_entries.xsd"
targetNamespace="https://gitlab.in2p3.fr/opsportal/lavoisierquery/raw/master/ex_entries.xsd"
xmlns:tns="https://gitlab.in2p3.fr/opsportal/lavoisiercli/raw/master/resources/ex_entries.xsd"
targetNamespace="https://gitlab.in2p3.fr/opsportal/lavoisiercli/raw/master/resources/ex_entries.xsd"
attributeFormDefault="unqualified" elementFormDefault="qualified">
<!--
@author : Olivier Lequeux
......
......@@ -8,10 +8,34 @@ namespace Lavoisier\Entries;
* Date: 28/10/13
*/
const $EX_ENTRIES_XMLNS = ""
class Entries extends \ArrayObject implements IEntries
{
// original simple entries/entry Lavoisier xsd (it's a subset of the following one)
const XMLNS_entries = "http://software.in2p3.fr/lavoisier/entries.xsd";
// extended recursive entries/entries/.../entries/entry lavoisiercli xsd
const XMLNS_ex_entries = "https://gitlab.in2p3.fr/opsportal/lavoisiercli/raw/master/resources/ex_entries.xsd";
/*
* @param bool set true to ask original Lavoisier XMLNS
* @return string XMLNS
*/
static public function getXMLNS($useLavoisierXMLNS = true)
{
if (true === $useLavoisierXMLNS) {
return self::XMLNS_entries;
} else {
return self::XMLNS_ex_entries;
}
}
public function __construct()
{
$this->useLavoisierXMLNS = true;
}
public function init()
{
}
......@@ -24,6 +48,7 @@ class Entries extends \ArrayObject implements IEntries
if ($iterator->valid()) {
$item = $iterator->current();
}
return $item;
}
......@@ -52,9 +77,9 @@ class Entries extends \ArrayObject implements IEntries
return self::convertToEntries($this);
}
static protected function convertToEntries($data)
static protected function convertToEntries($data , $useLavoisierXMLNS = true)
{
$xml = '<e:entries xmlns:e="http://software.in2p3.fr/lavoisier/entries.xsd">';
$xml = sprintf('<e:entries xmlns:e="%s">', self::getXMLNS($useLavoisierXMLNS));
foreach ($data as $key => $entry) {
if (is_array($entry)) {
$xml .= self::convertToEntries($entry);
......@@ -62,6 +87,7 @@ class Entries extends \ArrayObject implements IEntries
$xml .= '<e:entry key ="' . $key . '">' . $entry . '</e:entry>';
}
}
return $xml . '</e:entries>';
}
......
......@@ -2,8 +2,6 @@
namespace Lavoisier\Hydrators;
use \Lavoisier\IHydrator;
class StringHydrator implements IHydrator{
public function hydrate($str) {
......
......@@ -40,7 +40,7 @@ class EntriesTest extends \PHPUnit_Framework_TestCase
$hydrator = new \Lavoisier\Hydrators\EntriesHydrator("\TicketingSystem\Ticket\GgusFields");
$coll = $hydrator->hydrate($input);
print_r($coll);
// print_r($coll);
}
......
<e:entries xmlns:e="https://gitlab.in2p3.fr/opsportal/lavoisierquery/raw/master/ex_entries.xsd">
<e:entries xmlns:e="https://gitlab.in2p3.fr/opsportal/lavoisiercli/raw/master/resources/ex_entries.xsd">
<e:entry key="HOSTNAME">cream1.farm.particle.cz</e:entry>
<e:entry key="GOCDB_PORTAL_URL">https://goc.egi.eu/portal/index.php?Page_Type=Service&amp;id=751</e:entry>
<e:entry key="SERVICE_TYPE">APEL</e:entry>
......
<e:entries xmlns:e="https://gitlab.in2p3.fr/opsportal/lavoisierquery/raw/master/ex_entries.xsd">
<e:entries xmlns:e="https://gitlab.in2p3.fr/opsportal/lavoisiercli/raw/master/resources/ex_entries.xsd">
<e:entries key="info">
<e:entry key="PRIMARY_KEY">306G0</e:entry>
<e:entry key="CERTDN">/O=GRID-FR/C=FR/O=CNRS/OU=CC-IN2P3/CN=Foo Bar</e:entry>
......
<e:entries xmlns:e="https://gitlab.in2p3.fr/opsportal/lavoisierquery/raw/master/ex_entries.xsd">
<e:entries xmlns:e="http://software.in2p3.fr/lavoisier/entries.xsd">
<e:entries>
<e:entry key="HOSTNAME">cream1.farm.particle.cz</e:entry>
<e:entry key="GOCDB_PORTAL_URL">https://goc.egi.eu/portal/index.php?Page_Type=Service&amp;id=751</e:entry>
......
<e:entries xmlns:e="https://gitlab.in2p3.fr/opsportal/lavoisierquery/raw/master/ex_entries.xsd">
<e:entries xmlns:e="https://gitlab.in2p3.fr/opsportal/lavoisiercli/raw/master/resources/ex_entries.xsd">
<e:entry>Australia-ATLAS</e:entry>
<e:entry>HK-HKU-CC-01</e:entry>
<e:entry>IN-DAE-VECC-02</e:entry>
......
<e:entries xmlns:e="https://gitlab.in2p3.fr/opsportal/lavoisierquery/raw/master/ex_entries.xsd">
<e:entries xmlns:e="https://gitlab.in2p3.fr/opsportal/lavoisiercli/raw/master/resources/ex_entries.xsd">
<e:entries>
<e:entry key="GHD_Request_ID">50455</e:entry>
<e:entry key="GHD_Modified_Date">2013-11-14T08:58:41Z</e:entry>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment