Package org.opencustomer.framework.db.util.engine.configuration

Examples of org.opencustomer.framework.db.util.engine.configuration.Property


    public Table(TableEngine engine) {
        this.engine = engine;
   
        columns = new Column[engine.getConfiguration().getProperties().size()];
        for(int i=0; i<columns.length; i++) {
            Property property = engine.getConfiguration().getProperties().get(i);
            columns[i] = new Column(i, property.getMessageKey(), property.isSortable());
            columns[i].setFormatter(property.getFormatter());
            columns[i].setSearch(property.getSearch());
           
            order.add(columns.length-1-i, true);
        }
    }
View Full Code Here


            log.debug("create criterions ("+columns.length+")");

        dynamicRestrictions.addAll(restrictions);
       
        for(Column column : columns) {
            Property property = engine.getConfiguration().getProperties().get(column.getPosition());
           
            if(column.getSearch() instanceof TextSearch) {
                TextSearch search = (TextSearch)column.getSearch();
                if(search.getValue() != null) {
                    String critValue = search.getPattern().replace('*', '%').replaceAll("\\{search\\}", search.getValue());
                   
                    if(log.isDebugEnabled())
                        log.debug("add text criterion for "+property.getName()+": "+critValue);
                   
                    if(property.getAltName() == null) {
                        dynamicRestrictions.add(new Restriction("lower("+property.getName()+") like lower({0})", property.isGroup(), critValue));
                    } else {
                        dynamicRestrictions.add(new Restriction("(lower("+property.getName()+") like lower({0}) or ("+property.getName()+" is null and lower("+property.getAltName()+") like lower({0})))", property.isGroup(), critValue));
                    }
                }
            } else if(column.getSearch() instanceof EnumSearch) {
                EnumSearch search = (EnumSearch)column.getSearch();

                if(search.getValue() != null) {
                    dynamicRestrictions.add(new Restriction(property.getName()+" = {0}", property.isGroup(), search.getValue()));
                }
            } else if(column.getSearch() instanceof TextSelectSearch) {
                TextSelectSearch search = (TextSelectSearch)column.getSearch();
               
                if(search.isHql()) {
                    TextSelectSearch.Bean bean = search.getBeans().get(search.getValue());
                    if(bean.getHql() != null)
                        dynamicRestrictions.add(new Restriction(bean.getHql(), property.isGroup()));
                } else {
                    if(search.getValue() != null) {
                        dynamicRestrictions.add(new Restriction(property.getName()+" = {0}", property.isGroup(), search.getValue()));
                    }
                }
            } else if(column.getSearch() instanceof ListSelectSearch) {
                ListSelectSearch search = (ListSelectSearch)column.getSearch();
               
                if(search.getValue() != null)
                    dynamicRestrictions.add(new Restriction(search.getSearchProperty()+" = {0}", property.isGroup(), search.getValue()));
            } else if(column.getSearch() instanceof DateSearch) {
                DateSearch search = (DateSearch)column.getSearch();
               
                Date start = search.getValueStart();
                Date end   = search.getValueEnd();
                if(end != null) {
                    Calendar cal = GregorianCalendar.getInstance();
                    cal.setTime(end);
                    cal.add(Calendar.DAY_OF_MONTH, 1);
                    cal.add(Calendar.SECOND, -1);
                    end = cal.getTime();
                }
               
                if(start != null && end != null) {
                    dynamicRestrictions.add(new Restriction(property.getName()+" between {0} and {1}", property.isGroup(), start, end));
                } else if(start != null) {
                    dynamicRestrictions.add(new Restriction(property.getName()+" >= {0}", property.isGroup(), start));
                } else if(end != null) {
                    dynamicRestrictions.add(new Restriction(property.getName()+" <= {0}", property.isGroup(), end));
                }
            }
        }
       
        if(dynamicRestrictions.isEmpty()) {
View Full Code Here

                        } else if("join".equals(nodes.item(i).getNodeName())) {
                            conf.getJoins().add(parseJoin(nodes.item(i)));                           
                        } else if("restriction".equals(nodes.item(i).getNodeName())) {
                            conf.getRestrictions().add(parseRestriction(nodes.item(i)));                           
                        } else if("property".equals(nodes.item(i).getNodeName())) {
                            Property property = parseProperty(conf, nodes.item(i));
                            if(property.isId()) {
                                if(conf.getId() == null) {
                                    conf.setId(property);
                                } else {
                                    throw new TableEngineException("found duplicate id property");
                                }
                            }
                            property.setAlias("alias_"+conf.getProperties().size());
                            property.setPosition(conf.getProperties().size());
                            conf.getProperties().add(property);                           
                        }
                    }
                }
               
View Full Code Here

       
        return join;
    }
   
    private Property parseProperty(Configuration configuration, Node node) throws TableEngineException {
        Property property = new Property();
       
        NamedNodeMap attributes = node.getAttributes();
        for(int i=0; i<attributes.getLength(); i++) {
            Node attributeNode = attributes.item(i);
            if(attributeNode.getNodeType() == Node.ATTRIBUTE_NODE) {
                String name = attributeNode.getNodeName();
                if("name".equals(name)) {
                    property.setName(attributeNode.getNodeValue());
                } else if("altName".equals(name)) {
                    property.setAltName(attributeNode.getNodeValue());
                } else if("messageKey".equals(name)) {
                    property.setMessageKey(attributeNode.getNodeValue());
                } else if("entityMessageKey".equals(name)) {
                    property.setEntityMessageKey(attributeNode.getNodeValue());
                } else if("type".equals(name)) {
                    property.setSortable(Boolean.parseBoolean(attributeNode.getNodeValue()));
                } else if("id".equals(name)) {
                    property.setId(Boolean.parseBoolean(attributeNode.getNodeValue()));
                } else if("sortable".equals(name)) {
                    property.setSortable(Boolean.parseBoolean(attributeNode.getNodeValue()));
                } else if("default".equals(name)) {
                    configuration.getDefaultProperties().put(Integer.parseInt(attributeNode.getNodeValue()), property);
                } else if("group".equals(name)) {
                    property.setGroup(Boolean.parseBoolean(attributeNode.getNodeValue()));
                }
            }
        }
       
        NodeList nodes = node.getChildNodes();
        for(int i=0; i<nodes.getLength(); i++) {
            if(nodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
                if("format".equals(nodes.item(i).getNodeName())) {
                    Formatter format = parseFormat(nodes.item(i));
                    if(format == null) {
                        format = new DefaultFormatter();
                    }
                    property.setFormatter(format);
                } else if("search".equals(nodes.item(i).getNodeName())) {
                    property.setSearch(parseSearch(nodes.item(i)));
                }

            }
        }
       
View Full Code Here

TOP

Related Classes of org.opencustomer.framework.db.util.engine.configuration.Property

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.