use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.
the class UserProteinListDaoTest method testDuplicateUserProteinList.
@Test(expected = DuplicateKeyException.class)
public void testDuplicateUserProteinList() {
UserProteinList l = new UserProteinList();
l.setName("mylist");
l.setOwnerId(23);
l.setPublicId("00000001");
proteinListDao.createUserProteinList(l);
}
use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.
the class UserProteinListDaoTest method testCreateUserProteinList2.
@Test
public void testCreateUserProteinList2() {
int ownerId = 24;
String desc = "my list";
String name = "my list of proteins";
String publicId = "00000006";
UserProteinList list = new UserProteinList();
list.setName(name);
list.setOwnerId(ownerId);
list.setDescription(desc);
list.setPublicId(publicId);
long id = proteinListDao.createUserProteinList(list);
list = proteinListDao.getUserProteinListById(id);
assertNotNull(list);
assertEquals(ownerId, list.getOwnerId());
assertEquals(desc, list.getDescription());
assertEquals(name, list.getName());
assertEquals(publicId, list.getPublicId());
}
use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.
the class UserProteinListDaoTest method testUpdateUserProteinList2.
@Test
public void testUpdateUserProteinList2() {
UserProteinList l = new UserProteinList();
l.setId(156);
l.setName("ma liste");
l.setDescription("la liste de bob leponge");
l.setAccessions(Sets.newHashSet("NX_Q14249"));
proteinListDao.updateUserProteinListMetadata(l);
UserProteinList l2 = proteinListDao.getUserProteinListById(l.getId());
assertExpectedProteinList(l2, 156, "ma liste", "la liste de bob leponge", username, 23, 3, Sets.newHashSet("NX_Q14249", "NX_Q8N5Z0", "NX_P05165"), "ZZZZZU8V");
}
use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.
the class UserProteinListUtils method combine.
/**
* Apply the given operator to two user protein lists in a new instance of
* {@code UserProteinList}
*
* @param l1 first user protein list
* @param l2 second user protein list
* @param operator operator applied to operands
* @param username combined list user name
* @param name combined list name
* @param description combined list description
* @return a new user protein list combining l1 and l2
*/
public static UserProteinList combine(UserProteinList l1, UserProteinList l2, Operator operator, String username, String name, String description) {
NPreconditions.checkNotNull(l1, "The first user protein list should not be null");
NPreconditions.checkNotNull(l2, "The second user protein list should not be null");
NPreconditions.checkNotNull(operator, "The combine operator should not be null");
NPreconditions.checkNotNull(name, "The user protein list name should not be null");
NPreconditions.checkNotNull(username, "The user protein list user name should not be null");
NPreconditions.checkTrue(!l1.equals(l2), "Can't make combination with the same lists");
Set<String> combined = new HashSet<>();
if (operator.equals(Operator.AND)) {
combined.addAll(Sets.intersection(l1.getAccessionNumbers(), l2.getAccessionNumbers()));
} else if (operator.equals(Operator.OR)) {
combined = Sets.union(l1.getAccessionNumbers(), l2.getAccessionNumbers());
} else if (operator.equals(Operator.NOT_IN)) {
combined.addAll(Sets.difference(l1.getAccessionNumbers(), l2.getAccessionNumbers()));
}
if (combined.isEmpty())
throw new NextProtException("The combined list is empty. Only combinations resulting on non-empty lists are saved.");
UserProteinList combinedProteinList = new UserProteinList();
combinedProteinList.setName(name);
combinedProteinList.setOwner(username);
combinedProteinList.setDescription(description);
combinedProteinList.setAccessions(combined);
return combinedProteinList;
}
use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.
the class UserProteinListController method deleteUserProteinList.
// Delete a list
@ApiMethod(verb = ApiVerb.DELETE, description = "Deletes a user protein list for the current logged user", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(value = "/user/me/lists/{listid}", method = { RequestMethod.DELETE })
public void deleteUserProteinList(@PathVariable("listid") String id) {
UserProteinList userProteinList = proteinListService.getUserProteinListById(Long.parseLong(id));
this.proteinListService.deleteUserProteinList(userProteinList);
}
Aggregations