Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.api
Class DocumentModelFactory

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

public class DocumentModelFactory
extends Object

Bridge between a DocumentModel and a Document for creation / update.


Method Summary
static DataModel createDataModel(Document doc, Schema schema)
          Creates a data model from a document and a schema.
static DocumentModelImpl createDocumentModel(Document doc)
           
static DocumentModelImpl createDocumentModel(Document doc, String[] schemas)
          Creates a document model for an existing document.
static DocumentModelImpl createDocumentModel(DocumentType docType)
           
static DocumentModelImpl createDocumentModel(String docType)
          Returns a document model computed from its type, querying the SchemaManager service.
static DocumentModelImpl createDocumentModel(String sessionId, DocumentType docType)
          Creates a document model for a new document.
static DocumentModelImpl createDocumentModel(String parentPath, String id, DocumentType docType, String[] schemas)
          Deprecated. unused
static DocumentModel newDocument(DocumentModel parent, DocumentType type)
          Deprecated. unused
static DocumentModel newDocument(DocumentModel parent, String type)
          Deprecated. unused
static DocumentModel newDocument(DocumentModel parent, String name, DocumentType type)
          Deprecated. unused
static DocumentModel newDocument(DocumentModel parent, String name, String type)
          Deprecated. unused
static void prefetchValues(Property property, String start, String xpath, Prefetch prefetch, Set<String> docSchemas)
          Computes the keys and values of a document for a given xpath name.
static DocumentModel.DocumentModelRefresh 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newDocument

@Deprecated
public static DocumentModel newDocument(DocumentModel parent,
                                                   String type)
Deprecated. unused


newDocument

@Deprecated
public static DocumentModel newDocument(DocumentModel parent,
                                                   String name,
                                                   String type)
Deprecated. unused


newDocument

@Deprecated
public static DocumentModel newDocument(DocumentModel parent,
                                                   DocumentType type)
Deprecated. unused


newDocument

@Deprecated
public static DocumentModel newDocument(DocumentModel parent,
                                                   String name,
                                                   DocumentType type)
Deprecated. unused


createDocumentModel

public static DocumentModelImpl createDocumentModel(Document doc)
                                             throws DocumentException
Throws:
DocumentException

createDocumentModel

public static DocumentModelImpl createDocumentModel(Document doc,
                                                    String[] schemas)
                                             throws DocumentException
Creates a document model for an existing document.

Parameters:
doc - the document
schemas - the schemas to prefetch (deprecated), or null
Returns:
the new document model
Throws:
DocumentException

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 sessionId,
                                                    DocumentType docType)
                                             throws DocumentException
Creates a document model for a new document.

Initializes the proper data models according to the type info.

Parameters:
sessionId - the CoreSession id
docType - the document type
Returns:
the document model
Throws:
DocumentException

createDocumentModel

public static DocumentModelImpl createDocumentModel(DocumentType docType)
                                             throws DocumentException
Throws:
DocumentException

createDocumentModel

@Deprecated
public static DocumentModelImpl createDocumentModel(String parentPath,
                                                               String id,
                                                               DocumentType docType,
                                                               String[] schemas)
                                             throws DocumentException
Deprecated. unused

Throws:
DocumentException

createDataModel

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

Throws:
DocumentException

writeDocumentModel

public static DocumentModel writeDocumentModel(DocumentModel docModel,
                                               Document doc)
                                        throws DocumentException,
                                               ClientException
Writes a document model to a document. Returns the re-read document model.

Throws:
DocumentException
ClientException

refreshDocumentModel

public static DocumentModel.DocumentModelRefresh refreshDocumentModel(Document doc,
                                                                      int flags,
                                                                      String[] schemas)
                                                               throws DocumentException,
                                                                      LifeCycleException,
                                                                      Exception
Gets what's to refresh in a model (except for the ACPs, which need the session).

Throws:
DocumentException
LifeCycleException
Exception

prefetchValues

public static void prefetchValues(Property property,
                                  String start,
                                  String xpath,
                                  Prefetch prefetch,
                                  Set<String> docSchemas)
Computes the keys and values of a document for a given xpath name.

There may be several results returned as the name may contain wildcards for the complex lists indices.

INTERNAL

Parameters:
property - the document or a sub-property container
start - the xpath that led to this property
xpath - the canonical xpath with allowed list wildcards
prefetch - the prefetch to fill
docSchemas - the available schemas on the document

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.