1 4 5 6 package org.enhydra.shark.eventaudit; 7 8 import java.math.BigDecimal ; 9 import java.util.ArrayList ; 10 import java.util.HashMap ; 11 import java.util.Iterator ; 12 import java.util.List ; 13 import java.util.Map ; 14 15 import net.sf.hibernate.Query; 16 import net.sf.hibernate.Session; 17 18 import org.enhydra.shark.api.RootException; 19 import org.enhydra.shark.api.SharkTransaction; 20 import org.enhydra.shark.api.internal.eventaudit.AssignmentEventAuditPersistenceInterface; 21 import org.enhydra.shark.api.internal.eventaudit.CreateProcessEventAuditPersistenceInterface; 22 import org.enhydra.shark.api.internal.eventaudit.DataEventAuditPersistenceInterface; 23 import org.enhydra.shark.api.internal.eventaudit.EventAuditException; 24 import org.enhydra.shark.api.internal.eventaudit.EventAuditManagerInterface; 25 import org.enhydra.shark.api.internal.eventaudit.StateEventAuditPersistenceInterface; 26 import org.enhydra.shark.api.internal.working.CallbackUtilities; 27 import org.enhydra.shark.eventaudit.data.HibernateActivityStateEventAudit; 28 import org.enhydra.shark.eventaudit.data.HibernateEventType; 29 import org.enhydra.shark.eventaudit.data.HibernateProcessStateEventAudit; 30 import org.enhydra.shark.transaction.SharkHibernateTransaction; 31 import org.enhydra.shark.transaction.ThreadLocalSession; 32 import org.enhydra.shark.utilities.MiscUtilities; 33 import org.enhydra.shark.utilities.hibernate.HibernateUtilities; 34 35 42 public class HibernateEventAuditManager implements EventAuditManagerInterface { 43 44 private static final String LOG_CHANNEL="Persistence"; 45 private static final String PACKAGE_LOADED="packageLoaded"; 46 private static final String PACKAGE_UNLOADED="packageUnloaded"; 47 private static final String PACKAGE_UPDATED="packageUpdated"; 48 private static final String PROCESS_CREATED="processCreated"; 49 private static final String PROCESS_STATE_CHANGED="processStateChanged"; 50 private static final String PROCESS_CONTEXT_CHANGED="processContextChanged"; 51 private static final String ACTIVITY_STATE_CHANGED="activityStateChanged"; 52 private static final String ACTIVITY_CONTEXT_CHANGED="activityContextChanged"; 53 private static final String ACTIVITY_RESULT_CHANGED="activityResultChanged"; 54 private static final String ACTIVITY_ASSIGNMENT_CHANGED="activityAssignmentChanged"; 55 private static final int RESOURCE_TYPE_OBJECT=0; 56 private static final int PROCESS_DEFINITION_TYPE_OBJECT=1; 57 private static final int PROCESS_TYPE_OBJECT=2; 58 private static final int ACTIVITY_TYPE_OBJECT=3; 59 private static final int ASSIGNMENT_TYPE_OBJECT=4; 60 private static final int EVENT_AUDIT_ASSIGNMENT_TYPE_OBJECT=5; 61 private static final int EVENT_AUDIT_DATA_TYPE_OBJECT=6; 62 private static final int EVENT_AUDIT_STATE_TYPE_OBJECT=7; 63 private static final int EVENT_AUDIT_CREATE_PROCESS_TYPE_OBJECT=8; 64 private static final int EVENT_AUDIT_PACKAGE_TYPE_OBJECT=9; 65 66 private static final String [] activityAndProcessStates={"open.running", 67 "open.not_running.not_started","open.not_running.suspended", 68 "closed.completed", "closed.terminated", "closed.aborted"}; 69 70 private static final String [] eventTypes={PACKAGE_LOADED,PACKAGE_UNLOADED, 71 PACKAGE_UPDATED,PROCESS_CREATED,PROCESS_STATE_CHANGED, 72 PROCESS_CONTEXT_CHANGED,ACTIVITY_STATE_CHANGED,ACTIVITY_CONTEXT_CHANGED, 73 ACTIVITY_RESULT_CHANGED,ACTIVITY_ASSIGNMENT_CHANGED}; 74 75 private CallbackUtilities cus; 76 private boolean deleteFinishedProcesses = false; 77 78 82 public void configure(CallbackUtilities cus) throws RootException { 83 this.cus = cus; 84 String del = cus.getProperty("HibernatePersistentManager.deleteFinishedProcesses"); 85 deleteFinishedProcesses = new Boolean (del).booleanValue(); 86 87 try { 88 try { 89 HibernateUtilities.init(cus.getProperties()); 90 } catch (Throwable ex) { 91 ex.printStackTrace(); 92 } 93 initEventTypesTable(); 94 initActivityAndProcessStatesTable(); 95 } catch (Throwable tr) { 96 cus.error(LOG_CHANNEL, "Problem with registering database manager with Hibernate !", new RootException(tr)); 97 throw new RootException("Problem with registering database manager with Hibernate !", tr); 98 } 99 } 100 101 109 private void initActivityAndProcessStatesTable() throws EventAuditException { 110 SharkHibernateTransaction t = null; 111 try { 112 t = new SharkHibernateTransaction(ThreadLocalSession.currentSession().beginTransaction()); 113 Session session = t.getSession(); 114 for (int i = 0; i < activityAndProcessStates.length; i++) { 115 String state = activityAndProcessStates[i]; 116 HibernateProcessStateEventAudit resultProcessStateEventAudit = getPersistedProcessStateEventAuditObject(state, session); 117 if (resultProcessStateEventAudit == null) { 118 HibernateProcessStateEventAudit hibProcessStateEventAudit = new HibernateProcessStateEventAudit(); 119 hibProcessStateEventAudit.setKeyValue(state); 120 hibProcessStateEventAudit.setName(state); 121 ((SharkHibernateTransaction)t).store(hibProcessStateEventAudit); 122 } else { 123 resultProcessStateEventAudit.setName(state); 124 ((SharkHibernateTransaction)t).store(resultProcessStateEventAudit); 125 } 126 HibernateActivityStateEventAudit resultActivityStateEventAudit = getPersistedActivityStateEventAuditObject(state, session); 127 if (resultActivityStateEventAudit == null) { 128 HibernateActivityStateEventAudit hibActivityStateEventAudit = new HibernateActivityStateEventAudit(); 129 hibActivityStateEventAudit.setKeyValue(state); 130 hibActivityStateEventAudit.setName(state); 131 ((SharkHibernateTransaction)t).store(hibActivityStateEventAudit); 132 } else { 133 resultActivityStateEventAudit.setName(state); 134 ((SharkHibernateTransaction)t).store(resultActivityStateEventAudit); 135 } 136 } 137 ((SharkHibernateTransaction)t).write(); 138 t.commit(); 139 ThreadLocalSession.closeSession(); 140 } catch (Throwable thr) { 141 throw new EventAuditException(thr); 142 } finally { 143 try { 144 t = null; 145 } catch (Exception ex) { 146 } 147 } 148 } 149 150 159 private void initEventTypesTable() throws EventAuditException { 160 SharkHibernateTransaction t = null; 161 try { 162 t = new SharkHibernateTransaction(ThreadLocalSession.currentSession().beginTransaction()); 163 Session session = t.getSession(); 164 for (int i = 0; i < eventTypes.length; i++) { 165 String eventType = eventTypes[i]; 166 HibernateEventType resultEventType = getPersistedEventTypeObject(eventType, session); 167 if (resultEventType == null) { 168 HibernateEventType hibEventType = new HibernateEventType(); 169 hibEventType.setKeyValue(eventType); 170 hibEventType.setName(eventType); 171 ((SharkHibernateTransaction)t).store(hibEventType); 172 } else { 173 resultEventType.setName(eventType); 174 ((SharkHibernateTransaction)t).store(resultEventType); 175 } 176 } 177 ((SharkHibernateTransaction)t).write(); 178 t.commit(); 179 } catch (Throwable thr) { 180 throw new EventAuditException(thr); 181 } finally { 182 try { 183 t = null; 184 } catch (Exception ex) { 185 } 186 } 187 } 188 189 193 public void persist(AssignmentEventAuditPersistenceInterface aea, SharkTransaction ti) throws EventAuditException { 194 try { 195 Session session = ((SharkHibernateTransaction) ti).getSession(); 196 HibernateAssignmentEventAudit hibAssignEA = (HibernateAssignmentEventAudit) createAssignmentEventAudit(); 197 198 if (true) { 200 hibAssignEA.setUTCTime(aea.getUTCTime()); 201 HibernateEventType hibEventType = getPersistedEventTypeObject(aea.getType(), session); 202 hibAssignEA.setType(hibEventType.getName()); 203 hibAssignEA.setEventTypeId(hibEventType.getDbId()); 204 hibAssignEA.setProcessId(aea.getProcessId()); 205 hibAssignEA.setActivityId(aea.getActivityId()); 206 if (aea.getActivityName() != null) { 207 hibAssignEA.setActivityName(aea.getActivityName()); 208 } 209 hibAssignEA.setProcessName(aea.getProcessName()); 210 hibAssignEA.setProcessDefinitionName(aea.getProcessDefinitionName()); 211 hibAssignEA.setProcessDefinitionVersion(aea.getProcessDefinitionVersion()); 212 if (aea.getActivityDefinitionId() != null) { 213 hibAssignEA.setActivityDefinitionId(aea.getActivityDefinitionId()); 214 } 215 hibAssignEA.setProcessDefinitionId(aea.getProcessDefinitionId()); 216 hibAssignEA.setPackageId(aea.getPackageId()); 217 hibAssignEA.setNewResourceUsername(aea.getNewResourceUsername()); 218 if (aea.getNewResourceName() != null) { 219 hibAssignEA.setNewResourceName(aea.getNewResourceName()); 220 } 221 if (aea.getOldResourceUsername() != null) { 222 hibAssignEA.setOldResourceUsername(aea.getOldResourceUsername()); 223 } 224 if (aea.getOldResourceName() != null) { 225 hibAssignEA.setOldResourceName(aea.getOldResourceName()); 226 } 227 hibAssignEA.setIsAccepted(aea.getIsAccepted()); 228 ((SharkHibernateTransaction)ti).store(hibAssignEA); 229 } 230 cus.info(LOG_CHANNEL, "AssignmentEventAudit[processId=" + aea.getProcessId() + ",activityId=" + aea.getActivityId() + "] persisted"); 231 } catch (Throwable tr) { 232 cus.error(LOG_CHANNEL, "Persisting of AssignmentEventAudit failed"); 233 throw new EventAuditException("Persisting of AssignmentEventAudit failed", tr); 234 } 235 } 236 237 public void persist(StateEventAuditPersistenceInterface sea, SharkTransaction ti) throws EventAuditException { 238 try { 239 Session session = ((SharkHibernateTransaction) ti).getSession(); 240 HibernateStateEventAudit hibSEA = (HibernateStateEventAudit) createStateEventAudit(); 241 if (true) { 243 hibSEA.setUTCTime(sea.getUTCTime()); 244 HibernateEventType hibEventType = getPersistedEventTypeObject(sea.getType(), session); 245 hibSEA.setType(hibEventType.getName()); 246 hibSEA.setEventTypeId(hibEventType.getDbId()); 247 hibSEA.setProcessId(sea.getProcessId()); 248 if (sea.getActivityId() != null) { 249 hibSEA.setActivityId(sea.getActivityId()); 250 hibSEA.setNewState(getPersistedActivityStateEventAuditObject(sea.getNewState(), session).getName()); 252 if (sea.getOldState() != null) { 253 hibSEA.setOldState(getPersistedActivityStateEventAuditObject(sea.getOldState(), session).getName()); 255 } 256 } else { 257 hibSEA.setNewState(getPersistedProcessStateEventAuditObject(sea.getNewState(), session).getName()); 259 if (sea.getOldState() != null) { 260 hibSEA.setOldState(getPersistedProcessStateEventAuditObject(sea.getOldState(), session).getName()); 262 } 263 } 264 if (sea.getActivityName() != null) { 265 hibSEA.setActivityName(sea.getActivityName()); 266 } 267 hibSEA.setProcessName(sea.getProcessName()); 268 hibSEA.setProcessDefinitionName(sea.getProcessDefinitionName()); 269 hibSEA.setProcessDefinitionVersion(sea.getProcessDefinitionVersion()); 270 if (sea.getActivityDefinitionId() != null) { 271 hibSEA.setActivityDefinitionId(sea.getActivityDefinitionId()); 272 } 273 hibSEA.setProcessDefinitionId(sea.getProcessDefinitionId()); 274 hibSEA.setPackageId(sea.getPackageId()); 275 ((SharkHibernateTransaction)ti).store(hibSEA); 276 } 278 if (sea.getActivityId() != null) { 279 cus.info(LOG_CHANNEL, "StateEventAudit[processId=" + sea.getProcessId() + ",activityId=" + sea.getActivityId() + "] persisted"); 280 } else { 281 cus.info(LOG_CHANNEL, "StateEventAudit[processId=" + sea.getProcessId() + "] persisted"); 282 } 283 } catch (Throwable tr) { 284 cus.error(LOG_CHANNEL, "Persisting of StateEventAudit failed"); 285 throw new EventAuditException("Persisting of StateEventAudit failed", tr); 287 } 288 } 289 290 public void persist(CreateProcessEventAuditPersistenceInterface cpea, SharkTransaction ti) throws EventAuditException { 291 try { 292 Session session = ((SharkHibernateTransaction) ti).getSession(); 293 HibernateCreateProcessEventAudit hibCpEA = (HibernateCreateProcessEventAudit) createCreateProcessEventAudit(); 294 if (true) { 296 hibCpEA.setUTCTime(cpea.getUTCTime()); 297 HibernateEventType hibEventType = getPersistedEventTypeObject(cpea.getType(), session); 298 hibCpEA.setType(hibEventType.getName()); 299 hibCpEA.setEventTypeId(hibEventType.getDbId()); 300 hibCpEA.setProcessId(cpea.getProcessId()); 301 hibCpEA.setProcessName(cpea.getProcessName()); 302 hibCpEA.setProcessDefinitionId(cpea.getProcessDefinitionId()); 303 hibCpEA.setProcessDefinitionName(cpea.getProcessDefinitionName()); 304 hibCpEA.setProcessDefinitionVersion(cpea.getProcessDefinitionVersion()); 305 hibCpEA.setPackageId(cpea.getPackageId()); 306 if (cpea.getPProcessId() != null) { 307 hibCpEA.setPProcessId(cpea.getPProcessId()); 308 } 309 if (cpea.getPProcessName() != null) { 310 hibCpEA.setPProcessName(cpea.getPProcessName()); 311 } 312 if (cpea.getPActivityId() != null) { 313 hibCpEA.setPActivityId(cpea.getPActivityId()); 314 } 315 if (cpea.getPPackageId() != null) { 316 hibCpEA.setPPackageId(cpea.getPPackageId()); 317 } 318 if (cpea.getPProcessDefinitionId() != null) { 319 hibCpEA.setPProcessDefinitionId(cpea.getPProcessDefinitionId()); 320 } 321 if (cpea.getPActivityDefinitionId() != null) { 322 hibCpEA.setPActivityDefinitionId(cpea.getPActivityDefinitionId()); 323 } 324 if (cpea.getPProcessDefinitionName() != null) { 325 hibCpEA.setPProcessDefinitionName(cpea.getPProcessDefinitionName()); 326 } 327 if (cpea.getPProcessDefinitionVersion() != null) { 328 hibCpEA.setPProcessDefinitionVersion(cpea.getPProcessDefinitionVersion()); 329 } 330 ((SharkHibernateTransaction)ti).store(hibCpEA); 331 } 333 cus.info(LOG_CHANNEL, "CreateProcessEventAudit[processId=" + cpea.getProcessId() + "] persisted"); 334 } catch (Throwable tr) { 335 cus.error(LOG_CHANNEL, "Persisting of CreateProcessEventAudit failed"); 336 throw new EventAuditException("Persisting of CreateProcessEventAudit failed", tr); 337 } 338 } 339 340 public void persist(DataEventAuditPersistenceInterface dea, SharkTransaction ti) throws EventAuditException { 341 try { 342 Session session = ((SharkHibernateTransaction) ti).getSession(); 343 HibernateDataEventAudit hibDEA = (HibernateDataEventAudit) createDataEventAudit(); 344 if (true) { 346 hibDEA.setUTCTime(dea.getUTCTime()); 347 HibernateEventType hibEventType = getPersistedEventTypeObject(dea.getType(), session); 348 hibDEA.setType(hibEventType.getName()); 349 hibDEA.setEventTypeId(hibEventType.getDbId()); 350 hibDEA.setProcessId(dea.getProcessId()); 351 if (dea.getActivityId() != null) { 352 hibDEA.setActivityId(dea.getActivityId()); 353 } 354 if (dea.getActivityName() != null) { 355 hibDEA.setActivityName(dea.getActivityName()); 356 } 357 hibDEA.setProcessName(dea.getProcessName()); 358 hibDEA.setProcessDefinitionName(dea.getProcessDefinitionName()); 359 hibDEA.setProcessDefinitionVersion(dea.getProcessDefinitionVersion()); 360 if (dea.getActivityDefinitionId() != null) { 361 hibDEA.setActivityDefinitionId(dea.getActivityDefinitionId()); 362 } 363 hibDEA.setProcessDefinitionId(dea.getProcessDefinitionId()); 364 hibDEA.setPackageId(dea.getPackageId()); 365 366 if (dea.getOldData() != null) { 367 Map od = dea.getOldData(); 368 Map odS = new HashMap (); 369 Iterator it = od.entrySet().iterator(); 370 while (it.hasNext()) { 371 Map.Entry me = (Map.Entry ) it.next(); 372 odS.put((String ) me.getKey(), MiscUtilities.serialize(me.getValue())); 373 } 374 hibDEA.setOldData(odS); 375 } 376 if (dea.getNewData() != null) { 377 Map nd = dea.getNewData(); 378 Map ndS = new HashMap (); 379 Iterator it = nd.entrySet().iterator(); 380 while (it.hasNext()) { 381 Map.Entry me = (Map.Entry ) it.next(); 382 ndS.put((String ) me.getKey(), MiscUtilities.serialize(me.getValue())); 383 } 384 hibDEA.setNewData(ndS); 385 } 386 ((SharkHibernateTransaction)ti).store(hibDEA); 387 } 389 if (dea.getActivityId() != null) { 390 cus.info(LOG_CHANNEL, "DataEventAudit[processId=" + dea.getProcessId() + ",activityId=" + dea.getActivityId() + "] persisted"); 391 } else { 392 cus.info(LOG_CHANNEL, "DataEventAudit[processId=" + dea.getProcessId() + "] persisted"); 393 } 394 } catch (Throwable tr) { 395 tr.printStackTrace(); 396 cus.error(LOG_CHANNEL, "Persisting of DataEventAudit failed"); 397 throw new EventAuditException("Persisting of DataEventAudit failed", tr); 398 } 399 } 400 401 405 public boolean restore(AssignmentEventAuditPersistenceInterface aea, SharkTransaction ti) throws EventAuditException { 406 try { 407 Session session = ((SharkHibernateTransaction) ti).getSession(); 408 return restore(aea, getPersistedObject(aea, session), session); 409 } catch (Throwable tr) { 410 cus.error(LOG_CHANNEL, "Restoring of AssignmentEventAudit failed"); 411 tr.printStackTrace(); 412 throw new EventAuditException("Restoring of AssignmentEventAudit failed", tr); 413 } 414 } 415 416 private boolean restore(AssignmentEventAuditPersistenceInterface engineObj, HibernateAssignmentEventAudit hibAssignEA, Session s) throws EventAuditException { 417 if (hibAssignEA == null) 418 return false; 419 420 try { 421 engineObj.setUTCTime(hibAssignEA.getUTCTime()); 422 engineObj.setType(getPersistedEventTypeObjectById(hibAssignEA.getEventTypeId(), s).getName()); 423 engineObj.setProcessId(hibAssignEA.getProcessId()); 424 engineObj.setActivityId(hibAssignEA.getActivityId()); 425 if (hibAssignEA.getActivityName() != null) { 426 engineObj.setActivityName(hibAssignEA.getActivityName()); 427 } 428 engineObj.setProcessName(hibAssignEA.getProcessName()); 429 engineObj.setProcessDefinitionName(hibAssignEA.getProcessDefinitionName()); 430 engineObj.setProcessDefinitionVersion(hibAssignEA.getProcessDefinitionVersion()); 431 engineObj.setActivityDefinitionId(hibAssignEA.getActivityDefinitionId()); 432 engineObj.setProcessDefinitionId(hibAssignEA.getProcessDefinitionId()); 433 engineObj.setPackageId(hibAssignEA.getPackageId()); 434 engineObj.setNewResourceUsername(hibAssignEA.getNewResourceUsername()); 435 if (hibAssignEA.getNewResourceName() != null) { 436 engineObj.setNewResourceName(hibAssignEA.getNewResourceName()); 437 } 438 if (hibAssignEA.getOldResourceUsername() != null) { 439 engineObj.setOldResourceUsername(hibAssignEA.getOldResourceUsername()); 440 } 441 if (hibAssignEA.getOldResourceName() != null) { 442 engineObj.setOldResourceName(hibAssignEA.getOldResourceName()); 443 } 444 engineObj.setIsAccepted(hibAssignEA.getIsAccepted()); 445 446 cus.info(LOG_CHANNEL, "AssignmentEventAudit[processId=" + hibAssignEA.getProcessId() + ",activityId=" + hibAssignEA.getActivityId() + "] restored"); 447 } catch (Throwable tr) { 448 cus.error(LOG_CHANNEL, "Restoring of AssignmentEventAudit failed"); 449 throw new EventAuditException("Restoring of AssignmentEventAudit failed", tr); 450 } 451 return true; 452 } 453 454 public boolean restore(DataEventAuditPersistenceInterface dea, SharkTransaction ti) throws EventAuditException { 455 try { 456 Session session = ((SharkHibernateTransaction) ti).getSession(); 457 return restore(dea, getPersistedObject(dea, session), session); 458 } catch (Throwable tr) { 459 cus.error(LOG_CHANNEL, "Restoring of DataEventAudit failed"); 460 tr.printStackTrace(); 461 throw new EventAuditException("Restoring of DataEventAudit failed", tr); 462 } 463 } 464 private boolean restore(DataEventAuditPersistenceInterface engineObj, HibernateDataEventAudit hibDEA, Session s) throws EventAuditException { 465 if (hibDEA == null) 466 return false; 467 468 try { 469 engineObj.setUTCTime(hibDEA.getUTCTime()); 470 engineObj.setType(getPersistedEventTypeObjectById(hibDEA.getEventTypeId(), s).getName()); 471 engineObj.setProcessId(hibDEA.getProcessId()); 472 if (hibDEA.getActivityId() != null) { 473 engineObj.setActivityId(hibDEA.getActivityId()); 474 } 475 if (hibDEA.getActivityName() != null) { 476 engineObj.setActivityName(hibDEA.getActivityName()); 477 } 478 engineObj.setProcessName(hibDEA.getProcessName()); 479 engineObj.setProcessDefinitionName(hibDEA.getProcessDefinitionName()); 480 engineObj.setProcessDefinitionVersion(hibDEA.getProcessDefinitionVersion()); 481 if (hibDEA.getActivityDefinitionId() != null) { 482 engineObj.setActivityDefinitionId(hibDEA.getActivityDefinitionId()); 483 } 484 engineObj.setProcessDefinitionId(hibDEA.getProcessDefinitionId()); 485 engineObj.setPackageId(hibDEA.getPackageId()); 486 engineObj.setOldData(hibDEA.getOldData()); 489 engineObj.setNewData(hibDEA.getNewData()); 490 491 if (hibDEA.getActivityId() != null) { 492 cus.info(LOG_CHANNEL, "DataEventAudit[processId=" + hibDEA.getProcessId() + ",activityId=" + hibDEA.getActivityId() + "] restored"); 493 } else { 494 cus.info(LOG_CHANNEL, "DataEventAudit[processId=" + hibDEA.getProcessId() + "] restored"); 495 } 496 } catch (Throwable tr) { 497 cus.error(LOG_CHANNEL, "Restoring of DataEventAudit failed"); 498 throw new EventAuditException("Restoring of DataEventAudit failed", tr); 499 } 500 return true; 501 } 502 503 public boolean restore(StateEventAuditPersistenceInterface sea, SharkTransaction ti) throws EventAuditException { 504 try { 505 Session session = ((SharkHibernateTransaction) ti).getSession(); 506 return restore(sea, getPersistedObject(sea, session), session); 507 } catch (Throwable tr) { 508 cus.error(LOG_CHANNEL, "Restoring of StateEventAudit failed"); 509 tr.printStackTrace(); 510 throw new EventAuditException("Restoring of StateEventAudit failed", tr); 511 } 512 } 513 514 private boolean restore(StateEventAuditPersistenceInterface engineObj, HibernateStateEventAudit hibSEA, Session s) throws EventAuditException { 515 if (hibSEA == null) 516 return false; 517 518 try { 519 engineObj.setUTCTime(hibSEA.getUTCTime()); 520 engineObj.setType(getPersistedEventTypeObjectById(hibSEA.getEventTypeId(), s).getName()); 521 engineObj.setProcessId(hibSEA.getProcessId()); 522 if (hibSEA.getActivityId() != null) { 523 engineObj.setActivityId(hibSEA.getActivityId()); 524 } 525 if (hibSEA.getActivityName() != null) { 526 engineObj.setActivityName(hibSEA.getActivityName()); 527 } 528 engineObj.setProcessName(hibSEA.getProcessName()); 529 engineObj.setProcessDefinitionName(hibSEA.getProcessDefinitionName()); 530 engineObj.setProcessDefinitionVersion(hibSEA.getProcessDefinitionVersion()); 531 if (hibSEA.getActivityDefinitionId() != null) { 532 engineObj.setActivityDefinitionId(hibSEA.getActivityDefinitionId()); 533 } 534 engineObj.setProcessDefinitionId(hibSEA.getProcessDefinitionId()); 535 engineObj.setPackageId(hibSEA.getPackageId()); 536 engineObj.setNewState(hibSEA.getNewState()); 537 if (hibSEA.getOldState() != null) { 538 engineObj.setOldState(hibSEA.getOldState()); 539 } 540 541 if (hibSEA.getActivityId() != null) { 542 cus.info(LOG_CHANNEL, "StateEventAudit[processId=" + hibSEA.getProcessId() + ",activityId=" + hibSEA.getActivityId() + "] restored"); 543 } else { 544 cus.info(LOG_CHANNEL, "StateEventAudit[processId=" + hibSEA.getProcessId() + "] restored"); 545 } 546 } catch (Throwable tr) { 547 cus.error(LOG_CHANNEL, "Restoring of StateEventAudit failed"); 548 throw new EventAuditException("Restoring of StateEventAudit failed", tr); 549 } 550 return true; 551 } 552 553 public boolean restore(CreateProcessEventAuditPersistenceInterface cpea, SharkTransaction ti) throws EventAuditException { 554 try { 555 Session session = ((SharkHibernateTransaction) ti).getSession(); 556 return restore(cpea, getPersistedObject(cpea, session), session); 557 } catch (Throwable tr) { 558 cus.error(LOG_CHANNEL, "Restoring of CreateProcessEventAudit failed"); 559 tr.printStackTrace(); 560 throw new EventAuditException("Restoring of CreateProcessEventAudit failed", tr); 561 } 562 } 563 564 private boolean restore(CreateProcessEventAuditPersistenceInterface engineObj, HibernateCreateProcessEventAudit hibCpEA, Session s) throws EventAuditException { 565 if (hibCpEA == null) 566 return false; 567 568 try { 569 engineObj.setUTCTime(hibCpEA.getUTCTime()); 570 engineObj.setType(getPersistedEventTypeObjectById(hibCpEA.getEventTypeId(), s).getName()); 571 engineObj.setProcessId(hibCpEA.getProcessId()); 572 engineObj.setProcessName(hibCpEA.getProcessName()); 573 engineObj.setProcessDefinitionId(hibCpEA.getProcessDefinitionId()); 574 engineObj.setProcessDefinitionName(hibCpEA.getProcessDefinitionName()); 575 engineObj.setProcessDefinitionVersion(hibCpEA.getProcessDefinitionVersion()); 576 engineObj.setPackageId(hibCpEA.getPackageId()); 577 if (hibCpEA.getPProcessId() != null) { 578 engineObj.setPProcessId(hibCpEA.getPProcessId()); 579 } 580 if (hibCpEA.getPProcessName() != null) { 581 engineObj.setPProcessName(hibCpEA.getPProcessName()); 582 } 583 if (hibCpEA.getPActivityId() != null) { 584 engineObj.setPActivityId(hibCpEA.getPActivityId()); 585 } 586 if (hibCpEA.getPPackageId() != null) { 587 engineObj.setPPackageId(hibCpEA.getPPackageId()); 588 } 589 if (hibCpEA.getPProcessDefinitionId() != null) { 590 engineObj.setPProcessDefinitionId(hibCpEA.getPProcessDefinitionId()); 591 } 592 if (hibCpEA.getPActivityDefinitionId() != null) { 593 engineObj.setPActivityDefinitionId(hibCpEA.getPActivityDefinitionId()); 594 } 595 if (hibCpEA.getPProcessDefinitionName() != null) { 596 engineObj.setPProcessDefinitionName(hibCpEA.getPProcessDefinitionName()); 597 } 598 if (hibCpEA.getPProcessDefinitionVersion() != null) { 599 engineObj.setPProcessDefinitionVersion(hibCpEA.getPProcessDefinitionVersion()); 600 } 601 cus.info(LOG_CHANNEL, "CreateProcessEventAudit[processId=" + hibCpEA.getProcessId() + "] restored"); 602 } catch (Throwable tr) { 603 cus.error(LOG_CHANNEL, "Restoring of CreateProcessEventAudit failed"); 604 throw new EventAuditException("Restoring of CreateProcessEventAudit failed", tr); 605 } 606 return true; 607 } 608 609 public List restoreProcessHistory(String procId, SharkTransaction ti) throws EventAuditException { 610 try { 611 Session session = ((SharkHibernateTransaction) ti).getSession(); 612 List history = new ArrayList (); 613 614 HibernateCreateProcessEventAudit createProcessHistory = getPersistedObject(procId, session); 615 List dataHistory = getPersistedDataEventObjects(procId, null, session); 616 List stateHistory = getPersistedStateEventObjects(procId, null, session); 617 if (createProcessHistory != null) { 618 CreateProcessEventAuditPersistenceInterface a = createCreateProcessEventAudit(); 619 restore(a, createProcessHistory, session); 620 history.add(a); 621 } 622 if (dataHistory.size() != 0) { 623 for (Iterator it = dataHistory.iterator(); it.hasNext();) { 624 DataEventAuditPersistenceInterface d = createDataEventAudit(); 625 restore(d, (HibernateDataEventAudit) it.next(), session); 626 history.add(d); 627 } 628 } 629 if (stateHistory.size() != 0) { 630 for (Iterator it = stateHistory.iterator(); it.hasNext();) { 631 StateEventAuditPersistenceInterface s = createStateEventAudit(); 632 restore(s, (HibernateStateEventAudit) it.next(), session); 633 history.add(s); 634 } 635 } 636 return history; 637 } catch (Throwable tr) { 638 cus.error(LOG_CHANNEL, "restoreProcessHistory [id=" + procId + "] failed"); 639 throw new EventAuditException("restoreProcessHistory [id=" + procId + "] failed", tr); 640 } 641 } 642 643 public List restoreActivityHistory(String procId, String actId, SharkTransaction ti) throws EventAuditException { 644 try { 645 Session session = ((SharkHibernateTransaction) ti).getSession(); 646 List history = new ArrayList (); 647 648 List assignmentHistory = getPersistedAssignmentEventObjects(procId, actId, session); 649 List dataHistory = getPersistedDataEventObjects(procId, actId, session); 650 List stateHistory = getPersistedStateEventObjects(procId, actId, session); 651 if (assignmentHistory.size() != 0) { 652 for (Iterator it = assignmentHistory.iterator(); it.hasNext();) { 653 AssignmentEventAuditPersistenceInterface a = createAssignmentEventAudit(); 654 restore(a, (HibernateAssignmentEventAudit) it.next(), session); 655 history.add(a); 656 } 657 } 658 if (dataHistory.size() != 0) { 659 for (Iterator it = dataHistory.iterator(); it.hasNext();) { 660 DataEventAuditPersistenceInterface d = createDataEventAudit(); 661 restore(d, (HibernateDataEventAudit) it.next(), session); 662 history.add(d); 663 } 664 } 665 if (stateHistory.size() != 0) { 666 for (Iterator it = stateHistory.iterator(); it.hasNext();) { 667 StateEventAuditPersistenceInterface s = createStateEventAudit(); 668 restore(s, (HibernateStateEventAudit) it.next(), session); 669 history.add(s); 670 } 671 } 672 673 return history; 674 } catch (Throwable tr) { 675 cus.error(LOG_CHANNEL, "restoreActivityHistory [proId=" + procId + ",actId=" + actId + "] failed"); 676 tr.printStackTrace(); 677 throw new EventAuditException("restoreActivityHistory [proId=" + procId + ",actId=" + actId + "] failed", tr); 678 } 679 } 680 681 685 public void delete(AssignmentEventAuditPersistenceInterface aea, SharkTransaction ti) throws EventAuditException { 686 if (true) 688 return; 689 } 690 691 public void delete(DataEventAuditPersistenceInterface dea, SharkTransaction ti) throws EventAuditException { 692 if (true) 694 return; 695 } 696 697 public void delete(StateEventAuditPersistenceInterface sea, SharkTransaction ti) throws EventAuditException { 698 if (true) 700 return; 701 } 702 703 public void delete(CreateProcessEventAuditPersistenceInterface cpea, SharkTransaction ti) throws EventAuditException { 704 if (true) 706 return; 707 } 708 709 713 715 private HibernateProcessStateEventAudit getPersistedProcessStateEventAuditObject(String value, Session session) throws EventAuditException { 716 try { 717 Query qProcessStateEventAudit = session.createQuery("from HibernateProcessStateEventAudit processStateEventAudit where processStateEventAudit.keyValue = :keyValueParam"); 718 qProcessStateEventAudit.setString("keyValueParam", value); 719 return (HibernateProcessStateEventAudit) qProcessStateEventAudit.uniqueResult(); 720 } catch (Throwable t) { 721 throw new EventAuditException(t); 722 } 723 } 724 725 private HibernateProcessStateEventAudit getPersistedProcessStateEventAuditObjectById(int id, Session session) throws EventAuditException { 726 try { 727 Integer intId = new Integer (id); 728 return (HibernateProcessStateEventAudit) session.get(HibernateProcessStateEventAudit.class, intId); 729 } catch (Throwable t) { 730 throw new EventAuditException(t); 731 } 732 } 733 734 private HibernateActivityStateEventAudit getPersistedActivityStateEventAuditObjectById(int id, Session session) throws EventAuditException { 735 try { 736 Integer intId = new Integer (id); 737 return (HibernateActivityStateEventAudit) session.get(HibernateActivityStateEventAudit.class, intId); 738 } catch (Throwable t) { 739 throw new EventAuditException(t); 740 } 741 } 742 743 private HibernateActivityStateEventAudit getPersistedActivityStateEventAuditObject(String value, Session session) throws EventAuditException { 744 try { 745 Query qActivityStateEventAudit = session.createQuery("from HibernateActivityStateEventAudit activityStateEventAudit where activityStateEventAudit.keyValue = :keyValueParam"); 746 qActivityStateEventAudit.setString("keyValueParam", value); 747 return (HibernateActivityStateEventAudit) qActivityStateEventAudit.uniqueResult(); 748 749 } catch (Throwable t) { 750 throw new EventAuditException(t); 751 } 752 } 753 754 private HibernateEventType getPersistedEventTypeObject(String value, Session session) throws EventAuditException { 755 try { 756 Query qEventType = session.createQuery("from HibernateEventType eventType where eventType.keyValue = :keyValueParam"); 757 qEventType.setString("keyValueParam", value); 758 return (HibernateEventType) qEventType.uniqueResult(); 759 } catch (Throwable t) { 760 throw new EventAuditException(t); 761 } 762 } 763 764 private HibernateAssignmentEventAudit getPersistedObject(AssignmentEventAuditPersistenceInterface aea, Session s) throws EventAuditException { 765 try { 766 Query qAssignmentEventAuditQueryOldResUN; 767 Query qAssignmentEventAuditQuery; 768 if (aea.getOldResourceUsername() != null) { 769 qAssignmentEventAuditQueryOldResUN = 770 s.createQuery( 771 "from HibernateAssignmentEventAudit assignEA where assignEA.processId = :keyValueParam_1 and " 772 + "assignEA.activityId = :keyValueParam_2 and " 773 + "assignEA.timeStamp = :keyValueParam_3 and " 774 + "assignEA.eventTypeId = :keyValueParam_4 and " 775 + "assignEA.newResourceKey = :keyValueParam_5 and " 776 + "assignEA.isAccepted = :keyValueParam_6 and " 777 + "assignEA.oldResourceKey = :keyValueParam_7"); 778 qAssignmentEventAuditQueryOldResUN.setString("keyValueParam_1", aea.getProcessId()); 779 qAssignmentEventAuditQueryOldResUN.setString("keyValueParam_2", aea.getActivityId()); 780 qAssignmentEventAuditQueryOldResUN.setString("keyValueParam_3", aea.getUTCTime()); 781 qAssignmentEventAuditQueryOldResUN.setInteger("keyValueParam_4", getPersistedEventTypeObject(aea.getType(), s).getDbId()); 782 qAssignmentEventAuditQueryOldResUN.setString("keyValueParam_5", aea.getNewResourceUsername()); 783 qAssignmentEventAuditQueryOldResUN.setBoolean("keyValueParam_6", aea.getIsAccepted()); 784 qAssignmentEventAuditQueryOldResUN.setString("keyValueParam_7", aea.getOldResourceUsername()); 785 return (HibernateAssignmentEventAudit) qAssignmentEventAuditQueryOldResUN.uniqueResult(); 786 } else { 787 qAssignmentEventAuditQuery = 788 s.createQuery( 789 "from HibernateAssignmentEventAudit assignEA where assignEA.processId = :keyValueParam_1 and " 790 + "assignEA.activityId = :keyValueParam_2 and " 791 + "assignEA.timeStamp = :keyValueParam_3 and " 792 + "assignEA.eventTypeId = :keyValueParam_4 and " 793 + "assignEA.newResourceKey = :keyValueParam_5 and " 794 + "assignEA.isAccepted = :keyValueParam_6"); 795 qAssignmentEventAuditQuery.setString("keyValueParam_1", aea.getProcessId()); 796 qAssignmentEventAuditQuery.setString("keyValueParam_2", aea.getActivityId()); 797 qAssignmentEventAuditQuery.setString("keyValueParam_3", aea.getUTCTime()); 798 qAssignmentEventAuditQuery.setInteger("keyValueParam_4", getPersistedEventTypeObject(aea.getType(), s).getDbId()); 799 qAssignmentEventAuditQuery.setString("keyValueParam_5", aea.getNewResourceUsername()); 800 qAssignmentEventAuditQuery.setBoolean("keyValueParam_6", aea.getIsAccepted()); 801 return (HibernateAssignmentEventAudit) qAssignmentEventAuditQuery.uniqueResult(); 802 } 803 } catch (Throwable t) { 804 throw new EventAuditException(t); 805 } 806 } 807 808 private HibernateEventType getPersistedEventTypeObjectById(int id, Session session) throws EventAuditException { 809 try { 810 Integer intId = new Integer (id); 811 return (HibernateEventType) session.get(HibernateEventType.class, intId); 812 } catch (Throwable t) { 813 throw new EventAuditException(t); 814 } 815 } 816 817 private HibernateDataEventAudit getPersistedObject(DataEventAuditPersistenceInterface dea, Session s) throws EventAuditException { 818 try { 819 Query qDataEventAuditQueryActivityId; 820 Query qDataEventAuditQuery; 821 if (dea.getActivityId() != null) { 822 qDataEventAuditQueryActivityId = 823 s.createQuery( 824 "from HibernateDataEventAudit dataEA where dataEA.processId = :keyValueParam_1 and " 825 + "dataEA.activityId = :keyValueParam_2 and " 826 + "dataEA.timeStamp = :keyValueParam_3 and (dataEA.eventTypeId = :keyValueParam_4 or dataEA.eventTypeId = :keyValueParam_5)"); 827 qDataEventAuditQueryActivityId.setString("keyValueParam_1", dea.getProcessId()); 828 qDataEventAuditQueryActivityId.setString("keyValueParam_2", dea.getActivityId()); 829 qDataEventAuditQueryActivityId.setString("keyValueParam_3", dea.getUTCTime()); 830 qDataEventAuditQueryActivityId.setInteger("keyValueParam_4", getPersistedEventTypeObject(ACTIVITY_CONTEXT_CHANGED, s).getDbId()); 831 qDataEventAuditQueryActivityId.setInteger("keyValueParam_5", getPersistedEventTypeObject(ACTIVITY_RESULT_CHANGED, s).getDbId()); 832 return (HibernateDataEventAudit) qDataEventAuditQueryActivityId.uniqueResult(); 833 } else { 834 qDataEventAuditQuery = 835 s.createQuery( 836 "from HibernateDataEventAudit dataEA where dataEA.processId = :keyValueParam_1 and " + "dataEA.timeStamp = :keyValueParam_2 and " + "dataEA.eventTypeId = :keyValueParam_3"); 837 qDataEventAuditQuery.setString("keyValueParam_1", dea.getProcessId()); 838 qDataEventAuditQuery.setString("keyValueParam_2", dea.getUTCTime()); 839 qDataEventAuditQuery.setInteger("keyValueParam_3", getPersistedEventTypeObject(PROCESS_CONTEXT_CHANGED, s).getDbId()); 840 return (HibernateDataEventAudit) qDataEventAuditQuery.uniqueResult(); 841 } 842 } catch (Throwable t) { 843 throw new EventAuditException(t); 844 } 845 } 846 847 private HibernateStateEventAudit getPersistedObject(StateEventAuditPersistenceInterface sea, Session s) throws EventAuditException { 848 try { 849 Query qStateEventAuditQueryActivityId; 850 Query qStateEventAuditQuery; 851 if (sea.getActivityId() != null) { 852 qStateEventAuditQueryActivityId = 853 s.createQuery( 854 "from HibernateStateEventAudit stateEA where stateEA.processId = :keyValueParam_1 and " 855 + "stateEA.activityId = :keyValueParam_2 and " 856 + "stateEA.timeStamp = :keyValueParam_3 and " 857 + "stateEA.eventTypeId = :keyValueParam_4 and " 858 + "stateEA.oldState = :keyValueParam_5 and " 859 + "stateEA.newState = :keyValueParam_6"); 860 qStateEventAuditQueryActivityId.setString("keyValueParam_1", sea.getProcessId()); 861 qStateEventAuditQueryActivityId.setString("keyValueParam_2", sea.getActivityId()); 862 qStateEventAuditQueryActivityId.setString("keyValueParam_3", sea.getUTCTime()); 863 qStateEventAuditQueryActivityId.setInteger("keyValueParam_4", getPersistedEventTypeObject(sea.getType(), s).getDbId()); 864 qStateEventAuditQueryActivityId.setString("keyValueParam_5", getPersistedActivityStateEventAuditObject(sea.getOldState(), s).getName()); 865 qStateEventAuditQueryActivityId.setString("keyValueParam_6", getPersistedActivityStateEventAuditObject(sea.getNewState(), s).getName()); 866 return (HibernateStateEventAudit) qStateEventAuditQueryActivityId.uniqueResult(); 867 } else { 868 qStateEventAuditQuery = 869 s.createQuery( 870 "from HibernateStateEventAudit stateEA where stateEA.processId = :keyValueParam_1 and " 871 + "stateEA.timeStamp = :keyValueParam_2 and " 872 + "stateEA.eventTypeId = :keyValueParam_3 and " 873 + "stateEA.oldState = :keyValueParam_4 and " 874 + "stateEA.newState = :keyValueParam_5"); 875 qStateEventAuditQuery.setString("keyValueParam_1", sea.getProcessId()); 876 qStateEventAuditQuery.setString("keyValueParam_2", sea.getUTCTime()); 877 qStateEventAuditQuery.setInteger("keyValueParam_3", getPersistedEventTypeObject(sea.getType(), s).getDbId()); 878 qStateEventAuditQuery.setString("keyValueParam_4", getPersistedProcessStateEventAuditObject(sea.getOldState(), s).getName()); 879 qStateEventAuditQuery.setString("keyValueParam_5", getPersistedProcessStateEventAuditObject(sea.getNewState(), s).getName()); 880 return (HibernateStateEventAudit) qStateEventAuditQuery.uniqueResult(); 881 } 882 } catch (Throwable t) { 883 throw new EventAuditException(t); 884 } 885 } 886 887 private HibernateCreateProcessEventAudit getPersistedObject(CreateProcessEventAuditPersistenceInterface cpea, Session s) throws EventAuditException { 888 try { 889 Query qCreateProcessEventAuditQuery = s.createQuery("from HibernateCreateProcessEventAudit cpEA where cpEA.processId = :keyValueParam_1"); 890 qCreateProcessEventAuditQuery.setString("keyValueParam_1", cpea.getProcessId()); 891 return (HibernateCreateProcessEventAudit) qCreateProcessEventAuditQuery.uniqueResult(); 892 } catch (Throwable t) { 893 throw new EventAuditException(t); 894 } 895 } 896 897 private HibernateCreateProcessEventAudit getPersistedObject(String pId, Session s) throws EventAuditException { 898 try { 899 Query qCreateProcessEventAuditQuery = s.createQuery("from HibernateCreateProcessEventAudit cpEA where cpEA.processId = :keyValueParam_1"); 900 qCreateProcessEventAuditQuery.setString("keyValueParam_1", pId); 901 return (HibernateCreateProcessEventAudit) qCreateProcessEventAuditQuery.uniqueResult(); 902 } catch (Throwable t) { 903 throw new EventAuditException(t); 904 } 905 } 906 907 private List getPersistedDataEventObjects(String pId, String aId, Session s) throws EventAuditException { 908 try { 909 Query qDataEventAuditQueryActivityId; 910 Query qDataEventAuditQuery; 911 if (aId != null) { 912 qDataEventAuditQueryActivityId = 913 s.createQuery( 914 "from HibernateDataEventAudit dataEA where dataEA.processId = :keyValueParam_1 and " 915 + "dataEA.activityId = :keyValueParam_2 and (dataEA.eventTypeId = :keyValueParam_3 or dataEA.eventTypeId = :keyValueParam_4)"); 916 qDataEventAuditQueryActivityId.setString("keyValueParam_1", pId); 917 qDataEventAuditQueryActivityId.setString("keyValueParam_2", aId); 918 qDataEventAuditQueryActivityId.setInteger("keyValueParam_3", getPersistedEventTypeObject(ACTIVITY_CONTEXT_CHANGED, s).getDbId()); 919 qDataEventAuditQueryActivityId.setInteger("keyValueParam_4", getPersistedEventTypeObject(ACTIVITY_RESULT_CHANGED, s).getDbId()); 920 return qDataEventAuditQueryActivityId.list(); 921 } else { 922 qDataEventAuditQuery = s.createQuery("from HibernateDataEventAudit dataEA where dataEA.processId = :keyValueParam_1 and " + "dataEA.eventTypeId = :keyValueParam_2"); 923 qDataEventAuditQuery.setString("keyValueParam_1", pId); 924 qDataEventAuditQuery.setInteger("keyValueParam_2", getPersistedEventTypeObject(PROCESS_CONTEXT_CHANGED, s).getDbId()); 925 return qDataEventAuditQuery.list(); 926 } 927 } catch (Throwable t) { 928 throw new EventAuditException(t); 929 } 930 } 931 932 private List getPersistedStateEventObjects(String pId, String aId, Session s) throws EventAuditException { 933 try { 934 Query qStateEventAuditQueryActivityId; 935 Query qStateEventAuditQuery; 936 if (aId != null) { 937 qStateEventAuditQueryActivityId = 938 s.createQuery( 939 "from HibernateStateEventAudit stateEA where stateEA.processId = :keyValueParam_1 and " 940 + "stateEA.activityId = :keyValueParam_2 and " 941 + "stateEA.eventTypeId = :keyValueParam_3"); 942 qStateEventAuditQueryActivityId.setString("keyValueParam_1", pId); 943 qStateEventAuditQueryActivityId.setString("keyValueParam_2", aId); 944 qStateEventAuditQueryActivityId.setInteger("keyValueParam_3", getPersistedEventTypeObject(ACTIVITY_STATE_CHANGED, s).getDbId()); 945 return qStateEventAuditQueryActivityId.list(); 946 } else { 947 qStateEventAuditQuery = s.createQuery("from HibernateStateEventAudit stateEA where stateEA.processId = :keyValueParam_1 and " + "stateEA.eventTypeId = :keyValueParam_2"); 948 qStateEventAuditQuery.setString("keyValueParam_1", pId); 949 qStateEventAuditQuery.setInteger("keyValueParam_2", getPersistedEventTypeObject(PROCESS_STATE_CHANGED, s).getDbId()); 950 return qStateEventAuditQuery.list(); 951 } 952 } catch (Throwable t) { 953 throw new EventAuditException(t); 954 } 955 } 956 957 private List getPersistedAssignmentEventObjects(String pId, String aId, Session s) throws EventAuditException { 958 try { 959 Query qAssignmentEventAuditQuery = s.createQuery("from HibernateAssignmentEventAudit assignEA where assignEA.processId = :keyValueParam_1 and " + "assignEA.activityId = :keyValueParam_2"); 960 qAssignmentEventAuditQuery.setString("keyValueParam_1", pId); 961 qAssignmentEventAuditQuery.setString("keyValueParam_2", aId); 962 return qAssignmentEventAuditQuery.list(); 963 } catch (Throwable t) { 964 throw new EventAuditException(t); 965 } 966 } 967 968 972 public AssignmentEventAuditPersistenceInterface createAssignmentEventAudit() { 973 return new HibernateAssignmentEventAudit(); 974 } 975 976 public CreateProcessEventAuditPersistenceInterface createCreateProcessEventAudit() { 977 return new HibernateCreateProcessEventAudit(); 978 } 979 980 public DataEventAuditPersistenceInterface createDataEventAudit() { 981 return new HibernateDataEventAudit(); 982 } 983 984 public StateEventAuditPersistenceInterface createStateEventAudit() { 985 return new HibernateStateEventAudit(); 986 } 987 988 992 public BigDecimal getNextDecId(String idName) throws EventAuditException { 993 try { 994 return HibernateUtilities.getNext(idName); 995 } catch (Exception e) { 996 throw new EventAuditException("Couldn't allocate id"); 997 } 998 } 999 1000 public String getNextId(String idName) throws EventAuditException { 1001 return getNextDecId(idName).toString(); 1002 } 1003 1004} 1005 | Popular Tags |