Package edu.isi.karma.kr2rml.mapping

Examples of edu.isi.karma.kr2rml.mapping.WorksheetR2RMLJenaModelParser


    worksheet.getSuperSelectionManager().defineSelection("test").addSelection(sel);
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    List<KR2RMLRDFWriter> writers = new ArrayList<KR2RMLRDFWriter>();
    writers.add(new N3KR2RMLRDFWriter(new URIFormatter(), pw));
    WorksheetR2RMLJenaModelParser modelParser = new WorksheetR2RMLJenaModelParser(modelIdentifier);
    applyHistoryToWorksheet(workspace, worksheet, modelParser.parse());
    KR2RMLWorksheetRDFGenerator rdfGen = new KR2RMLWorksheetRDFGenerator(worksheet,
            workspace.getFactory(), workspace.getOntologyManager(), writers,
            false, modelParser.parse(), new ErrorReport(), worksheet.getSuperSelectionManager().getSuperSelection("test"));
    rdfGen.generateRDF(true);
    String rdf = sw.toString();
    assertNotEquals(rdf.length(), 0);
    String[] lines = rdf.split(System.getProperty("line.separator"));
    assertEquals(37, lines.length);
View Full Code Here


        BloomFilterKR2RMLRDFWriter t = (BloomFilterKR2RMLRDFWriter)writer;
        t.setR2RMLMappingIdentifier(id);
      }
    }
    //Check if the parser for this model exists, else create one
    WorksheetR2RMLJenaModelParser modelParser = readModelParsers.get(modelName);
    if(modelParser == null) {
      modelParser = loadModel(id);
    }
    generateRDF(modelParser, sourceName, data, dataType, maxNumLines, addProvenance, writers, rootStrategy);
  }
View Full Code Here

    return worksheet;
  }


  private WorksheetR2RMLJenaModelParser loadModel(R2RMLMappingIdentifier modelIdentifier) throws JSONException, KarmaException {
    WorksheetR2RMLJenaModelParser parser = new WorksheetR2RMLJenaModelParser(modelIdentifier);
    this.readModelParsers.put(modelIdentifier.getName(), parser);
    return parser;
  }
View Full Code Here

        pw.println(utilObj.getMappingFromTripleStore(modelRepoUrl, modelContext, url));
        pw.close();
        Model model = WorksheetR2RMLJenaModelParser.loadSourceModelIntoJenaModel(tmp.toURI().toURL());
        tmp.delete();
        R2RMLMappingIdentifier identifier = new R2RMLMappingIdentifier(mapping.getId().getName(), new URL(url));
        WorksheetR2RMLJenaModelParser parser = new WorksheetR2RMLJenaModelParser(model, identifier);
        mapping = parser.parse();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    logger.debug(mapping.toString());
View Full Code Here

  private JSONArray extractHistoryFromModel(Workspace workspace, UpdateContainer uc)
      throws RepositoryException, RDFParseException, IOException, JSONException, KarmaException {

    Worksheet ws = workspace.getFactory().getWorksheet(worksheetId);
    R2RMLMappingIdentifier id = new R2RMLMappingIdentifier(ws.getTitle(), r2rmlModelFile.toURI().toURL());
    WorksheetR2RMLJenaModelParser parser = new WorksheetR2RMLJenaModelParser(id);
    KR2RMLMapping mapping = parser.parse();
    KR2RMLVersion version = mapping.getVersion();
    if(version.compareTo(KR2RMLVersion.current) < 0)
    {
      uc.add(new InfoUpdate("Model version is " + version.toString() + ".  Current version is " + KR2RMLVersion.current.toString() + ".  Please publish it again."));
    }
View Full Code Here

  private void generateRDF(String wkname, String query, List<KR2RMLRDFWriter> writers, R2RMLMappingIdentifier id, String baseURI)
      throws IOException, JSONException, KarmaException, SQLException, ClassNotFoundException{
    logger.debug("Generating RDF...");

    WorksheetR2RMLJenaModelParser parserTest = new WorksheetR2RMLJenaModelParser(id);
    KR2RMLMapping mapping = parserTest.parse();
    for (KR2RMLRDFWriter writer : writers) {
      if (writer instanceof BloomFilterKR2RMLRDFWriter) {
        BloomFilterKR2RMLRDFWriter t = (BloomFilterKR2RMLRDFWriter)writer;
        t.setR2RMLMappingIdentifier(id);
      }
    }
    AbstractJDBCUtil dbUtil = JDBCUtilFactory.getInstance(dbType);
    Connection conn = dbUtil.getConnection(hostname, portnumber, username, password, dBorSIDName);
    conn.setAutoCommit(false);
   
    java.sql.Statement stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,
        java.sql.ResultSet.CONCUR_READ_ONLY);
    stmt.setFetchSize(DATABASE_TABLE_FETCH_SIZE);
   
    ResultSet r = stmt.executeQuery(query);
    ResultSetMetaData meta = r.getMetaData();;
   
    // Get the column names
    List<String> columnNames = new ArrayList<>();
    for (int i = 1; i <= meta.getColumnCount(); i++) {
      columnNames.add(meta.getColumnName(i));
    }
   
    // Prepare required Karma objects
       Workspace workspace = initializeWorkspace();
  
    RepFactory factory = workspace.getFactory();
    Worksheet wk = factory.createWorksheet(wkname, workspace, encoding);
    List<String> headersList = addHeaders(wk, columnNames, factory);
   
    int counter = 0;
   
    ArrayList<String> rowValues = null;
    while ((rowValues = dbUtil.parseResultSetRow(r)) != null) {
      // Generate RDF and create a new worksheet for every DATABASE_TABLE_FETCH_SIZE rows
      if(counter%DATABASE_TABLE_FETCH_SIZE == 0 && counter != 0) {
        generateRDFFromWorksheet(wk, workspace, mapping, writers, baseURI);
        logger.debug("Done for " + counter + " rows ..." );
          removeWorkspace(workspace);
         
          parserTest = new WorksheetR2RMLJenaModelParser(id);
        mapping = parserTest.parse();
          workspace = initializeWorkspace();
          factory = workspace.getFactory();
        wk = factory.createWorksheet(wkname, workspace, encoding);
        headersList = addHeaders(wk, columnNames, factory);
       
View Full Code Here

TOP

Related Classes of edu.isi.karma.kr2rml.mapping.WorksheetR2RMLJenaModelParser

Copyright © 2018 www.massapicom. 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.