查找

Artículo
· 13 nov, 2024 Lectura de 3 min

Pasarela de Lenguaje Externo de Java

Si os gusta Java y tenéis un ecosistema Java activo en el trabajo en el que necesitáis incorporar IRIS, no es un problema. La Pasarela de Lenguaje Externo de Java lo hará sin complicaciones, o casi. Esta pasarela sirve como puente entre Java y ObjectScript en IRIS. Podéis crear objetos de clases Java en IRIS y llamar a sus métodos. Solo necesitáis un archivo jar para hacerlo.

Connection diagram: proxy object <-> Gateway object <-> TCP/IP <-> External server <-> target object

Lo primero que debéis hacer es configurar el entorno. Para empezar a usar la Pasarela de Java, aseguraos de tener lo siguiente:

  1. InterSystems IRIS: Instalado y en funcionamiento.  
  2. Java Development Kit (JDK): Instalado y configurado

El segundo requisito puede parecer simple, ya que ya usáis Java en vuestro trabajo, pero no lo es. Gracias a esta cuestión, resultó que necesitáis usar la versión 11 de JDK como máximo. Esto significa que debéis cambiar la versión en vuestro IDE, lo cual puede causar bastantes complicaciones.

El siguiente paso es verificar que todo funcione e intentar instanciar el objeto de una clase del sistema de Java. Para hacer esto, tenéis que iniciar una conexión, crear un objeto proxy y llamar a un método. Suena como mucho código, pero en realidad es solo una línea:

write $system.external.getJavaGateway().new("java.util.Date").toString()

Esto imprimirá la fecha y hora actual en la pantalla.

Para ir más allá, podemos crear nuestra propia clase en Java:


public class Dish {
	private String name;
	private String description;
	private String category;
	private Float price;
	private String currency;
	private Integer calories;
	
	public void setName(String name) {
		this.name = name;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public void setPrice(Float price) {
		this.price = price;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}

	public void setCalories(Integer calories) {
		this.calories = calories;
	}
	
	public String describe() {
		return "The dish "+this.name+" costs "+this.price.toString()+
				this.currency+" and contains "+this.calories+" calories!";
	}
}

y llamar a sus métodos desde ObjectScript:

