Package com.ponysdk.core.query

Examples of com.ponysdk.core.query.Criterion


        hiddenValueByItems.put(item, hiddenValue);
        itemsByHiddenValue.put(hiddenValue, item);
    }

    protected List<String> filter(final String filter) {
        final Criterion criterionField = new Criterion("");
        criterionField.setValue("%" + filter + "%");
        criterionField.setSortingType(SortingType.ASCENDING);
        List<String> filtered = FilteringTools.filterStringCollection(new ArrayList<String>(hiddenValueByItems.keySet()), Arrays.asList(criterionField));
        filtered = FilteringTools.sortStringCollection(filtered, Arrays.asList(criterionField));
        return filtered;
    }
View Full Code Here


        final ComplexListView complexListView = new DefaultComplexListView();
        complexListView.setFloatableToolBar(scrolPanel);

        complexListActivity = new ComplexListActivity<Pony>(complexListConfiguration, complexListView, getRootEventBus());

        complexListActivity.registerSearchCriteria(new Criterion("name"), nameSearchField);
        complexListActivity.registerSearchCriteria(new Criterion("age"), ageSearchField);

        complexListActivity.setCommandFactory(new ComplexListCommandFactory<Pony>() {

            @Override
            public Command<Result<List<Pony>>> newFindCommand(final ComplexListActivity<Pony> complexListActivity, final Query query) {
View Full Code Here

    }

    @Override
    public List<Criterion> getCriteria() {

        final Criterion criterion = new Criterion(key);
        criterion.setSortingType(sortingType);

        return Arrays.asList(criterion);
    }
View Full Code Here

    @Override
    public List<Criterion> getCriteria() {

        if (formField.getValue() != null) {
            final Criterion criterion = new Criterion(key);
            criterion.setValue(formField.getValue());
            criterion.setSortingType(sortingType);
            return Arrays.asList(criterion);
        }

        if (sortingType != SortingType.NONE) {
            final Criterion criterion = new Criterion(key);
            criterion.setSortingType(sortingType);
            return Arrays.asList(criterion);
        }

        return Collections.emptyList();
    }
View Full Code Here

        final List<Criterion> criteria = new ArrayList<Criterion>();
        for (final Entry<Criterion, FormField> entry : formFieldsByCriterionFields.entrySet()) {
            final FormField formField = entry.getValue();

            if (formField.getValue() != null) {
                final Criterion criterionField = entry.getKey();
                criterionField.setValue(formField.getValue());
                criteria.add(criterionField);
            }
        }

        if (currentSortingPojoPropertyKey != null) {
            final Criterion criterionField = new Criterion(currentSortingPojoPropertyKey);
            criterionField.setSortingType(currentSortingType);
            criteria.add(criterionField);
        }

        final Query query = new Query();
        query.setCriteria(criteria);
View Full Code Here

        refresh();
    }

    @Override
    public void onComparatorTypeChange(final ComparatorTypeChangeEvent event) {
        final Criterion criterionField = criterionByPojoProperty.get(event.getPojoPropertyKey());
        if (criterionField != null) {
            criterionField.setComparator(event.getComparatorType());
        }
    }
View Full Code Here

        final ListColumnDescriptor<D, Object> columnDescriptor = new ListColumnDescriptor<D, Object>();
        columnDescriptor.setHeaderCellRenderer(headerCellRenderer);
        columnDescriptor.setCustom(true);
        columnDescriptor.setValueProvider(new BeanValueProvider<D, Object>(fieldPath));
        addDescriptor(columnDescriptor);
        registerSearchCriteria(new Criterion(fieldPath), formField);
        final ColumnDescriptorFieldHolder descriptorHolder = new ColumnDescriptorFieldHolder(caption, fieldPath, fieldType, complexListConfiguration.getTableName());
        customDescriptorHolderByCaption.put(caption, descriptorHolder);
        rebuildSimpleList();
        eventBus.fireEvent(new CustomColumnDescriptorAddedEvent(ComplexListActivity.this, descriptorHolder));
    }
