use of org.mifos.application.master.business.MasterDataEntity in project head by mifos.
the class LegacyMasterDao method findMasterDataEntitiesWithLocale.
/**
* use Dao specific calls - see feeDao.doRetrieveFeeCategories
*/
@SuppressWarnings("unchecked")
@Deprecated
public <T extends MasterDataEntity> List<T> findMasterDataEntitiesWithLocale(final Class<T> type) {
Session session = getSession();
List<T> masterEntities = session.createQuery("from " + type.getName()).list();
for (MasterDataEntity masterData : masterEntities) {
Hibernate.initialize(masterData.getNames());
}
return masterEntities;
}
use of org.mifos.application.master.business.MasterDataEntity in project head by mifos.
the class ApplicationConfigurationDaoHibernate method doFetchListOfMasterDataFor.
@SuppressWarnings("unchecked")
private <T extends MasterDataEntity> List<T> doFetchListOfMasterDataFor(Class<T> type) {
Session session = StaticHibernateUtil.getSessionTL();
List<T> masterEntities = session.createQuery("from " + type.getName()).list();
for (MasterDataEntity masterData : masterEntities) {
Hibernate.initialize(masterData.getNames());
Hibernate.initialize(masterData.getLookUpValue());
Hibernate.initialize(masterData.getLookUpValue().getLookUpValueLocales());
}
return masterEntities;
}
use of org.mifos.application.master.business.MasterDataEntity in project head by mifos.
the class AuditConfiguration method fetchMasterData.
private void fetchMasterData(String entityName, Short localeId, String classPath) throws SystemException {
Class clazz = null;
try {
clazz = Thread.currentThread().getContextClassLoader().loadClass(classPath);
} catch (ClassNotFoundException e) {
throw new SystemException(e);
}
List<MasterDataEntity> masterDataList = legacyMasterDao.findMasterDataEntities(clazz);
for (MasterDataEntity masterDataEntity : masterDataList) {
if (masterDataEntity instanceof PersonnelStatusEntity) {
String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
((PersonnelStatusEntity) masterDataEntity).setName(name);
}
if (masterDataEntity instanceof PersonnelLevelEntity) {
String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
((PersonnelLevelEntity) masterDataEntity).setName(name);
}
if (masterDataEntity instanceof OfficeLevelEntity) {
String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
((OfficeLevelEntity) masterDataEntity).setName(name);
}
if (masterDataEntity instanceof OfficeStatusEntity) {
String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
((OfficeStatusEntity) masterDataEntity).setName(name);
}
valueMap.put(masterDataEntity.getId().toString(), masterDataEntity.getName());
}
}
use of org.mifos.application.master.business.MasterDataEntity in project head by mifos.
the class InterceptHelper method readFurtherMetaForCollectionType.
private void readFurtherMetaForCollectionType(Object obj, String firstName, String state) {
Class l = getClazz(obj);
ClassMetadata customMeta = StaticHibernateUtil.getSessionFactory().getClassMetadata(l);
Object[] propertyValues = customMeta.getPropertyValues(obj, EntityMode.POJO);
String[] propertyNames = customMeta.getPropertyNames();
Type[] propertyTypes = customMeta.getPropertyTypes();
setPrimaryKeyValueForCollectionType(customMeta, obj, firstName.concat(customMeta.getIdentifierPropertyName()), state);
for (int i = 0; i < propertyNames.length; i++) {
if (!propertyTypes[i].isEntityType() && !propertyTypes[i].isComponentType() && !propertyTypes[i].isCollectionType()) {
if (state.equalsIgnoreCase(AuditConstants.TRANSACTIONBEGIN)) {
String name = firstName.concat(propertyNames[i]);
logger.debug("i readFurtherMetaForCollectionType : " + name + " : " + 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 readFurtherMetaForCollectionType : " + name + " : " + 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]);
}
}
}
if (propertyTypes[i].isEntityType() && !propertyTypes[i].isComponentType() && propertyValues[i] instanceof MasterDataEntity && AuditConfiguration.isObjectToBeLogged(entityName, propertyNames[i], firstName)) {
populateValueForObjectsOfTypeMasterDataEntityInCollections(propertyValues[i], state, firstName.concat(propertyNames[i]));
}
if (propertyTypes[i].isEntityType() && !propertyTypes[i].isComponentType() && !(propertyValues[i] instanceof MasterDataEntity) && AuditConfiguration.isObjectToBeLogged(entityName, propertyNames[i], firstName)) {
Object object = propertyValues[i];
if (object != null) {
if (object instanceof MeetingBO) {
MeetingBO meeting = (MeetingBO) object;
if (propertyNames[i].equalsIgnoreCase("meeting") && meeting.getMeetingId() != null) {
readMeetingCollection(meeting, propertyNames[i], state);
} else {
readFurtherMetaForCollectionType(object, propertyNames[i], state);
}
} else {
readFurtherMetaForCollectionType(object, propertyNames[i], state);
}
}
}
// Reading further component type
if (!propertyTypes[i].isEntityType() && propertyTypes[i].isComponentType() && !(propertyValues[i] instanceof MasterDataEntity) && AuditConfiguration.isObjectToBeLogged(entityName, propertyNames[i], firstName)) {
Object obj1 = propertyValues[i];
if (obj1 != null) {
readComponenetTypeInCollectionTypeWithoutMerge(obj1, propertyNames[i], state, propertyTypes[i]);
}
}
}
}
use of org.mifos.application.master.business.MasterDataEntity in project head by mifos.
the class InterceptHelper method readAndMergeCollectionTypes.
private void readAndMergeCollectionTypes(Object obj, String firstName, String parentName, String state) {
Class l = getClazz(obj);
ClassMetadata customMeta = StaticHibernateUtil.getSessionFactory().getClassMetadata(l);
Object[] propertyValues = customMeta.getPropertyValues(obj, EntityMode.POJO);
String[] propertyNames = customMeta.getPropertyNames();
Type[] propertyTypes = customMeta.getPropertyTypes();
setPrimaryKeyValueForCollectionTypeAndMerge(customMeta, obj, firstName.concat(customMeta.getIdentifierPropertyName()), state);
for (int i = 0; i < propertyNames.length; i++) {
logger.debug("property Name : " + propertyNames[i] + " value : " + propertyValues[i]);
if (!propertyTypes[i].isEntityType() && !propertyTypes[i].isComponentType() && !propertyTypes[i].isCollectionType()) {
if (state.equalsIgnoreCase(AuditConstants.TRANSACTIONBEGIN)) {
String name = firstName.concat(propertyNames[i]);
logger.debug("i readFurtherMetaForCollectionType " + 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 readFurtherMetaForCollectionType " + 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]);
}
}
}
}
}
}
if (propertyTypes[i].isEntityType() && !propertyTypes[i].isComponentType() && propertyValues[i] instanceof MasterDataEntity && AuditConfiguration.isObjectToBeLogged(entityName, propertyNames[i], firstName)) {
populateAndMergeValueForObjectsOfTypeMasterDataEntityInCollections(propertyValues[i], state, firstName.concat(propertyNames[i]));
}
if (propertyTypes[i].isEntityType() && !propertyTypes[i].isComponentType() && !(propertyValues[i] instanceof MasterDataEntity) && AuditConfiguration.isObjectToBeLogged(entityName, propertyNames[i], firstName)) {
Object object = propertyValues[i];
if (object != null) {
if (object instanceof MeetingBO) {
MeetingBO meeting = (MeetingBO) object;
if (propertyNames[i].equalsIgnoreCase("meeting") && meeting.getMeetingId() != null) {
readAndMergeMeetingCollection(meeting, propertyNames[i], state);
} else {
readAndMergeCollectionTypes(object, propertyNames[i], firstName, state);
}
} else {
readAndMergeCollectionTypes(object, propertyNames[i], firstName, state);
}
}
}
// Reading further component type
if (!propertyTypes[i].isEntityType() && propertyTypes[i].isComponentType() && !(propertyValues[i] instanceof MasterDataEntity) && AuditConfiguration.isObjectToBeLogged(entityName, propertyNames[i], firstName)) {
Object obj1 = propertyValues[i];
if (obj1 != null) {
readComponenetTypeInCollectionTypeWithMerge(obj1, propertyNames[i], state, propertyTypes[i]);
}
}
}
}
Aggregations