zoukankan      html  css  js  c++  java
  • 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")
    @WebService
    public 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);
            }*/
    }

  • 相关阅读:
    spring源码学习之容器的扩展(二)
    spring源码学习之容器的扩展(一)
    spring源码学习之bean的加载(三)
    spring源码学习之bean的加载(二)
    Linux find命令使用正则表达式
    Linux获取两个路径之间的相对路径
    利用linux sort命令比较版本号
    yum只下载不安装软件包
    tar命令排除某个文件夹
    ssh远程执行命令的符号转义问题
  • 原文地址:https://www.cnblogs.com/csjoz/p/15560469.html
Copyright © 2011-2022 走看看