Actividad 11
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-25">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1 @@
|
||||
/bin/
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Ficheros_11</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1792677715655</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
@@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=25
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=25
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=25
|
||||
@@ -0,0 +1,2 @@
|
||||
# Ruta del fichero XML de información del IES
|
||||
ies.xml.ruta=C:/Users/aleja/Desktop/2ºDam/Eclipse 2º DAM/Ficheros_11/config/informacion-IES.xml
|
||||
@@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<instituto nombre="IES Virgen de la Paloma" tipo="FP">
|
||||
<ciclo codigo="IFC05" nivel="CFGS" familia="IFC" numero_horas="2000">
|
||||
<nombre_corto>DAM</nombre_corto>
|
||||
<nombre_largo>Técnico Superior en Desarrollo de Aplicaciones Multiplataforma</nombre_largo>
|
||||
<curso numero="1">
|
||||
<modulo id="11" ref="0186">
|
||||
<titulo> Bases de datos</titulo>
|
||||
<numerohoras>205</numerohoras>
|
||||
</modulo>
|
||||
<modulo id="12" ref="0188">
|
||||
<numerohoras>90</numerohoras>
|
||||
<titulo>Entornos de desarrollo </titulo>
|
||||
</modulo>
|
||||
<modulo id="13" ref="0194">
|
||||
<numerohoras>90</numerohoras>
|
||||
<titulo>Formación y orientación laboral</titulo>
|
||||
</modulo>
|
||||
<modulo id="14" ref="0190">
|
||||
<numerohoras>140</numerohoras>
|
||||
<titulo>Lenguaje de marcas y sistemas de gestión de información</titulo>
|
||||
</modulo>
|
||||
<modulo id="14" ref="0189">
|
||||
<numerohoras>270</numerohoras>
|
||||
<titulo>Programación</titulo>
|
||||
</modulo>
|
||||
<modulo id="15" ref="0191">
|
||||
<numerohoras>205</numerohoras>
|
||||
<titulo>Sistemas informáticos</titulo>
|
||||
</modulo>
|
||||
</curso>
|
||||
<curso numero="2">
|
||||
<modulo id="21" ref="0286">
|
||||
<titulo>Acceso a Datos</titulo>
|
||||
<numerohoras>120</numerohoras>
|
||||
</modulo>
|
||||
<modulo id="22" ref="0288">
|
||||
<numerohoras>120</numerohoras>
|
||||
<titulo>Diseño de interfaces</titulo>
|
||||
</modulo>
|
||||
<modulo id="23" ref="0294">
|
||||
<numerohoras>65</numerohoras>
|
||||
<titulo>Empresa e iniciativa emprendedora </titulo>
|
||||
</modulo>
|
||||
<modulo id="24" ref="0290">
|
||||
<numerohoras>80</numerohoras>
|
||||
<titulo>Programación de servicios y procesos</titulo>
|
||||
</modulo>
|
||||
<modulo id="25" ref="0289">
|
||||
<numerohoras>80</numerohoras>
|
||||
<titulo>Programación multimedia y dispositivos móviles</titulo>
|
||||
</modulo>
|
||||
<modulo id="26" ref="0291">
|
||||
<numerohoras>40</numerohoras>
|
||||
<titulo>Inglés técnico para grado superior</titulo>
|
||||
</modulo>
|
||||
</curso>
|
||||
</ciclo>
|
||||
<ciclo codigo="IFC06" nivel="CFGS" familia="IFC" numero_horas="2000">
|
||||
<nombre_corto>DAW</nombre_corto>
|
||||
<nombre_largo>Técnico Superior en Desarrollo de Aplicaciones Web</nombre_largo>
|
||||
<curso numero="1">
|
||||
<modulo id="31" ref="0186">
|
||||
<titulo> Bases de datos</titulo>
|
||||
<numerohoras>205</numerohoras>
|
||||
</modulo>
|
||||
<modulo id="32" ref="0188">
|
||||
<numerohoras>90</numerohoras>
|
||||
<titulo>Entornos de desarrollo </titulo>
|
||||
</modulo>
|
||||
<modulo id="33" ref="0194">
|
||||
<numerohoras>90</numerohoras>
|
||||
<titulo>Formación y orientación laboral</titulo>
|
||||
</modulo>
|
||||
<modulo id="34" ref="0190">
|
||||
<numerohoras>140</numerohoras>
|
||||
<titulo>Lenguaje de marcas y sistemas de gestión de información</titulo>
|
||||
</modulo>
|
||||
<modulo id="34" ref="0189">
|
||||
<numerohoras>270</numerohoras>
|
||||
<titulo>Programación</titulo>
|
||||
</modulo>
|
||||
<modulo id="35" ref="0191">
|
||||
<numerohoras>205</numerohoras>
|
||||
<titulo>Sistemas informáticos</titulo>
|
||||
</modulo>
|
||||
</curso>
|
||||
<curso numero="2">
|
||||
<modulo id="41" ref="0286">
|
||||
<titulo>Desarrollo web en entorno cliente</titulo>
|
||||
<numerohoras>115</numerohoras>
|
||||
</modulo>
|
||||
<modulo id="42" ref="0288">
|
||||
<numerohoras>180</numerohoras>
|
||||
<titulo>Desarrollo web en entorno servidor</titulo>
|
||||
</modulo>
|
||||
<modulo id="43" ref="0294">
|
||||
<numerohoras>85</numerohoras>
|
||||
<titulo>Despliegue de aplicaciones web</titulo>
|
||||
</modulo>
|
||||
<modulo id="44" ref="0290">
|
||||
<numerohoras>115</numerohoras>
|
||||
<titulo>Diseño de interfaces web </titulo>
|
||||
</modulo>
|
||||
<modulo id="45" ref="0289">
|
||||
<numerohoras>30</numerohoras>
|
||||
<titulo>Proyecto de desarrollo de aplicaciones web </titulo>
|
||||
</modulo>
|
||||
<modulo id="46" ref="0291">
|
||||
<numerohoras>40</numerohoras>
|
||||
<titulo>Inglés técnico para grado superior</titulo>
|
||||
</modulo>
|
||||
<modulo id="23" ref="0294">
|
||||
<numerohoras>65</numerohoras>
|
||||
<titulo>Empresa e iniciativa emprendedora </titulo>
|
||||
</modulo>
|
||||
</curso>
|
||||
</ciclo>
|
||||
</instituto>
|
||||
@@ -0,0 +1,151 @@
|
||||
package org.palomafp.aadd.aez;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Scanner;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.palomafp.aadd.aez.config.GestorConfiguracion;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
public class AppPrincipal {
|
||||
public static void main(String[] args) {
|
||||
AppPrincipal app = new AppPrincipal();
|
||||
|
||||
// Se carga el árbol DOM que más tarde se usará para las consultas.
|
||||
Document documentoDOM = app.cargarArbolDOMFicheroXML();
|
||||
|
||||
Scanner sc = new Scanner(System.in);
|
||||
int opcion;
|
||||
|
||||
do {
|
||||
System.out.println("Elige una opción:");
|
||||
System.out.println("1. Buscar información instituto");
|
||||
System.out.println("2. Buscar información ciclos");
|
||||
System.out.println("3. Buscar información módulos - filtro 1");
|
||||
System.out.println("4. Buscar información módulos - filtro 2");
|
||||
|
||||
opcion = sc.nextInt();
|
||||
|
||||
if (opcion < 1 || opcion > 4) {
|
||||
System.out.println("Opción no válida. Inténtalo de nuevo.");
|
||||
}
|
||||
switch (opcion) {
|
||||
case 1:
|
||||
app.buscarInformacionInstituto(documentoDOM);
|
||||
break;
|
||||
case 2:
|
||||
app.buscarInformacionCiclos(documentoDOM);
|
||||
break;
|
||||
case 3:
|
||||
app.buscarInformacionModulos(documentoDOM);
|
||||
break;
|
||||
case 4:
|
||||
app.buscarInformacionModulosCiclo(documentoDOM);
|
||||
break;
|
||||
}
|
||||
|
||||
} while (opcion < 1 || opcion > 4);
|
||||
|
||||
System.out.println("Has elegido la opción " + opcion);
|
||||
|
||||
sc.close();
|
||||
}
|
||||
|
||||
private void buscarInformacionInstituto(Document docDOM) {
|
||||
Element elementoInstituto = (Element) docDOM.getElementsByTagName("instituto").item(0);
|
||||
|
||||
String nombre = elementoInstituto.getAttribute("nombre");
|
||||
String tipo = elementoInstituto.getAttribute("tipo");
|
||||
|
||||
System.out.println("Instituto - Nombre: " + nombre + " - Tipo: " + tipo);
|
||||
|
||||
}
|
||||
|
||||
private void buscarInformacionCiclos(Document docDOM) {
|
||||
NodeList nodosCiclo = docDOM.getElementsByTagName("ciclo");
|
||||
for (int i = 0; i < nodosCiclo.getLength(); i++) {
|
||||
Element elementoCiclo = (Element) nodosCiclo.item(i);
|
||||
|
||||
String codigo = elementoCiclo.getAttribute("codigo");
|
||||
String nombre = elementoCiclo.getElementsByTagName("nombre_corto").item(0).getTextContent();
|
||||
|
||||
System.out.println("Ciclo - Nombre: " + nombre + " - Código: " + codigo);
|
||||
}
|
||||
}
|
||||
|
||||
private void buscarInformacionModulos(Document docDOM) {
|
||||
|
||||
NodeList nodosModulo = docDOM.getElementsByTagName("modulo");
|
||||
for (int i = 0; i < nodosModulo.getLength(); i++) {
|
||||
Element elementoModulo = (Element) nodosModulo.item(i);
|
||||
|
||||
String identificador = elementoModulo.getAttribute("id");
|
||||
String referencia = elementoModulo.getAttribute("ref");
|
||||
String titulo = elementoModulo.getElementsByTagName("titulo").item(0).getTextContent();
|
||||
String numerohoras = elementoModulo.getElementsByTagName("numerohoras").item(0).getTextContent();
|
||||
|
||||
if (titulo != null && titulo.trim().startsWith("Programa")) {
|
||||
|
||||
System.out.println("Módulo - Título: " + titulo + " - Identificador: " + identificador
|
||||
+ " - Referencia: " + referencia + " - Número horas: " + numerohoras);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void buscarInformacionModulosCiclo(Document docDOM) {
|
||||
NodeList nodosModulo = docDOM.getElementsByTagName("modulo");
|
||||
for (int i = 0; i < nodosModulo.getLength(); i++) {
|
||||
Element elementoModulo = (Element) nodosModulo.item(i);
|
||||
|
||||
// Obtener el nodo padre del módulo --> el nodo curso
|
||||
Element elementoCurso = (Element) elementoModulo.getParentNode();
|
||||
String numero = elementoCurso.getAttribute("numero");
|
||||
|
||||
// Saltar los módulos que no pertenecen al curso 1
|
||||
if (numero == null || !"1".equals(numero)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String titulo = elementoModulo.getElementsByTagName("titulo").item(0).getTextContent().trim();
|
||||
|
||||
if (titulo != null && titulo.trim().startsWith("Programa")) {
|
||||
|
||||
String identificador = elementoModulo.getAttribute("id");
|
||||
String referencia = elementoModulo.getAttribute("ref");
|
||||
String numerohoras = elementoModulo.getElementsByTagName("numerohoras").item(0).getTextContent();
|
||||
|
||||
System.out.println("Módulo - Título: " + titulo + " - Identificador: " + identificador
|
||||
+ " - Referencia: " + referencia + " - Número horas: " + numerohoras);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Document cargarArbolDOMFicheroXML() {
|
||||
Document document = null;
|
||||
|
||||
try {
|
||||
// 1. Crear la fábrica
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
|
||||
// 2. Crear el parser que se usará para obtener el árbol DOM
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
|
||||
// 3. Leer el fichero XML y lo parseamos para obtener el árbol DOM
|
||||
File fichero = new File(GestorConfiguracion.getRutaFicheroIES());
|
||||
document = builder.parse(fichero);
|
||||
|
||||
// 4. Obtener el documento raíz normalizado
|
||||
document.getDocumentElement().normalize();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return document;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.palomafp.aadd.aez.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public class GestorConfiguracion {
|
||||
private static final String RUTA_FICHERO_CONFIGURACION = "application.properties";
|
||||
private static final Properties PROPIEDADES_CONFIGURACION = new Properties();
|
||||
|
||||
// Constructor privado: de esta manera conseguimos que esta clase no se puede
|
||||
// instanciar.
|
||||
private GestorConfiguracion() {
|
||||
}
|
||||
|
||||
// Este bloque se ejecuta una sola vez, cuando se carga la clase
|
||||
// GestorConfiguracion
|
||||
static {
|
||||
try (InputStream inputStream = GestorConfiguracion.class.getClassLoader().getResourceAsStream(RUTA_FICHERO_CONFIGURACION);)
|
||||
{
|
||||
|
||||
if (inputStream == null) {
|
||||
throw new IOException(
|
||||
"No se encuentra "+ RUTA_FICHERO_CONFIGURACION + " en el classpath");
|
||||
}
|
||||
PROPIEDADES_CONFIGURACION.load(inputStream);
|
||||
// System.out.println(PROPIEDADES_CONFIGURACION);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("No se ha podido cargar el fichero de configuración", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getRutaFicheroIES() {
|
||||
return PROPIEDADES_CONFIGURACION.getProperty("ies.ruta.fichero");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user