use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.
the class ChangeEntityIRIActionHandler method execute.
@Nonnull
@Override
public ChangeEntityIRIResult execute(@Nonnull ChangeEntityIRIAction action, @Nonnull ExecutionContext executionContext) {
OWLEntityRenamer renamer = new OWLEntityRenamer(rootOntology.getOWLOntologyManager(), rootOntology.getImportsClosure());
List<OWLOntologyChange> changeList = renamer.changeIRI(action.getEntity(), action.getTheNewIri());
OWLEntityData oldRendering = renderer.getRendering(action.getEntity());
applyChanges.applyChanges(executionContext.getUserId(), new FixedChangeListGenerator<>(changeList, action.getEntity(), String.format("Changed %s IRI from %s to %s", action.getEntity().getEntityType().getPrintName(), action.getEntity().getIRI(), action.getTheNewIri())));
OWLEntity theNewEntity = dataFactory.getOWLEntity(action.getEntity().getEntityType(), action.getTheNewIri());
discussionThreadRepository.replaceEntity(projectId, action.getEntity(), theNewEntity);
OWLEntityData newRendering = renderer.getRendering(theNewEntity);
return new ChangeEntityIRIResult(projectId, oldRendering, newRendering);
}
use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.
the class EntityDeprecatedChangedEventTranslator method translateOntologyChanges.
@Override
public void translateOntologyChanges(Revision revision, ChangeApplicationResult<?> changes, List<ProjectEvent<?>> projectEventList) {
for (OWLOntologyChange change : changes.getChangeList()) {
if (change.isAxiomChange()) {
if (change.getAxiom() instanceof OWLAnnotationAssertionAxiom) {
OWLAnnotationAssertionAxiom axiom = (OWLAnnotationAssertionAxiom) change.getAxiom();
if (axiom.getProperty().isDeprecated()) {
if (axiom.getSubject() instanceof IRI) {
IRI subject = (IRI) axiom.getSubject();
for (OWLEntity entity : hasGetEntitiesWithIRI.getEntitiesWithIRI(subject)) {
boolean deprecated = deprecatedEntityChecker.isDeprecated(entity);
projectEventList.add(new EntityDeprecatedChangedEvent(projectId, entity, deprecated));
}
}
}
}
}
}
}
use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.
the class BrowserTextChangedEventComputer method prepareForOntologyChanges.
@Override
public void prepareForOntologyChanges(List<OWLOntologyChange> submittedChanges) {
for (OWLOntologyChange change : submittedChanges) {
for (OWLEntity entity : hasChangeSubject.getChangeSubjects(change)) {
if (hasContainsEntityInSignature.containsEntityInSignature(entity)) {
String shortForm = shortFormProvider.getShortForm(entity);
shortFormMap.put(entity, shortForm);
}
}
}
}
use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.
the class BrowserTextChangedEventComputer method translateOntologyChanges.
@Override
public void translateOntologyChanges(Revision revision, ChangeApplicationResult<?> changes, List<ProjectEvent<?>> projectEventList) {
Set<OWLEntity> processedEntities = new HashSet<>();
for (OWLOntologyChange change : changes.getChangeList()) {
for (OWLEntity entity : hasChangeSubject.getChangeSubjects(change)) {
if (processedEntities.add(entity)) {
String shortForm = shortFormProvider.getShortForm(entity);
String oldShortForm = shortFormMap.get(entity);
if (oldShortForm == null || !shortForm.equals(oldShortForm)) {
projectEventList.add(new BrowserTextChangedEvent(entity, shortForm, projectId));
}
}
}
}
}
use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.
the class FormDataValueConverter method encodeObject.
@Override
public Object encodeObject(FormDataValue value, MappedField optionalExtraInfo) {
if (value instanceof FormDataObject) {
Document document = new Document();
FormDataObject object = (FormDataObject) value;
object.getMap().forEach((key, val) -> document.put(key, encodeObject(val, optionalExtraInfo)));
return document;
} else if (value instanceof FormDataList) {
List<Object> result = new ArrayList<>();
FormDataList list = (FormDataList) value;
list.getList().forEach(e -> result.add(encodeObject(e, optionalExtraInfo)));
return result;
} else if (value instanceof FormDataPrimitive) {
FormDataPrimitive primitive = (FormDataPrimitive) value;
if (primitive.isNumber()) {
return primitive.getValueAsDouble();
} else if (primitive.isString()) {
return primitive.getValueAsString();
} else if (primitive.isBoolean()) {
return primitive.getValueAsBoolean();
} else if (primitive instanceof FormDataPrimitive.LiteralPrimitive) {
OWLLiteral literal = primitive.asLiteral().get();
Document document = new Document();
document.put("literal", literal.getLiteral());
if (literal.isRDFPlainLiteral()) {
document.put("lang", literal.getLang());
} else {
document.put("datatype", literal.getDatatype());
}
return document;
} else if (primitive instanceof FormDataPrimitive.IRIPrimitive) {
return new Document("iri", primitive.asIRI().get().toString());
} else if (primitive instanceof FormDataPrimitive.OWLEntityPrimitive) {
OWLEntity entity = (OWLEntity) primitive.getValue();
return entityConverter.encodeObject(entity, optionalExtraInfo);
}
} else {
throw new RuntimeException("Unknown type of object " + value);
}
return null;
}
Aggregations