use of com.opensimulationplatform.modeldescription.xml.parser.OspModelDescriptionParser in project osp-validator by open-simulation-platform.
the class Validator method getModelDescriptionErrorMessages.
private List<String> getModelDescriptionErrorMessages(File ospSystemStructureFile, OspSystemStructure ospSystemStructureElement) {
List<String> errorMessages = new ArrayList<>();
for (Simulators.Simulator simulator : ospSystemStructureElement.getSimulators().getSimulator()) {
FmuLocator fmuLocator = new DefaultFmuLocator(ospSystemStructureFile);
URI fmu = fmuLocator.get(simulator);
OspModelDescriptionLocator ospModelDescriptionLocator = new DefaultOspModelDescriptionLocator(ospSystemStructureFile, fmuLocator);
Optional<File> ospModelDescriptionXml = ospModelDescriptionLocator.get(simulator);
if (ospModelDescriptionXml.isPresent()) {
OspModelDescriptionParser parser = new OspModelDescriptionParser();
OspModelDescriptionType ospModelDescriptionElement = parser.parse(ospModelDescriptionXml.get());
Map<Object, Location> locations = parser.getLocations();
ModelDescriptionFactory factory = new ModelDescriptionFactory();
ModelDescription modelDescription = factory.create(ospModelDescriptionXml.get(), fmu);
Simulator s = new Simulator();
s.setName(simulator.getName());
s.setModelDescription(modelDescription);
SystemStructure systemStructure = new SystemStructure();
systemStructure.getSimulators().add(s);
ModelDescriptionValidator validator = new ModelDescriptionValidator();
List<ValidationDiagnostic<Object>> diagnostics = validator.validate(systemStructure);
Map<Object, Object> coreToJaxb = createModelDescriptionMap(ospModelDescriptionElement, modelDescription);
errorMessages.addAll(getErrorMessages(ospModelDescriptionXml.get(), locations, diagnostics, coreToJaxb));
}
}
return errorMessages;
}
use of com.opensimulationplatform.modeldescription.xml.parser.OspModelDescriptionParser in project osp-validator by open-simulation-platform.
the class ModelDescriptionFactory method create.
public ModelDescription create(File ospModelDescription, URI fmu) {
OspModelDescriptionParser parser = new OspModelDescriptionParser();
OspModelDescriptionType ospModelDescriptionType = parser.parse(ospModelDescription);
OspModelDescriptionTypeConverter converter = new OspModelDescriptionTypeConverter(fmu);
return converter.convert(ospModelDescriptionType);
}
Aggregations