use of com.vaticle.typedb.core.concept.Concept in project grakn by graknlabs.
the class Mapping method transform.
public ConceptMap transform(ConceptMap conceptMap) {
Map<Retrievable, Concept> transformed = new HashMap<>();
for (Map.Entry<Retrievable, ? extends Concept> entry : conceptMap.concepts().entrySet()) {
Retrievable id = entry.getKey();
Retrievable mapped = mapping.get(id);
if (mapped != null) {
Concept concept = entry.getValue();
transformed.put(mapped, concept);
}
}
return new ConceptMap(transformed);
}
use of com.vaticle.typedb.core.concept.Concept in project grakn by graknlabs.
the class Resolver method compatibleBounds.
private Optional<ConceptMap> compatibleBounds(Conjunction conjunction, ConceptMap bounds) {
Map<Retrievable, Concept> newBounds = new HashMap<>();
for (Map.Entry<Retrievable, ? extends Concept> entry : bounds.concepts().entrySet()) {
Retrievable id = entry.getKey();
Concept bound = entry.getValue();
Variable conjVariable = conjunction.variable(id);
assert conjVariable != null;
if (conjVariable.isThing()) {
if (!conjVariable.asThing().iid().isPresent())
newBounds.put(id, bound);
else if (!conjVariable.asThing().iid().get().iid().equals(bound.asThing().getIID())) {
return Optional.empty();
}
} else if (conjVariable.isType()) {
if (!conjVariable.asType().label().isPresent())
newBounds.put(id, bound);
else if (!conjVariable.asType().label().get().properLabel().equals(bound.asType().getLabel())) {
return Optional.empty();
}
} else {
throw TypeDBException.of(ILLEGAL_STATE);
}
}
return Optional.of(new ConceptMap(newBounds));
}
Aggregations