Skip to content

Commit

Permalink
Tweak context argument in MappingGenerator constructor signature
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelborn committed Nov 16, 2024
1 parent 5ebe7c2 commit cc9f5da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
import ortus.boxlang.runtime.types.Struct;
import ortus.boxlang.runtime.types.exceptions.BoxRuntimeException;
import ortus.boxlang.runtime.types.exceptions.ParseException;
import ortus.boxlang.runtime.util.BoxFQN;
import ortus.boxlang.runtime.util.FileSystemUtil;
import ortus.boxlang.runtime.util.ResolvedFilePath;

public class MappingGenerator {

Expand Down Expand Up @@ -95,7 +95,7 @@ public class MappingGenerator {
*
* @return a map of datasource UNIQUE names to a list of EntityRecords.
*/
public static Map<String, List<EntityRecord>> discoverEntities( IBoxContext context, ORMConfig ormConfig ) {
public static Map<String, List<EntityRecord>> discoverEntities( IJDBCCapableContext context, ORMConfig ormConfig ) {
if ( !ormConfig.autoGenMap ) {
// Skip mapping generation and load the pre-generated mappings from `ormConfig.entityPaths`
throw new BoxRuntimeException( "ORMConfiguration setting `autoGenMap=false` is currently unsupported." );
Expand All @@ -107,13 +107,13 @@ public static Map<String, List<EntityRecord>> discoverEntities( IBoxContext cont
}
}

public MappingGenerator( IBoxContext context, ORMConfig config ) {
public MappingGenerator( IJDBCCapableContext context, ORMConfig config ) {
this.entities = new ArrayList<>();
this.config = config;
this.saveDirectory = null;
this.saveAlongsideEntity = config.saveMapping;
this.entityPaths = new java.util.ArrayList<>();
this.context = ( IJDBCCapableContext ) context;
this.context = context;
this.defaultDatasource = getDefaultDatasource();
// this.appDirectory = context.getParentOfType( ApplicationBoxContext.class ).getApplication().getApplicationDirectory();

Expand All @@ -123,10 +123,10 @@ public MappingGenerator( IBoxContext context, ORMConfig config ) {
}

for ( String entityPath : config.entityPaths ) {
this.entityPaths.add( FileSystemUtil.expandPath( context, entityPath ).absolutePath() );
this.entityPaths.add( FileSystemUtil.expandPath( ( IBoxContext ) context, entityPath ).absolutePath() );
}
if ( this.entityPaths.isEmpty() ) {
this.entityPaths.add( FileSystemUtil.expandPath( context, "." ).absolutePath() );
this.entityPaths.add( FileSystemUtil.expandPath( ( IBoxContext ) context, "." ).absolutePath() );
logger.warn(
"No entity paths found in ORM configuration; defaulting to app root. (You should STRONGLY consider setting an 'entityPaths' array in your ORM settings.)" );
}
Expand All @@ -140,7 +140,7 @@ public MappingGenerator( IBoxContext context, ORMConfig config ) {
public MappingGenerator generateMappings() {
final int MAX_SYNCHRONOUS_ENTITIES = 20;
ArrayList<IStruct> classes = discoverBLClasses( this.entityPaths );
boolean doParallel = classes.size() > MAX_SYNCHRONOUS_ENTITIES;
boolean doParallel = false;

if ( doParallel ) {
logger.debug( "Parallelizing metadata introspection", MAX_SYNCHRONOUS_ENTITIES );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import ortus.boxlang.modules.orm.config.ORMConfig;
import ortus.boxlang.modules.orm.config.ORMKeys;
import ortus.boxlang.runtime.BoxRuntime;
import ortus.boxlang.runtime.context.ScriptingRequestBoxContext;
import ortus.boxlang.runtime.logging.LoggingConfigurator;
import ortus.boxlang.runtime.types.Array;
import ortus.boxlang.runtime.types.Struct;
Expand Down Expand Up @@ -108,7 +109,7 @@ public static void main( String[] args ) {
// log.info( "Using ORM Config: {}", ormConfig );

ortus.boxlang.modules.orm.mapping.MappingGenerator generator = new ortus.boxlang.modules.orm.mapping.MappingGenerator(
runtime.getRuntimeContext(),
new ScriptingRequestBoxContext( runtime.getRuntimeContext() ),
ormConfig
);

Expand Down

0 comments on commit cc9f5da

Please sign in to comment.