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.
PersistenciaAcademica (in package util) provides local file persistence that operates entirely independently of SQL Server. Whenever the application writes or loads data, it can serialise the five in-memory data structures — the course array, student BST, semester matrix, enrollment list, and request queue — to a set of tab-separated value (TSV) files on disk. This means that even when the database is unreachable, no work is lost between sessions: the application saves to disk on exit and reloads on startup without requiring a network round-trip.
Storage Location
All TSV files are written to a subdirectory of the current user’s home folder. The directory name is exposed as a public constant so that other utilities in theutil package can locate the same folder.
~/.proyecto_utp_aed_datos/. On Windows it resolves to C:\Users\<username>\.proyecto_utp_aed_datos\. The directory is created automatically by FileUtils.forceMkdir() the first time guardar() is called.
TSV Files
Four files are maintained inside the directory. Each line represents one record; columns are separated by a single tab character (\t).
| File | Columns (in order) | Description |
|---|---|---|
cursos.tsv | codigo, nombre, creditos, semestre | Course catalogue sourced from ArregloCursos |
estudiantes.tsv | carnet, nombre, carrera | Student registry sourced from ArbolEstudiantes (in-order traversal) |
matriculas.tsv | carnet, codigo_curso | Enrollment pairs sourced from ListaMatricula |
solicitudes.tsv | carnet, tipo, descripcion, fecha, atendida, fechaAtencion | Request queue (0/1 for atendida; ISO-8601 datetimes) |
Lines beginning with
# are treated as comments and skipped during loading.
Completely blank lines are also ignored, so you can add a header comment to
any TSV file without breaking the parser.guardar() — Saving All Structures
guardar() is a static method that accepts the six live data-structure references held by the application controller.
Create the directory
FileUtils.forceMkdir(directorioFile()) ensures ~/.proyecto_utp_aed_datos/
exists, creating it (and any missing parent directories) if necessary.Write cursos.tsv
Iterates
arregloCursos.obtenerCursos(). Each non-null Curso is serialised
as four tab-joined columns: codigo, nombre, creditos, semestre.Write estudiantes.tsv
Calls
arbolEstudiantes.inorden(estudiantes::add) to produce an in-order
(sorted by carnet) list, then serialises each Estudiante as three columns:
carnet, nombre, carrera.Write matriculas.tsv
Calls
listaMatricula.recorrer(matriculas::add) and serialises each
Matricula as two columns: estudiante.getCarnet(), curso.getCodigo().cargar() — Loading All Structures
cargar() is the mirror of guardar(). It receives the same six structure references and rehydrates them from disk.
Guard check
If
~/.proyecto_utp_aed_datos/ does not exist as a directory, cargar()
returns immediately without modifying any structure.Clear all structures
All six structures are emptied before any file is read:
limpiar() on each
collection, and Queue.poll() in a loop for colaSolicitudes. This prevents
duplicate records when cargar() is called more than once.Load cursos.tsv (first)
Each course is inserted into
arregloCursos, matrizSemestres, and
listaCursos. Courses must be loaded before enrollments because
listaMatricula lookups require a live Curso reference.Load estudiantes.tsv (second)
Each student is inserted into
arbolEstudiantes. Students must be loaded
before enrollments for the same reason.Load matriculas.tsv (third)
For each row,
arbolEstudiantes.buscar(carnet) and listaCursos.buscar(codigo)
are called. If either lookup returns null (orphaned reference), the
enrollment line is silently skipped. After all enrollments are loaded,
CuentasEstudiantes.registrarPorMatricula() is called for each enrolled
student to ensure their login credential file is up to date.TSV Escaping
Tab characters are the column delimiter, so any tab, carriage-return, or newline character found inside a field value is replaced with a single space before writing. This is handled by the privateesc() helper:
Strings.nullToEmpty() (Google Guava) converts null values to "" so that Joiner.useForNull("") and esc() together guarantee no NullPointerException can reach the file writer.
Datetime Format
Dates onSolicitud objects are serialised and deserialised using the ISO-8601 local datetime format provided by Java’s DateTimeFormatter.ISO_LOCAL_DATE_TIME (e.g. 2024-03-15T14:30:00). No timezone information is stored; all datetimes are treated as local.
Apache Commons IO & Google Guava
PersistenciaAcademica relies on two third-party libraries for all low-level I/O and string manipulation:
| Library | Usage |
|---|---|
Apache Commons IO FileUtils | readLines(file, charset), writeLines(file, charset, lines), forceMkdir(dir) — handles charset-aware file I/O without manual stream management |
Google Guava Joiner | Joiner.on('\t').useForNull("") — joins column values with a tab separator, safely substituting "" for any null field |
Google Guava Splitter | Splitter.on('\t').trimResults() — splits each line back into columns and trims surrounding whitespace |
Google Guava ImmutableList | Wraps the Splitter output so that p.get(index) is bounds-safe |
Relationship to SQL Server
PersistenciaAcademica and the DAO layer are complementary, not mutually exclusive. The typical application flow is:
- On startup —
cargar()rehydrates the in-memory structures from the TSV files (fast, no network required). - On each mutation — the relevant DAO method (
insertar,actualizar,eliminar) attempts to persist the change to SQL Server. - On shutdown / explicit save —
guardar()writes the current in-memory state back to the TSV files, capturing any changes made while offline.