com.google.gson.JsonElement Java Examples
The following examples show how to use
com.google.gson.JsonElement.
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: TaskAction.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
@JaxrsMethodDescribe(value = "保存并继续流转.", action = ActionProcessing.class) @PUT @Path("{id}/processing") @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.APPLICATION_JSON) public void processing(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, @JaxrsParameterDescribe("标识") @PathParam("id") String id, JsonElement jsonElement) { ActionResult<ActionProcessing.Wo> result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { result = new ActionProcessing().execute(effectivePerson, id, jsonElement); } catch (Exception e) { logger.error(e, effectivePerson, request, jsonElement); result.error(e); } asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); }
Example #2
Source File: APSResultSerializer.java From HAPP with GNU General Public License v3.0 | 6 votes |
@Override public JsonElement serialize(APSResult src, Type typeOfSrc, JsonSerializationContext context) { final JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("action", src.getAction()); jsonObject.addProperty("reason", src.getReason()); jsonObject.addProperty("tempSuggested", src.getTempSuggested()); jsonObject.addProperty("eventualBG", src.getEventualBG()); jsonObject.addProperty("snoozeBG", src.getSnoozeBG()); jsonObject.addProperty("timestamp", src.getTimestamp().getTime()); jsonObject.addProperty("rate", src.getRate()); jsonObject.addProperty("duration", src.getDuration()); jsonObject.addProperty("basal_adjustemnt", src.getBasal_adjustemnt()); jsonObject.addProperty("accepted", src.getAccepted()); jsonObject.addProperty("aps_algorithm", src.getAps_algorithm()); jsonObject.addProperty("aps_mode", src.getAps_mode()); jsonObject.addProperty("current_pump_basal", src.getCurrent_pump_basal()); jsonObject.addProperty("aps_loop", src.getAps_loop()); return jsonObject; }
Example #3
Source File: NpmCliParser.java From synopsys-detect with Apache License 2.0 | 6 votes |
public NpmParseResult convertNpmJsonFileToCodeLocation(final String npmLsOutput) { final JsonObject npmJson = new JsonParser().parse(npmLsOutput).getAsJsonObject(); final MutableDependencyGraph graph = new MutableMapDependencyGraph(); final JsonElement projectNameElement = npmJson.getAsJsonPrimitive(JSON_NAME); final JsonElement projectVersionElement = npmJson.getAsJsonPrimitive(JSON_VERSION); String projectName = null; String projectVersion = null; if (projectNameElement != null) { projectName = projectNameElement.getAsString(); } if (projectVersionElement != null) { projectVersion = projectVersionElement.getAsString(); } populateChildren(graph, null, npmJson.getAsJsonObject(JSON_DEPENDENCIES), true); final ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.NPMJS, projectName, projectVersion); final CodeLocation codeLocation = new CodeLocation(graph, externalId); return new NpmParseResult(projectName, projectVersion, codeLocation); }
Example #4
Source File: MapTypeAdapterFactory.java From gson with Apache License 2.0 | 6 votes |
private String keyToString(JsonElement keyElement) { if (keyElement.isJsonPrimitive()) { JsonPrimitive primitive = keyElement.getAsJsonPrimitive(); if (primitive.isNumber()) { return String.valueOf(primitive.getAsNumber()); } else if (primitive.isBoolean()) { return Boolean.toString(primitive.getAsBoolean()); } else if (primitive.isString()) { return primitive.getAsString(); } else { throw new AssertionError(); } } else if (keyElement.isJsonNull()) { return "null"; } else { throw new AssertionError(); } }
Example #5
Source File: ReviewAction.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
@JaxrsMethodDescribe(value = "列示当前用户创建的工作的参阅,上一页.", action = V2ListCreatePrev.class) @POST @Path("v2/list/create/{id}/prev/{count}") @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.APPLICATION_JSON) public void V2ListCreatePrev(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, @JaxrsParameterDescribe("参阅标识") @PathParam("id") String id, @JaxrsParameterDescribe("数量") @PathParam("count") Integer count, JsonElement jsonElement) { ActionResult<List<V2ListCreatePrev.Wo>> result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { result = new V2ListCreatePrev().execute(effectivePerson, id, count, jsonElement); } catch (Exception e) { logger.error(e, effectivePerson, request, jsonElement); result.error(e); } asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); }
Example #6
Source File: JsonLoader.java From olca-app with Mozilla Public License 2.0 | 6 votes |
private void splitExchanges(JsonObject obj) { JsonArray exchanges = obj.getAsJsonArray("exchanges"); JsonArray inputs = new JsonArray(); JsonArray outputs = new JsonArray(); if (exchanges != null) for (JsonElement elem : exchanges) { JsonObject e = elem.getAsJsonObject(); JsonElement isInput = e.get("input"); if (isInput.isJsonPrimitive() && isInput.getAsBoolean()) inputs.add(e); else outputs.add(e); } obj.remove("exchanges"); obj.add("inputs", inputs); obj.add("outputs", outputs); }
Example #7
Source File: AttendanceStatisticShowAction.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
@JaxrsMethodDescribe(value = "列示根据过滤条件的组织月份统计数据,上一页", action = ActionListStmForUnitPrevWithFilter.class) @PUT @Path("filter/unitMonth/list/{id}/prev/{count}") @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.APPLICATION_JSON) public void listStmForUnitPrevWithFilter(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, @JaxrsParameterDescribe("上一页最后一条信息ID") @PathParam("id") String id, @JaxrsParameterDescribe("每页显示信息条目数量") @PathParam("count") Integer count, JsonElement jsonElement) { ActionResult<List<ActionListStmForUnitPrevWithFilter.Wo>> result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); Boolean check = true; if (check) { try { result = new ActionListStmForUnitPrevWithFilter().execute(request, effectivePerson, id, count, jsonElement); } catch (Exception e) { result = new ActionResult<>(); Exception exception = new ExceptionAttendanceSettingProcess(e, "获取所有数据统计信息列表时发生异常!"); result.error(exception); logger.error(e, effectivePerson, request, null); } } asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); }
Example #8
Source File: ActionListMyFilterPaging.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, Integer page, Integer size, JsonElement jsonElement) throws Exception { try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { Business business = new Business(emc); ActionResult<List<Wo>> result = new ActionResult<>(); Wi wi = this.convertToWrapIn(jsonElement, Wi.class); if (wi == null) { wi = new Wi(); } Integer adjustPage = this.adjustPage(page); Integer adjustPageSize = this.adjustSize(size); List<TaskCompleted> os = this.list(effectivePerson, business, adjustPage, adjustPageSize, wi); List<Wo> wos = Wo.copier.copy(os); result.setData(wos); result.setCount(this.count(effectivePerson, business, wi)); return result; } }
Example #9
Source File: WorkAction.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
@POST @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.APPLICATION_JSON) @Path("process/{processFlag}/force") @JaxrsMethodDescribe(value = "创建工作(强制创建存在的流程).", action = ActionCreateForce.class) public void createForce(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, @JaxrsParameterDescribe("流程标识") @PathParam("processFlag") String processFlag, JsonElement jsonElement) { ActionResult<List<ActionCreateForce.Wo>> result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { result = new ActionCreateForce().execute(effectivePerson, processFlag, jsonElement); } catch (Exception e) { logger.error(e, effectivePerson, request, jsonElement); result.error(e); } asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); }
Example #10
Source File: DeployGroupTypeAdapter.java From packagedrone with Eclipse Public License 1.0 | 6 votes |
@Override public JsonElement serialize ( final DeployGroup group, final Type type, final JsonSerializationContext ctx ) { final JsonObject obj = new JsonObject (); obj.addProperty ( "id", group.getId () ); obj.addProperty ( "name", group.getName () ); final JsonObject keys = new JsonObject (); obj.add ( "keys", keys ); for ( final DeployKey key : group.getKeys () ) { final JsonObject ok = new JsonObject (); ok.addProperty ( "name", key.getName () ); ok.addProperty ( "key", key.getKey () ); ok.add ( "timestamp", ctx.serialize ( Date.from ( key.getCreationTimestamp () ), Date.class ) ); keys.add ( key.getId (), ok ); } return obj; }
Example #11
Source File: ActionUpdateDataPath5.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
ActionResult<Wo> execute(String applicationDictFlag, String applicationFlag, String path0, String path1, String path2, String path3, String path4, String path5, JsonElement jsonElement) throws Exception { ActionResult<Wo> result = new ActionResult<>(); String id = null; try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { Business business = new Business(emc); Application application = business.application().pick(applicationFlag); if (null == application) { throw new ExceptionApplicationNotExist(applicationFlag); } id = business.applicationDict().getWithApplicationWithUniqueName(application.getId(), applicationDictFlag); if (StringUtils.isEmpty(id)) { throw new ExceptionApplicationDictNotExist(applicationFlag); } } Wo wo = ThisApplication.context().applications().putQuery(x_processplatform_service_processing.class, Applications.joinQueryUri("applicationdict", id, path0, path1, path2, path3, path4, path5, "data"), jsonElement, id).getData(Wo.class); result.setData(wo); return result; }
Example #12
Source File: ConfigAction.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
@JaxrsMethodDescribe(value = "更新人员设置.", action = ActionSetPerson.class) @PUT @Path("person") @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.APPLICATION_JSON) public void setPerson(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, JsonElement jsonElement) { ActionResult<ActionSetPerson.Wo> result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { result = new ActionSetPerson().execute(effectivePerson, jsonElement); } catch (Exception e) { logger.error(e, effectivePerson, request, jsonElement); result.error(e); } asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); }
Example #13
Source File: EventsExportEventsToJSON.java From unitime with Apache License 2.0 | 6 votes |
@Override protected void print(ExportHelper helper, EventLookupRpcRequest request, List<EventInterface> events, int eventCookieFlags, EventMeetingSortBy sort, boolean asc) throws IOException { helper.setup("application/json", reference(), false); Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { @Override public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) { return new JsonPrimitive(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(src)); } }) .setFieldNamingStrategy(new FieldNamingStrategy() { Pattern iPattern = Pattern.compile("i([A-Z])(.*)"); @Override public String translateName(Field f) { Matcher matcher = iPattern.matcher(f.getName()); if (matcher.matches()) return matcher.group(1).toLowerCase() + matcher.group(2); else return f.getName(); } }) .setPrettyPrinting().create(); helper.getWriter().write(gson.toJson(events)); }
Example #14
Source File: JsonUtil.java From olca-app with Mozilla Public License 2.0 | 6 votes |
private static boolean equal(String property, JsonArray a1, JsonArray a2, ElementFinder finder) { if (a1.size() != a2.size()) return false; Iterator<JsonElement> it1 = a1.iterator(); Set<Integer> used = new HashSet<>(); while (it1.hasNext()) { JsonElement e1 = it1.next(); int index = finder.find(property, e1, a2, used); if (index == -1) return false; JsonElement e2 = a2.get(index); if (!equal(property, e1, e2, finder)) return false; used.add(index); } return true; }
Example #15
Source File: JsonRecordGenerator.java From incubator-gobblin with Apache License 2.0 | 6 votes |
@Override public JsonElement getRecord(String id, PayloadType payloadType) { Object testObject; switch (payloadType) { case STRING: { testObject = new TestObject(id, TestUtils.generateRandomAlphaString(20)); break; } case LONG: { testObject = new TestObject(id, TestUtils.generateRandomLong()); break; } case MAP: { testObject = new TestObject(id, Collections.EMPTY_MAP); break; } default: throw new RuntimeException("Do not know how to handle this type of payload"); } JsonElement jsonElement = gson.toJsonTree(testObject); return jsonElement; }
Example #16
Source File: ActionListWithName.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception { try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { Wi wi = this.convertToWrapIn(jsonElement, Wi.class); ActionResult<Wo> result = new ActionResult<>(); Business business = new Business(emc); String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), StringUtils.join(wi.getNameList(), ",")); Element element = cache.get(cacheKey); if (null != element && (null != element.getObjectValue())) { result.setData((Wo) element.getObjectValue()); } else { Wo wo = this.list(business, wi); cache.put(new Element(cacheKey, wo)); result.setData(wo); } return result; } }
Example #17
Source File: GithubAuthHelper.java From PYX-Reloaded with Apache License 2.0 | 6 votes |
public GithubProfileInfo info(@NotNull String accessToken, @NotNull GithubEmails emails) throws IOException, GithubException { HttpGet get = new HttpGet(USER); get.addHeader("Authorization", "token " + accessToken); try { HttpResponse resp = client.execute(get); HttpEntity entity = resp.getEntity(); if (entity == null) throw new IOException(new NullPointerException("HttpEntity is null")); JsonElement element = parser.parse(new InputStreamReader(entity.getContent())); if (!element.isJsonObject()) throw new IOException("Response is not of type JsonObject"); JsonObject obj = new JsonObject(); if (obj.has("message")) throw GithubException.fromMessage(obj); else return new GithubProfileInfo(element.getAsJsonObject(), emails); } catch (JsonParseException | NullPointerException ex) { throw new IOException(ex); } finally { get.releaseConnection(); } }
Example #18
Source File: ActionFire.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception { try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { ActionResult<Wo> result = new ActionResult<>(); Wi wi = this.convertToWrapIn(jsonElement, Wi.class); if (effectivePerson.isNotManager()) { throw new ExceptionAccessDenied(effectivePerson); } Application application = ThisApplication.context().applications().get(wi.getApplication(), wi.getNode()); ScheduleRequest request = null; for (ScheduleRequest o : application.getScheduleRequestList()) { if (StringUtils.equalsIgnoreCase(wi.getClassName(), o.getClassName())) { request = o; break; } } this.fire(effectivePerson, application, request); Wo wo = new Wo(); wo.setValue(true); result.setData(wo); return result; } }
Example #19
Source File: ZhengwuDingdingAction.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
@JaxrsMethodDescribe(value = "发送一个拉入同步请求.", action = ActionSyncOrganizationCallback.class) @POST @Path("sync/organization/callback") @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.APPLICATION_JSON) public void syncOrganizationCallback(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, JsonElement jsonElement) { EffectivePerson effectivePerson = this.effectivePerson(request); ActionResult<ActionSyncOrganizationCallback.Wo> result = new ActionResult<>(); try { result = new ActionSyncOrganizationCallback().execute(effectivePerson, jsonElement); } catch (Exception e) { logger.error(e, effectivePerson, request, jsonElement); result.error(e); } asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); }
Example #20
Source File: DataAction.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
@JaxrsMethodDescribe(value = "根据路径获取指定work的data数据.", action = ActionGetWithJobPath5.class) @GET @Path("job/{job}/{path0}/{path1}/{path2}/{path3}/{path4}/{path5}") @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.APPLICATION_JSON) public void getWithJobPath5(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, @JaxrsParameterDescribe("标识") @PathParam("job") String job, @JaxrsParameterDescribe("0级路径") @PathParam("path0") String path0, @JaxrsParameterDescribe("1级路径") @PathParam("path1") String path1, @JaxrsParameterDescribe("2级路径") @PathParam("path2") String path2, @JaxrsParameterDescribe("3级路径") @PathParam("path3") String path3, @JaxrsParameterDescribe("4级路径") @PathParam("path4") String path4, @JaxrsParameterDescribe("5级路径") @PathParam("path5") String path5) { ActionResult<JsonElement> result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { result = new ActionGetWithJobPath5().execute(effectivePerson, job, path0, path1, path2, path3, path4, path5); } catch (Exception e) { logger.error(e, effectivePerson, request, null); result.error(e); } asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); }
Example #21
Source File: ActionGetDataPath0.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
ActionResult<JsonElement> execute(String appDictFlag, String appInfoFlag, String path0) throws Exception { try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { Business business = new Business(emc); ActionResult<JsonElement> result = new ActionResult<>(); AppInfo appInfo = business.getAppInfoFactory().pick(appInfoFlag); if (null == appInfo) { throw new ExceptionAppInfoNotExist(appInfoFlag); } String id = business.getAppDictFactory().getWithAppInfoWithUniqueName(appInfo.getId(), appDictFlag); if (StringUtils.isEmpty(id)) { throw new ExceptionAppDictNotExist(appInfoFlag); } AppDict dict = emc.find(id, AppDict.class); JsonElement wrap = this.get(business, dict, path0); result.setData(wrap); return result; } }
Example #22
Source File: TranslateTaskIdentityTools.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
private static List<String> duty(AeiObjects aeiObjects, Manual manual) throws Exception { List<String> list = new ArrayList<>(); if (StringUtils.isNotEmpty(manual.getTaskDuty())) { JsonArray array = XGsonBuilder.instance().fromJson(manual.getTaskDuty(), JsonArray.class); Iterator<JsonElement> iterator = array.iterator(); while (iterator.hasNext()) { JsonObject o = iterator.next().getAsJsonObject(); String name = o.get("name").getAsString(); String code = o.get("code").getAsString(); CompiledScript compiledScript = aeiObjects.business().element() .getCompiledScript(aeiObjects.getActivity(), Business.EVENT_TASKDUTY, name, code); Object objectValue = compiledScript.eval(aeiObjects.scriptContext()); List<String> ds = ScriptFactory.asDistinguishedNameList(objectValue); if (ListTools.isNotEmpty(ds)) { for (String str : ds) { List<String> os = aeiObjects.business().organization().unitDuty() .listIdentityWithUnitWithName(str, name); if (ListTools.isNotEmpty(os)) { list.addAll(os); } } } } } return ListTools.trim(list, true, true); }
Example #23
Source File: ProjectTemplateAction.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
@JaxrsMethodDescribe(value = "根据ID列表查询项目组信息列表.", action = ActionListWithFilter.class) @PUT @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.APPLICATION_JSON) public void listWithIds(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, @JaxrsParameterDescribe("传入的ID列表") JsonElement jsonElement ) { ActionResult<List<ActionListWithFilter.Wo>> result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { result = new ActionListWithFilter().execute(request, effectivePerson, jsonElement); } catch (Exception e) { logger.error(e, effectivePerson, request, null); result.error(e); } asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); }
Example #24
Source File: MethodInsnNodeSerializer.java From maple-ir with GNU General Public License v3.0 | 5 votes |
@Override public MethodInsnNode deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = (JsonObject) json; int opcode = jsonObject.get("opcode").getAsInt(); String owner = jsonObject.get("owner").getAsString(); String name = jsonObject.get("name").getAsString(); String desc = jsonObject.get("desc").getAsString(); return new MethodInsnNode(opcode, owner, name, desc, opcode == Opcodes.INVOKEINTERFACE); }
Example #25
Source File: ActionPrepareCreate.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception { logger.debug(effectivePerson, "jsonElement:{}.", jsonElement); try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { ActionResult<List<Wo>> result = new ActionResult<>(); Wi wi = this.convertToWrapIn(jsonElement, Wi.class); Business business = new Business(emc); List<Wo> wos = this.adjustForCreate(business, wi); result.setData(wos); return result; } }
Example #26
Source File: WatermarkInterval.java From incubator-gobblin with Apache License 2.0 | 5 votes |
public JsonElement toJson() { JsonObject jsonObject = new JsonObject(); jsonObject.add(LOW_WATERMARK_TO_JSON_KEY, this.lowWatermark.toJson()); jsonObject.add(EXPECTED_HIGH_WATERMARK_TO_JSON_KEY, this.expectedHighWatermark.toJson()); return jsonObject; }
Example #27
Source File: JsonReader.java From test-data-supplier with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public StreamEx<T> read() { var gson = new Gson(); try (var streamReader = new InputStreamReader(getUrl().openStream(), StandardCharsets.UTF_8); var jsonReader = new com.google.gson.stream.JsonReader(streamReader)) { return StreamEx.of((T[]) Match(parseReader(jsonReader)).of( Case($(JsonElement::isJsonArray), j -> gson.fromJson(j, castToArray(entityClass))), Case($(), j -> (T[]) new Object[] {gson.fromJson(j, castToObject(entityClass))}) )); } catch (IOException ex) { throw new IllegalArgumentException( format("Unable to read CSV data to %s. Check provided path.", entityClass), ex); } }
Example #28
Source File: JobSerializerHelper.java From cloudstack with Apache License 2.0 | 5 votes |
@Override public JsonElement serialize(Throwable th, Type type, JsonSerializationContext ctx) { JsonObject json = new JsonObject(); json.add("class", new JsonPrimitive(th.getClass().getName())); json.add("cause", s_gson.toJsonTree(th.getCause())); json.add("msg", new JsonPrimitive(th.getMessage())); // json.add("stack", s_gson.toJsonTree(th.getStackTrace())); return json; }
Example #29
Source File: ActionListWithSubjectForPage.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
protected ActionResult<List<Wo>> execute(HttpServletRequest request, EffectivePerson effectivePerson, Integer page, Integer count, JsonElement jsonElement) throws Exception { ActionResult<List<Wo>> result = new ActionResult<>(); Wi wrapIn = null; Boolean check = true; try { wrapIn = this.convertToWrapIn(jsonElement, Wi.class); if( wrapIn.getShowSubReply() == null ){ wrapIn.setShowSubReply(true); } } catch (Exception e) { check = false; Exception exception = new ExceptionReplyInfoProcess(e,"系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString()); result.error(exception); logger.error(e, effectivePerson, request, null); } if (check) { String cacheKey = wrapIn.getSubjectId() + "#" + page + "#" + count + "#" + wrapIn.getShowSubReply(); Element element = cache.get(cacheKey); if ((null != element) && (null != element.getObjectValue())) { ActionResult<List<Wo>> result_cache = (ActionResult<List<Wo>>) element.getObjectValue(); result.setData(result_cache.getData()); result.setCount(result_cache.getCount()); } else { result = getReplyQueryResult( wrapIn, request, effectivePerson, page, count ); cache.put(new Element(cacheKey, result)); } } return result; }
Example #30
Source File: MenuResource.java From fenixedu-cms with GNU Lesser General Public License v3.0 | 5 votes |
@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("/{oid}/menuItems") public JsonElement createMenuItem(@PathParam("oid") Menu menu, JsonObject json) { return view(createMenuItemFromJson(menu, json)); }