use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.
the class ExportController method exportList.
@RequestMapping("/export/lists/{listId}")
public void exportList(HttpServletResponse response, HttpServletRequest request, @ApiQueryParam(name = "listname", description = "The list id") @PathVariable("listId") String listId) {
UserProteinList pl = this.proteinListService.getUserProteinListByPublicId(listId);
String fileName = pl.getName() + ".txt";
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
// http://alpha-api.nextprot.org/export/lists/3C5KYA1M
try {
if (pl.getDescription() != null) {
response.getWriter().write("#" + pl.getDescription() + StringUtils.CR_LF);
}
if (pl.getAccessionNumbers() != null) {
for (String s : pl.getAccessionNumbers()) {
response.getWriter().write(s);
response.getWriter().write(StringUtils.CR_LF);
}
}
} catch (Exception e) {
throw new NextProtException(e.getMessage(), e);
}
}
use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.
the class UserProteinListServiceImpl method updateUserProteinList.
@Override
@Transactional
public void updateUserProteinList(UserProteinList proteinList) {
proteinListDao.updateUserProteinListMetadata(proteinList);
Set<String> accs = proteinList.getAccessionNumbers();
if (accs != null && !accs.isEmpty()) {
UserProteinList currentProteinList = proteinListDao.getUserProteinListById(proteinList.getId());
Set<String> accsToInsert = Sets.difference(accs, currentProteinList.getAccessionNumbers());
if (!accsToInsert.isEmpty())
proteinListDao.createUserProteinListItems(proteinList.getId(), accsToInsert);
}
}
use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.
the class UserProteinListDaoTest method testDeleteProteinListItems.
@Test
public void testDeleteProteinListItems() {
Set<String> accs = new HashSet<String>();
accs.add("NX_Q14249");
accs.add("NX_P05165");
int count = proteinListDao.deleteProteinListItems(156, accs);
assertEquals(2, count);
UserProteinList list = proteinListDao.getUserProteinListById(156);
assertExpectedProteinList(list, 156, "mylist", "my proteins", username, 23, 1, Sets.newHashSet("NX_Q8N5Z0"), "ZZZZZU8V");
}
use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.
the class UserProteinListDaoTest method testCreateUserProteinList.
@Test
public void testCreateUserProteinList() {
UserProteinList list = new UserProteinList();
list.setOwnerId(24);
list.setPublicId("00000001");
long id = proteinListDao.createUserProteinList(list);
assertTrue(id > 0);
UserProteinList list2 = proteinListDao.getUserProteinListById(id);
assertNotNull(list2);
assertEquals(list.getOwnerId(), list2.getOwnerId());
assertNull(list2.getDescription());
assertNull(list2.getName());
}
use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.
the class UserProteinListDaoTest method testGetUserProteinListById.
@Test
public void testGetUserProteinListById() {
UserProteinList list = proteinListDao.getUserProteinListById(156);
assertNotNull(list);
assertExpectedProteinList(list, 156, "mylist", "my proteins", username, 23, 3, Sets.newHashSet("NX_Q14249", "NX_Q8N5Z0", "NX_P05165"), "ZZZZZU8V");
}
Aggregations