Search in sources :

Example 1 with DataElementPath

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

the class FreemarkerScript method getErrors.

@Override
public List<ProjectElementException> getErrors() {
    List<ProjectElementException> result = new ArrayList<>();
    ProjectElementException error = getResult().getError();
    if (error != null && !error.isNoError()) {
        DataElementPath path = getCompletePath();
        if (error.getPath().equals(path.toString()))
            result.add(error);
        else
            result.add(new ProjectElementException(path, "source", error));
    }
    return result;
}
Also used : ProjectElementException(com.developmentontheedge.be5.metadata.exception.ProjectElementException) DataElementPath(com.developmentontheedge.be5.metadata.model.base.DataElementPath) ArrayList(java.util.ArrayList)

Example 2 with DataElementPath

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

the class Query method getErrors.

@Override
public List<ProjectElementException> getErrors() {
    List<ProjectElementException> result = super.getErrors();
    try {
        ModelValidationUtils.checkValueInSet(this, "type", getType().getName(), getQueryTypes());
    } catch (ProjectElementException e) {
        result.add(e);
    }
    String templateQueryName = getTemplateQueryName();
    if (!templateQueryName.isEmpty()) {
        int pos = templateQueryName.indexOf('.');
        if (pos < 0) {
            result.add(new ProjectElementException(getCompletePath(), "templateQueryName", new IllegalArgumentException("templateQueryName must have format <entity>:<query>")));
        }
    }
    Set<String> missingEntries = getRoles().getMissingEntries();
    if (!missingEntries.isEmpty()) {
        result.add(new ProjectElementException(getCompletePath(), "roles", "Unknown role(s): " + missingEntries));
    }
    ProjectElementException error = getQueryCompiled().getError();
    if (error != null && !error.isNoError()) {
        DataElementPath path = getCompletePath();
        if (error.getPath().equals(path.toString()))
            result.add(error);
        else
            result.add(new ProjectElementException(path, "query", error));
    }
    return result;
}
Also used : ProjectElementException(com.developmentontheedge.be5.metadata.exception.ProjectElementException) DataElementPath(com.developmentontheedge.be5.metadata.model.base.DataElementPath)

Example 3 with DataElementPath

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

the class PageCustomization method getErrors.

@Override
public List<ProjectElementException> getErrors() {
    List<ProjectElementException> result = new ArrayList<>();
    try {
        ModelValidationUtils.checkValueInSet(this, "domain", domain, getDomains());
    } catch (ProjectElementException e) {
        result.add(e);
    }
    try {
        ModelValidationUtils.checkValueInSet(this, "type", type, TYPES);
    } catch (ProjectElementException e) {
        result.add(e);
    }
    ProjectElementException error = getResult().getError();
    if (error != null && !error.isNoError()) {
        DataElementPath path = getCompletePath();
        if (error.getPath().equals(path.toString()))
            result.add(error);
        else
            result.add(new ProjectElementException(path, "query", error));
    }
    return result;
}
Also used : ProjectElementException(com.developmentontheedge.be5.metadata.exception.ProjectElementException) DataElementPath(com.developmentontheedge.be5.metadata.model.base.DataElementPath) ArrayList(java.util.ArrayList)

Example 4 with DataElementPath

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

the class AppData method executeScript.

protected void executeScript(final SqlExecutor sqlExecutor, FreemarkerScript freemarkerScript) throws ProjectElementException, IOException {
    String compiled = freemarkerScript.getResult().validate();
    if (logPath != null) {
        Files.write(logPath.toPath().resolve(be5Project.getName() + "_script_" + freemarkerScript.getModule().getName() + "_" + freemarkerScript.getName() + ".compiled"), compiled.getBytes(StandardCharsets.UTF_8));
    }
    String sql = compiled.trim();
    if (sql.isEmpty())
        return;
    DataElementPath path = freemarkerScript.getCompletePath();
    if (debug)
        System.err.println(sql);
    sqlExecutor.comment("Execute " + path);
    new FreemarkerSqlHandler(sqlExecutor, debug, logger).execute(freemarkerScript);
}
Also used : DataElementPath(com.developmentontheedge.be5.metadata.model.base.DataElementPath) FreemarkerSqlHandler(com.developmentontheedge.be5.metadata.freemarker.FreemarkerSqlHandler)

Example 5 with DataElementPath

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

the class FreemarkerSqlHandler method execute.

public void execute(FreemarkerScript freemarkerScript) throws ProjectElementException, FreemarkerSqlException {
    DataElementPath path = freemarkerScript.getCompletePath();
    if (log != null) {
        log.setOperationName("[>] " + path);
    }
    sqlExecutor.comment("Execute " + path);
    Project project = freemarkerScript.getProject();
    ResultToConsumerWriter out = new ResultToConsumerWriter(new MultiSqlConsumer(project.getDatabaseSystem().getType(), this));
    FreemarkerUtils.mergeTemplateByPath(path.toString(), project.getContext(freemarkerScript), project.getConfiguration(), out);
    for (int j = includeChain.size() - 1; j >= 0; j--) {
        sqlExecutor.comment("End of included " + includeChain.get(j), false);
    }
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project) DataElementPath(com.developmentontheedge.be5.metadata.model.base.DataElementPath) MultiSqlConsumer(com.developmentontheedge.dbms.MultiSqlConsumer)

Aggregations

DataElementPath (com.developmentontheedge.be5.metadata.model.base.DataElementPath)6 ProjectElementException (com.developmentontheedge.be5.metadata.exception.ProjectElementException)4 ArrayList (java.util.ArrayList)2 FreemarkerSqlHandler (com.developmentontheedge.be5.metadata.freemarker.FreemarkerSqlHandler)1 Project (com.developmentontheedge.be5.metadata.model.Project)1 MultiSqlConsumer (com.developmentontheedge.dbms.MultiSqlConsumer)1