Пример #1
0
  /** call as linkEntity(con, UserEntity, user_id, X, Y) to link an entity to a user */
  public LinkedEntity linkEntity(Connection con, String linkTable, String targetField, int targetId)
      throws SQLException {
    Statement st = null;

    EntityId existing = fetchEntityId(con, linkTable.replace("Entity", ""), targetId);

    if (existing != null) {
      return LinkedEntity.builder().linkId(targetId).entityId(existing).build();
    }

    EntityId eid = allocateEntityId(con);

    try {
      st = con.createStatement();
      st.executeUpdate(
          "INSERT INTO "
              + linkTable
              + " ("
              + linkTable.toLowerCase()
              + "_entity_id, "
              + linkTable.toLowerCase()
              + "_"
              + targetField
              + ") VALUES ("
              + eid
              + ", "
              + targetId
              + ")");
    } finally {
      cleanup(null, st, null);
    }

    return LinkedEntity.builder().linkId(targetId).entityId(eid).build();
  }
Пример #2
0
  @Override
  public void draw(Graphics2D oG) {
    // TODO Auto-generated method stub
    Entity oBlock = (Entity) oBlockHead.getNext();

    while (oBlock != null) {
      oBlock = (Entity) oBlock.getNext();
      oBlock.draw(oG);
    }
  }