Package edu.isi.karma.webserver

Examples of edu.isi.karma.webserver.KarmaException


        ArrayList<ArrayList<String>> data;
    try {
      data = dbUtil.getDataForLimitedRows(dbType, hostname,
              portnumber, username, password, tableName, dBorSIDName, 100);
    } catch (SQLException | ClassNotFoundException e) {
      throw new KarmaException("Unable to get data for limited rows " + e.getLocalizedMessage());
    }
        return generateWorksheet(dbUtil, data);
    }
View Full Code Here


      //If data could not be imported, delete the empty worksheet
      Worksheet ws = getWorksheet();
      if(ws != null)
        workspace.removeWorksheet(ws.getId());
     
      throw new KarmaException("Unable to get data for the SQL Query: " + e.getMessage());
    }
    }
View Full Code Here

    }
   
    // Capture the main mapping resource that corresponds to the source name
    Resource mappingResource = getMappingResourceFromSourceName();
    if (mappingResource == null) {
      throw new KarmaException("Resource not found in model for the source: " + id.getName());
    }
   
    Property modelVersionNameProp = model.getProperty(Uris.KM_MODEL_VERSION_URI);
    Statement s = model.getProperty(mappingResource, modelVersionNameProp);
   
View Full Code Here

    RDFNode node = model.createLiteral(id.getName());
    ResIterator res = model.listResourcesWithProperty(sourceNameProp, node);
    List<Resource> resList = res.toList();
   
    if (resList.size() > 1) {
      throw new KarmaException("More than one resource exists with source name: " + id.getName());
    } else if (resList.size() == 1) {
      return resList.get(0);
    } else {
      //If we didnt find the sourceName in the model, maybe it is a different source with the
      //same schema.
      //Maybe we need to substitute the sourceName in the model with this one
      NodeIterator sourceObjectIter = model.listObjectsOfProperty(sourceNameProp);
      List<RDFNode> sourceObjects = sourceObjectIter.toList();
     
      if(sourceObjects.size() > 1) {
        throw new KarmaException("More than one resource exists with source name: " + id.getName());
      } else if(sourceObjects.size() == 1) {
        RDFNode prevSourceObject = sourceObjects.get(0);
       
        //We got the previous source object, now get the Subject Node for this
        ResIterator prevSourceSubjectsIter = model.listResourcesWithProperty(sourceNameProp, prevSourceObject);
        List<Resource> prevSourceSubjects = prevSourceSubjectsIter.toList();
       
        if (prevSourceSubjects.size() == 1) {
          Resource subject = prevSourceSubjects.get(0);
          model.remove(subject, sourceNameProp, prevSourceObject);
          model.add(subject, sourceNameProp, node);
          return subject;
        } else if(prevSourceSubjects.size() > 1) {
          throw new KarmaException("More than one resource exists with model source name: " + prevSourceObject.toString());
        }
      }
      return null;
    }
  }
View Full Code Here

    }
    HTable hTable = workspace.getFactory().getHTable(hTableId);
    if(hTable == null)
    {
      logger.error("No HTable for id "+ hTableId);
      throw new KarmaException("No HTable for id "+ hTableId );
    }

    //add new column to this table
    //add column after the column with hNodeId
    HNode ndid = null;
View Full Code Here

  }
 
  public Worksheet generateWorksheet(Workspace workspace, String title, String encoding) throws KarmaException, IOException {

    if (workspace == null)
      throw new KarmaException("Workspace is null.");
   
    Worksheet worksheet = workspace.getFactory().createWorksheet(title, workspace, encoding);
   
    return worksheet;
  }
View Full Code Here

          throws KarmaException, IOException {
   
    R2RMLMappingIdentifier id = this.modelIdentifiers.get(modelName);
    ContextIdentifier contextId = this.contextIdentifiers.get(contextName);
    if(id == null) {
      throw new KarmaException("Cannot generate RDF. Model named " + modelName + " does not exist");
    }
    JSONObject context;
    if (contextId == null) {
      context = new JSONObject();
    }
View Full Code Here

              mapping, errorReport, selection);
      rdfGen.generateRDF(true);
    }
    catch( Exception e)
    {
      throw new KarmaException(e.getMessage());
    }
    finally
    {
      removeWorkspace(workspace);
    }
View Full Code Here

        AutoDetectParser parser = new AutoDetectParser();
        try {
          parser.parse(is, contenthandler, metadata);
        } catch (SAXException | TikaException e) {
          logger.error("Unable to parse stream: " + e.getMessage());
          throw new KarmaException("Unable to parse stream: "
              + e.getMessage());
        }
        MediaTypeRegistry registry = MimeTypes.getDefaultMimeTypes()
            .getMediaTypeRegistry();
        registry.addSuperType(new MediaType("text", "csv"), new MediaType(
            "text", "plain"));
        MediaType parsedType = MediaType.parse(metadata
            .get(Metadata.CONTENT_TYPE));
   
        if (registry.isSpecializationOf(registry.normalize(type), registry
            .normalize(parsedType).getBaseType())) {
          metadata.set(Metadata.CONTENT_TYPE, type.toString());
        }
        logger.info("Detected " + metadata.get(Metadata.CONTENT_TYPE));
        inputType = getInputType(metadata);
        encoding = metadata.get(Metadata.CONTENT_ENCODING);
      } else {
        encoding = EncodingDetector.detect(is);
      }
      is.reset();
     
      if(inputType == null) {
           throw new KarmaException("Content type unrecognized");
         }
     
      switch (inputType) {
        case JSON : {
 
          worksheet = generateWorksheetFromJSONStream(sourceName, is,
              workspace, encoding, maxNumLines);
          break;
        }
        case XML : {
          worksheet = generateWorksheetFromXMLStream(sourceName, is,
              workspace, encoding, maxNumLines);
          break;
        }
        case CSV : {
          worksheet = generateWorksheetFromDelimitedStream(sourceName,
              is, workspace, encoding, maxNumLines);
          break;
        }
        case AVRO : {
          worksheet = generateWorksheetFromAvroStream(sourceName, is, workspace, encoding, maxNumLines);
        }
      }
    } catch (Exception e ) {
      logger.error("Error generating worksheet", e);
      throw new KarmaException("Unable to generate worksheet: " + e.getMessage());
    }
    if(worksheet == null) {
         throw new KarmaException("Content type unrecognized");
       }
    return worksheet;
  }
View Full Code Here

    String hNodeId = HistoryJsonUtil.getStringValue(Arguments.hNodeId.name(), inputJson);
    this.normalizeSelectionId(worksheetId, inputJson, workspace);
    String selectionName = CommandInputJSONUtil.getStringValue(Arguments.selectionName.name(), inputJson);
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    if (worksheet == null) {
      throw new KarmaException("Worksheet not found");
    }
    String transformCode = worksheet.getMetadataContainer().getColumnMetadata().getColumnPython(hNodeId);
    if (transformCode == null) {
      throw new KarmaException("Transform code is null");
    }
    RepeatPythonTransformationCommand cmd = new RepeatPythonTransformationCommand(getNewId(workspace), worksheetId,
        hNodeId, transformCode, selectionName);
    cmd.setInputParameterJson(inputJson.toString());
    return cmd;
View Full Code Here

TOP

Related Classes of edu.isi.karma.webserver.KarmaException

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.