@Override final Relationship asCurrentBaseType(Concept other) { return other.asRelationship(); } }
@Override protected final Relationship asInstance(Concept concept) { return concept.asRelationship(); } }
@Override final Relationship asSelf(Concept concept) { return concept.asRelationship(); } }
@Override protected final Relationship asInstance(Concept concept) { return concept.asRelationship(); } }
@Override public final Relationship attributeRelationship(Attribute attribute) { return runMethod(ConceptMethods.setAttribute(attribute)).asRelationship(); }
/** * * @param concept The concept to no longer track */ @SuppressWarnings("SuspiciousMethodCalls") public void remove(Concept concept){ modifiedThings.remove(concept); modifiedRoles.remove(concept); modifiedRelationshipTypes.remove(concept); modifiedRules.remove(concept); if(concept.isAttribute()) { newAttributes.removeAll(AttributeImpl.from(concept.asAttribute()).getIndex()); } if(concept.isRelationship()){ newRelationships.remove(concept.asRelationship()); } conceptCache.remove(concept.id()); if (concept.isSchemaConcept()) { Label label = concept.asSchemaConcept().label(); schemaConceptCache.remove(label); labelCache.remove(label); } }
public static ConceptMethod<Stream<? extends Concept>> getRolePlayersByRoles(Role... roles) { return ConceptMethod.builder(ConceptResponseType.CONCEPTS) .requestSetter(builder -> builder.setGetRolePlayersByRoles(convert(Stream.of(roles)))) .function(concept -> concept.asRelationship().rolePlayers(roles)) .build(); }
@Override public Collection<PropertyExecutor> insert(Var var) throws GraqlQueryException { PropertyExecutor.Method method = executor -> { Relationship relationship = executor.get(var).asRelationship(); relationPlayers().forEach(relationPlayer -> addRoleplayer(executor, relationship, relationPlayer)); }; return ImmutableSet.of(PropertyExecutor.builder(method).requires(requiredVars(var)).build()); }
for (Map.Entry<Role, Set<Thing>> rolePlayers : concept.asRelationship().rolePlayersMap().entrySet()) { Role role = rolePlayers.getKey(); Set<Thing> things = rolePlayers.getValue();
@Override @Deprecated public final Relationship relhas(Attribute attribute) { // TODO: replace usage of this method as a getter, with relationships(Attribute attribute) // TODO: then remove this method altogether and just use has(Attribute attribute) ConceptProto.Method.Req method = ConceptProto.Method.Req.newBuilder() .setThingRelhasReq(ConceptProto.Thing.Relhas.Req.newBuilder() .setAttribute(RequestBuilder.Concept.concept(attribute))).build(); Concept concept = RemoteConcept.of(runMethod(method).getThingRelhasRes().getRelation(), tx()); return concept.asRelationship(); }
@Override public Stream<ConceptMap> materialise(){ RelationshipType relationType = getSchemaConcept().asRelationshipType(); Multimap<Role, Var> roleVarMap = getRoleVarMap(); ConceptMap substitution = getParentQuery().getSubstitution(); //if the relation already exists, only assign roleplayers, otherwise create a new relation Relationship relationship = substitution.containsVar(getVarName())? substitution.get(getVarName()).asRelationship() : RelationshipTypeImpl.from(relationType).addRelationshipInferred(); roleVarMap.asMap().forEach((key, value) -> value.forEach(var -> relationship.assign(key, substitution.get(var).asThing()))); ConceptMap relationSub = getRoleSubstitution().merge( getVarName().isUserDefinedName()? new ConceptMapImpl(ImmutableMap.of(getVarName(), relationship)) : new ConceptMapImpl() ); return Stream.of(substitution.merge(relationSub)); }
public static ConceptMethod<Void> removeRolePlayer(RolePlayer rolePlayer) { return ConceptMethod.builder(ConceptResponseType.UNIT) .requestSetter(builder -> builder.setUnsetRolePlayer(convert(rolePlayer))) .functionVoid(concept -> { concept.asRelationship().removeRolePlayer(rolePlayer.role(), rolePlayer.player()); }) .build(); }
public static ConceptMethod<Void> setRolePlayer(RolePlayer rolePlayer) { return ConceptMethod.builder(ConceptResponseType.UNIT) .requestSetter(builder -> builder.setSetRolePlayer(convert(rolePlayer))) .functionVoid(concept -> concept.asRelationship().addRolePlayer(rolePlayer.role(), rolePlayer.player())) .build(); }
private void attachAttribute(Concept owner, Attribute attribute){ if (owner.isEntity()){ EntityImpl.from(owner.asEntity()).attributeInferred(attribute); } else if (owner.isRelationship()){ RelationshipImpl.from(owner.asRelationship()).attributeInferred(attribute); } else if (owner.isAttribute()){ AttributeImpl.from(owner.asAttribute()).attributeInferred(attribute); } }
static Pattern toPattern(Concept concept) { if (!concept.isThing()){ throw GraqlQueryException.conceptNotAThing(concept); } if (concept.isEntity()) { return new EntityConverter().pattern(concept.asEntity()); } else if (concept.isRelationship()) { return new RelationshipConverter().pattern(concept.asRelationship()); } else if (concept.isAttribute()) { return new AttributeConverter().pattern(concept.asAttribute()); } else { throw CommonUtil.unreachableStatement("Unrecognised concept " + concept); } }