View Full Code Here

    private static Logger log = LoggerFactory.getLogger(AbstractCriteriaDecorator.class);

    @SuppressWarnings("rawtypes")
    @Override
    public void render(final CriteriaContext context) {
        final Criterion field = context.getCriterion();
        Criteria criteria = context.getOrderingCriteria();

        final List<String> propertyNamePath = Arrays.asList(field.getPojoProperty().split(REGEX_SPLIT));
        final Iterator<String> iter = propertyNamePath.iterator();
        String key = null;
        String associationPath = null;
        if (propertyNamePath.size() == 1) {
            associationPath = iter.next();
        } else while (iter.hasNext()) {
            key = iter.next();
            if (associationPath == null) {
                associationPath = new String(key);
            } else {
                associationPath += "." + key;
            }
            if (iter.hasNext()) {
                criteria = criteria.createCriteria(associationPath, key, CriteriaSpecification.INNER_JOIN);
                associationPath = new String(key);
            }
        }

        final T value = getObjectValue(field);
        ComparatorType comparator = field.getComparator();

        if (value != null) {
            if (value.toString().contains("%")) {
                comparator = ComparatorType.LIKE;
            }
        }

        if (field.getValue() != null || field.getComparator() == ComparatorType.IS_NULL || field.getComparator() == ComparatorType.IS_NOT_NULL) {

            switch (comparator) {
                case EQ:
                    criteria.add(Restrictions.eq(associationPath, value));
                    break;
                case GE:
                    criteria.add(Restrictions.ge(associationPath, value));
                    break;
                case GT:
                    criteria.add(Restrictions.gt(associationPath, value));
                    break;
                case LE:
                    criteria.add(Restrictions.le(associationPath, value));
                    break;
                case LT:
                    criteria.add(Restrictions.lt(associationPath, value));
                    break;
                case NE:
                    criteria.add(Restrictions.ne(associationPath, value));
                    break;
                case LIKE:
                    criteria.add(Restrictions.ilike(associationPath, value));
                    break;
                case IS_NULL:
                    criteria.add(Restrictions.isNull(associationPath));
                    break;
                case IS_NOT_NULL:
                    criteria.add(Restrictions.isNotNull(associationPath));
                    break;
                case IN:
                    if (value instanceof Collection) {
                        criteria.add(Restrictions.in(associationPath, (Collection) value));
                    } else if (value instanceof Object[]) {
                        criteria.add(Restrictions.in(associationPath, (Object[]) value));
                    } else {
                        log.warn("Type not allowed for IN clause: " + value.getClass() + ", value: " + value);
                    }
                    break;

                default:
                    log.warn("Restriction not supported: " + comparator);
                    break;
            }
        }

        switch (field.getSortingType()) {
            case ASCENDING:
                criteria.addOrder(Order.asc(associationPath));
                break;
            case DESCENDING:
                criteria.addOrder(Order.desc(associationPath));
View Full Code Here

            }
        }

        // sort forced on the default property
        if (applyDefaultSorting) {
            final Criterion field = new Criterion(defaultSortingProperty);
            field.setSortingType(sortingType);
            final CriteriaContext context = new CriteriaContext();
            context.setCriterion(field);
            context.setOrderingCriteria(criteria);
            sortCriteriaDecorator.render(context);
        }
View Full Code Here

public class DefaultSortCriteriaDecorator implements CriteriaDecorator {

    @Override
    public void render(final CriteriaContext context) {
        final Criterion field = context.getCriterion();

        if (field.getSortingType() == SortingType.NONE) return;

        Criteria criteria = context.getOrderingCriteria();

        final List<String> propertyNamePath = Arrays.asList(field.getPojoProperty().split(REGEX_SPLIT));
        final Iterator<String> iter = propertyNamePath.iterator();
        String key = null;
        String associationPath = null;
        if (propertyNamePath.size() == 1) {
            associationPath = iter.next();
        } else while (iter.hasNext()) {
            key = iter.next();
            if (associationPath == null) {
                associationPath = new String(key);
            } else {
                associationPath += "." + key;
            }
            if (iter.hasNext()) {
                criteria = criteria.createCriteria(associationPath, key, CriteriaSpecification.LEFT_JOIN);
                associationPath = new String(key);
            }
        }
        criteria = context.getOrderingCriteria();
        if (field.getSortingType() == SortingType.ASCENDING) {
            criteria.addOrder(Order.asc(associationPath));
        } else if (field.getSortingType() == SortingType.DESCENDING) {
            criteria.addOrder(Order.desc(associationPath));
        }
    }
View Full Code Here

TOP

Related Classes of com.ponysdk.core.query.Criterion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.