CCM NG/ccm-cms: More bugfixes
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4786 8810af33-2d31-482b-a856-94f89814c4df
parent
47c5e2c9d2
commit
def2c4e659
|
|
@ -32,6 +32,7 @@ import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
|||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.librecms.contenttypes.AuthoringKitInfo;
|
||||
import org.librecms.contenttypes.ContentTypeInfo;
|
||||
|
||||
|
|
@ -109,18 +110,24 @@ public class WizardSelector extends AuthoringKitSelector
|
|||
|
||||
final ContentItem item = itemSelectionModel.getSelectedObject(state);
|
||||
|
||||
final ContentType type = item.getContentType();
|
||||
final String typeClass;
|
||||
// final ContentType type = item.getContentType();
|
||||
// final String typeClass;
|
||||
//
|
||||
// if (type == null) {
|
||||
// // Try to get the default content type
|
||||
// typeClass = getComponentSelectionModel().getSelectedKey(state);
|
||||
// if (typeClass == null || typeClass.isEmpty()) {
|
||||
// throw new UncheckedWrapperException("Content type is missing");
|
||||
// }
|
||||
// } else {
|
||||
// typeClass = type.getContentItemClass();
|
||||
// }
|
||||
|
||||
if (type == null) {
|
||||
// Try to get the default content type
|
||||
typeClass = getComponentSelectionModel().getSelectedKey(state);
|
||||
if (typeClass == null || typeClass.isEmpty()) {
|
||||
throw new UncheckedWrapperException("Content type is missing");
|
||||
}
|
||||
} else {
|
||||
typeClass = type.getContentItemClass();
|
||||
}
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final WizardSelectorController controller = cdiUtil
|
||||
.findBean(WizardSelectorController.class);
|
||||
|
||||
final String typeClass = controller.getTypeClass(item);
|
||||
|
||||
// Return the selected wizard
|
||||
return getComponent(typeClass);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import org.librecms.contentsection.ContentItem;
|
|||
|
||||
import com.arsdigita.cms.ui.workflow.WorkflowRequestLocal;
|
||||
|
||||
import org.libreccm.workflow.Workflow;
|
||||
|
||||
public class ItemWorkflowRequestLocal extends WorkflowRequestLocal {
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import com.arsdigita.bebop.table.AbstractTableModelBuilder;
|
|||
import com.arsdigita.bebop.table.RowData;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
|
||||
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.util.Assert;
|
||||
|
||||
|
|
@ -33,36 +32,36 @@ import java.util.Collections;
|
|||
import java.util.Iterator;
|
||||
import org.libreccm.workflow.WorkflowState;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class AssignedTaskTableModelBuilder extends AbstractTableModelBuilder {
|
||||
|
||||
private final WorkflowRequestLocal m_workflow;
|
||||
private final WorkflowRequestLocal workflowRequestLocal;
|
||||
|
||||
public AssignedTaskTableModelBuilder(final WorkflowRequestLocal workflow) {
|
||||
m_workflow = workflow;
|
||||
public AssignedTaskTableModelBuilder(
|
||||
final WorkflowRequestLocal workflowRequestLocal) {
|
||||
this.workflowRequestLocal = workflowRequestLocal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table, final PageState state) {
|
||||
return new Model(m_workflow.getWorkflow(state));
|
||||
return new AssignedTaskTableModel(workflowRequestLocal.getWorkflow(state));
|
||||
}
|
||||
|
||||
private static class Model implements TableModel {
|
||||
private static class AssignedTaskTableModel implements TableModel {
|
||||
|
||||
private final Iterator<RowData<Long>> m_iter;
|
||||
// private CmsTask m_task;
|
||||
private RowData<Long> rowData;
|
||||
|
||||
Model(final Workflow workflow) {
|
||||
AssignedTaskTableModel(final Workflow workflow) {
|
||||
Assert.exists(workflow, Workflow.class);
|
||||
|
||||
final CdiUtil cdiUtil= CdiUtil.createCdiUtil();
|
||||
final WorkflowManager workflowManager = cdiUtil.findBean(WorkflowManager.class);
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final WorkflowManager workflowManager = cdiUtil.findBean(
|
||||
WorkflowManager.class);
|
||||
final WorkflowState workflowState = workflowManager
|
||||
.getWorkflowState(workflow);
|
||||
|
||||
if (workflow.getState() == WorkflowState.STARTED) {
|
||||
if (workflowState == WorkflowState.STARTED) {
|
||||
final AssignedTaskController controller = cdiUtil.findBean(
|
||||
AssignedTaskController.class);
|
||||
m_iter = controller.getAssignedTasks(workflow).iterator();
|
||||
|
|
@ -106,6 +105,7 @@ class AssignedTaskTableModelBuilder extends AbstractTableModelBuilder {
|
|||
column));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected final static GlobalizedMessage gz(final String key) {
|
||||
|
|
@ -115,4 +115,5 @@ class AssignedTaskTableModelBuilder extends AbstractTableModelBuilder {
|
|||
protected final static String lz(final String key) {
|
||||
return (String) gz(key).localize();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,14 @@ import java.util.Optional;
|
|||
|
||||
public abstract class WorkflowRequestLocal extends RequestLocal {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final Workflow getWorkflow(final PageState state) {
|
||||
return ((Optional<Workflow>) get(state)).get();
|
||||
final Object object = get(state);
|
||||
|
||||
if (object instanceof Optional) {
|
||||
return ((Optional<Workflow>) object).get();
|
||||
} else {
|
||||
return (Workflow) object;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ public class WorkflowManager {
|
|||
*
|
||||
* @param template The template which is used to create the new workflow.
|
||||
* @param object The object for which th workflow is generated.
|
||||
*
|
||||
* @return The new workflow.
|
||||
*/
|
||||
@AuthorizationRequired
|
||||
|
|
@ -151,6 +152,19 @@ public class WorkflowManager {
|
|||
return workflow;
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public WorkflowState getWorkflowState(final Workflow workflow) {
|
||||
|
||||
// Get a non detached entity
|
||||
final Workflow theWorkflow = workflowRepo
|
||||
.findById(workflow.getWorkflowId())
|
||||
.orElseThrow(() -> new IllegalArgumentException(String
|
||||
.format("No Workflow with ID in the database.",
|
||||
workflow.getWorkflowId())));
|
||||
|
||||
return theWorkflow.getState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for
|
||||
* {@link #createWorkflow(org.libreccm.workflow.WorkflowTemplate, org.libreccm.core.CcmObject)}
|
||||
|
|
@ -247,6 +261,7 @@ public class WorkflowManager {
|
|||
* Finds the enabled {@link Task}s of a {@link Workflow}.
|
||||
*
|
||||
* @param workflow The workflow.
|
||||
*
|
||||
* @return A unmodifiable list of the enabled tasks of the provided
|
||||
* {@code workflow}.
|
||||
*/
|
||||
|
|
@ -273,6 +288,7 @@ public class WorkflowManager {
|
|||
* Finds the finished {@link Task}s of a workflow.
|
||||
*
|
||||
* @param workflow The workflow.
|
||||
*
|
||||
* @return An unmodifiable list of the finished tasks of the provided
|
||||
* {@code Workflow}.
|
||||
*/
|
||||
|
|
@ -291,6 +307,7 @@ public class WorkflowManager {
|
|||
* Finds the {@link Task}s of a {@link Workflow} which are overdue.
|
||||
*
|
||||
* @param workflow The workflow.
|
||||
*
|
||||
* @return A unmodifiable list of the overdue tasks of the provided
|
||||
* {@code workflow}.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue