Skip to content

Commit

Permalink
Fetch project id from ClientState
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrinberg committed Jul 24, 2017
1 parent 1dd3441 commit 727e0b0
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.common.base.Optional;
import com.google.inject.Provider;
import org.mindswap.pellet.PelletOptions;
import org.protege.editor.core.ProtegeManager;
import org.protege.editor.core.editorkit.EditorKit;
import org.protege.editor.owl.OWLEditorKit;
import org.protege.editor.owl.client.ClientSession;
import org.protege.editor.owl.model.inference.AbstractProtegeOWLReasonerInfo;
import org.semanticweb.owlapi.reasoner.BufferingMode;
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory;

import java.util.List;


/**
*
Expand Down Expand Up @@ -45,8 +52,19 @@ public OWLReasonerFactory getReasonerFactory() {
break;
case REMOTE: {
final String serverURL = PelletReasonerPreferences.getInstance().getServerURL();
// TODO: read timeout from preferences too and pass to ClientModule, 3 min by default
final Injector aInjector = Guice.createInjector(new ClientModule(serverURL, Optional.<String>absent(), null));
final Injector aInjector = Guice.createInjector(new ClientModule(serverURL, Optional.<String>absent(),
new Provider<String>() {
@Override
public String get() {
final List<EditorKit> editorKits = ProtegeManager.getInstance().getEditorKitManager().getEditorKits();
if (editorKits.size() > 0) {
// cast is safe b/c there's only one implementaiton of EditorKit
return ClientSession.getInstance((OWLEditorKit) editorKits.get(0)).getActiveProject().get();
} else {
throw new RuntimeException("Project id not available becasuse there are no editor kits");
}
}
}));
factory = new RemotePelletReasonerFactory(aInjector.getInstance(SchemaReasonerFactory.class), getOWLModelManager());
break;
}
Expand Down

0 comments on commit 727e0b0

Please sign in to comment.