Search in sources :

Example 1 with GroovyOperation

use of com.developmentontheedge.be5.metadata.model.GroovyOperation 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");
}
Also used : GroovyOperation(com.developmentontheedge.be5.metadata.model.GroovyOperation)

Example 2 with GroovyOperation

use of com.developmentontheedge.be5.metadata.model.GroovyOperation 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();
}
Also used : GroovyOperation(com.developmentontheedge.be5.metadata.model.GroovyOperation)

Example 3 with GroovyOperation

use of com.developmentontheedge.be5.metadata.model.GroovyOperation in project be5 by DevelopmentOnTheEdge.

the class GroovyOperationLoader method initOperationMap.

void initOperationMap() {
    Map<String, com.developmentontheedge.be5.metadata.model.Operation> newOperationMap = new HashMap<>();
    List<Entity> entities = meta.getOrderedEntities("ru");
    for (Entity entity : entities) {
        List<String> operationNames = meta.getOperationNames(entity);
        for (String operationName : operationNames) {
            com.developmentontheedge.be5.metadata.model.Operation operation = meta.getOperationIgnoringRoles(entity, operationName);
            if (operation.getType().equals(OPERATION_TYPE_GROOVY)) {
                GroovyOperation groovyOperation = (GroovyOperation) operation;
                String fileName = groovyOperation.getFileName().replace("/", ".");
                newOperationMap.put(fileName, operation);
            }
        }
    }
    groovyOperationsMap = newOperationMap;
}
Also used : Entity(com.developmentontheedge.be5.metadata.model.Entity) Operation(com.developmentontheedge.be5.metadata.model.Operation) HashMap(java.util.HashMap) Operation(com.developmentontheedge.be5.metadata.model.Operation) GroovyOperation(com.developmentontheedge.be5.metadata.model.GroovyOperation) GroovyOperation(com.developmentontheedge.be5.metadata.model.GroovyOperation)

Aggregations

GroovyOperation (com.developmentontheedge.be5.metadata.model.GroovyOperation)3 Entity (com.developmentontheedge.be5.metadata.model.Entity)1 Operation (com.developmentontheedge.be5.metadata.model.Operation)1 HashMap (java.util.HashMap)1