Skip to content

Commit 5c1ec12

Browse files
authored
Merge pull request #28 from alb3rtov/develop
Generación de release v0.1.0
2 parents 755bc71 + 6be263d commit 5c1ec12

22 files changed

+1409
-49
lines changed

.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>BC05-ISO2</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
</buildSpec>
9+
<natures>
10+
</natures>
11+
</projectDescription>

GPEI/enfermedades/.classpath

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,28 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<classpath>
3-
<classpathentry kind="src" output="target/classes" path="src/main/java">
4-
<attributes>
5-
<attribute name="optional" value="true"/>
6-
<attribute name="maven.pomderived" value="true"/>
7-
</attributes>
8-
</classpathentry>
9-
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10-
<attributes>
11-
<attribute name="maven.pomderived" value="true"/>
12-
</attributes>
13-
</classpathentry>
14-
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
15-
<attributes>
16-
<attribute name="optional" value="true"/>
17-
<attribute name="maven.pomderived" value="true"/>
18-
<attribute name="test" value="true"/>
19-
</attributes>
20-
</classpathentry>
21-
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
22-
<attributes>
23-
<attribute name="maven.pomderived" value="true"/>
24-
<attribute name="test" value="true"/>
25-
</attributes>
26-
</classpathentry>
27-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
28-
<attributes>
29-
<attribute name="maven.pomderived" value="true"/>
30-
</attributes>
31-
</classpathentry>
32-
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
33-
<attributes>
34-
<attribute name="maven.pomderived" value="true"/>
35-
</attributes>
36-
</classpathentry>
37-
<classpathentry kind="output" path="target/classes"/>
38-
</classpath>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
10+
<attributes>
11+
<attribute name="optional" value="true"/>
12+
<attribute name="maven.pomderived" value="true"/>
13+
<attribute name="test" value="true"/>
14+
</attributes>
15+
</classpathentry>
16+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
17+
<attributes>
18+
<attribute name="maven.pomderived" value="true"/>
19+
</attributes>
20+
</classpathentry>
21+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
22+
<attributes>
23+
<attribute name="maven.pomderived" value="true"/>
24+
</attributes>
25+
</classpathentry>
26+
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
27+
<classpathentry kind="output" path="target/classes"/>
28+
</classpath>

