Search in sources :

Example 11 with UserProteinList

use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.

the class UserProteinListUtilsTest method testCombineSameListThrowsException.

@Test(expected = NextProtException.class)
public void testCombineSameListThrowsException() {
    UserProteinList l1 = createUserProteinList("cool1", Sets.newHashSet("NX_P123", "NX_P456"));
    UserProteinListUtils.combine(l1, l1, UserProteinListService.Operator.OR, "bobleponge", "coolio", null);
}
Also used : UserProteinList(org.nextprot.api.user.domain.UserProteinList) UserProteinListServiceTest.createUserProteinList(org.nextprot.api.user.service.UserProteinListServiceTest.createUserProteinList) Test(org.junit.Test)

Example 12 with UserProteinList

use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.

the class UserProteinListUtilsTest method testCombineOr2.

@Test
public void testCombineOr2() {
    UserProteinList l1 = createUserProteinList("cool1", Sets.newHashSet("NX_P123", "NX_P456"));
    UserProteinList l2 = createUserProteinList("cool2", Sets.newHashSet("NX_P123", "NX_P321"));
    UserProteinList l3 = UserProteinListUtils.combine(l2, l1, UserProteinListService.Operator.OR, "bobleponge", "coolio", null);
    assertEquals("coolio", l3.getName());
    assertEquals(3, l3.getAccessionNumbers().size());
    assertEquals("bobleponge", l3.getOwner());
    assertEquals(Sets.newHashSet("NX_P123", "NX_P456", "NX_P321"), l3.getAccessionNumbers());
}
Also used : UserProteinList(org.nextprot.api.user.domain.UserProteinList) UserProteinListServiceTest.createUserProteinList(org.nextprot.api.user.service.UserProteinListServiceTest.createUserProteinList) Test(org.junit.Test)

Example 13 with UserProteinList

use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.

the class UserProteinListUtilsTest method testCombineAnd2.

@Test
public void testCombineAnd2() {
    UserProteinList l1 = createUserProteinList("cool1", Sets.newHashSet("NX_P123", "NX_P456"));
    UserProteinList l2 = createUserProteinList("cool2", Sets.newHashSet("NX_P123", "NX_P321"));
    UserProteinList l3 = UserProteinListUtils.combine(l2, l1, UserProteinListService.Operator.AND, "bobleponge", "homie", null);
    assertEquals("homie", l3.getName());
    assertEquals(1, l3.getAccessionNumbers().size());
    assertEquals("bobleponge", l3.getOwner());
    assertEquals("NX_P123", l3.getAccessionNumbers().iterator().next());
}
Also used : UserProteinList(org.nextprot.api.user.domain.UserProteinList) UserProteinListServiceTest.createUserProteinList(org.nextprot.api.user.service.UserProteinListServiceTest.createUserProteinList) Test(org.junit.Test)

Example 14 with UserProteinList

use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.

the class SearchController method test.

@RequestMapping(value = "/user/{username}/protein-list/{list}/results", method = RequestMethod.GET)
public String test(@PathVariable("username") String username, @PathVariable("list") String listName, @RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "order", required = false) String order, @RequestParam(value = "start", required = false) String start, @RequestParam(value = "rows", required = false) String rows, @RequestParam(value = "filter", required = false) String filter, Model model) throws SearchQueryException {
    UserProteinList proteinList = this.proteinListService.getUserProteinListByNameForUser(username, listName);
    Set<String> accessions = proteinList.getAccessionNumbers();
    String queryString = "id:" + (accessions.size() > 1 ? "(" + Joiner.on(" ").join(accessions) + ")" : accessions.iterator().next());
    // SolrIndex index = this.configuration.getIndexByName("entry");
    Query query = this.queryBuilderService.buildQueryForProteinLists("entry", queryString, "", sort, order, start, rows, filter);
    SearchResult result = this.queryService.executeQuery(query);
    model.addAttribute("result", result);
    return "search";
}
Also used : Query(org.nextprot.api.solr.Query) UserQuery(org.nextprot.api.user.domain.UserQuery) UserProteinList(org.nextprot.api.user.domain.UserProteinList) SearchResult(org.nextprot.api.solr.SearchResult) AutocompleteSearchResult(org.nextprot.api.solr.AutocompleteSearchResult) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with UserProteinList

use of org.nextprot.api.user.domain.UserProteinList in project nextprot-api by calipho-sib.

the class UserProteinListServiceImpl method combine.

@Override
public UserProteinList combine(String name, String description, String username, String listName1, String listName2, Operator op) {
    UserProteinList l1 = proteinListDao.getUserProteinListByName(username, listName1);
    UserProteinList l2 = proteinListDao.getUserProteinListByName(username, listName2);
    return UserProteinListUtils.combine(l1, l2, op, username, name, description);
}
Also used : UserProteinList(org.nextprot.api.user.domain.UserProteinList)

Aggregations

UserProteinList (org.nextprot.api.user.domain.UserProteinList)51 Test (org.junit.Test)38 UserResourceBaseTest (org.nextprot.api.user.dao.test.base.UserResourceBaseTest)13 UserProteinListServiceTest.createUserProteinList (org.nextprot.api.user.service.UserProteinListServiceTest.createUserProteinList)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 MVCBaseSecurityTest (org.nextprot.api.web.dbunit.base.mvc.MVCBaseSecurityTest)8 HashSet (java.util.HashSet)5 AbstractUnitBaseTest (org.nextprot.api.commons.dbunit.AbstractUnitBaseTest)4 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)3 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)3 ApiMethod (org.jsondoc.core.annotation.ApiMethod)2 NextProtException (org.nextprot.api.commons.exception.NextProtException)2 UserQuery (org.nextprot.api.user.domain.UserQuery)2 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)2 SqlParameterSource (org.springframework.jdbc.core.namedparam.SqlParameterSource)2 IOException (java.io.IOException)1 List (java.util.List)1 AutocompleteSearchResult (org.nextprot.api.solr.AutocompleteSearchResult)1 Query (org.nextprot.api.solr.Query)1 SearchResult (org.nextprot.api.solr.SearchResult)1