go to post Marcio Coelho · Apr 26, 2022 Thank you @John Murray I create a method using the query SubclassOf that you shared.....
go to post Marcio Coelho · Jan 28, 2022 Hi @Maslennikov.Dmitry... I get the error on execute the line with "write args(1)" after "use $io..."Not possible execute "write" from process with JDBC connection.I will change all %Zen from my code coming soon. Thanks for warning
go to post Marcio Coelho · Jan 13, 2022 Hi Dan.Thank you so much. The code worked. Now I will work to improve my example. Thanks
go to post Marcio Coelho · Jan 12, 2022 Hi Dan... This is $zv from Iris instance. IRIS for UNIX (Red Hat Enterprise Linux for x86-64) 2021.1 (Build 215U) Wed Jun 9 2021 09:48:12 EDT I think you meant "Inverse proxy Object" HereI changed my code to this:Iris Class Class Utils.CSW1JavaFunctions Extends %RegisteredObject [ ClassType = "", Not ProcedureBlock ] { ClassMethod IrisReturn(user, pass) As %Stream.GlobalBinary [ ProcedureBlock = 1 ] { ; set cswStream=##class(%Stream.GlobalBinary).%New() ; set cswReturn=##class(%ZEN.proxyObject).%New() set cswReturn.user=$get(user) set cswReturn.pass=$get(pass) set cswReturn.success=1 ; try { set cswObj = ##class(%ZEN.Auxiliary.altJSONProvider).%ObjectToAET(cswReturn,,,"d") do cswObj.%ToJSON(cswStream) } catch ex { throw ex } quit cswStream } } I am not use Persistence class. In my case, my classes extends from %RegisteredObjectChange Java method to this: public Object execute(String method, Object... args) throws Exception { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = null; try { byte[] data = iris.classMethodBytes(CACHE_CLASS_NAME, method, args[0], args[1]); InputStream is = new ByteArrayInputStream(data); /* Just debug */ BufferedReader in = new BufferedReader(new InputStreamReader(is)); String line = null; while ((line = in.readLine()) != null) { System.out.println(line); } jsonNode = (JsonNode) mapper.readTree(is); } catch (Exception ex) { ex.printStackTrace(); } return jsonNode; } With this example, I get "3@%Stream.GlobalBinary" in console... lol :)
go to post Marcio Coelho · Jan 12, 2022 I created a very simple example with java classes and Iris methods. I make return a json string to demonstrate. I need to change this Strings to Strems. Ok?I use quarkus and jdk 11 and Iris database Restasy endpoint @Path("/session") @RequestScoped public class SessionEndPoint { @Inject BrokerService brokerService; private ObjectMapper mapper = new ObjectMapper(); @POST @Path("IrisReturn") @Produces(MediaType.APPLICATION_JSON) public Response systemBoot(@HeaderParam("user") String user, @HeaderParam("pass") String pass) { ResponseBuilder response = Response.ok(); try { JsonNode serverReturn = (JsonNode) brokerService.execute("IrisReturn", user, pass); response = Response.ok(mapper.writeValueAsString(serverReturn)); } catch (Exception ex) { response = Response.status(Status.INTERNAL_SERVER_ERROR); } return response.build(); } } Class BrokerService with @Inject datasource and unwrap to IrisConnection @RequestScoped public class BrokerService { @Inject DataSource dataSource; private Connection conn; private IRIS iris; private static String CACHE_CLASS_NAME = "Utils.CSW1JavaFunctions"; @PostConstruct public void linit() { try { conn = dataSource.getConnection(); IRISConnection iconn = (IRISConnection) conn.unwrap(IRISConnection.class); iris = IRIS.createIRIS(iconn); } catch (Exception e) { System.err.println("Connection erro!"); e.printStackTrace(); } } public Object execute(String method, Object... args) throws Exception { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = null; IRISReference cacheReturn = new IRISReference(""); try { iris.classMethodStatusCode(CACHE_CLASS_NAME, method, cacheReturn, args[0], args[1]); String xxxxxx = mapper.writeValueAsString(cacheReturn.getValue()); jsonNode = (JsonNode) mapper.readTree(xxxxxx); } catch (Exception ex) { ex.printStackTrace(); } return jsonNode; } } Iris Method ClassMethod IrisReturn(ByRef cswStream As %String, user, pass) As %Status [ ProcedureBlock = 1 ] { ; set cswStream="" //set cswStream=##class(%Stream.GlobalBinary).%New() ; set cswReturn=##class(%ZEN.proxyObject).%New() set cswReturn.user=$get(user) set cswReturn.pass=$get(pass) set cswReturn.success=1 ; try { set cswObj = ##class(%ZEN.Auxiliary.altJSONProvider).%ObjectToAET(cswReturn,,,"d") set cswStream=cswObj.%ToJSON() } catch ex { set ^%MJ("ee")=ex.AsStatus() } quit $$$OK } To test my example, I use curl curl -i -X POST -H "user: marcio.coelho" -H "pass: 123" -H "Content-Type: application/json" http://localhost:8090/session/IrisReturn Return "{\"pass\":123,\"success\":1,\"user\":\"marcio.coelho\"}" I need that parameter cswStream is a Stream. But.. I dont find examples in documentation to use Streams in java.With you need the project, I can upload in my GitHub Account and share to you.
go to post Marcio Coelho · Dec 17, 2021 I talked to intersystems support. he asked me to break validation into two steps. one for each Tag. I'm trying to follow the support tips. But without success so far. In this example I'm trying to validate just the first <NFe> tag ; ; set sc=$$ValidateNFe("teste.xml","v400") ; ValidateNFe(cswFileNameOrStream,cswNFeVersion) ; new reader,sc,data,nfeStream,protNFeStream,clazzProc,clazzNFe,clazzProtNFe ; set sc=$$Reader(cswFileNameOrStream,.reader) quit:$$$ISERR(sc) sc ; set clazzProc="br.com.sefaz.nfe."_cswNFeVersion_".TNfeProc" ; set sc=##class(%Dictionary.CompiledClass).%ExistsId(clazzProc) quit:$$$ISERR(sc) $$$ERROR(10000,"Classe ("_clazzProc_") não existente!") ; do reader.Correlate("nfeProc",clazzProc) if 'reader.Next(.data,.sc){ quit $$$ERROR(10000,"Arquivo XML inválido!") } ; set sc=$$XmlToStream(data.NFe,.nfeStream) quit:$$$ISERR(sc) sc ; set sc=##class(%XML.Document).GetDocumentFromStream(nfeStream,.document) do document.AddIDs() quit data.NFe.Signature.ValidateDocument(document) Reader(cswFileNameOrStream,cswReader) ; new sc ; set cswReader=##class(%XML.Reader).%New() set sc=cswReader.OpenStream(cswFileNameOrStream) quit sc XmlToStream(cswObj,xmlStream) ; new writer,sc ; set writer=##class(%XML.Writer).%New() set writer.Charset="UTF-8" set writer.Indent=1 set writer.NoXMLDeclaration=1 set xmlStream=##class(%GlobalBinaryStream).%New() ; set sc=writer.OutputToStream(.xmlStream) quit:$$$ISERR(sc) sc ; set sc=writer.RootObject(cswObj) quit sc I get this error w sc FailedCheck I believe that my "XmlToStream" rule is changing the original XML and therefore the validation was compromised. Does that make any sense?
go to post Marcio Coelho · Nov 30, 2021 Thanks for the reply Mr. Cemper. But my application has much more complex json layouts. This was just a very basic example. From the tests I did with Stream, it is ok. My problem is how to get this stream via Java through a JDBC connection
go to post Marcio Coelho · Dec 11, 2019 I noticed that ^% G has become unusable due to performance. I will direct my tests to another tool
go to post Marcio Coelho · Dec 2, 2019 This is works.... but sound like a workarround: set sc='$zf(-1,"export USER=`whoami` && export HOME=$( getent passwd ""$USER"" | cut -d: -f6 ) && touch $HOME/file.txt")
go to post Marcio Coelho · Dec 2, 2019 I try to set $HOME before to write file, but... when I run third party software that reads the configuration file, the $ HOME variable goes back to / root
go to post Marcio Coelho · Dec 2, 2019 I need to run third party software that needs a configuration file in $HOME
go to post Marcio Coelho · Oct 29, 2019 Hello Kevin. Thank you for your attention. I am trying to send an InputStream to the database.My Stream is coming from a rest service (jax-rs, upload) I have an average file size of 200Mb. I have a "prepareStatement" with sql query "Insert into <Class with %GlobalBinaryString property>"
go to post Marcio Coelho · Oct 29, 2019 Hello Kevin... The problem is a byte[] and java heap space. I have 200Mb into a InputStream and convert this a byte[], cause java.lang.OutOfMemoryError: Java heap space It's a piece of my code.... ByteArrayOutputStream buffer = new ByteArrayOutputStream(); int nRead; byte[] data = new byte[1024]; while ((nRead = binaryStream.read(data, 0, data.length)) != -1) { buffer.write(data, 0, nRead); } SerialBlob blob = new SerialBlob(buffer.toByteArray());
go to post Marcio Coelho · Oct 17, 2019 Bad news to me. Iris driver do not connect to cache 2018. And this is my case