private EntityType entityType() { return random.choose(tx.admin().getMetaEntityType().subs().collect(toSet())); }
/** * Helper method to get the types to be included in the query scope * * @return stream of Concept Types */ private Stream<Type> scopeTypes() { // Get all types if query.inTypes() is empty, else get all scoped types of each meta type. // Only include attributes and implicit "has-xxx" relationships when user specifically asked for them. if (!query.in().isPresent() || query.in().get().isEmpty()) { ImmutableSet.Builder<Type> typeBuilder = ImmutableSet.builder(); if (scopeIncludesAttributes()) { tx.admin().getMetaConcept().subs().forEach(typeBuilder::add); } else { tx.admin().getMetaEntityType().subs().forEach(typeBuilder::add); tx.admin().getMetaRelationType().subs() .filter(relationshipType -> !relationshipType.isImplicit()).forEach(typeBuilder::add); } return typeBuilder.build().stream(); } else { Stream<Type> subTypes = query.in().get().stream().map(label -> { Type type = tx.getType(label); if (type == null) throw GraqlQueryException.labelNotFound(label); return type; }).flatMap(Type::subs); if (!scopeIncludesAttributes()) { subTypes = subTypes.filter(relationshipType -> !relationshipType.isImplicit()); } return subTypes; } }