 set javaGate = $SYSTEM.external.getJavaGateway()
 do javaGate.addToPath("D:\Temp\GatewayTest.jar")
 set dish = javaGate.new("Dish")
 do dish.setCalories(1000)
 do dish.setCategory("salad")
 do dish.setCurrency("GBP")
 do dish.setDescription("Very tasty greek salad")
 do dish.setName("Greek salad")
 do dish.setPrice(15.2)
 write dish.describe()

Como resultado, obtendremos una cadena con la descripción del plato creado:

The dish Greek salad costs 15.2GBP and contains 1000 calories!

En Español: El plato Ensalada Griega cuesta 15,2 GBP y contiene 1000 calorías.

De todos modos, aprendéis más sobre el uso de las Pasarelas en la Documentación y ¡buena suerte implementando este conocimiento en vuestros proyectos!

Comentarios (0)1
Inicie sesión o regístrese para continuar
Pregunta
· 13 nov, 2024

Charting lineage across views and statements

Hi,

A customer today asked whether we could offer anything like the nice lineage charts that dbt offers, based on SQL view metadata. They are very much aware of our dbt-iris adapter, but were asking in the context of their landing area, which combines foreign tables and views, ahead of possibly using dbt for onward transformations.

I didn't have anything to point at right away, but was wondering if any creative minds in the Developer Community would have looked into something like this, and used any data viz libraries to feed on the DependsOn keyword for SQL view classes that point at the tables they depend on. And while we're at it, a similar (or combined) type of analysis could be made for query statements as a whole, drawing from the INFORMATION_SCHEMA.STATEMENT_RELATIONS table. I'm curious if this resonates with the audience here, and if someone would have particular suggestions wrt the graphics libraries one might use to implement this.

Thanks,
benjamin

Comentarios (0)1
Inicie sesión o regístrese para continuar
Pregunta
· 13 nov, 2024

SQL CLASS NODE SYNTAX

I HAVE A NEW SQL CLASS THAT DISPLAYS ENTRIES BASED ON THE FIRST 2 NODES OF A GLOBAL. I FOUND OUT THAT THE CLASS ALLOWS FOR AN ADDITIONAL NODE(s) TO BE INSERTED IN THE "User Specification Node:" along the delimiter and the Piece in the NewStorage Map1 for "ModifyDDDD" shown below. it is not working.

^GBL("AA","SSSSSS")="1:1:1:1:"

^GBL("AA,"MD",1,1)="1:"

^GBL("AA,"MD","A",1)="0:"

I HAVE USED THIS:

<Data name="ModifyDDDD">
<Delimiter>":"</Delimiter>
<Node>"3,4"</Node>
<Piece>1</Piece>
</Data>

WHILE IT COMPILES IT DISPLAY NOTHING. MY QUESTION IS WHAT IS THE RIGHT SYNTAX AND PUNTUATION FOR THIS, PLEASE?

HOW DO I TYPE IN THE <Node> tag the proper formated data? <Node>"MD","A",1</Node> ??????

Since the class is build on the first 2 nodes, should it be <Node>"A",1</Node>

I tried many different combinations to no avail.

5 comentarios
Comentarios (5)2
Inicie sesión o regístrese para continuar
Pregunta
· 13 nov, 2024

%CSP.Page.Include doesn't seem to work

I'm trying to rewrite a legacy portal created with all .csp files into a portal written in .cls files. The problem I have is that the old cap pages use "csp:include page='page.csp'> tags. I'm trying to use the Include method  that is in the %CSP.Page master page. It doesn't seem to insert the required file. Any suggestions?
 

<table width="100%">
<tr>
<script language="Cache" runat="server">
do ..Include("pubsub/portal/include/headLogoDXC.csp")
#; <!--csp:include page="/pubsub/portal/include/headLogoDXC.csp"-->
</script>
</tr>
</table>
1 Comentario
Comentarios (1)1
Inicie sesión o regístrese para continuar
Resumen
· 13 nov, 2024

InterSystems Community Q&A Monthly Newsletter #42

Top new questions
Can you answer these questions?
#InterSystems IRIS
Error Executing Stored Procedure in InterSystems Cache using SQL
By Qais Azam
How to package a custom IPM resource processor?
By Jani Hurskainen
cannot connect to the management portal but can connect to the web gateway - "Server is currently unavailable"
By Fred Gustafsson
Production "Update" activation which prevents tasks from running
By Moussa SAMB
Can InterSystems IRIS Data Platform 2019 be Integrated with Snowflake?
By Pavan Kumar Rayudu
setting up ALB and Proxy container
By Jignesh Patel
Running a routine by name in a non-conventional way?
By omer
Existing protections against XSS attacks on CSP pages ?
By Norman W. Freeman
How to view the patch version
By Martin Weissenborn
How to search message details in LIVE based on MRN
By prashanth ponugoti
dynamic SQL in object script code
By Kaveh Kaviani
IRIS Docker template not copying files
By Nicki Vallentgoed
Load and compile error
By omer
How to get the native sql error in SQL outbound adapter?
By Kurro Lopez
VSCode auto complete and show class methods while typing
By Paul Hula
Python import Iris AccessDenied
By Herman Slagman
Is there some tricks to make $system.obj.load() faster ?
By Norman W. Freeman
How to handle a XML without Schema in a Business Rule?
By Nicky Zhu
Operation Email sender error #6034 connection with SMTP not successfull
By Jacopo Magliani
#Caché
#InterSystems IRIS BI (DeepSee)
#InterSystems IRIS for Health
Monitoring - Adding multiple labels to a custom metric
By Claude Mourzelas
how to get notification that a web client has disconnected when using EnsLib.SOAP.Service/EnsLib.REST.Service
By Elisha Gould
Production messages visualization
By Dmitrii Baranov
File generation issues while using $ZF(-100 asynchronously
By Ashok Kumar
zToQuickXML+11^HS.SDA3.NVPair
By Shashvati Dash
FHIR "Search selects more than maximum allowed number of results (1000)."
By Dmitrii Baranov
ForEach with Assign only returning the second looped aux value in foreach when sending from rule editor
By Mark OReilly
SourceControl of InterSystems health IRIS cloud
By Yuhong Snyder
Can you build an IRIS Container without a license?
By John McBride
Help Needed: How to Ensure BPL ????? for All Asynchronous Calls Before Proceeding?͓̽
By Yone Moreno Jimenez
I want to test if two fields are numeric and positive, do subtraction, and test if the result is positive.
By Jonathan Harris
#Health Connect
#Ensemble
#42Monthly Q&A fromInterSystems Developers