Skip to content

Commit

Permalink
Adapt to new API files
Browse files Browse the repository at this point in the history
  • Loading branch information
gartens committed Oct 4, 2024
1 parent 3c0528c commit 9b5af76
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 62 deletions.
16 changes: 1 addition & 15 deletions src/main/java/org/polypheny/jdbc/multimodel/GraphResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
import org.polypheny.jdbc.PrismInterfaceErrors;
import org.polypheny.jdbc.PrismInterfaceServiceException;
import org.polypheny.jdbc.properties.PropertyUtils;
import org.polypheny.jdbc.types.PolyEdge;
import org.polypheny.jdbc.types.PolyGraphElement;
import org.polypheny.jdbc.types.PolyNode;
import org.polypheny.jdbc.types.PolyPath;
import org.polypheny.prism.Frame;
import org.polypheny.prism.Frame.ResultCase;
import org.polypheny.prism.GraphFrame;
Expand All @@ -50,17 +47,7 @@ public GraphResult( Frame frame, PolyStatement polyStatement ) {


private void addGraphElements( GraphFrame graphFrame ) {
if ( graphFrame.getNodesCount() > 0 ) {
graphFrame.getNodesList().forEach( n -> elements.add( new PolyNode( n ) ) );
return;
}
if ( graphFrame.getEdgesCount() > 0 ) {
graphFrame.getEdgesList().forEach( n -> elements.add( new PolyEdge( n ) ) );
return;
}
if ( graphFrame.getPathsCount() > 0 ) {
graphFrame.getPathsList().forEach( n -> elements.add( new PolyPath( n ) ) );
}
graphFrame.getElementList().forEach( n -> elements.add( PolyGraphElement.of( n ) ) );
}


Expand Down Expand Up @@ -126,5 +113,4 @@ public PolyGraphElement next() {

}


}
16 changes: 5 additions & 11 deletions src/main/java/org/polypheny/jdbc/types/PolyEdge.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@

import lombok.Getter;
import org.polypheny.prism.ProtoEdge;
import org.polypheny.prism.ProtoValue.ValueCase;

@Getter
public class PolyEdge extends PolyGraphElement {

private final String source;
private final String target;
private final String left;
private final String right;
private final EdgeDirection direction;


Expand All @@ -33,14 +32,9 @@ public PolyEdge( ProtoEdge protoEdge ) {
this.id = protoEdge.getId();
this.name = protoEdge.getName();
this.labels = protoEdge.getLabelsList();
protoEdge.getPropertiesList().stream()
.filter( e -> e.getKey().getValueCase() == ValueCase.STRING )
.forEach( p -> put(
p.getKey().getString().getString(),
new TypedValue( p.getValue() )
) );
this.source = protoEdge.getSource();
this.target = protoEdge.getTarget();
protoEdge.getPropertiesMap().forEach( ( k, v ) -> put( k, new TypedValue( v ) ) );
this.left = protoEdge.getSource();
this.right = protoEdge.getTarget();
this.direction = EdgeDirection.valueOf( protoEdge.getDirection().name() );
}

Expand Down
14 changes: 13 additions & 1 deletion src/main/java/org/polypheny/jdbc/types/PolyGraphElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
import lombok.Getter;
import org.polypheny.jdbc.PrismInterfaceErrors;
import org.polypheny.jdbc.PrismInterfaceServiceException;
import org.polypheny.prism.GraphElement;

@Getter
public class PolyGraphElement extends HashMap<String, TypedValue> {
public abstract class PolyGraphElement extends HashMap<String, TypedValue> {

protected String id;
protected String name;
Expand All @@ -39,4 +40,15 @@ public <T> T unwrap( Class<T> aClass ) throws PrismInterfaceServiceException {
}


public static PolyGraphElement of( GraphElement element ) {
switch ( element.getElementCase() ) {
case NODE:
return new PolyNode( element.getNode() );
case EDGE:
return new PolyEdge( element.getEdge() );
default:
throw new RuntimeException( "Unknown graph element of type " + element.getElementCase() );
}
}

}
7 changes: 1 addition & 6 deletions src/main/java/org/polypheny/jdbc/types/PolyNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ public PolyNode( ProtoNode protoNode ) {
this.id = protoNode.getId();
this.name = protoNode.getName();
this.labels = protoNode.getLabelsList();
protoNode.getPropertiesList().stream()
.filter( e -> e.getKey().getValueCase() == ValueCase.STRING )
.forEach( p -> put(
p.getKey().getString().getString(),
new TypedValue( p.getValue() )
) );
protoNode.getPropertiesMap().forEach( ( k, v ) -> put( k, new TypedValue( v ) ) );
}

}
29 changes: 0 additions & 29 deletions src/main/java/org/polypheny/jdbc/types/PolyPath.java

This file was deleted.

0 comments on commit 9b5af76

Please sign in to comment.