List of usage examples for com.fasterxml.jackson.databind JsonNode size
public int size()
From source file:com.tda.sitefilm.allocine.JSONAllocineAPIHelper.java
private static void parseListValues(List<String> values, JsonNode valuesNode) { if (valuesNode != null && (valuesNode.size() > 0)) { for (int i = 0; i < valuesNode.size(); i++) { String value = getValueAsString(valuesNode.get(i).get("$")); if (value != null) { values.add(value);//from w w w.j av a2 s. c o m } } } }
From source file:models.DataSet.java
public static List<DataSet> all() { List<DataSet> dataSets = new ArrayList<DataSet>(); JsonNode dataSetNode = APICall.callAPI(GET_ALL_DATASET); if (dataSetNode == null || dataSetNode.has("error") || !dataSetNode.isArray()) { return dataSets; }/*from w ww . j av a 2s. c om*/ for (int i = 0; i < dataSetNode.size(); i++) { JsonNode json = dataSetNode.path(i); DataSet dataset = new DataSet(); dataset.setId(json.get("id").asText()); dataset.setDataSetName(json.get("name").asText()); dataset.setAgencyId(json.get("agencyId").asText()); dataset.setInstrument(json.get("instrument").get("name").asText()); dataset.setPhysicalVariable(json.get("physicalVariable").asText()); dataset.setCMIP5VarName(json.get("CMIP5VarName").asText()); dataset.setUnits(json.get("units").asText()); dataset.setGridDimension(json.get("gridDimension").asText()); dataset.setSource(json.get("source").asText()); dataset.setStatus(json.get("status").asText()); dataset.setResponsiblePerson(json.get("responsiblePerson").asText()); dataset.setDataSourceName(json.get("dataSourceNameinWebInterface").asText()); dataset.setVariableName(json.get("variableNameInWebInterface").asText()); dataset.setDataSourceInput(json.get("dataSourceInputParameterToCallScienceApplicationCode").asText()); dataset.setVariableNameInput( json.get("variableNameInputParameterToCallScienceApplicationCode").asText()); String startTime = json.findPath("startTime").asText(); String endTime = json.findPath("endTime").asText(); Date tmpTime = null; try { tmpTime = (new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a")).parse(startTime); if (tmpTime != null) { dataset.setStartTime(new SimpleDateFormat("YYYYMM").format(tmpTime)); } } catch (ParseException e) { } try { tmpTime = (new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a")).parse(endTime); if (tmpTime != null) { dataset.setEndTime(new SimpleDateFormat("YYYYMM").format(tmpTime)); } } catch (ParseException e) { } dataSets.add(dataset); } return dataSets; }
From source file:com.tda.sitefilm.allocine.JSONAllocineAPIHelper.java
private static void parseSeasonList(List<Season> seasons, JsonNode rootNode) { JsonNode node = rootNode.get("season"); if (node != null && (node.size() > 0)) { for (int i = 0; i < node.size(); i++) { JsonNode seasonNode = node.get(i); Season season = new Season(); season.setCode(getValueAsInt(seasonNode.get("code"))); season.setSeasonNumber(getValueAsInt(seasonNode.get("seasonNumber"))); season.setYearStart(getValueAsString(seasonNode.get("yearStart"))); season.setYearEnd(getValueAsString(seasonNode.get("yearEnd"))); seasons.add(season);/*from www.j a va2s . co m*/ } } }
From source file:com.tda.sitefilm.allocine.JSONAllocineAPIHelper.java
private static Release parseRelease(JsonNode rootNode) { // parse release JsonNode node = rootNode.get("release"); if (node != null && (node.size() > 0)) { Release release = new Release(); release.setReleaseDate(getValueAsString(node.get("releaseDate"))); node = node.get("distributor"); if (node != null && (node.size() > 0)) { Distributor distributor = new Distributor(); distributor.setName(getValueAsString(node.get("name"))); release.setDistributor(distributor); }//from www. j av a 2s. com return release; } return null; }
From source file:com.tda.sitefilm.allocine.JSONAllocineAPIHelper.java
private static void parseEpisodeList(List<Episode> episodes, JsonNode rootNode) { JsonNode node = rootNode.get("episode"); if (node != null && (node.size() > 0)) { for (int i = 0; i < node.size(); i++) { JsonNode episodeNode = node.get(i); Episode episode = new Episode(); episode.setCode(getValueAsInt(episodeNode.get("code"))); episode.setTitle(getValueAsString(episodeNode.get("title"))); episode.setOriginalTitle(getValueAsString(episodeNode.get("originalTitle"))); episode.setEpisodeNumberSeries(getValueAsInt(episodeNode.get("episodeNumberSeries"))); episode.setEpisodeNumberSeason(getValueAsInt(episodeNode.get("episodeNumberSeason"))); episode.setSynopsis(getValueAsString(episodeNode.get("synopsis"))); episodes.add(episode);/* www .j a v a2 s .com*/ } } }
From source file:models.metadata.ClimateService.java
/** * Generate the list of all sensor categories * * @return a list of all the sensor categories *//*from ww w . jav a 2 s . c o m*/ public static List<ClimateService> all() { List<ClimateService> climateServices = new ArrayList<ClimateService>(); JsonNode climateServicesNode = APICall.callAPI(GET_CLIMATE_SERVICES_CALL); if (climateServicesNode == null || climateServicesNode.has("error") || !climateServicesNode.isArray()) { return climateServices; } for (int i = 0; i < climateServicesNode.size(); i++) { JsonNode json = climateServicesNode.path(i); ClimateService newService = new ClimateService(); newService.setId(json.path("id").asText()); newService.setClimateServiceName(json.get("name").asText()); newService.setPurpose(json.path("purpose").asText()); newService.setUrl(json.path("url").asText()); //newService.setCreateTime(json.path("createTime").asText()); newService.setScenario(json.path("scenario").asText()); newService.setVersion(json.path("versionNo").asText()); newService.setRootservice(json.path("rootServiceId").asText()); climateServices.add(newService); } return climateServices; }
From source file:com.tda.sitefilm.allocine.JSONAllocineAPIHelper.java
private static void parseMedia(List<Media> mediaList, JsonNode rootNode) { JsonNode node = rootNode.get("media"); if (node != null && (node.size() > 0)) { for (int i = 0; i < node.size(); i++) { JsonNode mediaNode = node.get(i); Media media = new Media(); JsonNode innerNode = mediaNode.get("type"); if (innerNode != null) { TypeType typeType = new TypeType(); typeType.setCode(getValueAsInt(innerNode.get("code"))); media.setType(typeType); }/* w ww.j av a 2 s. co m*/ innerNode = mediaNode.get("thumbnail"); if (innerNode != null) { ThumbnailType thumbnailType = new ThumbnailType(); thumbnailType.setHref(getValueAsString(innerNode.get("href"))); media.setThumbnail(thumbnailType); } mediaList.add(media); } } }
From source file:com.tda.sitefilm.allocine.JSONAllocineAPIHelper.java
private static Statistics parseStatistics(JsonNode rootNode) { JsonNode node = rootNode.get("statistics"); if (node != null) { JsonNode ratingNode = node.get("rating"); if (ratingNode != null && (ratingNode.size() > 0)) { Statistics statistics = new Statistics(); for (int i = 0; i < ratingNode.size(); i++) { node = ratingNode.get(i); RatingType ratingType = new RatingType(); ratingType.setNote(getValueAsFloat(node.get("note"))); ratingType.setValue(getValueAsInt(node.get("$"))); if (statistics.getRatingStats() == null) statistics.setRatingStats(new RatingStatsType()); statistics.getRatingStats().getRating().add(ratingType); }//from w w w . j av a2s .co m return statistics; } } return null; }
From source file:com.tda.sitefilm.allocine.JSONAllocineAPIHelper.java
private static void parseCasting(List<CastMember> members, JsonNode rootNode) { JsonNode node = rootNode.get("castMember"); if (node != null && (node.size() > 0)) { for (int i = 0; i < node.size(); i++) { JsonNode memberNode = node.get(i); CastMember member = new CastMember(); member.setRole(getValueAsString(memberNode.get("role"))); JsonNode personNode = memberNode.get("person"); if (personNode != null) { Person person = new Person(); person.setCode(getValueAsInt(personNode.get("code"))); person.setName(getValueAsString(personNode.get("name"))); member.setPerson(person); }/*www .j ava 2s .com*/ JsonNode activityNode = memberNode.get("activity"); if (activityNode != null) { ActivityType activityType = new ActivityType(); activityType.setCode(Integer.valueOf(getValueAsInt(activityNode.get("code")))); member.setActivity(activityType); } members.add(member); } } }
From source file:models.metadata.ClimateService.java
public static List<ClimateService> getMostPopular() { List<ClimateService> climateServices = new ArrayList<ClimateService>(); JsonNode climateServicesNode = APICall.callAPI(GET_MOST_POPULAR_CLIMATE_SERVICES_CALL); if (climateServicesNode == null || climateServicesNode.has("error") || !climateServicesNode.isArray()) { return climateServices; }/* w w w. j a v a2 s. c om*/ for (int i = 0; i < climateServicesNode.size(); i++) { JsonNode json = climateServicesNode.path(i); ClimateService newService = new ClimateService(); newService.setId(json.get("id").asText()); newService.setClimateServiceName(json.get("name").asText()); newService.setPurpose(json.findPath("purpose").asText()); newService.setUrl(json.findPath("url").asText()); newService.setScenario(json.findPath("scenario").asText()); newService.setVersion(json.findPath("versionNo").asText()); newService.setRootservice(json.findPath("rootServiceId").asText()); climateServices.add(newService); } return climateServices; }