Skip to content

Commit

Permalink
Update FrontBase plugin to use EOSchemaSyncronization.
Browse files Browse the repository at this point in the history
  • Loading branch information
spelletier committed Jan 15, 2014
1 parent 9e52a34 commit 5313ed3
Showing 1 changed file with 29 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
import com.webobjects.eoaccess.EOJoin;
import com.webobjects.eoaccess.EORelationship;
import com.webobjects.eoaccess.EOSQLExpression;
import com.webobjects.eoaccess.EOSchemaSynchronization;
import com.webobjects.eoaccess.EOSynchronizationFactory;
import com.webobjects.eoaccess.synchronization.EOSchemaGenerationOptions;
import com.webobjects.eoaccess.synchronization.EOSchemaSynchronization;
import com.webobjects.eoaccess.synchronization.EOSchemaSynchronizationFactory;
import com.webobjects.eocontrol.EOAndQualifier;
import com.webobjects.eocontrol.EOKeyValueQualifier;
import com.webobjects.eocontrol.EOQualifier;
Expand Down Expand Up @@ -114,7 +115,7 @@ public boolean canDescribeStoredProcedure(String s) {
}

@Override
public EOSynchronizationFactory createSynchronizationFactory() {
public EOSchemaSynchronizationFactory createSchemaSynchronizationFactory() {
return new _FrontBasePlugIn.FrontbaseSynchronizationFactory(_adaptor);
}

Expand Down Expand Up @@ -237,6 +238,7 @@ public Properties connectionPropertiesForConnectionDictionary(NSDictionary conne
* framework and this can be used as a hard-coded equivalent.
* </P>
*/
@SuppressWarnings("unchecked")
@Override
public NSDictionary<String, Object> jdbcInfo() {
// you can swap this code out to write the property list out in order // to get a fresh copy of the
Expand Down Expand Up @@ -645,7 +647,7 @@ else if (upperExternalType.equals("CLOB"))
return -1;
}

public static class FrontbaseSynchronizationFactory extends EOSynchronizationFactory {
public static class FrontbaseSynchronizationFactory extends EOSchemaSynchronizationFactory {

public FrontbaseSynchronizationFactory(EOAdaptor eoadaptor) {
super(eoadaptor);
Expand All @@ -665,10 +667,10 @@ public static boolean boolValueForKeyDefault(NSDictionary nsdictionary, String s
}

@Override
public String schemaCreationScriptForEntities(NSArray<EOEntity> allEntities, NSDictionary<String, String> options) {
public String schemaCreationScriptForEntities(NSArray<EOEntity> allEntities, EOSchemaGenerationOptions options) {
StringBuffer result = new StringBuffer();
if (options == null) {
options = NSDictionary.emptyDictionary();
options = new EOSchemaGenerationOptions();
}
NSArray<EOSQLExpression> statements = schemaCreationStatementsForEntities(allEntities, options);
int i = 0;
Expand All @@ -686,7 +688,7 @@ public String schemaCreationScriptForEntities(NSArray<EOEntity> allEntities, NSD
* </span>
*/
@Override
public NSArray<EOSQLExpression> schemaCreationStatementsForEntities(NSArray<EOEntity> entities, NSDictionary<String, String> options) {
public NSArray<EOSQLExpression> schemaCreationStatementsForEntities(NSArray<EOEntity> entities, EOSchemaGenerationOptions options) {
NSMutableArray<EOSQLExpression> result = new NSMutableArray<EOSQLExpression>();

if (entities == null || entities.count() == 0)
Expand All @@ -699,34 +701,34 @@ public NSArray<EOSQLExpression> schemaCreationStatementsForEntities(NSArray<EOEn
result.addObject(_expressionForString("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, LOCKING PESSIMISTIC"));

NSDictionary<String, Object> connectionDict = entities.lastObject().model().connectionDictionary();
if (boolValueForKeyDefault(options, "dropDatabase", false)) {
if (options.dropDatabase()) {
result.addObjectsFromArray(dropDatabaseStatementsForConnectionDictionary(connectionDict, null));
}
if (boolValueForKeyDefault(options, "createDatabase", false)) {
if (options.createDatabase()) {
result.addObjectsFromArray(createDatabaseStatementsForConnectionDictionary(connectionDict, null));
}
if (boolValueForKeyDefault(options, "dropPrimaryKeySupport", true)) {
if (options.dropPrimaryKeySupport()) {
NSArray<NSArray<EOEntity>> entityGroups = primaryKeyEntityGroupsForEntities(entities);
result.addObjectsFromArray(dropPrimaryKeySupportStatementsForEntityGroups(entityGroups));
}
if (boolValueForKeyDefault(options, "dropTables", true)) {
if (options.dropTables()) {
NSArray<NSArray<EOEntity>> entityGroups = tableEntityGroupsForEntities(entities);
result.addObjectsFromArray(dropTableStatementsForEntityGroups(entityGroups));
}
if (boolValueForKeyDefault(options, "createTables", true)) {
if (options.createTables()) {
NSArray<NSArray<EOEntity>> entityGroups = tableEntityGroupsForEntities(entities);
result.addObjectsFromArray(createTableStatementsForEntityGroups(entityGroups));
result.addObjectsFromArray(createIndexStatementsForEntityGroups(entityGroups));
}
if (boolValueForKeyDefault(options, "createPrimaryKeySupport", true)) {
if (options.createPrimaryKeySupport()) {
NSArray<NSArray<EOEntity>> entityGroups = primaryKeyEntityGroupsForEntities(entities);
result.addObjectsFromArray(primaryKeySupportStatementsForEntityGroups(entityGroups));
}
if (boolValueForKeyDefault(options, "primaryKeyConstraints", true)) {
if (options.primaryKeyConstraints()) {
NSArray<NSArray<EOEntity>> entityGroups = tableEntityGroupsForEntities(entities);
result.addObjectsFromArray(primaryKeyConstraintStatementsForEntityGroups(entityGroups));
}
if (boolValueForKeyDefault(options, "foreignKeyConstraints", false)) {
if (options.foreignKeyConstraints()) {
NSArray<NSArray<EOEntity>> entityGroups = tableEntityGroupsForEntities(entities);
for (NSArray<EOEntity> entityGroup : entityGroups) {
result.addObjectsFromArray(_foreignKeyConstraintStatementsForEntityGroup(entityGroup));
Expand Down Expand Up @@ -776,9 +778,9 @@ public NSArray<EOSQLExpression> dropTableStatementsForEntityGroup(NSArray<EOEnti

@Override
public NSArray<EOSQLExpression> primaryKeySupportStatementsForEntityGroup(NSArray<EOEntity> entityGroup) {
if (entityGroup == null)
if (entityGroup == null) {
return NSArray.emptyArray();

}
NSMutableArray<EOSQLExpression> result = new NSMutableArray<EOSQLExpression>();

for (int i = entityGroup.count() - 1; i >= 0; i--) {
Expand Down Expand Up @@ -904,9 +906,9 @@ public NSArray<EOSQLExpression> createTableStatementsForEntityGroup(NSArray<EOEn
NSMutableArray<String> nsmutablearray = new NSMutableArray<String>();
int j = entityGroup != null ? entityGroup.count() : 0;

if (j == 0)
if (j == 0) {
return NSArray.emptyArray();

}
// 出力バッファーを準備
StringBuilder columns = new StringBuilder();

Expand Down Expand Up @@ -967,9 +969,9 @@ public NSArray<EOSQLExpression> createIndexStatementsForEntityGroup(NSArray<EOEn
EOEntity eoentity = null;
int j = entityGroup != null ? entityGroup.count() : 0;

if (j == 0)
if (j == 0) {
return NSArray.emptyArray();

}
eosqlexpression = _expressionForEntity(entityGroup.objectAtIndex(0));

for (int i = 0; i < j; i++) {
Expand Down Expand Up @@ -1004,14 +1006,14 @@ public String columnTypeStringForAttribute(EOAttribute eoattribute) {
}

@Override
public NSArray<EOSQLExpression> statementsToConvertColumnType(String columnName, String tableName, ColumnTypes oldType, ColumnTypes newType, NSDictionary<String, String> options) {
public NSArray<EOSQLExpression> statementsToConvertColumnType(String columnName, String tableName, ColumnTypes oldType, ColumnTypes newType, EOSchemaGenerationOptions options) {
String columnTypeString = statementToCreateDataTypeClause(newType);
NSArray<EOSQLExpression> statements = new NSArray<EOSQLExpression>(_expressionForString("alter column " + quoteTableName(tableName) + "." + quoteTableName(columnName) + " to " + columnTypeString));
return statements;
}

@Override
public NSArray<EOSQLExpression> statementsToModifyColumnNullRule(String columnName, String tableName, boolean allowsNull, NSDictionary<String, String> options) {
public NSArray<EOSQLExpression> statementsToModifyColumnNullRule(String columnName, String tableName, boolean allowsNull, EOSchemaGenerationOptions options) {
NSArray<EOSQLExpression> statements;
if (allowsNull) {
if (USE_NAMED_CONSTRAINTS) {
Expand All @@ -1033,7 +1035,7 @@ public NSArray<EOSQLExpression> statementsToModifyColumnNullRule(String columnNa
}

@Override
public NSArray<EOSQLExpression> statementsToDeleteColumnNamed(String columnName, String tableName, NSDictionary<String, String> options) {
public NSArray<EOSQLExpression> statementsToDeleteColumnNamed(String columnName, String tableName, EOSchemaGenerationOptions options) {
return new NSArray<EOSQLExpression>(_expressionForString("alter table " + quoteTableName(tableName) + " drop column \"" + columnName.toUpperCase() + "\" cascade"));
}

Expand All @@ -1043,7 +1045,7 @@ public String _columnCreationClauseForAttribute(EOAttribute attribute) {
}

@Override
public NSArray<EOSQLExpression> statementsToInsertColumnForAttribute(EOAttribute attribute, NSDictionary<String, String> options) {
public NSArray<EOSQLExpression> statementsToInsertColumnForAttribute(EOAttribute attribute, EOSchemaGenerationOptions options) {
String clause = _columnCreationClauseForAttribute(attribute);
return new NSArray<EOSQLExpression>(_expressionForString("alter table " + quoteTableName(attribute.entity().externalName()) + " add " + clause));
}
Expand Down Expand Up @@ -1084,12 +1086,12 @@ private String statementToCreateDataTypeClause(EOSchemaSynchronization.ColumnTyp
}

@Override
public NSArray<EOSQLExpression> statementsToRenameColumnNamed(String columnName, String tableName, String newName, NSDictionary<String, String> options) {
public NSArray<EOSQLExpression> statementsToRenameColumnNamed(String columnName, String tableName, String newName, EOSchemaGenerationOptions options) {
return new NSArray<EOSQLExpression>(_expressionForString("alter column name " + quoteTableName(tableName) + "." + quoteTableName(columnName) + " to " + quoteTableName(newName)));
}

@Override
public NSArray<EOSQLExpression> statementsToRenameTableNamed(String tableName, String newName, NSDictionary<String, String> options) {
public NSArray<EOSQLExpression> statementsToRenameTableNamed(String tableName, String newName, EOSchemaGenerationOptions options) {
return new NSArray<EOSQLExpression>(_expressionForString("alter table name " + quoteTableName(tableName) + " to " + quoteTableName(newName)));
}

Expand Down

0 comments on commit 5313ed3

Please sign in to comment.