Java Code Examples for org.apache.jena.query.ReadWrite#WRITE

The following examples show how to use org.apache.jena.query.ReadWrite#WRITE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DatasetGraphChanges.java    From rdf-delta with Apache License 2.0 6 votes vote down vote up
@Override
public void begin() {
    if ( insideBegin.get() ) {
        super.begin();
        return;
    }
    insideBegin.set(true);
    try {
        // For the sync, we have to assume it will write.
        // Any potential write causes a write-sync to be done in "begin".
        txnSyncHandler.accept(ReadWrite.WRITE);
        super.begin();
        if ( transactionMode() == ReadWrite.WRITE )
            monitor.txnBegin();
    } finally {
        insideBegin.set(false);
    }
    internalBegin();
}
 
Example 2
Source File: DatasetGraphChanges.java    From rdf-delta with Apache License 2.0 6 votes vote down vote up
@Override
public void begin(TxnType txnType) {
    if ( insideBegin.get() ) {
        super.begin(txnType);
        return;
    }

    insideBegin.set(true);
    try {
        // For the sync, we have to assume it will write.
        ReadWrite readWrite = ( txnType == TxnType.READ) ? ReadWrite.READ : ReadWrite.WRITE;
        txnSyncHandler.accept(readWrite);
        super.begin(txnType);
        if ( transactionMode() == ReadWrite.WRITE )
            monitor.txnBegin();
    } finally {
        insideBegin.set(false);
    }
    internalBegin();
}
 
Example 3
Source File: DatasetGraphChanges.java    From rdf-delta with Apache License 2.0 6 votes vote down vote up
@Override
public void begin(ReadWrite readWrite) {
    if ( insideBegin.get() ) {
        super.begin(readWrite);
        return;
    }
    insideBegin.set(true);
    try {
        txnSyncHandler.accept(readWrite);
        super.begin(readWrite);
        if ( transactionMode() == ReadWrite.WRITE )
            monitor.txnBegin();
    } finally {
        insideBegin.set(false);
    }
    internalBegin();
}
 
Example 4
Source File: DatasetGraphChanges.java    From rdf-delta with Apache License 2.0 6 votes vote down vote up
@Override
    public boolean promote(Promote type) {
        // Any potential write causes a write-sync to be done in "begin".
        // Here we are inside the transaction so calling the sync handler is not possible (nested transaction risk).
        if ( super.transactionMode() == ReadWrite.READ ) {
            boolean b = super.promote(type);
            if ( super.transactionMode() == ReadWrite.WRITE ) {
                // Promotion happened.
                // READ_PROMOTE would not reveal any new triples.
                // READ_COMMITTED_PROMOTE : can't atomically do local and remote "begin(write)"
                // Nested transaction. See above.
//                if ( transactionType() == TxnType.READ_COMMITTED_PROMOTE )
//                    txnSyncHandler.accept(ReadWrite.WRITE);
                // We have gone ReadWrite.READ -> ReadWrite.WRITE
                monitor.txnBegin();
            }
            return b;
        }
        //Already WRITE.
        return super.promote(type);
    }
 
Example 5
Source File: DatasetGraphChanges.java    From rdf-delta with Apache License 2.0 5 votes vote down vote up
private void requireWriteTxn() {
    ReadWrite mode = transactionMode();
    if ( mode == ReadWrite.WRITE )
        return;
    boolean b = promote() ;
    if ( !b )
        throw new JenaTransactionException("Can't write") ;
}
 
Example 6
Source File: DatasetGraphChanges.java    From rdf-delta with Apache License 2.0 4 votes vote down vote up
private boolean isWriteMode() {
    return super.transactionMode() == ReadWrite.WRITE;
}