package com.linkedpipes.etl.convert.uv.configuration;

import com.linkedpipes.etl.convert.uv.pipeline.LpPipeline;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author Petr Škoda
 */
@XStreamAlias("eu.unifiedviews.plugins.trandformer.sparqlselect.SparqlSelectConfig")
class SparqlSelectConfig implements Configuration {

    private static final Logger LOG
            = LoggerFactory.getLogger(SparqlSelectConfig.class);

    private String targetPath = "/out.csv";

    private String query = "SELECT ?s ?p ?o WHERE { ?s ?p ?o }";

    @Override
    public void update(LpPipeline pipeline, LpPipeline.Component component) {

        // @DataUnit.AsInput(name = "input")
        // @DataUnit.AsOutput(name = "output")

        // @Component.InputPort(id = "InputRdf")
        // @Component.OutputPort(id = "OutputFiles")

        // http://plugins.linkedpipes.com/ontology/t-sparqlSelect#
        // query
        // fileName

        LOG.error("{} : Removed.", component);
        pipeline.removeComponent(component);
    }

}

@@ -176,56 +176,246 @@
 ort 
-org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory
+java.util.ArrayList;%0Aimport java.util.List;%0Aimport org.openrdf.model.IRI;%0Aimport org.openrdf.model.Statement;%0Aimport org.openrdf.model.ValueFactory;%0Aimport org.openrdf.model.impl.SimpleValueFactory;%0Aimport org.openrdf.model.vocabulary.RDF
 ;%0A%0A/
@@ -588,110 +588,8 @@
  %7B%0A%0A
-    private static final Logger LOG%0A            = LoggerFactory.getLogger(SparqlSelectConfig.class);%0A%0A
     
@@ -800,91 +800,130 @@
     
-// @DataUnit.AsInput(name = %22input%22)%0A        // @DataUnit.AsOutput(name = %22output%22)
+pipeline.renameInPort(component, %22input%22, %22InputRdf%22);%0A        pipeline.renameOutPort(component, %22output%22, %22OutputFiles%22);
 %0A%0A  
@@ -920,37 +920,33 @@
 les%22);%0A%0A        
-// @C
+c
 omponent.InputPo
@@ -942,87 +942,309 @@
 ent.
-InputPort(id = %22InputRdf%22)%0A        // @Component.OutputPort(id = %22OutputFiles
+setTemplate(LpPipeline.BASE_IRI + %22resources/components/t-sparqlSelect%22);%0A%0A        final ValueFactory vf = SimpleValueFactory.getInstance();%0A        final List%3CStatement%3E st = new ArrayList%3C%3E();%0A        final IRI configuration = vf.createIRI(%22http://localhost/resources/configuration/t-sparqlSelect
 %22)
+;
 %0A%0A  
@@ -1253,83 +1253,322 @@
     
-// http://plugins.linkedpipes.com/ontology/t-sparqlSelect#%0A        // 
+st.add(vf.createStatement(configuration,%0A                RDF.TYPE,%0A                vf.createIRI(%22http://plugins.linkedpipes.com/ontology/t-sparqlSelect#Configuration%22)));%0A%0A        st.add(vf.createStatement(configuration,%0A                vf.createIRI(%22http://plugins.linkedpipes.com/ontology/t-sparqlSelect#
 query
+%22),
 %0A   
@@ -1576,109 +1576,287 @@
     
-// fileName%0A%0A        LOG.error(%22%7B%7D : Removed.%22, component);%0A        pipeline.removeComponent(componen
+        vf.createLiteral(this.query)));%0A%0A        st.add(vf.createStatement(configuration,%0A                vf.createIRI(%22http://plugins.linkedpipes.com/ontology/t-sparqlSelect#fileName%22),%0A                vf.createLiteral(this.targetPath)));%0A%0A        component.setLpConfiguration(s
 t);%0A

Add support for SparqlSelect