GPEI/enfermedades/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,11 @@
77
</parent>
88
<groupId>enfermedades</groupId>
99
<artifactId>enfermedades</artifactId>
10+
<dependencies>
11+
<dependency>
12+
<groupId>mysql</groupId>
13+
<artifactId>mysql-connector-java</artifactId>
14+
<version>8.0.27</version>
15+
</dependency>
16+
</dependencies>
1017
</project>
Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
package dominio;
2+
3+
import java.sql.ResultSet;
4+
import java.sql.SQLException;
5+
import java.util.ArrayList;
6+
7+
import persistencia.Agente;
8+
9+
public class Enfermedad {
10+
private int id;
11+
private String nombre;
12+
private String descripcion;
13+
private int temporalidad;
14+
15+
public Enfermedad(int id, String nombre, String descripcion, int temporalidad) {
16+
this.id = id;
17+
this.nombre = nombre;
18+
this.descripcion = descripcion;
19+
this.temporalidad = temporalidad;
20+
}
21+
22+
public Enfermedad(String nombre, String descripcion, int temporalidad) {
23+
this.nombre = nombre;
24+
this.descripcion = descripcion;
25+
this.temporalidad = temporalidad;
26+
}
27+
28+
public int getId() {
29+
return this.id;
30+
}
31+
32+
public String getNombre() {
33+
return this.nombre;
34+
}
35+
36+
public String getDescripcion() {
37+
return this.descripcion;
38+
}
39+
40+
public int getTemporalidad() {
41+
return this.temporalidad;
42+
}
43+
44+
public int insert() throws Exception {
45+
int salida = 0;
46+
47+
salida = Agente.getAgente().insert("insert into ENFERMEDADES (NOMBRE, DESCRIPCION, TEMPORALIDAD) values('"+this.nombre+"','"+this.descripcion+"',"+this.temporalidad+")");
48+
System.out.println(salida);
49+
return salida;
50+
}
51+
52+
public static ArrayList<Enfermedad> readEnfermedad(String nombreEnfermedad) {
53+
ArrayList<String> list = new ArrayList<String>();
54+
ResultSet resultSet;
55+
String str = new String(nombreEnfermedad);
56+
ArrayList<Enfermedad> enfermedadesEncontradas = new ArrayList<Enfermedad>();
57+
58+
int id;
59+
String nombre;
60+
String descripcion;
61+
int temporalidad;
62+
63+
try {
64+
int i = 0;
65+
int size = 0;
66+
Enfermedad enfermedad;
67+
resultSet = Agente.getAgente().select("select ID_ENFERMEDAD, NOMBRE, DESCRIPCION, TEMPORALIDAD from ENFERMEDADES where lower(NOMBRE) like '%" + str.toLowerCase() + "%'");
68+
69+
while (resultSet.next()) {
70+
list.add(resultSet.getString("ID_ENFERMEDAD"));
71+
list.add(resultSet.getString("NOMBRE"));
72+
list.add(resultSet.getString("DESCRIPCION"));
73+
list.add(resultSet.getString("TEMPORALIDAD"));
74+
}
75+
76+
while (list.size()/4 > i) {
77+
78+
id = Integer.parseInt(list.get(0+size));
79+
nombre = list.get(1+size);
80+
descripcion = list.get(2+size);
81+
if (list.get(3+size) == null) {
82+
temporalidad = -1;
83+
} else {
84+
temporalidad = Integer.parseInt(list.get(3+size));
85+
}
86+
87+
i++;
88+
size +=4;
89+
90+
enfermedad = new Enfermedad(id, nombre, descripcion, temporalidad);
91+
enfermedadesEncontradas.add(enfermedad);
92+
}
93+
94+
} catch (SQLException e) {
95+
// TODO Auto-generated catch block
96+
e.printStackTrace();
97+
} catch (Exception e) {
98+
// TODO Auto-generated catch block
99+
e.printStackTrace();
100+
}
101+
return enfermedadesEncontradas;
102+
}
103+
104+
public static ArrayList<Vacuna> readVacunas(String nombreEnfermedad) {
105+
String str = new String(nombreEnfermedad);
106+
ArrayList<String> list = new ArrayList<String>();
107+
ArrayList<Vacuna> vacunasEncontradas = new ArrayList<Vacuna>();
108+
109+
int id;
110+
String enfermedad = nombreEnfermedad;
111+
String nombre;
112+
int num_dosis;
113+
114+
try {
115+
int i = 0;
116+
int size = 0;
117+
Vacuna vacuna;
118+
119+
ResultSet resultSet = Agente.getAgente().select("select * from VACUNAS where ID_ENFERMEDAD = (SELECT ID_ENFERMEDAD FROM ENFERMEDADES WHERE NOMBRE='" + str + "')");
120+
121+
while (resultSet.next()) {
122+
list.add(resultSet.getString("ID"));
123+
list.add(resultSet.getString("NOMBRE"));
124+
list.add(resultSet.getString("NUM_DOSIS"));
125+
}
126+
127+
while (list.size()/3 > i) {
128+
129+
id = Integer.parseInt(list.get(0+size));
130+
nombre = list.get(1+size);
131+
num_dosis = Integer.parseInt(list.get(2+size));
132+
i++;
133+
size +=3;
134+
135+
vacuna = new Vacuna(id, nombre, enfermedad, num_dosis);
136+
vacunasEncontradas.add(vacuna);
137+
}
138+
139+
} catch (SQLException e) {
140+
// TODO Auto-generated catch block
141+
e.printStackTrace();
142+
}
143+
144+
return vacunasEncontradas;
145+
}
146+
147+
public static ArrayList<Medicina> readMedicinas(String nombreEnfermedad) {
148+
String str = new String(nombreEnfermedad);
149+
ArrayList<String> list = new ArrayList<String>();
150+
ArrayList<Medicina> medicinasEncontradas = new ArrayList<Medicina>();
151+
152+
int id;
153+
String enfermedad = nombreEnfermedad;
154+
String nombre;
155+
String organismo;
156+
157+
try {
158+
int i = 0;
159+
int size = 0;
160+
Medicina medicina;
161+
162+
//ResultSet resultSet = Agente.getAgente().select("select * from VACUNAS where ID_ENFERMEDAD = (SELECT ID_ENFERMEDAD FROM ENFERMEDADES WHERE NOMBRE='" + str + "')");
163+
ResultSet resultSet = Agente.getAgente().select("select m.ID_MEDICINA, m.NOMBRE, o.NOMBRE FROM MEDICINAS m join ENFERMEDAD_MEDICINA em on m.ID_MEDICINA=em.ID_MEDICINA join ORGANISMOS o on m.O_APROBADOR=o.ID_ORGANISMO join ENFERMEDADES e on em.ID_ENFERMEDAD=e.ID_ENFERMEDAD WHERE e.NOMBRE='"+str+"'");
164+
165+
while (resultSet.next()) {
166+
list.add(resultSet.getString("m.ID_MEDICINA"));
167+
list.add(resultSet.getString("m.NOMBRE"));
168+
list.add(resultSet.getString("o.NOMBRE"));
169+
}
170+
171+
while (list.size()/3 > i) {
172+
173+
id = Integer.parseInt(list.get(0+size));
174+
nombre = list.get(1+size);
175+
organismo = list.get(2+size);
176+
i++;
177+
size +=3;
178+
179+
medicina = new Medicina(id, nombre, organismo, enfermedad);
180+
medicinasEncontradas.add(medicina);
181+
}
182+
183+
} catch (SQLException e) {
184+
// TODO Auto-generated catch block
185+
e.printStackTrace();
186+
}
187+
188+
return medicinasEncontradas;
189+
}
190+
191+
public static ArrayList<Sintoma> readSintomas(String nombreEnfermedad) {
192+
String str = new String(nombreEnfermedad);
193+
ArrayList<String> list = new ArrayList<String>();
194+
ArrayList<Sintoma> sintomasEncontradas = new ArrayList<Sintoma>();
195+
196+
int id;
197+
String nombre;
198+
String descripcion_s;
199+
200+
try {
201+
int i = 0;
202+
int size = 0;
203+
Sintoma sintoma;
204+
205+
//ResultSet resultSet = Agente.getAgente().select("select * from VACUNAS where ID_ENFERMEDAD = (SELECT ID_ENFERMEDAD FROM ENFERMEDADES WHERE NOMBRE='" + str + "')");
206+
ResultSet resultSet = Agente.getAgente().select("select s.ID_SINTOMA, s.NOMBRE, s.DESCRIPCION FROM SINTOMAS s join ENFERMEDAD_SINTOMAS es on s.ID_SINTOMA=es.ID_SINTOMA join ENFERMEDADES e on es.ID_ENFERMEDAD=e.ID_ENFERMEDAD where e.NOMBRE='"+str+"'");
207+
208+
while (resultSet.next()) {
209+
list.add(resultSet.getString("s.ID_SINTOMA"));
210+
list.add(resultSet.getString("s.NOMBRE"));
211+
list.add(resultSet.getString("s.DESCRIPCION"));
212+
}
213+
214+
while (list.size()/3 > i) {
215+
216+
id = Integer.parseInt(list.get(0+size));
217+
nombre = list.get(1+size);
218+
descripcion_s = list.get(2+size);
219+
i++;
220+
size +=3;
221+
222+
sintoma = new Sintoma(id, nombre, descripcion_s);
223+
sintomasEncontradas.add(sintoma);
224+
}
225+
226+
} catch (SQLException e) {
227+
// TODO Auto-generated catch block
228+
e.printStackTrace();
229+
}
230+
231+
return sintomasEncontradas;
232+
}
233+
234+
public static int deleteEnfermedad(int idEnfermedad) {
235+
int result = -1;
236+
237+
try {
238+
result = Agente.getAgente().delete("delete from ENFERMEDADES where ID_ENFERMEDAD = '"+idEnfermedad+"';");
239+
} catch (Exception e) {
240+
// TODO: handle exception
241+
e.printStackTrace();
242+
}
243+
244+
return result;
245+
}
246+
247+
public static int updateEnfermedad(int idEnfermedad, String nombre, String descripcion, int temporalidad) {
248+
int result = -1;
249+
250+
try {
251+
result = Agente.getAgente().update("update ENFERMEDADES set NOMBRE = '"+nombre+"', DESCRIPCION = '"+descripcion+"', TEMPORALIDAD = "+temporalidad+" where ID_ENFERMEDAD = '"+idEnfermedad+"';");
252+
} catch (Exception e) {
253+
// TODO: handle exception
254+
e.printStackTrace();
255+
}
256+
257+
return result;
258+
}
259+
260+
public static int updateEnfermedad(int idEnfermedad, String campo, int nuevoValor) {
261+
int result = -1;
262+
263+
try {
264+
result = Agente.getAgente().update("update ENFERMEDADES set "+campo+" = '"+nuevoValor+"' where ID_ENFERMEDAD = '"+idEnfermedad+"';");
265+
} catch (Exception e) {
266+
// TODO: handle exception
267+
e.printStackTrace();
268+
}
269+
270+
return result;
271+
}
272+
}

0 commit comments

Comments
 (0)