Search in sources :

Example 1 with OspModelDescriptionLocator

use of com.opensimulationplatform.systemstructure.util.OspModelDescriptionLocator 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;
}
Also used : ModelDescriptionFactory(com.opensimulationplatform.modeldescription.xml.factory.ModelDescriptionFactory) OspSystemStructure(com.opensimulationplatform.systemstructure.xml.model.OspSystemStructure) SystemStructure(com.opensimulationplatform.core.model.systemstructure.SystemStructure) URI(java.net.URI) OspModelDescriptionParser(com.opensimulationplatform.modeldescription.xml.parser.OspModelDescriptionParser) DefaultFmuLocator(com.opensimulationplatform.systemstructure.util.DefaultFmuLocator) FmuLocator(com.opensimulationplatform.systemstructure.util.FmuLocator) ModelDescriptionValidator(com.opensimulationplatform.core.validation.modeldescription.ModelDescriptionValidator) ModelDescription(com.opensimulationplatform.core.model.modeldescription.ModelDescription) Simulators(com.opensimulationplatform.systemstructure.xml.model.Simulators) DefaultOspModelDescriptionLocator(com.opensimulationplatform.systemstructure.util.DefaultOspModelDescriptionLocator) OspModelDescriptionLocator(com.opensimulationplatform.systemstructure.util.OspModelDescriptionLocator) DefaultOspModelDescriptionLocator(com.opensimulationplatform.systemstructure.util.DefaultOspModelDescriptionLocator) DefaultFmuLocator(com.opensimulationplatform.systemstructure.util.DefaultFmuLocator) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) File(java.io.File) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) Location(javax.xml.stream.Location)

Aggregations

ModelDescription (com.opensimulationplatform.core.model.modeldescription.ModelDescription)1 Simulator (com.opensimulationplatform.core.model.systemstructure.Simulator)1 SystemStructure (com.opensimulationplatform.core.model.systemstructure.SystemStructure)1 ValidationDiagnostic (com.opensimulationplatform.core.validation.ValidationDiagnostic)1 ModelDescriptionValidator (com.opensimulationplatform.core.validation.modeldescription.ModelDescriptionValidator)1 ModelDescriptionFactory (com.opensimulationplatform.modeldescription.xml.factory.ModelDescriptionFactory)1 OspModelDescriptionParser (com.opensimulationplatform.modeldescription.xml.parser.OspModelDescriptionParser)1 DefaultFmuLocator (com.opensimulationplatform.systemstructure.util.DefaultFmuLocator)1 DefaultOspModelDescriptionLocator (com.opensimulationplatform.systemstructure.util.DefaultOspModelDescriptionLocator)1 FmuLocator (com.opensimulationplatform.systemstructure.util.FmuLocator)1 OspModelDescriptionLocator (com.opensimulationplatform.systemstructure.util.OspModelDescriptionLocator)1 OspSystemStructure (com.opensimulationplatform.systemstructure.xml.model.OspSystemStructure)1 Simulators (com.opensimulationplatform.systemstructure.xml.model.Simulators)1 File (java.io.File)1 URI (java.net.URI)1 Location (javax.xml.stream.Location)1