@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); }
/** * 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 engine cannot be reached. */ public static GraknBackendException cannotReach(URI uri){ return create(COULD_NOT_REACH_ENGINE.getMessage(uri)); }
/** * Thrown when the graph can not be closed due to an unknown reason. */ public static GraknTxOperationException closingFailed(GraknTx tx, Exception e){ return new GraknTxOperationException(CLOSE_FAILURE.getMessage(tx.keyspace()), e); }
/** * Thrown when an thing does not have a type */ public static GraknTxOperationException noType(Thing thing){ return create(NO_TYPE.getMessage(thing.id())); }
/** * Thrown when trying to create something using a label reserved by the system */ public static GraknTxOperationException reservedLabel(Label label){ return create(RESERVED_WORD.getMessage(label.getValue())); }
/** * Thrown when a {@link Type} has incoming edges and therefore cannot be deleted */ public static GraknTxOperationException cannotBeDeleted(SchemaConcept schemaConcept){ return create(ErrorMessage.CANNOT_DELETE.getMessage(schemaConcept.label())); }
/** * Thrown when attempting to mutate a read only transaction */ public static GraknTxOperationException transactionReadOnly(GraknTx tx){ return create(ErrorMessage.TRANSACTION_READ_ONLY.getMessage(tx.keyspace())); }
/** * Thrown when attempting to set a regex on a {@link Attribute} whose type {@link AttributeType} is not of the * data type {@link AttributeType.DataType#STRING} */ public static GraknTxOperationException cannotSetRegex(AttributeType attributeType){ return create(REGEX_NOT_STRING.getMessage(attributeType.label())); }
public static GraqlQueryException conflictingProperties( VarPatternAdmin varPattern, UniqueVarProperty property, UniqueVarProperty other) { String message = ErrorMessage.CONFLICTING_PROPERTIES.getMessage( varPattern.getPrintableName(), property.graqlString(), other.graqlString() ); return new GraqlQueryException(message); }
/** * Thrown when a {@link Thing} is not allowed to have {@link Attribute} of that {@link AttributeType} */ public static GraknTxOperationException hasNotAllowed(Thing thing, Attribute attribute){ return create(HAS_INVALID.getMessage(thing.type().label(), attribute.type().label())); }