package com.boissinot.jenkins.csvexporter.service.extractor;

import com.boissinot.jenkins.csvexporter.domain.OutputCSVJobObj;
import com.boissinot.jenkins.csvexporter.service.extractor.command.BuildersElementRetriever;
import org.springframework.xml.transform.StringSource;
import org.springframework.xml.xpath.Jaxp13XPathTemplate;
import org.w3c.dom.Node;

import javax.xml.transform.Source;

/**
 * @author Gregory Boissinot
 */
public class MatrixJobExtractor extends JobExtractorSupport {

    public void buildCVSObj(OutputCSVJobObj.Builder builder, String configXML) {
        Jaxp13XPathTemplate template = new Jaxp13XPathTemplate();
        Source configXMLSource = new StringSource(configXML);

        //Get Maven Commands
        Node buildersNode = template.evaluateAsNode("//builders", configXMLSource);

        buildSCMSection(builder, configXML);

        builder.buildSteps(buildCommandSection(buildersNode));

        builder.buildSteps("\""
                + buildCommandSection(buildersNode)
                + "\"");
    }

    private String buildCommandSection(Node buildersNode) {
        BuildersElementRetriever buildersElementRetriever = new BuildersElementRetriever();
        return buildersElementRetriever.buildCommandSection(buildersNode);
    }

}

@@ -710,28 +710,45 @@
     
-//Get Maven Commands
+buildSCMSection(builder, configXML);%0A
 %0A   
@@ -832,119 +832,8 @@
 e);%0A
-%0A        buildSCMSection(builder, configXML);%0A%0A        builder.buildSteps(buildCommandSection(buildersNode));%0A%0A
     

Remove space