use of com.opensimulationplatform.core.model.modeldescription.Name in project osp-validator by open-simulation-platform.
the class OspOwlBuilder method removeNakedVariablesFromOntology.
private void removeNakedVariablesFromOntology() {
for (Map.Entry<OWLIndividual, Variable> entries : context.variables.entrySet()) {
OWLIndividual variableIndividual = entries.getKey();
Variable variable = entries.getValue();
Optional<Map.Entry<OWLIndividual, Name>> nameOptional = context.names.entrySet().stream().filter(e -> e.getValue().equals(variable.getName())).findFirst();
if (!variableExistsInVariableGroup(variable) && !variableExistsInConnection(variable)) {
OWLEntityRemover remover = new OWLEntityRemover(context.owl.manager, Collections.singleton(context.owl.ontology));
remover.visit((OWLNamedIndividual) variableIndividual);
if (nameOptional.isPresent()) {
OWLIndividual nameIndividual = nameOptional.get().getKey();
remover.visit((OWLNamedIndividual) nameIndividual);
}
context.owl.manager.applyChanges(remover.getChanges());
context.individuals.remove(variableIndividual);
if (nameOptional.isPresent()) {
OWLIndividual nameIndividual = nameOptional.get().getKey();
context.individuals.remove(nameIndividual);
}
}
}
}
use of com.opensimulationplatform.core.model.modeldescription.Name in project osp-validator by open-simulation-platform.
the class VE_Name_1_Test method invalid.
@Test
public void invalid() {
Variable v1 = new Variable();
v1.setName("not-a-unique-name");
Variable v2 = new Variable();
v2.setName("not-a-unique-name");
builder.build(v1);
builder.build(v2);
builder.complete();
List<ValidationDiagnostic<Name>> diagnostics = validationError.validate();
assertEquals(1, diagnostics.size());
Name invalidName = diagnostics.get(0).getValidatedObject();
assertEquals(invalidName.get(), v1.getName().get());
assertEquals(invalidName.get(), v2.getName().get());
}
use of com.opensimulationplatform.core.model.modeldescription.Name in project osp-validator by open-simulation-platform.
the class VE_Name_2_Test method invalid.
@Test
public void invalid() {
Simulator s1 = new Simulator();
s1.setName("not-a-unique-name");
Simulator s2 = new Simulator();
s2.setName("not-a-unique-name");
builder.build(s1);
builder.build(s2);
builder.complete();
List<ValidationDiagnostic<Name>> diagnostics = validationError.validate();
assertEquals(1, diagnostics.size());
Name invalidName = diagnostics.get(0).getValidatedObject();
assertEquals(invalidName.get(), s1.getName().get());
assertEquals(invalidName.get(), s2.getName().get());
}
use of com.opensimulationplatform.core.model.modeldescription.Name in project osp-validator by open-simulation-platform.
the class VE_Name_3_Test method invalid.
@Test
public void invalid() {
Generic vg1 = new Generic();
vg1.setName("not-a-unique-name");
Generic vg2 = new Generic();
vg2.setName("not-a-unique-name");
builder.build(vg1);
builder.build(vg2);
builder.complete();
List<ValidationDiagnostic<Name>> diagnostics = validationError.validate();
assertEquals(1, diagnostics.size());
Name invalidName = diagnostics.get(0).getValidatedObject();
assertEquals(invalidName.get(), vg1.getName().get());
assertEquals(invalidName.get(), vg2.getName().get());
}
Aggregations