use of org.jbei.ice.storage.model.SampleCreateModel in project ice by JBEI.
the class RequestRetriever method getFolderRequests.
public UserSamples getFolderRequests(String userId, int start, int limit, String sort, boolean asc, String folderNameFilter) {
// admin feature
if (!new AccountController().isAdministrator(userId))
throw new PermissionException("Admin privileges required for this action");
List<SampleCreateModel> models = DAOFactory.getSampleCreateModelDAO().list(start, limit, sort, asc, folderNameFilter);
UserSamples result = new UserSamples();
for (SampleCreateModel model : models) {
SampleRequest request = new SampleRequest();
request.setId(model.getId());
request.setStatus(model.getStatus());
FolderDetails details = model.getFolder().toDataTransferObject();
details.setCount(DAOFactory.getFolderDAO().getFolderSize(details.getId(), null, true));
request.setFolderDetails(details);
request.setRequester(model.getAccount().toDataTransferObject());
request.setRequestTime(model.getRequested().getTime());
request.setUpdateTime(model.getUpdated().getTime());
result.getRequests().add(request);
}
long available = DAOFactory.getSampleCreateModelDAO().availableCount(folderNameFilter);
result.setCount(Long.valueOf(available).intValue());
return result;
}
use of org.jbei.ice.storage.model.SampleCreateModel in project ice by JBEI.
the class RequestRetriever method updateFolderRequest.
private SampleRequest updateFolderRequest(long requestId, SampleRequestStatus newStatus) {
SampleCreateModel model = DAOFactory.getSampleCreateModelDAO().get(requestId);
if (model == null)
return null;
model.setStatus(newStatus);
model.setUpdated(new Date());
model = DAOFactory.getSampleCreateModelDAO().update(model);
SampleRequest request = new SampleRequest();
request.setId(model.getId());
request.setUpdateTime(model.getUpdated().getTime());
request.setStatus(model.getStatus());
return request;
}
use of org.jbei.ice.storage.model.SampleCreateModel in project ice by JBEI.
the class SampleCreateModelDAO method getByFolder.
public SampleCreateModel getByFolder(Folder folder) {
try {
CriteriaQuery<SampleCreateModel> query = getBuilder().createQuery(SampleCreateModel.class);
Root<SampleCreateModel> from = query.from(SampleCreateModel.class);
query.where(getBuilder().equal(from.get("folder"), folder));
return currentSession().createQuery(query).uniqueResult();
} catch (Exception he) {
Logger.error(he);
throw new DAOException(he);
}
}
use of org.jbei.ice.storage.model.SampleCreateModel in project ice by JBEI.
the class UserFolders method get.
public FolderDetails get(long folderId) {
Folder folder = this.dao.get(folderId);
if (folder == null)
throw new IllegalArgumentException("Folder with id " + folderId + " does not exist");
authorization.expectRead(this.userId, folder);
FolderDetails folderDetails = folder.toDataTransferObject();
List<String> types = dao.getContentTypes(folderId);
if (!types.isEmpty()) {
for (String type : types) {
EntryType entryType = EntryType.nameToType(type);
if (entryType != null)
folderDetails.getContentTypes().add(entryType);
}
}
Account owner = accountDAO.getByEmail(folder.getOwnerEmail());
if (owner != null) {
folderDetails.setOwner(owner.toDataTransferObject());
}
// get sample details
if (folder.getType() == FolderType.SAMPLE) {
SampleCreateModel model = DAOFactory.getSampleCreateModelDAO().getByFolder(folder);
if (model != null) {
SampleRequest request = new SampleRequest();
request.setId(model.getId());
request.setStatus(model.getStatus());
folderDetails.setSampleRequest(request);
}
}
return folderDetails;
}
Aggregations