Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/kenri89/PROYECTO_UTP_AED_1_1/llms.txt

Use this file to discover all available pages before exploring further.

The Student Management panel (PanelEstudiantes) is accessible to users with the Administrator (admin) and Secretary (secretaria) roles. It provides a full CRUD interface for maintaining the student registry, backed by a Binary Search Tree (BST) keyed on the carnet field. Every mutation is also persisted to the SQL Server database through EstudianteDAO, and the BST is re-hydrated from the database on each load to keep the in-memory structure in sync.

The Estudiante Data Model

Each student record contains three fields. The carnet is the primary key used as the BST sort key; no two students may share the same value.
FieldTypeDescriptionConstraint
carnetStringUnique student identifier — acts as the BST key.Non-null (Guava checkNotNull)
nombreStringStudent’s full name.Non-null
carreraStringDegree programme (e.g. DESARROLLO DE SISTEMAS).Non-null
The constructor enforces all three constraints via Google Guava Preconditions.checkNotNull:
public Estudiante(String carnet, String nombre, String carrera) {
    this.carnet  = checkNotNull(carnet,  "El carnet no puede ser nulo");
    this.nombre  = checkNotNull(nombre,  "El nombre no puede ser nulo");
    this.carrera = checkNotNull(carrera, "La carrera no puede ser nula");
}

CRUD Operations

1

Register a New Student

Fill in the Carnet, Nombre, and select a Carrera from the combo-box, then click Registrar.The panel calls EstudianteDAO.insertar(carnet, nombre, carrera). On success, cargarDatosDesdeSQL() reloads the BST and refreshes the table. If any field is empty the operation is blocked with a dialog before the DAO is ever reached.
// Validation guard in PanelEstudiantes.registrarEstudiante()
if (carnet.isEmpty() || nombre.isEmpty() || carrera == null) {
    JOptionPane.showMessageDialog(this, "Completa todos los campos.");
    return;
}
dao.EstudianteDAO estudianteDAO = new dao.EstudianteDAO();
boolean exitoSQL = estudianteDAO.insertar(carnet, nombre, carrera);
2

Search by Carnet

Click Buscar por carnet and enter the carnet in the prompt dialog. The panel delegates to ArbolEstudiantes.buscar(carnet), which performs a BST lookup in O(log n) average time by comparing the target against each node’s carnet string and traversing left or right accordingly.
Estudiante encontrado = arbol.buscar(carnet.trim());
The result is displayed in a message dialog showing the student’s name and programme.
3

Update a Student

Right-click any row in the table and choose Actualizar from the context menu. The row’s data is loaded into the form fields. Edit Nombre and/or Carrera (the carnet is pre-populated and read-only at this point), then click Actualizar.The panel calls EstudianteDAO.actualizar(carnetSeleccionado, nuevoNombre, nuevaCarrera) and refreshes the BST from SQL on success. The in-memory BST is also updated via ArbolEstudiantes.actualizar(), which finds the node by carnet and calls the setters directly — no removal and re-insertion needed.
public boolean actualizar(String carnet, String nuevoNombre, String nuevaCarrera) {
    Estudiante est = buscar(carnet);
    if (est != null) {
        est.setNombre(nuevoNombre);
        est.setCarrera(nuevaCarrera);
        return true;
    }
    return false;
}
4

Delete a Student

Right-click a row and choose Eliminar. A confirmation dialog is shown. On approval, EstudianteDAO.eliminar(carnet) removes the record from the database, and cargarDatosDesdeSQL() rebuilds the BST.The BST deletion itself promotes the in-order successor (leftmost node in the right subtree) when the removed node has two children, preserving the BST invariant:
} else {
    // Node has two children — find in-order successor
    actual.estudiante = encontrarMinimo(actual.derecha);
    actual.derecha = eliminarRec(actual.derecha, actual.estudiante.getCarnet());
}

In-Order Traversal

The method ArbolEstudiantes.inorden(Consumer<Estudiante>) performs a left-root-right recursive traversal, visiting every node in ascending carnet order. PanelEstudiantes uses it to populate the table view after every database reload:
private void cargarTabla() {
    modelo.setRowCount(0);
    arbol.inorden(est -> modelo.addRow(new Object[]{
        est.getCarnet(), est.getNombre(), est.getCarrera()
    }));
}
The same traversal is used by MenuPrincipal to populate the carnet combo-box in the enrollment panel, and by ExportadorExcel to collect the ordered student list for export.

Excel Export

Click Exportar a Excel in the toolbar below the table. A file-chooser dialog opens, defaulting to estudiantes.xls. The export is handled by the static utility:
ExportadorExcel.exportarEstudiantes(arbol, archivo);
Internally, exportarEstudiantes calls arbol.inorden(estudiantes::add) to collect all students in carnet order, then writes them to an HSSFWorkbook (Apache POI .xls format) with three columns:
Column AColumn BColumn C
CarnetNombreCarrera
The header row is styled with a royal-blue background and bold white text. All columns are auto-sized.

Full Usage Example

// Build and populate the BST
ArbolEstudiantes arbol = new ArbolEstudiantes();
arbol.insertar(new Estudiante("2024001", "María López", "DESARROLLO DE SISTEMAS"));
arbol.insertar(new Estudiante("2023050", "Pedro Ramírez", "CONTABILIDAD"));

// BST lookup — O(log n) average
Estudiante e = arbol.buscar("2024001");

// In-place update (no re-insertion)
arbol.actualizar("2024001", "María López Ruiz", "DESARROLLO DE SISTEMAS");

// In-order traversal — ascending carnet order
arbol.inorden(est -> System.out.println(est.getNombre()));

// BST deletion with in-order successor promotion
arbol.eliminar("2024001");
The carnet field is compared using String.compareTo(), so lexicographic ordering applies. Carnets that start with a higher digit (e.g. "2024...") sort after those that start with a lower digit (e.g. "2023...").
If EstudianteDAO.insertar() returns false (e.g. a duplicate carnet violates the database primary key), no student object is added to the BST. Always verify the dialog confirms success before assuming the record was stored.

Build docs developers (and LLMs) love