use of com.servoy.j2db.persistence.IDataProvider in project servoy-client by Servoy.
the class FormAndTableDataProviderLookup method getDataProvider.
public IDataProvider getDataProvider(String id) throws RepositoryException {
if (id == null)
return null;
// this getGlobalDataProvider handles related DPs as well like a.b.c
IDataProvider retval = this.flattenedSolution.getGlobalDataProvider(id);
if (retval == null) {
retval = formProviders.get(id);
if (retval != null) {
return retval;
}
retval = this.flattenedSolution.getDataProviderForTable(getTable(), id);
if (retval != null) {
formProviders.put(id, retval);
} else {
retval = form.getScriptVariable(id);
if (retval != null) {
formProviders.put(id, retval);
}
}
}
return retval;
}
use of com.servoy.j2db.persistence.IDataProvider in project servoy-client by Servoy.
the class NGUtils method getDataProviderPropertyDescription.
public static PropertyDescription getDataProviderPropertyDescription(String dataProviderName, IApplication app, Form form, ITable table, boolean parseHTMLIfString, boolean useLocalDateTime) {
FormAndTableDataProviderLookup dpLookup = new FormAndTableDataProviderLookup(app.getFlattenedSolution(), form, table);
IDataProvider dp = null;
try {
dp = dpLookup.getDataProvider(dataProviderName);
} catch (RepositoryException e) {
Debug.error(e);
}
if (dp != null) {
int dpType;
if (dp instanceof IColumn || dp instanceof ColumnWrapper) {
IColumn column = (dp instanceof IColumn) ? (IColumn) dp : ((ColumnWrapper) dp).getColumn();
ColumnInfo ci = column.getColumnInfo();
if (ci != null && ci.hasFlag(IBaseColumn.UUID_COLUMN)) {
return UUID_DATAPROVIDER_CACHED_PD;
}
dpType = app.getFoundSetManager().getConvertedTypeForColumn(column, true);
} else
dpType = dp.getDataProviderType();
return getDataProviderPropertyDescription(dpType, parseHTMLIfString, useLocalDateTime);
}
return null;
}
use of com.servoy.j2db.persistence.IDataProvider in project servoy-client by Servoy.
the class DataAdapterList method valueChanged.
/*
* _____________________________________________________________ JavaScriptModificationListner
*/
/**
* listen for global var changes via own listener and state vars(mainly columns) via state listener if via javascript any var is changed it will be noted
* here,and dispatched to refresh the displays
*/
public void valueChanged(ModificationEvent e) {
if (destroyed) {
Debug.error("Destroyed DataAdapterList " + formController + " was still attached to the record: " + e.getRecord() + ", removing it if possible, currentRecord: " + currentRecord, new RuntimeException());
if (e.getRecord() != null)
e.getRecord().removeModificationListener(this);
else if (currentRecord != null)
currentRecord.removeModificationListener(this);
return;
}
if (formController != null && formController.isDestroyed()) {
Debug.error("Destroying DataAdapterList of a destroyed " + formController, new RuntimeException());
destroy();
return;
}
FormScope formScope = getFormScope();
if (visible && (currentRecord != null || (formScope != null && formScope.has(e.getName(), formScope)))) {
for (IDataAdapter da : dataAdapters.values()) {
// dataAdapter should call state.getValue if name from event is same as its dataProviderID
da.valueChanged(e);
}
// check if a related adapter depends on he global
if (e != null && e.getName() != null) {
for (IDisplayRelatedData drd : relatedDataAdapters) {
boolean depends = false;
String[] allRelationNames = drd.getAllRelationNames();
for (int a = 0; !depends && allRelationNames != null && a < allRelationNames.length; a++) {
Relation[] relations = application.getFlattenedSolution().getRelationSequence(allRelationNames[a]);
for (int r = 0; !depends && relations != null && r < relations.length; r++) {
try {
IDataProvider[] primaryDataProviders = relations[r].getPrimaryDataProviders(application.getFlattenedSolution());
for (int p = 0; !depends && primaryDataProviders != null && p < primaryDataProviders.length; p++) {
depends = e.getName().equals(primaryDataProviders[p].getDataProviderID());
}
} catch (RepositoryException ex) {
Debug.log(ex);
}
}
}
if (depends) {
// related adapter depends on the modified global
if (drd instanceof IDisplayDependencyData)
((IDisplayDependencyData) drd).dependencyChanged(currentRecord);
else
drd.setRecord(currentRecord, true);
}
}
}
// inform servoy aware beans
for (IServoyAwareBean drd : servoyAwareBeans) {
if (drd instanceof IModificationListener) {
try {
((IModificationListener) drd).valueChanged(e);
} catch (RuntimeException ex) {
// never make the app break on faulty beans
Debug.error(ex);
}
}
}
}
}
use of com.servoy.j2db.persistence.IDataProvider in project servoy-client by Servoy.
the class PartNode method getAggregatesFromRenderer.
private void getAggregatesFromRenderer(final List<AggregateVariable> aggregates, final Form f, DataRenderer a_renderer) throws RepositoryException {
Map<IPersist, IDisplay> allFields = a_renderer.getFieldComponents();
Iterator<IDisplay> it = allFields.values().iterator();
while (it.hasNext()) {
IDisplay display = it.next();
if (display instanceof IDisplayData) {
String dataProviderID = ((IDisplayData) display).getDataProviderID();
if (dataProviderID != null) {
IDataProvider dp = application.getFlattenedSolution().getDataproviderLookup(application.getFoundSetManager(), f).getDataProvider(dataProviderID);
if (dp instanceof AggregateVariable) {
if (!aggregates.contains(dp))
aggregates.add((AggregateVariable) dp);
}
} else if (display instanceof IDisplayTagText) {
String tagText = ((IDisplayTagText) display).getTagText();
Text.processTags(tagText, new ITagResolver() {
public String getStringValue(String name) {
try {
IDataProvider dp = application.getFlattenedSolution().getDataproviderLookup(application.getFoundSetManager(), f).getDataProvider(name);
if (dp instanceof AggregateVariable) {
if (!aggregates.contains(dp))
aggregates.add((AggregateVariable) dp);
}
} catch (Exception e) {
Debug.error(e);
}
return null;
}
});
}
}
}
}
use of com.servoy.j2db.persistence.IDataProvider in project servoy-client by Servoy.
the class DataProviderEditor method fillDataProviderList.
protected void fillDataProviderList() {
try {
ITable table = null;
if (definedTable == null) {
FormManager fm = (FormManager) application.getFormManager();
FormController fc = fm.getCurrentMainShowingFormController();
if (fc != null) {
Form form = fc.getForm();
table = application.getFlattenedSolution().getTable(form.getDataSource());
}
} else {
if (!showRelatedOptionsOnly)
table = definedTable;
}
DefaultListModel model = (DefaultListModel) list.getModel();
model.removeAllElements();
if (showNoneOption)
model.addElement("-none-");
if (!showColumnsOnly)
model.addElement("*columns");
Object o = relationsComboBox.getSelectedItem();
if (o != null) {
if (o instanceof String) {
// table = form.getTable();
} else {
table = application.getFlattenedSolution().getTable(((Relation) o).getForeignDataSource());
}
if (table != null) {
Iterator<Column> it = table.getColumnsSortedByName();
while (it.hasNext()) {
IColumn c = it.next();
ColumnInfo ci = c.getColumnInfo();
if (ci != null && ci.isExcluded()) {
continue;
}
if (hideMediaColumns) {
// use dataprovider type as defined by column converter
ComponentFormat componentFormat = ComponentFormat.getComponentFormat(null, c, application);
if (componentFormat.dpType == IColumnTypes.MEDIA) {
continue;
}
}
model.addElement(c);
}
}
}
FlattenedSolution s = application.getFlattenedSolution();
if (table != null && !showColumnsOnly) {
Iterator it = s.getScriptCalculations(table, true);
if (it.hasNext()) {
model.addElement("*calculations");
}
while (it.hasNext()) {
ScriptCalculation sc = (ScriptCalculation) it.next();
for (int i = 0; i < model.size(); i++) {
Object obj = model.elementAt(i);
if (obj instanceof IDataProvider) {
IDataProvider dp = (IDataProvider) obj;
if (dp.getDataProviderID().equals(sc.getDataProviderID())) {
// remove the column from the list if use by
model.remove(i);
// stored calc
break;
}
}
}
model.addElement(sc);
}
Iterator it2 = s.getScriptVariables(true);
if (it2.hasNext()) {
model.addElement("*globals");
}
while (it2.hasNext()) {
model.addElement(it2.next());
}
Iterator it3 = s.getAggregateVariables(table, true);
if (it3.hasNext()) {
model.addElement("*aggregates");
}
while (it3.hasNext()) {
model.addElement(it3.next());
}
}
if (table != null && showColumnsOnly && showSortableOnly) {
Iterator it3 = s.getAggregateVariables(table, true);
while (it3.hasNext()) {
model.addElement(it3.next());
}
}
if (showGlobalsOption && showColumnsOnly) {
Iterator it2 = s.getScriptVariables(true);
if (it2.hasNext()) {
model.addElement("*globals");
}
while (it2.hasNext()) {
model.addElement(it2.next());
}
}
} catch (Exception ex) {
Debug.error(ex);
}
}
Aggregations