com.orientechnologies.orient.core.exception.OConfigurationException Java Examples

The following examples show how to use com.orientechnologies.orient.core.exception.OConfigurationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OAbstractETLComponent.java    From orientdb-etl with Apache License 2.0 6 votes vote down vote up
protected boolean skip(final Object input) {
  final OSQLFilter ifFilter = getIfFilter();
  if (ifFilter != null) {
    final ODocument doc = input instanceof OIdentifiable ? (ODocument) ((OIdentifiable) input).getRecord() : null;

    log(OETLProcessor.LOG_LEVELS.DEBUG, "Evaluating conditional expression if=%s...", ifFilter);

    final Object result = ifFilter.evaluate(doc, null, context);
    if (!(result instanceof Boolean))
      throw new OConfigurationException("'if' expression in Transformer " + getName() + " returned '" + result
          + "' instead of boolean");

    return !(Boolean) result;
  }
  return false;
}
 
Example #2
Source File: OETLProcessor.java    From orientdb-etl with Apache License 2.0 6 votes vote down vote up
protected Class getClassByName(final OETLComponent iComponent, final String iClassName) {
  final Class inClass;
  if (iClassName.equals("ODocument"))
    inClass = ODocument.class;
  else if (iClassName.equals("String"))
    inClass = String.class;
  else if (iClassName.equals("Object"))
    inClass = Object.class;
  else if (iClassName.equals("OrientVertex"))
    inClass = OrientVertex.class;
  else if (iClassName.equals("OrientEdge"))
    inClass = OrientEdge.class;
  else
    try {
      inClass = Class.forName(iClassName);
    } catch (ClassNotFoundException e) {
      throw new OConfigurationException("Class '" + iClassName + "' declared as 'input' of ETL Component '"
          + iComponent.getName() + "' was not found.");
    }
  return inClass;
}
 
Example #3
Source File: OETLProcessor.java    From orientdb-etl with Apache License 2.0 6 votes vote down vote up
protected void analyzeFlow() {
  if (extractor == null)
    throw new OConfigurationException("extractor is null");

  if (loader == null)
    throw new OConfigurationException("loader is null");

  OETLComponent lastComponent = extractor;

  for (OTransformer t : transformers) {
    checkTypeCompatibility(t, lastComponent);
    lastComponent = t;
  }

  checkTypeCompatibility(loader, lastComponent);
}
 
Example #4
Source File: OEdgeTransformer.java    From orientdb-etl with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(OETLProcessor iProcessor, final ODocument iConfiguration, final OCommandContext iContext) {
  super.configure(iProcessor, iConfiguration, iContext);
  edgeClass = iConfiguration.field("class");
  if (iConfiguration.containsField("direction")) {
    final String direction = iConfiguration.field("direction");
    if ("out".equalsIgnoreCase(direction))
      directionOut = true;
    else if ("in".equalsIgnoreCase(direction))
      directionOut = false;
    else
      throw new OConfigurationException("Direction can be 'in' or 'out', but found: " + direction);
  }

  if (iConfiguration.containsField("targetVertexFields"))
    targetVertexFields = (ODocument) iConfiguration.field("targetVertexFields");
  if (iConfiguration.containsField("edgeFields"))
    edgeFields = (ODocument) iConfiguration.field("edgeFields");
  if (iConfiguration.containsField("skipDuplicates"))
    skipDuplicates = (Boolean) resolve(iConfiguration.field("skipDuplicates"));
}
 
Example #5
Source File: OETLProcessor.java    From orientdb-etl with Apache License 2.0 5 votes vote down vote up
protected void checkTypeCompatibility(final OETLComponent iCurrentComponent, final OETLComponent iLastComponent) {
  final String out;
  final List<String> ins;

  try {
    out = iLastComponent.getConfiguration().field("output");
    if (out == null)
      // SKIP IT
      return;

    ins = iCurrentComponent.getConfiguration().field("input");
    if (ins == null)
      // SKIP IT
      return;

    final Class outClass = getClassByName(iLastComponent, out);

    for (String in : ins) {
      final Class inClass = getClassByName(iCurrentComponent, in);
      if (inClass.isAssignableFrom(outClass)) {
        return;
      }
    }

  } catch (Exception e) {
    throw new OConfigurationException("Error on checking compatibility between components '" + iLastComponent.getName()
        + "' and '" + iCurrentComponent.getName() + "'", e);
  }

  throw new OConfigurationException("Component '" + iCurrentComponent.getName() + "' expects one of the following inputs " + ins
      + " but the 'output' for component '" + iLastComponent.getName() + "' is: " + out);

}
 
