Ignore:
Timestamp:
07/29/11 14:51:06 (14 years ago)
Author:
basvannuland
Message:

updates to the database system. ao New file structure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/classes/ApplicationRDFReader.php

    r45 r62  
    33class ApplicationRDFReader
    44{
    5         protected $model;
    6                        
     5    protected $model;
     6
    77    public function __construct()
    88    {
    9         // Create empty MemModel
    10                 $factory = new ModelFactory();
    11                 $this->model = $factory->getDefaultModel();
    12                
    13                 $fileName = 'data/applications/applications.rdf';
    14                
    15                 if(file_exists($fileName))
    16                         $this->model->load($fileName);
     9    // Create empty MemModel
     10    $factory = new ModelFactory();
     11    $this->model = $factory->getDefaultModel();
     12
     13    $fileName = 'data/applications/applications.rdf';
     14
     15    if(file_exists($fileName))
     16        $this->model->load($fileName);
    1717    }
    18        
    19         public function readApplicationInfo($applicationID)
    20         {
    21                 $querystring = '
    22                         PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
    23                         PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
    24                         SELECT  ?title ?description ?style
    25                         WHERE   
    26                         {
    27                                 _application    predicates:resource_type        resources:application ;
    28                                                                 predicates:uid                          "' . $applicationID . '"        ;
    29                                                                 predicates:title                        ?title  ;
    30                                                                 prdeicates:description          ?description    ;
    31                                                                 predicates:style                        ?style
    32                         }';
    33                        
    34                 $result = $this->model->sparqlQuery($querystring);
    35                                
    36                 return $result;
    37         }
    38        
    39         public function readAllApplications()
    40         {
    41                 $result = array();
    42                 $result[] = $this->readApplicationIDs();
    43                 $result[] = $this->readApplicationTitles();                             
    44                 $result[] = $this->readApplicationDescriptions();
    45                 $result[] = $this->readApplicationStyles();
    46                
    47                 return $restult;
    48         }
    49        
    50         public function readApplicationIDs()
    51         {
    52                 $querystring = '
    53                         PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
    54                         PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
    55                         SELECT  ?uid
    56                         WHERE   
    57                         {
    58                                 _application    predicates:resource_type        resources:application ;
    59                                                                 predicates:uid                          ?uid
    60                         }';
    61                        
    62                 $result = $this->model->sparqlQuery($querystring);
    63                                
    64                 return $result;
    65         }
    66        
    67         public function readApplicationTitles()
    68         {
    69                 $querystring = '
    70                         PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
    71                         PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
    72                         SELECT  ?title
    73                         WHERE   
    74                         {
    75                                 _application    predicates:resource_type        resources:application ;
    76                                                                 predicates:title                        ?title
    77                         }';
    78                        
    79                 $result = $this->model->sparqlQuery($querystring);
    80                                
    81                 return $result;
    82         }
    83        
    84         public function readApplicationDescriptions()
    85         {
    86                 $querystring = '
    87                         PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
    88                         PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
    89                         SELECT  ?description
    90                         WHERE   
    91                         {
    92                                 _application    predicates:resource_type        resources:application ;
    93                                                                 prdeicates:description          ?description   
    94                         }';
    95                        
    96                 $result = $this->model->sparqlQuery($querystring);
    97                                
    98                 return $result;
    99         }
    100        
    101         public function readApplicationStyles()
    102         {
    103                 $querystring = '
    104                         PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
    105                         PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
    106                         SELECT  ?style
    107                         WHERE   
    108                         {
    109                                 _application    predicates:resource_type        resources:application ;
    110                                                                 predicates:style                        ?style
    111                         }';
    112                        
    113                 $result = $this->model->sparqlQuery($querystring);
    114                                
    115                 return $result;
    116         }
     18
     19    public function readApplicationInfo($applicationID)
     20    {
     21        $querystring = '
     22            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
     23            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
     24            SELECT  ?title ?description ?style
     25            WHERE       
     26            {
     27                    _application        predicates:resource_type        resources:application ;
     28                                        predicates:uid                  "' . $applicationID . '"        ;
     29                                        predicates:title                ?title  ;
     30                                        prdeicates:description          ?description    ;
     31                                        predicates:style                ?style
     32            }';
     33
     34        $result = $this->model->sparqlQuery($querystring);
     35
     36        return $result;
     37    }
     38
     39    public function readAllApplications()
     40    {
     41        $result = array();
     42        $result[] = $this->readApplicationIDs();
     43        $result[] = $this->readApplicationTitles();                             
     44        $result[] = $this->readApplicationDescriptions();
     45        $result[] = $this->readApplicationStyles();
     46
     47        return $restult;
     48    }
     49
     50    public function readApplicationIDs()
     51    {
     52        $querystring = '
     53            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
     54            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
     55            SELECT  ?uid
     56            WHERE       
     57            {
     58                    _application        predicates:resource_type        resources:application ;
     59                                        predicates:uid                  ?uid
     60            }';
     61
     62        $result = $this->model->sparqlQuery($querystring);
     63
     64        return $result;
     65    }
     66
     67    public function readApplicationTitles()
     68    {
     69        $querystring = '
     70            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
     71            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
     72            SELECT  ?title
     73            WHERE       
     74            {
     75                    _application        predicates:resource_type        resources:application ;
     76                                        predicates:title                ?title
     77            }';
     78
     79        $result = $this->model->sparqlQuery($querystring);
     80
     81        return $result;
     82    }
     83
     84    public function readApplicationDescriptions()
     85    {
     86        $querystring = '
     87            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
     88            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
     89            SELECT  ?description
     90            WHERE       
     91            {
     92                    _application        predicates:resource_type        resources:application ;
     93                                        prdeicates:description          ?description   
     94            }';
     95
     96        $result = $this->model->sparqlQuery($querystring);
     97
     98        return $result;
     99    }
     100
     101    public function readApplicationStyles()
     102    {
     103        $querystring = '
     104            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
     105            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
     106            SELECT  ?style
     107            WHERE       
     108            {
     109                    _application        predicates:resource_type        resources:application ;
     110                                        predicates:style                ?style
     111            }';
     112
     113        $result = $this->model->sparqlQuery($querystring);
     114
     115        return $result;
     116    }
    117117}
    118118
Note: See TracChangeset for help on using the changeset viewer.