Search in sources :

Example 11 with OWLEntityData

use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.

the class PrimitiveDataParserImpl_LiteralParsing_TestCase method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() {
    primitiveTypes = Sets.newHashSet();
    primitiveTypes.add(PrimitiveType.LITERAL);
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            AsyncCallback<Optional<OWLEntityData>> callback = (AsyncCallback<Optional<OWLEntityData>>) invocationOnMock.getArguments()[2];
            callback.onSuccess(Optional.empty());
            return null;
        }
    }).when(lookupHandler).lookupEntity(any(String.class), any(Set.class), any(AsyncCallback.class));
    parser = new PrimitiveDataParserImpl(lookupHandler);
}
Also used : Set(java.util.Set) Optional(java.util.Optional) PrimitiveDataParserImpl(edu.stanford.bmir.protege.web.client.primitive.PrimitiveDataParserImpl) InvocationOnMock(org.mockito.invocation.InvocationOnMock) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) Before(org.junit.Before)

Example 12 with OWLEntityData

use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.

the class CommentPostedEventView method setValue.

public void setValue(CommentPostedEvent event) {
    Comment comment = event.getComment();
    UserId createdBy = comment.getCreatedBy();
    userNameLabel.setText(createdBy.getUserName());
    userIconHolder.setWidget(UserIcon.get(createdBy));
    final java.util.Optional<OWLEntityData> targetAsEntityData = event.getEntity();
    if (targetAsEntityData.isPresent()) {
        entityLabel.setEntity(targetAsEntityData.get());
        entityLabel.setVisible(true);
    } else {
        entityLabel.setVisible(false);
    }
    timeLabel.setBaseTime(comment.getCreatedAt());
    final SafeHtmlBuilder builder = new SafeHtmlBuilder();
    bodyLabel.setHTML(builder.appendHtmlConstant(comment.getRenderedBody()).toSafeHtml());
}
Also used : Comment(edu.stanford.bmir.protege.web.shared.issues.Comment) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 13 with OWLEntityData

use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.

the class AugmentedFreshEntitiesSuggestStrategy method getSuggestion.

private Optional<FreshEntitySuggestion> getSuggestion(String query, EntityType<?> type, Optional<OWLEntityData> auxiliaryType) {
    // TODO: If query starts with a lowercase letter, suggest individual first?
    OWLEntity entity = DataFactory.getFreshOWLEntity(type, query);
    OWLEntityData entityData = DataFactory.getOWLEntityData(entity, query);
    if (auxiliaryType.isPresent()) {
        AuxiliaryTypeHandler auxiliaryTypeHandler = AuxiliaryTypeHandler.get(auxiliaryType.get());
        if (auxiliaryTypeHandler.isApplicableTo(type)) {
            Set<OWLAxiom> augmentingAxioms = auxiliaryTypeHandler.getAdditionalAxioms(entity);
            return Optional.of(new FreshEntitySuggestion(entityData, auxiliaryTypeHandler.getSuggestionText(entityData), augmentingAxioms));
        }
    }
    return Optional.empty();
}
Also used : OWLEntity(org.semanticweb.owlapi.model.OWLEntity) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) OWLAxiom(org.semanticweb.owlapi.model.OWLAxiom)

Example 14 with OWLEntityData

use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.

the class AugmentedFreshEntitiesSuggestStrategy method getSuggestions.

@Override
public List<EntitySuggestion> getSuggestions(String query, List<EntityType<?>> suggestedTypes) {
    List<EntitySuggestion> result = Lists.newArrayList();
    for (EntityType<?> type : suggestedTypes) {
        for (Optional<OWLEntityData> auxiliaryType : auxiliaryTypes) {
            Optional<FreshEntitySuggestion> suggestion = getSuggestion(query, type, auxiliaryType);
            if (suggestion.isPresent()) {
                result.add(suggestion.get());
            }
        }
        OWLEntity entity = DataFactory.getFreshOWLEntity(type, query);
        OWLEntityData entityData = DataFactory.getOWLEntityData(entity, query);
        result.add(new EntitySuggestion(entityData, formatSuggestText(query, type)));
    }
    return result;
}
Also used : EntitySuggestion(edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)

Example 15 with OWLEntityData

use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.

the class SimpleFreshEntitySuggestStrategy method getSuggestions.

@Override
public List<EntitySuggestion> getSuggestions(String query, List<EntityType<?>> suggestedTypes) {
    List<EntitySuggestion> suggestions = Lists.newArrayList();
    for (EntityType<?> allowedType : suggestedTypes) {
        OWLEntity entity = DataFactory.getFreshOWLEntity(allowedType, query);
        OWLEntityData entityData = DataFactory.getOWLEntityData(entity, query);
        suggestions.add(new EntitySuggestion(entityData, formatSuggestText(query, allowedType)));
    }
    return suggestions;
}
Also used : EntitySuggestion(edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)

Aggregations

OWLEntityData (edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)18 Nonnull (javax.annotation.Nonnull)5 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)5 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)3 EntitySuggestion (edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion)2 AnnotationPropertyFrame (edu.stanford.bmir.protege.web.shared.frame.AnnotationPropertyFrame)2 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)2 Tag (edu.stanford.bmir.protege.web.shared.tag.Tag)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Inject (javax.inject.Inject)2 IRI (org.semanticweb.owlapi.model.IRI)2 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 EntityLabel (edu.stanford.bmir.protege.web.client.library.entitylabel.EntityLabel)1 PrimitiveDataParserImpl (edu.stanford.bmir.protege.web.client.primitive.PrimitiveDataParserImpl)1 AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)1 ProjectResource.forProject (edu.stanford.bmir.protege.web.server.access.ProjectResource.forProject)1 Subject.forUser (edu.stanford.bmir.protege.web.server.access.Subject.forUser)1 ApplicationNameSupplier (edu.stanford.bmir.protege.web.server.app.ApplicationNameSupplier)1