| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | /* RDFInt.php - RDF Interfaces for PHP
|
|---|
| 4 | * Copyright 2011 netlabs.org
|
|---|
| 5 | * Author: Christian Langanke, Adrian Gschwend
|
|---|
| 6 | *
|
|---|
| 7 | * Licensed under the Apache License, Version 2.0 (the "License");
|
|---|
| 8 | * you may not use this file except in compliance with the License.
|
|---|
| 9 | * You may obtain a copy of the License at
|
|---|
| 10 | *
|
|---|
| 11 | * http://www.apache.org/licenses/LICENSE-2.0
|
|---|
| 12 | *
|
|---|
| 13 | * Unless required by applicable law or agreed to in writing, software
|
|---|
| 14 | * distributed under the License is distributed on an "AS IS" BASIS,
|
|---|
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|---|
| 16 | * See the License for the specific language governing permissions and
|
|---|
| 17 | * limitations under the License.
|
|---|
| 18 | */
|
|---|
| 19 |
|
|---|
| 20 | namespace rdfa;
|
|---|
| 21 |
|
|---|
| 22 | /**
|
|---|
| 23 | * \class SparqlEndpoint
|
|---|
| 24 | * \brief This class implements the configuration class for SPARQL endpoints, used
|
|---|
| 25 | * for creation of rdfa::SparqlQuery objects.
|
|---|
| 26 | * <br>This is a library specific extension to the RDF API and RDFa API.
|
|---|
| 27 | * \author Christian Langanke
|
|---|
| 28 | * \author Adrian Gschwend
|
|---|
| 29 | * \date 2011
|
|---|
| 30 | */
|
|---|
| 31 |
|
|---|
| 32 | class SparqlEndpoint {
|
|---|
| 33 |
|
|---|
| 34 | /**
|
|---|
| 35 | * Version of the class
|
|---|
| 36 | */
|
|---|
| 37 | const version = '1.0.0';
|
|---|
| 38 | /**
|
|---|
| 39 | * Name of the fDebug context
|
|---|
| 40 | */
|
|---|
| 41 | const debugcontext = 'RDFA_SPARQLENDPOINT';
|
|---|
| 42 |
|
|---|
| 43 | private $debugger;
|
|---|
| 44 | private $aconfig;
|
|---|
| 45 |
|
|---|
| 46 | // ---------------------------------------
|
|---|
| 47 |
|
|---|
| 48 | /**
|
|---|
| 49 | * Creates an endpoint configuration class instance.
|
|---|
| 50 | *
|
|---|
| 51 | * \param aconfig associative list of configuration data
|
|---|
| 52 | */
|
|---|
| 53 | public function __construct( $aconfig) {
|
|---|
| 54 |
|
|---|
| 55 | // setup debugger
|
|---|
| 56 | $this->debugger = \fDebug::getInstance();
|
|---|
| 57 |
|
|---|
| 58 | // initialize instance vars
|
|---|
| 59 | $this->aconfig = array();
|
|---|
| 60 |
|
|---|
| 61 | // store inital configuration
|
|---|
| 62 | if (is_array( $aconfig)) {
|
|---|
| 63 | $this->aconfig = $aconfig;
|
|---|
| 64 | $debugmessage = "Creating endpoint configuration\n";
|
|---|
| 65 | foreach ($aconfig as $name => $value) {
|
|---|
| 66 | $debugmessage .= "$name=$value\n";
|
|---|
| 67 | }
|
|---|
| 68 | $this->debugger->sendMessage( $debugmessage, self::debugcontext);
|
|---|
| 69 | } else {
|
|---|
| 70 | $debugmessage = "Missing configuration parameters provided for endpoint configuration!";
|
|---|
| 71 | $this->debugger->sendWarning( $debugmessage, self::debugcontext);
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | } // public function __construct
|
|---|
| 75 |
|
|---|
| 76 | // ---------------------------------------
|
|---|
| 77 |
|
|---|
| 78 | /**
|
|---|
| 79 | * Sets a single configuration value
|
|---|
| 80 | *
|
|---|
| 81 | * \param name name of the configurarion value
|
|---|
| 82 | * \param value new value to be set
|
|---|
| 83 | */
|
|---|
| 84 | public function setConfigurationValue( $name, $value) {
|
|---|
| 85 | $this->debugger->sendMessage( "Send endpoint configuration value $name=$value", self::debugcontext);
|
|---|
| 86 | $this->aconfig[ $name] = $value;
|
|---|
| 87 | return;
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | // ---------------------------------------
|
|---|
| 91 |
|
|---|
| 92 | /**
|
|---|
| 93 | * Gets a single configuration value
|
|---|
| 94 | *
|
|---|
| 95 | * \param name name of the configurarion value
|
|---|
| 96 | */
|
|---|
| 97 | public function getConfigurationValue( $name) {
|
|---|
| 98 | if (!isset( $this->aconfig[ $name]))
|
|---|
| 99 | return false;
|
|---|
| 100 | else
|
|---|
| 101 | return $this->aconfig[ $name];
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | // ---------------------------------------
|
|---|
| 105 |
|
|---|
| 106 | /**
|
|---|
| 107 | * Queries an associative list of the configuration values
|
|---|
| 108 | */
|
|---|
| 109 | public function getConfigurationValues( ) {
|
|---|
| 110 | return $this->aconfig;
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | } // class SparqlEndpoint
|
|---|
| 114 |
|
|---|
| 115 | ?>
|
|---|