/** * Explicitly removes the types from the entity. */ public void removeDesignations(Object entity, URI... types) throws RepositoryException { assert types != null && types.length > 0; boolean autoCommit = isAutoCommit(); if (autoCommit) { setAutoCommit(false); } try { Resource resource = findResource(entity); for (URI type : types) { this.types.removeTypeStatement(resource, type); } if (autoCommit) { setAutoCommit(true); } cachedObjects.remove(resource); } finally { if (autoCommit && !isAutoCommit()) { rollback(); setAutoCommit(true); } } }
/** * Explicitly removes the types from the entity. */ public void removeDesignations(Object entity, URI... types) throws RepositoryException { assert types != null && types.length > 0; boolean autoCommit = isAutoCommit(); if (autoCommit) { setAutoCommit(false); } try { Resource resource = findResource(entity); for (URI type : types) { this.types.removeTypeStatement(resource, type); } if (autoCommit) { setAutoCommit(true); } } finally { if (autoCommit && !isAutoCommit()) { rollback(); setAutoCommit(true); } } }
@Override public Object set(int index, Object obj) { ObjectConnection conn = getObjectConnection(); try { boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); try { Object old = getAndSet(index, obj); if (autoCommit) conn.setAutoCommit(true); return old; } finally { if (autoCommit && !conn.isAutoCommit()) { conn.rollback(); conn.setAutoCommit(true); } } } catch (RepositoryException e) { throw new ObjectPersistException(e); } }
@Override public Object set(int index, Object obj) { ObjectConnection conn = getObjectConnection(); try { boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); try { Object old = getAndSet(index, obj); if (autoCommit) conn.setAutoCommit(true); return old; } finally { if (autoCommit && !conn.isAutoCommit()) { conn.rollback(); conn.setAutoCommit(true); } } } catch (RepositoryException e) { throw new ObjectPersistException(e); } }
setAutoCommit(false); setAutoCommit(true); if (autoCommit && !isAutoCommit()) { rollback(); setAutoCommit(true);
public void setAll(Set<?> set) { if (this == set) return; if (set == null) { clear(); return; } Set<Object> c = new HashSet<Object>(set); ObjectConnection conn = getObjectConnection(); try { boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); try { clear(); addAll(c); if (autoCommit) conn.setAutoCommit(true); } finally { if (autoCommit && !conn.isAutoCommit()) { conn.rollback(); conn.setAutoCommit(true); } } } catch (RepositoryException e) { throw new ObjectPersistException(e); } }
public void setAll(Set<?> set) { if (this == set) return; if (set == null) { clear(); return; } Set<Object> c = new HashSet<Object>(set); ObjectConnection conn = getObjectConnection(); try { boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); try { clear(); addAll(c); if (autoCommit) conn.setAutoCommit(true); } finally { if (autoCommit && !conn.isAutoCommit()) { conn.rollback(); conn.setAutoCommit(true); } } } catch (RepositoryException e) { throw new ObjectPersistException(e); } }
public boolean removeAll(Collection<?> c) { ObjectConnection conn = getObjectConnection(); boolean modified = false; try { boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); try { for (Object o : c) if (remove(o)) modified = true; if (autoCommit) conn.setAutoCommit(true); } finally { if (autoCommit && !conn.isAutoCommit()) { conn.rollback(); conn.setAutoCommit(true); } } } catch (RepositoryException e) { throw new ObjectPersistException(e); } refresh(); refreshEntity(); return modified; }
public boolean addAll(Collection<?> c) { ObjectConnection conn = getObjectConnection(); boolean modified = false; try { boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); try { for (Object o : c) if (add(o)) modified = true; if (autoCommit) conn.setAutoCommit(true); } finally { if (autoCommit && !conn.isAutoCommit()) { conn.rollback(); conn.setAutoCommit(true); } } } catch (RepositoryException e) { throw new ObjectPersistException(e); } refresh(); refreshEntity(); return modified; }
public boolean removeAll(Collection<?> c) { ObjectConnection conn = getObjectConnection(); boolean modified = false; try { boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); try { for (Object o : c) if (remove(o)) modified = true; if (autoCommit) conn.setAutoCommit(true); } finally { if (autoCommit && !conn.isAutoCommit()) { conn.rollback(); conn.setAutoCommit(true); } } } catch (RepositoryException e) { throw new ObjectPersistException(e); } refresh(); refreshEntity(); return modified; }
public void setSingle(Object o) { if (o == null) { clear(); } else { ObjectConnection conn = getObjectConnection(); try { boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); try { clear(); add(o); if (autoCommit) conn.setAutoCommit(true); } finally { if (autoCommit && !conn.isAutoCommit()) { conn.rollback(); conn.setAutoCommit(true); } } } catch (RepositoryException e) { throw new ObjectPersistException(e); } } }
public void setSingle(Object o) { if (o == null) { clear(); } else { ObjectConnection conn = getObjectConnection(); try { boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); try { clear(); add(o); if (autoCommit) conn.setAutoCommit(true); } finally { if (autoCommit && !conn.isAutoCommit()) { conn.rollback(); conn.setAutoCommit(true); } } } catch (RepositoryException e) { throw new ObjectPersistException(e); } } }
public boolean addAll(Collection<?> c) { ObjectConnection conn = getObjectConnection(); boolean modified = false; try { boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); try { for (Object o : c) if (add(o)) modified = true; if (autoCommit) conn.setAutoCommit(true); } finally { if (autoCommit && !conn.isAutoCommit()) { conn.rollback(); conn.setAutoCommit(true); } } } catch (RepositoryException e) { throw new ObjectPersistException(e); } refresh(); refreshEntity(); return modified; }
@Override public void add(int index, Object obj) { ObjectConnection conn = getObjectConnection(); try { boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); try { for (int i = size() - 1; i >= index; i--) { replace(i + 1, get(i)); } replace(index, obj); if (_size > UNKNOWN) _size++; if (autoCommit) conn.setAutoCommit(true); } finally { if (autoCommit && !conn.isAutoCommit()) { conn.rollback(); conn.setAutoCommit(true); } } } catch (RepositoryException e) { throw new ObjectPersistException(e); } }
@Override public void add(int index, Object obj) { ObjectConnection conn = getObjectConnection(); try { boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); try { for (int i = size() - 1; i >= index; i--) { replace(i + 1, get(i)); } replace(index, obj); if (_size > UNKNOWN) _size++; if (autoCommit) conn.setAutoCommit(true); } finally { if (autoCommit && !conn.isAutoCommit()) { conn.rollback(); conn.setAutoCommit(true); } } } catch (RepositoryException e) { throw new ObjectPersistException(e); } }
private void replace(int index, Object o) throws RepositoryException { if (o == null) throw new NullPointerException(); URI pred = getMemberPredicate(index); ObjectConnection conn = getObjectConnection(); Value newValue = getObjectConnection().addObject(o); boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); try { conn.remove(getResource(), pred, null); conn.add(getResource(), pred, newValue); if (autoCommit) conn.setAutoCommit(true); } finally { if (autoCommit && !conn.isAutoCommit()) { conn.rollback(); conn.setAutoCommit(true); } } Object[] block = getBlock(index / BSIZE); if (block != null) { block[index % BSIZE] = o; } }
private void replace(int index, Object o) throws RepositoryException { if (o == null) throw new NullPointerException(); URI pred = getMemberPredicate(index); ObjectConnection conn = getObjectConnection(); Value newValue = getObjectConnection().addObject(o); boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); try { conn.remove(getResource(), pred, null); conn.add(getResource(), pred, newValue); if (autoCommit) conn.setAutoCommit(true); } finally { if (autoCommit && !conn.isAutoCommit()) { conn.rollback(); conn.setAutoCommit(true); } } Object[] block = getBlock(index / BSIZE); if (block != null) { block[index % BSIZE] = o; } }
public boolean retainAll(Collection<?> c) { ObjectConnection conn = getObjectConnection(); boolean modified = false; try { boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); ObjectIterator<?, Object> e = getObjectIterator(); try { while (e.hasNext()) { if (!c.contains(e.next())) { e.remove(); modified = true; } } } finally { e.close(); } if (autoCommit) conn.setAutoCommit(true); } catch (RepositoryException e) { throw new ObjectPersistException(e); } refresh(); refreshEntity(); return modified; }
public boolean retainAll(Collection<?> c) { ObjectConnection conn = getObjectConnection(); boolean modified = false; try { boolean autoCommit = conn.isAutoCommit(); if (autoCommit) conn.setAutoCommit(false); ObjectIterator<?, Object> e = getObjectIterator(); try { while (e.hasNext()) { if (!c.contains(e.next())) { e.remove(); modified = true; } } } finally { e.close(); } if (autoCommit) conn.setAutoCommit(true); } catch (RepositoryException e) { throw new ObjectPersistException(e); } refresh(); refreshEntity(); return modified; }
@Override public Object remove(int index) { ObjectConnection conn = getObjectConnection(); try { boolean autoCommit = conn.isAutoCommit(); if (autoCommit) { conn.setAutoCommit(false); } Object obj = get(index); int size = size(); for (int i = index; i < size - 1; i++) { replace(i, get(i + 1)); } URI pred = getMemberPredicate(size - 1); conn.remove(getResource(), pred, null); Object[] block = getBlock((size - 1) / BSIZE); if (block != null) { block[(size - 1) % BSIZE] = null; } if (_size > UNKNOWN) _size--; if (autoCommit) { conn.setAutoCommit(true); } return obj; } catch (RepositoryException e) { throw new ObjectPersistException(e); } }