Skip to content

Commit

Permalink
Merge pull request #46 from bicouy0/unprefixed-classnames
Browse files Browse the repository at this point in the history
moved INTERNAL_CLASSES_TO_TINKERPOP_CLASSES
  • Loading branch information
velo committed Dec 14, 2015
2 parents 81f6041 + e49f447 commit 43ccad2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.id.ORID;
import com.orientechnologies.orient.core.metadata.schema.OImmutableClass;
import com.orientechnologies.orient.core.record.impl.ODocument;

import org.apache.tinkerpop.gremlin.structure.*;
Expand All @@ -11,22 +10,13 @@
import static com.google.common.base.Preconditions.checkNotNull;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.stream.Stream;

public abstract class OrientElement implements Element {

private static final Map<String, String> INTERNAL_CLASSES_TO_TINKERPOP_CLASSES;

static {
INTERNAL_CLASSES_TO_TINKERPOP_CLASSES = new HashMap<>();
INTERNAL_CLASSES_TO_TINKERPOP_CLASSES.put(OImmutableClass.VERTEX_CLASS_NAME, Vertex.DEFAULT_LABEL);
INTERNAL_CLASSES_TO_TINKERPOP_CLASSES.put(OImmutableClass.EDGE_CLASS_NAME, Edge.DEFAULT_LABEL);
}

protected OIdentifiable rawElement;
protected OrientGraph graph;

Expand All @@ -45,7 +35,7 @@ public String label() {
String internalClassName = getRawDocument().getClassName();
// User labels on edges/vertices are prepended with E_ or V_ . The user
// should not see that.
return internalClassName.length() == 1 ? INTERNAL_CLASSES_TO_TINKERPOP_CLASSES.get(internalClassName) : graph.classNameToLabel(internalClassName);
return graph.classNameToLabel(internalClassName);
}

public Graph graph() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ public final class OrientGraph implements Graph {
.addStrategies(OrientGraphStepStrategy.instance()));
}

private static final Map<String, String> INTERNAL_CLASSES_TO_TINKERPOP_CLASSES;

static {
INTERNAL_CLASSES_TO_TINKERPOP_CLASSES = new HashMap<>();
INTERNAL_CLASSES_TO_TINKERPOP_CLASSES.put(OImmutableClass.VERTEX_CLASS_NAME, Vertex.DEFAULT_LABEL);
INTERNAL_CLASSES_TO_TINKERPOP_CLASSES.put(OImmutableClass.EDGE_CLASS_NAME, Edge.DEFAULT_LABEL);
}

public static String CONFIG_URL = "orient-url";
public static String CONFIG_USER = "orient-user";
public static String CONFIG_PASS = "orient-pass";
Expand Down Expand Up @@ -179,6 +187,9 @@ public String labelToClassName(String label, String prefix) {
* Convert a orientdb class name to label
*/
public String classNameToLabel(String className) {
if (INTERNAL_CLASSES_TO_TINKERPOP_CLASSES.containsKey(className)) {
return INTERNAL_CLASSES_TO_TINKERPOP_CLASSES.get(className);
}
if (configuration.getBoolean(CONFIG_LABEL_AS_CLASSNAME, false)) {
return className;
}
Expand Down

0 comments on commit 43ccad2

Please sign in to comment.