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);
}
}
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());
}
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);
}
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());
}
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));
}
Aggregations