use of com.servoy.j2db.persistence.Table in project servoy-client by Servoy.
the class EditRecordList method getRecordUpdateInfo.
/*
* _____________________________________________________________ Methods for data manipulation
*/
private RowUpdateInfo getRecordUpdateInfo(IRecordInternal state) throws ServoyException {
Table table = state.getParentFoundSet().getSQLSheet().getTable();
RowManager rowManager = fsm.getRowManager(fsm.getDataSource(table));
Row rowData = state.getRawData();
boolean doesExistInDB = rowData.existInDB();
if (doesExistInDB && !hasAccess(table, IRepository.UPDATE)) {
throw new ApplicationException(ServoyException.NO_MODIFY_ACCESS, new Object[] { table.getName() });
}
GlobalTransaction gt = fsm.getGlobalTransaction();
if (gt != null) {
gt.addRecord(table.getServerName(), state);
}
RowUpdateInfo rowUpdateInfo = rowManager.getRowUpdateInfo(rowData, hasAccess(table, IRepository.TRACKING));
return rowUpdateInfo;
}
use of com.servoy.j2db.persistence.Table in project servoy-client by Servoy.
the class DBValueList method getShowDataproviders.
public static List<String> getShowDataproviders(ValueList valueList, Table callingTable, String dataProviderID, IFoundSetManagerInternal foundSetManager) throws RepositoryException {
if (valueList == null) {
return null;
}
FlattenedSolution flattenedSolution = foundSetManager.getApplication().getFlattenedSolution();
// Find destination table in case dataProviderID is related
String[] split = dataProviderID.split("\\.");
String dataSource = callingTable.getDataSource();
for (// first parts are relation names, last part is column name
int i = 0; // first parts are relation names, last part is column name
i < split.length - 1; // first parts are relation names, last part is column name
i++) {
Relation relation = flattenedSolution.getRelation(split[i]);
if (relation == null || !relation.getPrimaryDataSource().equals(dataSource)) {
return null;
}
dataSource = relation.getForeignDataSource();
}
Table table = (Table) foundSetManager.getTable(dataSource);
String columnName = split[split.length - 1];
String prefix = dataProviderID.substring(0, dataProviderID.length() - columnName.length());
// first try fallback value list,
ValueList usedValueList = flattenedSolution.getValueList(valueList.getFallbackValueListID());
Relation valuelistSortRelation = flattenedSolution.getValuelistSortRelation(usedValueList, table, columnName, foundSetManager);
if (valuelistSortRelation == null) {
// then try regular value list
usedValueList = valueList;
valuelistSortRelation = flattenedSolution.getValuelistSortRelation(usedValueList, table, columnName, foundSetManager);
}
if (valuelistSortRelation == null) {
return null;
}
List<String> showDataproviders = new ArrayList<String>(3);
int showValues = usedValueList.getShowDataProviders();
if ((showValues & 1) != 0) {
showDataproviders.add(prefix + valuelistSortRelation.getName() + '.' + usedValueList.getDataProviderID1());
}
if ((showValues & 2) != 0) {
showDataproviders.add(prefix + valuelistSortRelation.getName() + '.' + usedValueList.getDataProviderID2());
}
if ((showValues & 4) != 0) {
showDataproviders.add(prefix + valuelistSortRelation.getName() + '.' + usedValueList.getDataProviderID3());
}
return showDataproviders;
}
use of com.servoy.j2db.persistence.Table in project servoy-client by Servoy.
the class FoundSetManager method getFoundSetCount.
public int getFoundSetCount(IFoundSetInternal fs) {
if (fs instanceof FoundSet && fs.getTable() != null) {
FoundSet foundset = (FoundSet) fs;
try {
// optimize
if (foundset.isInitialized() && !foundset.hadMoreRows()) {
return foundset.getSize();
}
long time = System.currentTimeMillis();
IDataServer ds = application.getDataServer();
Table t = (Table) foundset.getTable();
String transaction_id = getTransactionID(t.getServerName());
QuerySelect sqlString = foundset.getQuerySelectForReading();
// $NON-NLS-1$
QuerySelect selectCountSQLString = sqlString.getSelectCount("n", true);
IDataSet set = ds.performQuery(application.getClientID(), t.getServerName(), transaction_id, selectCountSQLString, null, getTableFilterParams(t.getServerName(), selectCountSQLString), false, 0, 10, IDataServer.FOUNDSET_LOAD_QUERY);
if (Debug.tracing()) {
Debug.trace(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
"Foundset count time: " + (System.currentTimeMillis() - time) + " thread: " + Thread.currentThread().getName() + ", SQL: " + selectCountSQLString.toString());
}
if (set.getRowCount() > 0) {
Object[] row = set.getRow(0);
if (row.length > 0) {
return Utils.getAsInteger(row[0]);
}
}
} catch (Exception e) {
Debug.error(e);
}
}
return -1;
}
Aggregations