use of org.finos.legend.engine.external.shared.format.model.compile.ExternalFormatSchemaException in project legend-engine by finos.
the class FlatDataSchemaCompiler method compile.
public Root_meta_external_format_flatdata_metamodel_FlatData compile() {
try {
FlatData flatData = new FlatDataSchemaParser(context.getContent()).parse();
FlatDataValidationResult validationResult = FlatDataValidation.validate(flatData);
if (!validationResult.isValid()) {
String message = validationResult.getDefects().stream().map(Object::toString).collect(Collectors.joining(", "));
throw new ExternalFormatSchemaException(message);
}
return convert(flatData);
} catch (FlatDataSchemaParseException e) {
throw new ExternalFormatSchemaException(e.getMessage(), e.getStartLine(), e.getStartColumn(), e.getEndLine(), e.getEndColumn());
}
}
use of org.finos.legend.engine.external.shared.format.model.compile.ExternalFormatSchemaException in project legend-engine by finos.
the class XsdParser method handleXmlStreamException.
private ExternalFormatSchemaException handleXmlStreamException(XMLStreamException e) {
Matcher matcher = Pattern.compile("ParseError at .*\nMessage: (.*)").matcher(e.getMessage());
String message;
if (matcher.matches()) {
message = matcher.group(1);
} else {
Matcher matcher2 = Pattern.compile("(.*)\\s*at\\s*\\[.*]").matcher(e.getMessage());
message = matcher2.matches() ? matcher2.group(1) : e.getMessage();
}
return new ExternalFormatSchemaException(message, e.getLocation().getLineNumber(), e.getLocation().getColumnNumber());
}
use of org.finos.legend.engine.external.shared.format.model.compile.ExternalFormatSchemaException in project legend-engine by finos.
the class SchemaSetCompiler method secondPass.
// Second pass - compile external schemas using extension
private void secondPass(ExternalFormatSchemaSet srcSchemaSet, CompileContext context) {
String path = context.pureModel.buildPackageString(srcSchemaSet._package, srcSchemaSet.name);
Root_meta_external_shared_format_metamodel_SchemaSet compiled = schemaSetIndex.get(path);
ExternalFormatExtension schemaExtension = externalFormatExtensions.get(srcSchemaSet.format);
compiled._schemas(Lists.mutable.empty());
for (ExternalFormatSchema srcSchema : srcSchemaSet.schemas) {
try {
Root_meta_external_shared_format_metamodel_SchemaDetail detail = schemaExtension.compileSchema(new SchemaCompileContext(srcSchema, srcSchemaSet, context));
Root_meta_external_shared_format_metamodel_Schema schema = new Root_meta_external_shared_format_metamodel_Schema_Impl("")._id(srcSchema.id)._location(srcSchema.location)._detail(detail);
compiled._schemasAdd(schema);
} catch (ExternalFormatSchemaException e) {
throw new EngineException(e.getMessage(), srcSchema.contentSourceInformation, EngineErrorType.COMPILATION, e);
}
}
}
Aggregations