Nova postagem

Pesquisar

Anúncio
· jan 2

Resumen del mes de diciembre, 2024

¿No habéis podido entrar en la Comunidad todo lo que os gustaría? ¡No os preocupéis! Os traemos un resumen de todo lo que hemos publicado en el mes de diciembre. Seguid leyendo y no os lo perdáis ⬇️⬇️
Estadísticas generales
✓ publicaciones nuevas:
 18 artículos
 6 anuncios
 7 nuevas preguntas
Top 10 publicaciones
Top 5 Autores
Todos los artículos
#InterSystems IRIS
Actualización de Auditoría en 2024.3 - Eventos de Sentencias SQL Más Detallados
Por Alberto Fuentes
HL7 -> SDA -> FHIR -> Crecimiento Personal
Por Andre Ribera
Construyendo una imagen de IRIS con CPF Merge
Por Luis Angel Pérez Ramos
EduVerse: Asistente de Aprendizaje Accesible
Por Rolano Rebelo
QuinielaML - Predicción de la 27ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
¿Cómo generar un error personalizado?
Por Ricardo Paiva
QuinielaML - Predicción de la 29ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
Usando IRIS y Presto para consultas SQL de alto rendimiento y escalabilidad
Por Yuri Marx
Mejoras en la interoperabilidad de InterSystems con IRIS Whiz
Por Rob Ellis
Editad vuestros Globals con VSCode y YAML
Por Yuri Marx
QuinielaML - Predicción de la 31ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
Cómo Monitorear el crecimiento del tamaño de la base de datos y emitir alertas
Por Ricardo Paiva
Análisis más rápido de mensajes con IRIS Whiz
Por Rob Ellis
 
#Comunidad de Desarrolladores Oficial
 
#Portal de ideas de InterSystems
 
#Global Masters
 
#Portal de Formación
 
Todos los anuncios
Todas las preguntas
diciembre, 2024Month at a GlanceInterSystems Developer Community
Discussão (0)1
Entre ou crie uma conta para continuar
Resumo
· jan 2

Resumen de la Comunidad de Desarrolladores, diciembre 2024

Hola y bienvenidos al boletín de la comunidad de desarrolladores diciembre 2024.
Estadísticas generales
✓ publicaciones nuevas:
 18 artículos
 6 anuncios
 7 nuevas preguntas
10 nuevos miembros se unieron en diciembre
1,958 contenidos publicados de forma constante
721 miembros se unieron de forma constante
Publicaciones populares
Autores populares
Artículos
#InterSystems IRIS
Actualización de Auditoría en 2024.3 - Eventos de Sentencias SQL Más Detallados
Por Alberto Fuentes
HL7 -> SDA -> FHIR -> Crecimiento Personal
Por Andre Ribera
Construyendo una imagen de IRIS con CPF Merge
Por Luis Angel Pérez Ramos
EduVerse: Asistente de Aprendizaje Accesible
Por Rolano Rebelo
QuinielaML - Predicción de la 27ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
¿Cómo generar un error personalizado?
Por Ricardo Paiva
QuinielaML - Predicción de la 29ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
Usando IRIS y Presto para consultas SQL de alto rendimiento y escalabilidad
Por Yuri Marx
Mejoras en la interoperabilidad de InterSystems con IRIS Whiz
Por Rob Ellis
Editad vuestros Globals con VSCode y YAML
Por Yuri Marx
QuinielaML - Predicción de la 31ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
Cómo Monitorear el crecimiento del tamaño de la base de datos y emitir alertas
Por Ricardo Paiva
Análisis más rápido de mensajes con IRIS Whiz
Por Rob Ellis
#Comunidad de Desarrolladores Oficial
#Portal de ideas de InterSystems
#Global Masters
#Portal de Formación
Anuncios
Preguntas
diciembre, 2024Month at a GlanceInterSystems Developer Community
Artigo
· jan 2 5min de leitura

Creating a REST client to get Tracks from Spotify REST API - Part5 creating my own REST service

Last Chapter: Creating a REST client to get Tracks from Spotify REST API - Part4 Save the Search Result

Git link: https://github.com/ecelg/InterSystems-IRIS-as-a-Spotify-REST-client

 

OK.... based on what I have done.... I am able to 

1. Query Track information by making use of the Spotify API

2. Store the necessary data into my own album, artists, and track table

 

so.... what next?🤔 How about I set up my own REST API service on my IRIS for the other people to query my table?🤔🤨

 

ok... 1st... start from document Introduction to Creating REST Services

so we have 2 ways to implement a REST service on IRIS

Way 1. Using the OpenAPI 2.0 specification 

Way 2. Creating a REST Service Manually

mummmm...both are ok for me.... how about trying the way 2?

 

OK Let's start with a simple HelloWorld!!!


