Package ke.go.moh.oec.mpi.list

Examples of ke.go.moh.oec.mpi.list.FingerprintList


                + "WHERE p.person_id BETWEEN " + minPersonId + " AND " + maxPersonId + " -- Thread " + threadIndex + "\n" // Comment for logging.
                + "GROUP BY p.person_id\n"
                + "ORDER BY p.person_id";
        ResultSet rs = Sql.query(conn, sql);
        int recordCount = 0;
        FingerprintList fingerprintList = new FingerprintList();
        fingerprintList.loadStart(minPersonId, maxPersonId);
        PersonIdentifierList personIdentifierList = new PersonIdentifierList();
        personIdentifierList.loadStart(minPersonId, maxPersonId);
        try {
            // Define ingeger variables to hold column index numbers.
            //
            // When loading the MPI from the database, it is substantially faster to
            // access the recordset by column number than by column name. This was
            // discovered by CPU profiling of the original code which used column name.
            //
            // On the other hand, it would be less code just to refer to the column numbers
            // rather than go through the trouble of defining integers and then looking
            // up the column indices. But this would be more error prone, in the event
            // that the list of columns is ever changed. So we define ingteger variables
            // for all the column indices, and then load them on the first result set.
            int colPersonId = 0, colPersonGuid = 0, colSex = 0, colBirthdate = 0, colDeathdate = 0,
                    colFirstName = 0, colMiddleName = 0, colLastName = 0, colOtherName = 0, colClanName = 0,
                    colMothersFirstName = 0, colMothersMiddleName = 0, colMothersLastName = 0,
                    colFathersFirstName = 0, colFathersMiddleName = 0, colFathersLastName = 0,
                    colCompoundheadFirstName = 0, colCompoundheadMiddleName = 0, colCompoundheadLastName = 0,
                    colVillageName = 0, colMaritalStatusName = 0, colConsentSigned = 0,
                    colVisitRegDate = 0, colVisitOneDate = 0, colVisitRegAddress = 0,colVisitRegFacility = 0, colVisitOneAddress = 0;
            boolean colsFound = false; // Have we found the column numbers yet?
            while (rs.next()) {
                if (!colsFound) {
                    colPersonId = rs.findColumn("person_id");
                    colPersonGuid = rs.findColumn("person_guid");
                    colSex = rs.findColumn("sex");
                    colBirthdate = rs.findColumn("birthdate");
                    colDeathdate = rs.findColumn("deathdate");
                    colFirstName = rs.findColumn("first_name");
                    colMiddleName = rs.findColumn("middle_name");
                    colLastName = rs.findColumn("last_name");
                    colOtherName = rs.findColumn("other_name");
                    colClanName = rs.findColumn("clan_name");
                    colMothersFirstName = rs.findColumn("mothers_first_name");
                    colMothersMiddleName = rs.findColumn("mothers_middle_name");
                    colMothersLastName = rs.findColumn("mothers_last_name");
                    colFathersFirstName = rs.findColumn("fathers_first_name");
                    colFathersMiddleName = rs.findColumn("fathers_middle_name");
                    colFathersLastName = rs.findColumn("fathers_last_name");
                    colCompoundheadFirstName = rs.findColumn("compoundhead_first_name");
                    colCompoundheadMiddleName = rs.findColumn("compoundhead_middle_name");
                    colCompoundheadLastName = rs.findColumn("compoundhead_last_name");
                    colVillageName = rs.findColumn("village_name");
                    colMaritalStatusName = rs.findColumn("marital_status_name");
                    colConsentSigned = rs.findColumn("consent_signed");
                    colVisitRegDate = rs.findColumn("visit_reg_date");
                    colVisitOneDate = rs.findColumn("visit_reg_address");
                    colVisitRegAddress = rs.findColumn("visit_one_date");
                    colVisitOneAddress = rs.findColumn("visit_one_address");
                    colVisitRegFacility = rs.findColumn("visit_reg_facility");
                    colsFound = true;
                }
                Person p = new Person();
                int dbPersonId = rs.getInt(colPersonId);
                p.setPersonGuid(getRsString(rs, colPersonGuid));
                p.setSex((Person.Sex) ValueMap.SEX.getVal().get(getRsString(rs, colSex)));
                p.setBirthdate(rs.getDate(colBirthdate, cal));
                p.setDeathdate(rs.getDate(colDeathdate, cal));
                p.setFirstName(getRsString(rs, colFirstName));
                p.setMiddleName(getRsString(rs, colMiddleName));
                p.setLastName(getRsString(rs, colLastName));
                p.setOtherName(getRsString(rs, colOtherName));
                p.setClanName(getRsString(rs, colClanName));
                p.setMothersFirstName(getRsString(rs, colMothersFirstName));
                p.setMothersMiddleName(getRsString(rs, colMothersMiddleName));
                p.setMothersLastName(getRsString(rs, colMothersLastName));
                p.setFathersFirstName(getRsString(rs, colFathersFirstName));
                p.setFathersMiddleName(getRsString(rs, colFathersMiddleName));
                p.setFathersLastName(getRsString(rs, colFathersLastName));
                p.setCompoundHeadFirstName(getRsString(rs, colCompoundheadFirstName));
                p.setCompoundHeadMiddleName(getRsString(rs, colCompoundheadMiddleName));
                p.setCompoundHeadLastName(getRsString(rs, colCompoundheadLastName));
                p.setVillageName(getRsString(rs, colVillageName));
                p.setMaritalStatus((Person.MaritalStatus) ValueMap.MARITAL_STATUS.getVal().get(getRsString(rs, colMaritalStatusName)));
                p.setPersonIdentifierList(personIdentifierList.loadNext(dbPersonId));
                p.setFingerprintList(fingerprintList.loadNext(dbPersonId));
                p.setConsentSigned((Person.ConsentSigned) ValueMap.CONSENT_SIGNED.getVal().get(getRsString(rs, colConsentSigned)));
                p.setLastRegularVisit(Visit.getVisit(rs.getDate(colVisitRegDate), getRsString(rs, colVisitOneDate),getRsString(rs, colVisitRegFacility)));
                p.setLastOneOffVisit(Visit.getVisit(rs.getDate(colVisitRegAddress), getRsString(rs, colVisitOneAddress),getRsString(rs, colVisitRegFacility)));
                PersonMatch per = new PersonMatch(p);
                per.setDbPersonId(dbPersonId);
                personMatchList.add(per);
                if (++recordCount % 10000 == 0) {
                    double timeInterval = (System.currentTimeMillis() - startTime);
                    Mediator.getLogger(LoadPersonThread.class.getName()).log(Level.FINE,
                            "Thread {0} loaded {1} entries in {2} milliseconds.",
                            new Object[]{threadIndex, recordCount, timeInterval});
                }
            }
        } catch (SQLException ex) {
            Logger.getLogger(LoadPersonThread.class.getName()).log(Level.SEVERE, null, ex);
            System.exit(1);
        }
        Sql.close(rs);
        Sql.close(conn);
        fingerprintList.loadEnd();
        personIdentifierList.loadEnd();
                double timeInterval = (System.currentTimeMillis() - startTime);
                Mediator.getLogger(LoadPersonThread.class.getName()).log(Level.FINE,
                        "Thread {0} finished loading {1} entries in {2} milliseconds.",
                        new Object[]{threadIndex, personMatchList.size(), timeInterval});
View Full Code Here

TOP

Related Classes of ke.go.moh.oec.mpi.list.FingerprintList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.