/** * @see org.kuali.rice.krad.dao.MaintenanceDocumentDao#getLockingDocumentNumber(java.lang.String, * java.lang.String) */ public String getLockingDocumentNumber(String lockingRepresentation, String documentNumber) { String lockingDocNumber = ""; // build the query criteria Criteria criteria = new Criteria(); criteria.addEqualTo("lockingRepresentation", lockingRepresentation); // if a docHeaderId is specified, then it will be excluded from the // locking representation test. if (StringUtils.isNotBlank(documentNumber)) { criteria.addNotEqualTo(KRADPropertyConstants.DOCUMENT_NUMBER, documentNumber); } // attempt to retrieve a document based off this criteria MaintenanceLock maintenanceLock = (MaintenanceLock) getPersistenceBrokerTemplate() .getObjectByQuery(QueryFactory.newQuery(MaintenanceLock.class, criteria)); // if a document was found, then there's already one out there pending, and // we consider it 'locked' and we return the docnumber. if (maintenanceLock != null) { lockingDocNumber = maintenanceLock.getDocumentNumber(); } return lockingDocNumber; }
protected TrickleDownInactivationStatus trickleDownInactivate( Collection<SubObjectCode> subObjects, String documentNumber) { TrickleDownInactivationStatus trickleDownInactivationStatus = new TrickleDownInactivationStatus(); if (subObjects != null && !subObjects.isEmpty()) { Maintainable subObjectMaintainable = getSubObjectMaintainable(documentNumber); for (Iterator<SubObjectCode> i = subObjects.iterator(); i.hasNext(); ) { SubObjectCode subObjCd = i.next(); if (subObjCd.isActive()) { subObjectMaintainable.setBusinessObject(subObjCd); List<MaintenanceLock> subAccountLocks = subObjectMaintainable.generateMaintenanceLocks(); MaintenanceLock failedLock = verifyAllLocksFromThisDocument(subAccountLocks, documentNumber); if (failedLock != null) { // another document has locked this sub account, so we don't try to inactivate the // account trickleDownInactivationStatus.alreadyLockedSubObjCds.put( subObjCd, failedLock.getDocumentNumber()); } else { // no locks other than our own (but there may have been no locks at all), just go ahead // and try to update subObjCd.setActive(false); try { subObjectMaintainable.saveBusinessObject(); trickleDownInactivationStatus.inactivatedSubObjCds.add(subObjCd); } catch (RuntimeException e) { LOG.error("Unable to trickle-down inactivate sub-account " + subObjCd.toString(), e); trickleDownInactivationStatus.errorPersistingSubObjCds.add(subObjCd); } } } } } return trickleDownInactivationStatus; }
/** * @see org.kuali.rice.krad.dao.MaintenanceDocumentDao#getLockingDocumentNumber(java.lang.String, * java.lang.String) */ public String getLockingDocumentNumber(String lockingRepresentation, String documentNumber) { String lockingDocNumber = ""; // build the query criteria Criteria criteria = new Criteria(MaintenanceLock.class.getName()); criteria.eq("lockingRepresentation", lockingRepresentation); // if a docHeaderId is specified, then it will be excluded from the // locking representation test. if (StringUtils.isNotBlank(documentNumber)) { criteria.ne(KRADPropertyConstants.DOCUMENT_NUMBER, documentNumber); } // attempt to retrieve a document based off this criteria MaintenanceLock maintenanceLock = (MaintenanceLock) new QueryByCriteria(entityManager, criteria).toQuery().getSingleResult(); // if a document was found, then there's already one out there pending, // and we consider it 'locked' and we return the docnumber. if (maintenanceLock != null) { lockingDocNumber = maintenanceLock.getDocumentNumber(); } return lockingDocNumber; }