Search in sources :

Example 21 with FlattenedSolution

use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.

the class SQLGenerator method makeRelatedSQL.

synchronized void makeRelatedSQL(SQLSheet relatedSheet, Relation r) {
    if (relatedSheet.getRelatedSQLDescription(r.getName()) != null)
        return;
    try {
        FlattenedSolution fs = application.getFlattenedSolution();
        if (!Relation.isValid(r, fs) || r.isParentRef()) {
            return;
        }
        ITable ft = fs.getTable(r.getForeignDataSource());
        if (ft == null) {
            return;
        }
        // add primary keys if missing
        QueryTable foreignQTable = new QueryTable(ft.getSQLName(), ft.getDataSource(), ft.getCatalog(), ft.getSchema());
        QuerySelect relatedSelect = new QuerySelect(foreignQTable);
        List<String> parentRequiredDataProviderIDs = new ArrayList<String>();
        Column[] relcols = r.getForeignColumns(fs);
        for (Column column : relcols) {
            parentRequiredDataProviderIDs.add(column.getDataProviderID());
        }
        relatedSelect.setCondition(CONDITION_RELATION, createRelatedCondition(application, r, foreignQTable));
        Collection<Column> rcolumns = ft.getColumns();
        relatedSelect.setColumns(makeQueryColumns(rcolumns.iterator(), foreignQTable, null));
        // fill dataprovider map
        List<String> dataProviderIDsDilivery = new ArrayList<String>();
        Iterator<Column> it = rcolumns.iterator();
        while (it.hasNext()) {
            Column col = it.next();
            dataProviderIDsDilivery.add(col.getDataProviderID());
        }
        relatedSheet.addRelatedSelect(r.getName(), relatedSelect, dataProviderIDsDilivery, parentRequiredDataProviderIDs, null);
        createAggregates(relatedSheet, foreignQTable);
    } catch (RepositoryException e) {
        Debug.error(e);
    }
}
Also used : QueryColumn(com.servoy.j2db.query.QueryColumn) BaseQueryColumn(com.servoy.base.query.BaseQueryColumn) IColumn(com.servoy.j2db.persistence.IColumn) Column(com.servoy.j2db.persistence.Column) ArrayList(java.util.ArrayList) SafeArrayList(com.servoy.j2db.util.SafeArrayList) FlattenedSolution(com.servoy.j2db.FlattenedSolution) ITable(com.servoy.j2db.persistence.ITable) RepositoryException(com.servoy.j2db.persistence.RepositoryException) QuerySelect(com.servoy.j2db.query.QuerySelect) BaseQueryTable(com.servoy.base.query.BaseQueryTable) QueryTable(com.servoy.j2db.query.QueryTable)

Example 22 with FlattenedSolution

use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.

the class FoundSetManager method getTriggerFunctions.

private List<TriggerFunction> getTriggerFunctions(ITable table, TypedProperty<Integer> property, Scriptable foundsetScope) {
    FlattenedSolution solutionRoot = getApplication().getFlattenedSolution();
    IExecutingEnviroment scriptEngine = getApplication().getScriptEngine();
    return stream(solutionRoot.getTableNodes(table)).map(tableNode -> {
        Object function = null;
        Scriptable scope = null;
        ScriptMethod scriptMethod = solutionRoot.getScriptMethod(((Integer) tableNode.getProperty(property.getPropertyName())).intValue());
        if (scriptMethod != null) {
            if (scriptMethod.getParent() instanceof Solution) {
                // global method
                GlobalScope gs = scriptEngine.getScopesScope().getGlobalScope(scriptMethod.getScopeName());
                if (gs != null) {
                    scope = gs;
                    function = gs.get(scriptMethod.getName());
                }
            } else if (foundsetScope != null) {
                // foundset method
                scope = foundsetScope;
                function = scope.getPrototype().get(scriptMethod.getName(), scope);
            }
        }
        if (function instanceof Function) {
            return new TriggerFunction((Function) function, scope, tableNode);
        }
        return null;
    }).filter(Objects::nonNull).collect(toList());
}
Also used : GlobalScope(com.servoy.j2db.scripting.GlobalScope) Function(org.mozilla.javascript.Function) IExecutingEnviroment(com.servoy.j2db.scripting.IExecutingEnviroment) FlattenedSolution(com.servoy.j2db.FlattenedSolution) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) Scriptable(org.mozilla.javascript.Scriptable) ScriptMethod(com.servoy.j2db.persistence.ScriptMethod) FlattenedSolution(com.servoy.j2db.FlattenedSolution) Solution(com.servoy.j2db.persistence.Solution)

