use of com.nedap.archie.adl14.ADL14Converter in project archetype-languageserver by nedap.
the class ADL14ConvertingStorage method convertAll.
public void convertAll(String rootUri) {
ADL14Converter adl14Converter = new ADL14Converter(BuiltinReferenceModels.getMetaModels(), configuration);
adl14Converter.setExistingRepository(repository);
ADL2ConversionResultList converted = adl14Converter.convert(new ArrayList<>(adl14Files.values()));
for (ADL2ConversionResult result : converted.getConversionResults()) {
if (result.getException() != null) {
textService.pushDiagnostics(new TextDocumentIdentifier(rootUri), result.getException());
} else {
String newPath = rootUri.substring(0, rootUri.lastIndexOf("/")) + "/out/" + result.getArchetypeId() + ".adls";
textService.writeFile(newPath, "ADL2 conversion of " + result.getArchetypeId(), ADLArchetypeSerializer.serialize(result.getArchetype()));
}
}
}
use of com.nedap.archie.adl14.ADL14Converter in project archetype-languageserver by nedap.
the class ADL14ConvertingStorage method convert.
public void convert(String documentUri) {
ADL14Converter adl14Converter = new ADL14Converter(BuiltinReferenceModels.getMetaModels(), configuration);
adl14Converter.setExistingRepository(repository);
Archetype archetype = adl14Files.get(documentUri);
// find all parent archetypes that must also be converted for this to properly work
List<Archetype> toConvert = getAllToConvertIncludingParents(archetype);
ADL2ConversionResultList converted = adl14Converter.convert(toConvert);
for (ADL2ConversionResult result : converted.getConversionResults()) {
if (result.getException() != null) {
textService.pushDiagnostics(new TextDocumentIdentifier(documentUri), result.getException());
} else {
String newPath = documentUri.substring(0, documentUri.lastIndexOf("/")) + "/adl2/" + result.getArchetypeId() + ".adls";
textService.writeFile(newPath, "ADL2 conversion of " + result.getArchetypeId(), ADLArchetypeSerializer.serialize(result.getArchetype()));
}
}
}
Aggregations