1.  Create a business service class rest.bs.RestService.cls extend the class  %CSP.REST   

Create a folder bs under the folder rest

Create a class RestService.cls under the folder bs

replace the code by the following

Class rest.bs.RestService Extends %CSP.REST
{

Parameter CONTENTTYPE = "application/json";
XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>
		<Route Url="/hello" Method="GET" Call="HelloWorld" />
	</Routes>
}

ClassMethod HelloWorld() As %Status
{
	//define a DynamicObject
	#dim tJSON As %DynamicObject={}
	
	//set the keys and values
	set tJSON."test_message"="Hello World!!"
	// write to response
	do ##class(%JSON.Formatter).%New().Format(tJSON)
	
	return $$$OK
}

}

Save it

 


2. Create a Web Application for this REST service

Open the management portal

Go to the page Web Applications

Name : /csp/myapi

Namespace : demo

Dispatch Class: rest.bs.RestService

Save

Assign %All in the application roles

 


3. Test the api

GET localhost/csp/myapi/hello

localhost can be replace as the url of your server, /csp/myapi is the path that I defined in the web application, /hello
is the path of the class method I would like to call, which is defined in the class rest.bs.RestService

Yeah!!! My REST API is working!!!😆😆

 


Now... let's try to let our API users search our tracks by the id of the track table

and write it to JSON as response to our API users

 

4. add the routing path to the class rest.bs.RestService.cls

We add the /:id as the arguments(in this case, it will pass into the 1st argument) for query, this argument will pass into the class method Track(will be implement in the next session) for process

<Route Url="/spotify/track/:id" Method="GET" Call="Track" />

 

 


5. Add the Class Method Track

This method will look up the related data based on the argument /:id  and return as JSON response

Add the following class method in to the class rest.bs.RestService.cls

ClassMethod Track(pId As %Integer) As %Status
{
	kill a
	//open an object with id
	set a=##class(rest.spotify.track).%OpenId(pId)
	
	//convert to JSON String
	set b=""
	do a.%JSONExportToString(.b)
	kill a
	
	// write to response
	w b
	return $$$OK
}

save the class

 


6. Test it!!!!

GET localhost/csp/myapi/track/5

localhost can be replace as the url of your server, /csp/myapi is the path that I defined in the web application, /track
is the path of the class method I would like to call, which is defined in the class rest.bs.RestService/5 is the argument for looking up the track by id

Yeah!!!  working!!!!😀

 


Ok seems working well!!!😁 My final question is... how to let our user search for a track???

mummmm... at least.. we can search by name of the track, market, or maybe by artist

OK... let's add another route and class method to handle it!!

 

7. add the routing path to the class rest.bs.RestService.cls

<Route Url="/spotify/searchtrack" Method="GET" Call="SearchTrack" />

 



8. Add the Class Method SearchTrack

This method will look up the related data based on the parameters name, market, artist  and return as JSON response

 

to get the parameters, you may use the code  $GET(%request.Data({paramete_key},1),""), for example to get the parameter name  $GET(%request.Data("name",1),"")

Add the following class method in to the class rest.bs.RestService.cls
 

