new ArrayList json.parse

发布时间:2022-06-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了new ArrayList json.parse脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

package com.sapdev.ws.getoperation;

import java.text.MessageFormat;import java.util.ArrayList;import java.util.List;import java.util.Map;

import javax.annotation.Resource;import javax.jws.WebMethod;import javax.jws.WebParam;import javax.jws.WebService;import javax.xml.ws.WebServiceContext;

import com.sap.engine.services.webservices.espbase.configuration.ann.dt.AuthenticationDT;import com.sap.engine.services.webservices.espbase.configuration.ann.dt.AuthenticationEnumsAuthenticationLevel;import com.sap.engine.services.webservices.espbase.configuration.ann.rt.AuthenticationRT;import com.sap.me.extension.Services;import com.sapdev.service.LogicServiceInterface;import com.sapdev.service.dto.LogicQueryResponse;import com.sapdev.service.dto.SqlQueryRequest;

import net.sf.json.JSONArray;import net.sf.json.JSONObject;

@AuthenticationDT(authenticationLevel = AuthenticationEnumsAuthenticationLevel.BASIC)@AuthenticationRT(AuthenticationMethod = "sapsp:HTTPBasic")@WebServicepublic class FirstOperationService {    @Resource    protected WebServiceContext wsContext;    //private final String GET_OPERATION_OBJECT = "SELECT * FROM Z_DIALOG WHERE DIALOG_ID = ''{0}''";    private final String GET_OPERATION_OBJECT = "SELECT operation,description,revision FROM operation WHERE status_bo =''StatusBO:{0},201'' ORDER BY operation";

    @WebMethod    public String getOperation(@WebParam(name = "opRequest") OperationRequest opRequest) throws Exception {

        String site = opRequest.getSite();        String sqls = MessageFormat.format(GET_OPERATION_OBJECT, site);        LogicServiceInterface lservice = Services.getService("com.sapdev.service", "LogicService", site);        // LogicService lservice = new LogicService();s        SqlQueryRequest sqlrequest = new SqlQueryRequest();        sqlrequest.setSql(sqls);        LogicQueryResponse LQRresponse = lservice.query(sqlrequest);        /*OperationResponse operationObj = new OperationResponse();

        List<Map> data = LQRresponse.getRecords();        List<OperationRecord> operList = new ArrayList<OperationRecord>();        if (data != null && data.size() > 0) {            for (Map map : data) {                OperationRecord or = new OperationRecord();                or.setOperation(map.get("OPERATION").toString());                or.setDeacription(map.get("DESCRIPTION").toString());                or.setRevision(map.get("REVISION").toString());                operList.add(or);            }        }        operationObj.setData(operList);

        return operationObj;*/                JSONObject json = new JSONObject();        List<Map> data = LQRresponse.getRecords();        List<OperationRecord> operList = new ArrayList<OperationRecord>();        JSONArray array = new JSONArray();        if (data != null && data.size() > 0) {            for (Map map : data) {                JSONObject object = new JSONObject();                object.put("operation", map.get("OPERATION").toString());                object.put("description", map.get("DESCRIPTION").toString());                object.put("revision", map.get("REVISION").toString());                                array.add(object);            }        }                json.put("json", array);        return json.toString();    }        /*    public static void main(String[] args) throws GetOperationException, Exception {            GetOperationRequest request=new GetOperationRequest();            request.setSite("1000");            GetOperationResponse a=new GetOperationService().getOperation(request);        }*/}

脚本宝典总结

以上是脚本宝典为你收集整理的new ArrayList json.parse全部内容,希望文章能够帮你解决new ArrayList json.parse所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: