private static boolean mayHaveEdgeInstances(SchemaConcept concept) { return concept.isRelationshipType() && concept.isImplicit(); } }
private Set<SchemaConcept> getTypes(SchemaConcept type, boolean direct) { Set<SchemaConcept> types = direct ? Sets.newHashSet(type) : type.subs().collect(Collectors.toSet()); return type.isImplicit()? types.stream().flatMap(t -> Stream.of(t, tx.getSchemaConcept(Schema.ImplicitType.explicitLabel(t.label())))).collect(Collectors.toSet()): types; }
/** * Helper method to check whether implicit or attribute types are included in the query scope * * @return true if they exist, false if they don't */ private boolean scopeIncludesImplicitOrAttributeTypes() { if (!query.in().isPresent()) return false; return query.in().get().stream().anyMatch(label -> { SchemaConcept type = tx.getSchemaConcept(label); return (type != null && (type.isAttributeType() || type.isImplicit())); }); }
@Override public Set<String> validateAsRuleHead(Rule rule){ Set<String> errors = new HashSet<>(); Set<Atomic> parentAtoms = getParentQuery().getAtoms(Atomic.class).filter(at -> !at.equals(this)).collect(toSet()); Set<Var> varNames = Sets.difference( getVarNames(), this.getInnerPredicates().map(Atomic::getVarName).collect(toSet()) ); boolean unboundVariables = varNames.stream() .anyMatch(var -> parentAtoms.stream().noneMatch(at -> at.getVarNames().contains(var))); if (unboundVariables) { errors.add(ErrorMessage.VALIDATION_RULE_ILLEGAL_HEAD_ATOM_WITH_UNBOUND_VARIABLE.getMessage(rule.then(), rule.label())); } SchemaConcept schemaConcept = getSchemaConcept(); if (schemaConcept == null){ errors.add(ErrorMessage.VALIDATION_RULE_ILLEGAL_HEAD_ATOM_WITH_AMBIGUOUS_SCHEMA_CONCEPT.getMessage(rule.then(), rule.label())); } else if (schemaConcept.isImplicit()){ errors.add(ErrorMessage.VALIDATION_RULE_ILLEGAL_HEAD_ATOM_WITH_IMPLICIT_SCHEMA_CONCEPT.getMessage(rule.then(), rule.label())); } return errors; }