Ignore:
Timestamp:
11/03/11 10:30:40 (13 years ago)
Author:
fpvanagthoven
Message:

Fixed mkdir call in ApplicationConnector?.php, now actually makes a directory instead of errors.
Cleaning up of pipeline Sequencer, smaller icons, etc. Trying to get non-db version of editor working properly, then integrate db calls.

File:
1 edited

Legend:

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

    r131 r144  
    1111 * @author jkraaijeveld
    1212 */
    13 class ApplicationConnector implements IConnector{
    14    
     13class ApplicationConnector implements IConnector {
     14
    1515    protected $model;
    1616    protected $fileName = 'data/applications/applications.rdf';
     
    1919     * Constructor for ApplicationConnector.
    2020     */
    21     public function __construct()
    22     {
     21    public function __construct() {
    2322        //Ensure the required folder for this connector exists
    24         if (!is_dir('data/applications/'))
    25             mkdir('data/applications/');       
     23        if (!is_dir('data/applications/')) {
     24            mkdir('data/applications/', null, true);
     25        }
    2626    }
    27    
     27
    2828    /**
    2929     * function load()
     
    3333        //Get the Memory Model from the ModelFactory
    3434        $this->model = ModelFactory::getDefaultModel();
    35        
     35
    3636        //Ensure the required file exists before loading
    37         if(file_exists($this->fileName))
     37        if (file_exists($this->fileName))
    3838            $this->model->load($this->fileName);
    3939    }
    40    
     40
    4141    /**
    4242     * function save()
     
    4444     */
    4545    public function save() {
    46         $this->model->saveAs($this->fileName,'rdf');
     46        $this->model->saveAs($this->fileName, 'rdf');
    4747    }
    48    
     48
    4949    /**
    5050     * function get($arguments)
     
    5858        $keys = array_keys($arguments);
    5959        //Set default values for arguments
    60         $uid = "?uid"; $title = "?title"; $description = "?description"; $style = "?style";
     60        $uid = "?uid";
     61        $title = "?title";
     62        $description = "?description";
     63        $style = "?style";
    6164        //Set the arguments if they are supplied
    62         if(in_array("uid", $keys))
    63             $uid = "\"".$arguments["uid"]."\"";
    64         if(in_array("title", $keys))
    65             $title = '\''.$arguments["title"].'\'';
    66         if(in_array("description", $keys))
    67             $description = "\"".$arguments["description"]."\"";
    68         if(in_array("style", $keys))
    69             $style = "\"".$arguments["style"]."\"";   
     65        if (in_array("uid", $keys))
     66            $uid = "\"" . $arguments["uid"] . "\"";
     67        if (in_array("title", $keys))
     68            $title = '\'' . $arguments["title"] . '\'';
     69        if (in_array("description", $keys))
     70            $description = "\"" . $arguments["description"] . "\"";
     71        if (in_array("style", $keys))
     72            $style = "\"" . $arguments["style"] . "\"";
    7073
    7174        //Create the querystring
     
    9093        $results = $this->model->sparqlQuery($querystring);
    9194        $applications = array();
    92         if(!empty($results))
    93         {
     95        if (!empty($results)) {
    9496            //Run over all results and create appropriate Application objets
    95             foreach($results as $result)
    96             {
    97                     $applications[] = new Application($result['?uid']->label, $result['?title']->label, $result['?description']->label, $result['?style']->label);
     97            foreach ($results as $result) {
     98                $applications[] = new Application($result['?uid']->label, $result['?title']->label, $result['?description']->label, $result['?style']->label);
    9899            }
    99100        }
    100101        return $applications;
    101102    }
    102    
     103
    103104    /**
    104105     * function set()
     
    107108     * @param type $rToolObject: The ResearchToolObject to be saved.
    108109     */
    109     public function set($rToolObject)
    110     {
     110    public function set($rToolObject) {
    111111        $this->load();
    112         $resourceApplication = new Resource(APPLICATION.'/'.$rToolObject->uid);
     112        $resourceApplication = new Resource(APPLICATION . '/' . $rToolObject->uid);
    113113        //Remove the old value stored with the given id
    114114        $this->model->subtract($this->model->find($resourceApplication, null, null));
     
    117117        $resourceApplicationType = new Resource(APPLICATION);
    118118        $predicateRType = new Resource(RTYPE);
    119         $this->model->add(new Statement($resourceApplication,$predicateRType,$resourceApplicationType));
    120                
     119        $this->model->add(new Statement($resourceApplication, $predicateRType, $resourceApplicationType));
     120
    121121        $literalApplicationID = new Literal($rToolObject->uid);
    122122        $predicateUniqueID = new Resource(UID);
    123         $this->model->add(new Statement($resourceApplication,$predicateUniqueID,$literalApplicationID));
     123        $this->model->add(new Statement($resourceApplication, $predicateUniqueID, $literalApplicationID));
    124124
    125125        $applicationTitle = new Literal($rToolObject->title);
    126         $predicateTitle = new Resource(TITLE); 
    127         $this->model->add(new Statement($resourceApplication,$predicateTitle,$applicationTitle));
     126        $predicateTitle = new Resource(TITLE);
     127        $this->model->add(new Statement($resourceApplication, $predicateTitle, $applicationTitle));
    128128
    129129        $applicationDescription = new Literal($rToolObject->description);
    130130        $predicateDescription = new Resource(DESCRIPTION);
    131         $this->model->add(new Statement($resourceApplication,$predicateDescription,$applicationDescription));
     131        $this->model->add(new Statement($resourceApplication, $predicateDescription, $applicationDescription));
    132132
    133133        $applicationStyle = new Literal($rToolObject->style);
    134134        $predicateStyle = new Resource(STYLE);
    135         $this->model->add(new Statement($resourceApplication,$predicateStyle,$applicationStyle));
    136                
    137         $this->save();
     135        $this->model->add(new Statement($resourceApplication, $predicateStyle, $applicationStyle));
     136
     137        $this->save();
    138138    }
     139
    139140}
    140141
Note: See TracChangeset for help on using the changeset viewer.