コード例 #1
0
  /**
   * This method should be called only if it has been determined that table schema should be created
   * (or deleted). Create the {@link CustomObject} for the metadata API to use during deploy
   *
   * @param cmd the class metadata for the entity
   * @param storeManager the store manager
   * @param mconn the managed connection that contains connections to the Force.com APIs
   */
  public void createCustomObject(
      AbstractClassMetaData cmd, ForceStoreManager storeManager, ForceManagedConnection mconn) {
    String shortName = removeCustomThingSuffix(tableImpl.getTableName().getName());

    if (isReadOnlyTable) {
      throw new NucleusUserException("Cannot create readOnlySchema custom object: " + shortName);
    }

    createCustomObjectStub();

    customObject.setDescription(shortName + ": Persistenceforce created custom object");
    customObject.setDeploymentStatus(DeploymentStatus.Deployed);
    customObject.setSharingModel(SharingModel.ReadWrite);
    customObject.setLabel(shortName);
    customObject.setPluralLabel(shortName);

    CustomField nf = new CustomField();
    nf.setType(FieldType.Text);
    nf.setLabel("name");
    nf.setFullName("name");
    nf.setDescription("name");

    customObject.setNameField(nf);

    Map<String, String> classExtensions = PersistenceUtils.getForceExtensions(cmd);
    String value = classExtensions.get("enableFeeds");
    if (value != null) {
      customObject.setEnableFeeds(Boolean.valueOf(value));
    }
  }
コード例 #2
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);
     }
   }
 }