Example usage for com.google.gwt.gears.client.database ResultSet getFieldAsInt

List of usage examples for com.google.gwt.gears.client.database ResultSet getFieldAsInt

Introduction

In this page you can find the example usage for com.google.gwt.gears.client.database ResultSet getFieldAsInt.

Prototype

public int getFieldAsInt(int fieldIndex) throws DatabaseException 

Source Link

Document

Retrieves the value of the field at fieldIndex as an int.

Usage

From source file:org.sigmah.client.offline.sigmah.dao.OrganizationDAO.java

License:Open Source License

private static OrganizationDTO asOrganizationDTO(ResultSet resultSet) throws DatabaseException {
    if (resultSet == null || !resultSet.isValidRow())
        return null;

    final OrganizationDTO organizationDTO = new OrganizationDTO();
    organizationDTO.setId(resultSet.getFieldAsInt(0));
    organizationDTO.setName(resultSet.getFieldAsString(1));
    organizationDTO.setLogo(resultSet.getFieldAsString(2));

    // Temporary value
    final OrgUnitDTO orgUnitDTO = new OrgUnitDTO();
    orgUnitDTO.setId(resultSet.getFieldAsInt(3));

    organizationDTO.setRoot(orgUnitDTO);

    return organizationDTO;
}

From source file:org.sigmah.client.offline.sigmah.dao.OrganizationDAO.java

License:Open Source License

private static OrgUnitDTO asOrgUnitDTO(ResultSet resultSet) throws DatabaseException {
    if (resultSet == null || !resultSet.isValidRow())
        return null;

    final OrgUnitDTO orgUnitDTO = new OrgUnitDTO();
    orgUnitDTO.setId(resultSet.getFieldAsInt(0));
    orgUnitDTO.setName(resultSet.getFieldAsString(1));
    orgUnitDTO.setFullName(resultSet.getFieldAsString(2));
    orgUnitDTO.setOrgUnitModel(getDummyOrgUnitModel(resultSet.getFieldAsInt(3)));
    orgUnitDTO.setOrganization(null);//from w ww  .  j a v  a 2 s  . c o m
    orgUnitDTO.setParent(null);
    orgUnitDTO.setCalendarId(resultSet.getFieldAsInt(9));
    orgUnitDTO.setOfficeLocationCountry(null);

    return orgUnitDTO;
}

From source file:org.sigmah.client.offline.sigmah.OnlineMode.java

License:Open Source License

/**
 * Read the current mode in the local database.
 * @return <code>true</code> if the user is in online mode, <code>false</code> otherwise.
 */// www  .  jav a  2  s  . c om
public boolean isOnline() {
    checkPermission(false);

    if (localDatabase != null) {
        localDatabase.open(LOCAL_DATABASE_NAME);
        try {
            final ResultSet result = localDatabase.execute("SELECT online FROM status WHERE id = 1");
            return asBoolean(result.getFieldAsInt(0));

        } catch (DatabaseException ex) {
            // Most likely, the database doesn't exists.
            Log.debug("Error while trying to determine the current mode.", ex);

        } finally {
            try {
                localDatabase.close();
            } catch (DatabaseException ex) {
                Log.debug("Database closing error.", ex);
            }
        }
    }

    return true;
}