public void save(String storeBasePath) throws Exception {

    PersistenceManager persistenceManager = getContext().getPersistenceManager();

    if (persistenceManager == null) throw new NullPointerException("Persistence manager not set");

    PersistedFormDocument formDocument = persistenceManager.saveForm(this, storeBasePath);
    setFormType(formDocument.getFormType());
    setFormId(formDocument.getFormId());
  }
  public void saveAllVersions(Long parentId) throws Exception {

    PersistenceManager persistenceManager = getContext().getPersistenceManager();

    if (persistenceManager == null) throw new NullPointerException("Persistence manager not set");

    PersistedFormDocument formDocument = persistenceManager.saveAllVersions(this, parentId);
    setFormType(formDocument.getFormType());
    setFormId(formDocument.getFormId());
  }
  public void lazyLoadDocument(PersistedFormDocument persistedForm) {

    if (persistedForm != null) {
      setFormId(persistedForm.getFormId());
      setFormType(persistedForm.getFormType());
      setFormVersion(persistedForm.getVersion());
    }

    setContainerElement(FormManagerUtil.getComponentsContainerElement(getXformsDocument()));

    persistedFormForLazyLoading = persistedForm;
  }
  private void loadDocumentInternal(PersistedFormDocument persistedForm) {

    Document xformsXmlDoc = getXformsDocument();

    if (persistedForm != null) {
      setFormId(persistedForm.getFormId());
      setFormType(persistedForm.getFormType());
      setFormVersion(persistedForm.getVersion());
    }

    setContainerElement(FormManagerUtil.getComponentsContainerElement(xformsXmlDoc));
    loadContainerComponents();
    setProperties();

    loaded = true;
  }