Search in sources :

Example 1 with OperationContext

use of com.developmentontheedge.be5.operation.OperationContext in project be5 by DevelopmentOnTheEdge.

the class OperationExecutorImpl method create.

@Override
public Operation create(String entityName, String queryName, String operationName, String[] selectedRows, Map<String, String> operationParams) {
    OperationInfo operationInfo = userAwareMeta.getOperation(entityName, operationName);
    OperationContext operationContext = new OperationContext(selectedRows, queryName, operationParams);
    return create(operationInfo, operationContext);
}
Also used : OperationInfo(com.developmentontheedge.be5.operation.OperationInfo) OperationContext(com.developmentontheedge.be5.operation.OperationContext)

Example 2 with OperationContext

use of com.developmentontheedge.be5.operation.OperationContext in project be5 by DevelopmentOnTheEdge.

the class OperationExecutorImpl method create.

@Override
public Operation create(OperationInfo operationInfo, OperationContext operationContext) {
    Operation operation;
    switch(operationInfo.getType()) {
        case OPERATION_TYPE_GROOVY:
            try {
                Class aClass = groovyOperationLoader.get(operationInfo);
                if (aClass != null) {
                    operation = (Operation) aClass.newInstance();
                } else {
                    throw Be5Exception.internalInOperation(new Error("Class " + operationInfo.getCode() + " is null."), operationInfo.getModel());
                }
            } catch (NoClassDefFoundError | IllegalAccessException | InstantiationException e) {
                throw new UnsupportedOperationException("Groovy feature has been excluded", e);
            } catch (Throwable e) {
                throw Be5Exception.internalInOperation(e, operationInfo.getModel());
            }
            break;
        case OPERATION_TYPE_JAVA:
            try {
                operation = (Operation) Class.forName(operationInfo.getCode()).newInstance();
                break;
            } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
                throw Be5Exception.internalInOperation(new RuntimeException("It is possible to use the 'file:' instead of the 'code:' " + "in the yaml file. \n\t" + e.getMessage(), e), operationInfo.getModel());
            }
        case OPERATION_TYPE_JAVAFUNCTION:
        case OPERATION_TYPE_SQL:
        case OPERATION_TYPE_JAVASCRIPT:
        case OPERATION_TYPE_JSSERVER:
        case OPERATION_TYPE_DOTNET:
        case OPERATION_TYPE_JAVADOTNET:
            throw Be5Exception.internal("Not support operation type: " + operationInfo.getType());
        default:
            throw Be5Exception.internal("Unknown action type '" + operationInfo.getType() + "'");
    }
    operation.initialize(operationInfo, operationContext, OperationResult.create());
    injector.injectAnnotatedFields(operation);
    return operation;
}
Also used : Operation(com.developmentontheedge.be5.metadata.model.Operation) TransactionalOperation(com.developmentontheedge.be5.operation.TransactionalOperation) Operation(com.developmentontheedge.be5.operation.Operation)

Aggregations

Operation (com.developmentontheedge.be5.metadata.model.Operation)1 Operation (com.developmentontheedge.be5.operation.Operation)1 OperationContext (com.developmentontheedge.be5.operation.OperationContext)1 OperationInfo (com.developmentontheedge.be5.operation.OperationInfo)1 TransactionalOperation (com.developmentontheedge.be5.operation.TransactionalOperation)1