CCM NG/ccm-core: Improved JavaDoc for some methods of the CategoryManager..
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4571 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
e74c25aede
commit
b0a73283fa
|
|
@ -44,6 +44,7 @@
|
||||||
<artifactId>hibernate-entitymanager</artifactId>
|
<artifactId>hibernate-entitymanager</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-jpamodelgen</artifactId>
|
<artifactId>hibernate-jpamodelgen</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -158,8 +158,19 @@ public class CategoryManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if an object is assigned to a category.
|
||||||
|
*
|
||||||
|
* @param category The category
|
||||||
|
* @param object The object
|
||||||
|
* @return {@code true} if the provided {@code object} is assigned to the
|
||||||
|
* provided {@code category}, {@code false} otherwise.
|
||||||
|
*/
|
||||||
public boolean isAssignedToCategory(final Category category,
|
public boolean isAssignedToCategory(final Category category,
|
||||||
final CcmObject object) {
|
final CcmObject object) {
|
||||||
|
Objects.requireNonNull(category);
|
||||||
|
Objects.requireNonNull(object);
|
||||||
|
|
||||||
final TypedQuery<Boolean> query = entityManager.createNamedQuery(
|
final TypedQuery<Boolean> query = entityManager.createNamedQuery(
|
||||||
"Categorization.isAssignedTo", Boolean.class);
|
"Categorization.isAssignedTo", Boolean.class);
|
||||||
query.setParameter("category", category);
|
query.setParameter("category", category);
|
||||||
|
|
@ -168,9 +179,25 @@ public class CategoryManager {
|
||||||
return query.getSingleResult();
|
return query.getSingleResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if an object is assigned to a category with a specific type. If you
|
||||||
|
* only want to check if an object is assigned to a category regardless of
|
||||||
|
* the type use
|
||||||
|
* {@link #isAssignedToCategory(org.libreccm.categorization.Category, org.libreccm.core.CcmObject)}.
|
||||||
|
*
|
||||||
|
* @param category The category
|
||||||
|
* @param object The object
|
||||||
|
* @param type The type with which the object has been assigned to the
|
||||||
|
* category. the type may be {@code null}.
|
||||||
|
* @return {@code true} if the provided {@code object} is assigned to the
|
||||||
|
* provided {@code category} using the provided {@code type}.
|
||||||
|
*/
|
||||||
public boolean isAssignedToCategoryWithType(final Category category,
|
public boolean isAssignedToCategoryWithType(final Category category,
|
||||||
final CcmObject object,
|
final CcmObject object,
|
||||||
final String type) {
|
final String type) {
|
||||||
|
Objects.requireNonNull(category);
|
||||||
|
Objects.requireNonNull(object);
|
||||||
|
|
||||||
final TypedQuery<Boolean> query = entityManager.createNamedQuery(
|
final TypedQuery<Boolean> query = entityManager.createNamedQuery(
|
||||||
"Categorization.isAssignedTo", Boolean.class);
|
"Categorization.isAssignedTo", Boolean.class);
|
||||||
query.setParameter("category", category);
|
query.setParameter("category", category);
|
||||||
|
|
@ -726,10 +753,24 @@ public class CategoryManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the index object of a category. There can only be one index object
|
||||||
|
* per category. Therefore this method first sets
|
||||||
|
* {@link Categorization#index} to false for all categorisations of the
|
||||||
|
* provided category. Then it retrieves the {@link Categorization} for the
|
||||||
|
* provided {@link CcmObject} and sets {@link Categorization#index} to
|
||||||
|
* {@code true} for this categorisation.
|
||||||
|
*
|
||||||
|
* @param category The category whose index object is set or changed.
|
||||||
|
* @param object The new index object for the category. The object must be
|
||||||
|
* assigned to the category.
|
||||||
|
* @throws ObjectNotAssignedToCategoryException If the provided
|
||||||
|
* {@code object} is not assigned to the provided {@code category}.
|
||||||
|
*/
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void setIndexObject(final Category category,
|
public void setIndexObject(final Category category,
|
||||||
final CcmObject object)
|
final CcmObject object)
|
||||||
throws ObjectNotAssignedToCategoryException{
|
throws ObjectNotAssignedToCategoryException {
|
||||||
|
|
||||||
Objects.requireNonNull(category);
|
Objects.requireNonNull(category);
|
||||||
Objects.requireNonNull(object);
|
Objects.requireNonNull(object);
|
||||||
|
|
@ -759,7 +800,7 @@ public class CategoryManager {
|
||||||
final Categorization categorization;
|
final Categorization categorization;
|
||||||
try {
|
try {
|
||||||
categorization = query.getSingleResult();
|
categorization = query.getSingleResult();
|
||||||
} catch(NoResultException ex) {
|
} catch (NoResultException ex) {
|
||||||
throw new ObjectNotAssignedToCategoryException(String.format(
|
throw new ObjectNotAssignedToCategoryException(String.format(
|
||||||
"Strange. The previous check if the provided object %s is "
|
"Strange. The previous check if the provided object %s is "
|
||||||
+ "assigned to the provided category %s returned "
|
+ "assigned to the provided category %s returned "
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue