/** * Explicitly removes the concept from the entity. */ public void removeDesignation(Object entity, Class<?> concept) throws RepositoryException { Resource resource = findResource(entity); URI type = of.getNameOf(concept); if (type == null) { throw new ObjectPersistException( "Concept is anonymous or is not registered: " + concept.getSimpleName()); } types.removeTypeStatement(resource, type); cachedObjects.remove(resource); }
/** * Explicitly removes the concept from the entity. */ public void removeDesignation(Object entity, Class<?> concept) throws RepositoryException { Resource resource = findResource(entity); URI type = of.getNameOf(concept); if (type == null) { throw new ObjectPersistException( "Concept is anonymous or is not registered: " + concept.getSimpleName()); } types.removeTypeStatement(resource, type); }
/** * Explicitly adds the concept to the entity. * * @return the entity with new composed concept */ public <T> T addDesignation(Object entity, Class<T> concept) throws RepositoryException { if (entity instanceof RDFObjectBehaviour) { RDFObjectBehaviour support = (RDFObjectBehaviour) entity; Object delegate = support.getBehaviourDelegate(); if (delegate != entity) { return addDesignation(delegate, concept); } } Resource resource = findResource(entity); Set<URI> types = new HashSet<URI>(4); getTypes(entity.getClass(), types); addConcept(resource, concept, types); Object bean = of.createObject(resource, types); assert assertConceptRecorded(bean, concept); return (T) bean; }
@SuppressWarnings("unchecked") public <T> T refresh(T object) throws RepositoryException { Resource resource = findResource(object); if (object instanceof Refreshable) { ((Refreshable) object).refresh(); } Set<URI> types = this.types.getTypes(resource); Class<?> proxy = of.getObjectClass(resource, types); RDFObject cached = cached(resource); if (cached != null && cached != object && cached instanceof Refreshable) { ((Refreshable) cached).refresh(); } if (cached != null && cached.getClass().equals(proxy)) return (T) cached; return (T) cache(of.createBean(resource, proxy)); }
/** * Explicitly adds the concept to the entity. * * @return the entity with new composed concept */ public <T> T addDesignation(Object entity, Class<T> concept) throws RepositoryException { if (entity instanceof RDFObjectBehaviour) { RDFObjectBehaviour support = (RDFObjectBehaviour) entity; Object delegate = support.getBehaviourDelegate(); if (delegate != entity) { return addDesignation(delegate, concept); } } Resource resource = findResource(entity); Set<URI> types = new HashSet<URI>(4); getTypes(entity.getClass(), types); addConcept(resource, concept, types); RDFObject bean = of.createObject(resource, types); assert assertConceptRecorded(bean, concept); return (T) cache(bean); }
/** * 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); } } }
Resource resource = findResource(entity); Set<URI> list = new HashSet<URI>(4); getTypes(entity.getClass(), list);
Resource resource = findResource(entity); Set<URI> list = new HashSet<URI>(4); getTypes(entity.getClass(), list);
/** * 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); } } }