public function import()
 {
     $this->checkUserIsAdmin();
     $xml = $this->request->get('xml_content')->agiledashboard;
     $xml_validator = new XML_RNGValidator();
     $rng_path = realpath(AGILEDASHBOARD_BASE_DIR . '/../www/resources/xml_project_agiledashboard.rng');
     $xml_validator->validate($xml, $rng_path);
     $xml_importer = new AgileDashboard_XMLImporter();
     $data = $xml_importer->toArray($xml, $this->request->get('mapping'));
     $validator = new Planning_RequestValidator($this->planning_factory, $this->kanban_factory);
     foreach ($data['plannings'] as $planning) {
         $request_params = array('planning' => $planning, 'group_id' => $this->group_id, 'planning_id' => '');
         $request = new Codendi_Request($request_params);
         if ($validator->isValid($request)) {
             $this->planning_factory->createPlanning($this->group_id, PlanningParameters::fromArray($planning));
         } else {
             throw new Exception('Planning is not valid: ' . print_r($planning, true));
         }
     }
 }
Esempio n. 2
0
 public function itThrowsAnExceptionIfTrackerMappingsAreInvalid()
 {
     $tracker_mappings = array();
     $this->expectException('AgileDashboard_XMLImporterInvalidTrackerMappingsException');
     $this->importer->toArray($this->xml_object, $tracker_mappings);
 }