Search in sources :

Example 1 with OWLDataFactoryImpl

use of uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl in project webprotege by protegeproject.

the class ImportsCacheManager method parseOntologyDocument.

private void parseOntologyDocument(File ontologyDocument) {
    try {
        WRITE_LOCK.lock();
        try (InputStream is = new BufferedInputStream(new FileInputStream(ontologyDocument))) {
            BinaryOWLOntologyDocumentSerializer serializer = new BinaryOWLOntologyDocumentSerializer();
            final Handler handler = new Handler();
            serializer.read(is, handler, new OWLDataFactoryImpl());
            OWLOntologyID id = handler.getOntologyID();
            if (id.getOntologyIRI().isPresent()) {
                ontologyIDs.add(id);
                iri2Document.put(id.getOntologyIRI().get(), IRI.create(ontologyDocument.toURI()));
                if (id.getVersionIRI().isPresent()) {
                    iri2Document.put(id.getVersionIRI().get(), IRI.create(ontologyDocument));
                }
                metadataMap.put(id, new ImportedOntologyMetadata(id, handler.getDocumentIRI(), handler.getTimestamp()));
            }
        } catch (IOException | BinaryOWLParseException | UnloadableImportException e) {
            logger.error("An error occurred", e);
        }
    } finally {
        WRITE_LOCK.unlock();
    }
}
Also used : BinaryOWLParseException(org.semanticweb.binaryowl.BinaryOWLParseException) ImportedOntologyMetadata(edu.stanford.bmir.protege.web.shared.project.ImportedOntologyMetadata) BinaryOWLOntologyDocumentSerializer(org.semanticweb.binaryowl.BinaryOWLOntologyDocumentSerializer) OWLDataFactoryImpl(uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl)

Example 2 with OWLDataFactoryImpl

use of uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl in project webprotege by protegeproject.

the class HeadRevisionNumberFinder method getHeadRevisionNumber.

/**
 * Computes the head revision number for the specified project.
 *
 * @param projectId The project.
 * @return The {@link RevisionNumber}
 */
@Nonnull
public RevisionNumber getHeadRevisionNumber(@Nonnull ProjectId projectId) throws IOException {
    /*
            This method works fairly well, even for large
            projects, but it is only intended to be a stopgap and needs replacing.
         */
    File projectDir = projectDirectoryFactory.getProjectDirectory(projectId);
    ChangeHistoryFileProvider changeHistoryFileProvider = new ChangeHistoryFileProvider(projectDir);
    File changeHistoryFile = changeHistoryFileProvider.get();
    try (BufferedInputStream bufferedInputStream = new BufferedInputStream(Files.newInputStream(changeHistoryFile.toPath()))) {
        BinaryOWLOntologyChangeLog log = new BinaryOWLOntologyChangeLog();
        RevisionExtractor extractor = new RevisionExtractor();
        log.readChanges(bufferedInputStream, new OWLDataFactoryImpl(), extractor, SKIP_DATA);
        return RevisionNumber.getRevisionNumber(extractor.getLastRevision());
    }
}
Also used : ChangeHistoryFileProvider(edu.stanford.bmir.protege.web.server.inject.project.ChangeHistoryFileProvider) BufferedInputStream(java.io.BufferedInputStream) BinaryOWLOntologyChangeLog(org.semanticweb.binaryowl.BinaryOWLOntologyChangeLog) File(java.io.File) OWLDataFactoryImpl(uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl) Nonnull(javax.annotation.Nonnull)

Example 3 with OWLDataFactoryImpl

use of uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl in project webprotege by protegeproject.

the class RebuildPermissions method run.

public void run() {
    System.out.println("Rebuilding permissions...");
    MongoClient mongoClient = new MongoClient();
    MorphiaProvider morphiaProvider = new MorphiaProvider(new UserIdConverter(), new OWLEntityConverter(new OWLDataFactoryImpl()), new ProjectIdConverter(), new ThreadIdConverter(), new CommentIdConverter(), new CollectionIdConverter(), new FormIdConverter(), new TagIdConverter(), new ColorConverter());
    Morphia morphia = morphiaProvider.get();
    Datastore datastore = morphia.createDatastore(mongoClient, "webprotege");
    AccessManager accessManager = new AccessManagerImpl(RoleOracleImpl.get(), datastore);
    accessManager.rebuild();
    mongoClient.close();
    System.out.println("Finished rebuilding permissions");
}
Also used : AccessManager(edu.stanford.bmir.protege.web.server.access.AccessManager) AccessManagerImpl(edu.stanford.bmir.protege.web.server.access.AccessManagerImpl) Morphia(org.mongodb.morphia.Morphia) FormIdConverter(edu.stanford.bmir.protege.web.server.form.FormIdConverter) OWLDataFactoryImpl(uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl) TagIdConverter(edu.stanford.bmir.protege.web.server.tag.TagIdConverter) CollectionIdConverter(edu.stanford.bmir.protege.web.server.collection.CollectionIdConverter) MongoClient(com.mongodb.MongoClient) Datastore(org.mongodb.morphia.Datastore) ColorConverter(edu.stanford.bmir.protege.web.server.color.ColorConverter)

Example 4 with OWLDataFactoryImpl

use of uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl in project webprotege by protegeproject.

the class MorphiaProvider method get.

@Override
public Morphia get() {
    Morphia morphia = new Morphia();
    Mapper mapper = morphia.getMapper();
    mapper.getOptions().setStoreEmpties(true);
    mapper.getOptions().setObjectFactory(new CustomMorphiaObjectFactory());
    Converters converters = mapper.getConverters();
    converters.addConverter(userIdConverter);
    converters.addConverter(entityConverter);
    converters.addConverter(projectIdConverter);
    converters.addConverter(threadIdConverter);
    converters.addConverter(commentIdConverter);
    FormDataValueConverter formDataValueConverter = new FormDataValueConverter(new OWLDataFactoryImpl(), entityConverter);
    converters.addConverter(formDataValueConverter);
    converters.addConverter(new FormDataConverter(formDataValueConverter));
    converters.addConverter(collectionIdConverter);
    converters.addConverter(formIdConverter);
    converters.addConverter(tagIdConverter);
    converters.addConverter(colorConverter);
    converters.addConverter(new CollectionIdConverter());
    converters.addConverter(new CollectionItemConverter());
    morphia.map(EntityDiscussionThread.class);
    morphia.map(UserActivityRecord.class);
    morphia.map(RoleAssignment.class);
    return morphia;
}
Also used : CollectionIdConverter(edu.stanford.bmir.protege.web.server.collection.CollectionIdConverter) Mapper(org.mongodb.morphia.mapping.Mapper) FormDataConverter(edu.stanford.bmir.protege.web.server.form.FormDataConverter) Morphia(org.mongodb.morphia.Morphia) FormDataValueConverter(edu.stanford.bmir.protege.web.server.form.FormDataValueConverter) CollectionItemConverter(edu.stanford.bmir.protege.web.server.collection.CollectionItemConverter) Converters(org.mongodb.morphia.converters.Converters) OWLDataFactoryImpl(uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl)

Example 5 with OWLDataFactoryImpl

use of uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl in project webprotege by protegeproject.

the class UUIDEntityCrudKitHandlerTestCase method setUp.

@Before
public void setUp() throws Exception {
    OWLDataFactoryImpl dataFactory = new OWLDataFactoryImpl();
    when(prefixSettings.getIRIPrefix()).thenReturn(PREFIX);
    when(crudContext.getDataFactory()).thenReturn(dataFactory);
    when(crudContext.getTargetOntology()).thenReturn(ontology);
    when(crudContext.getPrefixedNameExpander()).thenReturn(PrefixedNameExpander.builder().withNamespaces(Namespaces.values()).build());
    when(crudContext.getTargetLanguage()).thenReturn(Optional.empty());
    when(ontology.containsEntityInSignature(any(OWLEntity.class))).thenReturn(true);
    handler = new UUIDEntityCrudKitHandler(prefixSettings, suffixSettings);
}
Also used : OWLDataFactoryImpl(uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl) Before(org.junit.Before)

Aggregations

OWLDataFactoryImpl (uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl)7 CollectionIdConverter (edu.stanford.bmir.protege.web.server.collection.CollectionIdConverter)2 Before (org.junit.Before)2 Morphia (org.mongodb.morphia.Morphia)2 MatchResult (com.google.gwt.regexp.shared.MatchResult)1 MongoClient (com.mongodb.MongoClient)1 AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)1 AccessManagerImpl (edu.stanford.bmir.protege.web.server.access.AccessManagerImpl)1 CollectionItemConverter (edu.stanford.bmir.protege.web.server.collection.CollectionItemConverter)1 ColorConverter (edu.stanford.bmir.protege.web.server.color.ColorConverter)1 FormDataConverter (edu.stanford.bmir.protege.web.server.form.FormDataConverter)1 FormDataValueConverter (edu.stanford.bmir.protege.web.server.form.FormDataValueConverter)1 FormIdConverter (edu.stanford.bmir.protege.web.server.form.FormIdConverter)1 ChangeHistoryFileProvider (edu.stanford.bmir.protege.web.server.inject.project.ChangeHistoryFileProvider)1 TagIdConverter (edu.stanford.bmir.protege.web.server.tag.TagIdConverter)1 PerspectiveId (edu.stanford.bmir.protege.web.shared.perspective.PerspectiveId)1 ImportedOntologyMetadata (edu.stanford.bmir.protege.web.shared.project.ImportedOntologyMetadata)1 BufferedInputStream (java.io.BufferedInputStream)1 File (java.io.File)1 Nonnull (javax.annotation.Nonnull)1