use of org.apache.camel.maven.packaging.model.LanguageModel in project camel by apache.
the class SpringBootAutoConfigurationMojo method generateLanguageModel.
private static LanguageModel generateLanguageModel(String languageName, String json) {
List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("language", json, false);
LanguageModel language = new LanguageModel();
language.setTitle(getSafeValue("title", rows));
language.setName(getSafeValue("name", rows));
language.setModelName(getSafeValue("modelName", rows));
language.setDescription(getSafeValue("description", rows));
language.setFirstVersion(JSonSchemaHelper.getSafeValue("firstVersion", rows));
language.setLabel(getSafeValue("label", rows));
language.setDeprecated(getSafeValue("deprecated", rows));
language.setJavaType(getSafeValue("javaType", rows));
language.setGroupId(getSafeValue("groupId", rows));
language.setArtifactId(getSafeValue("artifactId", rows));
language.setVersion(getSafeValue("version", rows));
rows = JSonSchemaHelper.parseJsonSchema("properties", json, true);
for (Map<String, String> row : rows) {
LanguageOptionModel option = new LanguageOptionModel();
option.setName(getSafeValue("name", row));
option.setDisplayName(getSafeValue("displayName", row));
option.setKind(getSafeValue("kind", row));
option.setType(getSafeValue("type", row));
option.setJavaType(getSafeValue("javaType", row));
option.setDeprecated(getSafeValue("deprecated", row));
option.setDescription(getSafeValue("description", row));
option.setDefaultValue(getSafeValue("defaultValue", row));
option.setEnumValues(getSafeValue("enum", row));
language.addLanguageOption(option);
}
return language;
}
use of org.apache.camel.maven.packaging.model.LanguageModel in project camel by apache.
the class PrepareUserGuideMojo method executeLanguages.
protected void executeLanguages() throws MojoExecutionException, MojoFailureException {
Set<File> languageFiles = new TreeSet<>();
if (languagesDir != null && languagesDir.isDirectory()) {
File[] files = languagesDir.listFiles();
if (files != null) {
languageFiles.addAll(Arrays.asList(files));
}
}
try {
List<LanguageModel> models = new ArrayList<>();
for (File file : languageFiles) {
String json = loadText(new FileInputStream(file));
LanguageModel model = generateLanguageModel(json);
models.add(model);
}
// sor the models
Collections.sort(models, new LanguageComparator());
// the summary file has the TOC
File file = new File(userGuideDir, "SUMMARY.md");
// update languages
StringBuilder languages = new StringBuilder();
languages.append("* Expression Languages\n");
for (LanguageModel model : models) {
String line = "\t* " + link(model) + "\n";
languages.append(line);
}
boolean updated = updateLanguages(file, languages.toString());
if (updated) {
getLog().info("Updated user guide file: " + file);
} else {
getLog().debug("No changes to user guide file: " + file);
}
} catch (IOException e) {
throw new MojoFailureException("Error due " + e.getMessage(), e);
}
}
use of org.apache.camel.maven.packaging.model.LanguageModel in project camel by apache.
the class PrepareReadmeMojo method generateLanguageModel.
private LanguageModel generateLanguageModel(String json) {
List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("language", json, false);
LanguageModel language = new LanguageModel();
language.setTitle(JSonSchemaHelper.getSafeValue("title", rows));
language.setName(JSonSchemaHelper.getSafeValue("name", rows));
language.setModelName(JSonSchemaHelper.getSafeValue("modelName", rows));
language.setDescription(JSonSchemaHelper.getSafeValue("description", rows));
language.setFirstVersion(JSonSchemaHelper.getSafeValue("firstVersion", rows));
language.setLabel(JSonSchemaHelper.getSafeValue("label", rows));
language.setDeprecated(JSonSchemaHelper.getSafeValue("deprecated", rows));
language.setJavaType(JSonSchemaHelper.getSafeValue("javaType", rows));
language.setGroupId(JSonSchemaHelper.getSafeValue("groupId", rows));
language.setArtifactId(JSonSchemaHelper.getSafeValue("artifactId", rows));
language.setVersion(JSonSchemaHelper.getSafeValue("version", rows));
return language;
}
use of org.apache.camel.maven.packaging.model.LanguageModel in project camel by apache.
the class UpdateReadmeMojo method generateLanguageModel.
private LanguageModel generateLanguageModel(String languageName, String json) {
List<Map<String, String>> rows = parseJsonSchema("language", json, false);
LanguageModel language = new LanguageModel();
language.setTitle(getSafeValue("title", rows));
language.setModelName(getSafeValue("modelName", rows));
language.setName(getSafeValue("name", rows));
language.setDescription(getSafeValue("description", rows));
language.setFirstVersion(getSafeValue("firstVersion", rows));
language.setLabel(getSafeValue("label", rows));
language.setDeprecated(getSafeValue("deprecated", rows));
language.setJavaType(getSafeValue("javaType", rows));
language.setGroupId(getSafeValue("groupId", rows));
language.setArtifactId(getSafeValue("artifactId", rows));
language.setVersion(getSafeValue("version", rows));
rows = parseJsonSchema("properties", json, true);
for (Map<String, String> row : rows) {
LanguageOptionModel option = new LanguageOptionModel();
option.setName(getSafeValue("name", row));
option.setDisplayName(getSafeValue("displayName", row));
option.setKind(getSafeValue("kind", row));
option.setType(getSafeValue("type", row));
option.setJavaType(getSafeValue("javaType", row));
option.setDeprecated(getSafeValue("deprecated", row));
option.setEnumValues(getSafeValue("enum", row));
option.setDefaultValue(getSafeValue("defaultValue", row));
option.setDescription(getSafeValue("description", row));
// skip option named id/expression
if ("id".equals(option.getName()) || "expression".equals(option.getName())) {
getLog().debug("Skipping option: " + option.getName());
} else {
language.addLanguageOption(option);
}
}
return language;
}
Aggregations