Package org.apache.syncope.core.persistence.beans.user

Examples of org.apache.syncope.core.persistence.beans.user.UAttrValue


    public <T extends AbstractAttrValue> T newAttributeValue() {
        T result = null;

        switch (type) {
            case USER:
                result = (T) new UAttrValue();
                break;
            case ROLE:
                result = (T) new RAttrValue();
                break;
            case MEMBERSHIP:
View Full Code Here


        assertNull(attrValueDAO.find(22L, UAttrValue.class));
    }

    @Test
    public void deleteAttributeValue() {
        UAttrValue value = attrValueDAO.find(20L, UAttrValue.class);
        int attributeValueNumber = value.getAttribute().getValues().size();

        attrValueDAO.delete(20L, UAttrValue.class);

        attrValueDAO.flush();
View Full Code Here

        UDerAttr actual = derAttrDAO.find(derivedAttribute.getId(), UDerAttr.class);
        assertNotNull("expected save to work", actual);
        assertEquals(derivedAttribute, actual);

        UAttrValue firstnameAttribute = (UAttrValue) owner.getAttribute("firstname").getValues().iterator().next();
        UAttrValue surnameAttribute = (UAttrValue) owner.getAttribute("surname").getValues().iterator().next();

        assertEquals(surnameAttribute.getValue() + ", " + firstnameAttribute.getValue(), derivedAttribute
                .getValue(owner.getAttributes()));
    }
View Full Code Here

        if (schema == null) {
            LOG.warn("Ignoring invalid schema '{}'", cond.getSchema());
            return EMPTY_ATTR_QUERY;
        }

        UAttrValue attrValue = new UAttrValue();
        try {
            if (cond.getType() != AttributeCond.Type.LIKE && cond.getType() != AttributeCond.Type.ISNULL
                    && cond.getType() != AttributeCond.Type.ISNOTNULL) {

                schema.getValidator().validate(cond.getExpression(), attrValue);
View Full Code Here

                schema.setType(type);
            }
        }

        UAttrValue attrValue = new UAttrValue();
        try {
            if (cond.getType() != AttributeCond.Type.LIKE && cond.getType() != AttributeCond.Type.ISNULL
                    && cond.getType() != AttributeCond.Type.ISNOTNULL) {

                schema.getValidator().validate(cond.getExpression(), attrValue);
View Full Code Here

        userDAO.findByDerAttrValue("noschema", "Antonio, Maria");
    }

    @Test
    public void findByAttributeValue() {
        final UAttrValue fullnameValue = new UAttrValue();
        fullnameValue.setStringValue("chicchiricco");

        final List<SyncopeUser> list = userDAO.findByAttrValue("fullname", fullnameValue);
        assertEquals("did not get expected number of users ", 1, list.size());
    }
View Full Code Here

        assertEquals("did not get expected number of users ", 1, list.size());
    }

    @Test
    public void findByAttributeBooleanValue() {
        final UAttrValue coolValue = new UAttrValue();
        coolValue.setBooleanValue(true);

        final List<SyncopeUser> list = userDAO.findByAttrValue("cool", coolValue);
        assertEquals("did not get expected number of users ", 1, list.size());
    }
View Full Code Here

                                        + mappingItem.getIntAttrName() + "'");
                            }
                        }
                        if (virAttr.getValues() != null) {
                            for (String value : virAttr.getValues()) {
                                attrValue = new UAttrValue();
                                attrValue.setStringValue(value);
                                values.add(attrValue);
                            }
                        }
                    }

                    LOG.debug("Retrieved {} virtual attribute {}"
                            + "\n* IntAttrName {}"
                            + "\n* IntMappingType {}"
                            + "\n* Attribute values {}",
                            attributable.getClass().getSimpleName(),
                            virAttr, mappingItem.getIntAttrName(), mappingItem.getIntMappingType(), values);
                }
                break;

            case MembershipVirtualSchema:
                for (AbstractAttributable attributable : attributables) {
                    AbstractVirAttr virAttr = attributable.getVirAttr(mappingItem.getIntAttrName());
                    if (virAttr != null) {
                        if (membVAttrsToBeRemoved != null && membVAttrsToBeUpdated != null) {
                            if (membVAttrsToBeUpdated.containsKey(mappingItem.getIntAttrName())) {
                                virAttr.setValues(
                                        membVAttrsToBeUpdated.get(mappingItem.getIntAttrName()).getValuesToBeAdded());
                            } else if (membVAttrsToBeRemoved.contains(mappingItem.getIntAttrName())) {
                                virAttr.getValues().clear();
                            } else {
                                throw new IllegalArgumentException("Don't need to update membership virtual attribute '"
                                        + mappingItem.getIntAttrName() + "'");
                            }
                        }
                        if (virAttr.getValues() != null) {
                            for (String value : virAttr.getValues()) {
                                attrValue = new UAttrValue();
                                attrValue.setStringValue(value);
                                values.add(attrValue);
                            }
                        }
                    }

                    LOG.debug("Retrieved {} virtual attribute {}"
                            + "\n* IntAttrName {}"
                            + "\n* IntMappingType {}"
                            + "\n* Attribute values {}",
                            attributable.getClass().getSimpleName(),
                            virAttr, mappingItem.getIntAttrName(), mappingItem.getIntMappingType(), values);
                }
                break;

            case UserDerivedSchema:
            case RoleDerivedSchema:
            case MembershipDerivedSchema:
                for (AbstractAttributable attributable : attributables) {
                    AbstractDerAttr derAttr = attributable.getDerAttr(mappingItem.getIntAttrName());
                    if (derAttr != null) {
                        attrValue = (attributable instanceof SyncopeRole)
                                ? new RAttrValue() : new UAttrValue();
                        attrValue.setStringValue(derAttr.getValue(attributable.getAttrs()));
                        values.add(attrValue);
                    }

                    LOG.debug("Retrieved attribute {}"
                            + "\n* IntAttrName {}"
                            + "\n* IntMappingType {}"
                            + "\n* Attribute values {}",
                            derAttr, mappingItem.getIntAttrName(), mappingItem.getIntMappingType(), values);
                }
                break;

            case UserId:
            case RoleId:
            case MembershipId:
                for (AbstractAttributable attributable : attributables) {
                    attrValue = new UAttrValue();
                    attrValue.setStringValue(attributable.getId().toString());
                    values.add(attrValue);
                }
                break;

            case Username:
                for (AbstractAttributable attributable : attributables) {
                    if (attributable instanceof SyncopeUser) {
                        attrValue = new UAttrValue();
                        attrValue.setStringValue(((SyncopeUser) attributable).getUsername());
                        values.add(attrValue);
                    }
                }
                break;
