Fixed another lazy init
parent
cb8a95f4f7
commit
5bda9ca1d3
|
|
@ -21,8 +21,10 @@ package com.arsdigita.cms.ui.type;
|
||||||
import com.ibm.icu.impl.IllegalIcuArgumentException;
|
import com.ibm.icu.impl.IllegalIcuArgumentException;
|
||||||
import org.libreccm.workflow.Workflow;
|
import org.libreccm.workflow.Workflow;
|
||||||
import org.librecms.contentsection.ContentSection;
|
import org.librecms.contentsection.ContentSection;
|
||||||
|
import org.librecms.contentsection.ContentSectionManager;
|
||||||
import org.librecms.contentsection.ContentSectionRepository;
|
import org.librecms.contentsection.ContentSectionRepository;
|
||||||
import org.librecms.contentsection.ContentType;
|
import org.librecms.contentsection.ContentType;
|
||||||
|
import org.librecms.contentsection.ContentTypeManager;
|
||||||
import org.librecms.contentsection.ContentTypeRepository;
|
import org.librecms.contentsection.ContentTypeRepository;
|
||||||
import org.librecms.contenttypes.ContentTypeInfo;
|
import org.librecms.contenttypes.ContentTypeInfo;
|
||||||
import org.librecms.contenttypes.ContentTypesManager;
|
import org.librecms.contenttypes.ContentTypesManager;
|
||||||
|
|
@ -40,11 +42,6 @@ import java.util.stream.Collectors;
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.TypedQuery;
|
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
|
||||||
import javax.persistence.criteria.JoinType;
|
|
||||||
import javax.persistence.criteria.Root;
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -64,9 +61,15 @@ class ContentTypeAdminPaneController {
|
||||||
@Inject
|
@Inject
|
||||||
private ContentSectionRepository sectionRepo;
|
private ContentSectionRepository sectionRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ContentSectionManager sectionManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ContentTypeRepository typeRepo;
|
private ContentTypeRepository typeRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ContentTypeManager typeManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ContentTypesManager typesManager;
|
private ContentTypesManager typesManager;
|
||||||
|
|
||||||
|
|
@ -216,4 +219,30 @@ class ContentTypeAdminPaneController {
|
||||||
return new ArrayList<>(contentSection.getWorkflowTemplates());
|
return new ArrayList<>(contentSection.getWorkflowTemplates());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
protected void addContentTypeToContentSection(
|
||||||
|
final String type, final ContentSection toSection
|
||||||
|
) {
|
||||||
|
Objects.requireNonNull(type);
|
||||||
|
Objects.requireNonNull(toSection);
|
||||||
|
|
||||||
|
final ContentSection section = sectionRepo
|
||||||
|
.findById(toSection.getObjectId())
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No ContentSection identified by ID %d found.",
|
||||||
|
toSection.getObjectId()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
sectionManager.addContentTypeToSection(
|
||||||
|
typeManager.classNameToClass(type),
|
||||||
|
section,
|
||||||
|
section.getLifecycleDefinitions().get(0),
|
||||||
|
section.getWorkflowTemplates().get(0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue