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 ofTemplateBasedDocument
adapter. This adapter mainly expect from the underlyingDocumentModel
to have the "TemplateBased" facet- Author:
- Tiry ([email protected])
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected TemplateBindings
bindings
static String
TEMPLATEBASED_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 void
doSave()
protected OutputFormatDescriptor
getOutputFormatDescriptor(String outputFormat)
List<TemplateInput>
getParams(String templateName)
Retrieve parameters for the associated templateTemplateSourceDocument
getSourceTemplate(String templateName)
Retrieve theTemplateSourceDocument
for a given template nameDocumentModel
getSourceTemplateDoc(String templateName)
Retrieve the TemplateDocumentModel
for a given template nameDocumentRef
getSourceTemplateDocRef(String templateName)
Retrieve the TemplateDocumentRef
for a given template nameList<TemplateSourceDocument>
getSourceTemplates()
List allTemplateSourceDocument
s that are bound to the underlyingDocumentModel
Blob
getTemplateBlob(String templateName)
Return theBlob
of the associated templateString
getTemplateNameForRendition(String renditionName)
Find the template associated to a given RenditionNameList<String>
getTemplateNames()
Get the names of all the associated templatesprotected TemplateProcessor
getTemplateProcessor(String templateName)
String
getTemplateType(String templateName)
Return the template type for a given template nameboolean
hasEditableParams(String templateName)
Indicate of the associated Template has editable parameters or notboolean
hasParams(String templateName)
Indicate of the associated Template requires parameters or notDocumentModel
initializeFromTemplate(boolean save)
DocumentModel
initializeFromTemplate(String templateName, boolean save)
Initialize the template parameters from the associated templateprotected OperationContext
initOperationContext(Blob blob, String templateName)
boolean
isBidirectional()
DocumentModel
removeTemplateBinding(String templateName, boolean save)
Detach a template from the underlyingDocumentModel
Blob
renderAndStoreAsAttachment(String templateName, boolean save)
Render the named template against the underlying DocumentModel and store the result in the main BlobBlob
renderWithTemplate(String templateName)
Render the named template against the underlying DocumentModelDocumentModel
saveParams(String templateName, List<TemplateInput> params, boolean save)
Save parameters changes.protected void
setBlob(Blob blob)
DocumentModel
setTemplate(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:TemplateBasedDocument
Associate the document to a Template.- Specified by:
setTemplate
in 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:TemplateBasedDocument
Detach a template from the underlyingDocumentModel
- Specified by:
removeTemplateBinding
in interfaceTemplateBasedDocument
-
getSourceTemplate
public TemplateSourceDocument getSourceTemplate(String templateName)
Description copied from interface:TemplateBasedDocument
Retrieve theTemplateSourceDocument
for a given template name- Specified by:
getSourceTemplate
in interfaceTemplateBasedDocument
- Parameters:
templateName
- name of the template- Returns:
- the
TemplateSourceDocument
-
getSourceTemplateDocRef
public DocumentRef getSourceTemplateDocRef(String templateName)
Description copied from interface:TemplateBasedDocument
Retrieve the TemplateDocumentRef
for a given template name- Specified by:
getSourceTemplateDocRef
in interfaceTemplateBasedDocument
- Parameters:
templateName
- name of the template- Returns:
- the associated template
DocumentRef
-
getSourceTemplateDoc
public DocumentModel getSourceTemplateDoc(String templateName)
Description copied from interface:TemplateBasedDocument
Retrieve the TemplateDocumentModel
for a given template name- Specified by:
getSourceTemplateDoc
in interfaceTemplateBasedDocument
- Parameters:
templateName
- name of the template- Returns:
- the associated template
DocumentModel
-
getSourceTemplates
public List<TemplateSourceDocument> getSourceTemplates()
Description copied from interface:TemplateBasedDocument
List allTemplateSourceDocument
s that are bound to the underlyingDocumentModel
- Specified by:
getSourceTemplates
in interfaceTemplateBasedDocument
-
getTemplateType
public String getTemplateType(String templateName)
Description copied from interface:TemplateBasedDocument
Return the template type for a given template name- Specified by:
getTemplateType
in interfaceTemplateBasedDocument
-
initializeFromTemplate
public DocumentModel initializeFromTemplate(boolean save)
-
initializeFromTemplate
public DocumentModel initializeFromTemplate(String templateName, boolean save)
Description copied from interface:TemplateBasedDocument
Initialize the template parameters from the associated template- Specified by:
initializeFromTemplate
in interfaceTemplateBasedDocument
save
- flag to indicate if target DocumentModel must be saved or not- Returns:
- the updated DocumentModel
-
doSave
protected void doSave()
- Overrides:
doSave
in classAbstractTemplateDocument
-
setBlob
protected void setBlob(Blob blob)
-
renderWithTemplate
public Blob renderWithTemplate(String templateName)
Description copied from interface:TemplateBasedDocument
Render the named template against the underlying DocumentModel- Specified by:
renderWithTemplate
in 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:TemplateBasedDocument
Render the named template against the underlying DocumentModel and store the result in the main Blob- Specified by:
renderAndStoreAsAttachment
in interfaceTemplateBasedDocument
save
- 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:TemplateBasedDocument
Return theBlob
of the associated template- Specified by:
getTemplateBlob
in interfaceTemplateBasedDocument
-
hasParams
public boolean hasParams(String templateName)
Description copied from interface:TemplateBasedDocument
Indicate of the associated Template requires parameters or not- Specified by:
hasParams
in interfaceTemplateBasedDocument
-
getParams
public List<TemplateInput> getParams(String templateName)
Description copied from interface:TemplateBasedDocument
Retrieve parameters for the associated template- Specified by:
getParams
in interfaceTemplateBasedDocument
-
saveParams
public DocumentModel saveParams(String templateName, List<TemplateInput> params, boolean save)
Description copied from interface:TemplateBasedDocument
Save parameters changes.- Specified by:
saveParams
in interfaceTemplateBasedDocument
params
- 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:TemplateBasedDocument
Indicate of the associated Template has editable parameters or not- Specified by:
hasEditableParams
in interfaceTemplateBasedDocument
-
getTemplateNameForRendition
public String getTemplateNameForRendition(String renditionName)
Description copied from interface:TemplateBasedDocument
Find the template associated to a given RenditionName- Specified by:
getTemplateNameForRendition
in interfaceTemplateBasedDocument
- Returns:
- the template name if any, null otherwise
-
getTemplateNames
public List<String> getTemplateNames()
Description copied from interface:TemplateBasedDocument
Get the names of all the associated templates- Specified by:
getTemplateNames
in interfaceTemplateBasedDocument
-
-