src/main/java/org/jboss/loom/migrators/_ext/MigratorDefinitionProcessor.java
List<IMigrationAction> processChildren( ContainerOfStackableDefs cont ) throws MigrationException {
        
        List<IMigrationAction> actions = new LinkedList();
        
        // ForEach defs.
        if( cont.hasForEachDefs() )
        for( MigratorDefinition.ForEachDef forEachDef : cont.forEachDefs ) {
            
            DefinitionBasedMigrator.ConfigLoadResult queryResult = this.dbm.getQueryResultByName( forEachDef.queryName ); 
            if( null == queryResult )
                throw new MigrationException("Query '"+forEachDef.queryName+"' not found. Needed at " + XmlUtils.formatLocation(forEachDef.location));
            
            ForEachContext forEachContext = new ForEachContext(forEachDef);
            this.stack.push( forEachContext );
            
            // For each item in query result...
            //for( IConfigFragment configFragment : queryResult.configFragments ) {
            for( IConfigFragment configFragment : forEachContext ) {
                // A variable is set automatically in next().
                
                // Recurse.
                this.processChildren( forEachDef );
            }
            this.stack.pop();
        }
        
        // Action definitions.
        if( cont.hasActionDefs() )
        for( MigratorDefinition.ActionDef actionDef : cont.actionDefs ) {
            IMigrationAction action;
            switch( actionDef.type ){
                case "manual":
                    action = new ManualAction();
                    // warning
                    // forEach
                    break;
                case "copy": 
                    String src = actionDef.attribs.get("src");
                    String dest = actionDef.attribs.get("dest");
                    CopyFileAction.IfExists ifExists = CopyFileAction.IfExists.valueOf("ifExists");
                    action = new CopyFileAction( DefinitionBasedMigrator.class, new File(src), new File(dest), ifExists ); 
                    break;
                case "cli": 
                    String cliScript = actionDef.attribs.get("cliScript");
                    ModelNode modelNode = ModelNode.fromString( cliScript );
                    action = new CliCommandAction( DefinitionBasedMigrator.class, cliScript, modelNode ); 
                    break;
                default: 
                    throw new MigrationException("Unsupported action type '" + actionDef.type + "' in " + cont.location.getSystemId());
            }
            
            // Recurse
            this.stack.push( new ActionContext( action ) );
            this.processChildren( actionDef );
            this.stack.pop();
            
            actions.add( action );
        }
        return actions;
    }
/**
     *  Recursively processes the .mig.xml descriptor into Actions.
     *  TODO: Could be better to put the stack manipulation to the beginning and end of the method.
     */
Recursively processes the .mig.xml descriptor into Actions.
TODO: Could be better to put the stack manipulation to the beginning and end of the method.
Recursively processes the . mig . xml descriptor into Actions . TODO : Could be better to put the stack manipulation to the beginning and end of the method .
List<IMigrationAction> processChildren( ContainerOfStackableDefs cont ) throws MigrationException {
        List<IMigrationAction> actions = new LinkedList();
        if( cont.hasForEachDefs() )
        for( MigratorDefinition.ForEachDef forEachDef : cont.forEachDefs ) {
            DefinitionBasedMigrator.ConfigLoadResult queryResult = this.dbm.getQueryResultByName( forEachDef.queryName ); 
            if( null == queryResult )
                throw new MigrationException("Query '"+forEachDef.queryName+"' not found. Needed at " + XmlUtils.formatLocation(forEachDef.location));
            ForEachContext forEachContext = new ForEachContext(forEachDef);
            this.stack.push( forEachContext );
            for( IConfigFragment configFragment : forEachContext ) {
                this.processChildren( forEachDef );
            }
            this.stack.pop();
        }
        if( cont.hasActionDefs() )
        for( MigratorDefinition.ActionDef actionDef : cont.actionDefs ) {
            IMigrationAction action;
            switch( actionDef.type ){
                case "manual":
                    action = new ManualAction();
                    break;
                case "copy": 
                    String src = actionDef.attribs.get("src");
                    String dest = actionDef.attribs.get("dest");
                    CopyFileAction.IfExists ifExists = CopyFileAction.IfExists.valueOf("ifExists");
                    action = new CopyFileAction( DefinitionBasedMigrator.class, new File(src), new File(dest), ifExists ); 
                    break;
                case "cli": 
                    String cliScript = actionDef.attribs.get("cliScript");
                    ModelNode modelNode = ModelNode.fromString( cliScript );
                    action = new CliCommandAction( DefinitionBasedMigrator.class, cliScript, modelNode ); 
                    break;
                default: 
                    throw new MigrationException("Unsupported action type '" + actionDef.type + "' in " + cont.location.getSystemId());
            }
            this.stack.push( new ActionContext( action ) );
            this.processChildren( actionDef );
            this.stack.pop();
            actions.add( action );
        }
        return actions;
    }
List < IMigrationAction > processChildren ( ContainerOfStackableDefs cont ) throws MigrationException { List < IMigrationAction > actions = new LinkedList ( ) ; if ( cont . hasForEachDefs ( ) ) for ( MigratorDefinition . ForEachDef forEachDef : cont . forEachDefs ) { DefinitionBasedMigrator . ConfigLoadResult queryResult = this . dbm . getQueryResultByName ( forEachDef . queryName ) ; if ( null == queryResult ) throw new MigrationException ( "Query '" + forEachDef . queryName + "' not found. Needed at " + XmlUtils . formatLocation ( forEachDef . location ) ) ; ForEachContext forEachContext = new ForEachContext ( forEachDef ) ; this . stack . push ( forEachContext ) ; for ( IConfigFragment configFragment : forEachContext ) { this . processChildren ( forEachDef ) ; } this . stack . pop ( ) ; } if ( cont . hasActionDefs ( ) ) for ( MigratorDefinition . ActionDef actionDef : cont . actionDefs ) { IMigrationAction action ; switch ( actionDef . type ) { case "manual" : action = new ManualAction ( ) ; break ; case "copy" : String src = actionDef . attribs . get ( "src" ) ; String dest = actionDef . attribs . get ( "dest" ) ; CopyFileAction . IfExists ifExists = CopyFileAction . IfExists . valueOf ( "ifExists" ) ; action = new CopyFileAction ( DefinitionBasedMigrator . class , new File ( src ) , new File ( dest ) , ifExists ) ; break ; case "cli" : String cliScript = actionDef . attribs . get ( "cliScript" ) ; ModelNode modelNode = ModelNode . fromString ( cliScript ) ; action = new CliCommandAction ( DefinitionBasedMigrator . class , cliScript , modelNode ) ; break ; default : throw new MigrationException ( "Unsupported action type '" + actionDef . type + "' in " + cont . location . getSystemId ( ) ) ; } this . stack . push ( new ActionContext ( action ) ) ; this . processChildren ( actionDef ) ; this . stack . pop ( ) ; actions . add ( action ) ; } return actions ; }
Recursively processes the .mig.xml descriptor into Actions.
Recursively processes the . mig . xml descriptor into Actions .
// ForEach defs. // For each item in query result... //for( IConfigFragment configFragment : queryResult.configFragments ) { // A variable is set automatically in next(). // Recurse. // Action definitions. // warning // forEach // Recurse