Skip to content

Commit

Permalink
Apply master format
Browse files Browse the repository at this point in the history
  • Loading branch information
velo committed Dec 13, 2015
1 parent 9bdb72b commit 97e0338
Show file tree
Hide file tree
Showing 25 changed files with 777 additions and 713 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public static class OrientFeatures implements Features {
static final OrientFeatures INSTANCE_NOTX = new OrientFeatures(false);
static final OrientFeatures INSTANCE_TX = new OrientFeatures(true);

private OrientGraphFeatures graphFeatures;
private OrientGraphFeatures graphFeatures;

private OrientFeatures(boolean transactionalGraph) {
this.graphFeatures = new OrientGraphFeatures(transactionalGraph);
}
Expand Down Expand Up @@ -41,7 +42,6 @@ public String toString() {

public static abstract class OrientElementFeatures implements Features.ElementFeatures {


@Override
public boolean supportsAnyIds() {
return false;
Expand All @@ -54,22 +54,22 @@ public boolean supportsCustomIds() {

@Override
public boolean supportsNumericIds() {
return false;
return false;
}

@Override
public boolean supportsStringIds() {
return false;
return false;
}

@Override
public boolean supportsUserSuppliedIds() {
return false;
return false;
}

@Override
public boolean supportsUuidIds() {
return false;
return false;
}

@Override
Expand Down Expand Up @@ -109,7 +109,8 @@ private OrientEdgeFeatures() {

public static class OrientGraphFeatures implements Features.GraphFeatures {

protected final boolean transactionalGraph;
protected final boolean transactionalGraph;

private OrientGraphFeatures(boolean transactionalGraph) {
this.transactionalGraph = transactionalGraph;
}
Expand Down Expand Up @@ -238,37 +239,37 @@ public boolean supportsUniformListValues() {

public static class OrientVertexPropertyFeatures implements Features.VertexPropertyFeatures {

static final OrientVertexPropertyFeatures INSTANCE = new OrientVertexPropertyFeatures();

@Override
public boolean supportsAnyIds() {
return false;
}

@Override
public boolean supportsCustomIds() {
return false;
}

@Override
public boolean supportsNumericIds() {
return false;
}

@Override
public boolean supportsUserSuppliedIds() {
return false;
}

@Override
public boolean supportsUuidIds() {
return false;
}

@Override
public boolean willAllowId(Object id) {
return false;
}
static final OrientVertexPropertyFeatures INSTANCE = new OrientVertexPropertyFeatures();

@Override
public boolean supportsAnyIds() {
return false;
}

@Override
public boolean supportsCustomIds() {
return false;
}

@Override
public boolean supportsNumericIds() {
return false;
}

@Override
public boolean supportsUserSuppliedIds() {
return false;
}

@Override
public boolean supportsUuidIds() {
return false;
}

@Override
public boolean willAllowId(Object id) {
return false;
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import java.util.List;

public class OrientEdge extends OrientElement implements Edge {
private static final List<String> INTERNAL_FIELDS = Arrays.asList("@rid", "@class", "in", "out");
protected OIdentifiable vOut;
protected OIdentifiable vIn;
protected String label;

private static final List<String> INTERNAL_FIELDS = Arrays.asList("@rid", "@class", "in", "out");

protected OIdentifiable vOut;
protected OIdentifiable vIn;
protected String label;

public OrientEdge(OrientGraph graph, OIdentifiable rawElement, final OIdentifiable out, final OIdentifiable in, final String iLabel) {
super(graph, rawElement);
Expand All @@ -38,16 +38,15 @@ public OrientEdge(OrientGraph graph, String className, final OIdentifiable out,
}

public OrientEdge(OrientGraph graph, final OIdentifiable out, final OIdentifiable in, final String iLabel) {
this(graph, (OIdentifiable) null, out, in, iLabel);
this(graph, (OIdentifiable) null, out, in, iLabel);
}

public OrientEdge(OrientGraph graph, ODocument rawDocument, String label) {
this(graph, rawDocument, rawDocument.field("out", OIdentifiable.class), rawDocument.field("in", OIdentifiable.class), label);
}

public OrientEdge(OrientGraph graph, ODocument rawDocument)
{
this(graph, rawDocument, rawDocument.getClassName());
public OrientEdge(OrientGraph graph, ODocument rawDocument) {
this(graph, rawDocument, rawDocument.getClassName());
}

public static OIdentifiable getConnection(final ODocument iEdgeRecord, final Direction iDirection) {
Expand All @@ -61,24 +60,20 @@ protected static ODocument createRawElement(OrientGraph graph, String className)

@Override
public Iterator<Vertex> vertices(Direction direction) {
switch (direction)
{
case OUT:
return graph.vertices(vOut.getIdentity());
case IN:
return graph.vertices(vIn.getIdentity());
case BOTH:
default:
return graph.vertices(vOut.getIdentity(), vIn.getIdentity());
}
switch (direction) {
case OUT:
return graph.vertices(vOut.getIdentity());
case IN:
return graph.vertices(vIn.getIdentity());
case BOTH:
default:
return graph.vertices(vOut.getIdentity(), vIn.getIdentity());
}
}

public <V> Iterator<Property<V>> properties(final String... propertyKeys) {
Iterator<? extends Property<V>> properties = super.properties(propertyKeys);
return StreamUtils.asStream(properties).filter(p ->
!INTERNAL_FIELDS.contains(p.key()) ).map(p ->
(Property<V>) p
).iterator();
return StreamUtils.asStream(properties).filter(p -> !INTERNAL_FIELDS.contains(p.key())).map(p -> (Property<V>) p).iterator();
}

public OrientVertex getVertex(final Direction direction) {
Expand All @@ -102,18 +97,17 @@ public void remove() {
}

@SuppressWarnings("unchecked")
private void removeLink( Direction direction) {
private void removeLink(Direction direction) {
final String fieldName = OrientVertex.getConnectionFieldName(direction, this.label());
ODocument doc = this.getVertex(direction).getRawDocument();
Object found = doc.field(fieldName);
if(found instanceof ORidBag) {
ORidBag bag = (ORidBag)found;
if (found instanceof ORidBag) {
ORidBag bag = (ORidBag) found;
bag.remove(this.getRawElement());
if(bag.size() == 0) doc.removeField(fieldName);
}
else if (found instanceof Collection<?>) {
if (bag.size() == 0) doc.removeField(fieldName);
} else if (found instanceof Collection<?>) {
((Collection<Object>) found).remove(this.getRawElement());
if(((Collection<Object>) found).size() == 0) doc.removeField(fieldName);
if (((Collection<Object>) found).size() == 0) doc.removeField(fieldName);
} else
throw new IllegalStateException("Relationship content is invalid on field " + fieldName + ". Found: " + found);
doc.save();
Expand All @@ -128,11 +122,11 @@ public OIdentifiable getOutVertex() {
if (doc == null)
return null;

// if (settings != null && settings.isKeepInMemoryReferences())
// AVOID LAZY RESOLVING+SETTING OF RECORD
// return doc.rawField(OrientGraphUtils.CONNECTION_OUT);
// else
return doc.field(OrientGraphUtils.CONNECTION_OUT);
// if (settings != null && settings.isKeepInMemoryReferences())
// AVOID LAZY RESOLVING+SETTING OF RECORD
// return doc.rawField(OrientGraphUtils.CONNECTION_OUT);
// else
return doc.field(OrientGraphUtils.CONNECTION_OUT);
}

/**
Expand All @@ -147,11 +141,11 @@ public OIdentifiable getInVertex() {
if (doc == null)
return null;

// if (settings != null && settings.isKeepInMemoryReferences())
// AVOID LAZY RESOLVING+SETTING OF RECORD
// return doc.rawField(OrientGraphUtils.CONNECTION_IN);
// else
return doc.field(OrientGraphUtils.CONNECTION_IN);
// if (settings != null && settings.isKeepInMemoryReferences())
// AVOID LAZY RESOLVING+SETTING OF RECORD
// return doc.rawField(OrientGraphUtils.CONNECTION_IN);
// else
return doc.field(OrientGraphUtils.CONNECTION_IN);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class OrientEdgeIterator extends OLazyWrapperIterator<OrientEdge> {
private final String[] labels;

public OrientEdgeIterator(final OrientVertex iSourceVertex, final OrientVertex iTargetVertex,
final Object iMultiValue, final Iterator<?> iterator,
final OPair<Direction, String> connection, final String[] iLabels, final int iSize) {
final Object iMultiValue, final Iterator<?> iterator,
final OPair<Direction, String> connection, final String[] iLabels, final int iSize) {
super(iterator, iSize, iMultiValue);
this.sourceVertex = iSourceVertex;
this.targetVertex = iTargetVertex;
Expand Down Expand Up @@ -52,9 +52,9 @@ public OrientEdge createGraphElement(final Object iObject) {
if (!(record instanceof ODocument)) {
// SKIP IT
OLogManager.instance().warn(this,
"Found a record (%s) that is not an edge. Source vertex : %s, Target vertex : %s, Database : %s .", rec,
sourceVertex != null ? sourceVertex.id() : null, targetVertex != null ? targetVertex.id() : null,
record.getDatabase().getURL());
"Found a record (%s) that is not an edge. Source vertex : %s, Target vertex : %s, Database : %s .", rec,
sourceVertex != null ? sourceVertex.id() : null, targetVertex != null ? targetVertex.id() : null,
record.getDatabase().getURL());
return null;
}

Expand All @@ -80,13 +80,13 @@ public OrientEdge createGraphElement(final Object iObject) {

final OrientEdge edge;
if (immutableSchema.isVertexType()) {
// DIRECT VERTEX, CREATE DUMMY EDGE
// DIRECT VERTEX, CREATE DUMMY EDGE
if (connection.getKey() == Direction.OUT)
edge = new OrientEdge(this.sourceVertex.getGraph(), (OIdentifiable) this.sourceVertex.id(), rec.getIdentity(),
connection.getValue());
connection.getValue());
else
edge = new OrientEdge(this.sourceVertex.getGraph(), rec.getIdentity(), (OIdentifiable) this.sourceVertex.id(),
connection.getValue());
connection.getValue());
} else if (immutableSchema.isEdgeType()) {
edge = new OrientEdge(this.sourceVertex.getGraph(), value, connection.getValue());
} else
Expand All @@ -96,17 +96,20 @@ public OrientEdge createGraphElement(final Object iObject) {
}

public boolean filter(final OrientEdge edge) {
// return targetVertex == null || targetVertex.equals(edge.getVertex(connection.getKey().opposite()));
// throw new NotImplementedException();
//TODO simplify
// return targetVertex == null ||
// targetVertex.equals(edge.getVertex(connection.getKey().opposite()));
// throw new NotImplementedException();
// TODO simplify
if (targetVertex != null && !targetVertex.equals(edge.getVertex(connection.getKey().opposite())))
return false;
else
return true;
// if (targetVertex != null && !targetVertex.equals(iObject.getVertex(connection.getKey().opposite())))
// return false;
//
// return this.sourceVertex.settings.isUseVertexFieldsForEdgeLabels() || iObject.isLabeled(labels);
// if (targetVertex != null &&
// !targetVertex.equals(iObject.getVertex(connection.getKey().opposite())))
// return false;
//
// return this.sourceVertex.settings.isUseVertexFieldsForEdgeLabels() ||
// iObject.isLabeled(labels);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import com.orientechnologies.orient.core.metadata.schema.OImmutableClass;

public class OrientEdgeType extends OrientElementType {
// Keeping the name in Immutable class because i cannot do the other way around
// Keeping the name in Immutable class because i cannot do the other way
// around
public static final String CLASS_NAME = OImmutableClass.EDGE_CLASS_NAME;

public OrientEdgeType(final OrientGraph graph, final OClass delegate) {
Expand Down

0 comments on commit 97e0338

Please sign in to comment.