@Override
 public Object generateRuleExpression(Rule rule) {
   return new BinaryGraphicExpression(
       null,
       generateStaticExpression(rule.getInputModel()),
       generateStaticExpression(rule.getResultModel()),
       new StringGraphicOperator("=>"),
       BinaryGraphicExpression.Orientation.HORIZONTAL,
       tower,
       false);
 }
  /**
   * Gets all the rules that are avaible for this project
   *
   * @param projectId
   * @return
   * @throws DatabaseException
   * @throws SQLException
   * @throws DatabaseValueNotFoundException
   */
  private ArrayList<Rule> getRules(int projectId)
      throws DatabaseException, SQLException, DatabaseValueNotFoundException {
    PreparedStatement statement =
        this.conApex.prepareStatement("SELECT * FROM BUSINESSRULE WHERE BRG_PROJECTID=?");
    ArrayList<Rule> rules = new ArrayList<Rule>();
    String template = null;
    log.out(Level.INFORMATIVE, "getRules", "Getting rules for project");
    statement.setInt(1, projectId);
    ResultSet result = statement.executeQuery();

    while (result.next()) {
      log.out(Level.INFORMATIVE, "getRules", "Got trigger type");
      PreparedStatement templateStmt =
          this.conApex.prepareStatement("SELECT * FROM TEMPLATE WHERE ID=?");
      templateStmt.setInt(1, result.getInt("TEMPLATEID"));

      ResultSet templateRs = templateStmt.executeQuery();
      while (templateRs.next()) {
        template = templateRs.getString("TEMPLATE");
      }
      log.out(Level.INFORMATIVE, "getRules", "Got template string");

      Rule rule =
          new Rule(
              result.getString("NAME"),
              new Operator(result.getString("OPERATOR")),
              result.getString("TRIGGER_EVENT"),
              result.getString("ERROR_MESSAGE"),
              new RuleType(
                  result.getString("TRIGGER_CODE"),
                  result.getString("EXAMPLE"),
                  result.getString("DESCRIPTION")),
              template);
      rule.setId(result.getInt("ID"));
      rules.add(rule);
    }
    if (!rules.isEmpty()) {
      statement.close();
      return rules;
    } else {
      statement.close();
      log.out(Level.ERROR, "getRules", "No rules found for " + projectId);
      return null;
    }
  }
  /**
   * Gives Project object from given identifier
   *
   * @param projectId
   * @return
   * @throws DatabaseException
   * @throws SQLException
   * @throws DatabaseValueNotFoundException
   */
  public Project getProject(int projectId)
      throws DatabaseException, SQLException, DatabaseValueNotFoundException {
    PreparedStatement statement =
        this.conApex.prepareStatement(
            "SELECT * FROM BRG_PROJECT WHERE ID=?",
            ResultSet.TYPE_SCROLL_INSENSITIVE,
            ResultSet.CONCUR_READ_ONLY);

    statement.setInt(1, projectId);
    ResultSet result = statement.executeQuery();
    ArrayList<Rule> rules = getRules(projectId);

    while (result.next()) {
      Project tmpProject =
          new Project(
              result.getInt("ID"),
              result.getString("NAME"),
              result.getString("TARGET_DATABASE_DESC"),
              new DbConfiguration(
                  result.getString("TARGET_DATABASE_IP"),
                  result.getString("TARGET_DATABASE_USERNAME"),
                  result.getString("TARGET_DATABASE_PASSWORD"),
                  result.getString("TARGET_DATABASE_DATABASE"),
                  result.getString("TARGET_DATABASE_PORT")));

      if (rules != null) {
        for (Rule rule : rules) {
          ArrayList<Column> collumns = getColumns(rule.getId());
          if (collumns != null) {
            for (Column column : collumns) {
              rule.addColumns(column);
            }
          }
          ArrayList<Value> values = getValues(rule.getId());
          if (values != null) {
            for (Value value : values) {
              rule.addValues(value);
            }
          }
          ArrayList<Table> tables = getTables(rule.getId());
          if (tables != null) {
            for (Table table : tables) {
              rule.addTables(table);
            }
          }
          tmpProject.addRule(rule);
        }
      }
      statement.close();
      return tmpProject;
    }
    statement.close();
    throw new DatabaseValueNotFoundException("Project " + projectId + " not found");
  }