Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions common/Printer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@
import com.vaticle.typedb.client.api.concept.thing.Thing;
import com.vaticle.typedb.client.api.concept.type.RoleType;
import com.vaticle.typedb.client.api.concept.type.Type;
import com.vaticle.typedb.client.api.concept.value.Value;
import com.vaticle.typedb.client.api.database.Database;
import com.vaticle.typeql.lang.common.TypeQLToken;
import org.jline.utils.AttributedString;
import org.jline.utils.AttributedStyle;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import org.jline.utils.AttributedString;
import org.jline.utils.AttributedStyle;

import static com.vaticle.typeql.lang.common.TypeQLToken.Constraint.ISA;
import static java.util.stream.Collectors.joining;

Expand Down Expand Up @@ -87,9 +91,16 @@ public void databaseReplica(Database.Replica replica) {
}

private String conceptMapDisplayString(ConceptMap conceptMap, TypeDBTransaction tx) {
String content = conceptMap.map().entrySet().stream().map(
e -> TypeQLToken.Char.$ + e.getKey() + " " + conceptDisplayString(e.getValue(), tx) + ";"
).collect(joining("\n"));
Comparator<Map.Entry<String, Concept>> comparator = Comparator.comparing(e -> e.getValue().isValue());
comparator = comparator.thenComparing(e -> e.getKey().toLowerCase());
String content = conceptMap.map().entrySet().stream().sorted(comparator)
.map(e -> {
if (e.getValue().isValue()) {
return TypeQLToken.Char.QUESTION_MARK + e.getKey() + " = " + conceptDisplayString(e.getValue().asValue(), tx) + ";";
} else {
return TypeQLToken.Char.$ + e.getKey() + " " + conceptDisplayString(e.getValue(), tx) + ";";
}
}).collect(joining("\n"));
StringBuilder sb = new StringBuilder("{");
if (content.lines().count() > 1) sb.append("\n").append(indent(content)).append("\n");
else sb.append(" ").append(content).append(" ");
Expand All @@ -102,6 +113,8 @@ private static String indent(String string) {
}

private String conceptDisplayString(Concept concept, TypeDBTransaction tx) {
if (concept.isValue()) return valueDisplayString(concept.asValue());

StringBuilder sb = new StringBuilder();
if (concept instanceof Attribute<?>) {
sb.append(attributeDisplayString(concept.asThing().asAttribute()));
Expand All @@ -116,9 +129,14 @@ private String conceptDisplayString(Concept concept, TypeDBTransaction tx) {
if (concept instanceof Thing) {
sb.append(" ").append(isaDisplayString(concept.asThing()));
}

return sb.toString();
}

private String valueDisplayString(Value<?> value) {
return com.vaticle.typeql.lang.common.util.Strings.valueToString(value.getValue());
}

private String isaDisplayString(Thing thing) {
StringBuilder sb = new StringBuilder();
sb.append(colorKeyword(ISA.toString())).append(" ").append(colorType(thing.getType().getLabel().scopedName()));
Expand Down
6 changes: 3 additions & 3 deletions dependencies/vaticle/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ def vaticle_dependencies():
git_repository(
name = "vaticle_dependencies",
remote = "https://github.com/vaticle/dependencies",
commit = "b968cab9c4d2f85d80a0069b8d15cce5afdd0da5", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_dependencies
commit = "385716283e1e64245c3679a06054e271a0608ac1", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_dependencies
)

def vaticle_typedb_common():
git_repository(
name = "vaticle_typedb_common",
remote = "https://github.com/vaticle/typedb-common",
tag = "2.17.0" # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_common
commit = "9372dfb227d54c6eb631eed02e67f250e55e657e" # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_common
)

def vaticle_typedb_client_java():
git_repository(
name = "vaticle_typedb_client_java",
remote = "https://github.com/vaticle/typedb-client-java",
tag = "2.17.1", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_client_java
commit = "16c23649627001b44b39337f9d904619b4dac97c", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_client_java
)