Package play.db.jpa

Examples of play.db.jpa.JPABase


        try {
            if (!(object instanceof JPABase))
                return;
            if (object.getClass().getAnnotation(Indexed.class) == null)
                return;
            JPABase jpaBase = (JPABase ) object;
            String index = object.getClass().getName();
            getIndexWriter(index).deleteDocuments(new Term("_docID", ConvertionUtils.getIdValueFor(jpaBase) + ""));
            if (sync) {
                getIndexWriter(index).commit();
                dirtyReader(index);
View Full Code Here


        try {
            if (!(object instanceof JPABase)) {
                Logger.warn("Unable to index " + object + ", unsupported class type. Only play.db.jpa.JPABase classes are supported.");
                return;
            }
            JPABase jpaABase = (JPABase ) object;
            Document document = ConvertionUtils.toDocument(object);
            if (document == null)
                return;
            getIndexWriter(index).deleteDocuments(new Term("_docID", ConvertionUtils.getIdValueFor(jpaABase) + ""));
            getIndexWriter(index).addDocument(document);
View Full Code Here

        Indexed indexed = object.getClass().getAnnotation(Indexed.class);
        if (indexed == null)
            return null;
        if (!(object instanceof JPABase))
            return null;
        JPABase jpaBase = (JPABase) object;
        Document document = new Document();
        document.add(new Field("_docID", getIdValueFor(jpaBase) + "", Field.Store.YES, Field.Index.NOT_ANALYZED));
        StringBuffer allValue = new StringBuffer();
        for (java.lang.reflect.Field field : object.getClass().getFields()) {
            play.modules.search.Field index = field.getAnnotation(play.modules.search.Field.class);
            if (index == null)
                continue;
            if (field.getType().isArray())
                continue;
            if (Collection.class.isAssignableFrom(field.getType()))
                continue;

            String name = field.getName();
            String value = null;

            if (JPABase.class.isAssignableFrom(field.getType()) && !(index.joinField().length() == 0)) {
                JPABase joinObject = (JPABase ) field.get(object);
                for (java.lang.reflect.Field joinField : joinObject.getClass().getFields()) {
                    if (joinField.getName().equals(index.joinField())) {
                        name = joinField.getName();
                        value = valueOf(joinObject, joinField);
                    }
                }
View Full Code Here

TOP

Related Classes of play.db.jpa.JPABase

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.