Package org.nuxeo.ecm.core.api
Class DocumentModelFactory
java.lang.Object
org.nuxeo.ecm.core.api.DocumentModelFactory
Bridge between a
DocumentModel
and a Document
for creation / update.-
Method Summary
Modifier and TypeMethodDescriptionstatic DataModel
createDataModel
(Document doc, Schema schema) Creates a data model from a document and a schema.static DocumentModelImpl
createDocumentModel
(String docType) Returns a document model computed from its type, querying theSchemaManager
service.static DocumentModel
createDocumentModel
(String type, String id) Deprecated.since 11.1, unusedstatic DocumentModelImpl
createDocumentModel
(String typeName, DocumentRef parentRef, CoreSession coreSession) Creates a document model for a new document.static DocumentModelImpl
createDocumentModel
(Document doc, CoreSession coreSession) Creates a document model for an existing document.refreshDocumentModel
(Document doc, int flags, String[] schemas) Gets what's to refresh in a model (except for the ACPs, which need the session).static DocumentModel
writeDocumentModel
(DocumentModel docModel, Document doc) Writes a document model to a document.static DocumentModel
writeDocumentModel
(DocumentModel docModel, Document doc, boolean create) Writes a document model to a document.
-
Method Details
-
createDocumentModel
Creates a document model for an existing document.- Parameters:
doc
- the document- Returns:
- the new document model
-
createDocumentModel
Returns a document model computed from its type, querying theSchemaManager
service.The created document model is not linked to any core session.
- Since:
- 5.4.2
-
createDocumentModel
public static DocumentModelImpl createDocumentModel(String typeName, DocumentRef parentRef, CoreSession coreSession) Creates a document model for a new document.Initializes the proper data models according to the type info.
- Parameters:
typeName
- the document typeparentRef
- the parent ref- Returns:
- the document model
- Since:
- 11.1
-
createDataModel
Creates a data model from a document and a schema. If the document is null, just creates empty data models. -
writeDocumentModel
Writes a document model to a document. Returns the re-read document model. -
writeDocumentModel
public static DocumentModel writeDocumentModel(DocumentModel docModel, Document doc, boolean create) Writes a document model to a document. Returns the re-read document model.- Since:
- 11.1
-
refreshDocumentModel
public static DocumentModel.DocumentModelRefresh refreshDocumentModel(Document doc, int flags, String[] schemas) throws LifeCycleException Gets what's to refresh in a model (except for the ACPs, which need the session).- Throws:
LifeCycleException
-
createDocumentModel
Deprecated.since 11.1, unusedCreate an empty documentmodel for a given type with its id already setted. This can be useful when trying to attach a documentmodel that has been serialized and modified.- Since:
- 5.7.2
-