Commit 0e7a63f3 authored by jose.ignacio.fagian's avatar jose.ignacio.fagian
Browse files

Se añaden los cambios aplicados en el codigo de backend Java para el...

Se añaden los cambios aplicados en el codigo de backend Java para el procesamiento de los JSON en la nueva version de matefun.
Se actualiza el binario de matefun.
parent 1408b11e
......@@ -13,7 +13,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.Map;
import javax.annotation.PreDestroy;
import javax.ejb.Stateful;
import javax.inject.Inject;
......@@ -232,6 +232,11 @@ public class CommandsBean {
}
this.latch = new CountDownLatch(2);
Map<String, String> envs = this.builder.environment();
envs.put("LANGUAGE", "en");
this.proceso = this.builder.start();
this.p_stdin = new BufferedWriter(new OutputStreamWriter(proceso.getOutputStream()));
if (this.standardConsoleThread != null && this.standardConsoleThread.isAlive()) {
......@@ -298,7 +303,8 @@ public class CommandsBean {
try {
Scanner s = new Scanner(proceso.getInputStream());
latch.countDown();
Pattern p = Pattern.compile("OUTFigura:(Figura:)*\\[\\]");
Pattern p = Pattern.compile("OUTFigure:(Figure:)*\\[\\]");
Pattern p3d = Pattern.compile("OUT3D Figure:(3D Figure:)*\\[\\]");
ArrayList<String> animacion = new ArrayList<>();
while (s.hasNextLine()) {
String result = s.nextLine();
......@@ -314,16 +320,26 @@ public class CommandsBean {
nombrePrompt = "";
}
JsonObject respuestaJson = null;
if (result.contains("CANVAS:")) {
int index = result.indexOf("CANVAS:");
result = result.substring(index + 7);
if (result.contains("FIG:")) {
int index = result.indexOf("FIG:");
result = result.substring(index + 4);
animacion.add(result);
respuestaJson = null;
} else if (result.contains("FIG3D:")) {
int index = result.indexOf("FIG3D:");
result = result.substring(index + 6);
animacion.add(result);
respuestaJson = null;
} else if (result.equals("OUTFigura")) {
} else if (result.equals("OUTFigure")) {
respuestaJson = Json.createObjectBuilder().add("tipo", "canvas")
.add("resultado", animacion.get(0)).build();
animacion.clear();
} else if (result.equals("OUT3D Figure")) {
respuestaJson = Json.createObjectBuilder().add("tipo", "canvas3D")
.add("resultado", animacion.get(0)).build();
animacion.clear();
} else if (p.matcher(result).matches()) {
JsonArrayBuilder animJson = Json.createArrayBuilder();
......@@ -333,12 +349,23 @@ public class CommandsBean {
respuestaJson = Json.createObjectBuilder().add("tipo", "animacion")
.add("resultado", animJson).build();
animacion.clear();
} else if (p3d.matcher(result).matches()) {
JsonArrayBuilder animJson = Json.createArrayBuilder();
for (String canvas : animacion) {
animJson.add(canvas);
}
respuestaJson = Json.createObjectBuilder().add("tipo", "animacion3D")
.add("resultado", animJson).build();
animacion.clear();
} else if (result.contains("GRAPH:")) {
int index = result.indexOf("GRAPH:");
result = result.substring(index + 6);
respuestaJson = Json.createObjectBuilder().add("tipo", "graph").add("resultado", result)
.build();
} else if (result.contains("OUTGraph")) {
} else {
respuestaJson = Json.createObjectBuilder().add("tipo", "salida")
.add("resultado", result).build();
......
......@@ -24,8 +24,7 @@
<!-- </persistence-unit> -->
<persistence-unit name="matefunDS" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/azureDSjta</jta-data-source>
<jta-data-source>java:/matefun</jta-data-source>
<class>edu.proygrado.modelo.Alumno</class>
<class>edu.proygrado.modelo.Archivo</class>
<class>edu.proygrado.modelo.Configuracion</class>
......@@ -39,7 +38,6 @@
<class>edu.proygrado.modelo.Sesion</class>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="none" />
<property name="hibernate.transaction.jta.platform" value="org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform"/>
</properties>
</persistence-unit>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment