bayofmany / peapod

A new object-graph-wrapper for the Tinkerpop 3 graph stack.
Apache License 2.0
40 stars 8 forks source link

Compilation errors in generated classes when using Framed Edges #7

Closed markeastwood82 closed 8 years ago

markeastwood82 commented 8 years ago

When peapod generates the Impl classes for my project, the classes contain compilation errors. The root of the compilation problems exists in the class defined to represent an edge. When not framing edges, the classes come out ok.

The offending class is

import peapod.annotations.Edge;
import peapod.annotations.In;
import peapod.annotations.Out;

@Edge
public abstract class Uses {

    public abstract String getRole();
    public abstract void setRole(String role);

    @Out
    public abstract ConfigurationData getUses();
    public abstract void setUses(ConfigurationData uses);

    @In
    public abstract ConfigurationData getUsedBy();
    public abstract void setUsedBy(ConfigurationData usedBy);

}

for the sake of continuity, here is the ConfigurationData class

import java.util.List;

import peapod.annotations.Edge;
import peapod.annotations.In;
import peapod.annotations.Out;
import peapod.annotations.Vertex;

@Vertex
public abstract class ConfigurationData {

    @Out @Edge("configures")
    public abstract EntityData getEntity();
    public abstract void setEntity(EntityData entity);

    @Out
    public abstract List<Uses> getUses();
    public abstract Uses addUses();
    public abstract Uses removeUses();

    @In
    public abstract List<Uses> getUsedBy();
}

The generated Uses$Impl class has the following errors:

FramedVertex cannot be resolved to a type

Direction cannot be resolved to a type

Further, the generated setUses() and setUsedBy() methods both reference an undefined field v

The POM file I am using is as follows

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>au.gov.defence.dst.cewd</groupId>
  <artifactId>jats.peapod</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
        <executions>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.8.2</version>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
        <groupId>org.bayofmany.peapod</groupId>
        <artifactId>peapod</artifactId>
        <version>0.2.2</version>
    </dependency>
    <dependency>
        <groupId>com.thinkaurelius.titan</groupId>
        <artifactId>titan-core</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.thinkaurelius.titan</groupId>
        <artifactId>titan-cassandra</artifactId>
        <version>1.0.0</version>
    </dependency>
  </dependencies>
</project>

And for completeness, the generated Uses$Impl class

import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Element;
import peapod.FramedEdge;
import peapod.FramedElement;
import peapod.FramedGraph;
import peapod.internal.runtime.Framer;
import peapod.internal.runtime.IFramer;

@SuppressWarnings("unused")
public final class Uses$Impl extends Uses
    implements FramedEdge {

  private FramedGraph graph;
  private Edge e;
  public Uses$Impl(Edge e, FramedGraph graph) {
    this.e  = e;
    this.graph = graph;
  }
  public FramedGraph graph() {
    return graph;
  }
  public Element element() {
    return e;
  }
  public String getRole() {
    return e.<String>property("role").orElse(null);
  }
  public void setRole(String role) {
    if (role == null) {
      e.property("role").remove();
    } else {
      e.property("role", role);
    }
  }
  public ConfigurationData getUses() {
    // edge-getter-vertex
    return graph().frame(e.outVertex(), ConfigurationData.class);
  }
  public void setUses(ConfigurationData uses) {
    // vertex-setter-vertex
    v.edges(Direction.OUT, "uses").forEachRemaining(e -> e.remove());
    if (uses != null) {
      v.addEdge("uses", ((FramedVertex)uses).vertex());
    }
  }
  public ConfigurationData getUsedBy() {
    // edge-getter-vertex
    return graph().frame(e.inVertex(), ConfigurationData.class);
  }
  public void setUsedBy(ConfigurationData usedBy) {
    // vertex-setter-vertex
    v.edges(Direction.OUT, "usedBy").forEachRemaining(e -> e.remove());
    if (usedBy != null) {
      v.addEdge("usedBy", ((FramedVertex)usedBy).vertex());
    }
  }
  public int hashCode() {
    return e.hashCode();
  }

  public boolean equals(Object other) {
    return (other instanceof FramedElement) && e.equals(((FramedElement) other).element());
  }

  public String toString() {
    return e.label() + "[" + e.id() + "]";
  }

  @Framer
  public static final class UsesFramer
      implements IFramer<Edge, Uses> {

    public Class<Edge> type() {
      return Edge.class;
    }

    public Class<Uses> frameClass() {
      return Uses.class;
    }

    public String label() {
      return "uses";
    }

    public Uses frame(Edge e, FramedGraph graph) {
      return new Uses$Impl(e, graph);
    }

    public Uses frameNew(Edge e, FramedGraph graph) {
      return frame(e, graph);
    }
  }
}