mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Refactored the persistence for WorkflowFormProcessor and TaskFormProcessor.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21315 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -490,7 +490,6 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
|
|
||||||
Date modifiedDate = (Date)data.getFieldData(modifiedField.getDataKeyName()).getValue();
|
Date modifiedDate = (Date)data.getFieldData(modifiedField.getDataKeyName()).getValue();
|
||||||
assertNotNull("Expecting to find modified date", modifiedDate);
|
assertNotNull("Expecting to find modified date", modifiedDate);
|
||||||
assertTrue("Expecting modified field to return a Date", (modifiedDate instanceof Date));
|
|
||||||
|
|
||||||
Calendar calTestValue = Calendar.getInstance();
|
Calendar calTestValue = Calendar.getInstance();
|
||||||
calTestValue.setTime(VALUE_SENT_DATE);
|
calTestValue.setTime(VALUE_SENT_DATE);
|
||||||
|
@@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* 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 java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.repo.forms.Form;
|
||||||
|
import org.alfresco.repo.forms.FormData;
|
||||||
|
import org.alfresco.repo.forms.FormData.FieldData;
|
||||||
|
import org.alfresco.repo.forms.processor.FormCreationData;
|
||||||
|
import org.alfresco.repo.forms.processor.node.ContentModelFormProcessor;
|
||||||
|
import org.alfresco.repo.forms.processor.node.ItemData;
|
||||||
|
import org.alfresco.repo.workflow.WorkflowModel;
|
||||||
|
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Nick Smith
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class AbstractWorkflowFormProcessor<ItemType, PersistType> extends ContentModelFormProcessor<ItemType, PersistType>
|
||||||
|
{
|
||||||
|
/** WorkflowService */
|
||||||
|
protected WorkflowService workflowService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void populateForm(Form form, List<String> fields, FormCreationData data)
|
||||||
|
{
|
||||||
|
super.populateForm(form, fields, data);
|
||||||
|
|
||||||
|
// Add package actions to FormData.
|
||||||
|
ItemData<?> itemData = (ItemData<?>) data.getItemData();
|
||||||
|
addPropertyDataIfRequired(WorkflowModel.PROP_PACKAGE_ACTION_GROUP, form, itemData);
|
||||||
|
addPropertyDataIfRequired(WorkflowModel.PROP_PACKAGE_ITEM_ACTION_GROUP, form, itemData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.forms.processor.FilteredFormProcessor#internalPersist(java.lang.Object, org.alfresco.repo.forms.FormData)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected PersistType internalPersist(ItemType item, FormData data)
|
||||||
|
{
|
||||||
|
ContentModelFormPersister<PersistType> persister = makeFormPersister(item);
|
||||||
|
for (FieldData fieldData : data)
|
||||||
|
{
|
||||||
|
persister.addField(fieldData);
|
||||||
|
}
|
||||||
|
return persister.persist();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param workflowService the workflowService to set
|
||||||
|
*/
|
||||||
|
public void setWorkflowService(WorkflowService workflowService)
|
||||||
|
{
|
||||||
|
this.workflowService = workflowService;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract ContentModelFormPersister<PersistType> makeFormPersister(ItemType item);
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,194 @@
|
|||||||
|
/*
|
||||||
|
* 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 java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.repo.forms.FormData.FieldData;
|
||||||
|
import org.alfresco.repo.forms.processor.node.ItemData;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Nick Smith
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class ContentModelFormPersister<T> implements FormPersister<T>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Default Logger.
|
||||||
|
*/
|
||||||
|
private static final Log LOGGER= LogFactory.getLog(ContentModelFormPersister.class);
|
||||||
|
|
||||||
|
protected final static TypedPropertyValueGetter valueGetter = new TypedPropertyValueGetter();
|
||||||
|
protected final DataKeyMatcher keyMatcher;
|
||||||
|
protected final DictionaryService dictionaryService;
|
||||||
|
protected final Log logger;
|
||||||
|
protected final ItemData<?> itemData;
|
||||||
|
|
||||||
|
public ContentModelFormPersister(ItemData<?> itemData, NamespaceService namespaceService, DictionaryService dictionaryService, Log logger)
|
||||||
|
{
|
||||||
|
this.dictionaryService= dictionaryService;
|
||||||
|
this.logger = logger==null ? LOGGER : logger;
|
||||||
|
this.keyMatcher = new DataKeyMatcher(namespaceService);
|
||||||
|
this.itemData = itemData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.forms.processor.workflow.FormPersister#addField(java.lang.String, java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void addField(FieldData fieldData)
|
||||||
|
{
|
||||||
|
String dataKeyName = fieldData.getName();
|
||||||
|
DataKeyInfo keyInfo = keyMatcher.match(dataKeyName);
|
||||||
|
if (keyInfo == null)
|
||||||
|
{
|
||||||
|
logIgnore(fieldData);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
boolean wasApplied = persistField(fieldData, keyInfo);
|
||||||
|
if(wasApplied == false)
|
||||||
|
{
|
||||||
|
logIgnore(fieldData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean persistField(FieldData fieldData, DataKeyInfo keyInfo)
|
||||||
|
{
|
||||||
|
switch(keyInfo.getFieldType())
|
||||||
|
{
|
||||||
|
case PROPERTY:
|
||||||
|
return addProperty(keyInfo.getQName(), fieldData);
|
||||||
|
case TRANSIENT_PROPERTY:
|
||||||
|
return addTransientProperty(keyInfo.getFieldName(), fieldData);
|
||||||
|
default: // Handle properties
|
||||||
|
return changeAssociation(keyInfo, fieldData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean addTransientProperty(String fieldName, FieldData fieldData)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean changeTransientAssociation(String fieldName, List<NodeRef> values, boolean add)
|
||||||
|
{
|
||||||
|
if(add)
|
||||||
|
{
|
||||||
|
return addTransientAssociation(fieldName, values);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return removeTransientAssociation(fieldName, values);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean removeTransientAssociation(String fieldName, List<NodeRef> values)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean addTransientAssociation(String fieldName, List<NodeRef> values)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean addProperty(QName qName, FieldData fieldData)
|
||||||
|
{
|
||||||
|
Object rawValue = fieldData.getValue();
|
||||||
|
Serializable value = getPropertyValueToPersist(qName, rawValue);
|
||||||
|
return updateProperty(qName, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Serializable getPropertyValueToPersist(QName qName, Object value)
|
||||||
|
{
|
||||||
|
PropertyDefinition propDef = itemData.getPropertyDefinition(qName);
|
||||||
|
if (propDef == null)
|
||||||
|
{
|
||||||
|
propDef = dictionaryService.getProperty(qName);
|
||||||
|
}
|
||||||
|
if (propDef != null)
|
||||||
|
{
|
||||||
|
return valueGetter.getValue(value, propDef);
|
||||||
|
}
|
||||||
|
return (Serializable) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean changeAssociation(DataKeyInfo info, FieldData fieldData)
|
||||||
|
{
|
||||||
|
Object rawValue = fieldData.getValue();
|
||||||
|
if (rawValue instanceof String)
|
||||||
|
{
|
||||||
|
List<NodeRef> values = NodeRef.getNodeRefs((String)rawValue, LOGGER);
|
||||||
|
if (values.isEmpty()==false)
|
||||||
|
{
|
||||||
|
boolean add = info.isAdd();
|
||||||
|
if(info.getFieldType() == FieldType.ASSOCIATION)
|
||||||
|
{
|
||||||
|
return changeAssociation(info.getQName(), values, add);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return changeTransientAssociation(info.getFieldName(), values, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean changeAssociation(QName qName, List<NodeRef> values, boolean add)
|
||||||
|
{
|
||||||
|
if(add)
|
||||||
|
{
|
||||||
|
return addAssociation(qName, values);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return removeAssociation(qName, values);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void logIgnore(FieldData fieldData)
|
||||||
|
{
|
||||||
|
if(logger.isDebugEnabled())
|
||||||
|
logger.debug("Ignoring unrecognized field: " + fieldData.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.forms.processor.workflow.FormPersister#persist()
|
||||||
|
*/
|
||||||
|
public abstract T persist();
|
||||||
|
|
||||||
|
protected abstract boolean removeAssociation(QName qName, List<NodeRef> values);
|
||||||
|
|
||||||
|
protected abstract boolean addAssociation(QName qName, List<NodeRef> values);
|
||||||
|
|
||||||
|
protected abstract boolean updateProperty(QName qName, Serializable value);
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.alfresco.repo.forms.FormData.FieldData;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Nick Smith
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface FormPersister<T>
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
void addField(FieldData fieldData);
|
||||||
|
|
||||||
|
T persist();
|
||||||
|
}
|
@@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* 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 java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.repo.forms.processor.node.ItemData;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||||
|
import org.alfresco.service.cmr.workflow.WorkflowTask;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Nick Smith
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TaskFormPersister extends ContentModelFormPersister<WorkflowTask>
|
||||||
|
{
|
||||||
|
private final TaskUpdater updater;
|
||||||
|
|
||||||
|
public TaskFormPersister(ItemData<WorkflowTask> itemData,
|
||||||
|
NamespaceService namespaceService,
|
||||||
|
DictionaryService dictionaryService,
|
||||||
|
WorkflowService workflowService,
|
||||||
|
Log logger)
|
||||||
|
{
|
||||||
|
super(itemData, namespaceService, dictionaryService, logger);
|
||||||
|
WorkflowTask item = itemData.getItem();
|
||||||
|
this.updater = new TaskUpdater(item.id, workflowService);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#addAssociation(org.alfresco.service.namespace.QName, java.util.List)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean addAssociation(QName qName, List<NodeRef> values)
|
||||||
|
{
|
||||||
|
updater.addAssociation(qName, values);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#removeAssociation(org.alfresco.service.namespace.QName, java.util.List)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean removeAssociation(QName qName, List<NodeRef> values)
|
||||||
|
{
|
||||||
|
updater.removeAssociation(qName, values);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#updateProperty(org.alfresco.service.namespace.QName, java.io.Serializable)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean updateProperty(QName qName, Serializable value)
|
||||||
|
{
|
||||||
|
updater.addProperty(qName, value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#persist()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public WorkflowTask persist()
|
||||||
|
{
|
||||||
|
return updater.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -30,16 +30,12 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.repo.forms.Form;
|
import org.alfresco.repo.forms.Form;
|
||||||
import org.alfresco.repo.forms.FormData;
|
|
||||||
import org.alfresco.repo.forms.Item;
|
import org.alfresco.repo.forms.Item;
|
||||||
import org.alfresco.repo.forms.FormData.FieldData;
|
|
||||||
import org.alfresco.repo.forms.processor.FieldProcessorRegistry;
|
import org.alfresco.repo.forms.processor.FieldProcessorRegistry;
|
||||||
import org.alfresco.repo.forms.processor.FormCreationData;
|
import org.alfresco.repo.forms.processor.FormCreationData;
|
||||||
import org.alfresco.repo.forms.processor.node.ContentModelFormProcessor;
|
|
||||||
import org.alfresco.repo.forms.processor.node.ItemData;
|
import org.alfresco.repo.forms.processor.node.ItemData;
|
||||||
import org.alfresco.repo.workflow.WorkflowModel;
|
import org.alfresco.repo.workflow.WorkflowModel;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
|
||||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowTask;
|
import org.alfresco.service.cmr.workflow.WorkflowTask;
|
||||||
@@ -52,14 +48,10 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
/**
|
/**
|
||||||
* @author Nick Smith
|
* @author Nick Smith
|
||||||
*/
|
*/
|
||||||
public class TaskFormProcessor extends ContentModelFormProcessor<WorkflowTask, WorkflowTask>
|
public class TaskFormProcessor extends AbstractWorkflowFormProcessor<WorkflowTask, WorkflowTask>
|
||||||
{
|
{
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static final Log LOGGER = LogFactory.getLog(TaskFormProcessor.class);
|
private static final Log LOGGER = LogFactory.getLog(TaskFormProcessor.class);
|
||||||
|
|
||||||
private TypedPropertyValueGetter valueGetter;
|
|
||||||
private DataKeyMatcher keyMatcher;
|
|
||||||
private WorkflowService workflowService;
|
|
||||||
|
|
||||||
// Constructor for Spring
|
// Constructor for Spring
|
||||||
public TaskFormProcessor()
|
public TaskFormProcessor()
|
||||||
@@ -75,8 +67,6 @@ public class TaskFormProcessor extends ContentModelFormProcessor<WorkflowTask, W
|
|||||||
this.namespaceService = namespaceService;
|
this.namespaceService = namespaceService;
|
||||||
this.dictionaryService = dictionaryService;
|
this.dictionaryService = dictionaryService;
|
||||||
this.fieldProcessorRegistry = fieldProcessorRegistry;
|
this.fieldProcessorRegistry = fieldProcessorRegistry;
|
||||||
this.keyMatcher = new DataKeyMatcher(namespaceService);
|
|
||||||
this.valueGetter = new TypedPropertyValueGetter(dictionaryService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -99,68 +89,6 @@ public class TaskFormProcessor extends ContentModelFormProcessor<WorkflowTask, W
|
|||||||
addPropertyDataIfRequired(WorkflowModel.PROP_PACKAGE_ITEM_ACTION_GROUP, form, itemData);
|
addPropertyDataIfRequired(WorkflowModel.PROP_PACKAGE_ITEM_ACTION_GROUP, form, itemData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected WorkflowTask internalPersist(WorkflowTask task, FormData data)
|
|
||||||
{
|
|
||||||
TaskUpdater updater = new TaskUpdater(task.id, workflowService);
|
|
||||||
ItemData<WorkflowTask> itemData = makeItemData(task);
|
|
||||||
for (FieldData fieldData : data)
|
|
||||||
{
|
|
||||||
addFieldToSerialize(updater, itemData, fieldData);
|
|
||||||
}
|
|
||||||
return updater.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addFieldToSerialize(TaskUpdater updater,
|
|
||||||
ItemData<?> itemData,
|
|
||||||
FieldData fieldData)
|
|
||||||
{
|
|
||||||
String name = fieldData.getName();
|
|
||||||
DataKeyInfo keyInfo = keyMatcher.match(name);
|
|
||||||
if (keyInfo == null ||
|
|
||||||
FieldType.TRANSIENT_PROPERTY == keyInfo.getFieldType() )
|
|
||||||
{
|
|
||||||
if(LOGGER.isDebugEnabled())
|
|
||||||
LOGGER.debug("Ignoring unrecognized field: " + name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QName fullName = keyInfo.getQName();
|
|
||||||
Object rawValue = fieldData.getValue();
|
|
||||||
if (FieldType.PROPERTY == keyInfo.getFieldType())
|
|
||||||
{
|
|
||||||
Serializable propValue = getPropertyValueToPersist(fullName, rawValue, itemData);
|
|
||||||
// TODO What if the user wants to set prop to null?
|
|
||||||
if (propValue != null)
|
|
||||||
{
|
|
||||||
updater.addProperty(fullName, propValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (FieldType.ASSOCIATION == keyInfo.getFieldType())
|
|
||||||
{
|
|
||||||
if (rawValue instanceof String)
|
|
||||||
{
|
|
||||||
updater.changeAssociation(fullName, (String) rawValue, keyInfo.isAdd());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Serializable getPropertyValueToPersist(QName fullName,
|
|
||||||
Object value,
|
|
||||||
ItemData<?> itemData)
|
|
||||||
{
|
|
||||||
PropertyDefinition propDef = itemData.getPropertyDefinition(fullName);
|
|
||||||
if (propDef == null)
|
|
||||||
{
|
|
||||||
propDef = dictionaryService.getProperty(fullName);
|
|
||||||
}
|
|
||||||
if (propDef != null)
|
|
||||||
{
|
|
||||||
return valueGetter.getValue(value, propDef);
|
|
||||||
}
|
|
||||||
return (Serializable) value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
@@ -224,36 +152,13 @@ public class TaskFormProcessor extends ContentModelFormProcessor<WorkflowTask, W
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Workflow Service.
|
|
||||||
*
|
|
||||||
* @param workflowService
|
|
||||||
*/
|
|
||||||
public void setWorkflowService(WorkflowService workflowService)
|
|
||||||
{
|
|
||||||
this.workflowService = workflowService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @seeorg.alfresco.repo.forms.processor.task.ContentModelFormProcessor#
|
|
||||||
* setNamespaceService(org.alfresco.service.namespace.NamespaceService)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setNamespaceService(NamespaceService namespaceService)
|
|
||||||
{
|
|
||||||
super.setNamespaceService(namespaceService);
|
|
||||||
this.keyMatcher = new DataKeyMatcher(namespaceService);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.forms.processor.node.ContentModelFormProcessor#setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService)
|
* @see org.alfresco.repo.forms.processor.workflow.AbstractWorkflowFormProcessor#makeFormPersister(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setDictionaryService(DictionaryService dictionaryService)
|
protected ContentModelFormPersister<WorkflowTask> makeFormPersister(WorkflowTask item)
|
||||||
{
|
{
|
||||||
super.setDictionaryService(dictionaryService);
|
ItemData<WorkflowTask> itemData = makeItemData(item);
|
||||||
this.valueGetter = new TypedPropertyValueGetter(dictionaryService);
|
return new TaskFormPersister(itemData, namespaceService, dictionaryService, workflowService, LOGGER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,11 +31,8 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.repo.forms.FormException;
|
import org.alfresco.repo.forms.FormException;
|
||||||
import org.alfresco.repo.forms.processor.node.ItemData;
|
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.springframework.extensions.surf.util.I18NUtil;
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
@@ -47,27 +44,6 @@ public class TypedPropertyValueGetter
|
|||||||
{
|
{
|
||||||
public static final String ON = "on";
|
public static final String ON = "on";
|
||||||
|
|
||||||
private final DictionaryService dictionaryService;
|
|
||||||
|
|
||||||
public TypedPropertyValueGetter(DictionaryService dictionaryService)
|
|
||||||
{
|
|
||||||
this.dictionaryService = dictionaryService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Serializable getPropertyValueToPersist(QName fullName, Object value, ItemData<?> itemData)
|
|
||||||
{
|
|
||||||
PropertyDefinition propDef = itemData.getPropertyDefinition(fullName);
|
|
||||||
if (propDef == null)
|
|
||||||
{
|
|
||||||
propDef = dictionaryService.getProperty(fullName);
|
|
||||||
}
|
|
||||||
if (propDef != null)
|
|
||||||
{
|
|
||||||
return getValue(value, propDef);
|
|
||||||
}
|
|
||||||
return (Serializable) value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Serializable getValue(Object value, PropertyDefinition propDef)
|
public Serializable getValue(Object value, PropertyDefinition propDef)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
|
@@ -71,9 +71,12 @@ public class WorkflowBuilder
|
|||||||
params.put(name, value);
|
params.put(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAssociationParameter(QName name, Serializable value)
|
public void addAssociationParameter(QName name, List<NodeRef> values)
|
||||||
{
|
{
|
||||||
params.put(name, value);
|
if(values instanceof Serializable)
|
||||||
|
{
|
||||||
|
params.put(name, (Serializable) values);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPackageItems(List<NodeRef> items)
|
public void addPackageItems(List<NodeRef> items)
|
||||||
|
@@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* 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 java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.repo.forms.processor.node.ItemData;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||||
|
import org.alfresco.service.cmr.workflow.WorkflowInstance;
|
||||||
|
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Nick Smith
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class WorkflowFormPersister extends ContentModelFormPersister<WorkflowInstance>
|
||||||
|
{
|
||||||
|
private final WorkflowBuilder builder;
|
||||||
|
|
||||||
|
public WorkflowFormPersister(ItemData<?> itemData,
|
||||||
|
NamespaceService namespaceService,
|
||||||
|
DictionaryService dictionaryService,
|
||||||
|
WorkflowService workflowService,
|
||||||
|
NodeService nodeService,
|
||||||
|
Log logger)
|
||||||
|
{
|
||||||
|
super(itemData, namespaceService, dictionaryService, logger);
|
||||||
|
WorkflowDefinition definition = (WorkflowDefinition) itemData.getItem();
|
||||||
|
this.builder = new WorkflowBuilder(definition, workflowService, nodeService);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#addAssociation(org.alfresco.service.namespace.QName, java.util.List)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean addAssociation(QName qName, List<NodeRef> values)
|
||||||
|
{
|
||||||
|
builder.addAssociationParameter(qName, values);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#persist()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public WorkflowInstance persist()
|
||||||
|
{
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#removeAssociation(org.alfresco.service.namespace.QName, java.util.List)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean removeAssociation(QName qName, List<NodeRef> values)
|
||||||
|
{
|
||||||
|
// Do nothing!
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#updateProperty(org.alfresco.service.namespace.QName, java.io.Serializable)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean updateProperty(QName qName, Serializable value)
|
||||||
|
{
|
||||||
|
builder.addParameter(qName, value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#addTransientAssociation(java.lang.String, java.util.List)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean addTransientAssociation(String fieldName, List<NodeRef> values)
|
||||||
|
{
|
||||||
|
if(PackageItemsFieldProcessor.KEY.equals(fieldName))
|
||||||
|
{
|
||||||
|
builder.addPackageItems(values);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@@ -20,28 +20,16 @@ package org.alfresco.repo.forms.processor.workflow;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
import org.alfresco.repo.forms.Form;
|
|
||||||
import org.alfresco.repo.forms.FormData;
|
|
||||||
import org.alfresco.repo.forms.FormException;
|
|
||||||
import org.alfresco.repo.forms.FormNotFoundException;
|
import org.alfresco.repo.forms.FormNotFoundException;
|
||||||
import org.alfresco.repo.forms.Item;
|
import org.alfresco.repo.forms.Item;
|
||||||
import org.alfresco.repo.forms.FormData.FieldData;
|
|
||||||
import org.alfresco.repo.forms.processor.FormCreationData;
|
|
||||||
import org.alfresco.repo.forms.processor.node.ContentModelFormProcessor;
|
|
||||||
import org.alfresco.repo.forms.processor.node.ItemData;
|
import org.alfresco.repo.forms.processor.node.ItemData;
|
||||||
import org.alfresco.repo.workflow.WorkflowModel;
|
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
|
||||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowInstance;
|
import org.alfresco.service.cmr.workflow.WorkflowInstance;
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowTaskDefinition;
|
import org.alfresco.service.cmr.workflow.WorkflowTaskDefinition;
|
||||||
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;
|
||||||
@@ -52,34 +40,11 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
*
|
*
|
||||||
* @author Nick Smith
|
* @author Nick Smith
|
||||||
*/
|
*/
|
||||||
public class WorkflowFormProcessor extends ContentModelFormProcessor<WorkflowDefinition, WorkflowInstance>
|
public class WorkflowFormProcessor extends AbstractWorkflowFormProcessor<WorkflowDefinition, WorkflowInstance>
|
||||||
{
|
{
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private final static Log logger = LogFactory.getLog(WorkflowFormProcessor.class);
|
private final static Log logger = LogFactory.getLog(WorkflowFormProcessor.class);
|
||||||
|
|
||||||
/** WorkflowService */
|
|
||||||
private WorkflowService workflowService;
|
|
||||||
|
|
||||||
/** TyepdPropertyValueGetter */
|
|
||||||
private TypedPropertyValueGetter valueGetter;
|
|
||||||
|
|
||||||
private DataKeyMatcher keyMatcher;
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.forms.processor.FilteredFormProcessor#generateFields(org.alfresco.repo.forms.Form, java.util.List, org.alfresco.repo.forms.processor.FormCreationData)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void populateForm(Form form, List<String> fields, FormCreationData data)
|
|
||||||
{
|
|
||||||
super.populateForm(form, fields, data);
|
|
||||||
|
|
||||||
// Add package actions to FormData.
|
|
||||||
ItemData<?> itemData = (ItemData<?>) data.getItemData();
|
|
||||||
addPropertyDataIfRequired(WorkflowModel.PROP_PACKAGE_ACTION_GROUP, form, itemData);
|
|
||||||
addPropertyDataIfRequired(WorkflowModel.PROP_PACKAGE_ITEM_ACTION_GROUP, form, itemData);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.forms.processor.node.ContentModelFormProcessor#getAssociationValues(java.lang.Object)
|
* @see org.alfresco.repo.forms.processor.node.ContentModelFormProcessor#getAssociationValues(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@@ -197,126 +162,13 @@ public class WorkflowFormProcessor extends ContentModelFormProcessor<WorkflowDef
|
|||||||
return defName;
|
return defName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.forms.processor.FilteredFormProcessor#internalPersist(java.lang.Object, org.alfresco.repo.forms.FormData)
|
* @see org.alfresco.repo.forms.processor.workflow.AbstractWorkflowFormProcessor#makeFormPersister(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected WorkflowInstance internalPersist(WorkflowDefinition definition, FormData data)
|
protected ContentModelFormPersister<WorkflowInstance> makeFormPersister(WorkflowDefinition item)
|
||||||
{
|
{
|
||||||
WorkflowBuilder builder = new WorkflowBuilder(definition, workflowService, nodeService);
|
ItemData<WorkflowDefinition> itemData = makeItemData(item);
|
||||||
ItemData<WorkflowDefinition> itemData = makeItemData(definition);
|
return new WorkflowFormPersister(itemData, namespaceService, dictionaryService, workflowService, nodeService, logger);
|
||||||
for (FieldData fieldData : data)
|
|
||||||
{
|
|
||||||
addFieldToSerialize(builder, itemData, fieldData);
|
|
||||||
}
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addFieldToSerialize(WorkflowBuilder builder, ItemData<WorkflowDefinition> itemData, FieldData fieldData)
|
|
||||||
{
|
|
||||||
String dataKeyName = fieldData.getName();
|
|
||||||
DataKeyInfo keyInfo = keyMatcher.match(dataKeyName);
|
|
||||||
if (keyInfo == null ||
|
|
||||||
FieldType.TRANSIENT_PROPERTY == keyInfo.getFieldType() )
|
|
||||||
{
|
|
||||||
if(logger.isDebugEnabled())
|
|
||||||
logger.debug("Ignoring unrecognized field: " + dataKeyName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
WorkflowDataKeyInfoVisitor visitor = new WorkflowDataKeyInfoVisitor(fieldData.getValue(), builder, itemData);
|
|
||||||
keyInfo.visit(visitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param workflowService the workflowService to set
|
|
||||||
*/
|
|
||||||
public void setWorkflowService(WorkflowService workflowService)
|
|
||||||
{
|
|
||||||
this.workflowService = workflowService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.forms.processor.node.ContentModelFormProcessor#setNamespaceService(org.alfresco.service.namespace.NamespaceService)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setNamespaceService(NamespaceService namespaceService)
|
|
||||||
{
|
|
||||||
super.setNamespaceService(namespaceService);
|
|
||||||
this.keyMatcher = new DataKeyMatcher(namespaceService);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.forms.processor.node.ContentModelFormProcessor#setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setDictionaryService(DictionaryService dictionaryService)
|
|
||||||
{
|
|
||||||
super.setDictionaryService(dictionaryService);
|
|
||||||
this.valueGetter = new TypedPropertyValueGetter(dictionaryService);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class WorkflowDataKeyInfoVisitor implements DataKeyInfoVisitor<Void>
|
|
||||||
{
|
|
||||||
private final Object rawValue;
|
|
||||||
private final WorkflowBuilder builder;
|
|
||||||
private final ItemData<WorkflowDefinition> itemData;
|
|
||||||
|
|
||||||
public WorkflowDataKeyInfoVisitor(Object rawValue, WorkflowBuilder builder,
|
|
||||||
ItemData<WorkflowDefinition> itemData)
|
|
||||||
{
|
|
||||||
this.rawValue = rawValue;
|
|
||||||
this.builder = builder;
|
|
||||||
this.itemData = itemData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.forms.processor.workflow.DataKeyInfoVisitor#visitAssociation(org.alfresco.repo.forms.processor.workflow.DataKeyInfo)
|
|
||||||
*/
|
|
||||||
public Void visitAssociation(DataKeyInfo info)
|
|
||||||
{
|
|
||||||
QName qName = info.getQName();
|
|
||||||
if (rawValue instanceof String)
|
|
||||||
{
|
|
||||||
Serializable nodes = (Serializable) NodeRef.getNodeRefs((String) rawValue);
|
|
||||||
builder.addParameter(qName, nodes);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.forms.processor.workflow.DataKeyInfoVisitor#visitProperty(org.alfresco.repo.forms.processor.workflow.DataKeyInfo)
|
|
||||||
*/
|
|
||||||
public Void visitProperty(DataKeyInfo info)
|
|
||||||
{
|
|
||||||
QName qName = info.getQName();
|
|
||||||
Serializable propValue = valueGetter.getPropertyValueToPersist(qName, rawValue, itemData);
|
|
||||||
builder.addParameter(qName, propValue);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.forms.processor.workflow.DataKeyInfoVisitor#visitTransientAssociation(org.alfresco.repo.forms.processor.workflow.DataKeyInfo)
|
|
||||||
*/
|
|
||||||
public Void visitTransientAssociation(DataKeyInfo info)
|
|
||||||
{
|
|
||||||
if(PackageItemsFieldProcessor.KEY.equals(info.getFieldName()))
|
|
||||||
{
|
|
||||||
if(rawValue instanceof String)
|
|
||||||
{
|
|
||||||
builder.addPackageItems((String)rawValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.forms.processor.workflow.DataKeyInfoVisitor#visitTransientProperty(org.alfresco.repo.forms.processor.workflow.DataKeyInfo)
|
|
||||||
*/
|
|
||||||
public Void visitTransientProperty(DataKeyInfo info)
|
|
||||||
{
|
|
||||||
throw new FormException("This methdo should never be called!");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user