/** * @see org.kuali.rice.krad.service.KeyValuesService#findAll(java.lang.Class) */ @Override public <T> Collection<T> findAll(Class<T> clazz) { ModuleService responsibleModuleService = KRADServiceLocatorWeb.getKualiModuleService().getResponsibleModuleService(clazz); if(responsibleModuleService!=null && responsibleModuleService.isExternalizable(clazz)){ return (Collection<T>) responsibleModuleService.getExternalizableBusinessObjectsList((Class<ExternalizableBusinessObject>) clazz, Collections.<String, Object>emptyMap()); } if (containsActiveIndicator(clazz)) { return KRADServiceLocatorWeb.getLegacyDataAdapter().findMatching(clazz, Collections.singletonMap(CoreConstants.CommonElements.ACTIVE, true)); } if (LOG.isDebugEnabled()) { LOG.debug("Active indicator not found for class " + clazz.getName()); } return KRADServiceLocatorWeb.getLegacyDataAdapter().findAll(clazz); }
@Override public void encrypt(PersistableBusinessObject businessObject, Set<String> attributeNames) { for (String attributeName : attributeNames) { try { PropertyUtils.setProperty(businessObject, attributeName, encryptionService.encrypt(PropertyUtils .getProperty(businessObject, attributeName))); } catch (Exception e) { throw new RuntimeException(new StringBuffer( "PostDataLoadEncryptionServiceImpl caught exception while attempting to encrypt attribute ").append( attributeName).append(" of Class ").append(businessObject.getClass()).toString(), e); } } legacyDataAdapter.save(businessObject); }
@Override public boolean isBoNotesEnabled() { return KRADServiceLocatorWeb.getLegacyDataAdapter().areNotesSupported(getDataObjectClass()); }
if (!KRADServiceLocatorWeb.getLegacyDataAdapter().equalsByPrimaryKeys(oldBo, newDataObject)) { Map<String, ?> newPkFields = KRADServiceLocatorWeb.getLegacyDataAdapter().getPrimaryKeyFieldValues(newDataObject);
legacyDataAdapter.findByPrimaryKey(SessionDocument.class, primaryKeys); if (sessionDocument == null) { sessionDocument = new SessionDocument(); sessionDocument.setLastUpdatedDate(currentTime); legacyDataAdapter.save(sessionDocument); } catch (Exception e) { final String className = form != null ? form.getClass().getName() : "null";
@Override public void restoreClassDescriptor(Class<? extends PersistableBusinessObject> businessObjectClass, Set<String> attributeNames) { ClassDescriptor classDescriptor = getClassDescriptor(businessObjectClass); for (String attributeName : attributeNames) { classDescriptor.getFieldDescriptorByName(attributeName).setFieldConversionClassName( OjbKualiEncryptDecryptFieldConversion.class.getName()); } legacyDataAdapter.findAll(businessObjectClass); }
@Override public boolean isOldDataObjectInDocument() { boolean isOldDataObjectInExistence = true; if (getDataObject() == null) { isOldDataObjectInExistence = false; } else { // dataObject contains a non persistable wrapper - use agenda from the wrapper object instead Map<String, ?> keyFieldValues = getLegacyDataAdapter().getPrimaryKeyFieldValues( ((AgendaEditor) getDataObject()).getAgenda()); for (Object keyValue : keyFieldValues.values()) { if (keyValue == null) { isOldDataObjectInExistence = false; } else if ((keyValue instanceof String) && StringUtils.isBlank((String) keyValue)) { isOldDataObjectInExistence = false; } if (!isOldDataObjectInExistence) { break; } } } return isOldDataObjectInExistence; }
if (!KRADServiceLocatorWeb.getLegacyDataAdapter().equalsByPrimaryKeys(oldBo, newBo)) {
@Override public <T> Collection<T> findAllInactive(Class<T> clazz) { if (containsActiveIndicator(clazz)) { return KRADServiceLocatorWeb.getLegacyDataAdapter().findMatching(clazz, Collections.singletonMap(CoreConstants.CommonElements.ACTIVE, false)); } LOG.warn("Active indicator not found for class. Assuming all are active. " + clazz.getName()); return Collections.emptyList(); }
if (KRADServiceLocatorWeb.getLegacyDataAdapter().isPersistable(bo.getClass())) { Map<String, Class> references = KNSServiceLocator.getPersistenceStructureService().listReferenceObjectFields(bo);
/** * @see org.kuali.rice.krad.service.KeyValuesService#findAllOrderBy(java.lang.Class, java.lang.String, boolean) */ @Override public <T> Collection<T> findAllOrderBy(Class<T> clazz, String sortField, boolean sortAscending) { if (containsActiveIndicator(clazz)) { return KRADServiceLocatorWeb.getLegacyDataAdapter().findMatchingOrderBy(clazz, Collections.singletonMap(CoreConstants.CommonElements.ACTIVE, true), sortField, sortAscending); } if (LOG.isDebugEnabled()) { LOG.debug("Active indicator not found for class " + clazz.getName()); } return KRADServiceLocatorWeb.getLegacyDataAdapter().findMatchingOrderBy(clazz, new HashMap<String,Object>(), sortField, sortAscending); }
@Deprecated protected Object retrieveDocumentForm(UserSession userSession, String sessionId, String documentNumber, String ipAddress) throws Exception { HashMap<String, String> primaryKeys = new HashMap<String, String>(4); primaryKeys.put(SESSION_ID, sessionId); if (documentNumber != null) { primaryKeys.put(DOCUMENT_NUMBER, documentNumber); } primaryKeys.put(PRINCIPAL_ID, userSession.getPrincipalId()); primaryKeys.put(IP_ADDRESS, ipAddress); SessionDocument sessionDoc = legacyDataAdapter.findByPrimaryKey(SessionDocument.class, primaryKeys); if (sessionDoc != null) { byte[] formAsBytes = sessionDoc.getSerializedDocumentForm(); if (sessionDoc.isEncrypted()) { formAsBytes = getEncryptionService().decryptBytes(formAsBytes); } ByteArrayInputStream baip = new ByteArrayInputStream(formAsBytes); ObjectInputStream ois = new ObjectInputStream(baip); return ois.readObject(); } return null; }
/** * @see org.kuali.rice.krad.service.SessionDocumentService#purgeDocumentForm(String, String, * org.kuali.rice.krad.UserSession, String) * * @deprecated (Deprecated and removed from use in KRAD (KULRICE-9149) */ @Override @Deprecated public void purgeDocumentForm(String documentNumber, String docFormKey, UserSession userSession, String ipAddress) { synchronized (userSession) { LOG.debug("purge document form from session"); userSession.removeObject(docFormKey); try { LOG.debug("purge document form from database"); HashMap<String, String> primaryKeys = new HashMap<String, String>(4); primaryKeys.put(SESSION_ID, userSession.getKualiSessionId()); primaryKeys.put(DOCUMENT_NUMBER, documentNumber); primaryKeys.put(PRINCIPAL_ID, userSession.getPrincipalId()); primaryKeys.put(IP_ADDRESS, ipAddress); legacyDataAdapter.deleteMatching(SessionDocument.class, primaryKeys); } catch (Exception e) { LOG.error("purgeDocumentForm failed for SessId/DocNum/PrinId/IP:" + userSession.getKualiSessionId() + "/" + documentNumber + "/" + userSession.getPrincipalId() + "/" + ipAddress, e); } } }
try { postDataLoadEncryptionService.prepClassDescriptor(businessObjectClass, attributeNames); Collection<? extends PersistableBusinessObject> objectsToEncrypt = legacyDataAdapter.findAll(businessObjectClass); for (Object businessObject : objectsToEncrypt) { postDataLoadEncryptionService.encrypt((PersistableBusinessObject) businessObject, attributeNames);
/** * @see org.kuali.rice.krad.service.PersistenceService#retrieveNonKeyFields(java.lang.Object) */ @Override public void retrieveNonKeyFields(Object persistableObject) { if (persistableObject != null && ExternalizableBusinessObjectUtils.isExternalizableBusinessObject(persistableObject.getClass())) { // // special handling for EBOs // Map<String, ?> criteria = KRADServiceLocatorWeb.getLegacyDataAdapter().getPrimaryKeyFieldValues(persistableObject); if (!CollectionUtils.isEmpty(criteria)) { ModuleService moduleService = getKualiModuleService().getResponsibleModuleService(persistableObject.getClass()); if (moduleService != null) { Class<? extends ExternalizableBusinessObject> clazz = ExternalizableBusinessObjectUtils.determineExternalizableBusinessObjectSubInterface(persistableObject.getClass()); ExternalizableBusinessObject freshEbo = moduleService.getExternalizableBusinessObject(clazz, (Map<String, Object>)criteria); if (freshEbo != null) { BeanUtils.copyProperties(freshEbo, persistableObject); } } } } else { getService(persistableObject.getClass()).retrieveNonKeyFields(persistableObject); } }
/** * @see org.kuali.rice.krad.service.BusinessObjectService#findMatching(java.lang.Class, java.util.Map) */ @Override public <T> Collection<T> findMatching(Class<T> clazz, Map<String, Object> fieldValues) { if (containsActiveIndicator(clazz)) { // copying the map since we need to change it and don't know if it is unmodifiable Map<String,Object> criteria = new HashMap<String, Object>( fieldValues ); criteria.put(CoreConstants.CommonElements.ACTIVE, true); return KRADServiceLocatorWeb.getLegacyDataAdapter().findMatching(clazz, criteria); } if (LOG.isDebugEnabled()) { LOG.debug("Active indicator not found for class " + clazz.getName()); } return KRADServiceLocatorWeb.getLegacyDataAdapter().findMatching(clazz, fieldValues); }
if ( KRADServiceLocatorWeb.getLegacyDataAdapter().isPersistable(example.getClass())) { Criteria criteria = new Criteria();
/** * this needs to happen after the document itself is saved, to preserve consistency of the ver_nbr and in the case * of initial save, because this can't be saved until the document is saved initially * * @see org.kuali.rice.krad.document.DocumentBase#postProcessSave(org.kuali.rice.krad.rules.rule.event.DocumentEvent) */ @Override public void postProcessSave(DocumentEvent event) { Object bo = getNewMaintainableObject().getDataObject(); if (bo instanceof GlobalBusinessObject) { bo = KRADServiceLocatorWeb.getLegacyDataAdapter().save(bo); // KRAD/JPA - have to change the handle to object to that just saved getNewMaintainableObject().setDataObject(bo); } //currently only global documents could change the list of what they're affecting during routing, //so could restrict this to only happening with them, but who knows if that will change, so safest //to always do the delete and re-add...seems a bit inefficient though if nothing has changed, which is //most of the time...could also try to only add/update/delete what's changed, but this is easier if (!(event instanceof SaveDocumentEvent)) { //don't lock until they route getMaintenanceDocumentService().deleteLocks(MaintenanceDocumentBase.this.getDocumentNumber()); getMaintenanceDocumentService().storeLocks(MaintenanceDocumentBase.this.getNewMaintainableObject().generateMaintenanceLocks()); } }