List of usage examples for org.hibernate.type ComponentType getPropertyValues
@Override
public Object[] getPropertyValues(Object component, EntityMode entityMode) throws HibernateException
From source file:org.mifos.framework.components.audit.util.helpers.InterceptHelper.java
License:Open Source License
private void readFurtherComponenetMeta(Object obj, String firstName, String state, Type propertyType) { ComponentType componentType = (ComponentType) propertyType; Object[] propertyValues = componentType.getPropertyValues(obj, EntityMode.POJO); String[] propertyNames = componentType.getPropertyNames(); for (int i = 0; i < propertyNames.length; i++) { if (state.equalsIgnoreCase(AuditConstants.TRANSACTIONBEGIN)) { String name = firstName.concat(propertyNames[i]); logger.debug("i setColumnValues " + name + " : " + propertyValues[i]); if (AuditConfiguration.checkForPropertyName(entityName, name, localeId)) { String value = AuditConfiguration.getValueOfCorrespondingId(entityName, name, propertyValues[i], localeId);//from w w w . j a v a2s .co m initialValues.put(name, value); } else { if (propertyValues[i] instanceof Calendar && propertyValues[i] != null) { initialValues.put(name, ((Calendar) propertyValues[i]).getTime()); } else if (propertyValues[i] instanceof byte[] && propertyValues[i] != null) { initialValues.put(name, new String((byte[]) propertyValues[i])); } else if (propertyValues[i] instanceof Date && propertyValues[i] != null) { try { Date date = (Date) propertyValues[i]; initialValues.put(name, DateUtils.getUserLocaleDate(locale, new java.sql.Date(date.getTime()).toString())); } catch (Exception e) { initialValues.put(name, propertyValues[i].toString()); } } else { initialValues.put(name, propertyValues[i]); } } String columnName = AuditConfiguration.getColumnNameForPropertyName(entityName, name); if (columnName != null && !columnName.equals("")) { columnNames.put(name, columnName); } else { columnNames.put(name, propertyNames[i]); } } else { String name = firstName.concat(propertyNames[i]); logger.debug("c setColumnValues " + name + " : " + propertyValues[i]); if (AuditConfiguration.checkForPropertyName(entityName, name, localeId)) { String value = AuditConfiguration.getValueOfCorrespondingId(entityName, name, propertyValues[i], localeId); changedValues.put(name, value); } else { if (propertyValues[i] instanceof Calendar && propertyValues[i] != null) { changedValues.put(name, ((Calendar) propertyValues[i]).getTime()); } else if (propertyValues[i] instanceof byte[] && propertyValues[i] != null) { changedValues.put(name, new String((byte[]) propertyValues[i])); } else if (propertyValues[i] instanceof Date && propertyValues[i] != null) { Date date = (Date) propertyValues[i]; changedValues.put(name, DateUtils.getUserLocaleDate(locale, new java.sql.Date(date.getTime()).toString())); } else { changedValues.put(name, propertyValues[i]); } } String columnName = AuditConfiguration.getColumnNameForPropertyName(entityName, name); if (columnName != null && !columnName.equals("")) { columnNames.put(name, columnName); } else { columnNames.put(name, propertyNames[i]); } } } }
From source file:org.mifos.framework.components.audit.util.helpers.InterceptHelper.java
License:Open Source License
private void readComponenetTypeInCollectionTypeWithMerge(Object obj, String firstName, String state, Type propertyType) {//from www. j av a 2 s . c o m ComponentType componentType = (ComponentType) propertyType; Object[] propertyValues = componentType.getPropertyValues(obj, EntityMode.POJO); String[] propertyNames = componentType.getPropertyNames(); for (int i = 0; i < propertyNames.length; i++) { logger.debug("property Name : " + propertyNames[i] + " value : " + propertyValues[i]); if (state.equalsIgnoreCase(AuditConstants.TRANSACTIONBEGIN)) { String name = firstName.concat(propertyNames[i]); logger.debug( "i readComponenetTypeInCollectionTypeWithMerge " + name + " value : " + propertyValues[i]); if (isValueLoggable(propertyNames[i], firstName)) { if (AuditConfiguration.checkForPropertyName(entityName, name, localeId)) { String value = AuditConfiguration.getValueOfCorrespondingId(entityName, name, propertyValues[i], localeId); if (initialArray.toString().trim().length() == 0 || initialArray.toString().endsWith(",")) { initialArray.append(value); } else if (value.trim().length() != 0) { initialArray.append("-").append(value); } } else { if (propertyValues[i] != null) { if (initialArray.toString().trim().length() == 0 || initialArray.toString().endsWith(",")) { initialArray.append(propertyValues[i]); } else if (propertyValues[i].toString().trim().length() != 0) { initialArray.append("-").append(propertyValues[i]); } } } } } else { String name = firstName.concat(propertyNames[i].toString()); logger.debug( "c readComponenetTypeInCollectionTypeWithMerge " + name + " value : " + propertyValues[i]); if (isValueLoggable(propertyNames[i], firstName)) { if (AuditConfiguration.checkForPropertyName(entityName, name, localeId)) { String value = AuditConfiguration.getValueOfCorrespondingId(entityName, name, propertyValues[i], localeId); if (changeArray.toString().trim().length() == 0 || changeArray.toString().endsWith(",")) { changeArray.append(value); } else if (value.trim().length() != 0) { changeArray.append("-").append(value); } } else { if (propertyValues[i] != null) { if (changeArray.toString().trim().length() == 0 || changeArray.toString().endsWith(",")) { changeArray.append(propertyValues[i]); } else if (propertyValues[i].toString().trim().length() != 0) { changeArray.append("-").append(propertyValues[i]); } } } } } } }
From source file:org.mifos.framework.components.audit.util.helpers.InterceptHelper.java
License:Open Source License
private void readComponenetTypeInCollectionTypeWithoutMerge(Object obj, String firstName, String state, Type propertyType) {/*from ww w . j a v a 2s . c o m*/ ComponentType componentType = (ComponentType) propertyType; Object[] propertyValues = componentType.getPropertyValues(obj, EntityMode.POJO); String[] propertyNames = componentType.getPropertyNames(); for (int i = 0; i < propertyNames.length; i++) { if (state.equalsIgnoreCase(AuditConstants.TRANSACTIONBEGIN)) { String name = firstName.concat(propertyNames[i]); logger.debug("i readComponenetTypeInCollectionTypeWithoutMerge : " + name + " value : " + propertyValues[i]); String oldValue = getOldValueToKey(initialValues, name); if (AuditConfiguration.checkForPropertyName(entityName, name, localeId)) { String value = AuditConfiguration.getValueOfCorrespondingId(entityName, name, propertyValues[i], localeId); if (!oldValue.equals("")) { initialValues.put(name, value.concat(",").concat(oldValue)); } else { initialValues.put(name, value); } } else { if (propertyValues[i] instanceof Calendar && propertyValues[i] != null) { if (!oldValue.equals("")) { initialValues.put(name, ((Calendar) propertyValues[i]).getTime().toString().concat(",") .concat(oldValue)); } else { initialValues.put(name, ((Calendar) propertyValues[i]).getTime()); } } else if (!(propertyValues[i] instanceof Calendar) && !(propertyValues[i] instanceof Date) && propertyValues[i] != null) { if (!oldValue.equals("")) { initialValues.put(name, propertyValues[i].toString().concat(",").concat(oldValue)); } else { initialValues.put(name, propertyValues[i]); } } else if (propertyValues[i] instanceof Date && propertyValues[i] != null) { if (!oldValue.equals("")) { try { Date date = (Date) propertyValues[i]; initialValues.put(name, DateUtils .getUserLocaleDate(locale, new java.sql.Date(date.getTime()).toString()) .toString().concat(",").concat(oldValue)); } catch (Exception e) { initialValues.put(name, propertyValues[i].toString().concat(",").concat(oldValue)); } } else { try { Date date = (Date) propertyValues[i]; initialValues.put(name, DateUtils.getUserLocaleDate(locale, new java.sql.Date(date.getTime()).toString())); } catch (Exception e) { initialValues.put(name, propertyValues[i].toString()); } } } else { if (!oldValue.equals("")) { initialValues.put(name, oldValue); } else { initialValues.put(name, propertyValues[i]); } } } String columnName = AuditConfiguration.getColumnNameForPropertyName(entityName, name); if (columnName != null && !columnName.equals("")) { columnNames.put(name, columnName); } else { columnNames.put(name, propertyNames[i]); } } else { String name = firstName.concat(propertyNames[i].toString()); logger.debug("c readComponenetTypeInCollectionTypeWithoutMerge : " + name + " value : " + propertyValues[i]); String oldValue = getOldValueToKey(changedValues, name); if (AuditConfiguration.checkForPropertyName(entityName, name, localeId)) { String value = AuditConfiguration.getValueOfCorrespondingId(entityName, name, propertyValues[i], localeId); if (!value.equals("")) { changedValues.put(name, value.concat(",").concat(oldValue)); } else { changedValues.put(name, oldValue); } } else { if (propertyValues[i] instanceof Calendar && propertyValues[i] != null) { if (!oldValue.equals("")) { changedValues.put(name, ((Calendar) propertyValues[i]).getTime().toString().concat(",") .concat(oldValue)); } else { changedValues.put(name, ((Calendar) propertyValues[i]).getTime()); } } else if (!(propertyValues[i] instanceof Calendar) && !(propertyValues[i] instanceof Date) && propertyValues[i] != null) { if (!oldValue.equals("")) { changedValues.put(name, propertyValues[i].toString().concat(",").concat(oldValue)); } else { changedValues.put(name, propertyValues[i]); } } else if (propertyValues[i] instanceof Date && propertyValues[i] != null) { if (!oldValue.equals("")) { try { Date date = (Date) propertyValues[i]; changedValues.put(name, DateUtils .getUserLocaleDate(locale, new java.sql.Date(date.getTime()).toString()) .toString().concat(",").concat(oldValue)); } catch (Exception e) { changedValues.put(name, propertyValues[i].toString().concat(",").concat(oldValue)); } } else { try { Date date = (Date) propertyValues[i]; changedValues.put(name, DateUtils.getUserLocaleDate(locale, new java.sql.Date(date.getTime()).toString())); } catch (Exception e) { changedValues.put(name, propertyValues[i].toString()); } } } else { if (!oldValue.equals("")) { changedValues.put(name, oldValue); } else { changedValues.put(name, propertyValues[i]); } } } String columnName = AuditConfiguration.getColumnNameForPropertyName(entityName, name); if (columnName != null && !columnName.equals("")) { columnNames.put(name, columnName); } else { columnNames.put(name, propertyNames[i]); } } } }