Package org.jsf2jpa.entities

Examples of org.jsf2jpa.entities.AbstractAttribute


                    if (attrPropertyMethods != null && attrPropertyMethods.getGet() != null) {
                        try {
                            List<?> attrs = (List<?>) attrPropertyMethods.getGet().invoke(wrappedObject);
                            for (Object attr : attrs) {
                                if (attr instanceof AbstractAttribute) {
                                    AbstractAttribute a = (AbstractAttribute)attr;
                                    if (a.getName().equals(key.toString())) {
                                        ret = a;
                                        break;
                                    }
                                }
                            }
View Full Code Here


                 * If this is an attribute
                 */
                if (column.indexOf('[') != -1) {
                    try {
                        String attrName = column.substring(column.indexOf('[')+2, column.indexOf(']')-1);
                        AbstractAttribute attr = attributesClass.newInstance();
                        attr.setName(attrName);
                        attr.setStringValue((String)var);
                        addAttributeFilter(cq, builder, from, Arrays.asList(attr), NamingConstants.PARENT, preList);
                    }
                    catch (Exception ex) {
                        throw (new EJBException(ex));
                    }
                   
                    continue;
                }

                if (column.indexOf('.') != -1) {
                    /*
                     * This is not simple query because this field could become a reason for table join
                     */
                    String[] fields = column.split("\\.");
                    /*
                     * This is simple join. This filter allowed only simple joins
                     */
                    if (fields.length == 2) {
                        /*
                         * Get main attribute
                         */
                        Path attr = from.get(fields[0]);
                        /*
                         * If filterable column is id then just get desired object by it's identifier
                         */
                        if (fields[1].equals(NamingConstants.ID)) {
                            try {
                                BigInteger id = BigInteger.valueOf(NumberFormat.getInstance().parse(var.toString()).longValue());
                                Object value = getEntityManager().find(attr.getJavaType(), id);
                                preList.add(builder.equal(from.get(fields[0]), value));
                            }
                            catch (ParseException ex) {
                                Logger.getLogger(AbstractFacade.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                        else {
                            /*
                             * Create subquery to find by attribute
                             */
                            Subquery subquery = cq.subquery(attr.getJavaType());
                            Root fromAttr = subquery.from(attr.getJavaType());
                            subquery.select(fromAttr.get(NamingConstants.ID));

                            if (var instanceof String && ((String)var).contains("%")) {
                                /*
                                 * This is a like query
View Full Code Here

        for (Object a : attributesFilter) {
            if (!(a instanceof AbstractAttribute))
                continue;

            AbstractAttribute attr = (AbstractAttribute)a;
            Predicate pp = null;
            switch (attr.getDataType()) {
                case STRING:
                    pp = builder.and (
                            builder.equal(fromAttr.get(NamingConstants.NAME), attr.getName()),
                            builder.equal(
                                    fromAttr.get(NamingConstants.STRING_VALUE),
                                    attr.getStringValue())
                        );
                    break;
                   
                case NUMBER:
                    pp = builder.and (
                            builder.equal(fromAttr.get(NamingConstants.NAME), attr.getName()),
                            builder.equal(
                                    fromAttr.get(NamingConstants.NUMBER_VALUE),
                                    attr.getNumberValue())
                        );
                    break;
                   
                case DATE:
                    pp = builder.and (
                            builder.equal(fromAttr.get(NamingConstants.NAME), attr.getName()),
                            builder.equal(
                                    fromAttr.get(NamingConstants.DATE_VALUE),
                                    attr.getDateValue())
                        );
                    break;
            }
           
            if (pp == null)
View Full Code Here

TOP

Related Classes of org.jsf2jpa.entities.AbstractAttribute

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.