use of com.developmentontheedge.be5.operation.OperationInfo in project be5 by DevelopmentOnTheEdge.
the class GroovyOperationLoader method get.
public Class get(OperationInfo operationInfo) {
preloadSuperOperation(operationInfo);
GroovyOperation groovyOperation = (GroovyOperation) operationInfo.getModel();
String fileName = groovyOperation.getFileName();
String canonicalName = fileName.replace("/", ".");
String simpleName = fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length() - ".groovy".length()).trim();
return groovyRegister.getClass(canonicalName, operationInfo.getCode(), simpleName + ".groovy");
}
use of com.developmentontheedge.be5.operation.OperationInfo in project be5 by DevelopmentOnTheEdge.
the class GroovyOperationLoader method getSimpleSuperClassName.
public String getSimpleSuperClassName(OperationInfo operationInfo) {
GroovyOperation groovyOperation = (GroovyOperation) operationInfo.getModel();
String fileName = groovyOperation.getFileName();
String className = fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length() - ".groovy".length()).trim();
String classBegin = "class " + className + " extends ";
String code = operationInfo.getCode();
int superClassBeginPos = code.indexOf(classBegin);
if (superClassBeginPos == -1)
return null;
superClassBeginPos += classBegin.length();
int superClassEndPos = Math.min(code.indexOf(" ", superClassBeginPos) != -1 ? code.indexOf(" ", superClassBeginPos) : 999999999, code.indexOf("\n", superClassBeginPos));
return code.substring(superClassBeginPos, superClassEndPos).trim();
}
use of com.developmentontheedge.be5.operation.OperationInfo 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);
}
use of com.developmentontheedge.be5.operation.OperationInfo in project be5 by DevelopmentOnTheEdge.
the class GroovyOperationLoader method preloadSuperOperation.
public List<String> preloadSuperOperation(OperationInfo operationInfo) {
String simpleSuperClassName = getSimpleSuperClassName(operationInfo);
String superOperationCanonicalName = getCanonicalSuperClassName(operationInfo);
com.developmentontheedge.be5.metadata.model.Operation superOperation = groovyOperationsMap.get(superOperationCanonicalName);
if (superOperation != null && superOperation.getType().equals(OPERATION_TYPE_GROOVY)) {
if (groovyRegister.getGroovyClasses().getIfPresent(superOperationCanonicalName) == null) {
ArrayList<String> list = new ArrayList<>(preloadSuperOperation(new OperationInfo(superOperation)));
list.add(superOperationCanonicalName);
groovyRegister.getClass(superOperationCanonicalName, superOperation.getCode(), simpleSuperClassName + ".groovy");
return list;
}
return Collections.emptyList();
}
return Collections.emptyList();
}
use of com.developmentontheedge.be5.operation.OperationInfo 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;
}
Aggregations