use of org.semanticweb.owlapi.util.OWLEntityRenamer in project webprotege by protegeproject.
the class SuppliedNameSuffixEntityCrudKitHandler method update.
@Override
public <E extends OWLEntity> void update(ChangeSetEntityCrudSession session, E entity, EntityShortForm shortForm, EntityCrudContext context, OntologyChangeList.Builder<E> changeListBuilder) {
// TODO: This requires that we update comments on this entity
OWLEntityRenamer renamer = new OWLEntityRenamer(context.getTargetOntology().getOWLOntologyManager(), context.getTargetOntology().getImportsClosure());
List<OWLOntologyChange> changeList = renamer.changeIRI(entity, createEntityIRI(shortForm));
changeListBuilder.addAll(changeList);
}
use of org.semanticweb.owlapi.util.OWLEntityRenamer in project webprotege by protegeproject.
the class FindAndReplaceIRIPrefixChangeGenerator method generateChanges.
@Override
public OntologyChangeList<Collection<OWLEntity>> generateChanges(ChangeGenerationContext context) {
OntologyChangeList.Builder<Collection<OWLEntity>> builder = OntologyChangeList.builder();
Map<OWLEntity, IRI> renameMap = new HashMap<>();
for (OWLEntity entity : rootOntology.getSignature(Imports.INCLUDED)) {
if (!entity.isBuiltIn()) {
IRI iri = entity.getIRI();
String iriString = iri.toString();
if (iriString.startsWith(fromPrefix)) {
IRI toIRI = IRI.create(toPrefix + iri.subSequence(fromPrefix.length(), iri.length()));
renameMap.put(entity, toIRI);
}
}
}
OWLEntityRenamer entityRenamer = new OWLEntityRenamer(rootOntology.getOWLOntologyManager(), rootOntology.getImportsClosure());
List<OWLOntologyChange> changeList = entityRenamer.changeIRI(renameMap);
builder.addAll(changeList);
return builder.build(renameMap.keySet());
}
use of org.semanticweb.owlapi.util.OWLEntityRenamer in project webprotege by protegeproject.
the class MergeEntitiesChangeListGenerator method replaceUsage.
private void replaceUsage(OntologyChangeList.Builder<OWLEntity> builder) {
OWLEntityRenamer renamer = new OWLEntityRenamer(rootOntology.getOWLOntologyManager(), rootOntology.getImportsClosure());
List<OWLOntologyChange> renameChanges = renamer.changeIRI(sourceEntity.getIRI(), targetEntity.getIRI());
builder.addAll(renameChanges);
}
use of org.semanticweb.owlapi.util.OWLEntityRenamer 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);
}
Aggregations