View Full Code Here

        assertNull(attrValueDAO.find(28L, UAttrValue.class));
    }

    @Test
    public void deleteAttributeValue() {
        UAttrValue value = attrValueDAO.find(14L, UAttrValue.class);
        int attributeValueNumber = value.getAttribute().getValues().size();

        attrValueDAO.delete(value.getId(), UAttrValue.class);

        attrValueDAO.flush();

        assertNull(attrValueDAO.find(value.getId(), UAttrValue.class));

        UAttr attribute = attrDAO.find(104L, UAttr.class);
        assertEquals(attribute.getValues().size(), attributeValueNumber - 1);
    }
View Full Code Here

        UDerAttr actual = derAttrDAO.find(derivedAttribute.getId(), UDerAttr.class);
        assertNotNull("expected save to work", actual);
        assertEquals(derivedAttribute, actual);

        UAttrValue firstnameAttribute = (UAttrValue) owner.getAttr("firstname").getValues().iterator().next();
        UAttrValue surnameAttribute = (UAttrValue) owner.getAttr("surname").getValues().iterator().next();

        assertEquals(surnameAttribute.getValue() + ", " + firstnameAttribute.getValue(), derivedAttribute
                .getValue(owner.getAttrs()));
    }
View Full Code Here

TOP

Related Classes of org.apache.syncope.core.persistence.beans.user.UAttrValue

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.