blob: 4325b15257e86b1e27863d224df74d729a8d44c4 (
plain) (
tree)
|
|
package org.openslx.bwlp.sat.thrift.cache;
import java.sql.SQLException;
import java.util.List;
import org.apache.thrift.TException;
import org.openslx.bwlp.sat.database.mappers.DbOrganization;
import org.openslx.bwlp.thrift.iface.Organization;
import org.openslx.thrifthelper.ThriftManager;
import org.openslx.util.QuickTimer;
import org.openslx.util.QuickTimer.Task;
/**
* Holds the list of all known organizations. The list is synchronized with
* the master server.
*/
public class OrganizationList extends CacheBase<List<Organization>> {
private static final OrganizationList instance = new OrganizationList();
public static List<Organization> get() {
return instance.getInternal();
}
@Override
protected List<Organization> getCallback() throws TException {
final List<Organization> organizations = ThriftManager.getMasterClient().getOrganizations();
// Also store the list in the local data base (asynchronous, in the timer thread)
QuickTimer.scheduleOnce(new Task() {
@Override
public void fire() {
try {
DbOrganization.storeOrganizations(organizations);
} catch (SQLException e) {
}
}
});
return organizations;
}
}
|