parent
5957d5b9f4
commit
9a653f50d6
|
|
@ -142,10 +142,9 @@ public class CategoryTreeModelLite implements TreeModel {
|
||||||
return category.getName();
|
return category.getName();
|
||||||
} else {
|
} else {
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
final GlobalizationHelper globalizationHelper = cdiUtil
|
final CategoryTreeModelLiteController controller = cdiUtil
|
||||||
.findBean(GlobalizationHelper.class);
|
.findBean(CategoryTreeModelLiteController.class);
|
||||||
return globalizationHelper
|
return controller.getTitle(category);
|
||||||
.getValueFromLocalizedString(category.getTitle());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,11 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.categorization;
|
package org.libreccm.categorization;
|
||||||
|
|
||||||
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
@ -38,6 +41,9 @@ class CategoryTreeModelLiteController {
|
||||||
@Inject
|
@Inject
|
||||||
private CategoryRepository categoryRepo;
|
private CategoryRepository categoryRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
protected boolean hasSubCategories(final long categoryId) {
|
protected boolean hasSubCategories(final long categoryId) {
|
||||||
|
|
||||||
|
|
@ -50,7 +56,7 @@ class CategoryTreeModelLiteController {
|
||||||
return categoryManager.hasSubCategories(category);
|
return categoryManager.hasSubCategories(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
protected List<Category> findSubCategories(final long categoryId) {
|
protected List<Category> findSubCategories(final long categoryId) {
|
||||||
|
|
||||||
final Category category = categoryRepo
|
final Category category = categoryRepo
|
||||||
|
|
@ -62,4 +68,23 @@ class CategoryTreeModelLiteController {
|
||||||
return new ArrayList<>(category.getSubCategories());
|
return new ArrayList<>(category.getSubCategories());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
protected String getTitle(final Category ofCategory) {
|
||||||
|
Objects.requireNonNull(ofCategory);
|
||||||
|
|
||||||
|
final Category category = categoryRepo
|
||||||
|
.findById(ofCategory.getObjectId())
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Category with ID %d available.",
|
||||||
|
ofCategory.getObjectId()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return globalizationHelper.getValueFromLocalizedString(
|
||||||
|
category.getTitle()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue