AbstractForwardChainingInferencer.java
/*******************************************************************************
* Copyright (c) 2015 Eclipse RDF4J contributors, Aduna, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
package org.eclipse.rdf4j.sail.inferencer.fc;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.rdf4j.common.transaction.IsolationLevel;
import org.eclipse.rdf4j.common.transaction.IsolationLevels;
import org.eclipse.rdf4j.sail.NotifyingSail;
import org.eclipse.rdf4j.sail.helpers.NotifyingSailWrapper;
public abstract class AbstractForwardChainingInferencer extends NotifyingSailWrapper {
private static final IsolationLevels READ_COMMITTED = IsolationLevels.READ_COMMITTED;
/*--------------*
* Constructors *
*--------------*/
public AbstractForwardChainingInferencer() {
super();
}
public AbstractForwardChainingInferencer(NotifyingSail baseSail) {
super(baseSail);
}
/*---------*
* Methods *
*---------*/
@Override
public IsolationLevel getDefaultIsolationLevel() {
IsolationLevel level = super.getDefaultIsolationLevel();
if (level.isCompatibleWith(READ_COMMITTED)) {
return level;
} else {
List<IsolationLevel> supported = this.getSupportedIsolationLevels();
return IsolationLevels.getCompatibleIsolationLevel(READ_COMMITTED, supported);
}
}
@Override
public List<IsolationLevel> getSupportedIsolationLevels() {
List<IsolationLevel> supported = super.getSupportedIsolationLevels();
List<IsolationLevel> levels = new ArrayList<>(supported.size());
for (IsolationLevel level : supported) {
if (level.isCompatibleWith(READ_COMMITTED)) {
levels.add(level);
}
}
return levels;
}
}