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

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


        assertEquals(4, roleList.size());
    }

    @Test
    public void findByName() {
        USchema attributeSchema = schemaDAO.find("fullname", USchema.class);
        assertNotNull("did not find expected attribute schema", attributeSchema);
    }
View Full Code Here


        }
    }

    @Test
    public void save() {
        USchema attributeSchema = new USchema();
        attributeSchema.setName("secondaryEmail");
        attributeSchema.setType(SchemaType.String);
        attributeSchema.setValidatorClass("org.apache.syncope.core.validation.EmailAddressValidator");
        attributeSchema.setMandatoryCondition("false");
        attributeSchema.setMultivalue(true);

        schemaDAO.save(attributeSchema);

        USchema actual = schemaDAO.find("secondaryEmail", USchema.class);
        assertNotNull("expected save to work", actual);
        assertEquals(attributeSchema, actual);
    }
View Full Code Here

        assertEquals(attributeSchema, actual);
    }

    @Test(expected = InvalidEntityException.class)
    public void saveNonValid() {
        USchema attributeSchema = new USchema();
        attributeSchema.setName("secondaryEmail");
        attributeSchema.setType(SchemaType.String);
        attributeSchema.setValidatorClass("org.apache.syncope.core.validation.EmailAddressValidator");
        attributeSchema.setMandatoryCondition("false");
        attributeSchema.setMultivalue(true);
        attributeSchema.setUniqueConstraint(true);

        schemaDAO.save(attributeSchema);
    }
View Full Code Here

        assertFalse(actual.getEnumerationKeys().isEmpty());
    }

    @Test(expected = InvalidEntityException.class)
    public void saveInvalidSchema() {
        USchema schema = new USchema();
        schema.setName("username");
        schemaDAO.save(schema);
    }
View Full Code Here

        schemaDAO.save(schema);
    }

    @Test
    public void delete() {
        USchema schema = schemaDAO.find("fullname", USchema.class);

        schemaDAO.delete(schema.getName(), AttributableUtil.getInstance(AttributableType.USER));

        USchema actual = schemaDAO.find("fullname", USchema.class);
        assertNull("delete did not work", actual);
    }
View Full Code Here

    }

    @Override
    public List<SyncopeUser> findByAttrValue(final String schemaName, final UAttrValue attrValue) {

        USchema schema = schemaDAO.find(schemaName, USchema.class);
        if (schema == null) {
            LOG.error("Invalid schema name '{}'", schemaName);
            return Collections.EMPTY_LIST;
        }

        final String entityName = schema.isUniqueConstraint()
                ? UAttrUniqueValue.class.getName()
                : UAttrValue.class.getName();

        Query query = entityManager.createQuery("SELECT e FROM " + entityName + " e"
                + " WHERE e.attribute.schema.name = :schemaName " + " AND (e.stringValue IS NOT NULL"
View Full Code Here

    }

    @Override
    public SyncopeUser findByAttrUniqueValue(final String schemaName, final UAttrValue attrUniqueValue) {

        USchema schema = schemaDAO.find(schemaName, USchema.class);
        if (schema == null) {
            LOG.error("Invalid schema name '{}'", schemaName);
            return null;
        }
        if (!schema.isUniqueConstraint()) {
            LOG.error("This schema has not unique constraint: '{}'", schemaName);
            return null;
        }

        List<SyncopeUser> result = findByAttrValue(schemaName, attrUniqueValue);
View Full Code Here

        final StringBuilder bld = new StringBuilder();

        // Contains used identifiers in order to avoid replications
        final Set<String> used = new HashSet<String>();

        USchema schema;

        // Create several clauses: one for eanch identifiers
        for (int i = 0; i < identifiers.size(); i++) {
            if (!used.contains(identifiers.get(i))) {

                // verify schema existence and get schema type
                schema = schemaDAO.find(identifiers.get(i), USchema.class);
                if (schema == null) {
                    LOG.error("Invalid schema name '{}'", identifiers.get(i));
                    throw new InvalidSearchConditionException("Invalid schema name " + identifiers.get(i));
                }

                // clear builder
                bld.delete(0, bld.length());

                bld.append("(");

                // set schema name
                bld.append("s.name = '").append(identifiers.get(i)).append("'");

                bld.append(" AND ");

                bld.append("s.name = a.schema_name").append(" AND ");

                bld.append("a.id = v.attribute_id");

                bld.append(" AND ");

                // use a value clause different for eanch different schema type
                switch (schema.getType()) {
                    case Boolean:
                        bld.append("v.booleanValue = '").append(attrValues.get(i)).append("'");
                        break;
                    case Long:
                        bld.append("v.longValue = ").append(attrValues.get(i));
View Full Code Here

    @Test
    public void save() throws ClassNotFoundException {

        SyncopeUser user = userDAO.find(1L);

        USchema emailSchema = userSchemaDAO.find("email", USchema.class);
        assertNotNull(emailSchema);

        UAttr attribute = new UAttr();
        attribute.setSchema(emailSchema);
        attribute.setOwner(user);
View Full Code Here

    @Test
    public void checkForEnumType() throws ClassNotFoundException {

        SyncopeUser user = userDAO.find(1L);

        USchema gender = userSchemaDAO.find("gender", USchema.class);
        assertNotNull(gender);
        assertNotNull(gender.getType());
        assertNotNull(gender.getEnumerationValues());

        UAttr attribute = new UAttr();
        attribute.setSchema(gender);
        attribute.setOwner(user);
        user.addAttribute(attribute);
View Full Code Here

TOP

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

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.