Search in sources :

Example 11 with FieldSearchFilter

use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.

the class TestWidgetTypeAction method testAddNewWidgetType.

// TODO ADD MORE TESTS for add new widget
public void testAddNewWidgetType() throws Throwable {
    String widgetTypeCode = "randomWidgetCode_4";
    List<String> fragmantCodes = null;
    try {
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
        assertNull(this._guiFragmentManager.getGuiFragment(widgetTypeCode));
        String result = this.executeAddWidgetType("admin", widgetTypeCode, "**GUI**");
        assertEquals(Action.SUCCESS, result);
        WidgetType addedType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(addedType);
        FieldSearchFilter filterByType = new FieldSearchFilter("widgettypecode", widgetTypeCode, false);
        FieldSearchFilter[] filters = { filterByType };
        fragmantCodes = this._guiFragmentManager.searchGuiFragments(filters);
        assertNotNull(fragmantCodes);
        assertEquals(1, fragmantCodes.size());
        assertEquals(widgetTypeCode, fragmantCodes.get(0));
        GuiFragment guiFragment = this._guiFragmentManager.getGuiFragment(fragmantCodes.get(0));
        assertNotNull(guiFragment);
        assertEquals(widgetTypeCode, guiFragment.getWidgetTypeCode());
        assertEquals("**GUI**", guiFragment.getGui());
        assertFalse(guiFragment.isLocked());
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != fragmantCodes) {
            for (int i = 0; i < fragmantCodes.size(); i++) {
                String code = fragmantCodes.get(i);
                this._guiFragmentManager.deleteGuiFragment(code);
            }
        }
        this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
    }
}
Also used : GuiFragment(org.entando.entando.aps.system.services.guifragment.GuiFragment) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 12 with FieldSearchFilter

use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.

the class ConsumerFinderAction method getSearchFilters.

private FieldSearchFilter[] getSearchFilters() {
    FieldSearchFilter[] filters = new FieldSearchFilter[0];
    FieldSearchFilter keyFilter = null;
    if (null != this.getInsertedKey() && this.getInsertedKey().trim().length() > 0) {
        keyFilter = new FieldSearchFilter(IOAuthConsumerManager.CONSUMER_KEY_FILTER_KEY, this.getInsertedKey(), true);
    } else {
        keyFilter = new FieldSearchFilter(IOAuthConsumerManager.CONSUMER_KEY_FILTER_KEY);
    }
    keyFilter.setOrder(FieldSearchFilter.ASC_ORDER);
    filters = this.addFilter(keyFilter, filters);
    if (null != this.getInsertedDescription() && this.getInsertedDescription().trim().length() > 0) {
        FieldSearchFilter descrFilter = new FieldSearchFilter(IOAuthConsumerManager.CONSUMER_DESCRIPTION_FILTER_KEY, this.getInsertedDescription(), true);
        filters = this.addFilter(descrFilter, filters);
    }
    return filters;
}
Also used : FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

Example 13 with FieldSearchFilter

use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.

the class RestListRequestTest method should_create_default_pagination.

@SuppressWarnings("rawtypes")
@Test
public void should_create_default_pagination() {
    RestListRequest request = new RestListRequest();
    // filters
    List<FieldSearchFilter> filters = request.buildFieldSearchFilters();
    assertThat(filters.size(), is(2));
    // pagination
    assertThat(filters.get(0).getKey(), is(nullValue()));
    assertThat(filters.get(0).getLimit(), is(not(nullValue())));
    assertThat(filters.get(0).getOffset(), is(not(nullValue())));
}
Also used : RestListRequest(org.entando.entando.web.common.model.RestListRequest) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) Test(org.junit.Test)

Example 14 with FieldSearchFilter

use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.

the class WidgetTypeManager method getGuiFragmentUtilizers.

@Override
public List getGuiFragmentUtilizers(String guiFragmentCode) throws ApsSystemException {
    List<WidgetType> utilizers = new ArrayList<WidgetType>();
    try {
        FieldSearchFilter codeFilter = new FieldSearchFilter("code", guiFragmentCode, false);
        FieldSearchFilter widgetTypeFilter = new FieldSearchFilter("widgettypecode");
        FieldSearchFilter[] filters = { codeFilter, widgetTypeFilter };
        List<String> widgetUtilizers = this.getGuiFragmentManager().searchGuiFragments(filters);
        if (null != widgetUtilizers && !widgetUtilizers.isEmpty()) {
            for (int i = 0; i < widgetUtilizers.size(); i++) {
                String code = widgetUtilizers.get(i);
                GuiFragment fragment = this.getGuiFragmentManager().getGuiFragment(code);
                WidgetType widgetType = this.getWidgetType(fragment.getWidgetTypeCode());
                if (null != widgetType) {
                    utilizers.add(widgetType);
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Error extracting utilizers", t);
        throw new ApsSystemException("Error extracting utilizers", t);
    }
    return utilizers;
}
Also used : GuiFragment(org.entando.entando.aps.system.services.guifragment.GuiFragment) ArrayList(java.util.ArrayList) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

Example 15 with FieldSearchFilter

use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.

the class RestListRequest method getSublist.

public List getSublist(List master) {
    if (null == master) {
        return null;
    }
    if (0 == this.getPage()) {
        return master;
    }
    FieldSearchFilter pagFilter = this.buildPaginationFilter();
    int limit = (null != pagFilter) ? pagFilter.getLimit() : PAGE_SIZE_DEFAULT;
    if (null == pagFilter) {
        this.setPageSize(PAGE_SIZE_DEFAULT);
    }
    int offset = (null != pagFilter) ? pagFilter.getOffset() : this.getOffset();
    int size = master.size();
    int offsetToApply = (offset >= size) ? size : offset;
    int limitToApply = ((offsetToApply + limit) > size) ? size : (offsetToApply + limit);
    return master.subList(offsetToApply, limitToApply);
}
Also used : FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

Aggregations

FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)32 ArrayList (java.util.ArrayList)15 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)13 RestListRequest (org.entando.entando.web.common.model.RestListRequest)10 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)5 List (java.util.List)5 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)5 RestServerError (org.entando.entando.aps.system.exception.RestServerError)5 IDtoBuilder (org.entando.entando.aps.system.services.IDtoBuilder)5 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)4 Map (java.util.Map)3 GuiFragment (org.entando.entando.aps.system.services.guifragment.GuiFragment)3 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)3 Filter (org.entando.entando.web.common.model.Filter)3 Test (org.junit.Test)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 GroupUtilizer (com.agiletec.aps.system.services.group.GroupUtilizer)2