use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class TransferredParts method saveTransferred.
private Entry saveTransferred(PartData part) {
Entry entry = dao.getByRecordId(part.getRecordId());
if (entry != null) {
Logger.info("Transferred entry found locally " + part.getRecordId());
part.setId(entry.getId());
} else {
entry = InfoToModelFactory.infoToEntry(part);
entry.setVisibility(Visibility.TRANSFERRED.getValue());
entry = dao.create(entry);
part.setId(entry.getId());
part.setRecordId(entry.getRecordId());
}
// transfer and linked
for (PartData data : part.getLinkedParts()) {
Entry linked = saveTransferred(data);
data.setId(linked.getId());
data.setRecordId(linked.getRecordId());
entry.getLinkedEntries().add(linked);
dao.update(entry);
}
return entry;
}
use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class PartnerResource method getWebEntryTooltip.
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/entries/{entryId}/tooltip")
public Response getWebEntryTooltip(@PathParam("id") final long partnerId, @PathParam("entryId") final long entryId) {
final String userId = super.getUserId();
RemoteEntries remoteEntries = new RemoteEntries();
final PartData result = remoteEntries.getPublicEntryTooltip(userId, partnerId, entryId);
return super.respond(Response.Status.OK, result);
}
use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class BulkEntryCreator method createOrUpdateEntries.
public BulkUploadInfo createOrUpdateEntries(String userId, long draftId, List<PartData> data) {
BulkUpload draft = dao.get(draftId);
if (draft == null)
return null;
// check permissions
authorization.expectWrite(userId, draft);
BulkUploadInfo uploadInfo = draft.toDataTransferObject();
for (PartData datum : data) {
if (datum == null)
continue;
int index = datum.getIndex();
Entry entry = entryDAO.get(datum.getId());
if (entry != null) {
if (draft.getStatus() != BulkUploadStatus.BULK_EDIT)
entry.setVisibility(Visibility.DRAFT.getValue());
datum = doUpdate(userId, entry, datum);
} else
datum = createEntryForUpload(userId, datum, draft);
if (datum == null)
return null;
datum.setIndex(index);
uploadInfo.getEntryList().add(datum);
}
return uploadInfo;
}
use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class FolderContents method getContents.
/**
* Retrieves the folder specified in the parameter and contents
*
* @param userId unique identifier for user making request. If null, folder must have public read privs
* @param folderId unique identifier for folder to be retrieved
* @param pageParameters paging parameters
* @return wrapper around list of folder entries if folder is found, null otherwise
* @throws PermissionException if user does not have read permissions on folder
*/
public FolderDetails getContents(String userId, long folderId, PageParameters pageParameters) {
Folder folder = folderDAO.get(folderId);
if (folder == null)
return null;
// should have permission to read folder
folderAuthorization.expectRead(userId, folder);
if (folder.getType() == FolderType.REMOTE)
return getRemoteContents(userId, folder, pageParameters);
boolean visibleOnly = folder.getType() != FolderType.TRANSFERRED;
FolderDetails details = folder.toDataTransferObject();
// all local entries at this point
long folderSize = folderDAO.getFolderSize(folderId, pageParameters.getFilter(), visibleOnly);
details.setCount(folderSize);
if (userId != null) {
List<AccessPermission> permissions = getAndFilterFolderPermissions(userId, folder);
details.setAccessPermissions(permissions);
boolean canEdit = permissionsController.hasWritePermission(userId, folder);
details.setCanEdit(canEdit);
}
details.setPublicReadAccess(permissionsController.isPublicVisible(folder));
Account owner = DAOFactory.getAccountDAO().getByEmail(folder.getOwnerEmail());
if (owner != null)
details.setOwner(owner.toDataTransferObject());
// retrieve folder contents
List<Entry> results = folderDAO.retrieveFolderContents(folderId, pageParameters, visibleOnly);
for (Entry entry : results) {
PartData info = ModelToInfoFactory.createTableViewData(userId, entry, false);
details.getEntries().add(info);
}
return details;
}
use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class FolderController method getPublicEntries.
/**
* Retrieves entries that are made available publicly
*
* @param sort order of retrieval for the entries
* @param offset start of retrieval
* @param limit maximum number of entries to retrieve
* @param asc whether to retrieve the entries in ascending order
* @return wrapper around the retrieved entries
*/
public FolderDetails getPublicEntries(ColumnField sort, int offset, int limit, boolean asc) {
Group publicGroup = new GroupController().createOrRetrievePublicGroup();
Set<Group> groups = new HashSet<>();
groups.add(publicGroup);
EntryDAO entryDAO = DAOFactory.getEntryDAO();
List<Entry> results = entryDAO.retrieveVisibleEntries(null, groups, sort, asc, offset, limit, null);
long visibleCount = entryDAO.visibleEntryCount(null, groups, null);
FolderDetails details = new FolderDetails();
details.setCount(visibleCount);
for (Entry entry : results) {
try {
PartData info = ModelToInfoFactory.createTableViewData(null, entry, false);
info.setPublicRead(true);
details.getEntries().add(info);
} catch (Exception e) {
Logger.error(e);
}
}
return details;
}
Aggregations