Package edu.isi.karma.controller.update

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


      c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
      return c;
    } catch (Exception e) {
      logger.error("Error in FoldCommand" + e.toString());
      Util.logException(logger, e);
      return new UpdateContainer(new ErrorUpdate(e.getMessage()));
    }
  }
View Full Code Here


      return c;
    }
    catch (Exception e )
    {
      logger.error("Error occured during python transformation.",e);
      return new UpdateContainer(new ErrorUpdate("Error occured while creating applying Python transformation to the column."));
    }
  }
View Full Code Here

        prevCommand.resetColumnValues(workspace);
      }
      UpdateContainer uc = previousPythonTransformationCommand.doIt(workspace);
      return uc;
    } catch (CommandException e) {
      return new UpdateContainer(new ErrorUpdate("Error occured while  applying previous Python transformation to the column."));
   
    }
  }
View Full Code Here

      util.deleteMappingFromTripleStore(tripleStoreURL, context, mappingURI);
      SaveR2RMLModelCommandFactory scf = new SaveR2RMLModelCommandFactory();
      SaveR2RMLModelCommand command = scf.createCommand(workspace, mappingURI, tripleStoreURL, context, "URL");
      command.doIt(workspace);
    } catch (KarmaException e) {
      return new UpdateContainer(new ErrorUpdate("Error occured while deleting R2RML model!"));
    }
   
    uc.add(new AbstractUpdate() {
      public void generateJson(String prefix, PrintWriter pw, 
          VWorkspace vWorkspace) {
View Full Code Here

          worksheet.getSemanticTypes(), rdfPrefix, rdfNamespace,
          false, errorReport);
    } catch (KarmaException e)
    {
      logger.error("Error occured while generating RDF!", e);
      return new UpdateContainer(new ErrorUpdate("Error occured while generating RDF: " + e.getMessage()));
    }
    KR2RMLMapping mapping = mappingGen.getKR2RMLMapping();
    //    TriplesMap triplesMap = mapping.getTriplesMapIndex().get(alignmentNodeId);
    if (contextFromModel) {
      KR2RMLMappingWriter writer;
      try {
        StringWriter string = new StringWriter();
        PrintWriter pw = new PrintWriter(string);
        writer = new KR2RMLMappingWriter();
        writer.addR2RMLMapping(mapping, worksheet, workspace);
        writer.writeR2RMLMapping(pw);
        writer.close();
        pw.flush();
        pw.close();
        Model model = ModelFactory.createDefaultModel();
        InputStream s = new ReaderInputStream(new StringReader(string.toString()));
        model.read(s, null, "TURTLE");
        contextJSON = new ContextGenerator(model, true).generateContext().toString();

      } catch (Exception e) {

      }

    }
    logger.debug(mapping.toString());

    //****************************************************************************************************/
    //*** Extract list of TripleMaps *************************************************************************************************/
    List<TriplesMap> triplesMapList = mapping.getTriplesMapList();


    String rootTriplesMapId = null;
    for(TriplesMap map: triplesMapList)
    {
      if(map.getSubject().getId().compareTo(alignmentNodeId) == 0)
      {
        rootTriplesMapId = map.getId();
        break;
      }
    }
    if(null == rootTriplesMapId)
    {
      String errmsg ="Invalid alignment id " + alignmentNodeId;
      logger.error(errmsg);
      return new UpdateContainer(new ErrorUpdate("Error occured while searching for root for JSON: " +errmsg));
    }
    // create JSONKR2RMLRDFWriter
    final String jsonFileName = workspace.getCommandPreferencesId() + worksheetId + "-" +
        worksheet.getTitle().replaceAll("\\.", "_") "-export"+".json";
    final String jsonFileLocalPath = ServletContextParameterMap.getParameterValue(ContextParameter.JSON_PUBLISH_DIR)
        jsonFileName;
    final String contextName = workspace.getCommandPreferencesId() + worksheetId + "-" + worksheet.getTitle().replaceAll("\\.", "_") "-context.json";
    final String jsonContextFileLocalPath = ServletContextParameterMap.getParameterValue(ContextParameter.JSON_PUBLISH_DIR) + contextName;
    PrintWriter printWriter;
    try {
      printWriter = new PrintWriter(jsonFileLocalPath);
      String baseURI = worksheet.getMetadataContainer().getWorksheetProperties().getPropertyValue(Property.baseURI);
      JSONKR2RMLRDFWriter writer = new JSONKR2RMLRDFWriter(printWriter, baseURI);
      if (contextJSON != null && !contextJSON.isEmpty()) {
        JSONObject context = new JSONObject();
        try {
          context = new JSONObject(this.contextJSON);
        }catch(Exception e)
        {

        }

        PrintWriter pw = new PrintWriter(jsonContextFileLocalPath);
        pw.println(context.toString(4));
        pw.close();
        StringBuilder url = new StringBuilder();
        url.append(ServletContextParameterMap.getParameterValue(ContextParameter.JETTY_HOST));
        url.append(":");
        url.append(ServletContextParameterMap.getParameterValue(ContextParameter.JETTY_PORT));
        url.append("/");
        url.append(ServletContextParameterMap.getParameterValue(ContextParameter.JSON_PUBLISH_RELATIVE_DIR));
        url.append(contextName);
        writer.setGlobalContext(context, new ContextIdentifier(context.toString(), new URL(url.toString())));
      }
      writer.addPrefixes(mapping.getPrefixes());
      RootStrategy strategy = new UserSpecifiedRootStrategy(rootTriplesMapId, new SteinerTreeRootStrategy(new WorksheetDepthRootStrategy()));
      KR2RMLWorksheetRDFGenerator generator = new KR2RMLWorksheetRDFGenerator(worksheet, f, ontMgr, writer, false, strategy, mapping, errorReport, selection);
      try {
        generator.generateRDF(true);
        logger.info("RDF written to file.");
      } catch (IOException e1) {
        logger.error("Error occured while generating RDF!", e1);
        return new UpdateContainer(new ErrorUpdate("Error occured while generating RDF: " + e1.getMessage()));
      }
      printWriter.close();
    } catch (FileNotFoundException | MalformedURLException e) {
      logger.error("File Not found", e);
      return new UpdateContainer(new ErrorUpdate("File Not found while generating RDF: " + e.getMessage()));
    }

    //  ExportMongoDBUtil mongo = new ExportMongoDBUtil();
    try {
      //  mongo.publishMongoDB(JSONArray);
View Full Code Here

          worksheet.getSemanticTypes(), rdfPrefix, rdfNamespace,
          false, errorReport);
    } catch (KarmaException e)
    {
      logger.error("Error occured while generating RDF!", e);
      return new UpdateContainer(new ErrorUpdate("Error occured while generating RDF: " + e.getMessage()));
    }
    KR2RMLMapping mapping = mappingGen.getKR2RMLMapping();

    logger.debug(mapping.toString());
   
    //****************************************************************************************************/
    //*** Extract list of TripleMaps *************************************************************************************************/
    List<TriplesMap> triplesMapList = mapping.getTriplesMapList();
   

    String rootTriplesMapId = null;
    for(TriplesMap map: triplesMapList)
    {
      if(map.getSubject().getId().compareTo(alignmentNodeId) == 0)
      {
        rootTriplesMapId = map.getId();
        break;
      }
    }
    if(null == rootTriplesMapId)
    {
      String errmsg ="Invalid alignment id " + alignmentNodeId;
      logger.error(errmsg);
      return new UpdateContainer(new ErrorUpdate("Error occured while searching for root for JSON: " +errmsg));
    }
    final String avroFileName = workspace.getCommandPreferencesId() + worksheetId + "-" +
        worksheet.getTitle().replaceAll("\\.", "_") "-export"+".avro";
    final String avroFileLocalPath = ServletContextParameterMap.getParameterValue(ContextParameter.AVRO_PUBLISH_DIR)
        avroFileName;
   
    try {
      FileOutputStream fos = new FileOutputStream(new File(avroFileLocalPath));
      AvroKR2RMLRDFWriter writer = new AvroKR2RMLRDFWriter(fos);
      writer.addPrefixes(mapping.getPrefixes());
      RootStrategy strategy = new UserSpecifiedRootStrategy(rootTriplesMapId, new SteinerTreeRootStrategy(new WorksheetDepthRootStrategy()));
      KR2RMLWorksheetRDFGenerator generator = new KR2RMLWorksheetRDFGenerator(worksheet, f, ontMgr, writer,
          false, strategy, mapping, errorReport, selection);
      try {
        generator.generateRDF(true);
        logger.info("RDF written to file.");
      } catch (IOException e1) {
        logger.error("Error occured while generating RDF!", e1);
        return new UpdateContainer(new ErrorUpdate("Error occured while generating RDF: " + e1.getMessage()));
      }
      fos.flush();
      fos.close();
    } catch (FileNotFoundException e) {
      logger.error("File Not found", e);
      return new UpdateContainer(new ErrorUpdate("File Not found while generating RDF: " + e.getMessage()));
    } catch (IOException e) {
      logger.error("Error writing out  Not found", e);
      return new UpdateContainer(new ErrorUpdate("File Not found while generating RDF: " + e.getMessage()));
    }
     
    return new UpdateContainer(new AbstractUpdate() {
     
      @Override
View Full Code Here

        throw new KarmaException("No HTable for id "+ hTableId );
      }
      if (null != hTable.getHNodeFromColumnName(newColumnName)) {
        logger.error("Add column failed to create " + newColumnName
            + " because it already exists!");
        return new UpdateContainer(new ErrorUpdate(
            "Add column failed to create " + newColumnName
                + " because it already exists!"));
      }  
      //add new column to this table
      //add column after the column with hNodeId
      HNode ndid = hTable.addNewHNodeAfter(hNodeId, HNodeType.Transformation, workspace.getFactory(), newColumnName, worksheet,true);
      if(ndid == null)
      {
        logger.error("Unable to add new HNode!");
        throw new KarmaException("Unable to add new HNode!");
      }
      //add as first column in the table if hNodeId is null
      //HNode ndid = currentTable.addNewHNodeAfter(null, vWorkspace.getRepFactory(), newColumnName, worksheet,true);

      //save the new hNodeId for undo
      newHNodeId = ndid.getId();
     
      // Populate the column with default value if default value is present
      if (this.defaultValue != null && !this.defaultValue.equals("")) {
        populateRowsWithDefaultValues(worksheet, workspace.getFactory());
      }
     
      //create container and return hNodeId of newly created column
      UpdateContainer c =  new UpdateContainer(new AddColumnUpdate(newHNodeId, worksheetId));
     
      c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(worksheet)));
      c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace, ndid.getHNodePath(workspace.getFactory())));
      return c;
    } catch (Exception e) {
      logger.error("Error in AddColumnCommand" + e.toString());
      Util.logException(logger, e);
      return new UpdateContainer(new ErrorUpdate(e.getMessage()));
    }
  }
