Пример #1
0
 /**
  * This method should be called only if it has been determined that field schema should be created
  * (or deleted). Create the {@link CustomField} for the metadata API to use during deploy
  *
  * @param cmd the class metadata for the entity
  * @param storeManager the store manager
  */
 public void createCustomFields(AbstractClassMetaData cmd, ForceStoreManager storeManager) {
   synchronized (cmd) {
     try {
       if (cmd.isEmbeddedOnly() || PersistenceUtils.isReadOnlySchema(cmd, false)) return;
       ForceManagedConnection mconn = storeManager.createConnection();
       try {
         ForceColumnMetaData cols = new ForceColumnMetaData(cmd, tableImpl, storeManager);
         cols.createFieldSchema(mconn.getNamespace());
         if (customObject == null) {
           createCustomObjectStub();
         }
         cols.addFieldsToObject(customObject);
       } catch (NucleusException ce) {
         throw ce;
       } catch (Exception e) {
         throw new NucleusException(e.getMessage(), e);
       } finally {
         mconn.close();
       }
     } catch (Exception e) {
       throw new NucleusUserException(
           "Exception during initialisation of metadata for " + cmd.getFullClassName(), e);
     }
   }
 }
Пример #2
0
  /**
   * if a {@link CustomObject} needed to be created for this entity, pass it to the schema writer
   * which will store it and then later write all objects and fields at once. Pass all fields on the
   * custom object to the schema writer as well
   *
   * @param storeManager the store manager
   * @param mconn the managed connection that contains connections for the Force.com APIs
   */
  public void emit(ForceStoreManager storeManager, ForceManagedConnection mconn) {
    try {
      ForceSchemaWriter schemaWriter = storeManager.getSchemaWriter();
      if (customObject != null) {
        schemaWriter.addCustomObject(customObject, cmd, storeManager, this);

        for (CustomField field : customObject.getFields()) {
          schemaWriter.addCustomField(customObject, field);
        }

        customObject = null;
      }
    } catch (Exception x) {
      throw new NucleusException(x.getMessage(), x);
    }
    // Clear metadata in tableImpl
    tableImpl.clearMetaData();
  }