private PathTreeSymmetricKB(int n, int m){ super("path-test-symmetric.gql", Label.of("index"), n, m); }
@Override public final String toString() { // TODO: Consider using @AutoValue toString return getValue(); } }
@CheckReturnValue public Label getLabel(Label attributeType) { return attributeType.map(attribute -> String.format(label, attribute)); }
/** * Helper method which converts the implicit type label back into the original label from which is was built. * * @param implicitType the implicit type label * @return The original label which was used to build this type */ @CheckReturnValue public static Label explicitLabel(Label implicitType){ if(!implicitType.getValue().startsWith("key") && implicitType.getValue().startsWith("has")){ throw new IllegalArgumentException(INVALID_IMPLICIT_TYPE.getMessage(implicitType)); } int endIndex = implicitType.getValue().length(); if(implicitType.getValue().endsWith("-value") || implicitType.getValue().endsWith("-owner")) { endIndex = implicitType.getValue().lastIndexOf("-"); } //return the Label without the `@has-`or '@key-' prefix return Label.of(implicitType.getValue().substring(5, endIndex)); } }
private PathTreeKB(int n, int m){ super("path-test.gql", Label.of("index"), n, m); }
/** * Make a name for the role type corresponding to the subject (i.e. domain) of an OWL object * property. * * @param relationLabel The label of the Grakn {@link RelationshipType}. */ default Label subjectRole(Label relationLabel) { return relationLabel.map(relation -> OwlModel.SUBJECT.owlname() + "-" + relation); } /**
private PathMatrixKB(int n, int m){ super("path-test.gql", Label.of("index"), n, m); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof Label) { Label that = (Label) o; return (this.value.equals(that.getValue())); } return false; }
/** * Make a name for the role type corresponding to the object (i.e. range) of an OWL object * property. * * @param relationLabel The label of the Grakn {@link RelationshipType}. */ default Label objectRole(Label relationLabel) { return relationLabel.map(relation -> OwlModel.OBJECT.owlname() + "-" + relation); } /**
@CheckReturnValue public Label getLabel(String attributeType) { return Label.of(String.format(label, attributeType)); }
public static GraqlQueryException kCoreOnRelationshipType(Label label) { return create("cannot compute coreness of relationship type %s.", label.getValue()); }
/** * Create a matcher to test that the concept has the given type name. */ public static Matcher<MatchableConcept> role(String type) { return role(Label.of(type)); }
/** * @param label a label of a type * @return * The label of the type correctly escaped in graql. * If the label doesn't begin with a number and is only comprised of alphanumeric characters, underscores and dashes, * then it will be returned as-is, otherwise it will be quoted and escaped. */ public static String typeLabelToString(Label label) { return escapeLabelOrId(label.getValue()); }
/** * Create a matcher to test that the concept has the given type name. */ public static Matcher<MatchableConcept> type(String type) { return type(Label.of(type)); }
private Stream<AttributeType> attributes(Schema.ImplicitType implicitType){ //TODO: Make this less convoluted String [] implicitIdentifiers = implicitType.getLabel("").getValue().split("--"); String prefix = implicitIdentifiers[0] + "-"; String suffix = "-" + implicitIdentifiers[1]; //A traversal is not used in this so that caching can be taken advantage of. return playing().map(role -> role.label().getValue()). filter(roleLabel -> roleLabel.startsWith(prefix) && roleLabel.endsWith(suffix)). map(roleLabel -> { String attributeTypeLabel = roleLabel.replace(prefix, "").replace(suffix, ""); return vertex().tx().getAttributeType(attributeTypeLabel); }); }
@Nullable @Override public EntityType getEntityType(String label) { return getSchemaConcept(Label.of(label)); }
/** * Thrown when trying to create something using a label reserved by the system */ public static GraknTxOperationException reservedLabel(Label label){ return create(RESERVED_WORD.getMessage(label.getValue())); }
@Nullable @Override public Role getRole(String label) { return getSchemaConcept(Label.of(label)); }