Search in sources :

Example 1 with SpaceFilter

use of org.exoplatform.social.core.space.SpaceFilter in project social by Meeds-io.

the class SpaceServiceTest method testGetPendingSpacesByFilterWithSpaceNameSearchCondition.

/**
 * Test {@link SpaceService#getPendingSpacesByFilter(String, SpaceFilter))}
 *
 * @throws Exception
 * @since 1.2.0-GA
 */
public void testGetPendingSpacesByFilterWithSpaceNameSearchCondition() throws Exception {
    int count = 20;
    for (int i = 0; i < count; i++) {
        tearDownSpaceList.add(this.getSpaceInstance(i));
    }
    String nameSpace = "my space";
    ListAccess<Space> foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter(nameSpace));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    assertEquals("foundSpaces.load(0, 1).length must return: 1", 1, foundSpaces.load(0, 1).length);
    assertEquals("foundSpaces.load(0, count).length must return: " + count, count, foundSpaces.load(0, count).length);
    foundSpaces = spaceService.getPendingSpacesByFilter("paul", new SpaceFilter(nameSpace));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPendingSpacesByFilter("hacker", new SpaceFilter("space"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("add new"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("add*"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("*add*"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("*add"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("*add*e"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("*add*e*"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("%add%e%"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("%add*e%"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("%add*e*"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("no space"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: 0", 0, foundSpaces.getSize());
}
Also used : Space(org.exoplatform.social.core.space.model.Space) SpaceFilter(org.exoplatform.social.core.space.SpaceFilter)

Example 2 with SpaceFilter

use of org.exoplatform.social.core.space.SpaceFilter in project social by Meeds-io.

the class SpaceServiceTest method testGetPendingSpacesByFilterWithFirstCharacterOfSpaceName.

/**
 * Test {@link SpaceService#getPendingSpacesByFilter(String, SpaceFilter)}
 *
 * @throws Exception
 * @since 1.2.0-GA
 */
public void testGetPendingSpacesByFilterWithFirstCharacterOfSpaceName() throws Exception {
    int count = 20;
    for (int i = 0; i < count; i++) {
        tearDownSpaceList.add(this.getSpaceInstance(i));
    }
    ListAccess<Space> foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter('m'));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    assertEquals("foundSpaces.load(0, 1).length must return: 1", 1, foundSpaces.load(0, 1).length);
    assertEquals("foundSpaces.load(0, count).length must return: " + count, count, foundSpaces.load(0, count).length);
    foundSpaces = spaceService.getPendingSpacesByFilter("paul", new SpaceFilter('M'));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter('*'));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + 0, 0, foundSpaces.getSize());
    foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter('H'));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: 0", 0, foundSpaces.getSize());
    foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter('k'));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: 0", 0, foundSpaces.getSize());
}
Also used : Space(org.exoplatform.social.core.space.model.Space) SpaceFilter(org.exoplatform.social.core.space.SpaceFilter)

Example 3 with SpaceFilter

use of org.exoplatform.social.core.space.SpaceFilter in project social by Meeds-io.

the class SpaceServiceTest method testGetPublicSpacesByFilterWithSpaceNameSearchCondition.

/**
 * Test {@link SpaceService#getPublicSpacesByFilter(String, SpaceFilter)}
 *
 * @throws Exception
 * @since 1.2.0-GA
 */
public void testGetPublicSpacesByFilterWithSpaceNameSearchCondition() throws Exception {
    int count = 20;
    for (int i = 0; i < count; i++) {
        tearDownSpaceList.add(this.getSpaceInstance(i));
    }
    String nameSpace = "my space";
    ListAccess<Space> foundSpaces = spaceService.getPublicSpacesByFilter("tom", new SpaceFilter(nameSpace));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: 0", 0, foundSpaces.getSize());
    foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter(nameSpace));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    assertEquals("foundSpaces.load(0, 1).length must return: 1", 1, foundSpaces.load(0, 1).length);
    assertEquals("foundSpaces.load(0, count).length must return: " + count, count, foundSpaces.load(0, count).length);
    foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("*m"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("m*"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("*my*"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("*my*e"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("*my*e*"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("%my%e%"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("%my*e%"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("*my%e%"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
    foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("***"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + 0, 0, foundSpaces.getSize());
    foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("%%%"));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + 0, 0, foundSpaces.getSize());
    nameSpace = "my space 1";
    foundSpaces = spaceService.getPublicSpacesByFilter("stranger", new SpaceFilter(""));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + 0, 0, foundSpaces.getSize());
    nameSpace = "my space 20";
    foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter(nameSpace));
    assertNotNull("foundSpaces must not be null", foundSpaces);
    assertEquals("foundSpaces.getSize() must return: " + 0, 0, foundSpaces.getSize());
}
Also used : Space(org.exoplatform.social.core.space.model.Space) SpaceFilter(org.exoplatform.social.core.space.SpaceFilter)

Example 4 with SpaceFilter

use of org.exoplatform.social.core.space.SpaceFilter in project social by Meeds-io.

the class UIManageInvitationSpaces method loadInvitedSpaces.

private List<Space> loadInvitedSpaces(int index, int length) throws Exception {
    String charSearch = getSelectedChar();
    String searchCondition = uiSpaceSearch.getSpaceNameSearch();
    if (SEARCH_ALL.equals(charSearch) || (charSearch == null && searchCondition == null)) {
        setInvitedSpacesListAccess(getSpaceService().getInvitedSpacesWithListAccess(getUserId()));
    } else if (searchCondition != null) {
        setInvitedSpacesListAccess(getSpaceService().getInvitedSpacesByFilter(getUserId(), new SpaceFilter(searchCondition)));
    } else if (charSearch != null) {
        setInvitedSpacesListAccess(getSpaceService().getInvitedSpacesByFilter(getUserId(), new SpaceFilter(charSearch.charAt(0))));
    }
    setInvitedSpacesNum(getInvitedSpacesListAccess().getSize());
    uiSpaceSearch.setSpaceNum(getInvitedSpacesNum());
    Space[] spaces = getInvitedSpacesListAccess().load(index, length);
    return new ArrayList<Space>(Arrays.asList(spaces));
}
Also used : Space(org.exoplatform.social.core.space.model.Space) SpaceFilter(org.exoplatform.social.core.space.SpaceFilter) ArrayList(java.util.ArrayList)

Example 5 with SpaceFilter

use of org.exoplatform.social.core.space.SpaceFilter in project social by Meeds-io.

the class UIManageMySpaces method loadMySpaces.

private List<Space> loadMySpaces(int index, int length) throws Exception {
    String charSearch = getSelectedChar();
    String searchCondition = uiSpaceSearch.getSpaceNameSearch();
    if (SEARCH_ALL.equals(charSearch) || (charSearch == null && searchCondition == null)) {
        setMySpacesListAccess(getSpaceService().getMemberSpaces(getUserId()));
    } else if (searchCondition != null) {
        setMySpacesListAccess(getSpaceService().getMemberSpacesByFilter(getUserId(), new SpaceFilter(searchCondition)));
    } else if (charSearch != null) {
        setMySpacesListAccess(getSpaceService().getMemberSpacesByFilter(getUserId(), new SpaceFilter(charSearch.charAt(0))));
    }
    setMySpacesNum(getMySpacesListAccess().getSize());
    uiSpaceSearch.setSpaceNum(getMySpacesNum());
    Space[] spaces = getMySpacesListAccess().load(index, length);
    return new ArrayList<Space>(Arrays.asList(spaces));
}
Also used : Space(org.exoplatform.social.core.space.model.Space) SpaceFilter(org.exoplatform.social.core.space.SpaceFilter) ArrayList(java.util.ArrayList)

Aggregations

SpaceFilter (org.exoplatform.social.core.space.SpaceFilter)62 Space (org.exoplatform.social.core.space.model.Space)61 MaxQueryNumber (org.exoplatform.social.core.jpa.test.MaxQueryNumber)16 MaxQueryNumber (org.exoplatform.social.core.test.MaxQueryNumber)15 ArrayList (java.util.ArrayList)5 SpaceListAccess (org.exoplatform.social.core.space.SpaceListAccess)4 Identity (org.exoplatform.social.core.identity.model.Identity)3 SpaceService (org.exoplatform.social.core.space.spi.SpaceService)3 java.util (java.util)2 RolesAllowed (javax.annotation.security.RolesAllowed)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 GET (javax.ws.rs.GET)2 ExoContainerContext (org.exoplatform.container.ExoContainerContext)2 ExoLogger (org.exoplatform.services.log.ExoLogger)2 Log (org.exoplatform.services.log.Log)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponse (io.swagger.annotations.ApiResponse)1 ApiResponses (io.swagger.annotations.ApiResponses)1 Collectors (java.util.stream.Collectors)1 Row (javax.jcr.query.Row)1