public static String createAuthLinkResponse(){ JsonNodeFactory f = JsonNodeFactory.instance ; ObjectNode loginResponse = f.objectNode(); loginResponse.put("text","Authorization for SkyGiraffe to use Slack details is required."); ArrayNode attachments = loginResponse.putArray("attachments"); ObjectNode att = f.objectNode(); att.put("fallback", "Please authorize SkyGiraffe to access to your Slack details ..."); att.put("pretext", ""); att.put("title", "Please authorize.."); att.put("title_link", Config.getPropertyValue("SLACK_AUTH_URL_DEV")); att.put("text","Once authorized and logged into SkyGiraffe try '/sg help' to see all commands"); att.put("color", "#7CD197"); attachments.add(att); return loginResponse.toString(); }
public static Criteria getCriteria(ObjectNode rudeCriteria) throws Exception { Criteria criteria = new Criteria(); if (rudeCriteria.has("criterions")) { ArrayNode criterions = (ArrayNode) rudeCriteria.get("criterions"); if (criterions != null) { for (Iterator<JsonNode> it = criterions.iterator(); it.hasNext();) { criteria.addCriterion(parseCriterion((ObjectNode) it.next())); } } } if (rudeCriteria.has("orders")) { ArrayNode orders = (ArrayNode) rudeCriteria.get("orders"); if (orders != null) { for (Iterator<JsonNode> it = orders.iterator(); it.hasNext();) { ObjectNode rudeCriterion = (ObjectNode) it.next(); Order order = new Order(JsonUtils.getString(rudeCriterion, "property"), JsonUtils.getBoolean(rudeCriterion, "desc")); criteria.addOrder(order); } } } return criteria; }
/** * Extracts the crosspost blogs from an autosave and creates a JSON array. * * @param item * the item that holds the note data * @return the array */ private ArrayNode extractCrosspostBlogs(AutosaveNoteData item) { ArrayNode result = JsonHelper.getSharedObjectMapper().createArrayNode(); if (item.getCrosspostBlogs() != null) { for (BlogData b : item.getCrosspostBlogs()) { String title = b.getTitle(); ObjectNode blog = BlogSearchHelper.createBlogSearchJSONResult(b.getId(), b.getNameIdentifier(), title, false); result.add(blog); } } if (result.size() == 0) { return null; } return result; }
/** * @throws Exception * in case of an error */ @Test(dependsOnMethods = { "testCreateEditBlog" }) public void getReadableBlogs() throws Exception { ArrayNode array = doGetRequestAsJSONArray("/blogs.json?blogListType=READ&searchString=" + searchString, username, password); Assert.assertTrue(array.size() >= 1, "The array must have at least one blog with the search string! array=" + array); for (int i = 0; i < array.size(); i++) { JsonNode blog = array.get(i); if (LOG.isDebugEnabled()) { LOG.debug("Checking blog=" + blog); } checkJSONBlogResult(blog, "blog[" + i + "]"); String title = blog.get("title").asText(); Assert.assertTrue(title.contains(searchString), "Blog title must contain searchString! title=" + title + " searchString=" + searchString); } }
/** * { "attachments": [ { "fallback": "Please login into SkyGiraffe to continue ...", "pretext": "SkyGiraffe Login", "title": "Please login into SkyGiraffe to continue ...", "title_link": "https://sgbot-mobilityai.rhcloud.com/SGbot-1.0/skyg/login?key=", "text": "Once logged in try '/sg help' to see all commands", "color": "#7CD197" } ] } * @return */ public static String createLoginLinkResponse(String slackUserId, String email, String teamId){ JsonNodeFactory f = JsonNodeFactory.instance ; ObjectNode loginResponse = f.objectNode(); loginResponse.put("text","Login to SkyGiraffe is required."); ArrayNode attachments = loginResponse.putArray("attachments"); ObjectNode att = f.objectNode(); att.put("fallback", "Please login into SkyGiraffe to continue ..."); att.put("pretext", ""); att.put("title", "Please login.."); att.put("title_link", Config.getPropertyValue("SGDS_LOGIN_URL_DEV")+slackUserId+"&EMAIL="+email+"&TEAMID="+teamId); att.put("text","Once logged in try '/sg help' to see all commands"); att.put("color", "#7CD197"); attachments.add(att); return loginResponse.toString(); }
protected static Map<String, String> argumentsOn(JsonNode node) { Map<String, String> argValues = new HashMap<>(); JsonNode argsNode = node.get(ArgsKey); if (argsNode == null) return argValues; if (!argsNode.isArray()) { System.err.println("invalid argument node, must be an array"); return argValues; } ArrayNode args = (ArrayNode)argsNode; final int argCount = args.size(); for (int i=0; i<argCount; i++) { String[] tuple = getArgs(args.get(i)); argValues.put(tuple[0], tuple[1]); } return argValues; }
private static List<Integer>[] getOperatorDependency(ArrayNode operatorsJson) { Map<String, Integer> relationName2OperatorID = new HashMap<String, Integer>(); int numOperators = operatorsJson.size(); List<Integer>[] inputOperatorIDs = new ArrayList[numOperators]; for (int i = 0; i < numOperators; i++) { JsonNode operatorJson = operatorsJson.get(i); if (!operatorJson.has("operator")) continue; OperatorType type = OperatorType.valueOf(operatorJson.get("operator").getTextValue()); String outputName = operatorJson.get("output").getTextValue(); if (type.isTupleOperator()) { inputOperatorIDs[i] = getInputOperatorIDs(relationName2OperatorID, operatorJson); relationName2OperatorID.put(outputName, i); } } return inputOperatorIDs; }
@Private public JsonNode countersToJSON(Counters counters) { ObjectMapper mapper = new ObjectMapper(); ArrayNode nodes = mapper.createArrayNode(); if (counters != null) { for (CounterGroup counterGroup : counters) { ObjectNode groupNode = nodes.addObject(); groupNode.put("NAME", counterGroup.getName()); groupNode.put("DISPLAY_NAME", counterGroup.getDisplayName()); ArrayNode countersNode = groupNode.putArray("COUNTERS"); for (Counter counter : counterGroup) { ObjectNode counterNode = countersNode.addObject(); counterNode.put("NAME", counter.getName()); counterNode.put("DISPLAY_NAME", counter.getDisplayName()); counterNode.put("VALUE", counter.getValue()); } } } return nodes; }
public ArrayNode orderCollection(Collection<Order> collection) { ArrayNode array = JsonNodeFactory.instance.arrayNode(); for(Order param : collection){ ObjectNode obj = JsonNodeFactory.instance.objectNode(); obj.put("orderId", param.getId() ); obj.put("mile", param.getMilesage() ); obj.put("price", param.getPrice() ); obj.put("sold", param.getSold() ); obj.put("carName", param.getCar().getName() ); obj.put("carId", param.getCar().getId() ); obj.put("modelId", param.getCar().getModel().getId() ); obj.put("bodyId", param.getCar().getBody().getId() ); obj.put("drivetype", param.getCar().getDriveType().getId()); obj.put("engineId", param.getCar().getEngine().getId() ); obj.put("transsmId", param.getCar().getTransmission().getId() ); obj.put("data", param.getRelease().getTime()); obj.put("userId", param.getUser().getId() ); array.add(obj); } return array; }
public ArrayNode convert(Collection<Order> collection) { ArrayNode array = JsonNodeFactory.instance.arrayNode(); for(Order param : collection){ ObjectNode order = JsonNodeFactory.instance.objectNode(); order.put("orderId", param.getId() ); order.put("mile", param.getMilesage() ); order.put("price", param.getPrice() ); if(param.getSold()){ order.put("sold", "V" ); } else { order.put("sold", "" ); } order.put("carName", param.getCar().getName() ); order.put("carId", param.getCar().getId() ); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(param.getRelease().getTime()); //calendar.get(Calendar.YEAR); order.put("data", String.valueOf(calendar.get(Calendar.YEAR))); order.put("userId", param.getUser().getId() ); array.add(order); } return array; }
/** * Creates an array of JSON objects which hold details about the found users or groups. * * @param list * the search result to process * @param addSummary * if true a summary JSON object will be added to the top of the array. The JSON * object will be created with {@link #createSearchSummaryStatement(PageableList)} . * @param imageSize * the size of the user logo to include in the image path, can be null to not include * the image path into the JSON object. For groups no image will be included. * @return the JSON array with the details about the users */ public static ArrayNode createEntitySearchJSONResult( PageableList<CommunoteEntityData> list, boolean addSummary, ImageSizeType imageSize) { JsonNodeFactory nodeFactory = JsonHelper.getSharedObjectMapper() .getNodeFactory(); ArrayNode result = nodeFactory.arrayNode(); if (addSummary) { result.add(UserSearchHelper.createSearchSummaryStatement(list)); } for (CommunoteEntityData item : list) { String imagePath = null; boolean isGroup = (item instanceof EntityGroupListItem); if (!isGroup && imageSize != null) { imagePath = ImageUrlHelper.buildUserImageUrl(item.getEntityId(), imageSize); } ObjectNode entry = createUserSearchJSONResult(item.getEntityId(), item.getShortDisplayName(), item.getDisplayName(), imagePath, item.getAlias()); entry.put("isGroup", isGroup); result.add(entry); } return result; }
/** * Add the JSON objects of the blogs to the JSON response. * * @param jsonResponse * the response object to write to * @param list * list to process * @param includeDescription * whether to include the description * @param includeImagePath * whether to include the path to the image */ private static void addBlogsToJsonResponse(ArrayNode jsonResponse, Collection<BlogData> list, boolean includeDescription, boolean includeImagePath) { for (BlogData item : list) { ObjectNode entry; if (includeDescription) { entry = BlogSearchHelper.createBlogSearchJSONResult(item.getId(), item.getNameIdentifier(), item.getTitle(), item.getDescription(), includeImagePath); } else { entry = BlogSearchHelper.createBlogSearchJSONResult(item.getId(), item.getNameIdentifier(), item.getTitle(), includeImagePath); } jsonResponse.add(entry); } }
/** * Export the children of the topic to the response metadata as a JSON array * * @param children * the children to export */ private void exportChildrenToMetadata(List<DetailBlogListItem> children) { children = BlogManagementHelper.sortedBlogList(children); ArrayNode result = JsonHelper.getSharedObjectMapper().createArrayNode(); for (DetailBlogListItem child : children) { result.add(BlogSearchHelper.createBlogSearchJSONResult(child.getId(), child.getNameIdentifier(), child.getTitle(), false)); } this.setResponseMetadata("childTopics", result); }
/** * Extracts the attachments from a note and creates a JSON array. * * @param item * the item that holds the note data * @return the array */ private ArrayNode extractAttachments(NoteData item) { ArrayNode result = JsonHelper.getSharedObjectMapper().createArrayNode(); List<AttachmentData> attachments = item.getAttachments(); if (attachments != null) { for (AttachmentData attachment : attachments) { ObjectNode attach = CreateBlogPostFeHelper.createAttachmentJSONObject(attachment); result.add(attach); } } return result.size() == 0 ? null : result; }
/** * Extracts the tags from a note and creates a JSON array. * * @param item * the item that holds the note data * @return the array */ private ArrayNode extractTags(NoteData item) { ArrayNode result = JsonHelper.getSharedObjectMapper().createArrayNode(); // create items manually because TagData POJO is incompatible to REST API TagResource if (item.getTags() != null) { for (TagData tagItem : item.getTags()) { ObjectNode tag = result.addObject(); tag.put("tagId", tagItem.getId()); tag.put("tagStoreAlias", tagItem.getTagStoreAlias()); tag.put("tagStoreTagId", tagItem.getTagStoreTagId()); String languageCode = null; if (tagItem.getLocale() != null) { languageCode = tagItem.getLocale().toString().toLowerCase(); } tag.put("languageCode", languageCode); tag.put("name", tagItem.getName()); tag.put("description", tagItem.getDescription()); tag.put("defaultName", tagItem.getDefaultName()); } } return result; }
/** * Extracts the users to notify from a note and creates a JSON array. * * @param item * the item that holds the note data * @return the array */ private ArrayNode extractUsersToNotify(NoteData item) { ArrayNode result = JsonHelper.getSharedObjectMapper().createArrayNode(); if (item.getNotifiedUsers() != null) { for (DetailedUserData ul : item.getNotifiedUsers()) { ObjectNode user = UserSearchHelper.createUserSearchJSONResult(ul, ImageSizeType.MEDIUM); result.add(user); } } // add @@ mentions by building fake users if (item.isMentionDiscussionAuthors()) { result.add(UserSearchHelper.createUserSearchJSONResult(null, null, MessageHelper.getText(getRequest(), "autosuggest.atat.discussion"), null, NoteManagement.CONSTANT_MENTION_DISCUSSION_PARTICIPANTS)); } if (item.isMentionTopicAuthors()) { result.add(UserSearchHelper.createUserSearchJSONResult(null, null, MessageHelper.getText(getRequest(), "autosuggest.atat.authors"), null, NoteManagement.CONSTANT_MENTION_TOPIC_AUTHORS)); } if (item.isMentionTopicReaders()) { result.add(UserSearchHelper.createUserSearchJSONResult(null, null, MessageHelper.getText(getRequest(), "autosuggest.atat.all"), null, NoteManagement.CONSTANT_MENTION_TOPIC_READERS)); } if (item.isMentionTopicManagers()) { result.add(UserSearchHelper.createUserSearchJSONResult(null, null, MessageHelper.getText(getRequest(), "autosuggest.atat.managers"), null, NoteManagement.CONSTANT_MENTION_TOPIC_MANAGERS)); } if (result.size() == 0) { return null; } return result; }
/** * @throws Exception * in case of an error */ @Test public void getUsers() throws Exception { ArrayNode array = doGetRequestAsJSONArray("/users.json", username, password); Assert.assertTrue(array.size() > 0, "Must have at least on user!"); for (int i = 0; i < array.size(); i++) { JsonNode user = array.get(i); if (LOG.isDebugEnabled()) { LOG.debug("Checking user=" + user); } checkJSONUserResult(user, "user[" + i + "]"); } }
/** * @throws Exception * in case of an error */ @Test() public void getManagerBlogs() throws Exception { ArrayNode array = doGetRequestAsJSONArray("/blogs.json?blogListType=MANAGER", username, password); for (int i = 0; i < array.size(); i++) { JsonNode blog = array.get(i); if (LOG.isDebugEnabled()) { LOG.debug("Checking blog=" + blog); } checkJSONBlogResult(blog, "blog[" + i + "]"); } }
/** * @throws Exception * in case something goes wrong */ @Test public void filterPosts() throws Exception { ArrayNode result = doGetRequestAsJSONArray("/filter/posts.json?maxCount=2", getDefaultUsername(), getDefaultPassword()); Assert.assertEquals(result.size(), 2, "Result length must match!"); for (int i = 0; i < result.size(); i++) { checkJSONDetailPostListItemResult(result.get(i), "result[" + i + "].post"); } }
/** * @throws Exception * in case something goes wrong */ @Test public void filterPosts() throws Exception { ArrayNode result = doGetRequestAsJSONArray("/filter/users.json?maxCount=2", getDefaultUsername(), getDefaultPassword()); Assert.assertEquals(result.size(), 2, "Result length must match!"); for (int i = 0; i < result.size(); i++) { checkJSONUserResult(result.get(i), "result[" + i + "]"); } }
public static Object createNotePropertyFilter(String keyGroup, String key, String value, PropertyFilter.MatchMode matchMode, boolean negate) { ObjectNode propsObj = JsonHelper.getSharedObjectMapper().createObjectNode(); propsObj.put("name", "npf"); ArrayNode filterData = propsObj.putArray("value"); filterData.add("Note"); filterData.add(keyGroup); filterData.add(key); filterData.add(value); filterData.add(matchMode.name()); // negation flag is optional if (negate) { filterData.add(true); } return propsObj; }
public static SchemaComponent deSchema(String name, JsonNode n) { if (n.isObject()) return deSchema(name, (ObjectNode)n); if (n.isArray()) return deSchema(name, (ArrayNode)n); if (n.isBoolean()) return deSchema(name, (BooleanNode)n); if(n.isInt()) return deSchema(name, (IntNode)n); if (n.isFloatingPointNumber()) return deSchema(name, (DoubleNode)n); if (n.isNull()) return deSchema(name, (NullNode)n); return null; }
protected static void addParameters(ObjectNode cstNode, Map<Parameter<?>, Object> params) { ArrayNode argsNode = JsonNodeFactory.instance.arrayNode(); cstNode.put(ArgsKey, argsNode); for (Entry<Parameter<?>, Object> entry : params.entrySet()) { ObjectNode argNode = JsonNodeFactory.instance.objectNode(); argNode.put(ArgNameKey, entry.getKey().id()); argNode.put(ArgValueKey, String.valueOf(entry.getValue())); argsNode.add(argNode); } }
@Path("list") @GET @Produces(MediaType.APPLICATION_JSON) public String getClusterAsJson() throws Exception { InstanceConfig config = context.getExhibitor().getConfigManager().getConfig(); ObjectNode node = JsonNodeFactory.instance.objectNode(); ArrayNode serversNode = JsonNodeFactory.instance.arrayNode(); ServerList serverList = new ServerList(config.getString(StringConfigs.SERVERS_SPEC)); for ( ServerSpec spec : serverList.getSpecs() ) { serversNode.add(spec.getHostname()); } node.put("servers", serversNode); node.put("port", config.getInt(IntConfigs.CLIENT_PORT)); return JsonUtil.writeValueAsString(node); }
@Path("dataTable/{index-name}/{search-handle}") @GET @Produces(MediaType.APPLICATION_JSON) public String getDataTableData ( @PathParam("index-name") String indexName, @PathParam("search-handle") String searchHandle, @QueryParam("iDisplayStart") int iDisplayStart, @QueryParam("iDisplayLength") int iDisplayLength, @QueryParam("sEcho") String sEcho ) throws Exception { LogSearch logSearch = getLogSearch(indexName); if ( logSearch == null ) { return "{}"; } ObjectNode node; try { CachedSearch cachedSearch = logSearch.getCachedSearch(searchHandle); DateFormat dateFormatter = new SimpleDateFormat(DATE_FORMAT_STR); ArrayNode dataTab = JsonNodeFactory.instance.arrayNode(); for ( int i = iDisplayStart; i < (iDisplayStart + iDisplayLength); ++i ) { if ( i < cachedSearch.getTotalHits() ) { ObjectNode data = JsonNodeFactory.instance.objectNode(); int docId = cachedSearch.getNthDocId(i); SearchItem item = logSearch.toResult(docId); data.put("DT_RowId", "index-query-result-" + docId); data.put("0", getTypeName(EntryTypes.getFromId(item.getType()))); data.put("1", dateFormatter.format(item.getDate())); data.put("2", trimPath(item.getPath())); dataTab.add(data); } } node = JsonNodeFactory.instance.objectNode(); node.put("sEcho", sEcho); node.put("iTotalRecords", logSearch.getDocQty()); node.put("iTotalDisplayRecords", cachedSearch.getTotalHits()); node.put("aaData", dataTab); } finally { context.getExhibitor().getIndexCache().releaseLogSearch(logSearch.getFile()); } return node.toString(); }
@Path("backup-config") @GET @Produces(MediaType.APPLICATION_JSON) public String getBackupConfig() throws Exception { ArrayNode node = JsonNodeFactory.instance.arrayNode(); if ( context.getExhibitor().getBackupManager().isActive() ) { EncodedConfigParser parser = context.getExhibitor().getBackupManager().getBackupConfigParser(); List<BackupConfigSpec> configs = context.getExhibitor().getBackupManager().getConfigSpecs(); for ( BackupConfigSpec c : configs ) { ObjectNode n = JsonNodeFactory.instance.objectNode(); String value = parser.getValue(c.getKey()); n.put("key", c.getKey()); n.put("name", c.getDisplayName()); n.put("help", c.getHelpText()); n.put("value", (value != null) ? value : ""); n.put("type", c.getType().name().toLowerCase().substring(0, 1)); node.add(n); } } return JsonUtil.writeValueAsString(node); }
public JsonNode genJson(Resource resource, Map<?, ?> options) { final JsonNode rootNode; if (resource.getContents().size() == 1) { EObject rootObject = resource.getContents().get(0); rootNode = writeEObject(rootObject, resource); } else { final Collection<JsonNode> nodes = new ArrayList<JsonNode>(); rootNode = mapper.createArrayNode(); for (EObject obj: resource.getContents()) { JsonNode node = writeEObject(obj, resource); if (node != null) { nodes.add(node); } } ((ArrayNode)rootNode).addAll(nodes); } return rootNode; }
private void setJsonValue(ArrayNode node, Object value, EAttribute attribute) { final EDataType dataType = attribute.getEAttributeType(); if (value != null) { if (dataType.getName().contains("Int")) { int intValue = (Integer) value; node.add(intValue); } else if (dataType.getName().contains("Boolean")) { boolean booleanValue = (Boolean) value; node.add(booleanValue); } else if (dataType.getName().contains("Double")) { double doubleValue = (Double) value; node.add(doubleValue); } else if (value instanceof Date) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); String dateValue = sdf.format(value); node.add(dateValue); } else { node.add(value.toString()); } } }
protected String messageFromErrorNode(JsonNode errorNode) { StringBuffer sb = new StringBuffer(); sb.append(errorNode.get("message").asText()); if (errorNode.has("details")) { JsonNode detailsNode = errorNode.get("details"); if (detailsNode.isArray()) { ArrayNode detailsArray = (ArrayNode) detailsNode; if (detailsArray.size() > 0) { sb.append(" "); for (JsonNode detail : detailsArray) { sb.append("["); sb.append(detail.asText()); sb.append("]"); } } } else { sb.append("["); sb.append(detailsNode.asText()); sb.append("]"); } } return sb.toString(); }
private void loadMappings() { ObjectNode ports = (ObjectNode) core.get("NetworkSettings") .get("Ports"); Iterator<Entry<String, JsonNode>> it = ports.getFields(); while (it.hasNext()) { Entry<String, JsonNode> element = it.next(); String key = element.getKey(); // strip /tcp /udp suffix? if (ports.has(key)) { String[] parts = key.split("/"); String port = null; String protocol = "tcp"; if (parts.length > 1) { port = parts[0]; protocol = parts[1]; } else { port = key; } JsonNode value = element.getValue(); if (value instanceof ArrayNode) { ArrayNode mappings = (ArrayNode) element.getValue(); if (mappings.size() == 0) { System.err.println("Not mapped"); } else if (mappings.size() > 1) { System.err.println("Warning, multiple mappings. I don't know what that means, ignoring others"); } // String hostIp = hostname; //mappings.get(0).get("HostIp").asText(); String hostPort = mappings.get(0).get("HostPort").asText(); DockerServiceMapping ds = new DockerServiceMappingImpl(port, protocol, hostPort, hostname); this.mappings.put(port, ds); } } } }
/** * Static function to return instance of the union schema * * @param array JSON object for the union schema * @param props properties map. * @param names list of named schemas already read * @return a new {@link UnionSchema} instance */ public static UnionSchema newInstance(ArrayNode array, PropertyMap props, SchemaNames names) { LockableArrayList<Schema> schemas = new LockableArrayList<>(array.size()); for (JsonNode node : array) { Schema unionType = parse(node, names); if (null == unionType) { throw new SchemaParseException("Invalid JSON in union" + node); } schemas.add(unionType); } return new UnionSchema(schemas, props); }
/** This method returns JSON object with all the movie attributes and its * values**/ public ObjectNode getMovieJson() { ObjectNode movieJson = new ObjectNode(factory); ArrayNode genreArray = new ArrayNode(factory); ObjectNode genreJson = null; movieJson.put(JsonConstant.ID, this.getId()); movieJson.put(JsonConstant.TITLE, this.getTitle()); movieJson.put(JsonConstant.RELEASE_DATE, this.getDate()); movieJson.put(JsonConstant.OVERVIEW, this.getOverview()); movieJson.put(JsonConstant.VOTE, this.getVoteCount()); movieJson.put(JsonConstant.POPULARITY, this.getPopularity()); movieJson.put(JsonConstant.POSTER, this.getPosterPath()); movieJson.put(JsonConstant.RUNTIME, this.getRunTime()); for (GenreTO genreTO : genres) { genreJson = genreTO.getGenreJson(); genreArray.add(genreJson); } //EOF for //set genres to movie json object movieJson.put(JsonConstant.GENRES, genreArray); return movieJson; }
public ObjectNode getJsonObject() { this.custGenreNode = new ObjectNode(factory); ArrayNode genreArray = new ArrayNode(factory); custGenreNode.put(JsonConstant.ID, this.getId()); for (ScoredGenreTO scoredGenreTO : this.getScoredGenreList()) { genreArray.add(scoredGenreTO.getJsonObject()); } //EOF for //set cast to this object custGenreNode.put(JsonConstant.GENRES, genreArray); return custGenreNode; }
public ObjectNode getCrewJson() { this.crewNode = new ObjectNode(factory); ObjectNode movieNode = null; ArrayNode movieArray = new ArrayNode(factory); crewNode.put(JsonConstant.ID, this.getId()); crewNode.put(JsonConstant.NAME, this.getName()); crewNode.put(JsonConstant.JOB, this.getJob()); if (getMovieList() != null && getMovieList().size() > 0) { for (String movieId : this.getMovieList()) { movieNode = new ObjectNode(factory); movieNode.put(JsonConstant.ID, Integer.parseInt(movieId)); movieArray.add(movieNode); } //EOF for //set cast to this object crewNode.put(JsonConstant.MOVIES, movieArray); } return crewNode; }
public ObjectNode getJsonObject() { castCrewNode = new ObjectNode(factory); ObjectNode node = null; ArrayNode castArray = new ArrayNode(factory); ArrayNode crewArray = new ArrayNode(factory); castCrewNode.put(JsonConstant.ID, this.getMovieId()); if (castList != null) { for (CastTO castTO : castList) { node = castTO.geCastJson(); castArray.add(node); } //EOF for } if (crewList != null) { for (CrewTO crewTO : crewList) { node = crewTO.getCrewJson(); crewArray.add(node); } //EOF for } //set cast to this object castCrewNode.put(JsonConstant.CAST, castArray); //set crew to this object castCrewNode.put(JsonConstant.CREW, crewArray); return castCrewNode; }
/** This method returns JSON object with all the movie attributes and its * values**/ public ObjectNode getMovieJson() { ObjectNode movieJson = super.getObjectNode(); ArrayNode genreArray = super.getArrayNode(); ObjectNode genreJson = null; movieJson.put(JsonConstant.ID, this.getId()); movieJson.put(JsonConstant.TITLE, this.getTitle()); movieJson.put(JsonConstant.RELEASE_DATE, this.getDate()); movieJson.put(JsonConstant.VOTE, this.getVoteCount()); movieJson.put(JsonConstant.POPULARITY, this.getPopularity()); movieJson.put(JsonConstant.POSTER, this.getPosterPath()); movieJson.put(JsonConstant.RUNTIME, this.getRunTime()); movieJson.put(JsonConstant.OVERVIEW, this.getOverview()); for (GenreTO genreTO : genres) { genreJson = genreTO.getGenreJson(); genreArray.add(genreJson); } //EOF for //set genres to movie json object movieJson.put(JsonConstant.GENRES, genreArray); return movieJson; }