tag:blogger.com,1999:blog-111402952024-03-20T19:24:17.730-07:00AVBravoUn blog desde Panama sobre NetBeans, Java, JSF, jmoordb,Microprofile, JakartaEEavbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.comBlogger936125tag:blogger.com,1999:blog-11140295.post-41144183752111183522023-11-23T13:03:00.000-08:002023-11-23T13:03:15.832-08:00Implementando searchLikeBy en MongoDB con Jmoordbcore 1/3<p> En el siguiente enlace se muestra una serie de artículos donde se muestra el proceso.</p><p><a href="https://dev.to/avbravo/implementando-searchlikeby-en-mongodb-con-jmoordbcore-13-3odk">Implementando searchLikeBy en MongoDB con Jmoordbcore 1/3</a><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-11173953271799539102023-08-03T14:12:00.001-07:002023-08-03T14:16:18.906-07:00< p : schedule con filtros><p>Mostrare como implementar un < p: schedule > de Primefaces con filtros usando jmoordbcore</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJtcRJBCtzeBCfazKN12WCeKEeuOlRTFPqNvYn5GsIivFt4DQKo7lvV5sWzZRn05BTAKSATOVXBUJoHP25Eabn3elSjBm1FP_u9AHatsAl0pjnVqHstyhEzYMmozBdQ_wgAAUwZhlCekjpETM_vAL9uS3-SJNzYUlT4PWd_5HT53KZwiavNnvu/s1169/Captura%20desde%202023-08-03%2015-46-35.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="621" data-original-width="1169" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJtcRJBCtzeBCfazKN12WCeKEeuOlRTFPqNvYn5GsIivFt4DQKo7lvV5sWzZRn05BTAKSATOVXBUJoHP25Eabn3elSjBm1FP_u9AHatsAl0pjnVqHstyhEzYMmozBdQ_wgAAUwZhlCekjpETM_vAL9uS3-SJNzYUlT4PWd_5HT53KZwiavNnvu/s16000/Captura%20desde%202023-08-03%2015-46-35.png" /></a></div><br /><p>Se cuenta con una pagina Jakarta Server Faces</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSgX1QBRevZoy8TlYUrl1520diw3YVkz_9B4TxwODZB47P7Dst5lojpxoHeaS3f06k2xHcQWlyl9MHtEGybpeVWyp4Ydz0IAh-ZIogegE6oENOgk83uw3ZRV7lYXYTCcdc8bpck4PUv7ClRdsOnbsW5bZtFQU1kg5RA6FogxNTisSR3EeEGxbv/s867/Captura%20desde%202023-08-03%2015-51-36.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="385" data-original-width="867" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSgX1QBRevZoy8TlYUrl1520diw3YVkz_9B4TxwODZB47P7Dst5lojpxoHeaS3f06k2xHcQWlyl9MHtEGybpeVWyp4Ydz0IAh-ZIogegE6oENOgk83uw3ZRV7lYXYTCcdc8bpck4PUv7ClRdsOnbsW5bZtFQU1kg5RA6FogxNTisSR3EeEGxbv/s16000/Captura%20desde%202023-08-03%2015-51-36.png" /></a></div><br /><p><br /></p><p>En el Controller en el init definimos una operacion</p><p> @PostConstruct</p><p> public void init() {</p><p> try {</p><p> }</p><p>}</p><p><br /></p><p><b>Método refresh() , obtiene el primer día de la semana y el ultimo día de la semana actual, se invoca al loadSchedule()</b></p><p><br /></p><p><br /></p><p><span style="font-size: x-small;"> <b> public String refresh() {</b></span></p><p> <span style="font-family: Palatino; font-size: x-small;"> try {</span><span style="font-family: Palatino; font-size: small;"> </span></p><p><span style="font-family: Palatino; font-size: x-small;"> <span style="background-color: #ffa400;"> <b> Date start = DateUtil.convertirLocalDateToJavaDate(DateUtil.primerDiaSemanaActual(Boolean.FALSE));</b></span></span></p><p><span style="font-family: Palatino; font-size: x-small;"><b style="background-color: #ffa400;"> Date end = DateUtil.convertirLocalDateToJavaDate(DateUtil.ultimoDiaSemanaActual(Boolean.FALSE));</b></span></p><p><span style="background-color: #ffa400; font-family: Palatino; font-size: x-small;"> </span><span style="font-family: Palatino; font-size: small;"> tarjetaFinalizadoList = new ArrayList<>();</span></p><p><span style="font-family: Palatino; font-size: x-small;"> tarjetaPendienteList = new ArrayList<>();</span></p><p><span style="font-family: Palatino; font-size: x-small;"> tarjetaProgresoList = new ArrayList<>();</span></p><p><span style="font-family: Palatino; font-size: small;"> loadSchedule();</span></p><p><span style="font-family: Palatino; font-size: small;"> PrimeFaces.current().ajax().update(":form:schedule");</span></p><p><span style="font-family: Palatino; font-size: x-small;"> } catch (Exception e) {</span></p><p><span style="font-family: Palatino; font-size: x-small;"> FacesUtil.errorMessage(FacesUtil.nameOfClassAndMethod() + " " + e.getLocalizedMessage());</span></p><p><span style="font-family: Palatino; font-size: x-small;"> }</span></p><p><span style="font-family: Palatino; font-size: x-small;"> return "";</span></p><p><span style="font-family: Palatino; font-size: x-small;"> }</span></p><p><br /></p><p><b><span style="font-size: x-small;"> private Boolean loadTarjetaPendiente(Date start, Date end) {</span></b></p><p><span style="font-family: Palatino; font-size: x-small;"> Boolean result = Boolean.FALSE;</span></p><p><span style="font-family: Palatino; font-size: x-small;"> tarjetaPendienteList = new ArrayList<>();</span></p><p><span style="font-family: Palatino; font-size: x-small;"> try {</span></p><p><span style="font-family: Palatino; font-size: x-small;"> Integer page = 0;</span></p><p><span style="font-family: Palatino; font-size: x-small;"> Integer size = 0;</span></p><p><span style="font-family: Palatino; font-size: x-small;"> Document sortTarjeta = new Document("idtarjeta", 1).append("prioridad", 1);</span></p><p><span style="font-family: Palatino; font-size: x-small;"> </span><b style="font-family: Palatino; font-size: small;"><span style="color: #800180;"> Bson filterDate = DocumentUtil.createBsonBetweenDateWithoutHours(</span></b></p><p><span style="color: #800180; font-family: Palatino; font-size: x-small;"><b> "fechainicial", start, "fechainicial", end);</b></span></p><p><span style="font-family: Palatino; font-size: x-small;"> if (isPropietario) {</span></p><p><span style="font-family: Palatino; font-size: x-small;"> <b> Bson filter0 = eq("idproyecto", proyectoSelected.getIdproyecto());</b></span></p><p><span style="font-family: Palatino; font-size: x-small;"><b><br /></b></span></p><p><span style="font-family: Palatino; font-size: x-small;"><b> Bson filter = and(filter0,</b></span></p><p><span style="font-family: Palatino; font-size: x-small;"><b> filterDate,</b></span></p><p><span style="font-family: Palatino; font-size: x-small;"><b> eq("active", Boolean.TRUE),</b></span></p><p><span style="font-family: Palatino; font-size: x-small;"><b> eq("columna", "pendiente"));</b></span></p><p><span style="font-family: Palatino; font-size: small;"> </span></p><p><span style="font-family: Palatino; font-size: x-small;"><br /></span></p><p><span style="font-family: Palatino; font-size: x-small;"> tarjetaPendienteList = tarjetaServices.lookup(filter, sortTarjeta, page, size);</span></p><p><span style="font-family: Palatino; font-size: x-small;"> } else {</span></p><p><span style="font-family: Palatino; font-size: x-small;"> <b> Bson filter0 = eq("idproyecto", proyectoSelected.getIdproyecto());</b></span></p><p><span style="font-family: Palatino; font-size: x-small;"><b> Bson filter = and(filter0,</b></span></p><p><span style="font-family: Palatino; font-size: x-small;"><b> filterDate,</b></span></p><p><span style="font-family: Palatino; font-size: x-small;"><b> eq("active", Boolean.TRUE),</b></span></p><p><span style="font-family: Palatino; font-size: x-small;"><b> eq("columna", "pendiente"),</b></span></p><p><span style="font-family: Palatino; font-size: x-small;"><b> eq("user.iduser", userLogged.getIduser()));</b></span></p><p><span style="font-family: Palatino; font-size: x-small;"><br /></span></p><p><span style="font-family: Palatino; font-size: x-small;"> tarjetaPendienteList = tarjetaServices.lookup(filter, sortTarjeta, page, size);</span></p><p><span style="font-family: Palatino; font-size: x-small;"> }</span></p><p><span style="font-family: Palatino; font-size: x-small;"> } catch (Exception e) {</span></p><p><span style="font-family: Palatino; font-size: x-small;"> FacesUtil.errorMessage(FacesUtil.nameOfClassAndMethod() + " " + e.getLocalizedMessage());</span></p><p><span style="font-family: Palatino; font-size: x-small;"> }</span></p><p><span style="font-family: Palatino; font-size: x-small;"> return result;</span></p><p><span style="font-family: Palatino; font-size: x-small;"> }</span></p><p><br /></p><p><br /></p><p><b><br /></b></p><p><b>Cree el método </b><b>loadSchedule()</b></p><p>Procesa el evento loadEvents del schedule mediante la implementación de lazyEventModel</p><p><br /></p><p><b><span style="font-size: x-small;"> public void loadSchedule() {</span></b></p><p> <span style="font-family: Palatino; font-size: x-small;">try {</span></p><p><span style="font-family: Palatino; font-size: x-small;"> lazyEventModel = new LazyScheduleModel() {</span></p><p><span style="font-family: Palatino; font-size: x-small;"> List<Tarjeta> list = new ArrayList<>();</span></p><p><span style="font-family: Palatino; font-size: x-small;"> @Override</span></p><p><span style="font-family: Palatino; font-size: x-small;"> public void loadEvents(LocalDateTime start, LocalDateTime end) {</span></p><p><span style="font-family: Palatino; font-size: x-small;"> loadTarjetaPendiente(DateUtil.convertLocalDateTimeToJavaDate(start), DateUtil.convertLocalDateTimeToJavaDate(end));</span></p><p><span style="font-family: Palatino; font-size: x-small;"> loadTarjetaProgreso(DateUtil.convertLocalDateTimeToJavaDate(start), DateUtil.convertLocalDateTimeToJavaDate(end));</span></p><p><span style="font-family: Palatino; font-size: x-small;"> loadTarjetaFinalizado(DateUtil.convertLocalDateTimeToJavaDate(start), DateUtil.convertLocalDateTimeToJavaDate(end));</span></p><p><span style="font-family: Palatino; font-size: x-small;"> tarjetaPendienteList.forEach((a) -> {</span></p><p><span style="font-family: Palatino; font-size: x-small;"> if (!a.getBacklog()) {</span></p><p><span style="font-family: Palatino; font-size: x-small;"> DefaultScheduleEvent event = DefaultScheduleEvent.builder()</span></p><p><span style="font-family: Palatino; font-size: x-small;"> .title(a.getTarjeta() + " / " + siglasColaboradores(a.getUserView()))</span></p><p><span style="font-family: Palatino; font-size: x-small;"> .startDate(JmoordbCoreDateUtil.convertToLocalDateTimeViaInstant(a.getFechainicial()))</span></p><p><span style="font-family: Palatino; font-size: x-small;"> .endDate(JmoordbCoreDateUtil.convertToLocalDateTimeViaInstant(a.getFechafinal()))</span></p><p><span style="font-family: Palatino; font-size: x-small;"> .description(a.getDescripcion())</span></p><p><span style="font-family: Palatino; font-size: x-small;"> .id(a.getIdtarjeta().toString())</span></p><p><span style="font-family: Palatino; font-size: x-small;"> .backgroundColor("red")</span></p><p><span style="font-family: Palatino; font-size: x-small;"> .build();</span></p><p><span style="font-family: Palatino; font-size: x-small;"><br /></span></p><p><span style="font-family: Palatino; font-size: x-small;"> addEvent(event);</span></p><p><span style="font-family: Palatino; font-size: x-small;"> } else {</span></p><p><span style="font-family: Palatino; font-size: x-small;"> DefaultScheduleEvent event = DefaultScheduleEvent.builder()</span></p><p><span style="font-family: Palatino; font-size: x-small;"> .title("(R) " + a.getTarjeta() + " / " + siglasColaboradores(a.getUserView()))</span></p><p><span style="font-family: Palatino; font-size: x-small;"> .startDate(JmoordbCoreDateUtil.convertToLocalDateTimeViaInstant(a.getFechainicial()))</span></p><p><span style="font-family: Palatino; font-size: x-small;"> .endDate(JmoordbCoreDateUtil.convertToLocalDateTimeViaInstant(a.getFechafinal()))</span></p><p><span style="font-family: Palatino; font-size: x-small;"> .description(a.getDescripcion())</span></p><p><span style="font-family: Palatino; font-size: x-small;"> .id(a.getIdtarjeta().toString())</span></p><p><span style="font-family: Palatino; font-size: x-small;"> .backgroundColor("blue")</span></p><p><span style="font-family: Palatino; font-size: x-small;"> .build();</span></p><p><span style="font-family: Palatino; font-size: x-small;"> addEvent(event);</span></p><p><span style="font-family: Palatino; font-size: x-small;"> }</span></p><p><span style="font-family: Palatino; font-size: x-small;"> });</span></p><p> <span style="font-size: x-small;"> }</span></p><p><span style="font-size: small;"> };</span></p><p><span style="font-family: Palatino; font-size: x-small;"> } catch (Exception e) {</span></p><p><span style="font-family: Palatino; font-size: x-small;"> FacesUtil.errorMessage(FacesUtil.nameOfClassAndMethod() + " " + e.getLocalizedMessage());</span></p><p><span style="font-family: Palatino; font-size: x-small;"> }</span></p><p><span style="font-family: Palatino; font-size: x-small;"> }</span></p><p><br /></p><p><b>El método actionCommandButton() se invoca desde el botón</b></p><p><br /></p><p><b> <span style="font-size: x-small;"> public String actionCommandButton() {</span></b></p><p><span style="font-family: Palatino; font-size: x-small;"> try {</span></p><p><span style="font-family: Palatino; font-size: x-small;"> showSchedule = Boolean.TRUE;</span></p><p><span style="font-family: Palatino; font-size: x-small;"> refresh();</span></p><p><span style="font-family: Palatino; font-size: x-small;"> } catch (Exception e) {</span></p><p><span style="font-family: Palatino; font-size: x-small;"> FacesUtil.errorMessage(FacesUtil.nameOfClassAndMethod() + " " + e.getLocalizedMessage());</span></p><p><span style="font-family: Palatino; font-size: x-small;"> }</span></p><p><span style="font-family: Palatino; font-size: x-small;"> return "";</span></p><p><span style="font-family: Palatino; font-size: x-small;"> }</span></p><p> </p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-57303624969355871802023-08-02T06:27:00.002-07:002023-08-02T06:27:23.949-07:00Una amiga<p> En muchas ocasiones caminamos en la vida y en ese andar entre experiencias y aprendizaje, encontramos personas excepcionales , personas con un carisma y una chispa que logran iluminar los caminos para todas las personas a su alrededor. </p><p>Esas personas poseen una virtud extraordinaria, un dinamismo y alegría que hacen que los sueños tengan sentido, que es posible mirar en la distancia y saber que lograras todo aquello que te propongas en la vida. </p><p>Esa persona que podemos ver cada día y que es un ejemplo de vida es mi amiga Yessica Saez. Puedes encontrar acerca de ella en Wikipedia en el siguiente enlace: <a href="https://es.wikipedia.org/wiki/Yessica_S%C3%A1ez">https://es.wikipedia.org/wiki/Yessica_S%C3%A1ez</a> </p><p><br /></p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_ETzQsTwJVy9-sKY2lQQiTv19_Gz2b5eEcSPmH_57w7uRD3ey4NylE7gL-XCu8FXWdd02CgqqJsNkjeK-dDMtbQyk1ZKAkb5khJHcQN4QueI5154XWrZRa6zclv0b3R-pYXHt-Z0LSUFjfjC_txGFvEnMkmuyqfCeOck1yxbjyLEDG-4SpVia/s1024/Yessica_Saez_-_52781811644.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="683" data-original-width="1024" height="213" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_ETzQsTwJVy9-sKY2lQQiTv19_Gz2b5eEcSPmH_57w7uRD3ey4NylE7gL-XCu8FXWdd02CgqqJsNkjeK-dDMtbQyk1ZKAkb5khJHcQN4QueI5154XWrZRa6zclv0b3R-pYXHt-Z0LSUFjfjC_txGFvEnMkmuyqfCeOck1yxbjyLEDG-4SpVia/w320-h213/Yessica_Saez_-_52781811644.jpg" width="320" /></a></div><br /><p>Para todos aquellos que tenemos el honor de conocerla y contar con su amistad, siempre le deseamos muchos éxitos y nos sentimos orgullosos de sus logros.</p><p><br /></p><p>Muchas felicidades amiga.</p><p><br /></p><p><br /></p><p><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-78872374531494943732023-07-24T08:11:00.011-07:002023-07-25T13:55:19.933-07:00Primefaces v13<p> La versión nueva de primefaces v13.0 elimina el componente <p:repeat> </p><p>Consulte los cambios en </p><p><a href="https://github.com/primefaces/primefaces/releases/tag/13.0.0">https://github.com/primefaces/primefaces/releases/tag/13.0.0</a></p><p>por lo tanto si necesita una solución similar considere utilizar</p><p> <p:carousel></p><p> o</p><p> <ui:repeat></p><p>En la versión 13 genera una excepción</p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dwXk-qk2j5QpG7Jc2c0U9UpkMCGiUuQMJpbPhISXNidQcTFhfVxxtZkDvJsuaCrw2JIQK-0epIEnuA' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div><br /><p><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-45297170699692507782023-07-14T13:23:00.003-07:002023-07-14T13:23:20.839-07:00PayaraMicro 6.2023.7 con JDK 17+<p> Recién se ha liberado la versión 6.2023.7 de PayaraMicro, cuando ejecutamos el proyecto podemos encontrarnos con este error.</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0xdLv_nCl2uBwBtY0NyEYBPzxJH7DBchBChUiZGmPk0h774GMp5tjxXqoZD1ZeWWAJzcr29cvNWDr0StmOHt_ETZhfJX4-aKGSZMVfXIprZ-rI8Jwhrq-yX9Er92eJxpcdsdk8YorULni4oJiqGF6NsA7PA5yDthE45-1lvq-m1cpQlKlrmJv/s908/e1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="539" data-original-width="908" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0xdLv_nCl2uBwBtY0NyEYBPzxJH7DBchBChUiZGmPk0h774GMp5tjxXqoZD1ZeWWAJzcr29cvNWDr0StmOHt_ETZhfJX4-aKGSZMVfXIprZ-rI8Jwhrq-yX9Er92eJxpcdsdk8YorULni4oJiqGF6NsA7PA5yDthE45-1lvq-m1cpQlKlrmJv/s16000/e1.png" /></a></div><br /> <p></p><p>Generalmente es producido por el uso de EJB en Java 17. En una publicación de Payara desde la versión 5.2022.5 se mencionaba en la sección :<a href="https://docs.payara.fish/community/docs/5.2022.5/Technical%20Documentation/Payara%20Server%20Documentation/Jakarta%20EE%20API/Enterprise%20Java%20Beans%20(EJB)/JDK%2017%20Support.html">JDK 17 Support Considerations</a></p><p>Que debería agregarse el argumento a la JVM</p><p>--add-opens=java.base/java.lang=ALL-UNNAMED.</p><p>También se reporte el error al ejecutar Payara 6.2023.7 con JDK 17 </p><p><br /></p><p><a href="https://github.com/payara/Payara/issues/6337">Bug Report: Failed to deploy war with @Stateless in Payara Micro 6.2023.7 #6337</a></p><p>También indican la solución para PayaraServer</p><p><br /></p><p>asadmin create-jvm-options --add-opens=java.base/java.io=ALL-UNNAMED</p><p>asadmin restart-domain</p><p><br /></p><p>En nuestro caso estamos usando PayaraMicro 6.2023.7 añada al archivo pom.xml en la sección plugin de payara:</p><p><br /></p><p><br /></p><p> <javaCommandLineOptions></p><p> <option></p><p> <key>--add-opens</key></p><p> <value>java.base/java.io=ALL-UNNAMED</value></p><p> </option></p><p> </javaCommandLineOptions></p><p><br /></p><p>Una vista del archivo pom.xml</p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj44KsIil33FU30d94TO-YcO36fE-_jujmNPorHokfCw1Ne3iLIa-7zPdjR7B7J43LVoJBIqHdYshXdZTTRc-3DEPxFmbEvquhTK2A7gqrbf2qIZ5zmZ_Ci1PnDFuxiHTtu6-qEQge3JeZ2Z535MdGXny6aQnms9yP4qGmdjhRkTnRr75x711ag/s886/plugin.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="629" data-original-width="886" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj44KsIil33FU30d94TO-YcO36fE-_jujmNPorHokfCw1Ne3iLIa-7zPdjR7B7J43LVoJBIqHdYshXdZTTRc-3DEPxFmbEvquhTK2A7gqrbf2qIZ5zmZ_Ci1PnDFuxiHTtu6-qEQge3JeZ2Z535MdGXny6aQnms9yP4qGmdjhRkTnRr75x711ag/s16000/plugin.png" /></a></div><br /><p><br /></p><p>Al ejecutar el proyecto, puede observar que ejecuta sin errores</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmoc7E79uN2v1GwcHLC2Et_z0AChubjfXogj0yz5dgiF8PzdzS9jfqaPJVcXAojXoXUPwcsjdmlPWA70zmtOfEJ2dfTU-bdw8YrJVCUPaUVzbn5hdOwRR0C-vGuNCW6kS61guXX7A1QHx0YcNHTUNS8pb_dpdkJnYowA2hcI5vPL4STmf05NO7/s775/un.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="530" data-original-width="775" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmoc7E79uN2v1GwcHLC2Et_z0AChubjfXogj0yz5dgiF8PzdzS9jfqaPJVcXAojXoXUPwcsjdmlPWA70zmtOfEJ2dfTU-bdw8YrJVCUPaUVzbn5hdOwRR0C-vGuNCW6kS61guXX7A1QHx0YcNHTUNS8pb_dpdkJnYowA2hcI5vPL4STmf05NO7/s16000/un.png" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-3132658918305275022023-07-05T13:23:00.001-07:002023-07-05T13:23:13.211-07:00JMoordbCore @DeleteMany<p>A partir de la versión 0.29, se implementa el uso de @DeleteMany en Jmoordb-core permitiendo eliminar muchos documentos de una colección.</p><p>Asuma que tiene una entidad</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@Entity
public class Tarjeta {
@Id(autogeneratedActive = AutogeneratedActive.ON)
private Long idtarjeta;
@Column
private String tarjeta;
@Column
private String descripcion;
@ViewReferenced(from = "user", localField = "iduser")
List<UserView> userView;
@Column
private Date fechainicial;
@Column
private Date fechafinal;
@Referenced(from = "icono", localField = "idicono", commentary = "Esta asociado a la prioridad")
private Icono icono;
@Referenced(from = "tipotarjeta", localField = "idtipotarjeta", commentary = "Ayuda para la implementación de Deep Learning")
private Tipotarjeta tipotarjeta;
@Column
private Long idsprint;
@Column
private Long idproyecto;
@Column
private Boolean backlog;
@Column(commentary = "alta,baja,media")
private String prioridad;
@Column
private String estimacion;
@Column(commentary = "pendiente,progreso,finalizado")
private String columna;
@Column
private Boolean active;
@Embedded
List<Tarea> tarea;
@Embedded
List<Comentario> comentario;
@Embedded
List<Etiqueta> etiqueta;
@Embedded
List<Archivo> archivo;
@Embedded
List<Impedimento> impedimento;
@Column(commentary = "true cuando la crea un colaborador que no pertenece al proyecto y es un proyecto publico")
private Boolean foreaneo;
}</b></span></span></pre><p>Defina un repositorio, recuerde que CrudRepository implementa el método deleteMauy</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@Repository(database = "{mongodb.database1}", entity = Tarjeta.class)
public interface TarjetaRepository extends CrudRepository<Tarjeta, Long> {
@Lookup
public List<Tarjeta> lookup(Search search);
@Count()
public Long count(Search... search);
}</b></span></span><span style="color: white; font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 16px; font-weight: bold;">
</span></pre><div><br /></div><p>Defina un Controller</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@Path("tarjeta")
@Tag(name = "Información del tarjeta", description = "End-point para entidad Tarjeta")
@RolesAllowed({"admin"})
public class TarjetaController {
@Inject
TarjetaRepository tarjetaRepository;
@DELETE
@Path("deletemany")
public Response deleteMany(@QueryParam("filter") String filter ) {
Search search = DocumentUtil.convertForLookup(filter, "", 0, 0);
if (tarjetaRepository.deleteMany(search) == 0L) {
return Response.status(201).entity(Boolean.TRUE).build();
} else {
return Response.status(400).entity("Error " + tarjetaRepository.getJmoordbException().getLocalizedMessage()).build();
}
}
}</b></span></span></pre><p> En el cliente crear la interface RestClient</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>public interface TarjetaRestClient {
// <editor-fold defaultstate="collapsed" desc="lookupAuth()">
default String lookupAuth() {
/**
* *
* Leer las configuraciones del archivo microprofile-config.properties
*/
String secretKey = "SCox1jmWrkma$*opne2Amwz";
Config config = ConfigProvider.getConfig();
String userSecurity = config.getValue("userSecurity", String.class);
// or
ConfigValue passwordSecurity = config.getConfigValue("passwordSecurity");
String userDecrypted = Encryptor.decrypt(userSecurity, secretKey);
String passwordDecrypted = Encryptor.decrypt(passwordSecurity.getValue(), secretKey);
return "Basic "
+ Base64.getEncoder().encodeToString((userDecrypted + ":" + passwordDecrypted).getBytes());
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Response deleteMany(@QueryParam("filter") String filter)">
@DELETE
@Path("deletemany")
public Response deleteMany(@QueryParam("filter") String filter ) ;
// </editor-fold>
}</b></span></span></pre><p> Crear la interface Services</p><p><br /></p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>public interface TarjetaServices {
public Boolean deleteMany(Bson filter);
}</b></span></span></pre><p><br /></p><p>Implementar la interface Services</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@ApplicationScoped
public class ProyectoServicesImpl implements TarjetaServices {
// <editor-fold defaultstate="collapsed" desc="Services">
@Inject
TarjetaServices tarjetaServices;
// </editor-fold>
@Override
public Boolean deleteMany(Bson filter) {
Boolean result = Boolean.FALSE;
try {
Integer status = tarjetaRestClient.deleteMany(EncodeUtil.encodeBson(filter)).getStatus();
if (status == 201) {
result = Boolean.TRUE;
}
} catch (Exception e) {
FacesUtil.errorMessage(FacesUtil.nameOfClassAndMethod() + " " + e.getLocalizedMessage());
}
return result;
}
}</b></span></span></pre><p><br /></p><p>En otra clase que implementa la funcionalidad cree el filtro y realice la consulta</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b> Bson filter = and(
eq("active", Boolean.TRUE),
eq("age", 25)
);
tarjetaServices.deleteMany(filter);</b></span></span></pre>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-33257407219945673242023-07-05T07:25:00.005-07:002023-07-05T07:25:51.709-07:00Jmoordb-Core @UpdateMany y @DeleteMany<p> Jmoordb-Core @UpdateMany y @DeleteMany</p><p><br /></p><p>Estoy trabajando en una versión nueva de jmoordb-core en la cual se estará implementando nuevas funcionalidades como lo son @DeleteMany y @UpdateMany con la finalidad de hacer operaciones sobre múltiples documentos de la colección.</p><p><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-31471242414252113182023-03-31T18:20:00.002-07:002023-03-31T18:20:55.347-07:00A una amiga<p> En pocas ocasiones escribo en mi blog sobre temas que no estàn directamente relacionados con Java, JakartaEE, NoSQL, JmoordbCore entre otros.</p><p>Esta es una ocasión y lo hago para reconocer la labor incansable de una persona muy especial por quien siento mucho aprecio.</p><p>Ella es Yessica Sàez, (<span style="background-color: white; color: inherit; font-family: inherit; font-size: inherit; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit; white-space: inherit;"><a href="https://twitter.com/ysaez22">@ysaez22</a></span>) que ha recibido innumerables reconocimientos, que de enumerarlos me llevaría a realizar varias publicaciones.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiFKgkI0Opz03iAbreIrT8i0UhCxCVHyR7jd1sdZktq962mrPvHPf9VUc1xpayMudNpc4ml26xx7Z49OcZ8E0LzTNAxvHWxrAMC7ayCLabj4V2jre__FPXWHBhyl3Ev2YndwzScrxzWOyu1vDTzCPNIxLdZTgox_c4a8EO4XCuJrIiBH1iug/s680/y.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="680" data-original-width="680" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiFKgkI0Opz03iAbreIrT8i0UhCxCVHyR7jd1sdZktq962mrPvHPf9VUc1xpayMudNpc4ml26xx7Z49OcZ8E0LzTNAxvHWxrAMC7ayCLabj4V2jre__FPXWHBhyl3Ev2YndwzScrxzWOyu1vDTzCPNIxLdZTgox_c4a8EO4XCuJrIiBH1iug/s320/y.jpeg" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><div class="separator" style="clear: both;">Estamos muy orgullosos de su labor y sobre todo de esa persona que es. Te puedes encontrar con ella en uno de los pasillos de la Universidad, y te saludara con un carisma y amabilidad, que muchos no se imaginan todos los logros que ha conseguido.</div><div class="separator" style="clear: both;">Mis felicitaciones, amiga y a tu familia porque estoy seguro de que están muy orgullosos como lo estamos todos de tus éxitos y reconocimientos.</div><div class="separator" style="clear: both;">Haber coincidido en este tiempo y espacio contigo es todo un honor para mí.</div><div class="separator" style="clear: both;">Eres una fuente de inspiración para muchas personas entre las que me incluyo, no puedo olvidar el momento que conversamos y te comente que quería escribir un libro y el entusiasmo y motivación que me brindaste para que lo hiciera fue algo indescriptible.</div><div class="separator" style="clear: both;">Es un privilegio para nuestro país contar con un profesional de tu nivel.</div><div class="separator" style="clear: both;"> Muchas felicidades, amiga.</div></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><p><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-27465613561184510282023-01-31T12:48:00.007-08:002023-01-31T13:45:41.546-08:00@ViewEntity con Jmoordb-core<h2 style="text-align: left;"> @ViewEntity con Jmoordb-core</h2><p>Ofrece la posibilidad de crear Vistas de una entidad e incorporarlas dentro de otra entidad, documento embebido o vista mediante el uso de la anotación @ViewEntity se define una vista y se integra mediante el uso de @ViewReferenced.</p><p>Las vistas en jmoordb-core permiten realizar operasciones C.R.U.D. y se pueden integrar en otras vistas, entidades y documentos embebidos.</p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUaS3hRYiL3tNIt0UHF56d2lZvRoajmnoWWDjej_LBa8Rbh8hhHdhtFCYxTgpVmRAc75n6SFrZPatW4Umj220M2mWzuBg-KJXQC4qbMTID6cMctTY2sIk_2T-KV7Q2CVNMsAHcscv81DNE-27YL_ng4wOAUHbYm4TpaD5-cCTzSsPrLPFj1g/s960/referenced.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="960" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUaS3hRYiL3tNIt0UHF56d2lZvRoajmnoWWDjej_LBa8Rbh8hhHdhtFCYxTgpVmRAc75n6SFrZPatW4Umj220M2mWzuBg-KJXQC4qbMTID6cMctTY2sIk_2T-KV7Q2CVNMsAHcscv81DNE-27YL_ng4wOAUHbYm4TpaD5-cCTzSsPrLPFj1g/s16000/referenced.png" /></a></div><br /><p>Un ejemplo de documento almacenado en MongoDB</p><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><br /></pre><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXF37nxNllHByvDr5j5hcPLibXPbV7cwlF3VeQS5iZ0I12-JbL3g6QelhxHRN8pUFNoEG7rJBz1ZufrZ7y7AlERGC1pVqOdpCcZyc8J4_0DA950ExuH--NXpeGVuFfTzEWNY5UO_6DqOWCWxWScjXJSIRF07bkxj8RQDcSfWkbUktbXecQqA/s906/jsonuser.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="722" data-original-width="906" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXF37nxNllHByvDr5j5hcPLibXPbV7cwlF3VeQS5iZ0I12-JbL3g6QelhxHRN8pUFNoEG7rJBz1ZufrZ7y7AlERGC1pVqOdpCcZyc8J4_0DA950ExuH--NXpeGVuFfTzEWNY5UO_6DqOWCWxWScjXJSIRF07bkxj8RQDcSfWkbUktbXecQqA/s16000/jsonuser.png" /></a></div><br /><p><br /></p><p>Mostrare un ejemplo de una referencia sin el uso de vistas.</p><p>Declare una clase de tipo @DocumentEmbeddable</p><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@DocumentEmbeddable
public class Profile {
@Ignore
private Long id;
@Referenced(from = "applicative", localField = "idapplicative")
private Applicative applicative;
@Referenced(from = "role", localField = "idrole")
private Role role;
@Referenced(from = "departament", localField = "iddepartament")
private Departament departament;
//set/get
}
</b></span></span></pre><p>Declare la entidad User</p><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@Entity()
public class User {
@Id(autogeneratedActive = AutogeneratedActive.ON)
private Long iduser;
@Column
private String username;
@Column
private String cellphone;
@Column
private String email;
@Column
private String identificationcard;
@Column
private String sex;
@Column
private String socialsecuritynumber;
@Column
private String name;
@Column
private String password;
@Column
private String photo;
@Column
private Date dateofbirth;
@Referenced(from = "central", localField = "idcentral")
private Central central;
@Embedded
List<Profile> profile;
@Column
private Boolean active;</b></span></span></pre><p><br /></p><p>Omitiremos las otras declaraciones de entidades para no hacer muy larga la demostración.</p><p><br /></p><div class="row" style="background-color: #f2f2f2; box-sizing: border-box; color: #777777; font-family: benton-sans, "Helvetica Neue", helvetica, arial, sans-serif; font-size: 16px; margin-left: -15px; margin-right: -15px;"><div class="col-lg-2 text-right" style="box-sizing: border-box; float: left; min-height: 1px; padding-left: 15px; padding-right: 15px; position: relative; text-align: right; width: 146.234px;"></div></div><div class="row" style="background-color: #f2f2f2; box-sizing: border-box; margin-left: -15px; margin-right: -15px;"><div class="col-lg-10" style="box-sizing: border-box; float: left; min-height: 1px; padding-left: 15px; padding-right: 15px; position: relative; width: 731.25px;"><div role="tabpanel" style="box-sizing: border-box;"><div class="tab-content depTabs" style="box-sizing: border-box;"><div class="tab-pane depTab maven active" role="tabpanel" style="box-sizing: border-box; visibility: visible;"><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@Entity
public class Departament {
@Id(autogeneratedActive = AutogeneratedActive.ON)
private Long iddepartament;
@Column
private String departament;
@Column
private String shortname;
@Column
private Boolean active;
@Referenced(from = "central", localField = "idcentral")
private Central central;
// set/get
}
@Entity
public class Role {
@Id(autogeneratedActive = AutogeneratedActive.ON)
private Long idrole;
@Column
private Boolean active;
@Column
private String role;
//set/get
}
<br /></b></span></span></pre></div></div></div></div></div><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>.</p><p><br /></p><p>Applicative</p><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@Entity
public class Applicative {
@Id(autogeneratedActive = AutogeneratedActive.ON)
private Long idapplicative;
@Column
private Boolean active;
@Column
private String applicative;
@Column
private String description;
@Column
private String image;
@Column
private String path;
@Column
private String shortname;
@Embedded
List<Applicativerole> applicativerole;
@Embedded
List<Emailconfiguration> emailconfiguration;
@Embedded
List<Applicativeprivilege> applicativeprivilege;
//set/get
} </b></span></span></pre><p><br /></p><p> Tenga presente que deberá crear una entidad y un repositorio para cada colección de la base de datos que usamos en el ejemplo.</p><p><br /></p><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@Repository(entity = User.class)
public interface UserRepository extends CrudRepository<User, Long> {
@Find
public Optional<User> findByUsername(String username);
@Lookup
public List<User> lookup(Search search);
}</b></span></span></pre><p><br /></p><p>Creee un Controller con Eclipse Microprofile.io para consultar la colección User</p><p><br /></p><p><br /></p><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: #ad895c; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@Path("user")
public class UserController {
@Inject
UserRepository userRepository;
@GET
@RolesAllowed({"admin"})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public List<User> findAll() {
return userRepository.findAll();
}
}</b></span></span></pre><p>Podemos observar el tamaño que nos devuelve ya que al consultar User , obtiene la lista de documento sembebidos Profile(applicative,(tiene documentos embebidos) ,role(es una entidad siemple),Departamente (tiene referencia a Central y Central a Institution)). Tambien se procesa la referencia a Central y esta tiene referencia a Instirution.</p><p>Como puede observar son muchas referencias internas, que tal vez no necesitamos en nuestra aplicación</p><p>Al hacer la consulta, insertando varios documentos con referencias internas podemos obtener una salida como la siguiente.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3EHAYb2OjJ2L3taMtfCE8aPHa9Dg_Cr3C71sYRuKk2BU9IdnyOKTNIe7QuiJqhxVWmeYcIqoS6OPA073JZE4GxvVxdlfrvF_FN4klICv1z6NEC8J0DkcRzl-JCWxUZongUpumu_cYVeaRh7tCtADZUjkX1KaHTvmPh6IT9Shl85fMu8lHug/s805/resultado.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="586" data-original-width="805" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3EHAYb2OjJ2L3taMtfCE8aPHa9Dg_Cr3C71sYRuKk2BU9IdnyOKTNIe7QuiJqhxVWmeYcIqoS6OPA073JZE4GxvVxdlfrvF_FN4klICv1z6NEC8J0DkcRzl-JCWxUZongUpumu_cYVeaRh7tCtADZUjkX1KaHTvmPh6IT9Shl85fMu8lHug/s16000/resultado.png" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /><div style="text-align: left;">Obtendríamos un JSON de gran tamaño</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNR-F0a81L393iQHCdqsWAmE4YJbQuWyz5QAYPvuQIx-VLnQnjOQn5YQAp8sTFZ8nvgQDkUBUtirf6zn8CiGbWPo39iYYZXSvWiN6SyqyGeWWn-xyGeDmoEvN1OS-kzMTEv24ZN8O_ZSuybGyn5iwLFBquCaBLRpQrEy4cFE1OC4FYJmkcXg/s805/json.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="586" data-original-width="805" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNR-F0a81L393iQHCdqsWAmE4YJbQuWyz5QAYPvuQIx-VLnQnjOQn5YQAp8sTFZ8nvgQDkUBUtirf6zn8CiGbWPo39iYYZXSvWiN6SyqyGeWWn-xyGeDmoEvN1OS-kzMTEv24ZN8O_ZSuybGyn5iwLFBquCaBLRpQrEy4cFE1OC4FYJmkcXg/s16000/json.png" /></a></div><br /><div style="text-align: left;"><br /></div><h2 style="text-align: left;">@ViewEntity</h2><div style="text-align: left;"><br /></div><div style="text-align: left;">No necesitamos que se ejecuten consultas sobre referencias internas, ya que deseamos un mejor perfomance de la aplicación y por ejemplo cuando consulto Applicative no deseo obtener todos los elementos, y cuando consulto Departament no necesito que internamente consulte Central ni Institution que son referencias internas.</div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuFIqUz0TD743OHW9KaAo0He_ijdTKiiy8FMQJGaRJxyiwV0Njrg6QxCh2mxg8FDEIIY4BnDtN-veGnyz4b0Obc8eK-AY8ZipD-XBqPRhovhnkL3HnG6BfzyjnOtCk68mBU8t7Z4SI1UWK2C3bGxCVVfri_jC3VdlvxsQnztoIAdRSNNnAiA/s960/ViewEntity.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="720" data-original-width="960" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuFIqUz0TD743OHW9KaAo0He_ijdTKiiy8FMQJGaRJxyiwV0Njrg6QxCh2mxg8FDEIIY4BnDtN-veGnyz4b0Obc8eK-AY8ZipD-XBqPRhovhnkL3HnG6BfzyjnOtCk68mBU8t7Z4SI1UWK2C3bGxCVVfri_jC3VdlvxsQnztoIAdRSNNnAiA/s16000/ViewEntity.png" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"></td></tr></tbody></table><br /><div style="text-align: left;"><br /></div><div style="text-align: left;">Cree una vista mediante la anotación @ViewEntity, observe que solo colocamos algunos atributos omitimos la lista de documentos embebidos</div><div style="text-align: left;"><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: #ad895c; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@ViewEntity(collection = "applicative")
public class ApplicativeView {
@Id(autogeneratedActive = AutogeneratedActive.ON)
private Long idapplicative;
@Column
private Boolean active;
@Column
private String applicative;
@Column
private String description;
@Column
private String image;
@Column
private String path;
@Column
private String shortname;
//set/get
}
</b></span></span></pre></div><div style="text-align: left;"><br /></div><div style="text-align: left;">DepartamentView, eliminamos la referencia a Central.</div><div style="text-align: left;"><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: #ad895c; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@ViewEntity(collection = "departament")
public class DepartamentView {
@Id(autogeneratedActive = AutogeneratedActive.ON)
private Long iddepartament;
@Column
private String departament;
@Column
private String shortname;
@Column
private Boolean active;
//set/get
}
</b></span></span></pre></div><div style="text-align: left;"><br /></div><div style="text-align: left;"><br /></div><div style="text-align: left;">Modifique Profile para que utilice las vistas mediante @ViewReferenced</div><div style="text-align: left;"><br /></div><div style="text-align: left;"><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@DocumentEmbeddable
public class Profile {
@Ignore
private Long id;
@ViewReferenced(from = "applicative", localField = "idapplicative")
private ApplicativeView applicativeView;
@Referenced(from = "role", localField = "idrole")
private Role role;
@ViewReferenced(from = "departament", localField = "iddepartament")
private DepartamentView departamentView;
@Column
private Boolean active;
//set/get
}</b></span></span></pre></div><div style="text-align: left;"><br /></div><div style="text-align: left;">Defina una vista para Central eliminando la referencia a Insitution</div><div style="text-align: left;"><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@ViewEntity(collection = "central")
public class CentralView {
@Id
private Long idcentral;
@Column
private String central;
@Column
private Boolean active;
//set/get
}
</b></span></span></pre></div><div style="text-align: left;">Es necesario definir un Repositorio para cada vista de la misma manera en que lo define para cada Entidad</div><div style="text-align: left;"><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@Repository(entity = DepartamentView.class,collection = "departament")
public interface DepartamentViewRepository extends CrudRepository<DepartamentView, Long> {
@Find
public Optional<DepartamentView> findByDepartament(String departament);
@Lookup
public List<DepartamentView> lookup(Search search);
}
}
</b></span></span></pre></div><div style="text-align: left;"><br /></div><div style="text-align: left;">Edite User.java y coloque un @ViewReferenced a CentralView</div><div style="text-align: left;"><br /></div><div style="text-align: left;"><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@Entity()
public class User {
@Id(autogeneratedActive = AutogeneratedActive.ON)
private Long iduser;
@Column
private String username;
@Column
private String cellphone;
@Column
private String email;
@Column
private String identificationcard;
@Column
private String sex;
@Column
private String socialsecuritynumber;
@Column
private String name;
@Column
private String password;
@Column
private String photo;
@Column
private Date dateofbirth;
@ViewReferenced(from = "central", localField = "idcentral")
private CentralView centralView;
@Embedded
List<Profile> profile;
@Column
private Boolean active;
}</b></span></span></pre></div><div style="text-align: left;"><br /></div><div style="text-align: left;"><br /></div><div style="text-align: left;">Al realizar la consulta puede observar que el tiempo de respuesta es menor y el tamaño del archivo JSON es de 98.19k, comparado con los 261.58kb si usamos referencias.</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR1oC5aW5IxOCJp_klwBKHfCnRtjeEWqt7VTBPuFrhUEKqHKjktX5WzUG5Z99PorV_SVHAcbnE5MLMXukMjLrNnz0BNSIqBumCdAzwfB2lQK1fTmAHX28zXqzYj9mBGK-OjDSLcRObJ6K0i_VGafwxJ0J66jR0tiLEs195R9-_UDxXgICueA/s901/resultadoviewentity.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="585" data-original-width="901" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR1oC5aW5IxOCJp_klwBKHfCnRtjeEWqt7VTBPuFrhUEKqHKjktX5WzUG5Z99PorV_SVHAcbnE5MLMXukMjLrNnz0BNSIqBumCdAzwfB2lQK1fTmAHX28zXqzYj9mBGK-OjDSLcRObJ6K0i_VGafwxJ0J66jR0tiLEs195R9-_UDxXgICueA/s16000/resultadoviewentity.png" /></a></div><br /><h3 style="text-align: left;">Conclusiones</h3><div style="text-align: left;"><ul style="text-align: left;"><li>@ViewEntity permite mejorar los tiempos de respuesta y elimina el llamado a referencias internas en las clases que se implementan.</li><li>Es fácil de utilizar</li><li>Necesita diseñar adecuadamente las funcionalidades para aprovechar los beneficios de las mismas.</li><li>Se esta trabajando en el soporte de jmoordb-core para la especificación Jakarta NoSQL.</li><li><br /></li></ul></div><div style="text-align: left;"><br /></div></div>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-12149775123887867512023-01-20T17:15:00.001-08:002023-01-20T17:15:24.394-08:00Jmoordb-core implementando lookup(Search search) con MicroprofileRest<p> Jmoordb-core implementando lookup(Search search) con MicroprofileRest</p><p>Mostrare como utilizar MicroProfile RestClient con un Microservicio creado con las APIS de Microprofile sobre PayaraMicro.</p><p>Usamos Jmoordb-core para este proyecto</p><pre class="kode language-css code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: #f9ee9a; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b> <properties>
<jakartaee>10.0.0</jakartaee>
<version.payara>6.2022.1</version.payara>
<microprofile.version>5.0</microprofile.version>
<version.jmoordbcore>0.12</version.jmoordbcore>
<version.jmoordbfaces>1.3</version.jmoordbfaces>
<version.jmoordbutilfaces>0.7</version.jmoordbutilfaces>
<version.jmoordbencripter>1.0</version.jmoordbencripter>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>${microprofile.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.health</groupId>
<artifactId>microprofile-health-api</artifactId>
<version>3.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<!--Jakarta Faces
-->
<dependency>
<groupId>jakarta.faces</groupId>
<artifactId>jakarta.faces-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>12.0.0</version>
<classifier>jakarta</classifier>
</dependency>
<!--
lombok
-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>5.1.3</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
<version>6.0.0</version>
</dependency>
<!--
jmoordb-core
-->
<dependency>
<groupId>com.github.avbravo</groupId>
<artifactId>jmoordb-core</artifactId>
<version>${version.jmoordbcore}</version>
</dependency>
<!--
Encriptation
-->
<dependency>
<groupId>com.github.avbravo</groupId>
<artifactId>jmoordbencripter</artifactId>
<version>${version.jmoordbencripter}</version>
</dependency>
</dependencies></b></span></span></pre><p><br /></p><p>Partimos de la idea que contamos con una base de datos en MongoDB y en ella una colección llamada appconfiguration.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhj5qvHNs8IRVViEoj2nVomRvAzTPZvsGn6Bj7u3rvzwsjGeAIvcGYulYJUiX9D1r7fzJf9vgXm9kdUq8CmNWUeWW9nGauXr42qOJ4IFW1XKpBCUsbFtCHy1kgyOIpCzk3i-_JKtg925-j2tIKB1kNo5fajawACw-4tZg8THrsg0t14NNaBuw/s468/01_app.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="364" data-original-width="468" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhj5qvHNs8IRVViEoj2nVomRvAzTPZvsGn6Bj7u3rvzwsjGeAIvcGYulYJUiX9D1r7fzJf9vgXm9kdUq8CmNWUeWW9nGauXr42qOJ4IFW1XKpBCUsbFtCHy1kgyOIpCzk3i-_JKtg925-j2tIKB1kNo5fajawACw-4tZg8THrsg0t14NNaBuw/s16000/01_app.png" /></a></div><br /><p>Es una entidad que contiene una lista de documentos referenciados a una colección llamada role.</p><p>Definimos la entidad Role </p><pre class="kode language-css code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>import com.jmoordb.core.annotation.Column;
import com.jmoordb.core.annotation.Entity;
import com.jmoordb.core.annotation.Id;
import com.jmoordb.core.annotation.enumerations.AutogeneratedActive;
/**
*
* @author avbravo
*/
@Entity
public class Role {
@Id(autogeneratedActive = AutogeneratedActive.ON)
private Long idrole;
@Column
private Boolean active;
@Column
private String role;
// constructor set/get
}</b></span></span></pre><p>Defina la entidad Appconfiguration especificando la referencia</p><pre class="kode language-css code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>import com.jmoordb.core.annotation.Column;
import com.jmoordb.core.annotation.Entity;
import com.jmoordb.core.annotation.Id;
import com.jmoordb.core.annotation.Referenced;
import com.jmoordb.core.annotation.enumerations.AutogeneratedActive;
import java.util.List;
/**
*
* @author avbravo
*/
@Entity()
public class Appconfiguration {
@Id(autogeneratedActive = AutogeneratedActive.ON)
private Long idappconfiguration;
@Column
private Boolean active;
@Referenced(from = "applicative", localField = "idapplicative")
private Applicative applicative;
@Referenced(from = "role", localField = "idrole")
private List<Role> role;
// constructor set/get
}</b></span></span></pre><p>Cree el repositorio para la entidad Role</p><pre class="kode language-css code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>
import com.jmoordb.core.annotation.repository.Lookup;
import com.jmoordb.core.annotation.repository.Repository;
import com.jmoordb.core.model.Search;
import com.jmoordb.core.repository.CrudRepository;
import com.sft.model.Role;
import java.util.List;
/**
*
* @author avbravo
*/
@Repository(entity = Role.class)
public interface RoleRepository extends CrudRepository<Role, Long> {
@Lookup
public List<Role> lookup(Search search);
}</b></span></span><span style="color: white; font-family: Consolas, Monaco, "andale mono", "ubuntu mono", monospace; font-size: 16px; font-weight: 700;">
</span></pre><div><br /></div><p>Cree el repositorio para la entidad Role</p><pre class="kode language-css code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>@Repository(database = "{mongodb.database1}", entity = Actividad.class)
public interface ActividadRepository extends CrudRepository<Actividad, Long>{
@Lookup
public List<Actividad> lookup(Search search);
}
// constructor set/get
}</b></span></span></pre><p>Cree el controller y defina el método lookup</p><p><br /></p><p><br /></p><pre class="kode language-css code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>@Path("appconfiguration")
@Tag(name = "Información del appconfiguration", description = "End-point para entidad Appconfiguration")
@RolesAllowed({"admin"})
public class AppconfigurationController {
@Inject
AppconfigurationRepository appconfigurationRepository;
@GET
@Path("lookup")
@RolesAllowed({"admin"})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public List<Appconfiguration> lookup(@QueryParam("filter") String filter, @QueryParam("sort") String sort, @QueryParam("page") Integer page, @QueryParam("size") Integer size) {
Search search = DocumentUtil.convertForLookup(filter, sort, page, size);
return appconfigurationRepository.lookup(search);
}
}</b></span></span></pre><p><br /></p><p>Luego creamos un proyecto nuevo e implementamos Microprofile RestClient</p><p>Para ello defina en el archivo microprofile-config.properties la referencia a mp-rest indicado la clase que hara la implementación y el iurl</p><pre class="kode language-css code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>com.sft.client.AppconfigurationClient/mp-rest/url=http://localhost:9002/accreditation/api/</b></span></span></pre><p>Proceda a crear la interface AppconfigurationClient</p><pre class="kode language-css code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>package com.sft.client;
@RegisterRestClient()
@Path("/appconfiguration")
public interface AppconfigurationClient {
@GET
@Path("lookup")
public List<Appconfiguration> lookup(@QueryParam("filter") String filter, @QueryParam("sort") String sort, @QueryParam("page") Integer page, @QueryParam("size") Integer size);
}</b></span></span></pre><p><br /></p><p>Cree una clase desde la cual inyectara AppconfigurationClient</p><pre class="kode language-css code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>@Named
@SessionScoped
public class LoginFaces implements Serializable {
@Inject
AppconfigurationClient appconfigurationClient;
public List<Appconfiguration> searchAppConfiguration() {
try {
Integer page = 1;
Integer size = 1;
Bson filter = new Document("applicative.idapplicative", idapplicative.get().longValue());
Document sort = new Document("applicative.idapplicative", 1);
return appconfigurationClient.lookup(
EncodeUtil.encodeBson(filter),
EncodeUtil.encodeBson(sort),
page, size);
} catch (Exception e) {
FacesUtil.errorMessage(FacesUtil.nameOfMethod() + " " + e.getLocalizedMessage());
}
return new ArrayList<>();
}
}</b></span></span></pre><p><br /></p><p>Puede observar que el filtro es un BSON de MongoDB y el Sort es un Document de MongoDB, aplicamos un encode mediante EncodeUtil.encodeBson() e invocamos el método de la interface que corresponde al endopoint.</p><p>La utilización de Microprofile RestClient nos ayuda mucho para establecer la comunicación con los endpoint.</p><p><br /></p><p><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-75978977916569106332022-11-15T19:31:00.001-08:002022-11-15T19:31:08.754-08:00Probando Jmoordb-core con Helidon <p> En esta ocasión ejecute pruebas de jmoord-core con Helidon y MongoDB.</p><p>Los resultados fueron muy interesantes , un inicio rápido de las aplicaciones y un buen performance de la misma con un bajo consumo de recursos.</p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/nxJu6Nfw3HA" width="320" youtube-src-id="nxJu6Nfw3HA"></iframe></div><br /><p><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-5206100008950087502022-11-11T08:05:00.004-08:002022-11-11T09:55:38.889-08:00Probando Jmoordb-core con Quarkus 3.0 Alpha Jakarta EE 10<p> En el siguiente video se muestra como implementar un proyecto con Quarkus 3.0 Alpha 1 con Jmoordb-core , usando Jakarta EE 10, con una base de datos MongoDB.</p><p><a href="https://code.quarkus.io/?S=io.quarkus.platform%3A3.0">https://code.quarkus.io/?S=io.quarkus.platform%3A3.0</a></p><p>Luego lo descargamos y agregamos el repositorio</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; color: white; font-family: Consolas, Monaco, "andale mono", "ubuntu mono", monospace; font-size: 16px; font-weight: 700; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><code class=" kode language-markup" style="background: 0px 0px; border-radius: 0px; box-sizing: border-box; font-family: Consolas, Monaco, "andale mono", "ubuntu mono", monospace; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0px; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal; word-spacing: normal;"> <span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"><</span>repositories</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>
<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"><</span>repository</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>
<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"><</span>id</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>jitpack.io<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"></</span>id</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>
<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"><</span>url</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>https://jitpack.io<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"></</span>url</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>
<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"></</span>repository</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>
<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"></</span>repositories</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span></code></pre><p><br /></p><p>Y añadimos las dependencias</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><code class=" kode language-markup" style="background: 0px 0px; border-radius: 0px; box-sizing: border-box; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0px; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px; word-spacing: normal;"><b> </b></span><span style="font-size: 16px;"><b><dependency>
<groupId>com.github.avbravo</groupId>
<artifactId>jmoordb-core</artifactId>
<version>0.2</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
<version>2.12.3.Final</version>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api</artifactId>
<version>5.0.0-RC4</version>
<type>jar</type>
</dependency></b></span><span style="font-size: 16px; word-spacing: normal;"><b>
<br /></b></span></span></code></pre><p>Creamos el archivo microprofile-config.properties dentro de META-INF.</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>#-- Jmoordb-core
mongodb.uri=mongodb://localhost:27017
#-- Database de configuración
mongodb.jmoordb= configurationjmoordbdb
#-- Database
mongodb.database=ejemplodb
mongodb.database1=test
mongodb.database2=prueba</b></span></span></pre><p>Crear la clase MongoDBProducer, observe que se utiliza jakarta en lugar de javax en varios paquetes,</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import java.io.Serializable;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Disposes;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.inject.ConfigProperty;
@ApplicationScoped
@DateSupport()
public class MongoDBProducer implements Serializable {
@Inject
private Config config;
@Inject
@ConfigProperty(name = "mongodb.uri")
private String mongodburi;
@Produces
@ApplicationScoped
public MongoClient mongoClient() {
MongoClient mongoClient = MongoClients.create(mongodburi);
return mongoClient;
}
public void close(@Disposes final MongoClient mongoClient) {
mongoClient.close();
}
}</b></span></span></pre><div><code class=" kode language-markup" style="background: 0px 0px; border-radius: 0px; box-sizing: border-box; font-family: Consolas, Monaco, "andale mono", "ubuntu mono", monospace; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0px; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal; word-spacing: normal;"><span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"><br /></span></span></code></div><p><br /></p><p>Defina la entodad</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><code class=" kode language-markup" style="background: 0px 0px; border-radius: 0px; box-sizing: border-box; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0px; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px; word-spacing: normal;"><b> </b></span></span><span style="color: #ad895c; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>@Entity()
public class Pais {
@Id(autogeneratedActive = AutogeneratedActive.ON)
private Long idpais;
@Column
private String pais;
@Column
private Date fecha;</b></span></span><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px; word-spacing: normal;"><b>
}</b></span></span></code></pre><div><code class=" kode language-markup" style="background: 0px 0px; border-radius: 0px; box-sizing: border-box; font-family: Consolas, Monaco, "andale mono", "ubuntu mono", monospace; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0px; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal; word-spacing: normal;"><span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"><br /></span></span></code></div><p>Utilizamos un repositorio</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: #ad895c; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>@Repository(entity = Pais.class)
public interface PaisRepository extends CrudRepository<Pais, Long> {
}</b></span></span></pre><div><code class=" kode language-markup" style="background: 0px 0px; border-radius: 0px; box-sizing: border-box; font-family: Consolas, Monaco, "andale mono", "ubuntu mono", monospace; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0px; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal; word-spacing: normal;"><span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"><br /></span></span></code></div><p>Creamos un Controller</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: #ad895c; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>@Path("pais")
public class PaisController {
@Inject
PaisRepository paisRepository;
@GET
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public List<Pais> findAll() {
return paisRepository.findAll();
}
}</b></span></span></pre><div><span style="color: #ad895c; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b><br /></b></span></span></div><p><br /></p><p>Ejecutamos la aplicación </p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: #ad895c; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>quarkus dev</b></span></span></pre><div><span style="color: #ad895c; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b><br /></b></span></span></div><p>Podemos consultar el resultado mediante Postman</p><p><span style="background-color: #212121; color: white; font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", Helvetica, Arial, sans-serif; font-size: 12px; white-space: pre-wrap;">http://localhost:8080/pais</span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLzCKMrgxvZxb_xqGrbpjrK0uXa4aKwfW5iOcDnZkK3T9N13EMZKmV_qSR63Qlcnlu1dd1p3DqqnuLbn4h3YTDYgiFyZ-A1NRWpIc3plF37A3W9oqO_L7lU_xBim3MA-Bry2fZkl9Bi0D5r607IzG-UsW4iiPnwd57aeS2ZrcWPrFuwkAh7g/s737/Captura%20desde%202022-11-11%2012-49-25.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="190" data-original-width="737" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLzCKMrgxvZxb_xqGrbpjrK0uXa4aKwfW5iOcDnZkK3T9N13EMZKmV_qSR63Qlcnlu1dd1p3DqqnuLbn4h3YTDYgiFyZ-A1NRWpIc3plF37A3W9oqO_L7lU_xBim3MA-Bry2fZkl9Bi0D5r607IzG-UsW4iiPnwd57aeS2ZrcWPrFuwkAh7g/s16000/Captura%20desde%202022-11-11%2012-49-25.png" /></a></div><br /><p><br /></p><p>Video explicativo</p><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/6PjC7OcZqC4" width="320" youtube-src-id="6PjC7OcZqC4"></iframe></div><br /><p><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-9130273076214186212022-11-04T19:54:00.002-07:002022-11-04T19:54:20.702-07:00Probando PayaraMicro Payara Micro 6.2022.1 Jakarta 10.0 con Jmoordb-core<p> Recientemente Payara realizo la liberación de <a href="https://www.payara.fish/downloads/payara-platform-community-edition/?utm_content=227059572&utm_medium=social&utm_source=twitter&hss_channel=tw-2599580401">Payara 6 Community</a>, con soporte para Jakarta EE 10. realizamos las pruebas de jmoordb-core con MongoDB en esta nueva versión.</p><p>Agregamos las dependencias</p><p><br /></p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b> <properties>
<jakartaee>10.0.0</jakartaee>
<version.payara>6.2022.1</version.payara>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>${microprofile.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.github.avbravo</groupId>
<artifactId>jmoordb-core-processor</artifactId>
<version>1.0.10</version>
</dependency>
</dependencies>
<build>
<finalName>${final.name}</finalName>
<plugins>
<plugin>
<groupId>fish.payara.maven.plugins</groupId>
<artifactId>payara-micro-maven-plugin</artifactId>
<configuration>
<payaraVersion>${version.payara}</payaraVersion>
<deployWar>false</deployWar>
<commandLineOptions>
<option>
<key>--autoBindHttp</key>
</option>
<option>
<key>--deploy</key>
<value>${project.build.directory}/${project.build.finalName}</value>
</option>
</commandLineOptions>
</configuration>
<version>1.3.0</version>
</plugin>
</plugins>
</build></b></span></span></pre><p><br /></p><p><br /></p><p>Podemos ver la ejecución</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4sTGgaKJCwbywRkGlWzcauIJDcI9byym9SXjmENEptkPhamM3zV-yEx9P87a2xIiopfnaMGD2v6YHWFbAcaFRkbVTzDXEubmtQtKX4ntJYX4WEb7NqNE75rH3n1YAh_QRIC8O17IDgUlg3NN_Jj9x4f9yGDUaPm2uQrc5bhZfS0KBXu3D4A/s1363/ejecucion.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="726" data-original-width="1363" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4sTGgaKJCwbywRkGlWzcauIJDcI9byym9SXjmENEptkPhamM3zV-yEx9P87a2xIiopfnaMGD2v6YHWFbAcaFRkbVTzDXEubmtQtKX4ntJYX4WEb7NqNE75rH3n1YAh_QRIC8O17IDgUlg3NN_Jj9x4f9yGDUaPm2uQrc5bhZfS0KBXu3D4A/s16000/ejecucion.png" /></a></div><br /><p><br /></p><p>Puedes ver el video en el siguiente enlace</p><p><a href="https://www.youtube.com/watch?v=qI5LTZjNXww">Jmoordb.core Payara Micro 6</a><br /></p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/qI5LTZjNXww" width="320" youtube-src-id="qI5LTZjNXww"></iframe></div><br /><p><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-36524508024889630352022-11-02T19:26:00.005-07:002022-11-02T19:28:13.449-07:00Pruebas de referencias en MongoDB + jmoordbCore<p>Pruebas de Referencias y Embebidos </p><p>Se muestra un ejemplo de referencias de varios niveles entre colecciones de MongoDB utilizando Jmoordb.core.</p><p>Coleciones de MongoDB</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgC0uevtxV75eqqRPEUfiMu1yKZVZ_8MFndufFmWqHxTola-vsZT3JvUtEDEqv6k_9p9lTAHu9xMvZP49E1RCSqNE_6etDTpOiqyhfH8wt1x78TaAO-_77jJCL3nGdphH_oYpeWuhazNVYf31tZPiFPSbfa9GjBiC_17_60DpBzCq48DEMCSQ/s346/figure02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="346" data-original-width="286" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgC0uevtxV75eqqRPEUfiMu1yKZVZ_8MFndufFmWqHxTola-vsZT3JvUtEDEqv6k_9p9lTAHu9xMvZP49E1RCSqNE_6etDTpOiqyhfH8wt1x78TaAO-_77jJCL3nGdphH_oYpeWuhazNVYf31tZPiFPSbfa9GjBiC_17_60DpBzCq48DEMCSQ/s320/figure02.png" width="265" /></a></div><br /><p><br /></p><p><br /></p><p>Ejemplo de entidad: Persona</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@Entity(jakartaSource = JakartaSource.JAVAEE_LEGACY)
public class Persona {
@Id(autogeneratedActive = AutogeneratedActive.ON)
private Long idpersona;
@Column
private String nombre;
@Embedded
private Deporte deporte;
@Embedded
private List<Musica> musica;
@Referenced(from = "pais", localField = "idpais", typeReferenced = TypeReferenced.REFERENCED)
private Pais pais;
@Referenced(from = "animal", localField = "idanimal", typeReferenced = TypeReferenced.REFERENCED)
private List<Animal> animal;
</b></span></span></pre><p><br /></p><p>Ejemplo de entidad Animal. Se puede observar que tiene referencias a otras colecciones y documentos embebidos, que tienen referencias.</p><p><br /></p><div class="row" style="background-color: #f2f2f2; box-sizing: border-box; color: #777777; font-family: benton-sans, "helvetica neue", helvetica, arial, sans-serif; font-size: 16px; margin-left: -15px; margin-right: -15px;"><div class="col-lg-2 text-right" style="box-sizing: border-box; float: left; min-height: 1px; padding-left: 15px; padding-right: 15px; position: relative; text-align: right; width: 146.234px;"></div></div><div class="row" style="background-color: #f2f2f2; box-sizing: border-box; margin-left: -15px; margin-right: -15px;"><div class="col-lg-10" style="box-sizing: border-box; float: left; min-height: 1px; padding-left: 15px; padding-right: 15px; position: relative; width: 731.25px;"><div role="tabpanel" style="box-sizing: border-box;"><div class="tab-content depTabs" style="box-sizing: border-box;"><div class="tab-pane depTab maven active" role="tabpanel" style="box-sizing: border-box; visibility: visible;"><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: black 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal;"><code class="kode language-markup" id="depCode" style="background: none; border-radius: 0px; box-sizing: border-box; color: white; font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 16px; font-weight: bold; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0px; tab-size: 4; text-shadow: black 0px -0.1em 0.2em; word-break: normal; word-spacing: normal;"> </code><span style="color: #ad895c; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;"><span style="font-size: 16px;"><b>@Entity(jakartaSource = JakartaSource.JAVAEE_LEGACY)
public class Animal {
@Id(autogeneratedActive = AutogeneratedActive.ON)
private Long idanimal;
@Column
private String animal;
@Embedded
private Especie especie;
@Embedded
private List<Plaga> plaga;
@Referenced(from = "grupo",localField = "idgrupo",typeReferenced = TypeReferenced.REFERENCED)
private Grupo grupo;
@Referenced(from="zoo",localField = "idzoo",typeReferenced = TypeReferenced.REFERENCED)
private List<Zoo> zoo;</b></span></span></pre></div></div></div></div></div><p><br /></p><p><br /></p><p>Consulta con Postman</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4ClRAJIMHnauwFgQ8pfWvQ9ot04SsDzuQR2gFQ8RdcuQgoBeOb-Yf_Z4LuA8ADJpwZNX-bkTeX9kWNfjD20UZtN9YbfnwkvLCtanuZ6eFmzgV7MkIydbRew_5lNHIhaSYSYxh9GZVIhYqUKjkPtsrdXod4MxIUJOUspY-HgLOp8qrVqD9TQ/s1082/figure01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="666" data-original-width="1082" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4ClRAJIMHnauwFgQ8pfWvQ9ot04SsDzuQR2gFQ8RdcuQgoBeOb-Yf_Z4LuA8ADJpwZNX-bkTeX9kWNfjD20UZtN9YbfnwkvLCtanuZ6eFmzgV7MkIydbRew_5lNHIhaSYSYxh9GZVIhYqUKjkPtsrdXod4MxIUJOUspY-HgLOp8qrVqD9TQ/s16000/figure01.png" /></a></div><br /> <p></p><p>Datos:</p><p><b>Colleccion: </b></p><p>Pais: 439613 documentos</p><p>Persona: 12127 documentos</p><p>Animal: 2 documentos</p><p>Especie: 2 documentos</p><p>Grupo: 3 documentos</p><p>Zoo: 2 documentos</p><p><br /></p><p><b>Software:documentos</b></p><p>PayaraMicro</p><p>Microprofile</p><p>JmorodbCore</p><p>MongoDB</p><p><br /></p><p><b>-Hardware:</b></p><p>8GB RAM</p><p>Procesador Intel Core i3</p><p><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-7758169041851411562022-11-01T10:40:00.007-07:002022-11-01T10:40:55.264-07:00Documentos Referenciados con jmoordb-core<p> Los documentos reverenciados en jmoordb -core se basan en el principio de que estos son documentos embebidos en la colección, en los cuales podemos especificar si deben ser consultados en otra colección o se utilizan los documentos de la misma colección.</p><p><br /></p><p>En el ejemplo contados con tres colecciones Animal, Grupo , Zoo. Dentro de animal tenemos dos documentos embebidos Zoo y Especie.</p><p>Colección Grupo</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>
/* 0 */
{
"_id" : ObjectId("63613acfc6acae0fad901685"),
"grupo" : "Mamifero",
"idgrupo" : "mamifero"
}
/* 1 */
{
"_id" : ObjectId("63613afec6acae0fad901686"),
"grupo" : "Aves",
"idgrupo" : "aves"
}
/* 2 */
{
"_id" : ObjectId("63613b19c6acae0fad901687"),
"grupo" : "Reptiles",
"idgrupo" : "reptiles"
}</b></span></span><span style="color: white; font-family: Consolas, Monaco, "andale mono", "ubuntu mono", monospace; font-size: 16px; font-weight: 700;">
</span></pre><div><br /></div><p><br /></p><p>Colección Zoo</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>
/* 0 */
{
"_id" : ObjectId("63613a91c6acae0fad901683"),
"idzoo" : "panama",
"nombre" : "Zoo de Panama"
}
/* 1 */
{
"_id" : ObjectId("63613aa1c6acae0fad901684"),
"idzoo" : "china",
"nombre" : "Zoo de China"
}</b></span></span><span style="color: white; font-family: Consolas, Monaco, "andale mono", "ubuntu mono", monospace; font-size: 16px; font-weight: 700;">
</span></pre><div><br /></div><p><br /></p><p>Colección Animal</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>
{
"animal": "Perro",
"idanimal": NumberLong(1),
"especie":{
"nombre":"perropequeño"
},
"plaga": [
{
"nombre": "pulgas"
},
{
"nombre": "garrapatas"
}
],
"grupo": {
"grupo": "Mamifero",
"idgrupo": "mamifero"
},
"zoo": [
{
"idzoo": "panama",
"nombre": "Zoo de Panama"
}
,
{
"idzoo": "china",
"nombre": "Zoo de China"
}
]
}</b></span></span></pre><p><br /></p><p>Observe que aunque sean documentos referenciados estos se almacenan como documentos embebidos dentro de la colección principal. Esto nos permite que especifiquemos el mecanismo de consulta a realizar.</p><p><br /></p><p>Entidad Animal, utilizando @Referenced TypeReferenced.EMBEDDED si la utilizamos como un documento embebido no se harán consultas sobre la colección referenciada, se cargara el documento embebido por lo tanto se obtiene un mejor desempeño en la operación.</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>@Entity(jakartaSource = JakartaSource.JAVAEE_LEGACY)
public class Animal {
@Id(autogeneratedActive = AutogeneratedActive.ON)
private Long idanimal;
@Column
private String animal;
@Embedded
private Especie especie;
@Embedded
private List<Plaga> plaga;
@Referenced(from = "grupo",localField = "idgrupo",typeReferenced = TypeReferenced.EMBEDDED)
private Grupo grupo;
@Referenced(from="zoo",localField = "idzoo",typeReferenced = TypeReferenced.REFERENCED)
private List<Zoo> zoo;
</b></span></span></pre><p><br /></p><p>Al compilar el proyecto genera un código similar a este segmento que se muestra a continuación. Observe que grupo aunque es una referencia se maneja como documento embebido.</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><code class=" kode language-markup" style="background: 0px 0px; border-radius: 0px; box-sizing: border-box; color: white; font-family: Consolas, Monaco, "andale mono", "ubuntu mono", monospace; font-size: 16px; font-weight: 700; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0px; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal; word-spacing: normal;"> </code><span style="color: #ad895c; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>public Animal get(Supplier<? extends Animal> s, Document document_) {
Animal animal= s.get();
try {
animal.setIdanimal(document_.getLong("idanimal"));
animal.setAnimal(document_.getString("animal"));
// Embedded of especie
animal.setEspecie((Especie) document_.get("especie"));
// Embedded List<plaga>
List<Plaga> plagaList = new ArrayList<>();
List<Document> plagaDoc = (List) document_.get("plaga");
for( Document docPlaga : plagaDoc){
Plaga plaga = plagaSupplier.get(Plaga::new, docPlaga);
plagaList.add(plaga);
};
animal.setPlaga(plagaList);
// Embedded of grupo
animal.setGrupo((Grupo) document_.get("grupo"));
// Referenced List<zoo>
List<Document> zooDocumentList = (List)document_.get("zoo");
List<Zoo> zooList = new ArrayList<>();
for( Document zooDoc :zooDocumentList){
Zoo zoo = zooSupplier.get(Zoo::new,zooDoc);
Optional<Zoo> zooOptional = zooRepository.findByPk(zoo.getIdzoo());
if(zooOptional.isPresent()){
zooList.add(zooOptional.get());
}
}
animal.setZoo(zooList);</b></span></span></pre><p><br /></p><p><br /></p><p>Ahora si editamos la entidad Animal y especificamos la referencia a Grupo como<b> TypeReferenced.REFERENCED, </b> Se realizara una consulta a la colección Grupo. En el framework evitamos el uso de los $Lookup de MongoDB , para mejorar el desempeño de las operaciones.</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b> @Entity(jakartaSource = JakartaSource.JAVAEE_LEGACY)
public class Animal {
@Id(autogeneratedActive = AutogeneratedActive.ON)
private Long idanimal;
@Column
private String animal;
@Embedded
private Especie especie;
@Embedded
private List<Plaga> plaga;
@Referenced(from = "grupo",localField = "idgrupo",typeReferenced = TypeReferenced.REFERENCED)
private Grupo grupo;
@Referenced(from="zoo",localField = "idzoo",typeReferenced = TypeReferenced.REFERENCED)
private List<Zoo> zoo;</b></span></span></pre><p>Al compilar el proyecto se genera el siguiente código</p><p><br /></p><pre class="kode language-css code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><code class=" kode language-css" style="background: 0px 0px; border-radius: 0px; box-sizing: border-box; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0px; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px; word-spacing: normal;"><b>
</b></span><span style="font-size: 16px;"><b> public Animal get(Supplier<? extends Animal> s, Document document_) {
Animal animal= s.get();
try {
animal.setIdanimal(document_.getLong("idanimal"));
animal.setAnimal(document_.getString("animal"));
// Embedded of especie
animal.setEspecie((Especie) document_.get("especie"));
// Embedded List<plaga>
List<Plaga> plagaList = new ArrayList<>();
List<Document> plagaDoc = (List) document_.get("plaga");
for( Document docPlaga : plagaDoc){
Plaga plaga = plagaSupplier.get(Plaga::new, docPlaga);
plagaList.add(plaga);
};
animal.setPlaga(plagaList);
// @Referenced of grupo how Referenced
Grupo grupo = (Grupo) document_.get("grupo");
animal.setGrupo(grupoRepository.findByPk(grupo.getIdgrupo()).get());
// Referenced List<zoo>
List<Document> zooDocumentList = (List)document_.get("zoo");
List<Zoo> zooList = new ArrayList<>();
for( Document zooDoc :zooDocumentList){
Zoo zoo = zooSupplier.get(Zoo::new,zooDoc);
Optional<Zoo> zooOptional = zooRepository.findByPk(zoo.getIdzoo());
if(zooOptional.isPresent()){
zooList.add(zooOptional.get());
}
}
animal.setZoo(zooList);
} catch (Exception e) {
MessagesUtil.error(MessagesUtil.nameOfClassAndMethod() + " " + e.getLocalizedMessage());
}
return animal;
}</b></span><span style="font-size: 16px; word-spacing: normal;"><b>
</b></span></span></code></pre><p><br /></p><p>Usted puede utilizar a su conveniencia esta caracteristica</p><p><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-19560413128304932512022-10-28T14:09:00.002-07:002022-10-28T14:09:11.340-07:00Jmoordb-core-quarkus <p> Jmoordb-core-quarkus es la implementación que estamos desarrollando de Jmoordb-core, para intregaciñón con Quarkus y generar imágenes nativa.</p><p><br /></p><p>Solo necesitas agregar a tu proyecto Quarkus</p><pre class="kode language-markup code-toolbar" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; color: white; font-family: Consolas, Monaco, "andale mono", "ubuntu mono", monospace; font-size: 16px; font-weight: 700; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><code class=" kode language-markup" style="background: 0px 0px; border-radius: 0px; box-sizing: border-box; font-family: Consolas, Monaco, "andale mono", "ubuntu mono", monospace; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0px; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal; word-spacing: normal;"><span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"><</span>repositories</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>
<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"><</span>repository</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>
<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"><</span>id</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>jitpack.io<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"></</span>id</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>
<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"><</span>url</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>https://jitpack.io<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"></</span>url</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>
<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"></</span>repository</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>
<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"></</span>repositories</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span></code></pre><p><br /></p><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; color: white; font-family: Consolas, Monaco, "andale mono", "ubuntu mono", monospace; font-size: 16px; font-weight: 700; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><code class="kode language-markup" id="depCode" style="background: 0px 0px; border-radius: 0px; box-sizing: border-box; font-family: Consolas, Monaco, "andale mono", "ubuntu mono", monospace; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0px; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal; word-spacing: normal;"> <span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"><</span>dependency</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>
<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"><</span>groupId</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>com.github.avbravo<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"></</span>groupId</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>
<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"><</span>artifactId</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>jmoordb-core-processor-quarkus<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"></</span>artifactId</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>
<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"><</span>version</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>0.1<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"></</span>version</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span>
<span class="token tag" style="box-sizing: border-box; color: #ad895c; position: relative; z-index: 1;"><span class="token tag" style="box-sizing: border-box; position: relative; z-index: 1;"><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;"></</span>dependency</span><span class="token punctuation" style="box-sizing: border-box; opacity: 0.7; position: relative; z-index: 1;">></span></span></code></pre><p><br /></p><p><br /></p><p>Agregue la configuración al archivo application.properties</p><p>quarkus.mongodb.connection-string = mongodb://localhost:27017</p><p><br /></p><p><b>Cree una entidad</b></p><p><b><br /></b></p><p><b><br /></b></p><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; color: white; font-family: Consolas, Monaco, "andale mono", "ubuntu mono", monospace; font-size: 16px; font-weight: 700; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><p>@Entity(jakartaSource = JakartaSource.JAVAEE_LEGACY)</p><p>public class Pais {</p><p> @Id(autogeneratedActive = AutogeneratedActive.ON)</p><p> private Long idpais;</p><p> </p><p> @Column</p><p> private String pais;</p><p> </p><p> @Column</p><p> private Date fecha;</p><p><br /></p><p> public Pais() {</p><p> }</p><p>}</p><p><br style="color: black; font-family: "Times New Roman"; font-size: medium; font-weight: 400; white-space: normal;" /></p></pre><p><br /></p><p><br /></p><p><b>Cree un Repository</b></p><p><b><br /></b></p><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>@Repository(entity = Pais.class, jakartaSource = JakartaSource.JAVAEE_LEGACY)
public interface PaisRepository extends CrudRepository<Pais, Long> {
@Find
public List<Pais> findByFechaGreaterThanEqualAndFechaLessThanEqualAndPais(@ExcludeTime Date start, @ExcludeTime Date end, String pais);
}</b></span></span></pre><p><br /></p><p><br /></p><p><br /></p><p><b>Cree una clase llamada MongoDBProducer</b></p><p><br /></p><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>import com.jmoordb.core.annotation.DateSupport;
import com.jmoordb.core.annotation.enumerations.JakartaSource;
import java.io.Serializable;
import javax.enterprise.context.ApplicationScoped;
@ApplicationScoped
@DateSupport(jakartaSource = JakartaSource.JAVAEE_LEGACY)
public class MongoDBProducer implements Serializable {
}</b></span></span></pre><p><br /></p><p><br /></p><p><b>Cree el endpoint</b></p><p><br /></p><pre class="kode code-toolbar language-markup" style="background: rgb(20, 20, 20); border-radius: 0.5em; border: 0.3em solid rgb(84, 84, 84); box-shadow: rgb(0, 0, 0) 1px 1px 0.5em inset; box-sizing: border-box; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; overflow-wrap: normal; overflow: auto; padding: 1em; position: relative; tab-size: 4; text-shadow: rgb(0, 0, 0) 0px -0.1em 0.2em; word-break: normal;"><span style="color: white; font-family: Consolas, Monaco, andale mono, ubuntu mono, monospace;"><span style="font-size: 16px;"><b>import com.jmoordb.core.annotation.date.DateFormat;
import com.jmoordbcore.model.Pais;
import com.jmoordbcore.repository.PaisRepository;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import javax.inject.Inject;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/**
*
* @author avbravo
*/
@Path("pais")
public class PaisController {
// <editor-fold defaultstate="collapsed" desc="Inject">
@Inject
PaisRepository paisRepository;
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="findAll">
@GET
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public List<Pais> findAll() {
return paisRepository.findAll();
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Pais findByIdpais">
// <editor-fold defaultstate="collapsed" desc="Response save">
@POST
public Response save(Pais pais) {
pais.setFecha(new Date());
return Response.status(Response.Status.CREATED).entity(paisRepository.save(pais)).build();
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Response update">
@PUT
public Response update( Pais pais) {
pais.setFecha(new Date());
return Response.status(Response.Status.CREATED).entity(paisRepository.save(pais)).build();
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Response delete">
@DELETE
@Path("{idpais}")
public Response delete(@PathParam("idpais") Long idpais) {
paisRepository.deleteByPk(idpais);
return Response.status(Response.Status.NO_CONTENT).build();
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="@Path("fechagreaterthanequalandfechalessthanequalandpais")">
@Path("fechagreaterthanequalandfechalessthanequalandpais")
@GET
public List<Pais> findByFechaGreaterThanEqualAndFechaLessThanEqualAndPais(@QueryParam("fecha") @DateFormat final Date fecha, @QueryParam("fechafinal") @DateFormat final Date fechafinal, @QueryParam("pais") String pais) {
return paisRepository.findByFechaGreaterThanEqualAndFechaLessThanEqualAndPais(fecha, fechafinal, pais);
}
// </editor-fold>
}</b></span></span></pre><p><br /></p><p><br /></p><p><b>Crear la imagen nativa</b></p><p>./mvnw package -Pnative </p><p><br /></p><p>Ejecutar nuestra imagen nativa mediante</p><p>./target/capitulo25-1.0.0-SNAPSHOT-runner </p><p>Observe el tiempo en que demora en ejecutar la aplicación 0.003s</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjg8ewpr6vvRCrhaG5aoVGNumq6g_kxMiu4KrB5csV1pTnHjCuz6YkkgBPVMNN2vWE2P4j1pLgAZVBITbD4Lh4Nz3CZpkG9OL1gRKuRuwGpPClEwohBG-OBKHM-lTNFizZHsDfgsUYSnBn2CxI2lzU2BvrIc-cORy6W05Ag16-bQf-mZ9lgRQ/s1039/Captura%20desde%202022-10-28%2015-58-12.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="221" data-original-width="1039" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjg8ewpr6vvRCrhaG5aoVGNumq6g_kxMiu4KrB5csV1pTnHjCuz6YkkgBPVMNN2vWE2P4j1pLgAZVBITbD4Lh4Nz3CZpkG9OL1gRKuRuwGpPClEwohBG-OBKHM-lTNFizZHsDfgsUYSnBn2CxI2lzU2BvrIc-cORy6W05Ag16-bQf-mZ9lgRQ/s16000/Captura%20desde%202022-10-28%2015-58-12.png" /></a></div><br /><p><br /></p><p>Contamos con una colección de </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjelUyo4Ox1Nu3dyydY0abq-rJoYy8zEpgsMs751fNvySHVxhph5W3q6YptR5ZQREcOsTgmCMURZHVcj8OYMVtxP3-FA_LBu-qO96WEhNv7qx7pJEs1ylwSm5gyXidnToPrD7dAd4Gy7zySkIXYpNkZGFcT51mzPABsGSbZnvDnH2x6i8Oayw/s1032/coleccion.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="467" data-original-width="1032" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjelUyo4Ox1Nu3dyydY0abq-rJoYy8zEpgsMs751fNvySHVxhph5W3q6YptR5ZQREcOsTgmCMURZHVcj8OYMVtxP3-FA_LBu-qO96WEhNv7qx7pJEs1ylwSm5gyXidnToPrD7dAd4Gy7zySkIXYpNkZGFcT51mzPABsGSbZnvDnH2x6i8Oayw/s16000/coleccion.png" /></a></div><br /><p><br /></p><p>Realizamos la consulta con Postman</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOWROwyG9LcnIv1JcBknenSYDiDMGfq5Hg1g7g07rKaNcoZgYCDV-GD5XkvFS7cyYpFM6TDoBq-PSGtQk0hDU0zZb_PWXPH5nNjmzufcT9D-12LIFPNmg8pyhvLHdwzJn4n0NQUK_MzYtTV4UfN2jcuRpZ73PJeHqJ8YKbQemvJDa0GJwrlw/s859/Captura%20desde%202022-10-28%2015-54-07.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="483" data-original-width="859" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOWROwyG9LcnIv1JcBknenSYDiDMGfq5Hg1g7g07rKaNcoZgYCDV-GD5XkvFS7cyYpFM6TDoBq-PSGtQk0hDU0zZb_PWXPH5nNjmzufcT9D-12LIFPNmg8pyhvLHdwzJn4n0NQUK_MzYtTV4UfN2jcuRpZ73PJeHqJ8YKbQemvJDa0GJwrlw/s16000/Captura%20desde%202022-10-28%2015-54-07.png" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-69334780307282674332022-09-21T06:36:00.001-07:002022-09-21T06:36:08.665-07:00Markdown plugin para NetBeans<p> Markdown es muy utilizado por su sencillez, existe un plugin para NetBeans que esta desarrollando Moacir da Roza , que puedes descargar desde el siguiente enlace <a href="https://github.com/moacirrf/netbeans-markdown/releases">https://github.com/moacirrf/netbeans-markdown/releases</a></p><p><br /></p><p>Su uso es muy sencillo, solo necesitas instalar el plugin y al abrir un archivo con la extensión .md,</p><p>se muestra una pre visualización del mismo.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3vjRdU5qJHFfV4z7M3ntXT0Lkcv77nqIGI6WHrZNSgwuCvTeQeZJgACfmISHlPNOl0EIwBmK6iGatXFXe_p_6e2EpedfGJOC_WS81cl71QyV9bz38LKZG01_HHvIGcuuLU4b8jfX9WIZJufGzncaYWWUpcJl0SWOqBNjgT5sEhJmRZhrYLw/s1163/perfecto.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="626" data-original-width="1163" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3vjRdU5qJHFfV4z7M3ntXT0Lkcv77nqIGI6WHrZNSgwuCvTeQeZJgACfmISHlPNOl0EIwBmK6iGatXFXe_p_6e2EpedfGJOC_WS81cl71QyV9bz38LKZG01_HHvIGcuuLU4b8jfX9WIZJufGzncaYWWUpcJl0SWOqBNjgT5sEhJmRZhrYLw/s16000/perfecto.png" /></a></div><br /><div>Aun esta en desarrollo pero funciona muy bien, si necesitas soporte para Markdown en NetBeans sin duda es el componente que debes utilizar.</div>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-28827132459490303852022-07-22T19:36:00.003-07:002022-07-22T19:36:58.388-07:00jmoordb-core en Jakarta EE 10<p>Estamos haciendo pruebas de una versión totalmente reescrita desde cero de Jmoordb.</p><p>Jakarta EE 10/NetBeans 14/ MongoDB/ Glassish</p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/mfr8OQYXGl0" width="320" youtube-src-id="mfr8OQYXGl0"></iframe></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><p><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-89818106440540915392022-05-18T20:10:00.010-07:002022-05-19T06:44:47.550-07:00Jakarta NoSQL con MongoDB perspectivas<p><b> Jakarta NoSQL con MongoDB perspectivas</b></p><p>Hace unos años conversaba con un gran amigo Otavio Santa, acerca de bases de datos NoSQL.</p><p>Es admirable el trabajo que lleva adelante Otavio y otros desarrolladores en la especificación <a href="https://jakarta.ee/specifications/nosql/">Jakarta NoSQL.</a></p><p>La definición oficial en el sitio de Jakarta:</p><p>"<span face=""Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif" style="background-color: white; color: #3d3d3d; font-size: 14px;">Jakarta NoSQL is a Java API standard that streamlines the integration of Java applications with NoSQL databases. It defines a set of APIs and provides a standard implementation for most NoSQL databases. The goal is to create the specification in Jakarta EE to help Jakarta EE developers create enterprise-grade applications using Java® and NoSQL technologies. It helps them create scalable applications while maintaining low coupling with the underlying NoSQL technology."</span></p><p><span face=""Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif" style="background-color: white; color: #3d3d3d; font-size: 14px;"><br /></span></p><p><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="background-color: white; font-size: 14px;">Si leemos un poco la documentación oficial nos encontraremos que se define mediante dos capas:</span></span></p><p></p><ul style="text-align: left;"><li><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="background-color: white;"><span style="font-size: 14px;">Communication Layer: Contiene 4 módulos uno para cada tipo de bases de datos NoSQL. Es como JDBC para bases de datos relacionales.</span></span></span></li><li><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="background-color: white;"><span style="font-size: 14px;">Mapping Layer: Esta capa utiliza CDI, Bean Validaton, anotaciones para ofrecer sencillez a los desarrolladores, Se puede comparar con JPA.</span></span></span></li></ul><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;"><br /></span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;">Su uso es muy sencillo, definimos entidades de manera simple, y mediante interfaces usando el patrón Repository tenemos una gran funcionalidad con poco esfuerzo.</span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;"><br /></span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;">Hasta el momento de escribir este articulo es importante mencionar que no se soporta agregaciones por lo cual no podemos utilizar referencias entre documentos, tenemos que definir un modelo de datos optimizado generalmente usando documentos embebidos para el caso de MongoDB. </span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;"><br /></span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;">Su flexibilidad e integración con Microprofile es muy sencilla. Solamente agregamos al archivo micrroprofile-config, los atributos que indican el tipo de base de datos y los parámetros de conexión.</span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnKEt6rvAmDKPb1_qa3w9gEUSidPNcD5BADUFE2aMSpSCGKIe89v6poOEYTHPoYVCkHcr1gSVCsOHZSl2JJOYbnkN9XfjHzuo_hN7aGrnStxc6ORWZx4PGZ-ZUz2AC9kwPwKcoNGFOOnCIj11XquQxLUBE9HqpFGvYO2Lr-A6U-3wznLtIyA/s1520/Captura%20desde%202022-05-18%2020-53-22.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="288" data-original-width="1520" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnKEt6rvAmDKPb1_qa3w9gEUSidPNcD5BADUFE2aMSpSCGKIe89v6poOEYTHPoYVCkHcr1gSVCsOHZSl2JJOYbnkN9XfjHzuo_hN7aGrnStxc6ORWZx4PGZ-ZUz2AC9kwPwKcoNGFOOnCIj11XquQxLUBE9HqpFGvYO2Lr-A6U-3wznLtIyA/s16000/Captura%20desde%202022-05-18%2020-53-22.png" /></a></div><br /><span style="font-size: 14px;"><br /></span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;">Definimos nuestras entidades: Persona.java , Pais.java, Dirección.java, que representa la colección Persona y Pais en MongoDB. Lo hacemos de esta manera a modo de ejemplo:</span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;">Ejemplo A:</span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjctXLM4AMbJI2iMjme5TLmflwE7dgIEW4vk3tcfjISk-ZUx8YYtxYti8e4D4JiPocZAAvmTqASWuCDE2ss2sCPa3LEUDny2zNVLkHYFazCn7cv6NFXtfc39e55bSYfklkm6jh8WBXQ9HJuImpJqfz4kRVWgtnazo-Via1dTZIxY_BaJ23lVA/s827/Captura%20desde%202022-05-18%2021-08-34.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="389" data-original-width="827" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjctXLM4AMbJI2iMjme5TLmflwE7dgIEW4vk3tcfjISk-ZUx8YYtxYti8e4D4JiPocZAAvmTqASWuCDE2ss2sCPa3LEUDny2zNVLkHYFazCn7cv6NFXtfc39e55bSYfklkm6jh8WBXQ9HJuImpJqfz4kRVWgtnazo-Via1dTZIxY_BaJ23lVA/s16000/Captura%20desde%202022-05-18%2021-08-34.png" /></a></div><br /><span style="font-size: 14px;"><br /></span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;"><br /></span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;">Para el ejemplo definimos Pais como un entity pero le agregamos el atributo @Id</span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfy7eLaaoWH21mAdKzPB_2tNDq3G6O1rndx2USmaMCIr9nSO58nRGiWXSFI2SO-2hcZyKcDZ8JF97-k8UuXnC0Vn_KA68t27o_VnIYt4gh4AcOyKc-HbohLCS7BTHKDGLaqaIRBwO6KkskdnJSL1P-zZ20jEWymYnfvvSsmRbh3W4r0yTUiw/s668/Captura%20desde%202022-05-18%2021-09-52.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="259" data-original-width="668" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfy7eLaaoWH21mAdKzPB_2tNDq3G6O1rndx2USmaMCIr9nSO58nRGiWXSFI2SO-2hcZyKcDZ8JF97-k8UuXnC0Vn_KA68t27o_VnIYt4gh4AcOyKc-HbohLCS7BTHKDGLaqaIRBwO6KkskdnJSL1P-zZ20jEWymYnfvvSsmRbh3W4r0yTUiw/s16000/Captura%20desde%202022-05-18%2021-09-52.png" /></a></div><br /><span style="font-size: 14px;"><br /></span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;"><br /></span></span></div><h2 style="text-align: left;"><br /></h2><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;"><h2>Crear la interface Repository para Persona</h2></span></span></div><p></p><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;">public interface PersonaRepository extends Repository<Persona, String> {</span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><div><span style="font-size: 14px;"><br /></span></div><div><span style="font-size: 14px;"> Stream<Persona> findAll();</span></div><div><span style="font-size: 14px;"><br /></span></div><div><span style="font-size: 14px;"> Page<Persona> findAll(Pagination pagination);</span></div><div><span style="font-size: 14px;"><br /></span></div><div><span style="font-size: 14px;"><br /></span></div><div><span style="font-size: 14px;"> //Busca en el documento embebido</span></div><div><span style="font-size: 14px;"> @Query("select * from Persona where pais.code = @code")</span></div><div><span style="font-size: 14px;"> Stream<Persona> findByPaisIn(@Param("code") String code);</span></div><div><span style="font-size: 14px;"><br /></span></div><div><span style="font-size: 14px;"> Stream<Persona> findByName(String name);</span></div><div><br /></div><div><span style="font-size: 14px;">}</span></div><div><br /></div><div><br /></div><h2 style="text-align: left;">Ahora creamos la interface Repository para Pais</h2><div>Observe que estamos creando una consulta buscando en el documento embebido mediante pais.code</div><div><br /></div></span></div><p></p><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjC3c1XZOadU4wQwj8WdrqRqmanRB0sttahsSyQsv9tufnjYP_OwCQ0byUDMykiPbaiAIr97JRAI6m2nhbqrT8SI0wiJNMhsmigCmXBM6Qx-RArRIkLmyti6lfzGYslTr3mqx6BDrTVuO-4gEwu2xLoeTVi_1d-ilXa3AFyC5v5mGvRVmLn1g/s988/Captura%20desde%202022-05-18%2021-13-47.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="334" data-original-width="988" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjC3c1XZOadU4wQwj8WdrqRqmanRB0sttahsSyQsv9tufnjYP_OwCQ0byUDMykiPbaiAIr97JRAI6m2nhbqrT8SI0wiJNMhsmigCmXBM6Qx-RArRIkLmyti6lfzGYslTr3mqx6BDrTVuO-4gEwu2xLoeTVi_1d-ilXa3AFyC5v5mGvRVmLn1g/s16000/Captura%20desde%202022-05-18%2021-13-47.png" /></a></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><br /></span></div><br /><span><h2 style="font-size: 14px;">Crear el controlller utilizando Eclipse Microprofile</h2></span></span></div><div><br /></div><p></p><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;">@ApplicationScoped</span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><div style="font-size: 14px;">@Path("pais")</div><div style="font-size: 14px;">@Produces(MediaType.APPLICATION_JSON)</div><div style="font-size: 14px;">@Consumes(MediaType.APPLICATION_JSON)</div><div style="font-size: 14px;"><b>public class PaisController {</b></div><div style="font-size: 14px;"><br /></div><div style="font-size: 14px;"> private static final Supplier<WebApplicationException> NOT_FOUND =</div><div style="font-size: 14px;"> () -> new WebApplicationException(Response.Status.NOT_FOUND);</div><div style="font-size: 14px;"><br /></div><div style="font-size: 14px;"> @Inject</div><div style="font-size: 14px;"> private PaisRepository repository;</div><div style="font-size: 14px;"><br /></div><div style="font-size: 14px;"> @GET</div><div style="font-size: 14px;"> public List<Pais> findAll() {</div><div style="font-size: 14px;"> return repository.findAll()</div><div style="font-size: 14px;"> .collect(toList());</div><div style="font-size: 14px;"> }</div><div style="font-size: 14px;"><br /></div><div style="font-size: 14px;"> @GET</div><div style="font-size: 14px;"> @Path("/{id}")</div><div style="font-size: 14px;"> public Pais findById(@PathParam("id") String id) {</div><div style="font-size: 14px;"> return repository.findById(id).orElseThrow(NOT_FOUND);</div><div style="font-size: 14px;"> }</div><div style="font-size: 14px;"><br /></div><div style="font-size: 14px;"> </div><div style="font-size: 14px;"> @GET</div><div style="font-size: 14px;"> @Path("search/{name}")</div><div style="font-size: 14px;"> public List<Pais> findByYounger(@PathParam("name") String name) {</div><div style="font-size: 14px;"> return repository.findByName(name)</div><div style="font-size: 14px;"> .collect(toList());</div><div style="font-size: 14px;"> }</div><div style="font-size: 14px;"><br /></div><div style="font-size: 14px;"> @POST</div><div style="font-size: 14px;"> public void save(Pais hero) {</div><div style="font-size: 14px;"> repository.save(hero);</div><div style="font-size: 14px;"> }</div><div style="font-size: 14px;"><br /></div><div style="font-size: 14px;"> @PUT</div><div style="font-size: 14px;"> @Path("/{id}")</div><div style="font-size: 14px;"> public void update(@PathParam("id") String id, Pais hero) {</div><div style="font-size: 14px;"> repository.save(hero);</div><div style="font-size: 14px;"> }</div><div style="font-size: 14px;"><br /></div><div style="font-size: 14px;"> @Path("/{id}")</div><div style="font-size: 14px;"> @DELETE</div><div style="font-size: 14px;"> public void delete(@PathParam("id") String name) {</div><div style="font-size: 14px;"> repository.deleteById(name);</div><div style="font-size: 14px;"> }</div><div style="font-size: 14px;">}</div><div style="font-size: 14px;"><br /></div><div style="font-size: 14px;"><br /></div><h2 style="font-size: 14px; text-align: left;">Ahora crearmos el controller PersonaController.java</h2><div><div><span style="font-size: 14px;">@ApplicationScoped</span></div><div><span style="font-size: 14px;">@Path("persona")</span></div><div><span style="font-size: 14px;">@Produces(MediaType.APPLICATION_JSON)</span></div><div><span style="font-size: 14px;">@Consumes(MediaType.APPLICATION_JSON)</span></div><div><span style="font-size: 14px;">public class PersonaController {</span></div><div><span style="font-size: 14px;"><br /></span></div><div><span style="font-size: 14px;"> private static final Supplier<WebApplicationException> NOT_FOUND =</span></div><div><span style="font-size: 14px;"> () -> new WebApplicationException(Response.Status.NOT_FOUND);</span></div><div><span style="font-size: 14px;"><br /></span></div><div><span style="font-size: 14px;"> @Inject</span></div><div><span style="font-size: 14px;"> private PersonaRepository repository;</span></div><div><span style="font-size: 14px;"><br /></span></div><div><span style="font-size: 14px;"> @GET</span></div><div><span style="font-size: 14px;"> public List<Persona> findAll() {</span></div><div><span style="font-size: 14px;"> return repository.findAll()</span></div><div><span style="font-size: 14px;"> .collect(toList());</span></div><div><span style="font-size: 14px;"> }</span></div><div><span style="font-size: 14px;"><br /></span></div><div><span style="font-size: 14px;"> @GET</span></div><div><span style="font-size: 14px;"> @Path("/{id}")</span></div><div><span style="font-size: 14px;"> public Persona findById(@PathParam("id") String id) {</span></div><div><span style="font-size: 14px;"> return repository.findById(id).orElseThrow(NOT_FOUND);</span></div><div><span style="font-size: 14px;"> }</span></div><div><span style="font-size: 14px;"><br /></span></div><div><span style="font-size: 14px;"> @GET</span></div><div><span style="font-size: 14px;"> @Path("searchpais/{code}")</span></div><div><span style="font-size: 14px;"> public List<Persona> findByPaisIn(@PathParam("code") String code) {</span></div><div><span style="font-size: 14px;"> </span></div><div><span style="font-size: 14px;"> return repository.findByPaisIn(code)</span></div><div><span style="font-size: 14px;"> .collect(toList());</span></div><div><span style="font-size: 14px;"> }</span></div><div><span style="font-size: 14px;"> </span></div><div><span style="font-size: 14px;"><br /></span></div><div><span style="font-size: 14px;"> </span></div><div><span style="font-size: 14px;"> @POST</span></div><div><span style="font-size: 14px;"> public void save(Persona hero) {</span></div><div><span style="font-size: 14px;"> repository.save(hero);</span></div><div><span style="font-size: 14px;"> }</span></div><div><span style="font-size: 14px;"><br /></span></div><div><span style="font-size: 14px;"> @PUT</span></div><div><span style="font-size: 14px;"> @Path("/{id}")</span></div><div><span style="font-size: 14px;"> public void update(@PathParam("id") String id, Persona hero) {</span></div><div><span style="font-size: 14px;"> repository.save(hero);</span></div><div><span style="font-size: 14px;"> }</span></div><div><span style="font-size: 14px;"><br /></span></div><div><span style="font-size: 14px;"> @Path("/{id}")</span></div><div><span style="font-size: 14px;"> @DELETE</span></div><div><span style="font-size: 14px;"> public void delete(@PathParam("id") String name) {</span></div><div><span style="font-size: 14px;"> repository.deleteById(name);</span></div><div><span style="font-size: 14px;"> }</span></div><div><span style="font-size: 14px;">}</span></div><div style="font-size: 14px;"><br /></div><div style="font-size: 14px;"><br /></div><div style="font-size: 14px;"><b>Insertamos algunos documentos en la colección Pais</b></div><div style="font-size: 14px;"><br /></div><div style="font-size: 14px;"><div>curl -H "Content-Type: application/json" -X POST -d '{ "code": "pa","name": "Panama"}' http://localhost:8080/microjakartanosql/api/pais/</div><div>curl -H "Content-Type: application/json" -X POST -d '{ "code": "eu","name": "Estados Unidos"}' http://localhost:8080/microjakartanosql/api/pais/</div><div>curl -H "Content-Type: application/json" -X POST -d '{ "code": "cu","name": "Cuba"}' http://localhost:8080/microjakartanosql/api/pais/</div><div><br /></div><div><br /></div><div><br /></div></div><h2 style="text-align: left;"><br /><span style="background-color: white;"><span style="font-size: 14px;">Insertamos documentos en la colección Persona</span></span></h2></div></span></div><div><span face=""Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif" style="background-color: white; color: #3d3d3d; font-size: 14px;"><br /></span></div><div><span style="background-color: white;"><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;">curl -H "Content-Type: application/json" -X POST -d '{"id": "7","name": "Aristides","pais":{ "code": "pa","name": "Panama"},"direccion":{ "street": "Calle 1","city": "Los Santos"}}' http://localhost:8080/microjakartanosql/api/persona/</span></span></div><div><span face="Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #3d3d3d;"><span style="font-size: 14px;">curl -H "Content-Type: application/json" -X POST -d '{"id": "8","name": "Ana","pais":{ "code": "cu","name": "Cuba"},"direccion":{ "street": "La habana","city": "La habana"}}' http://localhost:8080/microjakartanosql/api/persona/</span></span></div><div style="color: #3d3d3d; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;"><br /></div><h2 style="color: #3d3d3d; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: left;">Podemos observar una situación interesante </h2></span></div><p>La colección Persona en MongoDB no genera el documento embebido pais y el campo code, es reemplazado automáticamente por _id.<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzZY-gBi3YZoy03Dw5Y4efHqTmAkiABAmnlVAOJEUHaaPDnZq0FG4voLswIuxztvhCUGlUD-DBSDQWU9xIe4xRu3ZUqlFWAXCWnl-qjVlmo738NaKRZ1ZNLfXONSwv4kqdUpMwDg3pJD4_HwcgaGnCvZySuP-QuskWtz23NgM2KUnvgde4EA/s622/Captura%20desde%202022-05-18%2021-20-38.png" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="246" data-original-width="622" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzZY-gBi3YZoy03Dw5Y4efHqTmAkiABAmnlVAOJEUHaaPDnZq0FG4voLswIuxztvhCUGlUD-DBSDQWU9xIe4xRu3ZUqlFWAXCWnl-qjVlmo738NaKRZ1ZNLfXONSwv4kqdUpMwDg3pJD4_HwcgaGnCvZySuP-QuskWtz23NgM2KUnvgde4EA/s16000/Captura%20desde%202022-05-18%2021-20-38.png" /></a></p><br /><p>. Esto ocurre porque en nuestra entidad Pais, definimos el atributo </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhA3fRvVLavNhMdO2V9EdmqUWceXC1LBHBemwVJlUmUUM4Wc5Gn55h8_aYqP3OUaQuWButntuMssC7369ESu7vYhiLZvTHCawcYeIEKA93GqBQAchfPCr2c2jmHGBlYKfiipnszA7pps1b9vPymcjKxJdqmpwTpU35bORPsoJGU3GaBXfts7A/s721/Captura%20desde%202022-05-18%2021-22-32.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="262" data-original-width="721" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhA3fRvVLavNhMdO2V9EdmqUWceXC1LBHBemwVJlUmUUM4Wc5Gn55h8_aYqP3OUaQuWButntuMssC7369ESu7vYhiLZvTHCawcYeIEKA93GqBQAchfPCr2c2jmHGBlYKfiipnszA7pps1b9vPymcjKxJdqmpwTpU35bORPsoJGU3GaBXfts7A/s16000/Captura%20desde%202022-05-18%2021-22-32.png" /></a></div><br /><div>y queríamos que se almacenar el atributo code.</div><div>Que hicimos mal o en que estamos fallando, en primer lugar si le ocurre esta situación indica que no hemos analizado bien el modelo de datos que queremos usar. Habia comentado inicialmente que Jakarta NoSQL no soporta aun documentos referenciados. Por la tanto podemos observar que dirección se almaceno correctamente los atributos street, city.</div><div>En la definición de la entidad</div><div>No contamos con ninguna columna definida con el atributo @Id</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmmasYmDOdMYZJQ-DQI_NnaGEwcIR8kC9kgDd5moC0U0Vr1itVu-xQY79bDF97JZep3n_p329WA5bHjX7psCJhpoxZOOscFCtSU6uTPqF6NsmCSgfCan1PQYQ7_a37Usn3LLF0q378pvMm38SIhx_T7JzcK2AhxOnNQY8Bm8r_HC6CCAVFUw/s733/Captura%20desde%202022-05-18%2021-26-09.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="233" data-original-width="733" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmmasYmDOdMYZJQ-DQI_NnaGEwcIR8kC9kgDd5moC0U0Vr1itVu-xQY79bDF97JZep3n_p329WA5bHjX7psCJhpoxZOOscFCtSU6uTPqF6NsmCSgfCan1PQYQ7_a37Usn3LLF0q378pvMm38SIhx_T7JzcK2AhxOnNQY8Bm8r_HC6CCAVFUw/s16000/Captura%20desde%202022-05-18%2021-26-09.png" /></a></div><br /><div>Por lo tanto si eliminamos la anotación @Id de la entidad Pais.java</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8rZoovq3xKVlraxNbne-xK6R9d0JiVDc1Fl66G4wsrKlSUn2sMRe4xGf2NQLTFrf3BM4ENDuatLSM-oEiHC74GmlXTsJkHGDn8LaF6XOjNmZ29EIRfvXPfUVcx3wGIu6R-cSa-Be50SHrwz3RgVdbR6QOjhC-sU5KxpKfKBu03I-_i7pbtQ/s733/Captura%20desde%202022-05-18%2021-27-43.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="233" data-original-width="733" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8rZoovq3xKVlraxNbne-xK6R9d0JiVDc1Fl66G4wsrKlSUn2sMRe4xGf2NQLTFrf3BM4ENDuatLSM-oEiHC74GmlXTsJkHGDn8LaF6XOjNmZ29EIRfvXPfUVcx3wGIu6R-cSa-Be50SHrwz3RgVdbR6QOjhC-sU5KxpKfKBu03I-_i7pbtQ/s16000/Captura%20desde%202022-05-18%2021-27-43.png" /></a></div><div><br /></div>Y eliminamos los documentos de nuestra colección Persona en MongoDB y detenemos nuesto microservicio y lo volvemos a ejecutar.<div><br /><div>curl -H "Content-Type: application/json" -X POST -d '{"id": "7","name": "Aristides","pais":{ "code": "pa","name": "Panama"},"direccion":{ "street": "Calle 1","city": "Los Santos"}}' http://localhost:8080/microjakartanosql/api/persona/<br />curl -H "Content-Type: application/json" -X POST -d '{"id": "8","name": "Ana","pais":{ "code": "cu","name": "Cuba"},"direccion":{ "street": "La habana","city": "La habana"}}' http://localhost:8080/microjakartanosql/api/persona/</div><div><span style="font-size: x-small;"><br /></span><div><div>Podemos observar que se almacena correctamente</div><div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMQVbo4yefRSIIq3kTGljquGgm57YAZI3gZ0PKQDy4MGCX2LnmXDNasvhgkOYH5Y-LYH8Mhb5smoR3iyWgdYZgKmglv9axwPxV9sFMlFB8sHP-yXh0IFYWqnMAN4p5J2aOoFzcZC0OgEXY9Yxmxvq7BBoBLNi29zCqEkmAHkIY3S48_FVDHw/s510/Captura%20desde%202022-05-18%2021-46-34.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="288" data-original-width="510" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMQVbo4yefRSIIq3kTGljquGgm57YAZI3gZ0PKQDy4MGCX2LnmXDNasvhgkOYH5Y-LYH8Mhb5smoR3iyWgdYZgKmglv9axwPxV9sFMlFB8sHP-yXh0IFYWqnMAN4p5J2aOoFzcZC0OgEXY9Yxmxvq7BBoBLNi29zCqEkmAHkIY3S48_FVDHw/s16000/Captura%20desde%202022-05-18%2021-46-34.png" /></a></div><br /><div>Como eliminamos el @Id del entity Pais, no podremos insertar los registros</div><div><br /></div><div><div><span style="font-size: x-small;">curl -H "Content-Type: application/json" -X POST -d '{"id": "7","name": "Aristides","pais":{ "code": "pa","name": "Panama"},"direccion":{ "street": "Calle 1","city": "Los Santos"}}' http://localhost:8080/microjakartanosql/api/persona/</span></div><div><span style="font-size: x-small;">curl -H "Content-Type: application/json" -X POST -d '{"id": "8","name": "Ana","pais":{ "code": "cu","name": "Cuba"},"direccion":{ "street": "La habana","city": "La habana"}}' http://localhost:8080/microjakartanosql/api/persona/</span></div></div><div><br /></div><div><br /></div><div>ya que nos enviara el error</div><div><br /></div><div><br /></div></div></div><br /><div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCopwq897IJLBp-YvIrQ3Z9QoaXjfvyf7LyCUxYwUlMuce4R5TQLpYy-a5b_41kqX2T4GC3KvlIqiW7moy7FV4yocghhr8J1kttpNoY3RvsAaD40tVpwcQKNgi_qyIoGm1UH_KCl3RtjFGD2J8BBYOVz7ctXMNl_Bt1bPtpp3dQnLRV57R6w/s1103/Captura%20desde%202022-05-18%2021-54-26.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="324" data-original-width="1103" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCopwq897IJLBp-YvIrQ3Z9QoaXjfvyf7LyCUxYwUlMuce4R5TQLpYy-a5b_41kqX2T4GC3KvlIqiW7moy7FV4yocghhr8J1kttpNoY3RvsAaD40tVpwcQKNgi_qyIoGm1UH_KCl3RtjFGD2J8BBYOVz7ctXMNl_Bt1bPtpp3dQnLRV57R6w/s16000/Captura%20desde%202022-05-18%2021-54-26.png" /></a></div><br /><div><br /></div><div>Indicando que solo usaremos una colección Persona, y tanto Direccion como Pais, serán embebidos</div></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAyzsRAOCMOdDQTO2TShXtCQuyD4qJiSAeSms-Vm1mHmEwAaxDwrq5HBr-RzcMOySkV51Qk8GExWf7Q1ddsKaXZvLAyBg4TeyNu-cOXW1axxgaS3cvJm02Xr8JZwe7w9iWP05Cbbq3g5Eb8SSabzxkjkEEhOuijpWLphZYG8IWkQutdKsCtg/s381/Captura%20desde%202022-05-18%2021-56-19.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="295" data-original-width="381" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAyzsRAOCMOdDQTO2TShXtCQuyD4qJiSAeSms-Vm1mHmEwAaxDwrq5HBr-RzcMOySkV51Qk8GExWf7Q1ddsKaXZvLAyBg4TeyNu-cOXW1axxgaS3cvJm02Xr8JZwe7w9iWP05Cbbq3g5Eb8SSabzxkjkEEhOuijpWLphZYG8IWkQutdKsCtg/s16000/Captura%20desde%202022-05-18%2021-56-19.png" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div>Por la tanto son los cambios importantes que debemos considerar al trabajar con bases de datos NoSQL y con las diversas implementaciones.<div>Muchas veces tenemos que redefinir adecuadamente para aprovechar el potencial <br /><div><br /><div><br /></div></div></div></div></div>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-29672042908069537472022-01-29T12:27:00.002-08:002022-01-29T12:29:00.420-08:00Primefaces p:schedule con p:dialog con fechas no editables<p> PrimeFaces nos ofrece un componente sumamente interesante para manejar nuestras fechas este es <p:schedule></p><p><a href="https://www.primefaces.org/showcase/ui/data/schedule/basic.xhtml">https://www.primefaces.org/showcase/ui/data/schedule/basic.xhtml</a></p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgvtbKJ6om5FlmRg59M9d3UvfF3EBLtX2lO8dXSpOB6IkyWn_X225VrZ6CqFkO3Nk2C8uBokuO0IA2IsOgsRjkRIM8I9ylvNO-yx91Ifh8PbBl_AHafvMeXBNDfiL_HOdcjCSoEjZeOMOcbtTIW4ksx7zD7ocOshYY9KEPci_fCce0exk0IQw=s1503" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="787" data-original-width="1503" height="168" src="https://blogger.googleusercontent.com/img/a/AVvXsEgvtbKJ6om5FlmRg59M9d3UvfF3EBLtX2lO8dXSpOB6IkyWn_X225VrZ6CqFkO3Nk2C8uBokuO0IA2IsOgsRjkRIM8I9ylvNO-yx91Ifh8PbBl_AHafvMeXBNDfiL_HOdcjCSoEjZeOMOcbtTIW4ksx7zD7ocOshYY9KEPci_fCce0exk0IQw=w320-h168" width="320" /></a></div><br /><p>Cuando deseamos mostrar un dialogo con las fechas seleccionadas pero sin necesidad de editar la fecha podemos recurrir a un truco muy sencillo.</p><p>Agregar en el dialog un componente <p:calendar con rendered="false", de esta manera se mostrara el contenido del dialog, pero no tendremos la fecha editable, que para algunas circunstancias puede no ser adecuado.</p><p><br /></p><p> <p:outputLabel value="Fecha:" styleClass="p-text-bold" rendered="false"/></p><p> <p:calendar value="#{testController.event.startDate}" pattern="dd/MM/yyyy hh:mm a"</p><p> rendered="false"</p><p> /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-25101212926654628522022-01-04T18:06:00.007-08:002022-01-04T18:18:40.471-08:00Controlar F5 o Refresh Button del Navegador con Jakarta Server FacesHay varias formas de Controlar cuando el usuario esta en una pagina Web desarrollada con Jakarta Server Faces. Presiona el boton Refresh o la tecla F5 para recargar o actualizar la pagina actual.<div>Creamos un proyecto Jakarta EE </div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhm74B4hFbA8qvlYL1dOwM7y4zr2d5P3P5sSQRca3xvaFxXp7tSfGOwhgNGGnbPJGm0nAr2Au0NYBbDHUftRRGStZW7qm1dtbC0gFEV30kzFX_RXgOhcfCoF2Py9wijeA0hnFeU2-NIBFcmQEz2BlTPapkCN2_yy32R-7PrGKdotfqSEV6L4g=s507" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="507" data-original-width="344" src="https://blogger.googleusercontent.com/img/a/AVvXsEhm74B4hFbA8qvlYL1dOwM7y4zr2d5P3P5sSQRca3xvaFxXp7tSfGOwhgNGGnbPJGm0nAr2Au0NYBbDHUftRRGStZW7qm1dtbC0gFEV30kzFX_RXgOhcfCoF2Py9wijeA0hnFeU2-NIBFcmQEz2BlTPapkCN2_yy32R-7PrGKdotfqSEV6L4g=s16000" /></a></div><br /><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div> y se ha configurado la pagina de inicio en el archivo web.xml</div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhB8T9uTYq6LtafdfsvTVC5Hz3AhS-FP09vSU8bUU5udlW8WWaP3meFV8vAqTng1wqWyIl7LpsMq5TNtVdmMvJVkMVsrXvgsMxXKhw1ZFc6n4JZbPVLO9TUKAVEheJ6IVlXKzhCt5Yv7PFJvVXdWA46pMfSbU94wqSoQHT4wrx4ZY8hcMkyHg=s791" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="476" data-original-width="791" src="https://blogger.googleusercontent.com/img/a/AVvXsEhB8T9uTYq6LtafdfsvTVC5Hz3AhS-FP09vSU8bUU5udlW8WWaP3meFV8vAqTng1wqWyIl7LpsMq5TNtVdmMvJVkMVsrXvgsMxXKhw1ZFc6n4JZbPVLO9TUKAVEheJ6IVlXKzhCt5Yv7PFJvVXdWA46pMfSbU94wqSoQHT4wrx4ZY8hcMkyHg=s16000" /></a></div><br /><div>Al ejecutar la aplicación se muestra la pagina de login.xhtml donde se pedirá las credenciales del usuario.</div><div><br /></div><div><div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjg7kkvpB9bKwQoDYMdqxymGJD4sdsfuMmPtcDOZgaAInQ4Uto4YNErkoICmo2-bP8ygqct_YZslNZ35TNofS0pc7HoJE6MU4UiQXOLRBAabEcOLWjHM3O78qSt5poxdFCPJduu5_k3nVRUSqAgvzvv3adhzGxtGWIkMLKcVC8dyHm_5O477g" style="display: block; padding: 1em 0px; text-align: center;"><img alt="" border="0" data-original-height="364" data-original-width="553" src="https://blogger.googleusercontent.com/img/a/AVvXsEjg7kkvpB9bKwQoDYMdqxymGJD4sdsfuMmPtcDOZgaAInQ4Uto4YNErkoICmo2-bP8ygqct_YZslNZ35TNofS0pc7HoJE6MU4UiQXOLRBAabEcOLWjHM3O78qSt5poxdFCPJduu5_k3nVRUSqAgvzvv3adhzGxtGWIkMLKcVC8dyHm_5O477g" /></a>al ingresar las credenciales nos dirige a la pagina index.xhtml</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgXnTEulVzZ_mDC6iyd2WLADKF8cGp-Auvi0hlrUsKWuVSoXZtQqn6XromaplOq6_IQz-1RiEcpHF4dksiX4sVvWo0PtYilC4M16Rj6M8YSMgBX7v0tG3eq0jWxc-BGERQnpXl5Gejw1yqCKDW7OFQzk30vMvb47lTvUKa1zDjV90c49jwPdg=s473" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="284" data-original-width="473" src="https://blogger.googleusercontent.com/img/a/AVvXsEgXnTEulVzZ_mDC6iyd2WLADKF8cGp-Auvi0hlrUsKWuVSoXZtQqn6XromaplOq6_IQz-1RiEcpHF4dksiX4sVvWo0PtYilC4M16Rj6M8YSMgBX7v0tG3eq0jWxc-BGERQnpXl5Gejw1yqCKDW7OFQzk30vMvb47lTvUKa1zDjV90c49jwPdg=s16000" /></a></div><div class="separator" style="clear: both; text-align: left;">Si presionamos la tecla F5 o el botón Refresh del navegador </div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgiYWtlJN9sDtcm0PetIfL3y8v1G20r_IKQ7Z0qeHXaqkMgKk14UzVH-KbF2xYzsL9AfvZzEuIxKrZSapkyRX-cxQpW4OqIYD6jRhBXQXSeq1qZ9IhAClBbweq1eE6ZxVsOgEXOoQ4AekzWgvPXGEMxWw2KVnfJVr7ZPgH4Rw9QMuFJq0LwDQ=s135" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="38" data-original-width="135" height="38" src="https://blogger.googleusercontent.com/img/a/AVvXsEgiYWtlJN9sDtcm0PetIfL3y8v1G20r_IKQ7Z0qeHXaqkMgKk14UzVH-KbF2xYzsL9AfvZzEuIxKrZSapkyRX-cxQpW4OqIYD6jRhBXQXSeq1qZ9IhAClBbweq1eE6ZxVsOgEXOoQ4AekzWgvPXGEMxWw2KVnfJVr7ZPgH4Rw9QMuFJq0LwDQ" width="135" /></a></div><div class="separator" style="clear: both; text-align: left;">podrá notar que sera redirigido a la pagina de login.xhtml, en lugar de actualizar la pagina index.xhtml.</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">Para evitar esta situación y mantener al usuario observando la pagina actual se pueden implementar de varias formas:</div><div class="separator" style="clear: both; text-align: left;"><ul style="text-align: left;"><li> Controlar los eventos con JavaScript,</li><li>Guardar datos en el cliente.</li><li>Personalizar mediante <f:viewAction></li></ul></div><div class="separator" style="clear: both; text-align: left;">En nuestro caso mostraremos como utilizar algo diferente mediante <f:viewAction/>, es un ejemplo demostrativo solamente.</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">Lo que haremos en colocar en cada formulario .xhtml</div><h:head>
<f:metadata>
<f:viewaction action="#{accessController.verificarIsLogin()}">
</f:viewaction></f:metadata></h:head><div class="separator" style="clear: both; text-align: left;"> </div><div class="separator" style="clear: both; text-align: left;"><h:head>
<f:metadata>
<f:viewaction action="#{accessController.verificarIsLogin()}">
</f:viewaction></f:metadata></h:head><h:head>
<f:metadata>
<f:viewaction action="#{accessController.verificarIsLogin()}">
</f:viewaction></f:metadata></h:head><div class="separator" style="clear: both;"><h:head></div><div class="separator" style="clear: both;"> <title>Facelet Title</title></div><div class="separator" style="clear: both;"> <f:metadata></div><div class="separator" style="clear: both;"> <b> <f:viewAction action="#{accessController.browserEvent()}"/></b></div><div class="separator" style="clear: both;"> </f:metadata></div><div class="separator" style="clear: both;"> </h:head></div><div class="separator" style="clear: both; text-align: center;"><br /></div>Y cuando ocurran los eventos el invocara el método broserEvent()., que realizara las validaciones correspondientes y nos dirigirá a la pagina que se almaceno en la sesión en la variable pageInView.<br /><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><div class="separator" style="clear: both;"><br /></div></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhRrqL0J0O1-opwjccj8btSBmhKLuBvac_We8rjTwXXlG-HQ0Hh_1EKgWiAIK-CKJs1j3ic7r_taMUrcO-iMrE3T0MYbbdgPGN0ssCKpBh6mvOfOvoAHLsKmm_Xx1vSGMfaUM8_ndfpKAqiZmUL5vCo_1iI7_xCThgv3T_z3qyjLtJju93mVg=s1135" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="673" data-original-width="1135" src="https://blogger.googleusercontent.com/img/a/AVvXsEhRrqL0J0O1-opwjccj8btSBmhKLuBvac_We8rjTwXXlG-HQ0Hh_1EKgWiAIK-CKJs1j3ic7r_taMUrcO-iMrE3T0MYbbdgPGN0ssCKpBh6mvOfOvoAHLsKmm_Xx1vSGMfaUM8_ndfpKAqiZmUL5vCo_1iI7_xCThgv3T_z3qyjLtJju93mVg=s16000" /></a></div><br /><div><br /></div>En la clase AccessController validamos la pagina indicada en pageInView y hacemos un llamado a ella.</div><div><br /></div><h3 style="text-align: left;">AccessController.java</h3><div><div> Boolean loggedIn = false;</div><div><br /></div><div> <b> public String login() {</b></div><div> loggedIn = Boolean.TRUE;</div><div>//Valide las credenciales de los usuarios</div><div> <b> JmoordbContext.put("pageInView", "/faces/index.xhtml");</b></div><div> return "/faces/index.xhtml";</div><div> }</div><div><br /></div><div><div> <b>public String browserEvent() {</b></div><div> </div><div> String pageInView = "";</div><div> try {</div><div> </div><div> pageInView = (String) JmoordbContext.get("pageInView");</div><div> </div><div> pageInView = (pageInView == null ? (loggedIn?"/faces/index.xhtml":"/faces/login.xhtml" ): pageInView);</div><div> System.out.println(" pageInView revisado"+ pageInView);</div><div> return pageInView;</div><div> </div><div> } catch (Exception e) {</div><div> }</div><div> return pageInView;</div><div> }</div></div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Desde cada Controller guardamos la ruta de la pagina xhtml a desplegar en pageInView</div><div class="separator" style="clear: both;"> JmoordbContext.put("pageInView", "/faces/index.xhtml");</div><div class="separator" style="clear: both;">y con solo indicar en cada formulario</div><div class="separator" style="clear: both;"><div class="separator" style="clear: both;"><h:head></div><div class="separator" style="clear: both;"> <title>Facelet Title</title></div><div class="separator" style="clear: both;"> <f:metadata></div><div class="separator" style="clear: both;"> <f:viewAction action="#{accessController.verificarIsLogin()}"/></div><div class="separator" style="clear: both;"> </f:metadata></div><div class="separator" style="clear: both;"> </h:head></div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Mantenemos al usuario en la misma pagina y evitamos que se dirigía a la pagina indicada en el web.xml.</div><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjg7kkvpB9bKwQoDYMdqxymGJD4sdsfuMmPtcDOZgaAInQ4Uto4YNErkoICmo2-bP8ygqct_YZslNZ35TNofS0pc7HoJE6MU4UiQXOLRBAabEcOLWjHM3O78qSt5poxdFCPJduu5_k3nVRUSqAgvzvv3adhzGxtGWIkMLKcVC8dyHm_5O477g" style="display: block; padding: 1em 0px; text-align: center;"><br /></a><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjg7kkvpB9bKwQoDYMdqxymGJD4sdsfuMmPtcDOZgaAInQ4Uto4YNErkoICmo2-bP8ygqct_YZslNZ35TNofS0pc7HoJE6MU4UiQXOLRBAabEcOLWjHM3O78qSt5poxdFCPJduu5_k3nVRUSqAgvzvv3adhzGxtGWIkMLKcVC8dyHm_5O477g" style="display: block; padding: 1em 0px; text-align: center;"><br /></a></div></div>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-72583355413400698842021-11-16T17:27:00.004-08:002021-11-16T17:27:43.563-08:00Java Champions<p> Este día recibí con mucha complacencia y para mi es un gran honor formar parte de los java Champions, <span style="background-color: white; color: inherit; font-family: inherit; font-size: inherit; font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; font-weight: inherit; white-space: inherit;"><a href="@Java_Champions">@Java_Champions</a></span></p><p>Mi nueva cuenta de Twitter es: <span style="background-color: white; color: #536471; font-family: TwitterChirp, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 15px; white-space: nowrap;">@aristidesvbravo</span></p><div class="css-901oao css-bfa6kz r-1awozwy r-1sw30gj r-z2wwpe r-6koalj r-1q142lx r-37j5jr r-n6v787 r-16dba41 r-1cwl3u0 r-13hce6t r-bcqeeo r-s1qlax r-qvutc0" dir="auto" style="-webkit-box-align: center; align-items: center; background-color: #eff3f4; border-radius: 4px; border: 0px solid black; box-sizing: border-box; color: #536471; display: flex; flex-shrink: 0; font-family: TwitterChirp, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 16px; margin: 0px 0px 0px 4px; max-width: 100%; min-width: 0px; overflow-wrap: break-word; overflow: hidden; padding: 0px 4px; text-overflow: ellipsis; white-space: nowrap;"></div><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-tgtCmmFQNKfb6p3ModweF_JtyyBw9wVLOu8IyViumYJoat6b1Pm3kkorhIFF1ga5fO0HzVJah2drmou63JnohOLFa3NYHFYc9PYWmAhoM7o9MsE4mT5EGkQaomUrOxs9k8rw/s400/9928f94d6fb7bc0024781fa68e0bc571_400x400.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="400" data-original-width="400" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-tgtCmmFQNKfb6p3ModweF_JtyyBw9wVLOu8IyViumYJoat6b1Pm3kkorhIFF1ga5fO0HzVJah2drmou63JnohOLFa3NYHFYc9PYWmAhoM7o9MsE4mT5EGkQaomUrOxs9k8rw/s320/9928f94d6fb7bc0024781fa68e0bc571_400x400.jpeg" width="320" /></a></div><div class="separator" style="clear: both; text-align: left;">Quiero agradecer a los miembros de la comunidad Java por el gran honor que me han dado. En este camino en la comunidad Java.</div><div class="separator" style="clear: both; text-align: left;">También a muchos amigos que han compartido durante muchos años este camino.</div><br /><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKz7B7mFzFw3V6DWhvt2LUO2nvUuZI91y2BCN9-jzo0WgDJPehbz5DpK_XorJkS37wXqvlfQXprYq22pp-d3PYQUTCH0Cf48X6Y_uy2DhAcONPqPo_GQ4DHR92xUmNeBELHIKH/s659/ds.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="424" data-original-width="659" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKz7B7mFzFw3V6DWhvt2LUO2nvUuZI91y2BCN9-jzo0WgDJPehbz5DpK_XorJkS37wXqvlfQXprYq22pp-d3PYQUTCH0Cf48X6Y_uy2DhAcONPqPo_GQ4DHR92xUmNeBELHIKH/s16000/ds.png" /></a></div><br /><p>La comunidad Java es una gran comunidad de muchas oportunidades, y conversaba con un gran amigo en la tarde de hoy sobre como involucrarse en la comunidad y como podemos hacer contribuciones al ecosistema de Java y sobre todo a las comunidades.</p><p>Podemos empezar por pasos pequeños: </p><p></p><ul style="text-align: left;"><li>Escribir sobre lo que sabemos , lo que nos gusta, ayudando a otros desarrolladores, compartiendo con ellos y aprendiendo cada día más de personas con un alto conocimiento, y siempre dispuestas a ayudarnos.</li><li>En lo personal el desarrollo de plugins para NetBeans sigue siendo una de mis principales actividades.</li><li>Crear Apis y Frameworks nos hace aplicar muchos conceptos y aprender en el camino.<br /></li><li>Las tecnologías para Microservicios como Eclipse Microprofile sin duda nos atraen mucho.</li><li>JakartaEE es mi preferido para el desarrollo de aplicaciones</li><li>Un proyecto sumamente interesante Jakarta NoSQL.</li><li>En los últimos años he estado creando un stack de componentes para NoSQL con Jakarta EE para ir probando cosas nuevas.</li><li>También he estado viendo unos proyectos de unos grandes amigos que estan creando unos Framework muy interesantes. Se que pronto lo tendrá terminado y ayudara mucho al desarrollo rápido de aplicaciones.</li></ul><div>A todas muchas gracias y en especial a Java Champions por este honor.</div><div><br /></div><p></p><p><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-16222650953835371932021-09-17T07:38:00.004-07:002021-09-17T07:38:31.417-07:00Jakarta Server Faces<p> Jakarta Server Faces es una excelente especificación que nos ofrece una forma fácil de crear aplicaciones Web, con grandess bibliotecas que puedes utilizar como lo son:</p><p><a href="https://omnifaces.org/">Omnifaces:</a> Liberia de utilidades</p><p><a href="https://www.primefaces.org/">Primefaces:</a> La mejor librería de componentes visuales para JSF.</p><p>Otra de las ventajas es que nosotros podemos crear nuestras propias bibliotecas de componentes y personalizar las aplicaciones a nuestra comodidad.</p><p>En mi caso he ido personalizando una biblioteca llamada jmoordbjsf , la cual esta optimizada para ser usada con jmoordb (APi para MongoDB), con jmoordbutils (Libreria de utilidades).</p><p>Aqui mostramos un enlace a las diferentes bibliotecas</p><p><a href="https://avbravo.github.io/">https://avbravo.github.io/</a><br /></p><p><br /></p><p>Pronto estaremos descrbiendo paso a paso la creación de una aplicación con Microprofile con MongoDB y Jakarta Server Faces (Primefaces + jmoordbjsf)</p><p><br /></p>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-49927705691262510352021-08-06T13:20:00.002-07:002021-08-06T13:20:25.271-07:00jmoordb 2.3 soporte para shell de MongoDB<p> Se ha incluido en la versión 2.3 de Jmoordb el soporte para ejecutar instrucciones de consultas y agregaciones que se ejecutan en MongoDB directamente en jmoordb. Con lo cual sera más facial expresar instrucciones de MongoDB.</p><p>En el siguiente enlace he detallado un ejemplo de su utilización, con un $elemMatch </p><p><a class="oiM5sf" dir="ltr" href="https://avbravo-2.gitbook.io/jmoordb/capitulo-4/introduccion-cap4/shell" jslog="91781; 11:%.@.0]; track:vis" rel="noopener nofollow noreferrer" style="-webkit-tap-highlight-color: transparent; background: rgb(255, 255, 255); font-family: Roboto, sans-serif; font-size: 14px; margin: 0px; padding: 0px; text-decoration-line: none; vertical-align: baseline; white-space: pre-wrap;" target="_blank">https://avbravo-2.gitbook.io/jmoordb/capitulo-4/introduccion-cap4/shell</a></p><p><br /></p><p><br /></p><p> <dependency></p><p> <groupId>com.github.avbravo</groupId></p><p> <artifactId>jmoordb</artifactId></p><p> <version>2.3</version></p><p> </dependency></p><p><br /></p><p><repositories></p><p> <repository></p><p> <id>jitpack.io</id></p><p> <url>https://jitpack.io</url></p><p> </repository></p><p> </repositories></p><pre style="border-radius: 6px; box-sizing: border-box; color: #c9d1d9; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13.6px; line-height: 1.45; margin-bottom: 0px; margin-top: 0px; overflow-wrap: normal; overflow: auto; padding: 16px; word-break: normal;"><br /></pre>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0tag:blogger.com,1999:blog-11140295.post-21520886545148534042021-06-23T10:20:00.005-07:002021-06-23T10:21:50.281-07:00Usando LazyDataModel con Jmoordb y Microprofile<h2 style="text-align: left;"> Usando LazyDataModel con Jmoordb y Microprofile</h2><p><br /></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Lazy es una característica muy interesante que nos permite mostrar solo unos registros en lugar</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> de todos por ejemplo en un DataTable. Esto reduce el tiempo de espera y disminuye el consumo </span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">de recursos para desplegar los. </span></p><p><span id="docs-internal-guid-0372d945-7fff-fa70-506b-570c005bb211"></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Un escenario puede ser donde tenemos 20000 registros y queremos mostrarlos en un datatable </span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">en la cual solo mostraremos 25 por pagina, no seria adecuado cargar los 20000 registros al mismo</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> tiempo. Para ello podemos utilizar LazyDataModel.</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><br /></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOidJiWiXXNnzIH7szl5pWP2KGuemZPGIUagKTRNHLQJ0nW6wlQzMNE25m7quO2n9ri7269ISE7uaMtDZ2aGA0vdBJmR3n_AMQ_Zjq7wzaTUjOmpo1eoIyoZbmx5-QTNmO5_72/s1036/vista.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="583" data-original-width="1036" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOidJiWiXXNnzIH7szl5pWP2KGuemZPGIUagKTRNHLQJ0nW6wlQzMNE25m7quO2n9ri7269ISE7uaMtDZ2aGA0vdBJmR3n_AMQ_Zjq7wzaTUjOmpo1eoIyoZbmx5-QTNmO5_72/s16000/vista.png" /></a></div><br /><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><br /></span><p></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><br /></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><br /></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Para usarlo agregar un objeto LazyDataModel con los métodos set/get:</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><br /></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">private LazyDataModel<Colegio> lazyDataModelColegio;</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">//set/get</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><br /></span></p><h1 dir="ltr" style="line-height: 1.38; margin-bottom: 6pt; margin-top: 20pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 20pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">En el método init</span></h1><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Instanciar el objeto lazyDataModelColegio y en el método </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">load()</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> haremos las implementaciones. El offset es el desplazamiento entre las paginas, sortBy tiene </span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">información sobre la ordenación y filterBy información sobre el filtro entre las columnas. </span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">En nuestro caso usaremos la clase paginator de jmoordb para gestionar varias acciones como</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> filtros que pueden cambiar las condiciones de búsqueda.</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><span id="docs-internal-guid-77fb3bfa-7fff-1484-ab0b-fb2cc42a052b"></span></span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">this.lazyDataModelColegio = new LazyDataModel<Colegio>() {</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> @Override</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> public List<Colegio> load(int offset, int pageSize, Map<String, SortMeta> sortBy, </span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Map<String, FilterMeta> filterBy) {</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> /// Implementación</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><span id="docs-internal-guid-1e261038-7fff-5c72-1050-c42e2ee266d0"></span></span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">}</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><br /></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial;"><span style="font-size: 14.6667px; white-space: pre-wrap;"><b>Implementación usando paginator de jmoordb</b></span></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial;"><span style="font-size: 14.6667px; white-space: pre-wrap;"><b>Pasos:</b></span></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"></p><ul style="text-align: left;"><li><span style="font-family: Arial;"><span style="font-size: 14.6667px; white-space: pre-wrap;"><b>Contar el numero de documentos que cumplen la condición</b></span></span></li><li><span style="font-family: Arial;"><b style="font-size: 14.6667px; white-space: pre-wrap;">Invocar el </b><span style="font-size: 14.6667px; white-space: pre-wrap;"><b>método</b></span><b style="font-size: 14.6667px; white-space: pre-wrap;"> </b></span> processLazyDataModel de la interace IPaginator de JmoordbUtils</li><li>Realizar la consulta</li><li>Actualizar lazyDataModelColegio con la cantidad de registros.</li></ul><p></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial;"><span style="font-size: 14.6667px; white-space: pre-wrap;"><br /></span></span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">// <editor-fold defaultstate="collapsed" desc="init"></span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> @PostConstruct</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> public void init() {</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> try {</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><b id="docs-internal-guid-2129b2e3-7fff-ff1e-f3a8-29e140d69028" style="font-weight: normal;"><br /></b></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> </span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><b style="font-weight: normal;"><br /></b></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> this.lazyDataModelColegio = new LazyDataModel<Colegio>() {</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> @Override</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> public List<Colegio> load(int offset, int pageSize, Map<String, SortMeta> sortBy, Map<String, FilterMeta> filterBy) {</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><b style="font-weight: normal;"><br /></b></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> Integer totalRecords = colegioServices.countJsonQuery(JmoordbDocument.bsonToJson(paginator.getQuery()));</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><b style="font-weight: normal;"><br /></b></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> processLazyDataModel(paginator, paginatorOld, offset, rowPage.get(), totalRecords, sortBy);</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> List<Colegio> result = colegioServices.jsonQuery(</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> JmoordbDocument.documentToJson(paginator.getQuery()),</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> JmoordbDocument.documentToJson(paginator.getSort()),</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> paginator.getPage(),</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> rowPage.get());</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> lazyDataModelColegio.setRowCount(totalRecords);</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> return result;</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> }</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><b style="font-weight: normal;"><br /></b></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> };</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> } catch (Exception e) {</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> System.out.println(JsfUtil.nameOfMethod() + " " + e.getLocalizedMessage());</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> JsfUtil.errorDialog(JsfUtil.nameOfMethod(), e.getLocalizedMessage());</span></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> }</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"></p><p dir="ltr" style="line-height: 1.2; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> }</span></p><div><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><br /></span></div><div><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><br /></span></div><div><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>Si tenemos algunos filtros lo implementamos con la clase paginator</b></span></div><div><span style="background-color: transparent; font-size: 14.6667px; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Arial;"> // @RolesAllowed({"admin"})
public String filterActive() {
try {
//Aqui aplicar un filter
Bson filter = eq("active", status);
Document sort = new Document("idcolegio", -1);
paginator
= new Paginator.Builder()
.page(1)
.query(JmoordbDocument.jsonToDocument(JmoordbDocument.bsonToJson(filter)))
.sort(sort)
.title(rf.getMessage("filter.active") + " = " + status)
.build();
} catch (Exception e) {
JsfUtil.errorDialog(JsfUtil.nameOfMethod(), e.getLocalizedMessage());
}
return "";
}
// </editor-fold></span></span></div>avbravohttp://www.blogger.com/profile/11646646633845998411noreply@blogger.com0