Skip to content

Commit

Permalink
Revert "Add QueryFilter BIF"
Browse files Browse the repository at this point in the history
This reverts commit 0cc1e06.
  • Loading branch information
quinteroj committed Apr 10, 2024
1 parent 0cc1e06 commit f61a66b
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 251 deletions.
37 changes: 37 additions & 0 deletions modules/test/bifs/Hola.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* [BoxLang]
*
* Copyright [2023] [Ortus Solutions, Corp]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package bifs;

import ortus.boxlang.runtime.bifs.BIF;
import ortus.boxlang.runtime.bifs.BoxBIF;
import ortus.boxlang.runtime.context.IBoxContext;
import ortus.boxlang.runtime.scopes.ArgumentsScope;

@BoxBIF
public class Hola extends BIF {

/**
* Hola
*
* @param context The context in which the BIF is being invoked.
* @param arguments Argument scope for the BIF.
*/
public String _invoke( IBoxContext context, ArgumentsScope arguments ) {
return "Hola Mundo!";
}
}
69 changes: 69 additions & 0 deletions modules/test/components/ModuleAbort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* [BoxLang]
*
* Copyright [2023] [Ortus Solutions, Corp]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package components;

import ortus.boxlang.runtime.components.Attribute;
import ortus.boxlang.runtime.components.BoxComponent;
import ortus.boxlang.runtime.components.Component;
import ortus.boxlang.runtime.context.IBoxContext;
import ortus.boxlang.runtime.scopes.Key;
import ortus.boxlang.runtime.types.IStruct;
import ortus.boxlang.runtime.types.exceptions.AbortException;
import ortus.boxlang.runtime.types.exceptions.CustomException;

@BoxComponent
public class ModuleAbort extends Component {

/**
* --------------------------------------------------------------------------
* Constructor(s)
* --------------------------------------------------------------------------
*/

public ModuleAbort() {
super();
declaredAttributes = new Attribute[] {
new Attribute( Key.showerror, "string" ),
new Attribute( Key.type, "string", "request" )
};
}

/**
* Tests for a parameter's existence, tests its data type, and, if a default value is not assigned, optionally provides one.
*
* @param context The context in which the Component is being invoked
* @param attributes The attributes to the Component
* @param body The body of the Component
* @param executionState The execution state of the Component
*
* @attribute.showerror Whether to show an error
*
* @attribute.type The type of the abort (request or page)
*
*/
public BodyResult _invoke( IBoxContext context, IStruct attributes, ComponentBody body, IStruct executionState ) {
String showerror = attributes.getAsString( Key.showerror );
String type = attributes.getAsString( Key.type );

Throwable cause = null;
if ( showerror != null && !showerror.isEmpty() ) {
cause = new CustomException( showerror );
}
throw new AbortException( type, cause );
}
}
113 changes: 113 additions & 0 deletions modules/test/config/Scheduler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/**
* [BoxLang]
*
* Copyright [2023] [Ortus Solutions, Corp]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package config;

import java.util.Optional;

import ortus.boxlang.runtime.async.tasks.BaseScheduler;
import ortus.boxlang.runtime.async.tasks.IScheduler;
import ortus.boxlang.runtime.async.tasks.ScheduledTask;

public class Scheduler extends BaseScheduler implements IScheduler {

public Scheduler() {
super( "ModuleScheduler" );
}

/**
* Declare the tasks for this scheduler
*/
@Override
public void configure() {
task( "PeriodicalTask" )
.call( () -> System.out.println( "++++++ >>>>>> Hello from MyModuleTask" ) )
.everySecond()
.onFailure( ( task, exception ) -> System.out.println( "MyModuleTask failed: " + exception.getMessage() ) )
.onSuccess( ( task, result ) -> System.out.println( "MyModuleTask succeeded: " + result ) );

task( "OneOffTask" )
.call( () -> System.out.println( "++++++ >>>>>> Hello from OneOffTask" ) );

xtask( "A Disabled Task" )
.call( () -> System.out.println( "Hello from A Disabled Task" ) )
.everySecond();
}

/**
* Called before the scheduler is going to be shutdown
*/
@Override
public void onShutdown() {
System.out.println( "[onShutdown] ==> Bye bye from the Module Scheduler!" );
}

/**
* Called after the scheduler has registered all schedules
*/
@Override
public void onStartup() {
System.out.println( "[onStartup] ==> The Module Scheduler is in da house!!!!!" );
}

/**
* Called whenever ANY task fails
*
* @task The task that got executed
*
* @exception The ColdFusion exception object
*/
@Override
public void onAnyTaskError( ScheduledTask task, Exception exception ) {
System.out.println( "[onAnyTaskError] ==> " + task.getName() + " task just went kabooooooom!" );
}

/**
* Called whenever ANY task succeeds
*
* @task The task that got executed
*
* @result The result (if any) that the task produced
*/
@Override
public void onAnyTaskSuccess( ScheduledTask task, Optional<?> result ) {
System.out.println( "[onAnyTaskSuccess] ==> " + task.getName() + " task completed!" );
}

/**
* Called before ANY task runs
*
* @task The task about to be executed
*/
@Override
public void beforeAnyTask( ScheduledTask task ) {
System.out.println( "[beforeAnyTask] ==> I am running before the task: " + task.getName() );
}

/**
* Called after ANY task runs
*
* @task The task that got executed
*
* @result The result (if any) that the task produced
*/
@Override
public void afterAnyTask( ScheduledTask task, Optional<?> result ) {
System.out.println( "[afterAnyTask] ==> I am running after the task: " + task.getName() );
}

}

This file was deleted.

9 changes: 1 addition & 8 deletions src/main/java/ortus/boxlang/runtime/types/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ public Array getColumnArray() {
*/
public void sort( Comparator<IStruct> compareFunc ) {
// data.sort( compareFunc );
Stream<IStruct> sorted = intStream()
Stream<IStruct> sorted = IntStream.range( 0, data.size() )
.mapToObj( index -> getRowAsStruct( index ) )
.sorted( compareFunc );

Expand Down Expand Up @@ -682,11 +682,4 @@ public BoxMeta getBoxMeta() {
return this.$bx;
}

/*
* Returns a IntStream of the indexes
*/
public IntStream intStream() {
return IntStream.range( 0, data.size() );
}

}
21 changes: 0 additions & 21 deletions src/main/java/ortus/boxlang/runtime/types/util/BLCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import ortus.boxlang.runtime.scopes.Key;
import ortus.boxlang.runtime.types.Array;
import ortus.boxlang.runtime.types.IStruct;
import ortus.boxlang.runtime.types.Query;
import ortus.boxlang.runtime.types.Struct;

public class BLCollector {
Expand Down Expand Up @@ -77,24 +76,4 @@ private BLCollector() {
);
}

/**
* Returns a Collector that collects the input elements into a Query
*
* @param newQuery The query to populate with data
*
* @return the populated query
*/
public static Collector<IStruct, Query, Query> toQuery( Query newQuery ) {
return Collector.of(
() -> newQuery, // supplier
Query::add, // accumulator
( left, right ) -> {
left.addAll( right );
return left;
}, // combiner
Collector.Characteristics.IDENTITY_FINISH,
Collector.Characteristics.CONCURRENT
);
}

}
Loading

0 comments on commit f61a66b

Please sign in to comment.