Package org.data2semantics.cat.modules

Source Code of org.data2semantics.cat.modules.LoadRDF

package org.data2semantics.cat.modules;

import java.io.File;
import java.util.List;

import org.data2semantics.platform.annotation.In;
import org.data2semantics.platform.annotation.Main;
import org.data2semantics.platform.annotation.Module;
import org.lilian.graphs.DTGraph;
import org.lilian.graphs.data.RDF;
import org.lilian.graphs.data.RDFDataSet;
import org.lilian.graphs.data.RDFFileDataSet;
import org.openrdf.model.Statement;
import org.openrdf.rio.RDFFormat;

@Module(name="Load RDF")
public class LoadRDF
{

  @In(name="file")
  public String file;
 
  @Main(name="data", print=false)
  public DTGraph<String, String> load()
  {
   
    RDFFormat format = RDFFormat.forFileName(file);
   
    if(format == null)
      throw new RuntimeException("RDF file "+file+" not recognized");
     
    RDFDataSet testSet = new RDFFileDataSet(file, format);

    List<Statement> triples = testSet.getFullGraph()
   
    return RDF.createDirectedGraph(triples, null, null);
   
  }
 
}
TOP

Related Classes of org.data2semantics.cat.modules.LoadRDF

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.