@Override public QueryBuilder graql() { if (queryBuilderConstructor == null) { throw new RuntimeException(CANNOT_FIND_CLASS.getMessage("query executor", QUERY_EXECUTOR_CLASS_NAME)); } try { return (QueryBuilder) queryBuilderConstructor.newInstance(this); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public final QueryExecutor queryExecutor() { if (queryExecutorFactory == null) { throw new RuntimeException(CANNOT_FIND_CLASS.getMessage("query builder", QUERY_BUILDER_CLASS_NAME)); } try { return (QueryExecutor) queryExecutorFactory.invoke(null, this); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Thrown when engine cannot delete a keyspace as expected */ public static GraknServerException couldNotDelete(Keyspace keyspace){ return new GraknServerException(CANNOT_DELETE_KEYSPACE.getMessage(keyspace), SC_INTERNAL_SERVER_ERROR); }
/** * Thrown when there is a syntactic error in a Graql template */ public static GraqlSyntaxException parsingIncorrectValueType(Object object, Class clazz, Map data){ return new GraqlSyntaxException(INVALID_STATEMENT.getMessage(object, clazz.getName(), data.toString())); }
/** * Thrown when a key is missing during parsing a template with matching data */ public static GraqlSyntaxException parsingTemplateMissingKey(String invalidText, Map<String, Object> data){ return new GraqlSyntaxException(TEMPLATE_MISSING_KEY.getMessage(invalidText, data)); } }
/** * Thrown when casting concepts incorrectly. For example when doing {@link Concept#asEntityType()} on a * {@link ai.grakn.concept.Entity} */ public static GraknTxOperationException invalidCasting(Object concept, Class type){ return create(ErrorMessage.INVALID_OBJECT_TYPE.getMessage(concept, type)); }
/** * Thrown when the persistence layer throws an unexpected exception. * This can include timeouts */ public static GraknBackendException unknown(Exception e){ return new GraknBackendException(BACKEND_EXCEPTION.getMessage(), e); }
@Override public void commit(){ LOG.warn(ErrorMessage.TRANSACTIONS_NOT_SUPPORTED.getMessage(TinkerGraph.class.getName(), "committed")); super.commit(); }
@Override public void abort(){ LOG.warn(ErrorMessage.TRANSACTIONS_NOT_SUPPORTED.getMessage(TinkerGraph.class.getName(), "aborted")); super.abort(); } }
/** * Thrown when a request is missing the body */ public static GraknServerException requestMissingBody(){ return new GraknServerException(MISSING_REQUEST_BODY.getMessage(), SC_BAD_REQUEST); }
public static GraqlQueryException incorrectAggregateArgumentNumber( String name, int minArgs, int maxArgs, List<Object> args) { String expectedArgs = (minArgs == maxArgs) ? Integer.toString(minArgs) : minArgs + "-" + maxArgs; String message = ErrorMessage.AGGREGATE_ARGUMENT_NUM.getMessage(name, expectedArgs, args.size()); return new GraqlQueryException(message); }
/** * Thrown when attempting to traverse an edge in an invalid direction */ public static GraknTxOperationException invalidDirection(Direction direction){ return create(INVALID_DIRECTION.getMessage(direction)); }
/** * Thrown when changing the {@link Label} of an {@link SchemaConcept} which is owned by another {@link SchemaConcept} */ public static GraknTxOperationException labelTaken(Label label){ return create(LABEL_TAKEN.getMessage(label)); }
/** * Thrown when engine cannot be reached. */ public static GraknBackendException cannotReach(URI uri){ return create(COULD_NOT_REACH_ENGINE.getMessage(uri)); }
public static GraqlQueryException maxIterationsReached(Class<?> clazz) { return new GraqlQueryException(ErrorMessage.MAX_ITERATION_REACHED .getMessage(clazz.toString())); }
@Override public Collection<EquivalentFragmentSet> match(Var start) { throw new UnsupportedOperationException(ErrorMessage.MATCH_INVALID.getMessage(this.getName())); }
/** * Thrown when a request is missing mandatory parameters in the body */ public static GraknServerException requestMissingBodyParameters(String parameter){ return new GraknServerException( MISSING_MANDATORY_BODY_REQUEST_PARAMETERS.getMessage(parameter), SC_BAD_REQUEST); }
/** * Thrown the content type specified in a request is invalid */ public static GraknServerException unsupportedContentType(String contentType){ return new GraknServerException(UNSUPPORTED_CONTENT_TYPE.getMessage(contentType), SC_NOT_ACCEPTABLE); }
/** * Thrown when attempting to mutate a {@link ai.grakn.util.Schema.MetaSchema} */ public static GraknTxOperationException metaTypeImmutable(Label metaLabel){ return create(META_TYPE_IMMUTABLE.getMessage(metaLabel)); }
/** * Thrown when attempting to mutate a property which is immutable */ public static GraknTxOperationException immutableProperty(Object oldValue, Object newValue, Enum vertexProperty){ return create(ErrorMessage.IMMUTABLE_VALUE.getMessage(oldValue, newValue, vertexProperty.name())); }