use of org.mifos.customers.client.business.CustomerPictureEntity in project head by mifos.
the class ClientPhotoServiceDatabase method create.
@Override
public boolean create(Long clientId, InputStream in) {
boolean transactionStarted = false;
if (in == null) {
return false;
}
try {
//create blob
final Blob blob = this.createBlob(in);
//create picture
final ImageInfo imageInfo = new ImageInfo();
imageInfo.setContentType(this.determineContentType(in));
imageInfo.setLength(blob.length());
CustomerPictureEntity picture = new CustomerPictureEntity(blob);
imageInfo.setPicture(picture);
final ClientPhoto clientPhoto = new ClientPhoto();
clientPhoto.setClientId(clientId);
clientPhoto.setImageInfo(imageInfo);
//save
hibernateTransactionHelper.startTransaction();
transactionStarted = true;
this.genericDao.createOrUpdate(clientPhoto);
hibernateTransactionHelper.commitTransaction();
} catch (Exception ex) {
if (transactionStarted) {
hibernateTransactionHelper.rollbackTransaction();
}
LOG.error("Unable to create picture", ex);
return false;
}
return true;
}
use of org.mifos.customers.client.business.CustomerPictureEntity in project head by mifos.
the class CustomerPersistence method retrievePicture.
public CustomerPictureEntity retrievePicture(final Integer customerId) throws PersistenceException {
Map<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("customerId", customerId);
List queryResult = executeNamedQuery(NamedQueryConstants.GET_CUSTOMER_PICTURE, queryParameters);
return (CustomerPictureEntity) queryResult.get(0);
}
Aggregations