use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project cas by apereo.
the class ConfigurationMetadataGenerator method execute.
/**
* Execute.
*
* @throws Exception the exception
*/
public void execute() throws Exception {
final File jsonFile = new File(buildDir, "classes/java/main/META-INF/spring-configuration-metadata.json");
final ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
final TypeReference<Map<String, Set<ConfigurationMetadataProperty>>> values = new TypeReference<Map<String, Set<ConfigurationMetadataProperty>>>() {
};
final Map<String, Set> jsonMap = mapper.readValue(jsonFile, values);
final Set<ConfigurationMetadataProperty> properties = jsonMap.get("properties");
final Set<ConfigurationMetadataProperty> groups = jsonMap.get("groups");
final Set<ConfigurationMetadataProperty> collectedProps = new HashSet<>();
final Set<ConfigurationMetadataProperty> collectedGroups = new HashSet<>();
properties.stream().filter(p -> NESTED_TYPE_PATTERN.matcher(p.getType()).matches()).forEach(Unchecked.consumer(p -> {
final Matcher matcher = NESTED_TYPE_PATTERN.matcher(p.getType());
final boolean indexBrackets = matcher.matches();
final String typeName = matcher.group(1);
final String typePath = buildTypeSourcePath(typeName);
parseCompilationUnit(collectedProps, collectedGroups, p, typePath, typeName, indexBrackets);
}));
properties.addAll(collectedProps);
groups.addAll(collectedGroups);
final Set<ConfigurationMetadataHint> hints = processHints(properties, groups);
jsonMap.put("properties", properties);
jsonMap.put("groups", groups);
jsonMap.put("hints", hints);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
final PrettyPrinter pp = new DefaultPrettyPrinter();
mapper.writer(pp).writeValue(jsonFile, jsonMap);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project cytoscape-impl by cytoscape.
the class CyTransformerWriterImpl method write.
@Override
public void write(OutputStream stream, NamedTransformer<?, ?>... namedTransformers) throws IOException {
JsonGenerator generator = factory.createGenerator(stream);
try {
generator.setPrettyPrinter(new DefaultPrettyPrinter());
generator.writeStartArray();
try {
for (NamedTransformer<?, ?> namedTransformer : namedTransformers) {
write(generator, namedTransformer);
}
} finally {
generator.writeEndArray();
}
} finally {
generator.close();
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project hippo by NHS-digital-website.
the class OdsUtils method main.
public static void main(String[] args) throws IOException {
OdsUtils util = new OdsUtils();
int offSet = 1;
List<Organisation> finalList = new ArrayList();
while (true) {
String str = util.extracted(String.valueOf(offSet)).toString().trim();
System.out.println("Value is " + str.length());
List<Organisation> tempList = util.jsonFomart(str);
System.out.println("Value is tempList " + tempList.size());
if (tempList != null && tempList.size() > 0) {
finalList.addAll(tempList);
offSet += 1000;
System.out.println("Value of offSet is " + offSet);
System.out.println("Size of finalList is " + finalList.size());
} else {
break;
}
}
ObjectMapper objectMapper = new ObjectMapper();
// Set pretty printing of json
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
ObjectWriter writer = objectMapper.writer(new DefaultPrettyPrinter());
writer.writeValue(new File("ODS_JSON.json"), finalList);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project cxf by apache.
the class Java2SwaggerMojo method generateSwaggerPayLoad.
private void generateSwaggerPayLoad() throws MojoExecutionException {
if (outputFile == null && project != null) {
// Put the json in target/generated/json
// put the yaml in target/generated/yaml
final String name;
if (outputFileName != null) {
name = outputFileName;
} else if (resourceClasses.size() == 1) {
name = resourceClasses.iterator().next().getSimpleName();
} else {
name = "swagger";
}
outputFile = (project.getBuild().getDirectory() + "/generated/" + payload.toLowerCase() + "/" + name + "." + payload.toLowerCase()).replace("/", File.separator);
}
FileUtils.mkDir(new File(outputFile).getParentFile());
try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile))) {
if ("json".equals(this.payload)) {
ObjectWriter jsonWriter = mapper.writer(new DefaultPrettyPrinter());
writer.write(jsonWriter.writeValueAsString(swagger));
} else if ("yaml".equals(this.payload)) {
writer.write(Yaml.pretty().writeValueAsString(swagger));
}
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
// with the enclosing project
if (attachSwagger && outputFile != null) {
File jsonFile = new File(outputFile);
if (jsonFile.exists()) {
if (classifier != null) {
projectHelper.attachArtifact(project, payload.toLowerCase(), classifier, jsonFile);
} else {
projectHelper.attachArtifact(project, payload.toLowerCase(), jsonFile);
}
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project ambry by linkedin.
the class AccountUpdateTool method editAccounts.
/**
* Edit accounts in a text editor and upload them to zookeeper.
* @param accountNames the name of the accounts to edit.
* @param ignoreSnapshotVersion if {@code true}, don't verify the snapshot version.
* @throws IOException
* @throws InterruptedException
*/
void editAccounts(Collection<String> accountNames, boolean ignoreSnapshotVersion) throws IOException, InterruptedException, AccountServiceException {
Path accountJsonPath = Files.createTempFile("account-update-", ".json");
List<Account> accounts = accountNames.stream().map(accountName -> Optional.ofNullable(accountService.getAccountByName(accountName)).orElseThrow(() -> new IllegalArgumentException("Could not find account: " + accountName))).collect(Collectors.toList());
try (BufferedWriter writer = Files.newBufferedWriter(accountJsonPath)) {
new ObjectMapper().writer(new DefaultPrettyPrinter()).writeValue(writer, accounts);
}
ToolUtils.editFile(accountJsonPath);
System.out.println("The following account metadata will be uploaded:");
try (Stream<String> lines = Files.lines(accountJsonPath)) {
lines.forEach(System.out::println);
}
if (ToolUtils.yesNoPrompt("Do you want to update these accounts?")) {
updateAccountsFromFile(accountJsonPath.toAbsolutePath().toString(), ignoreSnapshotVersion);
} else {
System.out.println("Not updating any accounts");
}
Files.delete(accountJsonPath);
}
Aggregations