Examples of AbstractSchema


Examples of net.hydromatic.optiq.impl.AbstractSchema

    if (schemaList.contains("lingual")) {
      rootSchema.add("SALES",
          new ReflectiveSchema(new JdbcTest.LingualSchema()));
    }
    if (schemaList.contains("post")) {
      final SchemaPlus post = rootSchema.add("POST", new AbstractSchema());
      post.add("EMP",
          ViewTable.viewMacro(
              post,
              "select * from (values\n"
              + "    ('Jane', 10, 'F'),\n"
View Full Code Here

Examples of net.hydromatic.optiq.impl.AbstractSchema

          new ReflectiveSchema(new JdbcTest.HrSchema()));
    case LINGUAL:
      return rootSchema.add("SALES",
          new ReflectiveSchema(new JdbcTest.LingualSchema()));
    case POST:
      final SchemaPlus post = rootSchema.add("POST", new AbstractSchema());
      post.add("EMP",
          ViewTable.viewMacro(post,
              "select * from (values\n"
              + "    ('Jane', 10, 'F'),\n"
              + "    ('Bob', 10, 'M'),\n"
View Full Code Here

Examples of org.apache.drill.exec.store.AbstractSchema

    return true;
  }

  protected boolean shouldVisitSchema(SchemaPlus schema) {
    try {
      AbstractSchema drillSchema = schema.unwrap(AbstractSchema.class);
      return drillSchema.showInInformationSchema();
    } catch(ClassCastException e) {
      // ignore and return true as this is not a drill schema
    }
    return true;
  }
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.AbstractSchema

        return entityManager.merge(schema);
    }

    @Override
    public void delete(final String name, final AttributableUtil attributableUtil) {
        AbstractSchema schema = find(name, attributableUtil.schemaClass());
        if (schema == null) {
            return;
        }

        List<? extends AbstractAttr> attributes = getAttributes(schema, attributableUtil.attrClass());
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.AbstractSchema

        switch (accountIdItem.getIntMappingType()) {
            case UserSchema:
            case RoleSchema:
                final AbstractAttrValue value = attrUtil.newAttrValue();

                AbstractSchema schema = schemaDAO.find(accountIdItem.getIntAttrName(), attrUtil.schemaClass());
                if (schema == null) {
                    value.setStringValue(uid);
                } else {
                    try {
                        value.parseValue(schema, uid);
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.AbstractSchema

    }

    private String getQuery(final AttributeCond cond, final boolean not, final List<Object> parameters,
            final AttributableUtil attrUtil) {

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

        AbstractAttrValue attrValue = attrUtil.newAttrValue();
        try {
            if (cond.getType() != AttributeCond.Type.LIKE && cond.getType() != AttributeCond.Type.ISNULL
                    && cond.getType() != AttributeCond.Type.ISNOTNULL) {

                schema.getValidator().validate(cond.getExpression(), attrValue);
            }
        } catch (ValidationException e) {
            LOG.error("Could not validate expression '" + cond.getExpression() + "'", e);
            return EMPTY_ATTR_QUERY;
        }

        StringBuilder query = new StringBuilder("SELECT DISTINCT subject_id FROM ").
                append(attrUtil.searchView()).append("_attr WHERE ").append("schema_name='").append(schema.getName());
        fillAttributeQuery(query, attrValue, schema, cond, not, parameters);

        return query.toString();
    }
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.AbstractSchema

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

        AbstractSchema schema = attrUtil.newSchema();
        schema.setName(attributableField.getName());
        for (AttributeSchemaType type : AttributeSchemaType.values()) {
            if (attributableField.getType().isAssignableFrom(type.getType())) {
                schema.setType(type);
            }
        }

        // Deal with Attributable Integer fields logically mapping to boolean values
        // (SyncopeRole.inheritAttributes, for example)
        boolean foundBooleanMin = false;
        boolean foundBooleanMax = false;
        if (Integer.class.equals(attributableField.getType())) {
            for (Annotation annotation : attributableField.getAnnotations()) {
                if (Min.class.equals(annotation.annotationType())) {
                    foundBooleanMin = ((Min) annotation).value() == 0;
                } else if (Max.class.equals(annotation.annotationType())) {
                    foundBooleanMax = ((Max) annotation).value() == 1;
                }
            }
        }
        if (foundBooleanMin && foundBooleanMax) {
            if ("true".equalsIgnoreCase(cond.getExpression())) {
                cond.setExpression("1");
                schema.setType(AttributeSchemaType.Long);
            } else if ("false".equalsIgnoreCase(cond.getExpression())) {
                cond.setExpression("0");
                schema.setType(AttributeSchemaType.Long);
            }
        }

        // Deal with Attributable fields representing relationships to other entities
        // Only _id and _name are suppored
        if (attributableField.getType().getAnnotation(Entity.class) != null) {
            if (BeanUtils.findDeclaredMethodWithMinimalParameters(attributableField.getType(), "getId") != null) {
                cond.setSchema(cond.getSchema() + "_id");
                schema.setType(AttributeSchemaType.Long);
            }
            if (BeanUtils.findDeclaredMethodWithMinimalParameters(attributableField.getType(), "getName") != null) {
                cond.setSchema(cond.getSchema() + "_name");
                schema.setType(AttributeSchemaType.String);
            }
        }

        AbstractAttrValue attrValue = attrUtil.newAttrValue();
        try {
            if (cond.getType() != AttributeCond.Type.LIKE && cond.getType() != AttributeCond.Type.ISNULL
                    && cond.getType() != AttributeCond.Type.ISNOTNULL) {

                schema.getValidator().validate(cond.getExpression(), attrValue);
            }
        } catch (ValidationException e) {
            LOG.error("Could not validate expression '" + cond.getExpression() + "'", e);
            return EMPTY_ATTR_QUERY;
        }
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.AbstractSchema

        switch (accountIdItem.getIntMappingType()) {
            case UserSchema:
            case RoleSchema:
                final AbstractAttrValue value = attrUtil.newAttrValue();

                AbstractSchema schema = schemaDAO.find(accountIdItem.getIntAttrName(), attrUtil.schemaClass());
                if (schema == null) {
                    value.setStringValue(uid);
                } else {
                    try {
                        value.parseValue(schema, uid);
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.AbstractSchema

        }

        final List<AbstractAttrValue> values = MappingUtil.getIntValues(resource, mapItem, attributables,
                vAttrsToBeRemoved, vAttrsToBeUpdated);

        AbstractSchema schema = null;
        AttributeSchemaType schemaType;
        switch (mapItem.getIntMappingType()) {
            case UserSchema:
            case RoleSchema:
            case MembershipSchema:
                final ConfigurableApplicationContext context = ApplicationContextProvider.getApplicationContext();
                final SchemaDAO schemaDAO = context.getBean(SchemaDAO.class);
                schema = schemaDAO.find(mapItem.getIntAttrName(),
                        MappingUtil.getIntMappingTypeClass(mapItem.getIntMappingType()));
                schemaType = schema == null ? AttributeSchemaType.String : schema.getType();
                break;

            default:
                schemaType = AttributeSchemaType.String;
        }

        final String extAttrName = mapItem.getExtAttrName();

        LOG.debug("Define mapping for: "
                + "\n* ExtAttrName " + extAttrName
                + "\n* is accountId " + mapItem.isAccountid()
                + "\n* is password " + (mapItem.isPassword() || mapItem.getIntMappingType() == IntMappingType.Password)
                + "\n* mandatory condition " + mapItem.getMandatoryCondition()
                + "\n* Schema " + mapItem.getIntAttrName()
                + "\n* IntMappingType " + mapItem.getIntMappingType().toString()
                + "\n* ClassType " + schemaType.getType().getName()
                + "\n* Values " + values);

        List<Object> objValues = new ArrayList<Object>();

        for (AbstractAttrValue value : values) {
            if (FrameworkUtil.isSupportedAttributeType(schemaType.getType())) {
                objValues.add(value.getValue());
            } else {
                objValues.add(value.getValueAsString());
            }
        }

        Map.Entry<String, Attribute> result;

        if (mapItem.isAccountid()) {
            result = new AbstractMap.SimpleEntry<String, Attribute>(objValues.iterator().next().toString(), null);
        } else if (mapItem.isPassword() && subject instanceof SyncopeUser) {
            String passwordAttrValue = password;
            if (StringUtils.isBlank(passwordAttrValue)) {
                SyncopeUser user = (SyncopeUser) subject;
                if (user.canDecodePassword()) {
                    try {
                        passwordAttrValue = PasswordEncoder.decode(user.getPassword(), user.getCipherAlgorithm());
                    } catch (Exception e) {
                        LOG.error("Could not decode password for {}", user, e);
                    }
                } else if (resource.isRandomPwdIfNotProvided()) {
                    try {
                        passwordAttrValue = passwordGenerator.generate(user);
                    } catch (InvalidPasswordPolicySpecException e) {
                        LOG.error("Could not generate policy-compliant random password for {}", user, e);

                        passwordAttrValue = RandomStringUtils.randomAlphanumeric(16);
                    }
                }
            }

            result = new AbstractMap.SimpleEntry<String, Attribute>(null,
                    AttributeBuilder.buildPassword(passwordAttrValue.toCharArray()));
        } else {
            if (schema != null && schema.isMultivalue()) {
                result = new AbstractMap.SimpleEntry<String, Attribute>(null, AttributeBuilder.build(extAttrName,
                        objValues));
            } else {
                result = new AbstractMap.SimpleEntry<String, Attribute>(null, objValues.isEmpty()
                        ? AttributeBuilder.build(extAttrName)
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.AbstractSchema

                context.disableDefaultConstraintViolation();
                context.buildConstraintViolationWithTemplate(EntityViolationType.MoreThanOneNonNull.toString())
                        .addNode(object.toString().replaceAll("\\n", " ")).addConstraintViolation();
            } else if (object instanceof AbstractAttrUniqueValue) {
                AbstractSchema uniqueValueSchema = ((AbstractAttrUniqueValue) object).getSchema();
                AbstractSchema attrSchema = object.getAttribute().getSchema();

                isValid = uniqueValueSchema.equals(attrSchema);

                if (!isValid) {
                    LOG.error("Unique value schema for " + object.getClass().getSimpleName() + "[" + object.getId()
                            + "]" + " is " + uniqueValueSchema + ", while owning " + "attribute schema is "
                            + attrSchema);

                    context.disableDefaultConstraintViolation();
                    context.buildConstraintViolationWithTemplate(
                            EntityViolationType.valueOf("Invalid" + attrSchema.getClass().getSimpleName()).toString())
                            .addNode(
                                    object.getClass().getSimpleName() + "[" + object.getId() + "].schema="
                                            + uniqueValueSchema + " != " + attrSchema).addConstraintViolation();
                }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.