Example #6
Source File: OHttpSource.java    From orientdb-etl with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(OETLProcessor iProcessor, ODocument iConfiguration, OCommandContext iContext) {
  super.configure(iProcessor, iConfiguration, iContext);
  url = iConfiguration.field("url");
  if (url == null || url.isEmpty())
    throw new OConfigurationException("HTTP Source missing URL");
  if (iConfiguration.containsField("method"))
    method = iConfiguration.field("method");

  if (iConfiguration.containsField("headers"))
    headers = iConfiguration.field("headers");
}
 
Example #7
Source File: OFlowTransformer.java    From orientdb-etl with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(OETLProcessor iProcessor, final ODocument iConfiguration, OCommandContext iContext) {
  super.configure(iProcessor, iConfiguration, iContext);
  operation = iConfiguration.field("operation");
  if (operation == null)
    throw new OConfigurationException("Flow transformer has not mandatory 'operation' field");
  if (!operation.equalsIgnoreCase("halt") && !operation.equalsIgnoreCase("skip"))
    throw new OConfigurationException("Flow transformer has invalid 'operation' field='" + operation
        + "', while supported are: 'skip' and 'halt'");
}
 
Example #8
Source File: OBlockTransformer.java    From orientdb-etl with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(OETLProcessor iProcessor, final ODocument iConfiguration, OCommandContext iContext) {
  super.configure(iProcessor, iConfiguration, iContext);
  final String[] fieldNames = iConfiguration.fieldNames();

  try {
    block = processor.getFactory().getBlock(fieldNames[0]);
    block.configure(processor, (ODocument) iConfiguration.field(fieldNames[0]), context);
  } catch (Exception e) {
    throw new OConfigurationException("[Block transformer] Error on configuring inner block", e);
  }
}
 
Example #9
Source File: OLuceneIndexFactory.java    From orientdb-lucene with Apache License 2.0 5 votes vote down vote up
private OIndexInternal<?> createLuceneIndex(String name, ODatabaseDocumentInternal oDatabaseRecord, String indexType,
    String valueContainerAlgorithm, ODocument metadata) {
  if (OClass.INDEX_TYPE.FULLTEXT.toString().equals(indexType)) {
    return new OLuceneFullTextIndex(name, indexType, LUCENE_ALGORITHM, new OLuceneIndexEngine<Set<OIdentifiable>>(
        new OLuceneFullTextIndexManager(), indexType), valueContainerAlgorithm, metadata);
  } else if (OClass.INDEX_TYPE.SPATIAL.toString().equals(indexType)) {
    return new OLuceneSpatialIndex(name, indexType, LUCENE_ALGORITHM, new OLuceneIndexEngine<Set<OIdentifiable>>(
        new OLuceneSpatialIndexManager(OShapeFactoryImpl.INSTANCE), indexType), valueContainerAlgorithm, metadata);
  }
  throw new OConfigurationException("Unsupported type : " + indexType);
}
 
Example #10
Source File: OLuceneIndexFactory.java    From orientdb-lucene with Apache License 2.0 4 votes vote down vote up
@Override
public OIndexInternal<?> createIndex(String name, ODatabaseDocumentInternal database, String indexType, String algorithm,
    String valueContainerAlgorithm, ODocument metadata, int version) throws OConfigurationException {
  return createIndex(name, database, indexType, algorithm, valueContainerAlgorithm, metadata);
}
 
Example #11
Source File: OLuceneIndexFactory.java    From orientdb-lucene with Apache License 2.0 4 votes vote down vote up
protected OIndexInternal<?> createIndex(String name, ODatabaseDocumentInternal oDatabaseRecord, String indexType,
    String algorithm, String valueContainerAlgorithm, ODocument metadata) throws OConfigurationException {
  return createLuceneIndex(name, oDatabaseRecord, indexType, valueContainerAlgorithm, metadata);
}
 
Example #12
Source File: HighLanderIndexFactory.java    From divide with Apache License 2.0 4 votes vote down vote up
@Override
public OIndexInternal<?> createIndex(ODatabaseRecord database, String indexType, String algorithm,
                                     String valueContainerAlgorithm) throws OConfigurationException {
    return new OIndexHighLander(indexType, ODefaultIndexFactory.SBTREE_ALGORITHM, new OMVRBTreeIndexEngine<OIdentifiable>(), valueContainerAlgorithm);
}