Import.php 4.86 KB
Newer Older
1 2 3 4 5 6 7
<?php

namespace Biopen\GeoDirectoryBundle\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
8
use Biopen\CoreBundle\Document\AbstractFile;
9 10 11 12

/** 
* @MongoDB\Document 
* @Vich\Uploadable
13 14
* Import data into GoGoCarto. the data can imported through a static file, or via API url
* The Import can be made once for all (static import) or dynamically every X days (ImportDynamic)
15
*/
16
class Import extends AbstractFile
17
{
Sebastian Castro's avatar
Sebastian Castro committed
18 19
    protected $vichUploadFileKey = "import_file";

20 21 22 23 24 25 26
    /**
     * @var int
     * @MongoDB\Id(strategy="INCREMENT") 
     */
    private $id;

    /**
27 28
     * @var string   
     * @MongoDB\Field(type="string")
29
     */
30
    public $sourceName;
31 32

    /**
33 34 35 36 37 38 39
     * @var string   
     * Url of API to get the data
     * @MongoDB\Field(type="string")
     */
    private $url;

    /**
40
     * @MongoDB\ReferenceOne(targetDocument="Biopen\GeoDirectoryBundle\Document\Category", cascade={"persist"})
41
     */
42
    private $parentCategoryToCreateOptions = null;
43 44

    /**
45
     * @MongoDB\ReferenceMany(targetDocument="Biopen\GeoDirectoryBundle\Document\Option", cascade={"persist"})
46
     */
47
    private $optionsToAddToEachElement = [];
48 49 50 51

    /**
     * @MongoDB\Field(type="bool")
     */
52
    private $createMissingOptions = false;
53 54 55 56

    /**
     * @MongoDB\Field(type="bool")
     */
57
    private $geocodeIfNecessary = false;    
58
    
Sebastian Castro's avatar
Sebastian Castro committed
59
    public function __construct() {}
60

61 62
    public function isDynamicImport() { return false; }

63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
    /**
     * Get id
     *
     * @return int_id $id
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set parentCategoryToCreateOptions
     *
     * @param Biopen\GeoDirectoryBundle\Document\Category $parentCategoryToCreateOptions
     * @return $this
     */
    public function setParentCategoryToCreateOptions(\Biopen\GeoDirectoryBundle\Document\Category $parentCategoryToCreateOptions)
    {
        $this->parentCategoryToCreateOptions = $parentCategoryToCreateOptions;
        return $this;
    }

    /**
     * Get parentCategoryToCreateOptions
     *
     * @return Biopen\GeoDirectoryBundle\Document\Category $parentCategoryToCreateOptions
     */
    public function getParentCategoryToCreateOptions()
    {
        return $this->parentCategoryToCreateOptions;
    }

    /**
96
     * Set url
97
     *
98
     * @param string $url
99 100
     * @return $this
     */
101
    public function setUrl($url)
102
    {
103
        $this->url = $url;
104 105 106 107
        return $this;
    }

    /**
108
     * Get url
109
     *
110
     * @return string $url
111
     */
112
    public function getUrl()
113
    {
114 115
        return $this->url;
    }    
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159

    /**
     * Set createMissingOptions
     *
     * @param bool $createMissingOptions
     * @return $this
     */
    public function setCreateMissingOptions($createMissingOptions)
    {
        $this->createMissingOptions = $createMissingOptions;
        return $this;
    }

    /**
     * Get createMissingOptions
     *
     * @return bool $createMissingOptions
     */
    public function getCreateMissingOptions()
    {
        return $this->createMissingOptions;
    }

    /**
     * Set geocodeIfNecessary
     *
     * @param bool $geocodeIfNecessary
     * @return $this
     */
    public function setGeocodeIfNecessary($geocodeIfNecessary)
    {
        $this->geocodeIfNecessary = $geocodeIfNecessary;
        return $this;
    }

    /**
     * Get geocodeIfNecessary
     *
     * @return bool $geocodeIfNecessary
     */
    public function getGeocodeIfNecessary()
    {
        return $this->geocodeIfNecessary;
    }
160 161

    /**
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
     * Add optionsToAddToEachElement
     *
     * @param Biopen\GeoDirectoryBundle\Document\Option $optionsToAddToEachElement
     */
    public function addOptionsToAddToEachElement(\Biopen\GeoDirectoryBundle\Document\Option $optionsToAddToEachElement)
    {
        $this->optionsToAddToEachElement[] = $optionsToAddToEachElement;
    }

    /**
     * Remove optionsToAddToEachElement
     *
     * @param Biopen\GeoDirectoryBundle\Document\Option $optionsToAddToEachElement
     */
    public function removeOptionsToAddToEachElement(\Biopen\GeoDirectoryBundle\Document\Option $optionsToAddToEachElement)
    {
        $this->optionsToAddToEachElement->removeElement($optionsToAddToEachElement);
    }

    /**
     * Get optionsToAddToEachElement
     *
     * @return \Doctrine\Common\Collections\Collection $optionsToAddToEachElement
     */
    public function getOptionsToAddToEachElement()
    {
        return $this->optionsToAddToEachElement;
    }

    /**
     * Set sourceName
193
     *
194
     * @param string $sourceName
195 196
     * @return $this
     */
197
    public function setSourceName($sourceName)
198
    {
199
        $this->sourceName = $sourceName;
200 201 202 203
        return $this;
    }

    /**
204
     * Get sourceName
205
     *
206
     * @return string $sourceName
207
     */
208
    public function getSourceName()
209
    {
210
        return $this->sourceName;
211
    }
212
}