CCM NG/ccm-cms: More bugfixes

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4786 8810af33-2d31-482b-a856-94f89814c4df
jensp 2017-06-16 17:46:48 +00:00
parent 47c5e2c9d2
commit def2c4e659
5 changed files with 94 additions and 63 deletions

View File

@ -32,6 +32,7 @@ import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.contenttypes.AuthoringKitInfo; import org.librecms.contenttypes.AuthoringKitInfo;
import org.librecms.contenttypes.ContentTypeInfo; import org.librecms.contenttypes.ContentTypeInfo;
@ -109,18 +110,24 @@ public class WizardSelector extends AuthoringKitSelector
final ContentItem item = itemSelectionModel.getSelectedObject(state); final ContentItem item = itemSelectionModel.getSelectedObject(state);
final ContentType type = item.getContentType(); // final ContentType type = item.getContentType();
final String typeClass; // 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) { final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// Try to get the default content type final WizardSelectorController controller = cdiUtil
typeClass = getComponentSelectionModel().getSelectedKey(state); .findBean(WizardSelectorController.class);
if (typeClass == null || typeClass.isEmpty()) {
throw new UncheckedWrapperException("Content type is missing"); final String typeClass = controller.getTypeClass(item);
}
} else {
typeClass = type.getContentItemClass();
}
// Return the selected wizard // Return the selected wizard
return getComponent(typeClass); return getComponent(typeClass);

View File

@ -25,7 +25,6 @@ import org.librecms.contentsection.ContentItem;
import com.arsdigita.cms.ui.workflow.WorkflowRequestLocal; import com.arsdigita.cms.ui.workflow.WorkflowRequestLocal;
import org.libreccm.workflow.Workflow;
public class ItemWorkflowRequestLocal extends WorkflowRequestLocal { public class ItemWorkflowRequestLocal extends WorkflowRequestLocal {

View File

@ -20,7 +20,6 @@ import com.arsdigita.bebop.table.AbstractTableModelBuilder;
import com.arsdigita.bebop.table.RowData; import com.arsdigita.bebop.table.RowData;
import com.arsdigita.bebop.table.TableModel; import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
@ -33,36 +32,36 @@ import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import org.libreccm.workflow.WorkflowState; import org.libreccm.workflow.WorkflowState;
/**
*
*
*/
class AssignedTaskTableModelBuilder extends AbstractTableModelBuilder { class AssignedTaskTableModelBuilder extends AbstractTableModelBuilder {
private final WorkflowRequestLocal m_workflow; private final WorkflowRequestLocal workflowRequestLocal;
public AssignedTaskTableModelBuilder(final WorkflowRequestLocal workflow) { public AssignedTaskTableModelBuilder(
m_workflow = workflow; final WorkflowRequestLocal workflowRequestLocal) {
this.workflowRequestLocal = workflowRequestLocal;
} }
@Override @Override
public TableModel makeModel(final Table table, final PageState state) { 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 final Iterator<RowData<Long>> m_iter;
// private CmsTask m_task; // private CmsTask m_task;
private RowData<Long> rowData; private RowData<Long> rowData;
Model(final Workflow workflow) { AssignedTaskTableModel(final Workflow workflow) {
Assert.exists(workflow, Workflow.class); Assert.exists(workflow, Workflow.class);
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final WorkflowManager workflowManager = cdiUtil.findBean(WorkflowManager.class); 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( final AssignedTaskController controller = cdiUtil.findBean(
AssignedTaskController.class); AssignedTaskController.class);
m_iter = controller.getAssignedTasks(workflow).iterator(); m_iter = controller.getAssignedTasks(workflow).iterator();
@ -106,6 +105,7 @@ class AssignedTaskTableModelBuilder extends AbstractTableModelBuilder {
column)); column));
} }
} }
} }
protected final static GlobalizedMessage gz(final String key) { protected final static GlobalizedMessage gz(final String key) {
@ -115,4 +115,5 @@ class AssignedTaskTableModelBuilder extends AbstractTableModelBuilder {
protected final static String lz(final String key) { protected final static String lz(final String key) {
return (String) gz(key).localize(); return (String) gz(key).localize();
} }
} }

View File

@ -27,7 +27,14 @@ import java.util.Optional;
public abstract class WorkflowRequestLocal extends RequestLocal { public abstract class WorkflowRequestLocal extends RequestLocal {
@SuppressWarnings("unchecked")
public final Workflow getWorkflow(final PageState state) { 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;
}
} }
} }

View File

@ -106,6 +106,7 @@ public class WorkflowManager {
* *
* @param template The template which is used to create the new workflow. * @param template The template which is used to create the new workflow.
* @param object The object for which th workflow is generated. * @param object The object for which th workflow is generated.
*
* @return The new workflow. * @return The new workflow.
*/ */
@AuthorizationRequired @AuthorizationRequired
@ -151,6 +152,19 @@ public class WorkflowManager {
return workflow; 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 * Helper method for
* {@link #createWorkflow(org.libreccm.workflow.WorkflowTemplate, org.libreccm.core.CcmObject)} * {@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}. * Finds the enabled {@link Task}s of a {@link Workflow}.
* *
* @param workflow The workflow. * @param workflow The workflow.
*
* @return A unmodifiable list of the enabled tasks of the provided * @return A unmodifiable list of the enabled tasks of the provided
* {@code workflow}. * {@code workflow}.
*/ */
@ -273,6 +288,7 @@ public class WorkflowManager {
* Finds the finished {@link Task}s of a workflow. * Finds the finished {@link Task}s of a workflow.
* *
* @param workflow The workflow. * @param workflow The workflow.
*
* @return An unmodifiable list of the finished tasks of the provided * @return An unmodifiable list of the finished tasks of the provided
* {@code Workflow}. * {@code Workflow}.
*/ */
@ -291,6 +307,7 @@ public class WorkflowManager {
* Finds the {@link Task}s of a {@link Workflow} which are overdue. * Finds the {@link Task}s of a {@link Workflow} which are overdue.
* *
* @param workflow The workflow. * @param workflow The workflow.
*
* @return A unmodifiable list of the overdue tasks of the provided * @return A unmodifiable list of the overdue tasks of the provided
* {@code workflow}. * {@code workflow}.
*/ */