Java Code Examples for com.alibaba.fastjson.JSONArray#remove()

The following examples show how to use com.alibaba.fastjson.JSONArray#remove() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OutGivingProjectEditController.java    From Jpom with MIT License 5 votes vote down vote up
@RequestMapping(value = "editProject", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
@Feature(method = MethodFeature.EDIT)
public String editProject(String id) {
    setAttribute("type", "add");
    OutGivingModel outGivingModel;
    if (StrUtil.isNotEmpty(id)) {
        outGivingModel = outGivingServer.getItem(id);
        if (outGivingModel != null) {
            setAttribute("item", outGivingModel);
            setAttribute("type", "edit");
        }
    }
    // 运行模式
    JSONArray runModes = (JSONArray) JSONArray.toJSON(RunMode.values());
    runModes.remove(RunMode.File.name());
    //
    setAttribute("runModes", runModes);
    //
    JSONArray afterOpt = BaseEnum.toJSONArray(AfterOpt.class);
    setAttribute("afterOpt", afterOpt);
    // 权限
    List<NodeModel> nodeModels = nodeService.list();
    setAttribute("nodeModels", nodeModels);
    //
    String reqId = nodeService.cacheNodeList(nodeModels);
    setAttribute("reqId", reqId);

    // 白名单
    List<String> jsonArray = serverWhitelistServer.getOutGiving();
    setAttribute("whitelistDirectory", jsonArray);
    return "outgiving/editProject";
}
 
Example 2
Source File: EditProjectController.java    From Jpom with MIT License 5 votes vote down vote up
/**
 * 修改项目页面
 *
 * @param id 项目Id
 * @return json
 */
@RequestMapping(value = "editProject", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
@Feature(method = MethodFeature.EDIT)
public String editProject(String id) {
    JSONObject projectInfo = projectInfoService.getItem(getNode(), id);

    // 白名单
    List<String> jsonArray = whitelistDirectoryService.getProjectDirectory(getNode());
    setAttribute("whitelistDirectory", jsonArray);

    setAttribute("item", projectInfo);
    // 运行模式
    JSONArray runModes = (JSONArray) JSONArray.toJSON(RunMode.values());
    if (projectInfo != null) {
        try {
            String runMode = projectInfo.getString("runMode");
            RunMode mode = RunMode.valueOf(runMode);
            if (mode != RunMode.File) {
                // java 项目不能转换为file,可能有未结束的进程
                runModes.remove(RunMode.File.name());
            }
        } catch (Exception ignored) {
        }
    }
    setAttribute("runModes", runModes);
    //
    List<String> hashSet = projectInfoService.getAllGroup(getNode());
    if (hashSet.isEmpty()) {
        hashSet.add("默认");
    }
    setAttribute("groups", hashSet);
    //jdk
    JSONArray array = projectInfoService.getJdkList(getNode(), getRequest());
    setAttribute("jdkArray", array);
    return "node/manage/editProject";
}
 
Example 3
Source File: ChartsResource.java    From EasyML with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/getChartParams")
@Produces(MediaType.APPLICATION_JSON)
public String getChartParams(@FormParam("filePath") String path, @FormParam("dataType") String type,@FormParam("columns") List<String> columns,@FormParam("chartType")String chartType) throws Exception{
	ChartService chartService = new ChartService();
	String paramsStr = chartService.getChartParams(chartType);
	JSONObject paramObj = JSON.parseObject(paramsStr);
	JSONArray controlArr = paramObj.getJSONArray("controls");
	System.out.println(controlArr.toJSONString());
	for(int i=0;i<controlArr.size();i++)
	{
		JSONObject conObj = controlArr.getJSONObject(i);
		String contType = conObj.getString("control_type");
		if(contType.equals("select"))
		{
			String value = conObj.getString("value");
			if(value.equals(""))
			{
				StringBuffer buf = new StringBuffer();
				for(int j=0;j<columns.size();j++)
				{
					if(j == columns.size()-1)
						buf.append(columns.get(j));
					else
						buf.append(columns.get(j)+",");
				}
				conObj.put("value", buf.toString());
				controlArr.remove(i);
				controlArr.add(i, conObj);
			}
		}
	}
	paramObj.put("controls", controlArr);
	System.out.println(paramObj.toJSONString());
	return paramObj.toJSONString();
}
 
Example 4
Source File: DiscussionService.java    From voj with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 移除JSONArray对象中的一个值.
 * 为了修复JSONArray自带contains方法的Bug.
 * 使用场景: 从Vote列表中移除某个用户的UID.
 * @param jsonArray - 待移除值的JSONArray对象
 * @param value - 待移除的值
 */
private void remove(JSONArray jsonArray, long value) {
	for ( int i = 0; i < jsonArray.size(); ++ i ) {
		if ( jsonArray.getLong(i) == value ) {
			jsonArray.remove(i);
		}
	}
}
 
Example 5
Source File: SocialMainAdapter.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 
 * 取消点赞
 * 
 */
public void cancelGood(String sID, TextView tv_good, JSONArray jsons,
		LinearLayout ll_goodmembers_temp, View view, int cSize) {

	// 即时改变当前UI
	for (int i = 0; i < jsons.size(); i++) {
		JSONObject json = jsons.getJSONObject(i);
		if (json.getString("userID").equals(myuserID)) {
			jsons.remove(i);
		}
	}
	setGoodTextClick(tv_good, jsons, ll_goodmembers_temp, view, cSize);
	Map<String, String> map = new HashMap<String, String>();
	map.put("sID", sID);
	map.put("userID", myuserID);

	SocialApiTask task = new SocialApiTask(context, Constant.URL_SOCIAL_GOOD_CANCEL,
			map);
	task.getData(new DataCallBack() {

		@Override
		public void onDataCallBack(JSONObject data) {
			// dialog.dismiss();
			if (data == null) {
				Log.e("hideCommentEditText()-->>>>",
						"hideCommentEditText()-----ERROR");
				return;
			}
			int code = data.getInteger("code");
			if (code == 1000) {
				Log.e("hideCommentEditText()-->>>>",
						"hideCommentEditText()-----SUCCESS");
			} else {
				Log.e("hideCommentEditText()-->>>>",
						"hideCommentEditText()-----ERROR_2");

			}
		}
	});

}
 
Example 6
Source File: SocialMainAdapter.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
private void deleteComment(String userID, final int postion, String scID,
		int type, TextView ctextView, final JSONArray cjsons, View view,
		int goodSize) {

	if (scID == null) {
		scID = "LOCAL";
	}
	;
	String tag = cjsons.getJSONObject(postion).getString("tag");
	if (tag == null) {
		tag = String.valueOf(System.currentTimeMillis());
	}
	// 更新UI
	cjsons.remove(postion);
	setCommentTextClick(ctextView, cjsons, view, goodSize);
	// 更新服务器
	Map<String, String> map = new HashMap<String, String>();
	map.put("scID", scID);
	map.put("userID", myuserID);
	map.put("tag", tag);
	SocialApiTask task = new SocialApiTask(context, Constant.URL_SOCIAL_DELETE_COMMENT,
			map);
	task.getData(new DataCallBack() {

		@Override
		public void onDataCallBack(JSONObject data) {
			// dialog.dismiss();
			if (data == null) {
				Log.e("hideCommentEditText()-->>>>",
						"hideCommentEditText()-----ERROR");
				return;
			}
			int code = data.getInteger("code");
			if (code == 1000) {
				Log.e("hideCommentEditText()-->>>>",
						"hideCommentEditText()-----SUCCESS");
			} else {
				Log.e("hideCommentEditText()-->>>>",
						"hideCommentEditText()-----ERROR_2");

			}
		}
	});

}
 
Example 7
Source File: SocialFriendAdapter.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 
 * 取消点赞
 * 
 */
public void cancelGood(String sID, TextView tv_good, JSONArray jsons,
        LinearLayout ll_goodmembers_temp, View view, int cSize) {

    // 即时改变当前UI
    for (int i = 0; i < jsons.size(); i++) {
        JSONObject json = jsons.getJSONObject(i);
        if (json.getString("userID").equals(myuserID)) {
            jsons.remove(i);
        }
    }
    setGoodTextClick(tv_good, jsons, ll_goodmembers_temp, view, cSize);
    Map<String, String> map = new HashMap<String, String>();
    map.put("sID", sID);
    map.put("userID", myuserID);

    SocialApiTask task = new SocialApiTask(context,
            Constant.URL_SOCIAL_GOOD_CANCEL, map);
    task.getData(new DataCallBack() {

        @Override
        public void onDataCallBack(JSONObject data) {
            // dialog.dismiss();
            if (data == null) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR");
                return;
            }
            int code = data.getInteger("code");
            if (code == 1000) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----SUCCESS");
            } else {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR_2");

            }
        }
    });

}
 
