mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
. Submit dialog now gathers all associated rendered assets and form instance data when files are submitted
- if the user attempts to submit either a single rendering asset or the form instance data for an Xform and does not include all the other associated files, then the Submit dialog will automatically add the missing assets/formdata to the submit list - this means that a form and all generated assets are always submitted together git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4552 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,6 +24,7 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.faces.context.FacesContext;
|
import javax.faces.context.FacesContext;
|
||||||
|
|
||||||
@@ -49,6 +50,9 @@ import org.alfresco.util.ISO8601DateFormat;
|
|||||||
import org.alfresco.util.NameMatcher;
|
import org.alfresco.util.NameMatcher;
|
||||||
import org.alfresco.web.app.servlet.DownloadContentServlet;
|
import org.alfresco.web.app.servlet.DownloadContentServlet;
|
||||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||||
|
import org.alfresco.web.forms.Form;
|
||||||
|
import org.alfresco.web.forms.FormsService;
|
||||||
|
import org.alfresco.web.forms.RenderingEngineTemplate;
|
||||||
import org.alfresco.web.ui.common.Utils;
|
import org.alfresco.web.ui.common.Utils;
|
||||||
import org.alfresco.web.ui.common.component.UIListItem;
|
import org.alfresco.web.ui.common.component.UIListItem;
|
||||||
import org.alfresco.web.ui.wcm.WebResources;
|
import org.alfresco.web.ui.wcm.WebResources;
|
||||||
@@ -377,6 +381,7 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
}
|
}
|
||||||
if (selected != null)
|
if (selected != null)
|
||||||
{
|
{
|
||||||
|
Set<String> submittedPaths = new HashSet<String>(selected.size());
|
||||||
this.submitItems = new ArrayList<ItemWrapper>(selected.size());
|
this.submitItems = new ArrayList<ItemWrapper>(selected.size());
|
||||||
this.warningItems = new ArrayList<ItemWrapper>(selected.size() >> 1);
|
this.warningItems = new ArrayList<ItemWrapper>(selected.size() >> 1);
|
||||||
for (AVMNodeDescriptor node : selected)
|
for (AVMNodeDescriptor node : selected)
|
||||||
@@ -386,10 +391,48 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
// lookup if this item was created via a form - then lookup the workflow defaults
|
// lookup if this item was created via a form - then lookup the workflow defaults
|
||||||
// for that form and store into the list of available workflows
|
// for that form and store into the list of available workflows
|
||||||
NodeRef ref = AVMNodeConverter.ToNodeRef(-1, node.getPath());
|
NodeRef ref = AVMNodeConverter.ToNodeRef(-1, node.getPath());
|
||||||
|
if (submittedPaths.contains(node.getPath()) == false)
|
||||||
|
{
|
||||||
if (this.nodeService.hasAspect(ref, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
|
if (this.nodeService.hasAspect(ref, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
|
||||||
{
|
{
|
||||||
// found an XML form instance data file
|
NodeRef formInstanceDataRef = ref;
|
||||||
String formName = (String)this.nodeService.getProperty(ref, WCMAppModel.PROP_PARENT_FORM_NAME);
|
|
||||||
|
// check if this is a rendition - as they also have the forminstancedata aspect
|
||||||
|
if (this.nodeService.hasAspect(ref, WCMAppModel.ASPECT_RENDITION))
|
||||||
|
{
|
||||||
|
// found a generated rendition asset - locate the parent form instance data file
|
||||||
|
// and use this to find all generated assets that are appropriate
|
||||||
|
// NOTE: this ref will be in the 'preview' store convert back to user store first
|
||||||
|
String formInstanceDataPath = AVMNodeConverter.ToAVMVersionPath(
|
||||||
|
(NodeRef)this.nodeService.getProperty(
|
||||||
|
ref, WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA)).getSecond();
|
||||||
|
formInstanceDataPath = formInstanceDataPath.replaceFirst(AVMConstants.STORE_PREVIEW,
|
||||||
|
AVMConstants.STORE_MAIN);
|
||||||
|
formInstanceDataRef = AVMNodeConverter.ToNodeRef(-1, formInstanceDataPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the form instance data file to the list for submission
|
||||||
|
AVMNodeDescriptor formInstanceNode = this.avmService.lookup(
|
||||||
|
-1, AVMNodeConverter.ToAVMVersionPath(formInstanceDataRef).getSecond());
|
||||||
|
this.submitItems.add(new ItemWrapper(formInstanceNode));
|
||||||
|
submittedPaths.add(formInstanceNode.getPath());
|
||||||
|
|
||||||
|
// locate renditions for this form instance data file and add to list for submission
|
||||||
|
NodeRef formNodeRef = (NodeRef)this.nodeService.getProperty(
|
||||||
|
formInstanceDataRef, WCMAppModel.PROP_PARENT_FORM);
|
||||||
|
Form form = FormsService.getInstance().getForm(formNodeRef);
|
||||||
|
for (RenderingEngineTemplate ret : form.getRenderingEngineTemplates())
|
||||||
|
{
|
||||||
|
String renditionAvmPath = FormsService.getOutputAvmPathForRendition(
|
||||||
|
ret, formInstanceDataRef);
|
||||||
|
AVMNodeDescriptor renditionNode = this.avmService.lookup(-1, renditionAvmPath);
|
||||||
|
this.submitItems.add(new ItemWrapper(renditionNode));
|
||||||
|
submittedPaths.add(renditionNode.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
// lookup the associated Form workflow from the parent form property
|
||||||
|
String formName = (String)this.nodeService.getProperty(
|
||||||
|
formInstanceDataRef, WCMAppModel.PROP_PARENT_FORM_NAME);
|
||||||
FormWorkflowWrapper wrapper = this.formWorkflowMap.get(formName);
|
FormWorkflowWrapper wrapper = this.formWorkflowMap.get(formName);
|
||||||
if (wrapper != null && wrapper.Params != null)
|
if (wrapper != null && wrapper.Params != null)
|
||||||
{
|
{
|
||||||
@@ -397,7 +440,12 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
this.workflows.add(wrapper);
|
this.workflows.add(wrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
this.submitItems.add(new ItemWrapper(node));
|
this.submitItems.add(new ItemWrapper(node));
|
||||||
|
submittedPaths.add(node.getPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -534,5 +582,24 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
{
|
{
|
||||||
return Utils.getFileTypeImage(descriptor.getName(), true);
|
return Utils.getFileTypeImage(descriptor.getName(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj)
|
||||||
|
{
|
||||||
|
if (obj instanceof ItemWrapper)
|
||||||
|
{
|
||||||
|
return ((ItemWrapper)obj).descriptor.getPath().equals(descriptor.getPath());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return descriptor.getPath().hashCode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -386,7 +386,7 @@ public final class FormsService
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getOutputAvmPathForRendition(final RenderingEngineTemplate ret,
|
public static String getOutputAvmPathForRendition(final RenderingEngineTemplate ret,
|
||||||
final NodeRef formInstanceDataNodeRef)
|
final NodeRef formInstanceDataNodeRef)
|
||||||
{
|
{
|
||||||
final String formInstanceDataAvmPath =
|
final String formInstanceDataAvmPath =
|
||||||
|
Reference in New Issue
Block a user