View Full Code Here

    }
    catch (Exception e)
    {
      logger.error("Error occured during python transformation.",e);
      return new UpdateContainer(new ErrorUpdate("Error occured while creating new column for applying Python transformation to the column."));
    }
    try
    {
      UpdateContainer c = applyPythonTransformation(workspace, worksheet, f,
          hNode, ctrl, addColCmd.getNewHNodeId());
      WorksheetUpdateFactory.detectSelectionStatusChange(worksheetId, workspace, this);
      return c;
    }
    catch (Exception e )
    {
      addColCmd.undoIt(workspace);
      logger.error("Error occured during python transformation.",e);
      return new UpdateContainer(new ErrorUpdate("Error occured while creating applying Python transformation to the column."));
    }
  }
View Full Code Here

          prevCommand.resetColumnValues(workspace);
        }
        UpdateContainer uc = previousPythonTransformationCommand.doIt(workspace);
        return uc;
      } catch (CommandException e) {
        return new UpdateContainer(new ErrorUpdate("Error occured while  applying previous Python transformation to the column."));

      }
    } else if(this.originalColumnValues != null) {
      resetColumnValues(workspace);
    }
View Full Code Here

        }
      }catch(Exception e) {
        System.out.println("here");
        e.printStackTrace();
        logger.error("Error occured while saving R2RML Model!");
        return new UpdateContainer(new ErrorUpdate("Error occured while saving R2RML model!"));
      }

    }
    else {
      boolean result = saveMapping(modelUrl, graphContext);
      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(), "SaveModel");
              pw.println(outputObject.toString());
            } catch (JSONException e) {
              e.printStackTrace();
              logger.error("Error occured while generating JSON!");
            }
          }
        });
        successful = result;
        return uc;
      }
    }
    logger.error("Error occured while saving R2RML Model!");
    return new UpdateContainer(new ErrorUpdate("Error occured while saving R2RML model!"));
  }
View Full Code Here

TOP

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

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.