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:
@@ -23,8 +23,6 @@ import org.alfresco.repo.forms.Field;
|
||||
import org.alfresco.repo.forms.FormException;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import com.sun.star.lang.IllegalArgumentException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 3.4
|
||||
@@ -53,7 +51,7 @@ public abstract class AbstractFieldProcessor<Data> implements FieldProcessor
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@@ -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 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.TransitionFieldProcessor;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
@@ -51,25 +52,24 @@ public class MockFieldProcessorRegistry extends ContentModelFieldProcessorRegist
|
||||
register(SizeFieldProcessor.KEY, makeSizeFieldProcessor());
|
||||
register(TransitionFieldProcessor.KEY, makeTransitionFieldProcessor());
|
||||
register(PackageItemsFieldProcessor.KEY, makePackageItemFieldProcessor());
|
||||
register(MessageFieldProcessor.KEY, makeMessageFieldProcessor());
|
||||
setDefaultProcessor(makeDefaultFieldProcessor(namespaceService, dictionaryService));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private FieldProcessor makePackageItemFieldProcessor()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return new PackageItemsFieldProcessor();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private FieldProcessor makeTransitionFieldProcessor()
|
||||
{
|
||||
return new TransitionFieldProcessor();
|
||||
}
|
||||
|
||||
private FieldProcessor makeMessageFieldProcessor()
|
||||
{
|
||||
return new MessageFieldProcessor();
|
||||
}
|
||||
|
||||
private FieldProcessor makeDefaultFieldProcessor(NamespaceService namespaceService,
|
||||
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.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* FormProcessor implementation for workflow tasks.
|
||||
@@ -154,6 +155,7 @@ public class TaskFormProcessor extends AbstractWorkflowFormProcessor<WorkflowTas
|
||||
Map<String, Object> values = new HashMap<String, Object>(2);
|
||||
values.put(TransitionFieldProcessor.KEY, getTransitionValues(item));
|
||||
values.put(PackageItemsFieldProcessor.KEY, getPackageItemValues(item));
|
||||
values.put(MessageFieldProcessor.KEY, getMessageValues(item));
|
||||
return values;
|
||||
}
|
||||
|
||||
@@ -183,6 +185,23 @@ public class TaskFormProcessor extends AbstractWorkflowFormProcessor<WorkflowTas
|
||||
|
||||
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)
|
||||
{
|
||||
|
@@ -266,6 +266,26 @@ public class TaskFormProcessorTest extends TestCase
|
||||
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
|
||||
{
|
||||
@@ -490,14 +510,12 @@ public class TaskFormProcessorTest extends TestCase
|
||||
{
|
||||
String expDataKey = makeDataKeyName(fieldName);
|
||||
checkSingleField(form, fieldName, fieldData, expDataKey);
|
||||
|
||||
}
|
||||
|
||||
private void checkSingleAssociation(Form form, String fieldName, Serializable fieldData)
|
||||
{
|
||||
String expDataKey = makeAssociationDataKey(fieldName);
|
||||
checkSingleField(form, fieldName, fieldData, 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();
|
||||
assertEquals(expDataKey, 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)
|
||||
@@ -575,6 +600,7 @@ public class TaskFormProcessorTest extends TestCase
|
||||
WorkflowTask result = new WorkflowTask();
|
||||
result.id = TASK_ID;
|
||||
result.state = WorkflowTaskState.IN_PROGRESS;
|
||||
result.title = "Test";
|
||||
result.definition = makeTaskDefinition();
|
||||
result.properties = makeTaskProperties();
|
||||
|
||||
|
Reference in New Issue
Block a user