@Override public Filters deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { final JsonObject j = json.getAsJsonObject(); final JsonElement filters = j.get(KEY_FILTERS); if (null == filters) { throw new JsonParseException("Missing filters array!"); } final ArrayList<DashboardFilter> viewFilters = new ArrayList<>(); filters.getAsJsonArray().forEach((f) -> viewFilters.add(context.deserialize(f, DashboardFilter.class))); return new Filters(viewFilters); } }
public static List<ConfigurationProperty> fromJSONArray(JsonReader jsonReader, String arrayKey) { List<ConfigurationProperty> configurationProperties = new ArrayList<>(); jsonReader.readArrayIfPresent(arrayKey, properties -> { properties.forEach(property -> { JsonReader configPropertyReader = new JsonReader(property.getAsJsonObject()); ConfigurationProperty configurationProperty = fromJSON(configPropertyReader); configurationProperties.add(configurationProperty); }); }); return configurationProperties; }
public static RoleConfig fromJSON(JsonReader jsonReader) { RoleConfig model = new RoleConfig(); if (jsonReader == null) { return model; } jsonReader.readArrayIfPresent("users", users -> { users.forEach(user -> model.addUser(new RoleUser(user.getAsString()))); }); return model; }
public static Tasks fromJSONArray(JsonReader jsonReader) { Tasks allTasks = new Tasks(); jsonReader.readArrayIfPresent("tasks", tasks -> { tasks.forEach(task -> { allTasks.add(fromJSON(new JsonReader(task.getAsJsonObject()))); }); }); return allTasks; }
public static ArtifactPropertiesConfig fromJSONArray(JsonReader jsonReader) { ArtifactPropertiesConfig artifactPropertyConfigs = new ArtifactPropertiesConfig(); jsonReader.readArrayIfPresent("properties", properties -> { properties.forEach(property -> { artifactPropertyConfigs.add(PropertyConfigRepresenter.fromJSON(new JsonReader(property.getAsJsonObject()))); }); }); return artifactPropertyConfigs; }
public static ParamsConfig fromJSONArray(JsonReader jsonReader) { ParamsConfig paramConfigs = new ParamsConfig(); jsonReader.readArrayIfPresent("parameters", params -> { params.forEach(param -> { paramConfigs.add(ParamRepresenter.fromJSON(new JsonReader(param.getAsJsonObject()))); }); }); return paramConfigs; }
private static void populateConfig(AdminsConfig config, JsonReader jsonReader) { jsonReader.readArrayIfPresent("users", users -> users.forEach(user -> config.add(new AdminUser(new CaseInsensitiveString(user.getAsString()))))); jsonReader.readArrayIfPresent("roles", roles -> roles.forEach(role -> config.add(new AdminRole(new CaseInsensitiveString(role.getAsString()))))); } }
public static Tabs fromJSONArray(JsonReader jsonReader) { Tabs tabsConfig = new Tabs(); jsonReader.readArrayIfPresent("tabs", tabs -> { tabs.forEach(tab -> { tabsConfig.add(fromJSON(new JsonReader(tab.getAsJsonObject()))); }); }); return tabsConfig; }
private static void setResources(JobConfig jobConfig) { ResourceConfigs resourceConfigs = new ResourceConfigs(); jsonReader.readArrayIfPresent("resources", resources -> { resources.forEach(resource -> { resourceConfigs.add(new ResourceConfig(resource.getAsString())); }); }); jobConfig.setResourceConfigs(resourceConfigs); }
public static MaterialConfigs fromJSONArray(JsonReader jsonReader, ConfigHelperOptions options) { MaterialConfigs materialConfigs = new MaterialConfigs(); jsonReader.readArrayIfPresent("materials", materials -> { materials.forEach(material -> { materialConfigs.add(MaterialRepresenter.fromJSON(new JsonReader(material.getAsJsonObject()), options)); }); }); return materialConfigs; }
public static ArtifactPropertiesConfig fromJSONArray(JsonReader jsonReader) { ArtifactPropertiesConfig artifactPropertyConfigs = new ArtifactPropertiesConfig(); jsonReader.readArrayIfPresent("properties", properties -> { properties.forEach(property -> { artifactPropertyConfigs.add(PropertyConfigRepresenter.fromJSON(new JsonReader(property.getAsJsonObject()))); }); }); return artifactPropertyConfigs; }
public static PipelineScheduleOptions fromJSON(JsonReader jsonReader) { PipelineScheduleOptions model = new PipelineScheduleOptions(); model.shouldPerformMDUBeforeScheduling(jsonReader.optBoolean("update_materials_before_scheduling").orElse(Boolean.TRUE)); jsonReader.readArrayIfPresent("materials", materials -> { List<MaterialForScheduling> materialsForScheduling = new ArrayList<>(); materials.forEach(material -> materialsForScheduling.add(MaterialRevisionRepresenter.fromJSON(new JsonReader(material.getAsJsonObject())))); model.setMaterials(materialsForScheduling); }); model.setEnvironmentVariables(EnvironmentVariableRepresenter.fromJSONArray(jsonReader)); return model; } }
public static EnvironmentVariablesConfig fromJSONArray(JsonReader jsonReader) { EnvironmentVariablesConfig variables = new EnvironmentVariablesConfig(); jsonReader.readArrayIfPresent("environment_variables", environmentVariables -> { environmentVariables.forEach(variable -> variables.add(EnvironmentVariableRepresenter.fromJSON(new JsonReader(variable.getAsJsonObject())))); }); return variables; }
public static Tasks fromJSONArray(JsonReader jsonReader) { Tasks allTasks = new Tasks(); jsonReader.readArrayIfPresent("tasks", tasks -> { tasks.forEach(task -> { allTasks.add(fromJSON(new JsonReader(task.getAsJsonObject()))); }); }); return allTasks; }
public static Filter fromJSON(JsonReader jsonReader) { Filter filter = new Filter(); filter.clear(); jsonReader.readArrayIfPresent("ignore", ignoredFiles -> { ignoredFiles.forEach(ignoredFile -> { filter.add(new IgnoredFiles(ignoredFile.getAsString())); }); }); return filter; } }
public static EnvironmentVariablesConfig fromJSONArray(JsonReader jsonReader) { EnvironmentVariablesConfig variables = new EnvironmentVariablesConfig(); jsonReader.readArrayIfPresent("environment_variables", environmentVariables -> { environmentVariables.forEach(variable -> variables.add(EnvironmentVariableRepresenter.fromJSON(new JsonReader(variable.getAsJsonObject())))); }); return variables; }
public static AdminsConfig fromJSON(JsonReader jsonReader) { AdminsConfig adminsConfig = new AdminsConfig(); jsonReader.readArrayIfPresent("users", users -> { users.forEach(user -> adminsConfig.add(new AdminUser(new CaseInsensitiveString(user.getAsString())))); }); jsonReader.readArrayIfPresent("roles", roles -> { roles.forEach(role -> adminsConfig.add(new AdminRole(new CaseInsensitiveString(role.getAsString())))); }); return adminsConfig; }
private static void setJobs(JsonReader jsonReader, StageConfig stageConfig) { JobConfigs allJobs = new JobConfigs(); jsonReader.readArrayIfPresent("jobs", jobs -> { jobs.forEach(job -> { allJobs.add(JobRepresenter.fromJSON(new JsonReader(job.getAsJsonObject()))); }); }); stageConfig.setJobs(allJobs); } }
private static void setStages(JsonReader jsonReader, PipelineConfig pipelineConfig) { pipelineConfig.getStages().clear(); jsonReader.readArrayIfPresent("stages", stages -> { stages.forEach(stage -> { pipelineConfig.addStageWithoutValidityAssertion(StageRepresenter.fromJSON(new JsonReader(stage.getAsJsonObject()))); }); }); } }
private static void setJobs(JsonReader jsonReader, StageConfig stageConfig) { JobConfigs allJobs = new JobConfigs(); jsonReader.readArrayIfPresent("jobs", jobs -> { jobs.forEach(job -> { allJobs.add(JobRepresenter.fromJSON(new JsonReader(job.getAsJsonObject()))); }); }); stageConfig.setJobs(allJobs); } }