Class DocumentModelFactory

java.lang.Object
org.nuxeo.ecm.core.api.DocumentModelFactory

public class DocumentModelFactory extends Object
Bridge between a DocumentModel and a Document for creation / update.
  • Method Details

    • createDocumentModel

      public static DocumentModelImpl createDocumentModel(Document doc, CoreSession coreSession)
      Creates a document model for an existing document.
      Parameters:
      doc - the document
      Returns:
      the new document model
    • createDocumentModel

      public static DocumentModelImpl createDocumentModel(String docType)
      Returns a document model computed from its type, querying the SchemaManager 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 type
      parentRef - the parent ref
      Returns:
      the document model
      Since:
      11.1
    • createDataModel

      public static DataModel createDataModel(Document doc, Schema schema)
      Creates a data model from a document and a schema. If the document is null, just creates empty data models.
    • writeDocumentModel

      public static DocumentModel writeDocumentModel(DocumentModel docModel, Document doc)
      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 public static DocumentModel createDocumentModel(String type, String id)
      Deprecated.
      since 11.1, unused
      Create 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