Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to return return a single record in a list of maps?  RSS feed

 
Sharib Zafar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
private List<Map<String, Object>> mapResponse(ConsultasWsRet[] resp){
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

for (ConsultasWsRet obj:resp){
Map<String, Object> ctxResponse = new HashMap<String, Object>();
ctxResponse.put(IContextDataKeys.MSISDN1, obj.getMSISDN());
ctxResponse.put(IContextDataKeys.MSISDN2, obj.getMSISDN2());
ctxResponse.put(IContextDataKeys.OPERATOR_DESCRIPTION, obj.getOperdescripcion());
ctxResponse.put(IContextDataKeys.OPERATOR_VIRTUAL_DESCRIPTION, obj.getOpervdescripcion());
ctxResponse.put(IContextDataKeys.OPERATOR_RECEPTOR, obj.getReceptor());
ctxResponse.put(IContextDataKeys.OPERATOR_VIRTUAL_RECEPTOR, obj.getReceptorVirtual());
ctxResponse.put(IContextDataKeys.CREATION_DATE, obj.getFechaCreacion());
ctxResponse.put(IContextDataKeys.LAST_DATE_MODIFICATION, obj.getFechaUltimaModificacion());
ctxResponse.put(IContextDataKeys.LAST_DATE_CANCEL, obj.getFechaVentanaDefinitiva());
ctxResponse.put(IContextDataKeys.COD_STATUS, obj.getEstado());

WebServiceClientUtil.readMap(ctxResponse, "Portabilidad - PT4 :: ConsultationPortabilityWebServiceClient :: Muestra los datos recibidos del servicio Web MPS -> ");

list.add(ctxResponse);
}
return list;
}
*****************************************************************************************************************************
The above program returns a List of Map.
I need to filter record based on the creation_date((IContextDataKeys.CREATION_DATE, obj.getFechaCreacion()) field from objects and compare them
to leave only the most recent. So in this sample you would leave an array with only one object.

how do i do this?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!