Example 8
Source File: SocialFriendAdapter.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
private void deleteComment(String userID, final int postion, String scID,
        int type, TextView ctextView, final JSONArray cjsons, View view,
        int goodSize) {

    if (scID == null) {
        scID = "LOCAL";
    }
    ;
    String tag = cjsons.getJSONObject(postion).getString("tag");
    if (tag == null) {
        tag = String.valueOf(System.currentTimeMillis());
    }
    // 更新UI
    cjsons.remove(postion);
    setCommentTextClick(ctextView, cjsons, view, goodSize);
    // 更新服务器
    Map<String, String> map = new HashMap<String, String>();
    map.put("scID", scID);
    map.put("userID", myuserID);
    map.put("tag", tag);
    SocialApiTask task = new SocialApiTask(context,
            Constant.URL_SOCIAL_DELETE_COMMENT, map);
    task.getData(new DataCallBack() {

        @Override
        public void onDataCallBack(JSONObject data) {
            // dialog.dismiss();
            if (data == null) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR");
                return;
            }
            int code = data.getInteger("code");
            if (code == 1000) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----SUCCESS");
            } else {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR_2");

            }
        }
    });

}
 
Example 9
Source File: SocialDetailActivity.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
private void deleteComment(String userID, final int postion, String scID,
        int type, TextView ctextView, final JSONArray cjsons, View view,
        int goodSize) {

    if (scID == null) {
        scID = "LOCAL";
    }
    ;
    String tag = cjsons.getJSONObject(postion).getString("tag");
    if (tag == null) {
        tag = String.valueOf(System.currentTimeMillis());
    }
    // 更新UI
    cjsons.remove(postion);
    setCommentTextClick(ctextView, cjsons, view, goodSize);
    // 更新服务器
    Map<String, String> map = new HashMap<String, String>();
    map.put("scID", scID);
    map.put("userID", myuserID);
    map.put("tag", tag);
    SocialApiTask task = new SocialApiTask(SocialDetailActivity.this,
            Constant.URL_SOCIAL_DELETE_COMMENT, map);
    task.getData(new DataCallBack() {

        @Override
        public void onDataCallBack(JSONObject data) {
            // dialog.dismiss();
            if (data == null) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR");
                return;
            }
            int code = data.getInteger("code");
            if (code == 1000) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----SUCCESS");
            } else {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR_2");

            }
        }
    });

}
 
Example 10
Source File: SocialDetailActivity.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 
 * 取消点赞
 * 
 */
public void cancelGood(String sID, TextView tv_good, JSONArray jsons,
        LinearLayout ll_goodmembers_temp, View view, int cSize) {

    // 即时改变当前UI
    for (int i = 0; i < jsons.size(); i++) {
        JSONObject json = jsons.getJSONObject(i);
        if (json.getString("userID").equals(myuserID)) {
            jsons.remove(i);
        }
    }
    setGoodTextClick(tv_good, jsons, ll_goodmembers_temp, view, cSize);
    Map<String, String> map = new HashMap<String, String>();
    map.put("sID", sID);
    map.put("userID", myuserID);

    SocialApiTask task = new SocialApiTask(SocialDetailActivity.this,
            Constant.URL_SOCIAL_GOOD_CANCEL, map);
    task.getData(new DataCallBack() {

        @Override
        public void onDataCallBack(JSONObject data) {
            // dialog.dismiss();
            if (data == null) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR");
                return;
            }
            int code = data.getInteger("code");
            if (code == 1000) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----SUCCESS");
            } else {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR_2");

            }
        }
    });

}