Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
Showing
with 34 additions and 9 deletions
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
...@@ -13,7 +13,7 @@ import java.util.concurrent.CountDownLatch; ...@@ -13,7 +13,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.Map;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import javax.ejb.Stateful; import javax.ejb.Stateful;
import javax.inject.Inject; import javax.inject.Inject;
...@@ -232,6 +232,11 @@ public class CommandsBean { ...@@ -232,6 +232,11 @@ public class CommandsBean {
} }
this.latch = new CountDownLatch(2); this.latch = new CountDownLatch(2);
Map<String, String> envs = this.builder.environment();
envs.put("LANGUAGE", "en");
this.proceso = this.builder.start(); this.proceso = this.builder.start();
this.p_stdin = new BufferedWriter(new OutputStreamWriter(proceso.getOutputStream())); this.p_stdin = new BufferedWriter(new OutputStreamWriter(proceso.getOutputStream()));
if (this.standardConsoleThread != null && this.standardConsoleThread.isAlive()) { if (this.standardConsoleThread != null && this.standardConsoleThread.isAlive()) {
...@@ -298,7 +303,8 @@ public class CommandsBean { ...@@ -298,7 +303,8 @@ public class CommandsBean {
try { try {
Scanner s = new Scanner(proceso.getInputStream()); Scanner s = new Scanner(proceso.getInputStream());
latch.countDown(); 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<>(); ArrayList<String> animacion = new ArrayList<>();
while (s.hasNextLine()) { while (s.hasNextLine()) {
String result = s.nextLine(); String result = s.nextLine();
...@@ -314,16 +320,26 @@ public class CommandsBean { ...@@ -314,16 +320,26 @@ public class CommandsBean {
nombrePrompt = ""; nombrePrompt = "";
} }
JsonObject respuestaJson = null; JsonObject respuestaJson = null;
if (result.contains("CANVAS:")) { if (result.contains("FIG:")) {
int index = result.indexOf("CANVAS:"); int index = result.indexOf("FIG:");
result = result.substring(index + 7); 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); animacion.add(result);
respuestaJson = null; respuestaJson = null;
} else if (result.equals("OUTFigura")) { } else if (result.equals("OUTFigure")) {
respuestaJson = Json.createObjectBuilder().add("tipo", "canvas") respuestaJson = Json.createObjectBuilder().add("tipo", "canvas")
.add("resultado", animacion.get(0)).build(); .add("resultado", animacion.get(0)).build();
animacion.clear(); 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()) { } else if (p.matcher(result).matches()) {
JsonArrayBuilder animJson = Json.createArrayBuilder(); JsonArrayBuilder animJson = Json.createArrayBuilder();
...@@ -333,12 +349,23 @@ public class CommandsBean { ...@@ -333,12 +349,23 @@ public class CommandsBean {
respuestaJson = Json.createObjectBuilder().add("tipo", "animacion") respuestaJson = Json.createObjectBuilder().add("tipo", "animacion")
.add("resultado", animJson).build(); .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(); animacion.clear();
} else if (result.contains("GRAPH:")) { } else if (result.contains("GRAPH:")) {
int index = result.indexOf("GRAPH:"); int index = result.indexOf("GRAPH:");
result = result.substring(index + 6); result = result.substring(index + 6);
respuestaJson = Json.createObjectBuilder().add("tipo", "graph").add("resultado", result) respuestaJson = Json.createObjectBuilder().add("tipo", "graph").add("resultado", result)
.build(); .build();
} else if (result.contains("OUTGraph")) {
} else { } else {
respuestaJson = Json.createObjectBuilder().add("tipo", "salida") respuestaJson = Json.createObjectBuilder().add("tipo", "salida")
.add("resultado", result).build(); .add("resultado", result).build();
......
...@@ -24,8 +24,7 @@ ...@@ -24,8 +24,7 @@
<!-- </persistence-unit> --> <!-- </persistence-unit> -->
<persistence-unit name="matefunDS" transaction-type="JTA"> <persistence-unit name="matefunDS" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <jta-data-source>java:/matefun</jta-data-source>
<jta-data-source>jdbc/azureDSjta</jta-data-source>
<class>edu.proygrado.modelo.Alumno</class> <class>edu.proygrado.modelo.Alumno</class>
<class>edu.proygrado.modelo.Archivo</class> <class>edu.proygrado.modelo.Archivo</class>
<class>edu.proygrado.modelo.Configuracion</class> <class>edu.proygrado.modelo.Configuracion</class>
...@@ -39,7 +38,6 @@ ...@@ -39,7 +38,6 @@
<class>edu.proygrado.modelo.Sesion</class> <class>edu.proygrado.modelo.Sesion</class>
<properties> <properties>
<property name="javax.persistence.schema-generation.database.action" value="none" /> <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> </properties>
</persistence-unit> </persistence-unit>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment