1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284:
This is the code where Iam getting this error mostly: this is the function from "ReportManagerBean.java" public synchronized void updateReport(Report report) throws ReportNotFoundException, ReportUpdateException { ReportRecordLocal reportRec; Log log = LogFactory.getFactory().getInstance(this.getClass()); try { reportRec = reportRecHome.findByPrimaryKey(report.getId()); } catch (FinderException fe) { if (fe instanceof ObjectNotFoundException) { throw new ReportNotFoundException(fe); } else { String msg = "error finding report: " + report.getId(); log.error(msg, fe); throw new EJBException(fe); } } // update the report record reportRec.setBeat(report.getBeat()); reportRec.setCaseNumber(report.getCaseNumber()); reportRec.setChargeType(report.getChargeType()); reportRec.setDetail(report.getDetail()); reportRec.setDisposition(report.getDisposition()); reportRec.setIncidentDate(report.getIncidentDate()); reportRec.setLocation(report.getLocation()); reportRec.setReportDate(report.getReportDate()); reportRec.setConfidential(report.getConfidential()); reportRec.setIncident(report.getIncident()); reportRec.setPlaceOfOccurrence(report.getPlaceOfOccurrence()); reportRec.setTimeCommitted(report.getTimeCommitted()); reportRec.setDateCommitted(report.getDateCommitted()); reportRec.setOic(report.getOic()); reportRec.setFormType(report.getFormType()); reportRec.setAgeClass(report.getAgeClass()); reportRec.setSupplement(report.isSupplement()); reportRec.setStatus(report.getStatus()); reportRec.setComplainantName(report.getComplainantName()); reportRec.setErrors(report.hasErrors()); reportRec.setDateLocked(report.getDateLocked()); reportRec.setFlags(report.getFlags()); // update the primary document if ( report.getPrimaryDocument() != null ) { FileInfo file = report.getPrimaryDocument(); RepositoryFileRecordLocal fileRec = reportRec.getPrimaryDocument(); fileRec.setCreatedBy( file.getCreatedBy() ); fileRec.setDateModified( file.getDateModified() ); fileRec.setMimeType( file.getMimeType() ); fileRec.setName( file.getName() ); } // update the primary document if ( report.getFinalDocument() != null ) { FileInfo file = report.getFinalDocument(); RepositoryFileRecordLocal fileRec = reportRec.getFinalDocument(); fileRec.setCreatedBy( file.getCreatedBy() ); fileRec.setDateModified( file.getDateModified() ); fileRec.setMimeType( file.getMimeType() ); fileRec.setName( file.getName() ); } // create the persons Collection persons = report.getPersons(); //Collection personRecs = reportRec.getPersons(); // BEGIN TEMP Collection personRecs = reportRec.getPersonAssoc(); Iterator personRecsItr = personRecs.iterator(); Collection tempCollection = new HashSet(); while (personRecsItr.hasNext()) { PersonReportRecordLocal pr = (PersonReportRecordLocal) personRecsItr.next(); try { tempCollection.add(personRecHome.findByPrimaryKey(pr.getPersonId())); } catch (Exception ex) { ; } } personRecs = tempCollection; // END TEMP Set recsToRemove = new HashSet(); recsToRemove.addAll(personRecs); if (persons != null) { Iterator iter = persons.iterator(); try{ while (iter.hasNext()) { Person person = (Person) iter.next(); if ( person.getFirstName() == null && person.getMiddleName() == null && person.getLastName() == null ) continue; PersonRecordLocal personRec = null; if ( person.getId() != null ) { // look for an existing person record //Iterator prIter = reportRec.getPersons().iterator(); //BEGIN TEMP Iterator prIter = personRecs.iterator(); //END TEMP while ( prIter.hasNext() ) { PersonRecordLocal pr = (PersonRecordLocal) prIter.next(); if ( pr.getId() == person.getId() ) { personRec = pr; break; } } } // query database for existing person Map personQuery = new HashMap(); Object[] args = new Object[4]; if (person.getLastName() == null) person.setLastName(""); args[0] = person.getLastName().toLowerCase() + "%"; if (person.getFirstName() == null) person.setFirstName(""); args[1] = person.getFirstName().toLowerCase() + "%"; if (person.getMiddleName() == null) person.setMiddleName(""); args[2] = person.getMiddleName().toLowerCase() + "%"; if (person.getSsn() == null) person.setSsn(""); args[3] = person.getSsn().toLowerCase() + "%"; // check if person already exists in database // by full name and ssn String queryBase = "SELECT OBJECT(p) FROM PersonRecord p WHERE " + "LCASE(p.lastName) LIKE ?1" + "AND " + "LCASE(p.firstName) LIKE ?2" + "AND " + "LCASE(p.middleName) LIKE ?3" + "AND " + "LCASE(p.ssn) LIKE ?4"; Collection existingPersons = personRecHome.findPersons(queryBase, args); if (existingPersons != null) { Iterator prIter = existingPersons.iterator(); if ( prIter.hasNext() ) { PersonRecordLocal pr = (PersonRecordLocal) prIter.next(); person.setId(pr.getId()); personRec = pr; } } else { // check if person already exists in database // only by full name queryBase = "SELECT OBJECT(p) FROM PersonRecord p WHERE " + "LCASE(p.lastName) LIKE ?1" + "AND " + "LCASE(p.firstName) LIKE ?2" + "AND " + "LCASE(p.middleName) LIKE ?3"; Object[] nameArgs = new Object[3]; for (int i=0; i < 3; i++) nameArgs[i] = args[i]; existingPersons = personRecHome.findPersons(queryBase, nameArgs); if (existingPersons != null) { Iterator prIter = existingPersons.iterator(); if ( prIter.hasNext() ) { PersonRecordLocal pr = (PersonRecordLocal) prIter.next(); person.setId(pr.getId()); personRec = pr; } } } if ( personRec == null ) { personRec = personRecHome.create( person.getFirstName(), person.getMiddleName(), person.getLastName(), person.getAddress(), person.getPhone(), person.getDob(), person.getSex(), person.getRace(), person.getHeight(), person.getWeight(), person.getHair(), person.getEyes(), person.getSsn()); // add the person to the person set personRecs.add( personRec ); } else { if (person.getFirstName() != null) personRec.setFirstName( person.getFirstName() ); if (person.getMiddleName() != null) personRec.setMiddleName( person.getMiddleName() ); if (person.getLastName() != null) personRec.setLastName( person.getLastName() ); if (person.getAddress() != null) personRec.setAddress( person.getAddress() ); if (person.getPhone() != null) personRec.setPhone( person.getPhone() ); if (person.getDob() != null) personRec.setDob( person.getDob() ); if (person.getSex() != null) personRec.setSex( person.getSex() ); if (person.getRace() != null) personRec.setRace( person.getRace() ); if (person.getHeight() != null) personRec.setHeight( person.getHeight() ); if (person.getWeight() != null) personRec.setWeight( person.getWeight() ); if (person.getHair() != null) personRec.setHair( person.getHair() ); if (person.getEyes() != null) personRec.setEyes( person.getEyes() ); if (person.getSsn() != null) personRec.setSsn( person.getSsn() ); recsToRemove.remove(personRec); } // create a person report reference for this entry // if one doesn't already exist try { PersonReportRecordLocal existingRef = personReportRecHome.findByPrimaryKey( new PersonReportRecordPK( personRec.getId(), report.getId()) ); } catch (FinderException fe) { PersonReportRecordLocal personReportRec = personReportRecHome.create( personRec.getId(), report.getId()); } Collection roles = person.getRoles(); if (roles != null) { Collection personRecRoles = personRec.getRoles(); Iterator prrIter = personRecRoles.iterator(); Set oldRoles = new HashSet(); while ( prrIter.hasNext() ) { PersonRoleRecordLocal prr = (PersonRoleRecordLocal) prrIter.next(); if ( ! roles.contains( prr.getRole() ) ) { prrIter.remove(); prr.remove(); } else { oldRoles.add( prr.getRole() ); } } Iterator roleIter = roles.iterator(); while (roleIter.hasNext()) { String role = (String) roleIter.next(); if ( ! oldRoles.contains( role )) { PersonRoleRecordLocal roleRec = roleRecHome.create( personRec.getId(), role); personRecRoles.add(roleRec); } } } else { Iterator prrIter = personRec.getRoles().iterator(); while ( prrIter.hasNext() ) { PersonRoleRecordLocal prr = (PersonRoleRecordLocal) prrIter.next(); prrIter.remove(); prr.remove(); } } } } catch (Exception ce) { log.error( ce ); throw new ReportUpdateException( "error updating report " + report.getId() ); } }