Example 23 with FlattenedSolution

use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.

the class ClientPluginAccessProvider method getStyleSheet.

/*
	 * (non-Javadoc)
	 *
	 * @see com.servoy.j2db.plugins.IClientPluginAccess#getStyleSheet(java.lang.String)
	 */
public IStyleSheet getStyleSheet(String name) {
    FlattenedSolution flattenedSolution = application.getFlattenedSolution();
    if (flattenedSolution == null) {
        // when called before flattened solution is set.
        return null;
    }
    String style_name = ComponentFactory.getOverriddenStyleName(application, name);
    Style s = flattenedSolution.getStyle(style_name);
    return ComponentFactory.getCSSStyle(application, s);
}
Also used : FlattenedSolution(com.servoy.j2db.FlattenedSolution) Style(com.servoy.j2db.persistence.Style)

Example 24 with FlattenedSolution

use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.

the class JSForm method setDataSource.

@JSSetter
public void setDataSource(String arg) {
    // check syntax, do not accept invalid URIs
    if (arg != null) {
        try {
            new URI(arg);
        } catch (URISyntaxException e) {
            // $NON-NLS-1$//$NON-NLS-2$
            throw new RuntimeException("Invalid dataSource URI: '" + arg + "' :" + e.getMessage());
        }
    }
    checkModification();
    getForm().setDataSource(arg);
    // clear the data provider lookups affected by this change
    FlattenedSolution fs = application.getFlattenedSolution();
    fs.flushDataProviderLookups(getForm());
}
Also used : FlattenedSolution(com.servoy.j2db.FlattenedSolution) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) JSSetter(org.mozilla.javascript.annotations.JSSetter)

Example 25 with FlattenedSolution

use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.

the class JSPortal method setRelationName.

@JSSetter
public void setRelationName(String arg) {
    getBaseComponent(true).setRelationName(Utils.toEnglishLocaleLowerCase(arg));
    // clear the data provider lookups affected by this change
    FlattenedSolution fs = application.getFlattenedSolution();
    fs.flushDataProviderLookups(getBaseComponent(true));
}
Also used : FlattenedSolution(com.servoy.j2db.FlattenedSolution) JSSetter(org.mozilla.javascript.annotations.JSSetter)

Aggregations

FlattenedSolution (com.servoy.j2db.FlattenedSolution)79 JSFunction (org.mozilla.javascript.annotations.JSFunction)27 Form (com.servoy.j2db.persistence.Form)20 RepositoryException (com.servoy.j2db.persistence.RepositoryException)17 ArrayList (java.util.ArrayList)17 Relation (com.servoy.j2db.persistence.Relation)15 Media (com.servoy.j2db.persistence.Media)10 Solution (com.servoy.j2db.persistence.Solution)10 ScriptMethod (com.servoy.j2db.persistence.ScriptMethod)9 IBaseSMForm (com.servoy.base.solutionmodel.IBaseSMForm)7 AbstractActiveSolutionHandler (com.servoy.j2db.AbstractActiveSolutionHandler)7 ISMForm (com.servoy.j2db.solutionmodel.ISMForm)7 FormController (com.servoy.j2db.FormController)6 TableNode (com.servoy.j2db.persistence.TableNode)6 ValueList (com.servoy.j2db.persistence.ValueList)6 JSForm (com.servoy.j2db.scripting.solutionmodel.JSForm)6 IApplicationServer (com.servoy.j2db.server.shared.IApplicationServer)6 ITable (com.servoy.j2db.persistence.ITable)5 QueryTable (com.servoy.j2db.query.QueryTable)5 SafeArrayList (com.servoy.j2db.util.SafeArrayList)5