Removed lazy init exception
parent
bdde67db3f
commit
b13e3b787d
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package com.arsdigita.cms.ui.type;
|
||||
|
||||
import com.ibm.icu.impl.IllegalIcuArgumentException;
|
||||
import org.libreccm.workflow.Workflow;
|
||||
import org.librecms.contentsection.ContentSection;
|
||||
import org.librecms.contentsection.ContentSectionRepository;
|
||||
|
|
@ -78,6 +79,27 @@ class ContentTypeAdminPaneController {
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
protected List<String> getContentItemClassesList(
|
||||
final ContentSection ofSection
|
||||
) {
|
||||
final ContentSection section = sectionRepo.findById(
|
||||
ofSection.getObjectId()
|
||||
)
|
||||
.orElseThrow(
|
||||
() -> new IllegalIcuArgumentException(
|
||||
String.format(
|
||||
"No ContentSection with ID %d found.",
|
||||
ofSection.getObjectId()
|
||||
)
|
||||
)
|
||||
);
|
||||
return section.getContentTypes()
|
||||
.stream()
|
||||
.map(type -> type.getContentItemClass())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private String[] generateListEntry(final ContentType type) {
|
||||
final String[] entry = new String[2];
|
||||
|
||||
|
|
@ -126,7 +148,8 @@ class ContentTypeAdminPaneController {
|
|||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
protected Optional<String> getLifecycleDefinitionLabel(final ContentType type,
|
||||
protected Optional<String> getLifecycleDefinitionLabel(
|
||||
final ContentType type,
|
||||
final Locale locale) {
|
||||
|
||||
final LifecycleDefinition lifecycleDefinition = getLifecycleDefinition(
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ public class SelectType extends CMSForm implements PrintListener,
|
|||
/**
|
||||
* Generate a checkbox list of all content type not associated with the
|
||||
* current content section
|
||||
* @param event
|
||||
*/
|
||||
@Override
|
||||
public void prepare(final PrintEvent event) {
|
||||
|
|
@ -111,15 +112,19 @@ public class SelectType extends CMSForm implements PrintListener,
|
|||
final ContentSection section = CMS.getContext().getContentSection();
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final ContentTypeAdminPaneController controller = cdiUtil
|
||||
.findBean(ContentTypeAdminPaneController.class);
|
||||
final ContentTypesManager typesManager = cdiUtil.findBean(
|
||||
ContentTypesManager.class);
|
||||
|
||||
final List<ContentTypeInfo> availableTypes = typesManager
|
||||
.getAvailableContentTypes();
|
||||
final List<String> assignedTypes = section.getContentTypes()
|
||||
.stream()
|
||||
.map(contentType -> contentType.getContentItemClass())
|
||||
.collect(Collectors.toList());
|
||||
final List<String> assignedTypes = controller
|
||||
.getContentItemClassesList(section);
|
||||
// = section.getContentTypes()
|
||||
// .stream()
|
||||
// .map(contentType -> contentType.getContentItemClass())
|
||||
// .collect(Collectors.toList());
|
||||
|
||||
final List<ContentTypeInfo> notAssignedTypes = availableTypes.stream()
|
||||
.filter(type -> assignedTypes.contains(type.getContentItemClass()
|
||||
|
|
|
|||
Loading…
Reference in New Issue