mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fixed ALF-4644: Message field in task details page shows the default description and not (No Message) like the rest of the UI
Added a transient "message" property to the TaskFormProcessor, this returns the default (No Message) value if the user did not enter a description when starting the workflow. Changed all task forms to use the new "message" property instead of bpm:description. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22384 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -187,4 +187,8 @@
|
|||||||
class="org.alfresco.repo.forms.processor.workflow.TransitionFieldProcessor"
|
class="org.alfresco.repo.forms.processor.workflow.TransitionFieldProcessor"
|
||||||
parent="baseFieldProcessor" />
|
parent="baseFieldProcessor" />
|
||||||
|
|
||||||
|
<bean id="messageFieldProcessor"
|
||||||
|
class="org.alfresco.repo.forms.processor.workflow.MessageFieldProcessor"
|
||||||
|
parent="baseFieldProcessor" />
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
@@ -7,5 +7,13 @@ form_service.encoding.description=Encoding of the content
|
|||||||
form_service.size.label=Size
|
form_service.size.label=Size
|
||||||
form_service.size.description=Size of the content in bytes
|
form_service.size.description=Size of the content in bytes
|
||||||
|
|
||||||
|
form_service.message.label=Message
|
||||||
|
form_service.message.description=Message the user entered when starting the workflow
|
||||||
|
form_service.message.value.none=(No Message)
|
||||||
|
|
||||||
|
form_service.transitions.label=Transitions
|
||||||
|
form_service.transitions.description=The transitions available for the task
|
||||||
|
|
||||||
form_service.package.items.label=Items
|
form_service.package.items.label=Items
|
||||||
form_service.package.items.description=Items that are part of the workflow
|
form_service.package.items.description=Items that are part of the workflow
|
||||||
|
|
||||||
|
@@ -23,8 +23,6 @@ import org.alfresco.repo.forms.Field;
|
|||||||
import org.alfresco.repo.forms.FormException;
|
import org.alfresco.repo.forms.FormException;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import com.sun.star.lang.IllegalArgumentException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @since 3.4
|
* @since 3.4
|
||||||
@@ -53,7 +51,7 @@ public abstract class AbstractFieldProcessor<Data> implements FieldProcessor
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String msg = "Data object: "+itemData+" is not of expected type: "+expectedType;
|
String msg = "Data object: " + itemData + " is not of expected type: " + expectedType;
|
||||||
throw new FormException(msg, new IllegalArgumentException());
|
throw new FormException(msg, new IllegalArgumentException());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,6 +29,7 @@ import static org.alfresco.repo.forms.processor.node.FormFieldConstants.ASSOC;
|
|||||||
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.PROP;
|
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.PROP;
|
||||||
|
|
||||||
import org.alfresco.repo.forms.processor.FieldProcessor;
|
import org.alfresco.repo.forms.processor.FieldProcessor;
|
||||||
|
import org.alfresco.repo.forms.processor.workflow.MessageFieldProcessor;
|
||||||
import org.alfresco.repo.forms.processor.workflow.PackageItemsFieldProcessor;
|
import org.alfresco.repo.forms.processor.workflow.PackageItemsFieldProcessor;
|
||||||
import org.alfresco.repo.forms.processor.workflow.TransitionFieldProcessor;
|
import org.alfresco.repo.forms.processor.workflow.TransitionFieldProcessor;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
@@ -51,26 +52,25 @@ public class MockFieldProcessorRegistry extends ContentModelFieldProcessorRegist
|
|||||||
register(SizeFieldProcessor.KEY, makeSizeFieldProcessor());
|
register(SizeFieldProcessor.KEY, makeSizeFieldProcessor());
|
||||||
register(TransitionFieldProcessor.KEY, makeTransitionFieldProcessor());
|
register(TransitionFieldProcessor.KEY, makeTransitionFieldProcessor());
|
||||||
register(PackageItemsFieldProcessor.KEY, makePackageItemFieldProcessor());
|
register(PackageItemsFieldProcessor.KEY, makePackageItemFieldProcessor());
|
||||||
|
register(MessageFieldProcessor.KEY, makeMessageFieldProcessor());
|
||||||
setDefaultProcessor(makeDefaultFieldProcessor(namespaceService, dictionaryService));
|
setDefaultProcessor(makeDefaultFieldProcessor(namespaceService, dictionaryService));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private FieldProcessor makePackageItemFieldProcessor()
|
private FieldProcessor makePackageItemFieldProcessor()
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return new PackageItemsFieldProcessor();
|
return new PackageItemsFieldProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private FieldProcessor makeTransitionFieldProcessor()
|
private FieldProcessor makeTransitionFieldProcessor()
|
||||||
{
|
{
|
||||||
return new TransitionFieldProcessor();
|
return new TransitionFieldProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private FieldProcessor makeMessageFieldProcessor()
|
||||||
|
{
|
||||||
|
return new MessageFieldProcessor();
|
||||||
|
}
|
||||||
|
|
||||||
private FieldProcessor makeDefaultFieldProcessor(NamespaceService namespaceService,
|
private FieldProcessor makeDefaultFieldProcessor(NamespaceService namespaceService,
|
||||||
DictionaryService dictionaryService)
|
DictionaryService dictionaryService)
|
||||||
{
|
{
|
||||||
|
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.repo.forms.processor.workflow;
|
||||||
|
|
||||||
|
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.PROP_DATA_PREFIX;
|
||||||
|
|
||||||
|
import org.alfresco.repo.forms.FieldDefinition;
|
||||||
|
import org.alfresco.repo.forms.PropertyFieldDefinition;
|
||||||
|
import org.alfresco.repo.forms.processor.node.TransientFieldProcessor;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transient field processor for the "message" property.
|
||||||
|
*
|
||||||
|
* @since 3.4
|
||||||
|
* @author Gavin Cornwell
|
||||||
|
*/
|
||||||
|
public class MessageFieldProcessor extends TransientFieldProcessor
|
||||||
|
{
|
||||||
|
public static final String KEY = "message";
|
||||||
|
public static final String DATA_TYPE = DataTypeDefinition.TEXT.getLocalName();
|
||||||
|
public static final String MSG_VALUE_NONE = "form_service.message.value.none";
|
||||||
|
|
||||||
|
private static final String MSG_LABEL = "form_service.message.label";
|
||||||
|
private static final String MSG_DESCRIPTION = "form_service.message.description";
|
||||||
|
|
||||||
|
private static final Log LOGGER = LogFactory.getLog(MessageFieldProcessor.class);
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.forms.processor.node.TransientFieldProcessor#makeTransientPropertyDefinition()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected FieldDefinition makeTransientFieldDefinition()
|
||||||
|
{
|
||||||
|
PropertyFieldDefinition fieldDef = new PropertyFieldDefinition(KEY, DATA_TYPE);
|
||||||
|
fieldDef.setRepeating(false);
|
||||||
|
fieldDef.setProtectedField(true);
|
||||||
|
|
||||||
|
fieldDef.setLabel(I18NUtil.getMessage(MSG_LABEL));
|
||||||
|
fieldDef.setDescription(I18NUtil.getMessage(MSG_DESCRIPTION));
|
||||||
|
fieldDef.setDataKeyName(PROP_DATA_PREFIX + KEY);
|
||||||
|
return fieldDef;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.forms.processor.AbstractFieldProcessor#getLogger()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Log getLogger()
|
||||||
|
{
|
||||||
|
return LOGGER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.forms.processor.AbstractFieldProcessor#getRegistryKey()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected String getRegistryKey()
|
||||||
|
{
|
||||||
|
return KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -47,6 +47,7 @@ import org.alfresco.service.namespace.NamespaceService;
|
|||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FormProcessor implementation for workflow tasks.
|
* FormProcessor implementation for workflow tasks.
|
||||||
@@ -154,6 +155,7 @@ public class TaskFormProcessor extends AbstractWorkflowFormProcessor<WorkflowTas
|
|||||||
Map<String, Object> values = new HashMap<String, Object>(2);
|
Map<String, Object> values = new HashMap<String, Object>(2);
|
||||||
values.put(TransitionFieldProcessor.KEY, getTransitionValues(item));
|
values.put(TransitionFieldProcessor.KEY, getTransitionValues(item));
|
||||||
values.put(PackageItemsFieldProcessor.KEY, getPackageItemValues(item));
|
values.put(PackageItemsFieldProcessor.KEY, getPackageItemValues(item));
|
||||||
|
values.put(MessageFieldProcessor.KEY, getMessageValues(item));
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,6 +186,23 @@ public class TaskFormProcessor extends AbstractWorkflowFormProcessor<WorkflowTas
|
|||||||
return buildTransitionString(item, transitions);
|
return buildTransitionString(item, transitions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getMessageValues(WorkflowTask task)
|
||||||
|
{
|
||||||
|
String message = I18NUtil.getMessage(MessageFieldProcessor.MSG_VALUE_NONE);
|
||||||
|
|
||||||
|
String description = (String)task.getProperties().get(WorkflowModel.PROP_DESCRIPTION);
|
||||||
|
if (description != null)
|
||||||
|
{
|
||||||
|
String taskTitle = task.getTitle();
|
||||||
|
if (taskTitle == null || !taskTitle.equals(description))
|
||||||
|
{
|
||||||
|
message = description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
private String buildTransitionString(WorkflowTask item, WorkflowTransition[] transitions)
|
private String buildTransitionString(WorkflowTask item, WorkflowTransition[] transitions)
|
||||||
{
|
{
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
@@ -266,6 +266,26 @@ public class TaskFormProcessorTest extends TestCase
|
|||||||
checkSingleProperty(form, fieldName, transitionValues);
|
checkSingleProperty(form, fieldName, transitionValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGenerateMessage() throws Exception
|
||||||
|
{
|
||||||
|
String message = null;
|
||||||
|
String fieldName = MessageFieldProcessor.KEY;
|
||||||
|
Form form = processForm(fieldName);
|
||||||
|
checkSingleProperty(form, fieldName, message);
|
||||||
|
|
||||||
|
// add a description to the task and check it comes back
|
||||||
|
message = "This is some text the user may have entered";
|
||||||
|
this.task.properties.put(PROP_DESCRIPTION, message);
|
||||||
|
|
||||||
|
form = processForm(fieldName);
|
||||||
|
checkSingleProperty(form, fieldName, message);
|
||||||
|
|
||||||
|
// set the description to the same as the task title
|
||||||
|
// and make sure the message comes back as null
|
||||||
|
this.task.properties.put(PROP_DESCRIPTION, this.task.title);
|
||||||
|
form = processForm(fieldName);
|
||||||
|
checkSingleProperty(form, fieldName, null);
|
||||||
|
}
|
||||||
|
|
||||||
public void testGeneratePackageItems() throws Exception
|
public void testGeneratePackageItems() throws Exception
|
||||||
{
|
{
|
||||||
@@ -490,14 +510,12 @@ public class TaskFormProcessorTest extends TestCase
|
|||||||
{
|
{
|
||||||
String expDataKey = makeDataKeyName(fieldName);
|
String expDataKey = makeDataKeyName(fieldName);
|
||||||
checkSingleField(form, fieldName, fieldData, expDataKey);
|
checkSingleField(form, fieldName, fieldData, expDataKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkSingleAssociation(Form form, String fieldName, Serializable fieldData)
|
private void checkSingleAssociation(Form form, String fieldName, Serializable fieldData)
|
||||||
{
|
{
|
||||||
String expDataKey = makeAssociationDataKey(fieldName);
|
String expDataKey = makeAssociationDataKey(fieldName);
|
||||||
checkSingleField(form, fieldName, fieldData, expDataKey);
|
checkSingleField(form, fieldName, fieldData, expDataKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkSingleField(Form form, String fieldName, Serializable fieldData, String expDataKey)
|
private void checkSingleField(Form form, String fieldName, Serializable fieldData, String expDataKey)
|
||||||
@@ -509,7 +527,14 @@ public class TaskFormProcessorTest extends TestCase
|
|||||||
String dataKey = fieldDef.getDataKeyName();
|
String dataKey = fieldDef.getDataKeyName();
|
||||||
assertEquals(expDataKey, dataKey);
|
assertEquals(expDataKey, dataKey);
|
||||||
FieldData data = form.getFormData().getFieldData(dataKey);
|
FieldData data = form.getFormData().getFieldData(dataKey);
|
||||||
assertEquals(fieldData, data.getValue());
|
if (fieldData != null)
|
||||||
|
{
|
||||||
|
assertEquals(fieldData, data.getValue());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
assertNull(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String makeDataKeyName(String fieldName)
|
private String makeDataKeyName(String fieldName)
|
||||||
@@ -575,6 +600,7 @@ public class TaskFormProcessorTest extends TestCase
|
|||||||
WorkflowTask result = new WorkflowTask();
|
WorkflowTask result = new WorkflowTask();
|
||||||
result.id = TASK_ID;
|
result.id = TASK_ID;
|
||||||
result.state = WorkflowTaskState.IN_PROGRESS;
|
result.state = WorkflowTaskState.IN_PROGRESS;
|
||||||
|
result.title = "Test";
|
||||||
result.definition = makeTaskDefinition();
|
result.definition = makeTaskDefinition();
|
||||||
result.properties = makeTaskProperties();
|
result.properties = makeTaskProperties();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user