/** * @param label the label of a concept * @return a variable pattern that identifies a concept by label */ @CheckReturnValue public static VarPattern label(Label label) { return var().label(label); }
/** * @param label the label of a concept * @return a variable pattern that identifies a concept by label */ @CheckReturnValue public static VarPattern label(String label) { return var().label(label); }
@Override public final VarPattern key(String type) { return key(Graql.var().label(type)); }
Var varName = rp.getRolePlayer().var(); Role role = Iterables.getOnlyElement(entry.getValue()); VarPatternAdmin rolePattern = Graql.var().label(role.label()).admin(); inferredRelationPlayers.add(RelationPlayer.of(rolePattern, varName.admin())); allocatedRelationPlayers.add(rp); rolePattern.var().label(metaRole.label()).admin() : Graql.var().label(metaRole.label()).admin(); inferredRelationPlayers.add(RelationPlayer.of(rolePattern, varName.admin())); });
/** * if any {@link Role} variable of the parent is user defined rewrite ALL {@link Role} variables to user defined (otherwise unification is problematic) * @param parentAtom parent atom that triggers rewrite * @return new relation atom with user defined {@link Role} variables if necessary or this */ private RelationshipAtom rewriteWithVariableRoles(Atom parentAtom){ if (!parentAtom.requiresRoleExpansion()) return this; VarPattern relVar = getPattern().admin().getProperty(IsaProperty.class) .map(prop -> getVarName().isa(prop.type())).orElse(getVarName()); for (RelationPlayer rp: getRelationPlayers()) { VarPatternAdmin rolePattern = rp.getRole().orElse(null); if (rolePattern != null) { Var roleVar = rolePattern.var(); Label roleLabel = rolePattern.getTypeLabel().orElse(null); relVar = relVar.rel(roleVar.asUserDefined().label(roleLabel), rp.getRolePlayer()); } else { relVar = relVar.rel(rp.getRolePlayer()); } } return create(relVar.admin(), this.getPredicateVariable(), this.getTypeId(), this.getPossibleTypes(), this.getParentQuery()); }
/** * Create a var with the information underlying all Types * @param schemaConcept type to be mapped * @return {@link VarPattern} containing basic information about the given type */ private static VarPattern formatBase(SchemaConcept schemaConcept) { VarPattern var = var().label(schemaConcept.label()); SchemaConcept superType = schemaConcept.sup(); if (schemaConcept.sup() != null) { var = var.sub(Graql.label(superType.label())); } if(schemaConcept.isType()) { Type type = schemaConcept.asType(); var = plays(var, type); var = isAbstract(var, type); } return var; }
if (concept.isRole()) { Label roleLabel = concept.asSchemaConcept().label(); rolePattern = roleVar.label(roleLabel); } else { throw GraqlQueryException.nonRoleIdAssignedToRoleVariable(var);