Package edu.isi.karma.er.helper

Examples of edu.isi.karma.er.helper.TripleStoreUtil


    return null;
  }

  private boolean saveMapping(String modelUrl, String graphContext) {
    try {
      TripleStoreUtil utilObj = new TripleStoreUtil();
      if (graphContext == null || graphContext.trim().compareTo("") == 0)
        return false;
      URL url = new URL(modelUrl);
      StringWriter test = new StringWriter();
      Model model = WorksheetR2RMLJenaModelParser.loadSourceModelIntoJenaModel(url);
      Property rdfTypeProp = model.getProperty(Uris.RDF_TYPE_URI);

      RDFNode node = model.getResource(Uris.KM_R2RML_MAPPING_URI);
      ResIterator res = model.listResourcesWithProperty(rdfTypeProp, node);
      List<Resource> resList = res.toList();
      for(Resource r: resList)
      {
        model.add(r, model.getProperty(Uris.OWL_SAMEAS_URI), model.getResource(url.toString()));
      }
      model.write(test,"TTL");
      model.close();
      String content = test.getBuffer().toString();
      test.close();
      if (utilObj.testURIExists(tripleStoreUrl, graphContext, modelUrl)) {
        utilObj.deleteMappingFromTripleStore(tripleStoreUrl, graphContext, modelUrl);
      }
      boolean result = utilObj.saveToStoreFromString(content, tripleStoreUrl, graphContext, new Boolean(false), null);
      return result;
    }catch (Exception e) {
      return false;
    }
  }
View Full Code Here


    return CommandType.notInHistory;
  }

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    TripleStoreUtil util = new TripleStoreUtil();
    try {
      util.deleteMappingFromTripleStore(tripleStoreURL, context, mappingURI);
    } catch (KarmaException e) {
      return new UpdateContainer(new ErrorUpdate("Error occured while deleting R2RML model!"));
    }
    UpdateContainer uc = new UpdateContainer();
    uc.add(new AbstractUpdate() {
View Full Code Here

    return CommandType.notInHistory;
  }

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    TripleStoreUtil utilObj = new TripleStoreUtil();
    boolean showModelsWithoutMatching = ModelingConfiguration.isShowModelsWithoutMatching();
    try {
      HashMap<String, List<String>> metadata = utilObj.getMappingsWithMetadata(TripleStoreUrl, context);
      RepFactory factory = workspace.getFactory();
      List<String> model_Names = metadata.get("model_names");
      List<String> model_Urls = metadata.get("model_urls");
      List<String> model_Times = metadata.get("model_publishtimes");
      List<String> model_Contexts = metadata.get("model_contexts");
View Full Code Here

    } catch (Exception e1) {
      logger.error("Error occured while generating RDF!", e1);
      return new UpdateContainer(new ErrorUpdate("Error occured while generating RDF: " + e1.getMessage()));
    }
   
    TripleStoreUtil utilObj = new TripleStoreUtil();
   
    boolean result = false;
    try{
      JSONObject pref = workspace.getCommandPreferences().getCommandPreferencesJSONObject("PublishRDFCommandPreferences");
      String rdfNamespace = "";
      if(pref != null) {
        rdfNamespace = pref.optString(PublishRDFCommandPreferencesKeys.rdfNamespace.name());
      }
      result = utilObj.saveToStoreFromFile(generatedRDFFileName, TripleStoreUtil.defaultDataRepoUrl, graphUri, true, rdfNamespace);
    }
    catch(Exception e)
    {
      result = false;
    }
View Full Code Here

    return CommandType.notInHistory;
  }

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    TripleStoreUtil utilObj = new TripleStoreUtil();

    // get the source name for this work sheet
    Worksheet worksheet = workspace.getWorksheet(this.worksheetId);
   
    // prepare the graph url if graphUri is not provided
    if(this.graphUriTobeValidated == null || this.graphUriTobeValidated.isEmpty()) {
      String title = worksheet.getTitle();
      title = title.replace(".", "_");
      this.graphUriTobeValidated = "http://localhost.com/worksheets/"+title;
    }
   
    // check for uniqueness with the existing contexts
    if(!utilObj.isUniqueGraphUri(this.tripleStoreUrl, this.graphUriTobeValidated)) {
      // modify the url if required
      if(this.graphUriTobeValidated.charAt(this.graphUriTobeValidated.length()-1) != '/') {
        this.graphUriTobeValidated += "/";
      }
      this.graphUriTobeValidated += String.valueOf(System.nanoTime());
View Full Code Here

    return CommandType.notInHistory;
  }

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    TripleStoreUtil utilObj = new TripleStoreUtil();
    final List<String> graphs = utilObj.getContexts(this.tripleStoreUrl);
    if(graphs == null) {
      return new UpdateContainer(new ErrorUpdate("Error occurred while fetching graphs!"));
    }
    logger.info("Graphs fetched : " + graphs.size());
   
View Full Code Here

          formParams.getFirst(FormParameters.PASSWORD));

      break;

    case FormParameters.TRIPLE_STORE_SESAME:
      TripleStoreUtil tsu = new TripleStoreUtil();

      // TODO Find purpose of Graph URI and replace it with formParams
      String baseURI = "http://isiimagefinder/";

      boolean success = tsu.saveToStoreFromString(strRDF, tripleStoreURL,
          formParams.getFirst(FormParameters.GRAPH_URI), overWrite,
          baseURI);
      responseCode = (success) ? 200 : 503; // HTTP OK or Error
      break;
    default:
View Full Code Here

TOP

Related Classes of edu.isi.karma.er.helper.TripleStoreUtil

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.