Search in sources :

Example 21 with OWLEntity

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);
}
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)

Example 22 with OWLEntity

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));
                        }
                    }
                }
            }
        }
    }
}
Also used : OWLAnnotationAssertionAxiom(org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom) HasGetEntitiesWithIRI(edu.stanford.bmir.protege.web.shared.HasGetEntitiesWithIRI) IRI(org.semanticweb.owlapi.model.IRI) EntityDeprecatedChangedEvent(edu.stanford.bmir.protege.web.shared.event.EntityDeprecatedChangedEvent) OWLOntologyChange(org.semanticweb.owlapi.model.OWLOntologyChange) OWLEntity(org.semanticweb.owlapi.model.OWLEntity)

Example 23 with OWLEntity

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);
            }
        }
    }
}
Also used : OWLOntologyChange(org.semanticweb.owlapi.model.OWLOntologyChange) OWLEntity(org.semanticweb.owlapi.model.OWLEntity)

Example 24 with OWLEntity

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));
                }
            }
        }
    }
}
Also used : OWLOntologyChange(org.semanticweb.owlapi.model.OWLOntologyChange) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) BrowserTextChangedEvent(edu.stanford.bmir.protege.web.shared.event.BrowserTextChangedEvent) HashSet(java.util.HashSet)

Example 25 with OWLEntity

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;
}
Also used : TypeSafeConverter(edu.stanford.bmir.protege.web.server.persistence.TypeSafeConverter) Document(org.bson.Document) OWLLiteral(org.semanticweb.owlapi.model.OWLLiteral) OWLDataFactory(org.semanticweb.owlapi.model.OWLDataFactory) OWLEntityConverter(edu.stanford.bmir.protege.web.server.persistence.OWLEntityConverter) HashMap(java.util.HashMap) FormDataPrimitive(edu.stanford.bmir.protege.web.shared.form.data.FormDataPrimitive) FormDataList(edu.stanford.bmir.protege.web.shared.form.data.FormDataList) MappedField(org.mongodb.morphia.mapping.MappedField) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) List(java.util.List) FormDataObject(edu.stanford.bmir.protege.web.shared.form.data.FormDataObject) DBObject(com.mongodb.DBObject) IRI(org.semanticweb.owlapi.model.IRI) Map(java.util.Map) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) FormDataValue(edu.stanford.bmir.protege.web.shared.form.data.FormDataValue) SimpleValueConverter(org.mongodb.morphia.converters.SimpleValueConverter) FormDataList(edu.stanford.bmir.protege.web.shared.form.data.FormDataList) FormDataPrimitive(edu.stanford.bmir.protege.web.shared.form.data.FormDataPrimitive) FormDataObject(edu.stanford.bmir.protege.web.shared.form.data.FormDataObject) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) Document(org.bson.Document) OWLLiteral(org.semanticweb.owlapi.model.OWLLiteral) FormDataList(edu.stanford.bmir.protege.web.shared.form.data.FormDataList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

OWLEntity (org.semanticweb.owlapi.model.OWLEntity)45 Test (org.junit.Test)13 OWLOntologyChange (org.semanticweb.owlapi.model.OWLOntologyChange)7 OWLEntityData (edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)6 ArrayList (java.util.ArrayList)6 Nonnull (javax.annotation.Nonnull)6 Inject (javax.inject.Inject)6 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)5 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)4 AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)3 IRI (org.semanticweb.owlapi.model.IRI)3 DBObject (com.mongodb.DBObject)2 EntitySuggestion (edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion)2 AbstractProjectActionHandler (edu.stanford.bmir.protege.web.server.dispatch.AbstractProjectActionHandler)2 ExecutionContext (edu.stanford.bmir.protege.web.server.dispatch.ExecutionContext)2 VIEW_PROJECT (edu.stanford.bmir.protege.web.shared.access.BuiltInAction.VIEW_PROJECT)2 ColumnType (edu.stanford.bmir.protege.web.shared.csv.ColumnType)2 OWLPrimitiveData (edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)2 ProjectEvent (edu.stanford.bmir.protege.web.shared.event.ProjectEvent)2 Comparator.comparing (java.util.Comparator.comparing)2