Class Database.Builder

java.lang.Object
org.eclipse.mosaic.lib.database.Database.Builder
Enclosing class:
Database

public static class Database.Builder extends Object
Builder class for simple generation for a new Database.
  • Constructor Details

  • Method Details

    • loadFromFile

      public static Database.Builder loadFromFile(File file)
      This method loads tries to load a database object from the given File, which should refer to a database-file. A SQLiteReader is used for the translation of the database to the Java-Object
      Parameters:
      file - the database-file
      Returns:
      the builder for easy cascading of methods
    • loadFromDatabase

      public Database.Builder loadFromDatabase(Database database)
      Overrides the database to be created with the input Database.
      Parameters:
      database - the Database-object, that shall be used as the database
      Returns:
      the builder for easy cascading
    • copyFromDatabase

      public Database.Builder copyFromDatabase(Database other)
      Copies all elements of the given Database into the current one.
      Parameters:
      other - the Database to copy into the existing one
      Returns:
      the builder for easy cascading
    • getIntermediateDatabase

      public Database getIntermediateDatabase()
      Deprecated.
      will be removed in future versions. It should not be required to have access to a Database which is being currently built.
      Returns the current state of the database, it is used to access by different classes, that add fields to this object, but need information already contained in the object.
      Returns:
      the current database
    • clearNetwork

      public Database.Builder clearNetwork()
      Resets network components of database.
      Returns:
      the builder for easy cascading
    • addProperty

      public Database.Builder addProperty(String key, String value)
      Adds a new property to the database. Adding a property whose key is already in the list will replace the previous value.
      Parameters:
      key - the key of the property
      value - the value of the property
      Returns:
      the builder for easy cascading
    • addNode

      public Database.Builder addNode(Node node)
      Deprecated.
      Adds a new Node to the database. Be aware, that node IDs have to be distinct! Adding a Node whose ID is already in the list will replace the previous Node.
      Parameters:
      node - Node to add.
      Returns:
      this builder for easy cascading
    • addNode

      public Node addNode(String nodeId, GeoPoint position)
      Adds a new Node to the database using an id and a position. This method will create a new Node, add it to the database and will return the created Node for further manipulation of it.
      Parameters:
      nodeId - a String representing a unique id for the Node
      position - the position of the Node
      Returns:
      the created Node for further manipulation
    • addNode

      public Node addNode(String nodeId, GeoPoint position, boolean isTrafficLight)
      Adds a new Node to the database using an id and a position. This method will create a new Node, add it to the database and will return the created Node for further manipulation of it. This overload of the method addNode(org.eclipse.mosaic.lib.database.road.Node) is used to add TrafficLightNode-Nodes to the database.
      Parameters:
      nodeId - a String representing a unique id for the Node
      position - the position of the Node
      isTrafficLight - boolean to determine if the node to be added is a TrafficLightNode
      Returns:
      the created Node for further manipulation
    • nodeExists

      public boolean nodeExists(String nodeId)
    • getNode

      public Node getNode(String nodeId)
    • getNodes

      public Collection<Node> getNodes()
    • addWay

      public Database.Builder addWay(Way way)
      Deprecated.
      Adds a new Way to the database. Be aware that adding a Way whose ID is already in the list will replace the previous Way. This method also makes sure, that the Nodes of the way know the way.
      Parameters:
      way - Way to add.
    • addWay

      public Way addWay(String id, String name, String type)
    • getWay

      public Way getWay(String wayId)
    • getWays

      public Collection<Way> getWays()
    • addConnection

      public Database.Builder addConnection(Connection connection)
      Deprecated.
      Adds a new Connection to the database. Be aware that adding a Connection whose ID is already in the list will replace the previous Connection. This method also makes sure, that dependent Nodes and Ways know the connection.
      Parameters:
      connection - Connection to add.
      Returns:
      the builder for easy cascading
    • addConnection

      public Connection addConnection(String connectionId, String wayId)
      Adds a new Connection to the database. Be aware that adding a Connection whose ID is already in the list will replace the previous Connection. This method also makes sure, that dependent Nodes and Ways know the connection.
      Parameters:
      connectionId - the id of the connection to be added
      wayId - the way id abstracted by the Connection
      Returns:
      the added Connection for further manipulation
    • getConnections

      public Collection<Connection> getConnections()
    • getConnection

      public Connection getConnection(String connectionId)
    • addNodeToWay

      public Database.Builder addNodeToWay(String wayId, String nodeId)
      This will add a Node to a Way, validating the input parameters against null.
      Parameters:
      wayId - the id of the Way to add the node to
      nodeId - the id of the Node to add to the way
      Returns:
      the builder for easy cascading
    • addNodeToConnection

      public Database.Builder addNodeToConnection(String connectionId, String nodeId)
      This will add a Node to a Connection, validating the input parameters against null.
      Parameters:
      connectionId - the id of the Connection to add the node to
      nodeId - the id of the Node to be added to the connection
      Returns:
      the builder for easy cascading
    • addRoundabout

      public Roundabout addRoundabout(String roundaboutId, List<Node> nodes)
      Adds a new Roundabout to the database.
      Parameters:
      roundaboutId - the id of the roundabout
      nodes - the nodes belonging to the roundabout
      Returns:
      the builder for easy cascading
    • addRestriction

      public Restriction addRestriction(String restrictionId, Restriction.Type type, String sourceWayId, String viaNodeId, String targetWayId)
      Adds a new Restriction to the database. This method will create a new Restriction object using the given parameters.
      Parameters:
      restrictionId - the id for the restriction
      type - the Restriction.Type of the restriction
      sourceWayId - start of the restriction
      viaNodeId - restriction will be via this node
      targetWayId - end of the restriction
      Returns:
      the Restriction object for further manipulation
    • addBuilding

      public Building addBuilding(@Nonnull String id, String name, double height, GeoPoint[] corners)
      Adds a new building by a given list of corners defining the corners of the building.
      Parameters:
      id - the id of the building
      name - the name of the building
      height - the height of the building
      corners - the list of geographical points describing the contour of the building
    • addRoute

      public Database.RouteBuilder addRoute(String routeId)
      Adds a new Route to the database. Be aware that adding a Route whose ID is already in the list will replace the previous Route. This method also returns the Database.RouteBuilder for further manipulation.
      Parameters:
      routeId - the id of the route to be added
    • addRoute

      public void addRoute(Route route)
      Deprecated.
      use addRoute instead
      Adds a new Route to the database. Be aware that adding a Route whose ID is already in the list will replace the previous Route.
      Parameters:
      route - Route to add.
    • getRoute

      public Route getRoute(String routeId)
    • setImportOrigin

      public void setImportOrigin(String value)
      Sets the import origin as a new property in the database. Adding a property whose key is already in the list will replace the previous value.
      Parameters:
      value - the value the import origin should be set to
    • build

      public Database build()
      This method cleans the database of unnecessary network elements and returns it.
      Returns:
      the build Database
    • build

      public Database build(boolean cleanupUnusedFields)
      This method allows to disable the cleaning of the database. This is mostly of importance for testing purposes.
      Returns:
      the build Database
    • cleanGraphs

      public void cleanGraphs()
      Cleans the database of detected graphs, used for importing purposes.
    • clearRoutes

      public void clearRoutes()
      This clears the list of routes. Should only be called when importing routes!
    • calculateIntersections

      public void calculateIntersections()
      Sets the "intersection" flag for all nodes, which have more than 2 neighboring nodes.
    • completeConnections

      public void completeConnections()
    • connectionExists

      public boolean connectionExists(String connectionId)