use of org.jbei.ice.storage.model.Request in project ice by JBEI.
the class RequestRetriever method setRequestsStatus.
public boolean setRequestsStatus(String userId, ArrayList<Long> ids, SampleRequestStatus status) {
boolean sendEmail = status == SampleRequestStatus.PENDING;
Account account = DAOFactory.getAccountDAO().getByEmail(userId);
for (long id : ids) {
Request request = dao.get(id);
if (request == null)
continue;
if (!request.getAccount().getEmail().equalsIgnoreCase(userId) && account.getType() != AccountType.ADMIN)
continue;
request.setStatus(status);
request.setRequested(new Date());
dao.update(request);
}
// send email to strain archivist
if (sendEmail) {
String email = Utils.getConfigValue(ConfigurationKey.BULK_UPLOAD_APPROVER_EMAIL);
if (email != null && !email.isEmpty()) {
String subject = "Sample request";
String body = "A sample request has been received from " + account.getFullName() + " for " + ids.size();
if (ids.size() == 1)
body += " sample";
else
body += " samples";
body += "\n\nPlease go to the following link to review pending requests.\n\n";
body += Utils.getConfigValue(ConfigurationKey.URI_PREFIX) + "/admin/samples";
EmailFactory.getEmail().send(email, subject, body);
}
}
return true;
}
use of org.jbei.ice.storage.model.Request in project ice by JBEI.
the class RequestRetriever method getRequests.
public UserSamples getRequests(String userId, int start, int limit, String sort, boolean asc, SampleRequestStatus status, String filter) {
Account account = DAOFactory.getAccountDAO().getByEmail(userId);
if (account.getType() != AccountType.ADMIN)
return getUserSamples(userId, null, start, limit, sort, asc);
int count = dao.getCount(status, filter);
UserSamples samples = new UserSamples();
samples.setCount(count);
List<Request> results = dao.get(start, limit, sort, asc, status, filter);
SampleService sampleService = new SampleService();
for (Request request : results) {
SampleRequest sampleRequest = request.toDataTransferObject();
List<PartSample> location = sampleService.retrieveEntrySamples(userId, Long.toString(request.getEntry().getId()));
sampleRequest.setLocation(location);
samples.getRequests().add(sampleRequest);
}
return samples;
}
use of org.jbei.ice.storage.model.Request in project ice by JBEI.
the class RequestRetriever method getUserSamples.
public UserSamples getUserSamples(String userId, SampleRequestStatus status, int start, int limit, String sort, boolean asc) {
Account account = DAOFactory.getAccountDAO().getByEmail(userId);
UserSamples samples = new UserSamples();
int count = dao.getCount(account);
samples.setCount(count);
List<Request> requestList = dao.getAccountRequests(account, status, start, limit, sort, asc);
for (Request request : requestList) samples.getRequests().add(request.toDataTransferObject());
return samples;
}
Aggregations