Exemple #1
0
        private async static Task <ModelMetadata> UpdateModelMetadata(AltinnAppGitRepository altinnAppGitRepository, JsonSchema jsonSchema, string schemaName)
        {
            JsonSchemaToInstanceModelGenerator converter = new JsonSchemaToInstanceModelGenerator(altinnAppGitRepository.Org, altinnAppGitRepository.Repository, jsonSchema);
            ModelMetadata modelMetadata = converter.GetModelMetadata();

            await altinnAppGitRepository.UpdateModelMetadata(modelMetadata, schemaName);

            return(modelMetadata);
        }
Exemple #2
0
        private async Task <string> ProcessNewXsd(
            AltinnAppGitRepository altinnAppGitRepository,
            MemoryStream xsdMemoryStream,
            string filePath)
        {
            Json.Schema.JsonSchema jsonSchema = GenerateJsonSchemaFromXsd(xsdMemoryStream);
            var jsonContent = SerializeJson(jsonSchema);

            await altinnAppGitRepository.WriteTextByRelativePathAsync(
                Path.ChangeExtension(filePath, "schema.json"), jsonContent, true);

            var jsonSchemaConverterStrategy = JsonSchemaConverterStrategyFactory.SelectStrategy(jsonSchema);
            var metamodelConverter          =
                new JsonSchemaToMetamodelConverter(jsonSchemaConverterStrategy.GetAnalyzer());
            var schemaName    = GetSchemaName(filePath);
            var modelMetadata = metamodelConverter.Convert(schemaName, jsonContent);
            await altinnAppGitRepository.UpdateModelMetadata(modelMetadata, schemaName);

            await UpdateCSharpClasses(altinnAppGitRepository, modelMetadata, schemaName);

            await UpdateApplicationMetadata(altinnAppGitRepository, schemaName, schemaName);

            return(jsonContent);
        }