public function insertValues(ExcelInputFile $excelInputFile, $subgroup, $origin, $destiny, $type, $variety, $font, $typeCountry = null, $internationalTrade = false)
 {
     $countries = $excelInputFile->getValuesOfColumn(1);
     $dataToSave = new ArrayObject();
     foreach ($countries as $country) {
         if ($typeCountry == 'origin') {
             $origin = CacheCountry::getCountries()->getOrigins()->get(utf8_encode($country))->id();
             if (is_null($origin)) {
                 $origin = $this->countryMap->getOuthersForOrigin();
             }
             if (!$internationalTrade) {
                 $destiny = 0;
             }
         } elseif ($typeCountry == 'destiny') {
             $destiny = CacheCountry::getCountries()->getDestinies()->get(utf8_encode($country))->id();
             if (is_null($destiny)) {
                 $destiny = $this->countryMap->getOthersForDestiny();
             }
             if (!$internationalTrade) {
                 $origin = 0;
             }
         } else {
             $origin = CacheCountry::getCountries()->getOrigins()->get(utf8_encode($country))->id();
         }
         $dataParam = new DataParam($subgroup, $font, $type, $variety, $origin, $destiny);
         $dataOfCurrentCountry = $this->getValuesWithSimpleFilter($dataParam);
         $yearsToInsert = $this->insertValuesIfACountryDoesNotHaveItStoredYet($dataOfCurrentCountry, $excelInputFile, $country);
         if ($yearsToInsert->count() > 0) {
             $this->getDataToSave($dataToSave, $yearsToInsert, $excelInputFile, $country, $subgroup, $font, $type, $variety, $origin, $destiny);
         }
     }
     return $this->repository->save($dataToSave);
 }
 /**
  * @return \CountryMap 
  */
 private static function populateCountryMap()
 {
     $dao = new GenericDao(Connection::connect());
     $controller = new Controller($dao);
     $countryMap = new CountryMap();
     $countryMap->addOrigins($controller->listOrigins());
     $countryMap->addDestinies($controller->listDestinies());
     return $countryMap;
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public static function GetKeyMaps()
 {
     if (self::$KM == null) {
         self::$KM = array();
         self::$KM["fk_placelocation_country"] = new KeyMap("fk_placelocation_country", "Idcountry", "PlaceLocation", "Country", KM_TYPE_ONETOMANY, KM_LOAD_LAZY);
         // use KM_LOAD_EAGER with caution here (one-to-one relationships only)
         self::$KM["fk_state_country1"] = new KeyMap("fk_state_country1", "Idcountry", "State", "Country", KM_TYPE_ONETOMANY, KM_LOAD_LAZY);
         // use KM_LOAD_EAGER with caution here (one-to-one relationships only)
     }
     return self::$KM;
 }