ClassMethod SearchTrack() As %Status
{
	// get the parameter "name"
	#dim tname As %String=$GET(%request.Data("name",1),"")
	// get the parameter "name"
	#dim tmarket As %String=$GET(%request.Data("market",1),"")
	// get the parameter "name"
	#dim tartists As %String=$GET(%request.Data("artists",1),"")
	
	set sname="%"_tname_"%"
	set trowid=0
	&sql(SELECT top 1 ID into :trowid FROM rest_spotify.track where name like :sname order by popularity desc)
	set tarowid=""
	if (tartists'="")
	{
		set sartists=tartists
		&sql(SELECT top 1 ID into :trowid FROM rest_spotify.track where name like :sname  and album->artists->name like :sartists order by popularity )
	}
	if tarowid'="" set trowid=tarowid
	/*//debug
	//define a DynamicObject
	#dim tJSON As %DynamicObject={}
	//set the keys and values
	set tJSON."debug_message_name"=$replace(tname," ","%20")
	set tJSON."debug_message_market"=tmarket
	set tJSON."debug_message_rowid"=trowid
	// write to response
	do ##class(%JSON.Formatter).%New().Format(tJSON)
	*/
	if (trowid="")
	{
		/*//debug
		//define a DynamicObject
		#dim tJSON As %DynamicObject={}
		//set the keys and values
		set tJSON."debug_message_rowid"="not found"
		// write to response
		do ##class(%JSON.Formatter).%New().Format(tJSON)
		*/
		set tquery="offset=5&limit=10&query="_tname_"&type=track&market="_tmarket
		set str=##class(rest.utli.requestUtli).getdata("Spotify","/search",tquery)
		set std=##class(rest.utli.spotifyUtli).getSearchResult(str)
		&sql(SELECT top 1 ID into :trowid FROM rest_spotify.track where name like :sname order by popularity desc)
	}
	if (trowid>0)
	{
		//open an object with id
		set a=##class(rest.spotify.track).%OpenId(trowid)
		
		//convert to JSON String
		set b=""
		do a.%JSONExportToString(.b)
	
		// write to response
		w b
		return $$$OK
	}
	
	return $$$OK
}

save the class

 


9. Test it again!!!

 

GET localhost/csp/myapi/searchtrack?name=APT&market=SG&artists=

localhost can be replace as the url of your server, /csp/myapi is the path that I defined in the web application, /track
is the path of the class method I would like to call, which is defined in the class rest.bs.RestServicename, market, artist are the parameter input for searching

Yeah!! working!!!😁

Let's try one more

GET localhost/csp/myapi/searchtrack?name=call me maybe&market=SG&artists=Carly Rae Jepsen

Discussão (0)1
Entre ou crie uma conta para continuar
Artigo
· jan 1 2min de leitura

第六十二章 假脱机设备 - 查看 ^SPOOL 全局

第六十二章 假脱机设备 - 查看 ^SPOOL 全局

查看 ^SPOOL 全局

与任何下标的全局变量一样,您可以通过发出 WRITE 命令来显示 spool 文件中的行,如下所示:

   WRITE "1st spool file node: ",^SPOOL(1,1),!

但是,要查看和编辑假脱机文件本身,请转到管理门户并选择 System ExplorerGlobals。选择您当前的命名空间,找到 SPOOL 全局变量,然后单击 data。这将显示类似于以下示例的假脱机文件数据。

在下面的假脱机文件中,() 终止字符结束假脱机文件中的每个节点行。这些终止字符是假脱机文件的一部分,作为 $CHAR(13,10) 连接到文本字符串(ReturnLine Feed)。

Discussão (0)1
Entre ou crie uma conta para continuar
Anúncio
· jan 1

开发者社区回顾, 十二月 2024

您好,欢迎阅读 十二月 2024 开发人员社区通讯。
统计信息
✓ 十二月发布了 32 篇新帖子:
 29篇新文章
 1 new announcement
 2个新问题
✓ 十二月有 29 位新成员加入
✓ 所有时间发布了 2,316 篇帖子
✓ 所有时间有 2,100 位成员加入
最高职位
本月最佳作家
文章
#InterSystems IRIS
 
#InterSystems IRIS for Health
第三十八章 终端输入 输出 - USER命令
按姚 鑫
第三十九章 终端输入 输出 - terminator
按姚 鑫
第四十章 终端输入 输出 - OPEN 和 USE 命令的关键字参数
按姚 鑫
第四十章 终端输入 输出 - 用于OPEN和USE的字母代码协议
按姚 鑫
第四十一章 终端输入 输出 - 协议终止符
按姚 鑫
第四十二章 终端输入 输出 - 显式终止符
按姚 鑫
第四十三章 终端输入 输出 - READ 命令
按姚 鑫
第四十四章 终端输入 输出 - 特殊协议字符影响终端 I O
按姚 鑫
第四十五章 终端输入 输出 - WRITE 命令
按姚 鑫
第四十六章 终端输入 输出 - CLOSE 命令
按姚 鑫
第四十七章 终端输入 输出 - DTM PC 控制台的助记符空间
按姚 鑫
第四十九章 终端输入 输出 - 转义序列编程
按姚 鑫
第五十章 File 输入 输出
按姚 鑫
第五十一章 File 输入 输出 - 文件路径名工具
按姚 鑫
第五十二章 File 输入 输出 - OPEN模式参数
按姚 鑫
第五十三章 File 输入 输出 - OPEN模式参数
按姚 鑫
第五十四章 File 输入 输出 - OPEN 参数关键字
按姚 鑫
第五十五章 File 输入 输出 - 与非 InterSystems IRIS 软件的交互
按姚 鑫
第五十六章 File 输入 输出 - USE 命令
按姚 鑫
第五十七章 File 输入 输出 - READ 命令
按姚 鑫
第五十八章 File 输入 输出 - WRITE 命令
按姚 鑫
第五十九章 假脱机设备
按姚 鑫
第六十章 假脱机设备 - WRITE 命令
按姚 鑫
第六十一章 假脱机设备 - 假脱机和特殊变量
按姚 鑫
 
#InterSystems IRIS BI (DeepSee)
 
公告
#开发者社区官方
 
问题
十二月, 2024Month at a GlanceInterSystems Developer Community
Discussão (0)0
Entre ou crie uma conta para continuar