private function appendValueToFieldChangeNode(Tracker_ArtifactLinkInfo $artifact_link_info, $index, $userdata)
 {
     $field_xml = $userdata['field_xml'];
     $artifact = $userdata['artifact'];
     $children_trackers = $userdata['children_trackers'];
     if ($this->canExportLinkedArtifact($artifact_link_info, $children_trackers)) {
         $field_xml->addChild('value', $artifact_link_info->getArtifactId());
         $this->children_collector->addChild($artifact_link_info->getArtifactId(), $artifact->getId());
     }
 }
Esempio n. 2
0
 public function exportChildren(SimpleXMLElement $xml)
 {
     while ($artifact_id = $this->children_collector->pop()) {
         $artifact = $this->artifact_factory->getArtifactById($artifact_id);
         if (!$artifact) {
             continue;
         }
         $last_changeset = $artifact->getLastChangeset();
         $this->artifact_xml_updater->exportSnapshotWithoutComments($xml, $last_changeset);
         $index_last_artifact = count($xml->artifact) - 1;
         $this->file_xml_updater->update($xml->artifact[$index_last_artifact]);
     }
 }
Esempio n. 3
0
 private function createLinksBetweenArtifacts(PFUser $user, Tracker_XML_Importer_ArtifactImportedMapping $artifacts_imported_mapping, Tracker_Artifact $root_artifact)
 {
     $comment_message = '';
     $send_notifications = false;
     $original_id = $artifacts_imported_mapping->getOriginal($root_artifact->getId());
     $children = $this->children_collector->getChildrenForParent($original_id);
     if (!$children) {
         return;
     }
     foreach ($children as $key => $original_child_id) {
         $children[$key] = $artifacts_imported_mapping->get($original_child_id);
     }
     $field_id = $root_artifact->getAnArtifactLinkField($user)->getId();
     $fields_data = array($field_id => array(Tracker_FormElement_Field_ArtifactLink::NEW_VALUES_KEY => implode(',', $children)));
     $root_artifact->createNewChangeset($fields_data, $comment_message, $user, $send_notifications, Tracker_Artifact_Changeset_Comment::TEXT_COMMENT);
     foreach ($children as $child_id) {
         $artifact = $this->artifact_factory->getArtifactById($child_id);
         $this->createLinksBetweenArtifacts($user, $artifacts_imported_mapping, $artifact);
     }
 }
 public function itStoresTheChildrenOfTheFirstArtifact()
 {
     $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?>
         <artifacts>
             <artifact id="100" tracker_id="22">
                 <changeset>
                     <field_change field_name="content" type="art_link">
                         <value>123</value>
                     </field_change>
                 </changeset>
             </artifact>
             <artifact id="123" tracker_id="23">
                 <changeset>
                     <field_change field_name="content" type="art_link">
                         <value>124</value>
                     </field_change>
                 </changeset>
             </artifact>
             <artifact id="124" tracker_id="24">
                 <changeset>
                     <field_change field_name="content" type="art_link">
                         <value/>
                     </field_change>
                 </changeset>
             </artifact>
         </artifacts>');
     stub($this->xml_importer)->importOneArtifactFromXML('*', $xml->artifact[1], '*')->returns($this->created_artifact);
     stub($this->xml_importer)->importOneArtifactFromXML('*', $xml->artifact[2], '*')->returns($this->another_child_artifact);
     stub($this->artifacts_imported_mapping)->get(100)->returns($this->root_artifact->getId());
     stub($this->artifacts_imported_mapping)->get(123)->returns($this->created_artifact->getId());
     stub($this->artifacts_imported_mapping)->get(124)->returns($this->another_child_artifact->getId());
     stub($this->artifacts_imported_mapping)->getOriginal($this->root_artifact->getId())->returns(100);
     stub($this->artifacts_imported_mapping)->getOriginal($this->created_artifact->getId())->returns(123);
     stub($this->artifacts_imported_mapping)->getOriginal($this->another_child_artifact->getId())->returns(124);
     $this->importer->importChildren($this->artifacts_imported_mapping, $xml, 'whatever', $this->root_artifact, $this->user);
     $expected_parents = array(100, 123);
     $this->assertEqual($expected_parents, $this->children_collector->getAllParents());
 }
 public function itCollectsChildren()
 {
     stub($this->changeset_value)->getValue()->returns(array($this->anArtifactLinkInfoUserCanView(111, 101), $this->anArtifactLinkInfoUserCanView(222, 102)));
     $this->exporter->export($this->artifact_xml, $this->changeset_xml, mock('Tracker_Artifact'), $this->changeset_value);
     $this->assertEqual($this->collector->getAllChildrenIds(), array(111, 222));
 }