Search in sources :

Example 1 with OWLEntityRenamer

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);
}
Also used : OWLEntityRenamer(org.semanticweb.owlapi.util.OWLEntityRenamer)

Example 2 with OWLEntityRenamer

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());
}
Also used : IRI(org.semanticweb.owlapi.model.IRI) HashMap(java.util.HashMap) OWLOntologyChange(org.semanticweb.owlapi.model.OWLOntologyChange) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) Collection(java.util.Collection) OWLEntityRenamer(org.semanticweb.owlapi.util.OWLEntityRenamer)

Example 3 with OWLEntityRenamer

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);
}
Also used : OWLEntityRenamer(org.semanticweb.owlapi.util.OWLEntityRenamer)

Example 4 with OWLEntityRenamer

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);
}
Also used : ChangeEntityIRIResult(edu.stanford.bmir.protege.web.shared.entity.ChangeEntityIRIResult) OWLOntologyChange(org.semanticweb.owlapi.model.OWLOntologyChange) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) OWLEntityRenamer(org.semanticweb.owlapi.util.OWLEntityRenamer) Nonnull(javax.annotation.Nonnull)

Aggregations

OWLEntityRenamer (org.semanticweb.owlapi.util.OWLEntityRenamer)4 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)2 OWLOntologyChange (org.semanticweb.owlapi.model.OWLOntologyChange)2 ChangeEntityIRIResult (edu.stanford.bmir.protege.web.shared.entity.ChangeEntityIRIResult)1 OWLEntityData (edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Nonnull (javax.annotation.Nonnull)1 IRI (org.semanticweb.owlapi.model.IRI)1