Search in sources :

Example 1 with ADL2ConversionResult

use of com.nedap.archie.adl14.ADL2ConversionResult 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()));
        }
    }
}
Also used : ADL14Converter(com.nedap.archie.adl14.ADL14Converter) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) VersionedTextDocumentIdentifier(org.eclipse.lsp4j.VersionedTextDocumentIdentifier) ADL2ConversionResultList(com.nedap.archie.adl14.ADL2ConversionResultList) ADL2ConversionResult(com.nedap.archie.adl14.ADL2ConversionResult)

Example 2 with ADL2ConversionResult

use of com.nedap.archie.adl14.ADL2ConversionResult 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()));
        }
    }
}
Also used : ADL14Converter(com.nedap.archie.adl14.ADL14Converter) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) VersionedTextDocumentIdentifier(org.eclipse.lsp4j.VersionedTextDocumentIdentifier) Archetype(com.nedap.archie.aom.Archetype) ADL2ConversionResultList(com.nedap.archie.adl14.ADL2ConversionResultList) ADL2ConversionResult(com.nedap.archie.adl14.ADL2ConversionResult)

Aggregations

ADL14Converter (com.nedap.archie.adl14.ADL14Converter)2 ADL2ConversionResult (com.nedap.archie.adl14.ADL2ConversionResult)2 ADL2ConversionResultList (com.nedap.archie.adl14.ADL2ConversionResultList)2 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)2 VersionedTextDocumentIdentifier (org.eclipse.lsp4j.VersionedTextDocumentIdentifier)2 Archetype (com.nedap.archie.aom.Archetype)1