Package edu.stanford.bmir.protege.web.server.owlapi

Examples of edu.stanford.bmir.protege.web.server.owlapi.OWLAPIProject


        return s.replace(" ", "%20");
    }


    private OWLAnnotation convertXRefToAnnotation(ProjectId projectId, OBOXRef xref) {
        OWLAPIProject project = getProject(projectId);
        OWLDataFactory df = project.getDataFactory();
        OWLAnnotationProperty xrefAnnotationProperty = df.getOWLAnnotationProperty(getXRefPropertyIRI());
        String oboId = xref.toOBOId();
        Set<OWLAnnotation> descriptionAnnotations;
        if (xref.getDescription().isEmpty()) {
            descriptionAnnotations = Collections.emptySet();
View Full Code Here


        return pm.getProject(projectId);
    }

    public Collection<OBOTermSynonym> getSynonyms(ProjectId projectId, OWLEntity term) {
        Set<OBOTermSynonym> result = new HashSet<OBOTermSynonym>();
        OWLAPIProject project = getProject(projectId);
        for (OWLOntology ontology : project.getRootOntology().getImportsClosure()) {
            Set<OWLAnnotationAssertionAxiom> annotationAssertionAxioms = ontology.getAnnotationAssertionAxioms(term.getIRI());
            for (OWLAnnotationAssertionAxiom ax : annotationAssertionAxioms) {
                OBOTermSynonymScope synonymScope = getSynonymScope(ax);
                if (synonymScope != null) {
                    OBOTermSynonym termSynonym = new OBOTermSynonym(getXRefs(ax), getStringValue(ax), synonymScope);
View Full Code Here

        return result;
    }

    public void setSynonyms(ProjectId projectId, OWLEntity term, Collection<OBOTermSynonym> synonyms) throws NotSignedInException {
        org.semanticweb.owlapi.model.IRI subject = term.getIRI();
        OWLAPIProject project = getProject(projectId);
        OWLOntology rootOntology = project.getRootOntology();
        OWLDataFactory df = project.getDataFactory();
        List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();

        for (OWLAnnotationAssertionAxiom ax : project.getRootOntology().getAnnotationAssertionAxioms(subject)) {
            if (getSynonymScope(ax) != null) {
                changes.add(new RemoveAxiom(rootOntology, ax));
            }
        }

        for (OBOTermSynonym synonym : synonyms) {
            OWLAnnotationProperty synonymProperty = getSynonymAnnoationProperty(df, synonym.getScope());
            OWLLiteral synonymNameLiteral = df.getOWLLiteral(synonym.getName());
            Set<OWLAnnotation> synonymXRefs = convertOBOXRefsToOWLAnnotations(projectId, synonym.getXRefs());
            OWLAnnotationAssertionAxiom synonymAnnotationAssertion = df.getOWLAnnotationAssertionAxiom(synonymProperty, subject, synonymNameLiteral, synonymXRefs);
            changes.add(new AddAxiom(rootOntology, synonymAnnotationAssertion));
        }


        project.applyChanges(getUserInSessionAndEnsureSignedIn(), changes, "Set synonym");
    }
View Full Code Here

//        return Obo2OWLConstants.getVocabularyObj(vocabulary.getName()).getIRI();
    }

    public OBOTermRelationships getRelationships(ProjectId projectId, OWLClass term) {
        OWLAPIProject project = getProject(projectId);
        OWLClass cls = project.getDataFactory().getOWLClass(term.getIRI());
        Set<OWLSubClassOfAxiom> subClassOfAxioms = project.getRootOntology().getSubClassAxiomsForSubClass(cls);
        Set<OBORelationship> rels = new HashSet<OBORelationship>();
        for (OWLSubClassOfAxiom ax : subClassOfAxioms) {
            Set<OWLObjectSomeValuesFrom> relationships = new HashSet<OWLObjectSomeValuesFrom>();
            Set<OWLClassExpression> conjuncts = ax.getSuperClass().asConjunctSet();
            for (OWLClassExpression conjunct : conjuncts) {
View Full Code Here

    public void setRelationships(ProjectId projectId, OWLClass lastEntity, OBOTermRelationships relationships) {
        ensureSignedIn();
        if (relationships == null) {
            throw new NullPointerException("relationships must not be null");
        }
        OWLAPIProject project = getProject(projectId);

        OWLDataFactory dataFactory = project.getDataFactory();

        Set<OWLObjectSomeValuesFrom> superClsesToSet = new HashSet<OWLObjectSomeValuesFrom>();
        for (OBORelationship relationship : relationships.getRelationships()) {
            OWLObjectSomeValuesFrom someValuesFrom = toSomeValuesFrom(dataFactory, relationship);
            superClsesToSet.add(someValuesFrom);
        }


        List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();

        OWLOntology ontology = project.getRootOntology();
        OWLClass cls = dataFactory.getOWLClass(lastEntity.getIRI());
        Set<OWLObjectSomeValuesFrom> existingSuperClsesToReplace = new HashSet<OWLObjectSomeValuesFrom>();
        for (OWLSubClassOfAxiom ax : ontology.getSubClassAxiomsForSubClass(cls)) {
            if (ax.getSuperClass() instanceof OWLObjectSomeValuesFrom) {
                OWLObjectSomeValuesFrom existing = (OWLObjectSomeValuesFrom) ax.getSuperClass();
                existingSuperClsesToReplace.add(existing);
            }
        }
        // What's changed?

        StringBuilder description = new StringBuilder();
        for (OWLObjectSomeValuesFrom toReplace : existingSuperClsesToReplace) {
            if (!superClsesToSet.contains(toReplace)) {
                // Was there but not any longer
                changes.add(new RemoveAxiom(ontology, dataFactory.getOWLSubClassOfAxiom(cls, toReplace)));
                description.append("Removed ");
                description.append(project.getRenderingManager().getBrowserText(toReplace.getProperty()));
                description.append(" relationship to ");
                description.append(project.getRenderingManager().getBrowserText(toReplace.getFiller()));
                description.append("    ");
            }
        }
        // What do we add?
        for (OWLObjectSomeValuesFrom toSet : superClsesToSet) {
            if (!existingSuperClsesToReplace.contains(toSet)) {
                // Not already there - we're adding it.
                changes.add(new AddAxiom(ontology, dataFactory.getOWLSubClassOfAxiom(cls, toSet)));
                description.append("Added ");
                description.append(project.getRenderingManager().getBrowserText(toSet.getProperty()));
                description.append(" relationship to ");
                description.append(project.getRenderingManager().getBrowserText(toSet.getFiller()));
                description.append("    ");
            }
        }


        if (!changes.isEmpty()) {
            UserId userId = getUserInSessionAndEnsureSignedIn();
            project.applyChanges(userId, changes, "Edited relationship values: " + description.toString());
        }

    }
View Full Code Here

        OWLClass owlCls = dataFactory.getOWLClass(filler.getIRI());
        return dataFactory.getOWLObjectSomeValuesFrom(owlObjectProperty, owlCls);
    }

    public OBOTermCrossProduct getCrossProduct(ProjectId projectId, OWLClass term) {
        OWLAPIProject project = getProject(projectId);
        OWLDataFactory df = project.getDataFactory();
        OWLClass cls = toOWLClass(df, term);
        OWLEquivalentClassesAxiom axiom = getCrossProductEquivalentClassesAxiom(project.getRootOntology(), cls);
        if (axiom == null) {
            return OBOTermCrossProduct.emptyOBOTermCrossProduct();
        }

        Set<OWLObjectSomeValuesFrom> relationships = new HashSet<OWLObjectSomeValuesFrom>();
View Full Code Here

    public void setCrossProduct(ProjectId projectId, OWLClass term, OBOTermCrossProduct crossProduct) throws NotSignedInException {
        if (crossProduct == null) {
            throw new RuntimeException("crossProduct must not be null");
        }

        OWLAPIProject project = getProject(projectId);
        OWLDataFactory df = project.getDataFactory();

        Set<OWLClassExpression> intersectionOperands = new HashSet<OWLClassExpression>();

        OWLClassData visualGenus = crossProduct.getGenus();
        if (visualGenus != null) {
            OWLClass cls = toOWLClass(df, visualGenus.getEntity());
            intersectionOperands.add(cls);
        }

        for (OBORelationship relationship : crossProduct.getRelationships().getRelationships()) {
            OWLObjectSomeValuesFrom someValuesFrom = toSomeValuesFrom(df, relationship);
            intersectionOperands.add(someValuesFrom);
        }
        OWLObjectIntersectionOf intersectionOf = df.getOWLObjectIntersectionOf(intersectionOperands);

        OWLClass owlClass = toOWLClass(df, term);
        OWLEquivalentClassesAxiom newXPAxiom = df.getOWLEquivalentClassesAxiom(owlClass, intersectionOf);

        OWLOntology rootOntology = project.getRootOntology();
        OWLEquivalentClassesAxiom existingXPAxiom = getCrossProductEquivalentClassesAxiom(rootOntology, owlClass);

        UserId userId = getUserInSessionAndEnsureSignedIn();
        List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
        changes.add(new AddAxiom(rootOntology, newXPAxiom));
        if (existingXPAxiom != null) {
            changes.add(new RemoveAxiom(rootOntology, existingXPAxiom));
        }
        project.applyChanges(userId, changes, "Set cross product values");

    }
View Full Code Here

        return UserHasProjectReadPermissionValidator.get();
    }

    @Override
    public GetObjectResult<LabelledFrame<NamedIndividualFrame>> execute(GetNamedIndividualFrameAction action, ExecutionContext executionContext) {
        OWLAPIProject project = OWLAPIProjectManager.getProjectManager().getProject(action.getProjectId());
        FrameActionResultTranslator<NamedIndividualFrame, OWLNamedIndividual> t = new FrameActionResultTranslator<NamedIndividualFrame, OWLNamedIndividual>(action.getSubject(), project, TRANSLATOR);
        return new GetObjectResult<LabelledFrame<NamedIndividualFrame>>(t.doIT());
    }
View Full Code Here

    protected abstract RequestValidator<A> getAdditionalRequestValidator(A action, RequestContext requestContext);

    @Override
    final public R execute(A action, ExecutionContext executionContext) {
        final OWLAPIProjectManager pm = OWLAPIProjectManager.getProjectManager();
        OWLAPIProject project = pm.getProject(action.getProjectId());
        return execute(action, project, executionContext);
    }
View Full Code Here

public class RenderingServiceImpl extends WebProtegeRemoteServiceServlet implements RenderingService  {

    @Override
    public GetRenderingResponse execute(GetRendering command) {
        ProjectId projectId = command.getProjectId();
        OWLAPIProject project = OWLAPIProjectManager.getProjectManager().getProject(projectId);
        RenderingManager rm = project.getRenderingManager();
        Map<OWLEntity, OWLEntityData> result = rm.getRendering(command.getEntities());
        return new GetRenderingResponse(result);
    }
View Full Code Here

TOP

Related Classes of edu.stanford.bmir.protege.web.server.owlapi.OWLAPIProject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.