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

The following examples show how to use com.orientechnologies.orient.core.exception.OSchemaException. 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: IntegrationTestClass.java    From bjoern with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void csvBatchImporterTest() throws java.lang.Exception
{

    CSVBatchImporter importer = new CSVBatchImporter();

    importer.setDbName("__TEST__1");
    try {
        importer.importCSVFiles(
                "test/src/resources/nodes.csv",
                "test/src/resources/edges.csv");
    }
    catch (OSchemaException exception) {
        exception.printStackTrace();
        throw exception;
    }

    OrientGraph graph = new OrientGraph(
            "plocal:" + System.getProperty("ORIENTDB_HOME") + "/databases/" + "__TEST__1");

    Pipe pipe = Gremlin.compile("_().map");
    pipe.setStarts(graph.getVertices());
}
 
Example #2
Source File: OrientDbLoader.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
protected void createProperties(Row row) {
    OClass clazz;
    if (className != null) {
        clazz = getOrCreateClass(className);
    } else {
        clazz = ((ODocument) row.getPayload()).getSchemaClass();
    }

    int count = row.getFieldCount();
    for (int i = 0; i < count; i++) {
        String fieldName = row.getFieldName(i);
        OProperty property = clazz.getProperty(fieldName);
        if (property == null) {
            OType type = OType.getTypeByClass(row.getFieldType(i));
            try {
                clazz.createProperty(fieldName, type);
            } catch (OSchemaException e) {
                log.error(e.getMessage(), e);
            }

            log.debug("Created property '{}' of type '{}'", fieldName, type);
        }
    }
}
 
Example #3
Source File: OrientDefaultExceptionsHandlingListener.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
@Override
public IRequestHandler onException(RequestCycle cycle, Exception ex) {
	try {
		Throwable th = null;
		if((th=Exceptions.findCause(ex, OSecurityException.class))!=null
				|| (th=Exceptions.findCause(ex, OValidationException.class))!=null
				|| (th=Exceptions.findCause(ex, OSchemaException.class))!=null
				|| (th=Exceptions.findCause(ex, IllegalStateException.class))!=null && Exceptions.findCause(ex, WicketRuntimeException.class)==null)
		{
			Page page = extractCurrentPage(false);
			if(page==null) {
				if(th instanceof OSecurityException) 
					OrientDbWebApplication.get().restartResponseAtSignInPage(); //Will throw exception
				return null;
			}
			OrientDbWebSession.get().error(th.getMessage());
			return new RenderPageRequestHandler(new PageProvider(page),
			RenderPageRequestHandler.RedirectPolicy.ALWAYS_REDIRECT);
		}
		else if((th=Exceptions.findCause(ex, UnauthorizedActionException.class))!=null)
		{
			final UnauthorizedActionException unauthorizedActionException = (UnauthorizedActionException)th;
			return new UnauthorizedInstantiationHandler(unauthorizedActionException.getComponent());
		}
		else
		{
			return null;
		}
	} catch (ReplaceHandlerException e) {
		return e.getReplacementRequestHandler();
	}
}
 
Example #4
Source File: OOrientDBLoader.java    From orientdb-etl with Apache License 2.0 5 votes vote down vote up
protected void createProperty(final OClass cls, final String f, final Object fValue) {
  if (fValue != null) {
    final OType fType = OType.getTypeByClass(fValue.getClass());

    try {
      cls.createProperty(f, fType);
    } catch (OSchemaException e) {
    }

    log(OETLProcessor.LOG_LEVELS.DEBUG, "created property [%s.%s] of type [%s]", cls.getName(), f, fType);
  }
}