Package org.nuxeo.template.adapters.doc
Class TemplateBasedDocumentAdapterImpl
- java.lang.Object
-
- org.nuxeo.template.adapters.AbstractTemplateDocument
-
- org.nuxeo.template.adapters.doc.TemplateBasedDocumentAdapterImpl
-
- All Implemented Interfaces:
Serializable,TemplateBasedDocument
public class TemplateBasedDocumentAdapterImpl extends AbstractTemplateDocument implements Serializable, TemplateBasedDocument
Default implementation ofTemplateBasedDocumentadapter. This adapter mainly expect from the underlyingDocumentModelto have the "TemplateBased" facet- Author:
- Tiry (tdelprat@nuxeo.com)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected TemplateBindingsbindingsstatic StringTEMPLATEBASED_FACET-
Fields inherited from class org.nuxeo.template.adapters.AbstractTemplateDocument
adaptedDoc
-
-
Constructor Summary
Constructors Constructor Description TemplateBasedDocumentAdapterImpl(DocumentModel doc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoSave()protected OutputFormatDescriptorgetOutputFormatDescriptor(String outputFormat)List<TemplateInput>getParams(String templateName)Retrieve parameters for the associated templateTemplateSourceDocumentgetSourceTemplate(String templateName)Retrieve theTemplateSourceDocumentfor a given template nameDocumentModelgetSourceTemplateDoc(String templateName)Retrieve the TemplateDocumentModelfor a given template nameDocumentRefgetSourceTemplateDocRef(String templateName)Retrieve the TemplateDocumentReffor a given template nameList<TemplateSourceDocument>getSourceTemplates()List allTemplateSourceDocuments that are bound to the underlyingDocumentModelBlobgetTemplateBlob(String templateName)Return theBlobof the associated templateStringgetTemplateNameForRendition(String renditionName)Find the template associated to a given RenditionNameList<String>getTemplateNames()Get the names of all the associated templatesprotected TemplateProcessorgetTemplateProcessor(String templateName)StringgetTemplateType(String templateName)Return the template type for a given template namebooleanhasEditableParams(String templateName)Indicate of the associated Template has editable parameters or notbooleanhasParams(String templateName)Indicate of the associated Template requires parameters or notDocumentModelinitializeFromTemplate(boolean save)DocumentModelinitializeFromTemplate(String templateName, boolean save)Initialize the template parameters from the associated templateprotected OperationContextinitOperationContext(Blob blob, String templateName)booleanisBidirectional()DocumentModelremoveTemplateBinding(String templateName, boolean save)Detach a template from the underlyingDocumentModelBlobrenderAndStoreAsAttachment(String templateName, boolean save)Render the named template against the underlying DocumentModel and store the result in the main BlobBlobrenderWithTemplate(String templateName)Render the named template against the underlying DocumentModelDocumentModelsaveParams(String templateName, List<TemplateInput> params, boolean save)Save parameters changes.protected voidsetBlob(Blob blob)DocumentModelsetTemplate(DocumentModel template, boolean save)Associate the document to a Template.-
Methods inherited from class org.nuxeo.template.adapters.AbstractTemplateDocument
getAdaptedDoc, getSession, save
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.template.api.adapters.TemplateBasedDocument
getAdaptedDoc
-
-
-
-
Field Detail
-
TEMPLATEBASED_FACET
public static final String TEMPLATEBASED_FACET
- See Also:
- Constant Field Values
-
bindings
protected final TemplateBindings bindings
-
-
Constructor Detail
-
TemplateBasedDocumentAdapterImpl
public TemplateBasedDocumentAdapterImpl(DocumentModel doc)
-
-
Method Detail
-
setTemplate
public DocumentModel setTemplate(DocumentModel template, boolean save)
Description copied from interface:TemplateBasedDocumentAssociate the document to a Template.- Specified by:
setTemplatein interfaceTemplateBasedDocument- Parameters:
template- DocumentModel holding the templatesave- flag to indicate if target DocumentModel must be saved or not- Returns:
- the updated DocumentModel
-
removeTemplateBinding
public DocumentModel removeTemplateBinding(String templateName, boolean save)
Description copied from interface:TemplateBasedDocumentDetach a template from the underlyingDocumentModel- Specified by:
removeTemplateBindingin interfaceTemplateBasedDocument
-
getSourceTemplate
public TemplateSourceDocument getSourceTemplate(String templateName)
Description copied from interface:TemplateBasedDocumentRetrieve theTemplateSourceDocumentfor a given template name- Specified by:
getSourceTemplatein interfaceTemplateBasedDocument- Parameters:
templateName- name of the template- Returns:
- the
TemplateSourceDocument
-
getSourceTemplateDocRef
public DocumentRef getSourceTemplateDocRef(String templateName)
Description copied from interface:TemplateBasedDocumentRetrieve the TemplateDocumentReffor a given template name- Specified by:
getSourceTemplateDocRefin interfaceTemplateBasedDocument- Parameters:
templateName- name of the template- Returns:
- the associated template
DocumentRef
-
getSourceTemplateDoc
public DocumentModel getSourceTemplateDoc(String templateName)
Description copied from interface:TemplateBasedDocumentRetrieve the TemplateDocumentModelfor a given template name- Specified by:
getSourceTemplateDocin interfaceTemplateBasedDocument- Parameters:
templateName- name of the template- Returns:
- the associated template
DocumentModel
-
getSourceTemplates
public List<TemplateSourceDocument> getSourceTemplates()
Description copied from interface:TemplateBasedDocumentList allTemplateSourceDocuments that are bound to the underlyingDocumentModel- Specified by:
getSourceTemplatesin interfaceTemplateBasedDocument
-
getTemplateType
public String getTemplateType(String templateName)
Description copied from interface:TemplateBasedDocumentReturn the template type for a given template name- Specified by:
getTemplateTypein interfaceTemplateBasedDocument
-
initializeFromTemplate
public DocumentModel initializeFromTemplate(boolean save)
-
initializeFromTemplate
public DocumentModel initializeFromTemplate(String templateName, boolean save)
Description copied from interface:TemplateBasedDocumentInitialize the template parameters from the associated template- Specified by:
initializeFromTemplatein interfaceTemplateBasedDocumentsave- flag to indicate if target DocumentModel must be saved or not- Returns:
- the updated DocumentModel
-
doSave
protected void doSave()
- Overrides:
doSavein classAbstractTemplateDocument
-
renderWithTemplate
public Blob renderWithTemplate(String templateName)
Description copied from interface:TemplateBasedDocumentRender the named template against the underlying DocumentModel- Specified by:
renderWithTemplatein interfaceTemplateBasedDocument- Returns:
- the resulting
Blob
-
initOperationContext
protected OperationContext initOperationContext(Blob blob, String templateName)
-
renderAndStoreAsAttachment
public Blob renderAndStoreAsAttachment(String templateName, boolean save)
Description copied from interface:TemplateBasedDocumentRender the named template against the underlying DocumentModel and store the result in the main Blob- Specified by:
renderAndStoreAsAttachmentin interfaceTemplateBasedDocumentsave- flag to indicate if target DocumentModel must be saved or not- Returns:
- the resulting
Blob
-
isBidirectional
public boolean isBidirectional()
-
getTemplateBlob
public Blob getTemplateBlob(String templateName)
Description copied from interface:TemplateBasedDocumentReturn theBlobof the associated template- Specified by:
getTemplateBlobin interfaceTemplateBasedDocument
-
hasParams
public boolean hasParams(String templateName)
Description copied from interface:TemplateBasedDocumentIndicate of the associated Template requires parameters or not- Specified by:
hasParamsin interfaceTemplateBasedDocument
-
getParams
public List<TemplateInput> getParams(String templateName)
Description copied from interface:TemplateBasedDocumentRetrieve parameters for the associated template- Specified by:
getParamsin interfaceTemplateBasedDocument
-
saveParams
public DocumentModel saveParams(String templateName, List<TemplateInput> params, boolean save)
Description copied from interface:TemplateBasedDocumentSave parameters changes.- Specified by:
saveParamsin interfaceTemplateBasedDocumentparams- the updated list of parameterssave- flag to indicate if target DocumentModel must be saved or not
-
getTemplateProcessor
protected TemplateProcessor getTemplateProcessor(String templateName)
-
getOutputFormatDescriptor
protected OutputFormatDescriptor getOutputFormatDescriptor(String outputFormat)
-
hasEditableParams
public boolean hasEditableParams(String templateName)
Description copied from interface:TemplateBasedDocumentIndicate of the associated Template has editable parameters or not- Specified by:
hasEditableParamsin interfaceTemplateBasedDocument
-
getTemplateNameForRendition
public String getTemplateNameForRendition(String renditionName)
Description copied from interface:TemplateBasedDocumentFind the template associated to a given RenditionName- Specified by:
getTemplateNameForRenditionin interfaceTemplateBasedDocument- Returns:
- the template name if any, null otherwise
-
getTemplateNames
public List<String> getTemplateNames()
Description copied from interface:TemplateBasedDocumentGet the names of all the associated templates- Specified by:
getTemplateNamesin interfaceTemplateBasedDocument
-
-