コード例 #1
2
ファイル: CollegeServlet.java プロジェクト: LockiYang/lims
  private void get(HttpServletRequest request, HttpServletResponse response) throws IOException {
    PrintWriter out = response.getWriter();
    String sPage = request.getParameter("page");
    String sRows = request.getParameter("rows");
    String order = request.getParameter("order");
    String sort = request.getParameter("sort");
    int page = 0;
    int rows = 0;
    if (sPage != null && sRows != null) {
      page = Integer.parseInt(sPage);
      rows = Integer.parseInt(sRows);
    }

    int total = service.count();
    List list = service.get(page, rows, order, sort);
    Map m = new HashMap();
    m.put("total", total);
    m.put("rows", list);

    JSONArray jsonArray = new JSONArray().fromObject(m);
    String json = jsonArray.toString();
    String j = json.substring(1, json.lastIndexOf("]"));

    out.write(j);
  }
コード例 #2
0
 /**
  * 从数据库查询信息供写文件使用
  *
  * @return JSONArray
  */
 public JSONArray loadInfo() {
   JSONArray jsonArray = new JSONArray();
   try {
     List<Asset> assetList = assetService.findAllAssetList();
     for (int i = 0; i < assetList.size(); i++) {
       JSONObject jsonObject = new JSONObject();
       Asset asset = new Asset();
       asset = assetList.get(i);
       jsonObject.put("number", asset.getNumber());
       jsonObject.put("name", asset.getName());
       jsonObject.put("uses", asset.getUses());
       jsonObject.put("category", asset.getCategory());
       jsonObject.put(
           "entryTime", new SimpleDateFormat("yyyy-MM-dd").format(asset.getEntryTime()));
       jsonObject.put("status", asset.getStatus());
       jsonObject.put("remarks", asset.getRemarks());
       jsonObject.put(
           "edit",
           "<a href='javascript:void(0)' onclick='editAsset("
               + '"'
               + asset.getId()
               + '"'
               + ")'>编辑</>/<a href='javascript:void(0)' onclick='deleteAsset("
               + '"'
               + asset.getId()
               + '"'
               + ")'>删除</>");
       jsonArray.add(jsonObject);
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return jsonArray;
 }
コード例 #3
0
  private static JSONObject extractPercentileTransactionSet(
      Map<Integer, TreeMap<String, PercentileTransactionWholeRun>> graphData,
      HashSet<String> transactions) {
    JSONObject graphDataSet = new JSONObject();
    JSONArray labels = new JSONArray();

    HashMap<String, ArrayList<Number>> percentileTrtData =
        new HashMap<String, ArrayList<Number>>(0);
    for (String transaction : transactions) {
      percentileTrtData.put(transaction, new ArrayList<Number>(0));
    }

    for (Map.Entry<Integer, TreeMap<String, PercentileTransactionWholeRun>> result :
        graphData.entrySet()) {
      labels.add(result.getKey());

      for (String transaction : transactions) {
        if (!result.getValue().containsKey(transaction)) {
          percentileTrtData.get(transaction).add(null);
          // TODO:change to null
          continue;
        }
        percentileTrtData
            .get(transaction)
            .add((result.getValue()).get(transaction).getActualValue());
      }
    }

    graphDataSet.put(LABELS, labels);
    graphDataSet.put(SERIES, createGraphDatasets(percentileTrtData));

    return graphDataSet;
  }
コード例 #4
0
	public String items(){
		List<Object[]> itemsAll = bidItemsDao.getAllBidItemsByEntpId(getUser().getProjectId(),getUser().getEntpId());
			
		try {
			List<Items> dd = new java.util.ArrayList<Items>();
			
			for(Object item : itemsAll){
				
				Object[] imo = ((Object[])item);
				if(imo[1].toString().indexOf("\\")!= -1){
					imo[1]=imo[1].toString().replace("\\", "/");
				}
				
				Items i = new Items(imo[0].toString(), imo[2].toString(), imo[1].toString());
				dd.add(i);
			}
			JSONArray jsonArray = JSONArray.fromObject(dd);
			
			itemsAllString = jsonArray.toString();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return "items";
	}
コード例 #5
0
  private static JSONObject extractAvgTrtData(
      Map<Integer, TreeMap<String, AvgTransactionResponseTime>> graphData,
      HashSet<String> transactions) {
    HashMap<String, ArrayList<Number>> averageTRTData = new HashMap<String, ArrayList<Number>>(0);
    JSONObject graphDataSet = new JSONObject();

    JSONArray labels = new JSONArray();

    for (String transaction : transactions) {
      averageTRTData.put(transaction, new ArrayList<Number>(0));
    }

    for (Map.Entry<Integer, TreeMap<String, AvgTransactionResponseTime>> result :
        graphData.entrySet()) {
      labels.add(result.getKey());

      for (String transaction : transactions) {
        if (!result.getValue().containsKey(transaction)) {
          averageTRTData.get(transaction).add(null);
          // TODO:change to null
          continue;
        }
        averageTRTData
            .get(transaction)
            .add((result.getValue()).get(transaction).getActualValueAvg());
      }
    }

    graphDataSet.put(LABELS, labels);
    JSONArray datasets = createGraphDatasets(averageTRTData);
    graphDataSet.put(SERIES, datasets);
    return graphDataSet;
  }
コード例 #6
0
  @Override
  protected void updateConnectorDataHistory(UpdateInfo updateInfo)
      throws RateLimitReachedException, Exception {
    // taking care of resetting the data if things went wrong before
    if (!connectorUpdateService.isHistoryUpdateCompleted(updateInfo.apiKey, -1))
      apiDataService.eraseApiData(updateInfo.apiKey, -1);
    int retrievedItems = ITEMS_PER_PAGE;
    for (int page = 0; retrievedItems == ITEMS_PER_PAGE; page++) {
      JSONObject feed = retrievePhotoHistory(updateInfo, 0, System.currentTimeMillis(), page);
      if (feed.has("stat")) {
        String stat = feed.getString("stat");
        if (stat.equalsIgnoreCase("fail")) {
          String message = feed.getString("message");
          throw new RuntimeException("Could not retrieve Flickr history: " + message);
        }
      }
      JSONObject photosWrapper = feed.getJSONObject("photos");

      if (photosWrapper != null) {
        JSONArray photos = photosWrapper.getJSONArray("photo");
        retrievedItems = photos.size();
        apiDataService.cacheApiDataJSON(updateInfo, feed, -1, -1);
      } else break;
    }
  }
コード例 #7
0
ファイル: NoahHi.java プロジェクト: HenryYu/noah_hi
  public void pick() throws IOException {
    while (true) {
      pickUrl =
          String.format(
              "http://web.im.baidu.com/pick?v=30&session=&source=22&type=23&flag=1&seq=%d&ack=%s&guid=%s",
              sequence, ack, guid);

      HttpGet getRequest = new HttpGet(pickUrl);
      HttpResponse pickRes = httpClient.execute(getRequest);
      String entityStr = EntityUtils.toString(pickRes.getEntity());
      System.out.println("Pick result:" + entityStr);
      EntityUtils.consume(pickRes.getEntity());

      JSONObject jsonObject = JSONObject.fromObject(entityStr);
      JSONObject content = jsonObject.getJSONObject("content");
      if (content != null && content.get("ack") != null) {
        ack = (String) content.get("ack");
        JSONArray fields = content.getJSONArray("fields");
        JSONObject o = fields.getJSONObject(0);
        String fromUser = (String) o.get("from");
        System.out.println("++++Message from: " + fromUser);
      }
      updateSequence();

      if (sequence > 4) {
        break;
      }
    }
  }
コード例 #8
0
ファイル: APIHandler.java プロジェクト: kyeoh/tales-core
  private void errors(HttpServletResponse response) {

    try {

      // gets the errors
      JSONArray array = new JSONArray();

      for (Log log : LogsDB.getErrors(Globals.DASHBOARD_MAX_ERRORS)) {

        JSONObject obj = new JSONObject();
        obj.put("added", log.getAdded().toString());
        obj.put("id", log.getId());
        obj.put("publicDNS", log.getPublicDNS());
        obj.put("pid", log.getPid());
        obj.put("logType", log.getLogType());
        obj.put("methodPath", log.getMethodPath());
        obj.put("lineNumber", log.getLineNumber());

        array.add(obj);
      }

      // response
      response.setContentType("application/json");
      response.setStatus(HttpServletResponse.SC_OK);
      response.getWriter().println(array);

    } catch (Exception e) {
      new TalesException(new Throwable(), e);
    }
  }
コード例 #9
0
ファイル: APIHandler.java プロジェクト: kyeoh/tales-core
  private void databases(HttpServletResponse response) {

    try {

      JSONArray json = new JSONArray();

      for (String dbName : DBUtils.getLocalDBNames()) {

        JSONArray tables = new JSONArray();
        for (String tableName : DBUtils.getTableNames(new TemplateLocalhostConnection(), dbName)) {

          JSONObject table = new JSONObject();
          table.put("table", tableName);
          table.put(
              "size", DBUtils.getTableCount(new TemplateLocalhostConnection(), dbName, tableName));
          tables.add(table);
        }

        JSONObject database = new JSONObject();
        database.put("name", dbName);
        database.put("tables", tables);
        json.add(database);
      }

      response.setContentType("application/json");
      response.setStatus(HttpServletResponse.SC_OK);
      response.getWriter().println(json);

    } catch (Exception e) {
      new TalesException(new Throwable(), e);
    }
  }
コード例 #10
0
  public String getCodeJson(MobileServerConfig mobileServerConfig, Document doc, String urlPara) {
    String json = "";

    JSONObject jsonObjectResult = new JSONObject();

    try {
      List<Code> list = GetCodeCache();

      if (list != null && list.size() > 0) {
        JSONArray jsonArray = new JSONArray();

        for (Code code : list) {
          JSONObject jsonObjectData = new JSONObject();

          jsonObjectData.put("codeName", code.getCodeName());
          jsonObjectData.put("description", code.getDescription());
          jsonObjectData.put("category", code.getCategory());

          jsonArray.add(jsonObjectData);
        }

        jsonObjectResult.put("result", "1");
        jsonObjectResult.put("data", jsonArray);
      }
    } catch (Exception e) {
      // TODO: handle exception
      jsonObjectResult.put("result", "0");
      jsonObjectResult.put("message", e.getMessage());
    }

    json = jsonObjectResult.toString();

    return json;
  }
コード例 #11
0
  @SuppressWarnings("rawtypes")
  public List<Code> GetCodeCache() {
    List<Code> list = new ArrayList<Code>();

    if (MemCached.used()) {
      Object obj = MemCached.getInstance().get("Code");
      if (obj != null && !obj.equals("")) {
        String json = MemCached.getInstance().get("Code").toString();

        JSONArray array = JSONArray.fromObject(json);
        for (Iterator iter = array.iterator(); iter.hasNext(); ) {
          JSONObject jsonObject = (JSONObject) iter.next();
          list.add((Code) JSONObject.toBean(jsonObject, Code.class));
        }
      } else {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("status", "Y");
        list = this.findForUnPage(params);

        JSONArray jsonObject = JSONArray.fromObject(list);

        MemCached.getInstance().set("Code", jsonObject);
      }
    }

    return list;
  }
コード例 #12
0
  @Override
  protected String getJSONString(RunData rundata, Context context) throws Exception {
    String result = "";
    JSONArray json;

    try {

      String mode = rundata.getParameters().getString("mode");
      if ("group".equals(mode)) {
        String groupname = rundata.getParameters().getString("groupname");

        json =
            JSONArray.fromObject(
                AddressBookUserUtils.getAddressBookUserLiteBeansFromGroup(
                    groupname, ALEipUtils.getUserId(rundata)));
      } else {
        json = new JSONArray();
      }
      result = json.toString();
    } catch (Exception e) {
      logger.error("AddressBookUserLiteJSONScreen.getJSONString", e);
    }

    return result;
  }
コード例 #13
0
ファイル: LawsServlet.java プロジェクト: 210290/experiment
 /**
  * The doPost method of the servlet. <br>
  * This method is called when a form has its tag value method equals to post.
  *
  * @param request the request send by the client to the server
  * @param response the response send by the server to the client
  * @throws ServletException if an error occurred
  * @throws IOException if an error occurred
  */
 public void doPost(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   request.setCharacterEncoding("utf-8");
   response.setCharacterEncoding("utf-8");
   // 读取参数
   String search = request.getParameter("search"); // 查询内容
   String key = request.getParameter("searchkey"); // 查询条件
   boolean k = false; // 判断查询方式
   if (key.equals("issue")) {
     k = true; // 按颁发部门查询
   } else {
     k = false; // 按关键字查询
   }
   // 访问数据库
   // LawsSearch laws = new LawsSearch();
   ILawsDao dao = DaoFactory.createLawsDao();
   JSONArray json = new JSONArray();
   ResultSet rs = dao.searchLaws(search, k);
   json = ToJson.resultJSON(rs);
   // 应答
   response.setContentType("text/html");
   PrintWriter out = response.getWriter();
   out.print(json.toString());
   out.flush();
   out.close();
 }
コード例 #14
0
ファイル: Inventaire.java プロジェクト: vitiok123/inf4375_tp2
  private String jsonArtistes(Map<String, Artiste> artistes) {
    Map<String, Artiste> artistesTrie = new TreeMap<String, Artiste>(artistes);
    JSONObject jsonResultat = new JSONObject();
    JSONArray jsonArtistes = new JSONArray();
    for (String nome : artistesTrie.keySet()) {
      Artiste artiste = artistesTrie.get(nome);
      JSONObject jsonArtiste = new JSONObject();
      jsonArtiste.put("nom", nome);
      JSONArray jsonAlbums = new JSONArray();
      for (Integer annee : artiste.getAlbums().keySet()) {
        Album album = artiste.getAlbums().get(annee);
        JSONObject newAlbum = new JSONObject();
        newAlbum.put("id", album.getId());
        newAlbum.put("titre", album.getTitre());
        newAlbum.put("annee", album.getAnnee());
        newAlbum.put("qte", album.getQuantite());
        jsonAlbums.add(newAlbum);
      }
      jsonArtiste.accumulate("albums", jsonAlbums);
      jsonArtistes.add(jsonArtiste);
    }
    jsonResultat.accumulate("artistes", jsonArtistes);

    return jsonResultat.toString(2);
  }
コード例 #15
0
 private void addJsonAnnotations(ModelAndView mav, String style, boolean prefix) {
   if (prefix) {
     mav.addObject("mapPrefix", "map");
     mav.addObject("mimetype", "application/x-javascript");
   } else {
     mav.addObject("mimetype", "application/json");
   }
   List<ConceptAnnotation> annotations =
       (List<ConceptAnnotation>) mav.getModel().get("annotations");
   if (annotations != null) {
     JSONArray mappings = new JSONArray();
     for (ConceptAnnotation annotation : annotations) {
       JSONObject mapping = new JSONObject();
       mapping.accumulate("id", String.valueOf(annotation.getOid()));
       mapping.accumulate("start", String.valueOf(annotation.getBegin()));
       mapping.accumulate("end", String.valueOf(annotation.getEnd()));
       mapping.accumulate("pname", annotation.getPname());
       mapping.accumulate("group", annotation.getStygroup());
       mapping.accumulate("codes", StringUtils.replace(annotation.getStycodes(), "\"", ""));
       mapping.accumulate("text", annotation.getCoveredText());
       mappings.put(mapping);
     }
     mav.addObject(
         "stringAnnotations", "pretty".equals(style) ? mappings.toString(2) : mappings.toString());
   }
 }
コード例 #16
0
ファイル: CheckFeeModAction.java プロジェクト: qw4wer/back
  public String myGetCheckFeeDateList() throws Exception {

    JSONArray jsonArray = new JSONArray();

    confirmCond = new ConfirmCond();
    confirmCond.setPropertyId(request.getParameter("propertyId"));

    List<Map<String, Object>> checkFeeDateList = confirmServices.checkFeeDateList(confirmCond);

    for (int i = 0; i < checkFeeDateList.size(); i++) {

      Map<String, Object> mapobject = checkFeeDateList.get(i);

      String checkfee_date =
          mapobject.get("checkfee_date") == null ? "" : mapobject.get("checkfee_date").toString();

      if (!CommonUtils.isStrEmpty(checkfee_date)) {

        Map<String, Object> json = new HashMap<String, Object>();
        json.put(
            "checkFeeDate",
            CommonUtils.getDateString(CommonUtils.getDateFromString(checkfee_date)));

        jsonArray.add(json);
      }
    }

    CustomerUtils.writeResponse(response, jsonArray.toString());

    return null;
  }
コード例 #17
0
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    // OutputStream out = response.getOutputStream();
    // Creating parameters
    String startTime = request.getParameter("startTime");
    String endTime = request.getParameter("endTime");
    System.out.println(startTime);
    // System.out.println(endTime);

    // Formating the time parameters into "yyyy-MM-dd HH:mm:ss"
    SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String newStartTime = sd.format(new Date(startTime));
    System.out.println(newStartTime);

    // Formating the time parameters into "yyyy-MM-dd HH:mm:ss"
    SimpleDateFormat sd1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String newEndTime = sd1.format(new Date(endTime));
    System.out.println(newEndTime);

    // Creating json format ready to pass the parameters
    List<Station> listStation = getDataSet(newStartTime, newEndTime);
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("listStation", listStation);

    JSONArray jsonArray = new JSONArray();
    jsonArray.add(jsonObject);
    PrintWriter out = response.getWriter();
    out.write(jsonArray.toString());
  }
コード例 #18
0
ファイル: CoreBusiness.java プロジェクト: etc1208/vmapAPI
 @SuppressWarnings("unchecked")
 public static String formXML(JSONArray array, boolean success) {
   StringBuilder sb = new StringBuilder();
   sb.append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
   sb.append("<results>\n");
   sb.append("<success>" + success + "</success>\n");
   sb.append("<total>" + array.size() + "</total>\n");
   sb.append("<rows>");
   JSONObject object = null;
   for (int i = 0; i < array.size(); i++) {
     object = array.getJSONObject(i);
     Iterator<String> o = object.keys();
     sb.append("<unit>\n");
     for (; o.hasNext(); ) {
       String temp = o.next();
       sb.append("<" + temp + ">");
       sb.append(object.getString(temp));
       sb.append("</" + temp + ">\n");
     }
     sb.append("</unit>\n");
   }
   sb.append("</rows>\n");
   sb.append("</results>");
   if (object != null) {
     object.clear();
     object = null;
   }
   return sb.toString();
 }
コード例 #19
0
  @Override
  public void updateConnectorData(UpdateInfo updateInfo) throws Exception {
    int retrievedItems = ITEMS_PER_PAGE;
    long lastUploadTime = getLastUploadTime(updateInfo);
    for (int page = 0; retrievedItems == ITEMS_PER_PAGE; page++) {
      JSONObject feed =
          retrievePhotoHistory(updateInfo, lastUploadTime, System.currentTimeMillis(), page);

      if (!(feed.getString("stat").equalsIgnoreCase("ok"))) {
        String message = "n/a";
        if (feed.containsKey("message")) message = feed.getString("message");
        throw new Exception("There was an error calling the Flickr API: " + message);
      }

      JSONObject photosWrapper = feed.getJSONObject("photos");

      if (photosWrapper != null) {
        if (photosWrapper.containsKey("photo")) {
          JSONArray photos = photosWrapper.getJSONArray("photo");
          retrievedItems = photos.size();
          apiDataService.cacheApiDataJSON(updateInfo, feed, -1, -1);
        } else break;
      } else break;
    }
  }
コード例 #20
0
    /**
     * Parses the raw response from Google
     *
     * @param rawResponse The raw, unparsed response from Google
     * @return Returns the parsed response.
     */
    void parseResponse(String rawResponse, GoogleResponse googleResponse) {
        try {
            JSONObject json = JSONObject.fromObject(rawResponse);
            int status = json.getInt("status");

            if (status == 0) {
                JSONArray hypotheses = json.getJSONArray("hypotheses");

                for (int index = 0; index < hypotheses.size(); index++) {
                    JSONObject hypothese = (JSONObject) hypotheses.get(index);

                    if (hypothese.containsKey(CONFIDENCE)) {
                        googleResponse.setResponse(hypothese.getString("utterance"));
                        googleResponse.setConfidence(hypothese.getDouble(CONFIDENCE) + "");
                    } else {
                        googleResponse.getOtherPossibleResponses().add(hypothese.getString("utterance"));
                    }
                }
            } else {
                Logger.getLogger(Recognizer.class.getName()).log(Level.WARNING, "status: {0}", status);
            }
        } catch (JSONException e) {
            Logger.getLogger(Recognizer.class.getName()).log(Level.WARNING, e.getLocalizedMessage(), e);
        }
    }
コード例 #21
0
 public String getSuccessString(String API_CODE, JSONObject temp) {
   JSONArray jarray = new JSONArray();
   temp.put("status", "0");
   temp.put("msg", API_CODE + "00");
   jarray.add(temp);
   return jarray.toString();
 }
コード例 #22
0
  /**
   * 将集合元素封装成json对象并返回
   *
   * @param list 要封装的数组集合
   * @param config 类在转换成json数据时遵循的一些配置规则
   * @param status 状态标识
   * @return json对象 返回json对象的内部格式如下:data中的内容就是list集合中的内容,count表示data中的条数,也就是list集合中数据数 { status:1,
   *     message:"ok", result:{ count:2, data:[
   *     {id:"2353sdkfhosdf",name:boat.jpg,type=1,savepath:"http://172.19.68.77:8080/zhushou/images/logo.jpg"},
   *     {id:"2353sdkfhosdf",name:boat.jpg,type=1,savepath:"http://172.19.68.77:8080/zhushou/images/logo.jpg"},
   *     <p>] } }
   */
  @Deprecated
  public static <T> JSONObject createJsonObject(List<T> list, JsonConfig config, MyStatus status) {

    // 整个json
    JSONObject jsonObject = new JSONObject();
    // result json
    JSONObject resultObject = new JSONObject();
    // 数组json
    JSONArray jsonArray = new JSONArray();

    int count = 0;
    if (list != null) {
      for (T entity : list) {
        JSONObject entityJson;
        if (config == null) entityJson = JSONObject.fromObject(entity);
        else entityJson = JSONObject.fromObject(entity, config);
        jsonArray.add(entityJson);
        count++;
      }
    }
    resultObject.put("count", count);
    resultObject.put("data", jsonArray);
    jsonObject.put("result", resultObject);

    JsonTool.putStatusJson(status, jsonObject);
    return jsonObject;
  }
コード例 #23
0
  /**
   * 单选
   *
   * @return
   */
  public String single() {
    if (vo == null) {
      vo = new DepartmentSO();
    }
    vo.setPageNumber(1);
    vo.setObjectsPerPage(Integer.MAX_VALUE);
    List<Department> list = departmentDAO.getList(vo);

    if (list != null && list.size() > 0) {
      JSONArray array = new JSONArray();
      for (Department dep : list) {
        JSONObject json = new JSONObject();
        json.put("id", dep.getId());

        if (dep.getDepartment() == null) {
          json.put("pId", 0);
        } else {
          json.put("pId", dep.getDepartment().getId());
          json.put("open", true);
        }

        json.put("name", dep.getName());

        if (id != null) {
          if (id.equals(dep.getId())) {
            json.put("checked", true);
          }
        }

        array.add(json);
      }
      nodes = array.toString();
    }
    return Constants.SINGLE;
  }
コード例 #24
0
ファイル: GetHaoYouLB.java プロジェクト: weiyk/ES
 public List<List> getHaoYou(String yhbh, String key) {
   web = new HttpWebs();
   web.init();
   list = new ArrayList<List>();
   GetUrl getUrl = new GetUrl();
   String url = getUrl.getUrl("findFriend_url");
   Map<String, String> parmMap = new HashMap<String, String>();
   parmMap.put("uid", yhbh);
   parmMap.put("key", key);
   String sb = web.callByGet(url, parmMap);
   JSONArray array = JSONArray.fromObject("[" + Base64Util.decrypt(sb) + "]");
   JSONObject jsonObject = array.getJSONObject(0);
   String msgCode = jsonObject.get("msgCode").toString();
   try {
     if ("1".equals(msgCode)) {
       String uids = jsonObject.get("uids").toString();
       String[] uidlist = uids.split(",");
       for (int i = 0; i < uidlist.length; i++) {
         String uid = uidlist[i];
         printHtml(uid);
       }
     }
     return list;
   } catch (SQLException e) {
     e.printStackTrace();
     return list;
   }
 }
コード例 #25
0
  private static JSONObject extractVuserResult(Map<Integer, TreeMap<String, Integer>> graphData) {
    JSONObject graphDataSet;
    graphDataSet = new JSONObject();
    JSONArray labels = new JSONArray();

    HashMap<String, ArrayList<Number>> vUserState = new HashMap<String, ArrayList<Number>>(0);
    vUserState.put("Passed", new ArrayList<Number>(0));
    vUserState.put("Failed", new ArrayList<Number>(0));
    vUserState.put("Stopped", new ArrayList<Number>(0));
    vUserState.put("Error", new ArrayList<Number>(0));
    for (Map.Entry<Integer, TreeMap<String, Integer>> run : graphData.entrySet()) {
      Number tempVUserCount = run.getValue().get("Count");
      if (tempVUserCount != null && tempVUserCount.intValue() > 0) {
        labels.add(run.getKey());
        vUserState.get("Passed").add(run.getValue().get("Passed"));
        vUserState.get("Failed").add(run.getValue().get("Failed"));
        vUserState.get("Stopped").add(run.getValue().get("Stopped"));
        vUserState.get("Error").add(run.getValue().get("Error"));
      }
    }

    graphDataSet.put(LABELS, labels);
    graphDataSet.put(SERIES, createGraphDatasets(vUserState));
    return graphDataSet;
  }
コード例 #26
0
  public String sddata() {
    try {
      Map<String, Object> params = new HashMap<String, Object>();
      params.put("staffno", staffno);
      if (!statusid.equals("")) {
        String statusWhere =
            " CHARINDEX(','+CAST(A.StatusId AS VARCHAR(4))+',','," + statusid + ",') > 0 ";
        params.put("statusWhere", statusWhere);
      }
      params.put("starttime", startDate);
      params.put("endtime", endDate);

      List<StatusDetail> lists = statusDetailService.retrieveForMod(params);
      for (StatusDetail entity : lists) {
        entity.setStatusName(HelperUtils.getLanguageValue("zh", entity.getStatusName()));
      }
      JsonConfig jsonConfig = new JsonConfig();
      jsonConfig.registerJsonValueProcessor(
          Date.class, new JsonDateValueProcessor("yyyy-MM-dd HH:mm:ss"));
      JSONArray json = JSONArray.fromObject(lists, jsonConfig);
      String s = json.toString();
      postJSON("{\"rows\":" + s + "}");
    } catch (Exception ex) {
      throw ex;
    }
    return null;
  }
コード例 #27
0
  @RequestMapping(value = "/gotoData", method = RequestMethod.GET)
  public String gotoData(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    User user = (User) request.getSession().getAttribute("user");
    // 设计返回数据是的数组
    JSONArray sendjsonarray = new JSONArray();
    Map returnmap = new HashMap();
    if (user == null) {
      returnmap.put("statics", "0");
    } else {

      // 设计保存在缓存中的数据内容
      Map sessionmap = new HashMap();
      // 通过ip  时间    host  区分登陆的是不是一个人
      Usersession se = new Usersession();
      se.setAddtime(new Timestamp(new Date().getTime()));
      se.setIp(request.getHeader("X-Real-IP"));
      se.setUser(user);
      se.save();
      returnmap.put("statics", "1");
      returnmap.put("id", se.getUsersessionid());
      returnmap.put("userid", user.getUserid());
    }

    JSONObject jsonObject = JSONObject.fromObject(returnmap);
    sendjsonarray.add(0, jsonObject);
    response.getWriter().print("jsonp={'returns':" + sendjsonarray + "}");
    return null;
  }
コード例 #28
0
ファイル: SongAction.java プロジェクト: ruankai/yueju
  public String query() throws IOException {
    List<Song> songs = songService.findSongs();

    JsonConfig jc = new JsonConfig();
    jc.setExcludes(
        new String[] {
          "recorder",
          "copyright",
          "size",
          "initiateName",
          "keyword",
          "date",
          "description",
          "singer"
        });

    JSONArray jsonArray = JSONArray.fromObject(songs, jc);

    String json = jsonArray.toString();

    System.out.print(json);
    ServletActionContext.getResponse().setContentType("text/json;charset=UTF-8");
    System.out.println(json);
    ServletActionContext.getResponse().getWriter().print(json);

    return NONE;
  }
コード例 #29
0
ファイル: CollegeServlet.java プロジェクト: LockiYang/lims
  // 修改学院信息
  private void edit(HttpServletRequest request, HttpServletResponse response) throws IOException {
    PrintWriter out = response.getWriter();
    JsonBean j = new JsonBean();
    int id = Integer.parseInt(request.getParameter("id"));
    int college_num = Integer.parseInt(request.getParameter("college_num"));
    int college_state = Integer.parseInt(request.getParameter("college_state"));
    String college_name = request.getParameter("college_name");

    College co = new College();
    co.setCollege_name(college_name);
    co.setCollege_num(college_num);
    co.setCollege_state(college_state);
    co.setId(id);

    if (service.edit(co)) {
      j.setSuccess(true);
      j.setMsg("修改[" + college_name + "]成功!");
    } else {
      j.setMsg("修改[" + college_name + "]失败!");
    }

    JSONArray jsonArray = new JSONArray().fromObject(j);
    String jsonS = jsonArray.toString();
    String json = jsonS.substring(1, jsonS.lastIndexOf("]"));
    out.write(json);
  }
コード例 #30
0
ファイル: XshlfxLcReportAction.java プロジェクト: qw4wer/back
  public String searchxshlfxLcReport() throws Exception {

    // 步骤1:进行List的定义,直接对应于html页面的Table
    ArrayList<ReportShowTR> trList = new ArrayList();
    trList = (ArrayList<ReportShowTR>) request.getSession().getAttribute("trList");
    try {

      JSONArray jsonArray = new JSONArray();
      JSONObject jsonobj = new JSONObject();

      StringBuilder sb = new StringBuilder("");
      for (int i = 0; i < trList.size(); i++) {
        for (int j = 0; j < trList.get(i).getTdsCount(); j++) {
          jsonobj.put("xs" + j, trList.get(i).getTD(j).getXyValueText());
        }
        jsonArray.add(jsonobj);
      }
      Map<String, Object> json = new HashMap<String, Object>();
      json.put("rows", jsonArray); // rows键 存放每页记录 list
      result = JSONObject.fromObject(json); // 格式化result一定要是JSONObject
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    return "suc";
  }