Package org.apache.syncope.core.persistence.dao.search

Examples of org.apache.syncope.core.persistence.dao.search.AttributeCond


        assertTrue(ids.contains(3L));
    }

    @Test
    public void searchByBoolean() {
        AttributeCond coolLeafCond = new AttributeCond(AttributeCond.Type.EQ);
        coolLeafCond.setSchema("cool");
        coolLeafCond.setExpression("true");

        SearchCond cond = SearchCond.getLeafCond(coolLeafCond);
        assertTrue(cond.isValid());

        List<SyncopeUser> users =
View Full Code Here


        assertEquals(Long.valueOf(4L), users.get(0).getId());
    }

    @Test
    public void searchByPageAndSize() {
        AttributeCond fullnameLeafCond = new AttributeCond(AttributeCond.Type.LIKE);
        fullnameLeafCond.setSchema("fullname");
        fullnameLeafCond.setExpression("%o%");

        MembershipCond membershipCond = new MembershipCond();
        membershipCond.setRoleId(1L);

        AttributeCond loginDateCond = new AttributeCond(AttributeCond.Type.EQ);
        loginDateCond.setSchema("loginDate");
        loginDateCond.setExpression("2009-05-26");

        SearchCond subCond = SearchCond.getAndCond(SearchCond.getLeafCond(fullnameLeafCond), SearchCond.getLeafCond(
                membershipCond));

        assertTrue(subCond.isValid());
View Full Code Here

        assertEquals(5, users.size());
    }

    @Test
    public void searchByIsNull() {
        AttributeCond coolLeafCond = new AttributeCond(AttributeCond.Type.ISNULL);
        coolLeafCond.setSchema("cool");

        List<SyncopeUser> users = searchDAO.search(
                EntitlementUtil.getRoleIds(entitlementDAO.findAll()), SearchCond.getLeafCond(coolLeafCond),
                SubjectType.USER);
        assertNotNull(users);
        assertEquals(4, users.size());

        coolLeafCond = new AttributeCond(AttributeCond.Type.ISNOTNULL);
        coolLeafCond.setSchema("cool");

        users = searchDAO.search(
                EntitlementUtil.getRoleIds(entitlementDAO.findAll()), SearchCond.getLeafCond(coolLeafCond),
                SubjectType.USER);
        assertNotNull(users);
View Full Code Here

    public void searchByUsernameAndFullname() {
        SubjectCond usernameLeafCond = new SubjectCond(SubjectCond.Type.EQ);
        usernameLeafCond.setSchema("username");
        usernameLeafCond.setExpression("rossini");

        AttributeCond idRightCond = new AttributeCond(AttributeCond.Type.LIKE);
        idRightCond.setSchema("fullname");
        idRightCond.setExpression("Giuseppe V%");

        SearchCond searchCondition = SearchCond.getOrCond(SearchCond.getLeafCond(usernameLeafCond),
                SearchCond.getLeafCond(idRightCond));

        List<SyncopeUser> matchingUsers =
View Full Code Here

    @Test
    public void userOrderBy() {
        SubjectCond usernameLeafCond = new SubjectCond(SubjectCond.Type.EQ);
        usernameLeafCond.setSchema("username");
        usernameLeafCond.setExpression("rossini");
        AttributeCond idRightCond = new AttributeCond(AttributeCond.Type.LIKE);
        idRightCond.setSchema("fullname");
        idRightCond.setExpression("Giuseppe V%");
        SearchCond searchCondition = SearchCond.getOrCond(
                SearchCond.getLeafCond(usernameLeafCond), SearchCond.getLeafCond(idRightCond));

        List<OrderByClause> orderByClauses = new ArrayList<OrderByClause>();
        OrderByClause orderByClause = new OrderByClause();
View Full Code Here

        assertEquals(1, users.size());
    }

    @Test
    public void issueSYNCOPE433() {
        AttributeCond isNullCond = new AttributeCond(AttributeCond.Type.ISNULL);
        isNullCond.setSchema("loginDate");

        SubjectCond likeCond = new SubjectCond(AttributeCond.Type.LIKE);
        likeCond.setSchema("username");
        likeCond.setExpression("%ossin%");
View Full Code Here

    public SearchCondVisitor(final Map<String, String> fieldMap) {
        super(fieldMap);
    }

    private AttributeCond createAttributeCond(final String schema) {
        AttributeCond attributeCond = ATTRIBUTABLE_FIELDS.contains(schema)
                ? new SubjectCond()
                : new AttributeCond();
        attributeCond.setSchema(schema);
        return attributeCond;
    }
View Full Code Here

        String value = SearchUtils.toSqlWildcardString(sc.getStatement().getValue().toString(), false).
                replaceAll("\\\\_", "_");
        SpecialAttr specialAttrValue = SpecialAttr.fromString(value);

        AttributeCond attributeCond = createAttributeCond(name);
        attributeCond.setExpression(value);

        SearchCond leaf;
        switch (sc.getConditionType()) {
            case EQUALS:
            case NOT_EQUALS:
                if (specialAttrName == null) {
                    if (specialAttrValue != null && specialAttrValue == SpecialAttr.NULL) {
                        attributeCond.setType(AttributeCond.Type.ISNULL);
                        attributeCond.setExpression(null);
                    } else if (value.indexOf('%') == -1) {
                        attributeCond.setType(AttributeCond.Type.EQ);
                    } else {
                        attributeCond.setType(AttributeCond.Type.LIKE);
                    }

                    leaf = SearchCond.getLeafCond(attributeCond);
                } else {
                    switch (specialAttrName) {
                        case ROLES:
                            MembershipCond membershipCond = new MembershipCond();
                            membershipCond.setRoleId(Long.valueOf(value));
                            leaf = SearchCond.getLeafCond(membershipCond);
                            break;

                        case RESOURCES:
                            ResourceCond resourceCond = new ResourceCond();
                            resourceCond.setResourceName(value);
                            leaf = SearchCond.getLeafCond(resourceCond);
                            break;

                        case ENTITLEMENTS:
                            EntitlementCond entitlementCond = new EntitlementCond();
                            entitlementCond.setExpression(value);
                            leaf = SearchCond.getLeafCond(entitlementCond);
                            break;

                        default:
                            throw new IllegalArgumentException(
                                    String.format("Special attr name %s is not supported", specialAttrName));
                    }
                }
                if (sc.getConditionType() == ConditionType.NOT_EQUALS) {
                    if (leaf.getAttributeCond() != null
                            && leaf.getAttributeCond().getType() == AttributeCond.Type.ISNULL) {

                        leaf.getAttributeCond().setType(AttributeCond.Type.ISNOTNULL);
                    } else if (leaf.getSubjectCond() != null
                            && leaf.getSubjectCond().getType() == SubjectCond.Type.ISNULL) {

                        leaf.getSubjectCond().setType(AttributeCond.Type.ISNOTNULL);
                    } else {
                        leaf = SearchCond.getNotLeafCond(leaf);
                    }
                }
                break;

            case GREATER_OR_EQUALS:
                attributeCond.setType(AttributeCond.Type.GE);
                leaf = SearchCond.getLeafCond(attributeCond);
                break;

            case GREATER_THAN:
                attributeCond.setType(AttributeCond.Type.GT);
                leaf = SearchCond.getLeafCond(attributeCond);
                break;

            case LESS_OR_EQUALS:
                attributeCond.setType(AttributeCond.Type.LE);
                leaf = SearchCond.getLeafCond(attributeCond);
                break;

            case LESS_THAN:
                attributeCond.setType(AttributeCond.Type.LT);
                leaf = SearchCond.getLeafCond(attributeCond);
                break;

            default:
                throw new IllegalArgumentException(
View Full Code Here

public class TestSyncRule implements SyncCorrelationRule {

    @Override
    public SearchCond getSearchCond(ConnectorObject connObj) {
        AttributeCond cond = new AttributeCond();
        cond.setSchema("email");
        cond.setType(AttributeCond.Type.EQ);
        cond.setExpression(connObj.getName().getNameValue());

        return SearchCond.getLeafCond(cond);
    }
View Full Code Here

TOP

Related Classes of org.apache.syncope.core.persistence.dao.search.AttributeCond

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.