mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
- adding a primitive select default workflow screen
- improved output path expressions - got the details screen pretty much in sync with wireframes. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4358 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -41,6 +41,8 @@ import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.FileUploadBean;
|
||||
@@ -49,7 +51,9 @@ import org.alfresco.web.data.IDataContainer;
|
||||
import org.alfresco.web.data.QuickSort;
|
||||
import org.alfresco.web.forms.*;
|
||||
import org.alfresco.web.forms.xforms.SchemaFormBuilder;
|
||||
import org.alfresco.web.ui.common.component.UIListItem;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.alfresco.web.ui.wcm.WebResources;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.xerces.xs.*;
|
||||
@@ -135,13 +139,15 @@ public class CreateFormWizard
|
||||
|
||||
private final static Log LOGGER = LogFactory.getLog(CreateFormWizard.class);
|
||||
|
||||
private String schemaRootElementName;
|
||||
private String formName;
|
||||
private String formTitle;
|
||||
private String formDescription;
|
||||
private String schemaRootElementName = null;
|
||||
private String formName = null;
|
||||
private String formTitle = null;
|
||||
private String formDescription = null;
|
||||
private String defaultWorkflowId = null;
|
||||
private RenderingEngine renderingEngine = null;
|
||||
protected ContentService contentService;
|
||||
protected MimetypeService mimetypeService;
|
||||
protected WorkflowService workflowService;
|
||||
private DataModel renderingEngineTemplatesDataModel;
|
||||
private List<RenderingEngineTemplateData> renderingEngineTemplates = null;
|
||||
private String outputPathPatternForFormInstanceData = null;
|
||||
@@ -191,6 +197,10 @@ public class CreateFormWizard
|
||||
this.getSchemaRootElementName());
|
||||
props.put(WCMModel.PROP_OUTPUT_PATH_PATTERN_FOR_FORM_INSTANCE_DATA,
|
||||
this.getOutputPathPatternForFormInstanceData());
|
||||
if (this.defaultWorkflowId != null)
|
||||
{
|
||||
props.put(WCMModel.PROP_DEFAULT_WORKFLOW_ID, this.defaultWorkflowId);
|
||||
}
|
||||
this.nodeService.addAspect(folderInfo.getNodeRef(), WCMModel.ASPECT_FORM, props);
|
||||
|
||||
for (RenderingEngineTemplateData retd : this.renderingEngineTemplates)
|
||||
@@ -272,6 +282,7 @@ public class CreateFormWizard
|
||||
this.outputPathPatternForFormInstanceData = null;
|
||||
this.outputPathPatternForRendition = null;
|
||||
this.mimetypeForRendition = null;
|
||||
this.defaultWorkflowId = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -318,11 +329,9 @@ public class CreateFormWizard
|
||||
*/
|
||||
public String getOutputPathPatternForRendition()
|
||||
{
|
||||
if (this.outputPathPatternForRendition == null && this.mimetypeForRendition != null)
|
||||
if (this.outputPathPatternForRendition == null)
|
||||
{
|
||||
this.outputPathPatternForRendition =
|
||||
("${formInstanceData.name}." +
|
||||
this.mimetypeService.getExtension(this.mimetypeForRendition));
|
||||
this.outputPathPatternForRendition = "${name}.${extension}";
|
||||
}
|
||||
return this.outputPathPatternForRendition;
|
||||
}
|
||||
@@ -655,7 +664,7 @@ public class CreateFormWizard
|
||||
{
|
||||
if (this.outputPathPatternForFormInstanceData == null)
|
||||
{
|
||||
this.outputPathPatternForFormInstanceData = "${formInstanceData.name}.xml";
|
||||
this.outputPathPatternForFormInstanceData = "${name}.xml";
|
||||
}
|
||||
return this.outputPathPatternForFormInstanceData;
|
||||
}
|
||||
@@ -701,6 +710,54 @@ public class CreateFormWizard
|
||||
{
|
||||
return this.formDescription;
|
||||
}
|
||||
|
||||
public void setDefaultWorkflowId(final String[] defaultWorkflowId)
|
||||
{
|
||||
assert defaultWorkflowId.length == 1;
|
||||
this.defaultWorkflowId = ("no_default_workflow_selected".equals(defaultWorkflowId[0])
|
||||
? null
|
||||
: defaultWorkflowId[0]);
|
||||
}
|
||||
|
||||
|
||||
public String[] getDefaultWorkflowId()
|
||||
{
|
||||
return new String[] {
|
||||
(this.defaultWorkflowId == null
|
||||
? "no_default_workflow_selected"
|
||||
: this.defaultWorkflowId)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return List of UI items to represent the available Workflows for all websites
|
||||
*/
|
||||
public List<UIListItem> getDefaultWorkflowChoices()
|
||||
{
|
||||
// TODO: add list of workflows from config
|
||||
// @see org.alfresco.web.wcm.FormDetailsDialog#getWorkflowList()
|
||||
final List<WorkflowDefinition> workflowDefs = this.workflowService.getDefinitions();
|
||||
final List<UIListItem> result = new ArrayList<UIListItem>(workflowDefs.size() + 1);
|
||||
|
||||
UIListItem item = new UIListItem();
|
||||
item.setValue("no_default_workflow_selected");
|
||||
item.setLabel("None");
|
||||
item.setDescription("");
|
||||
item.setImage(WebResources.IMAGE_WORKFLOW_32);
|
||||
result.add(item);
|
||||
|
||||
for (WorkflowDefinition workflowDef : workflowDefs)
|
||||
{
|
||||
item = new UIListItem();
|
||||
item.setValue(workflowDef.id);
|
||||
item.setLabel(workflowDef.title);
|
||||
item.setDescription(workflowDef.description);
|
||||
item.setImage(WebResources.IMAGE_WORKFLOW_32);
|
||||
result.add(item);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the summary data for the wizard.
|
||||
@@ -742,6 +799,14 @@ public class CreateFormWizard
|
||||
{
|
||||
this.mimetypeService = mimetypeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param workflowService The workflowService to set.
|
||||
*/
|
||||
public void setWorkflowService(final WorkflowService workflowService)
|
||||
{
|
||||
this.workflowService = workflowService;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Helper Methods
|
||||
|
@@ -1021,6 +1021,11 @@ public class CreateWebsiteWizard extends BaseWizardBean
|
||||
*/
|
||||
public WorkflowWrapper getWorkflow()
|
||||
{
|
||||
WorkflowDefinition wf = this.form.getDefaultWorkflow();
|
||||
if (this.workflow == null && wf != null)
|
||||
{
|
||||
this.workflow = new WorkflowWrapper(wf.name);
|
||||
}
|
||||
return this.workflow;
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package org.alfresco.web.forms;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.SAXException;
|
||||
import java.io.IOException;
|
||||
@@ -45,6 +46,12 @@ public interface Form
|
||||
/** the output path pattern for form instance data */
|
||||
public String getOutputPathPattern();
|
||||
|
||||
/**
|
||||
* @return the default workflow associated with this form or <tt>null</tt>
|
||||
* if none is configured.
|
||||
*/
|
||||
public WorkflowDefinition getDefaultWorkflow();
|
||||
|
||||
/** the xml schema for this template type */
|
||||
public Document getSchema()
|
||||
throws IOException, SAXException;
|
||||
|
@@ -27,16 +27,21 @@ import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import javax.faces.context.FacesContext;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.WCMModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.TemplateService;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.wcm.AVMConstants;
|
||||
import org.alfresco.web.forms.xforms.XFormsProcessor;
|
||||
import org.alfresco.web.app.servlet.DownloadContentServlet;
|
||||
@@ -51,9 +56,6 @@ public class FormImpl
|
||||
private static final Log LOGGER = LogFactory.getLog(FormImpl.class);
|
||||
|
||||
private final NodeRef folderNodeRef;
|
||||
private final NodeService nodeService;
|
||||
private final ContentService contentService;
|
||||
private final TemplateService templateService;
|
||||
|
||||
private final static LinkedList<FormProcessor> PROCESSORS =
|
||||
new LinkedList<FormProcessor>();
|
||||
@@ -62,87 +64,56 @@ public class FormImpl
|
||||
FormImpl.PROCESSORS.add(new XFormsProcessor());
|
||||
}
|
||||
|
||||
public FormImpl(final NodeRef folderNodeRef,
|
||||
final NodeService nodeService,
|
||||
final ContentService contentService,
|
||||
final TemplateService templateService)
|
||||
public FormImpl(final NodeRef folderNodeRef)
|
||||
{
|
||||
this.folderNodeRef = folderNodeRef;
|
||||
this.nodeService = nodeService;
|
||||
this.contentService = contentService;
|
||||
this.templateService = templateService;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return (String)
|
||||
this.nodeService.getProperty(this.folderNodeRef,
|
||||
ContentModel.PROP_TITLE);
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
return (String)nodeService.getProperty(this.folderNodeRef,
|
||||
ContentModel.PROP_TITLE);
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return (String)
|
||||
this.nodeService.getProperty(this.folderNodeRef,
|
||||
ContentModel.PROP_DESCRIPTION);
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
return (String)nodeService.getProperty(this.folderNodeRef,
|
||||
ContentModel.PROP_DESCRIPTION);
|
||||
}
|
||||
|
||||
public String getOutputPathPattern()
|
||||
{
|
||||
return (String)
|
||||
this.nodeService.getProperty(this.folderNodeRef,
|
||||
WCMModel.PROP_OUTPUT_PATH_PATTERN_FOR_FORM_INSTANCE_DATA);
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
return (String)nodeService.getProperty(this.folderNodeRef,
|
||||
WCMModel.PROP_OUTPUT_PATH_PATTERN_FOR_FORM_INSTANCE_DATA);
|
||||
}
|
||||
|
||||
public WorkflowDefinition getDefaultWorkflow()
|
||||
{
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
final String defaultWorkflowId = (String)nodeService.getProperty(this.folderNodeRef,
|
||||
WCMModel.PROP_DEFAULT_WORKFLOW_ID);
|
||||
final WorkflowService workflowService = this.getServiceRegistry().getWorkflowService();
|
||||
return (defaultWorkflowId != null
|
||||
? workflowService.getDefinitionById(defaultWorkflowId)
|
||||
: null);
|
||||
}
|
||||
|
||||
public String getOutputPathForFormInstanceData(final String parentAVMPath,
|
||||
final String formInstanceDataFileName,
|
||||
final String formInstanceDataName,
|
||||
final Document formInstanceData)
|
||||
{
|
||||
final String outputPathPattern = (String)
|
||||
this.nodeService.getProperty(this.folderNodeRef,
|
||||
WCMModel.PROP_OUTPUT_PATH_PATTERN_FOR_FORM_INSTANCE_DATA);
|
||||
final String outputPathPattern = this.getOutputPathPattern();
|
||||
|
||||
final TemplateHashModel formInstanceDataModel = new TemplateHashModel()
|
||||
{
|
||||
|
||||
private TemplateModel formInstanceDataModel;
|
||||
|
||||
public TemplateModel get(final String key)
|
||||
{
|
||||
LOGGER.debug("looking up property " + key);
|
||||
if ("xml".equals(key))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (formInstanceDataModel == null)
|
||||
{
|
||||
formInstanceDataModel = NodeModel.wrap(formInstanceData);
|
||||
}
|
||||
return formInstanceDataModel;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if ("name".equals(key))
|
||||
{
|
||||
return new SimpleScalar(formInstanceDataFileName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
final Map<String, TemplateModel> root = new HashMap<String, TemplateModel>();
|
||||
root.put("formInstanceData", formInstanceDataModel);
|
||||
final Map<String, Object> root = new HashMap<String, Object>();
|
||||
root.put("xml", NodeModel.wrap(formInstanceData));
|
||||
root.put("name", formInstanceDataName);
|
||||
root.put("date", new SimpleDate(new Date(), SimpleDate.DATETIME));
|
||||
|
||||
final TemplateService templateService = this.getServiceRegistry().getTemplateService();
|
||||
|
||||
String result = templateService.processTemplateString(null,
|
||||
outputPathPattern,
|
||||
new SimpleHash(root));
|
||||
@@ -153,9 +124,9 @@ public class FormImpl
|
||||
|
||||
public String getSchemaRootElementName()
|
||||
{
|
||||
return (String)
|
||||
this.nodeService.getProperty(folderNodeRef,
|
||||
WCMModel.PROP_XML_SCHEMA_ROOT_ELEMENT_NAME);
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
return (String)nodeService.getProperty(folderNodeRef,
|
||||
WCMModel.PROP_XML_SCHEMA_ROOT_ELEMENT_NAME);
|
||||
}
|
||||
|
||||
public Document getSchema()
|
||||
@@ -163,9 +134,9 @@ public class FormImpl
|
||||
SAXException
|
||||
{
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
final NodeRef schemaNodeRef = (NodeRef)
|
||||
this.nodeService.getProperty(folderNodeRef,
|
||||
WCMModel.PROP_XML_SCHEMA);
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
final NodeRef schemaNodeRef = (NodeRef)nodeService.getProperty(folderNodeRef,
|
||||
WCMModel.PROP_XML_SCHEMA);
|
||||
return ts.parseXML(schemaNodeRef);
|
||||
}
|
||||
|
||||
@@ -182,24 +153,21 @@ public class FormImpl
|
||||
|
||||
public List<RenderingEngineTemplate> getRenderingEngineTemplates()
|
||||
{
|
||||
final List<AssociationRef> refs = this.nodeService.getTargetAssocs(this.folderNodeRef,
|
||||
WCMModel.ASSOC_RENDERING_ENGINE_TEMPLATES);
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
final List<AssociationRef> refs = nodeService.getTargetAssocs(this.folderNodeRef,
|
||||
WCMModel.ASSOC_RENDERING_ENGINE_TEMPLATES);
|
||||
final List<RenderingEngineTemplate> result = new ArrayList<RenderingEngineTemplate>(refs.size());
|
||||
for (AssociationRef assoc : refs)
|
||||
{
|
||||
final NodeRef retNodeRef = assoc.getTargetRef();
|
||||
for (ChildAssociationRef assoc2 : this.nodeService.getChildAssocs(retNodeRef,
|
||||
WCMModel.ASSOC_RENDITION_PROPERTIES,
|
||||
RegexQNamePattern.MATCH_ALL))
|
||||
for (ChildAssociationRef assoc2 : nodeService.getChildAssocs(retNodeRef,
|
||||
WCMModel.ASSOC_RENDITION_PROPERTIES,
|
||||
RegexQNamePattern.MATCH_ALL))
|
||||
{
|
||||
final NodeRef renditionPropertiesNodeRef = assoc2.getChildRef();
|
||||
|
||||
final RenderingEngineTemplate ret =
|
||||
new RenderingEngineTemplateImpl(retNodeRef,
|
||||
renditionPropertiesNodeRef,
|
||||
this.nodeService,
|
||||
this.contentService,
|
||||
this.templateService);
|
||||
new RenderingEngineTemplateImpl(retNodeRef, renditionPropertiesNodeRef);
|
||||
LOGGER.debug("loaded rendering engine template " + ret);
|
||||
result.add(ret);
|
||||
}
|
||||
@@ -209,10 +177,11 @@ public class FormImpl
|
||||
|
||||
public void registerFormInstanceData(final NodeRef formInstanceDataNodeRef)
|
||||
{
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
final Map<QName, Serializable> props = new HashMap<QName, Serializable>(2, 1.0f);
|
||||
props.put(WCMModel.PROP_PARENT_FORM, this.folderNodeRef);
|
||||
props.put(WCMModel.PROP_PARENT_FORM_NAME, this.getName());
|
||||
this.nodeService.addAspect(formInstanceDataNodeRef, WCMModel.ASPECT_FORM_INSTANCE_DATA, props);
|
||||
nodeService.addAspect(formInstanceDataNodeRef, WCMModel.ASPECT_FORM_INSTANCE_DATA, props);
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
@@ -228,4 +197,10 @@ public class FormImpl
|
||||
"renderingEngineTemplates: " + this.getRenderingEngineTemplates() +
|
||||
"}");
|
||||
}
|
||||
|
||||
private ServiceRegistry getServiceRegistry()
|
||||
{
|
||||
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||
return Repository.getServiceRegistry(fc);
|
||||
}
|
||||
}
|
@@ -55,6 +55,7 @@ import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.TemplateService;
|
||||
@@ -105,7 +106,6 @@ public final class FormsService
|
||||
private final NamespaceService namespaceService;
|
||||
private final SearchService searchService;
|
||||
private final AVMService avmService;
|
||||
private final TemplateService templateService;
|
||||
|
||||
private NodeRef contentFormsNodeRef;
|
||||
|
||||
@@ -116,8 +116,7 @@ public final class FormsService
|
||||
final DictionaryService dictionaryService,
|
||||
final NamespaceService namespaceService,
|
||||
final SearchService searchService,
|
||||
final AVMService avmService,
|
||||
final TemplateService templateService)
|
||||
final AVMService avmService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
this.nodeService = nodeService;
|
||||
@@ -126,7 +125,6 @@ public final class FormsService
|
||||
this.namespaceService = namespaceService;
|
||||
this.searchService = searchService;
|
||||
this.avmService = avmService;
|
||||
this.templateService = templateService;
|
||||
if (INSTANCE == null)
|
||||
INSTANCE = this;
|
||||
}
|
||||
@@ -266,10 +264,7 @@ public final class FormsService
|
||||
{
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("loading form for " + nodeRef);
|
||||
final Form result = new FormImpl(nodeRef,
|
||||
this.nodeService,
|
||||
this.contentService,
|
||||
this.templateService);
|
||||
final Form result = new FormImpl(nodeRef);
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("loaded form " + result);
|
||||
return result;
|
||||
|
@@ -29,15 +29,20 @@ import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.faces.context.FacesContext;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.WCMModel;
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.TemplateNode;
|
||||
import org.alfresco.service.cmr.repository.TemplateService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.wcm.AVMConstants;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -54,42 +59,32 @@ public class RenderingEngineTemplateImpl
|
||||
|
||||
private final NodeRef nodeRef;
|
||||
private final NodeRef renditionPropertiesNodeRef;
|
||||
private final NodeService nodeService;
|
||||
private final ContentService contentService;
|
||||
private final TemplateService templateService;
|
||||
|
||||
protected RenderingEngineTemplateImpl(final NodeRef nodeRef,
|
||||
final NodeRef renditionPropertiesNodeRef,
|
||||
final NodeService nodeService,
|
||||
final ContentService contentService,
|
||||
final TemplateService templateService)
|
||||
final NodeRef renditionPropertiesNodeRef)
|
||||
{
|
||||
this.nodeRef = nodeRef;
|
||||
this.renditionPropertiesNodeRef = renditionPropertiesNodeRef;
|
||||
this.nodeService = nodeService;
|
||||
this.contentService = contentService;
|
||||
this.templateService = templateService;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return (String)
|
||||
this.nodeService.getProperty(this.nodeRef,
|
||||
ContentModel.PROP_NAME);
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
return (String)nodeService.getProperty(this.nodeRef, ContentModel.PROP_NAME);
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return (String)
|
||||
this.nodeService.getProperty(this.nodeRef,
|
||||
ContentModel.PROP_DESCRIPTION);
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
return (String)nodeService.getProperty(this.nodeRef,
|
||||
ContentModel.PROP_DESCRIPTION);
|
||||
}
|
||||
|
||||
public String getOutputPathPattern()
|
||||
{
|
||||
return (String)
|
||||
this.nodeService.getProperty(this.renditionPropertiesNodeRef,
|
||||
WCMModel.PROP_OUTPUT_PATH_PATTERN_FOR_RENDITION);
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
return (String)nodeService.getProperty(this.renditionPropertiesNodeRef,
|
||||
WCMModel.PROP_OUTPUT_PATH_PATTERN_FOR_RENDITION);
|
||||
}
|
||||
|
||||
public NodeRef getNodeRef()
|
||||
@@ -105,8 +100,9 @@ public class RenderingEngineTemplateImpl
|
||||
public InputStream getInputStream()
|
||||
throws IOException
|
||||
{
|
||||
final ContentService contentService = this.getServiceRegistry().getContentService();
|
||||
final ContentReader contentReader =
|
||||
this.contentService.getReader(this.nodeRef, ContentModel.TYPE_CONTENT);
|
||||
contentService.getReader(this.nodeRef, ContentModel.TYPE_CONTENT);
|
||||
return contentReader.getContentInputStream();
|
||||
}
|
||||
|
||||
@@ -117,9 +113,10 @@ public class RenderingEngineTemplateImpl
|
||||
*/
|
||||
public RenderingEngine getRenderingEngine()
|
||||
{
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
final String renderingEngineName = (String)
|
||||
this.nodeService.getProperty(this.nodeRef,
|
||||
WCMModel.PROP_PARENT_RENDERING_ENGINE_NAME);
|
||||
nodeService.getProperty(this.nodeRef,
|
||||
WCMModel.PROP_PARENT_RENDERING_ENGINE_NAME);
|
||||
final FormsService fs = FormsService.getInstance();
|
||||
return fs.getRenderingEngine(renderingEngineName);
|
||||
}
|
||||
@@ -131,62 +128,37 @@ public class RenderingEngineTemplateImpl
|
||||
*/
|
||||
public String getOutputPathForRendition(final NodeRef formInstanceDataNodeRef)
|
||||
{
|
||||
final ServiceRegistry sr = this.getServiceRegistry();
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
final String outputPathPattern = (String)
|
||||
this.nodeService.getProperty(this.renditionPropertiesNodeRef,
|
||||
WCMModel.PROP_OUTPUT_PATH_PATTERN_FOR_RENDITION);
|
||||
nodeService.getProperty(this.renditionPropertiesNodeRef,
|
||||
WCMModel.PROP_OUTPUT_PATH_PATTERN_FOR_RENDITION);
|
||||
final String formInstanceDataAVMPath =
|
||||
AVMNodeConverter.ToAVMVersionPath(formInstanceDataNodeRef).getSecond();
|
||||
|
||||
final TemplateHashModel formInstanceDataModel = new TemplateHashModel()
|
||||
final Map<String, Object> root = new HashMap<String, Object>();
|
||||
|
||||
final String formInstanceDataName = (String)
|
||||
sr.getNodeService().getProperty(formInstanceDataNodeRef, ContentModel.PROP_NAME);
|
||||
root.put("name",
|
||||
formInstanceDataName.replaceAll("(.+)\\..*", "$1"));
|
||||
root.put("extension",
|
||||
sr.getMimetypeService().getExtension(this.getMimetypeForRendition()));
|
||||
|
||||
try
|
||||
{
|
||||
private TemplateModel formInstanceDataModel;
|
||||
final FormsService fs = FormsService.getInstance();
|
||||
root.put("xml", NodeModel.wrap(fs.parseXML(formInstanceDataNodeRef)));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error(e);
|
||||
}
|
||||
|
||||
public TemplateModel get(final String key)
|
||||
{
|
||||
LOGGER.debug("looking up property " + key);
|
||||
if ("xml".equals(key))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (formInstanceDataModel == null)
|
||||
{
|
||||
final FormsService fs = FormsService.getInstance();
|
||||
final Document formInstanceData = fs.parseXML(formInstanceDataNodeRef);
|
||||
formInstanceDataModel = NodeModel.wrap(formInstanceData);
|
||||
}
|
||||
return formInstanceDataModel;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final Map<QName, Serializable> properties =
|
||||
nodeService.getProperties(formInstanceDataNodeRef);
|
||||
for (QName qname : properties.keySet())
|
||||
{
|
||||
if (qname.getLocalName().equals(key))
|
||||
{
|
||||
return new SimpleScalar((String)properties.get(qname));
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
final Map<String, TemplateModel> root = new HashMap<String, TemplateModel>();
|
||||
root.put("formInstanceData", formInstanceDataModel);
|
||||
root.put("node", new TemplateNode(formInstanceDataNodeRef, sr, null));
|
||||
root.put("date", new SimpleDate(new Date(), SimpleDate.DATETIME));
|
||||
|
||||
final TemplateService templateService = sr.getTemplateService();
|
||||
String result = templateService.processTemplateString(null,
|
||||
outputPathPattern,
|
||||
new SimpleHash(root));
|
||||
@@ -203,17 +175,25 @@ public class RenderingEngineTemplateImpl
|
||||
*/
|
||||
public String getMimetypeForRendition()
|
||||
{
|
||||
return (String)
|
||||
this.nodeService.getProperty(this.renditionPropertiesNodeRef,
|
||||
WCMModel.PROP_MIMETYPE_FOR_RENDITION);
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
return (String)nodeService.getProperty(this.renditionPropertiesNodeRef,
|
||||
WCMModel.PROP_MIMETYPE_FOR_RENDITION);
|
||||
}
|
||||
|
||||
public void registerRendition(final NodeRef renditionNodeRef,
|
||||
final NodeRef primaryFormInstanceDataNodeRef)
|
||||
{
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
final Map<QName, Serializable> props = new HashMap<QName, Serializable>(2, 1.0f);
|
||||
props.put(WCMModel.PROP_PARENT_RENDERING_ENGINE_TEMPLATE, this.nodeRef);
|
||||
props.put(WCMModel.PROP_PRIMARY_FORM_INSTANCE_DATA, primaryFormInstanceDataNodeRef);
|
||||
this.nodeService.addAspect(renditionNodeRef, WCMModel.ASPECT_RENDITION, props);
|
||||
nodeService.addAspect(renditionNodeRef, WCMModel.ASPECT_RENDITION, props);
|
||||
}
|
||||
}
|
||||
|
||||
private ServiceRegistry getServiceRegistry()
|
||||
{
|
||||
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||
return Repository.getServiceRegistry(fc);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user