Examples of EOSchemaGeneration


Examples of com.webobjects.eoaccess.EOSchemaGeneration

        public WOComponent update() {
            sql = "";
            try {
                EOAdaptor adaptor = EOAdaptor.adaptorWithModel(model);
                EOSchemaGeneration synchronizationFactory = adaptor.synchronizationFactory();
                NSArray array = synchronizationFactory.createTableStatementsForEntityGroup(new NSArray(selectedEntity));
                sql =  ((NSArray)array.valueForKeyPath("statement")).componentsJoinedByString(";\n");
            } catch(Exception ex) {
                sql = "" + ex;
            }
            return null;
View Full Code Here

Examples of com.webobjects.eoaccess.EOSchemaGeneration

   */
  @SuppressWarnings("unchecked")
  public static void upgrade(EOEditingContext editingContext, EOAdaptorChannel channel, EOModel model, String entityName, String tagsRelationshipName, String tagEntityName) throws SQLException {
    EOEntity joinEntity = ERTaggableEntity.registerTaggable(model.entityNamed(entityName), tagsRelationshipName, model.modelGroup().entityNamed(tagEntityName), null);
    EODatabaseContext databaseContext = EODatabaseContext.registeredDatabaseContextForModel(model, editingContext);
    EOSchemaGeneration generation = databaseContext.adaptorContext().adaptor().synchronizationFactory();
    NSArray<EOSQLExpression> createTableStatements = generation.createTableStatementsForEntityGroup(new NSArray<EOEntity>(joinEntity));
    ERXJDBCUtilities.executeUpdateScript(channel, ERXMigrationDatabase._stringsForExpressions(createTableStatements));
  }
View Full Code Here

Examples of com.webobjects.eoaccess.EOSchemaGeneration

   *
   * @return an array of EOSQLExpressions for creating this table
   */
  @SuppressWarnings("unchecked")
  public NSArray<EOSQLExpression> _createExpressions() {
    EOSchemaGeneration schemaGeneration = _database.synchronizationFactory();
    NSArray<EOSQLExpression> expressions = schemaGeneration.createTableStatementsForEntityGroup(new NSArray<EOEntity>(_newEntity()));
    ERXMigrationDatabase._ensureNotEmpty(expressions, "create table", true);
    return expressions;
  }
View Full Code Here

Examples of com.webobjects.eoaccess.EOSchemaGeneration

   *
   * @return an array of EOSQLExpressions for dropping this table
   */
  @SuppressWarnings("unchecked")
  public NSArray<EOSQLExpression> _dropExpressions() {
    EOSchemaGeneration schemaGeneration = _database.synchronizationFactory();
    NSArray<EOSQLExpression> expressions = schemaGeneration.dropTableStatementsForEntityGroup(new NSArray<EOEntity>(_blankEntity()));
    ERXMigrationDatabase._ensureNotEmpty(expressions, "drop table", true);
    return expressions;
  }
View Full Code Here

Examples of com.webobjects.eoaccess.EOSchemaGeneration

   *
   * @return an array of EOSQLExpressions for setting the primary key constraint of this table
   */
  @SuppressWarnings("unchecked")
  public NSArray<EOSQLExpression> _setPrimaryKeyExpressions(ERXMigrationColumn... columns) {
    EOSchemaGeneration schemaGeneration = _database.synchronizationFactory();
    EOEntity entity = columns[0].table()._blankEntity();
    NSMutableArray<EOAttribute> attributes = new NSMutableArray<EOAttribute>();
    for (ERXMigrationColumn column : columns) {
      EOAttribute attribute = column._newAttribute(entity);
      attributes.addObject(attribute);
    }
    entity.setPrimaryKeyAttributes(attributes);
    NSArray<EOSQLExpression> expressions = schemaGeneration.primaryKeyConstraintStatementsForEntityGroup(new NSArray<EOEntity>(entity));
    ERXMigrationDatabase._ensureNotEmpty(expressions, "add primary key", true);
    NSArray<EOSQLExpression> supportExpressions = schemaGeneration.primaryKeySupportStatementsForEntityGroup(new NSArray<EOEntity>(entity));
    return expressions.arrayByAddingObjectsFromArray(supportExpressions);
  }
View Full Code Here

Examples of com.webobjects.eoaccess.EOSchemaGeneration

   * @param destinationColumn the destination columns of the relationship (should be the PK of the destination table)
   * @return an array of EOSQLExpressions for adding a foreign key constraint to this table
   */
  @SuppressWarnings("unchecked")
  public NSArray<EOSQLExpression> _addForeignKeyExpressions(ERXMigrationColumn sourceColumn, ERXMigrationColumn destinationColumn) {
    EOSchemaGeneration schemaGeneration = _database.synchronizationFactory();
    NSArray<EOSQLExpression> expressions = schemaGeneration.foreignKeyConstraintStatementsForRelationship(_newRelationship(new ERXMigrationColumn[] { sourceColumn }, new ERXMigrationColumn[] { destinationColumn }));
    ERXMigrationDatabase._ensureNotEmpty(expressions, "add foreign key", false);
    return expressions;
  }
View Full Code Here

Examples of com.webobjects.eoaccess.EOSchemaGeneration

   * @param destinationColumns the destination columns of the relationship (should be the PKs of the destination table)
   * @return an array of EOSQLExpressions for adding a foreign key constraint to this table
   */
  @SuppressWarnings("unchecked")
  public NSArray<EOSQLExpression> _addForeignKeyExpressions(ERXMigrationColumn[] sourceColumns, ERXMigrationColumn[] destinationColumns) {
    EOSchemaGeneration schemaGeneration = _database.synchronizationFactory();
    NSArray<EOSQLExpression> expressions = schemaGeneration.foreignKeyConstraintStatementsForRelationship(_newRelationship(sourceColumns, destinationColumns));
    ERXMigrationDatabase._ensureNotEmpty(expressions, "add foreign key", false);
    return expressions;
  }
View Full Code Here

Examples of com.webobjects.eoaccess.EOSchemaGeneration

   * @param columns the primary key columns to drop
   * @return an array of EOSQLExpressions for removing the primary key constraint of this table
   */
  @SuppressWarnings("unchecked")
  public NSArray<EOSQLExpression> _dropPrimaryKeyExpressions(ERXMigrationColumn... columns) {
    EOSchemaGeneration schemaGeneration = _database.synchronizationFactory();
    EOEntity entity = columns[0].table()._blankEntity();
    NSMutableArray<EOAttribute> attributes = new NSMutableArray<EOAttribute>();
    for (ERXMigrationColumn column : columns) {
      EOAttribute attribute = column._newAttribute(entity);
      attributes.addObject(attribute);
    }
    entity.setPrimaryKeyAttributes(attributes);
    NSArray<EOSQLExpression> expressions = schemaGeneration.dropPrimaryKeySupportStatementsForEntityGroup(new NSArray<EOEntity>(entity));
    ERXMigrationDatabase._ensureNotEmpty(expressions, "drop primary key", true);
    return expressions;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.