Package edu.isi.karma.controller.update

Examples of edu.isi.karma.controller.update.AbstractUpdate


    Iterator<String> concatenatedPredicateObjectMapsListItr = concatenatedPredicateObjectMapsList.iterator();
    Iterator<String> predicatesItr = predicates.iterator();
    Iterator<String> otherClassesItr = otherClasses.iterator();
    String hNodeId = FetchHNodeIdFromAlignmentCommand.gethNodeId(AlignmentManager.Instance().constructAlignmentId(workspace.getId(), worksheetId), columnUri);
    if (hNodeId == null) {
      return new UpdateContainer(new AbstractUpdate() {

        @Override
        public void generateJson(String prefix, PrintWriter pw, VWorkspace vWorkspace) {
          pw.print(array.toString());
        }
      });
    }
    HNode hnode = factory.getHNode(hNodeId);
    List<Table> dataTables = new ArrayList<Table>();
    CloneTableUtils.getDatatable(worksheet.getDataTable(), factory.getHTable(hnode.getHTableId()), dataTables, selection);
    KR2RMLBloomFilter uris = new KR2RMLBloomFilter(KR2RMLBloomFilter.defaultVectorSize, KR2RMLBloomFilter.defaultnbHash, Hash.JENKINS_HASH);
    Set<String> uriSet = new HashSet<String>();
    for(Table t : dataTables) {
      for(Row r : t.getRows(0, t.getNumRows(), selection)) {
        Node n = r.getNode(hNodeId);
        if(n != null && n.getValue() != null && !n.getValue().isEmptyValue() && n.getValue().asString() != null && !n.getValue().asString().trim().isEmpty() ) {
          String value = n.getValue().asString().trim().replace(" ", "");
          String baseURI = worksheet.getMetadataContainer().getWorksheetProperties().getPropertyValue(Property.baseURI);
          try {
            URI uri = new URI(value);
            if (!uri.isAbsolute() && baseURI != null) {
              value = baseURI + value;
            }
          } catch (URISyntaxException e) {
          }
          builder = new StringBuilder();
          value = builder.append("<").append(value).append(">").toString(); //String builder
          uriSet.add(value);
          uris.add(new Key(value.getBytes(UTF8_CHARSET)));
        }
      }
    }
    Set<String> maps = new HashSet<String>();
    Map<String, String> bloomfilterMapping = new HashMap<String, String>();
    try{
      for (String concatenatedPredicateObjectMaps : concatenatedPredicateObjectMapsList) {
        List<String> predicateObjectMaps = new ArrayList<String>(Arrays.asList(concatenatedPredicateObjectMaps.split(",")));
        maps.addAll(predicateObjectMaps);
        if (maps.size() > limit) {
          bloomfilterMapping.putAll(util.getBloomFiltersForMaps(tripleStoreUrl, null, maps));
          maps = new HashSet<String>();
        }
      }
      if (maps.size() > 0)
        bloomfilterMapping.putAll(util.getBloomFiltersForMaps(tripleStoreUrl, null, maps));
    } catch (KarmaException e1) {
      e1.printStackTrace();
    }
    while(concatenatedPredicateObjectMapsListItr.hasNext() && predicatesItr.hasNext() && otherClassesItr.hasNext())
    {

      String concatenatedPredicateObjectMaps = concatenatedPredicateObjectMapsListItr.next();
      List<String> predicateObjectMaps = new ArrayList<String>(Arrays.asList(concatenatedPredicateObjectMaps.split(",")));
      String predicate =  predicatesItr.next();
      String otherClass = otherClassesItr.next();
      try {
        KR2RMLBloomFilter intersectionBF = new KR2RMLBloomFilter(KR2RMLBloomFilter.defaultVectorSize, KR2RMLBloomFilter.defaultnbHash, Hash.JENKINS_HASH);
        for (String triplemap : predicateObjectMaps) {
          String serializedBloomFilter = bloomfilterMapping.get(triplemap);
          if (serializedBloomFilter != null) {
            KR2RMLBloomFilter bf = new KR2RMLBloomFilter();
            bf.populateFromCompressedAndBase64EncodedString(serializedBloomFilter);
            intersectionBF.or(bf);
          }
        }
        System.out.println(predicate + " " + intersectionBF.estimateNumberOfHashedValues());
        intersectionBF.and(uris);
        int estimate = intersectionBF.estimateNumberOfHashedValues();
        JSONObject obj = new JSONObject();
        obj.put("predicate", predicate);
        obj.put("otherClass", otherClass);
        obj.put("estimate", estimate);
        obj.put("incoming", "false");
        //          array.put(obj);
        objects.add(obj);

      } catch (Exception e) {
        LOG.error("Unable to process bloom filter: " + e.getMessage());
      }
    }

    Collections.sort(objects, new Comparator<JSONObject>() {

      @Override
      public int compare(JSONObject a, JSONObject b) {
        return b.getInt("estimate") - a.getInt("estimate");
      }
    });
    for (JSONObject obj : objects) {
      array.put(obj);
    }
    return new UpdateContainer(new AbstractUpdate() {

      @Override
      public void generateJson(String prefix, PrintWriter pw, VWorkspace vWorkspace) {
        System.out.println(array.toString());
        pw.print(array.toString());
View Full Code Here


    try {
      final boolean success = ontManager.doImportAndUpdateCache(
          getFile(), encoding);
      logger.debug("Done loading ontology: "
          + getFile().getAbsolutePath());
      return new UpdateContainer(new AbstractUpdate() {
        @Override
        public void generateJson(String prefix, PrintWriter pw,
            VWorkspace vWorkspace) {
          pw.println("{");
          pw.println("  \"" + GenericJsonKeys.updateType.name()
View Full Code Here

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    String hNodeId = gethNodeId(alignmentId, columnUri);
    final String copy = hNodeId;
    return new UpdateContainer(new AbstractUpdate() {
     
      @Override
      public void generateJson(String prefix, PrintWriter pw, VWorkspace vWorkspace) {
        JSONObject obj = new JSONObject();
        obj.put("HNodeId", copy);
View Full Code Here

        obj.put("appliedCommands", commands);
        array.put(obj);
      }
    }
    try {
      return new UpdateContainer(new AbstractUpdate() {

        @Override
        public void generateJson(String prefix, PrintWriter pw, VWorkspace vWorkspace) {
          pw.print(array.toString());
        }
View Full Code Here

  @Override
  public UpdateContainer doIt(final Workspace workspace) throws CommandException {
    logger.info("Get Semantic Suggestions: " + worksheetId + "," + hNodeId);
    UpdateContainer uc = new UpdateContainer();
    final SuperSelection selection = getSuperSelection(workspace);
    uc.add(new AbstractUpdate() {

      @Override
      public void generateJson(String prefix, PrintWriter pw,
          VWorkspace vWorkspace) {
        HNodePath currentColumnPath = null;
View Full Code Here

      }
      final JSONObject sprqlOutput = new JSONObject(sData);
//      final JSONObject sprqlOutput = TripleStoreUtil.invokeSparqlQuery(sparqlQuery,
//          TripleStoreUtil.defaultModelsRepoUrl);
     
      return new UpdateContainer(new AbstractUpdate() {
       
        @Override
        public void generateJson(String prefix, PrintWriter pw,
            VWorkspace vWorkspace) {
          JSONObject response = new JSONObject();
View Full Code Here

      }
    });
    for (JSONObject obj : objects) {
      array.put(obj);
    }
    return new UpdateContainer(new AbstractUpdate() {

      @Override
      public void generateJson(String prefix, PrintWriter pw, VWorkspace vWorkspace) {
        System.out.println(array.toString());
        pw.print(array.toString());
View Full Code Here

      }
      // logger.trace(out.toString());
      // logger.info("Connnection success : " + url + " Successful.");
      final JSONObject data1 = new JSONObject(out.toString());
      // logger.trace("Data--->" + data1);
      return new UpdateContainer(new AbstractUpdate() {

        @Override
        public void generateJson(String prefix, PrintWriter pw,
            VWorkspace vWorkspace) {
          JSONObject response = new JSONObject();
View Full Code Here

          }
        }
      }
    }
   
    c.add(new AbstractUpdate(){
       
 
        @Override
        public void generateJson(String prefix, PrintWriter pw,
            VWorkspace vWorkspace) {
View Full Code Here

        workspace.getWorksheet(worksheetId).getMetadataContainer().getWorksheetProperties().setPropertyValue(Property.modelContext, graphName);
        workspace.getWorksheet(worksheetId).getMetadataContainer().getWorksheetProperties().setPropertyValue(Property.modelRepository, tripleStoreUrl);
      }
      if (result) {
        logger.info("Saved model to triple store");
        uc.add(new AbstractUpdate() {
          public void generateJson(String prefix, PrintWriter pw, 
              VWorkspace vWorkspace) {
            JSONObject outputObject = new JSONObject();
            try {
              outputObject.put(JsonKeys.updateType.name(), "PublishR2RMLUpdate");
View Full Code Here

TOP

Related Classes of edu.isi.karma.controller.update.AbstractUpdate

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.