Package com.jengine.orm.model.field

Examples of com.jengine.orm.model.field.Field


    protected Object processItem(Iterator itr, MultiModelItem item) throws DBException {
        LinkedHashMap<String, Object> values = new LinkedHashMap<String, Object>();
        for (MultiModelField field : item.getFieldList()) {
            values.put(field.getModelField().getFieldName(), field.cast(itr.next()));
        }
        Field pk = item.getPrimaryKey().getModelField();
        if (values.containsKey(pk.getFieldName()) && values.get(pk.getFieldName()) != null) {
            Model obj = item.getModelClass().newInstance();
            obj.setNew(false);
            obj.setData(values);
            obj.cache();
View Full Code Here


        }
        for (OrderItem orderItem : orderList) {
            orderItem.setSQL(query);
        }
        for (String fieldName : values.keySet()) {
            Field field = manager.getField(fieldName);
            query.addValue(field.getColumnName(), values.get(fieldName));
        }
        if (page.get("start") != null && page.get("end") != null) {
            query.setStart(page.get("start"));
            query.setEnd(page.get("end"));
            query.addParam(page.get("start"));
View Full Code Here

    }

    public Object cast(Object value) throws DBException {
        List result = new ArrayList();
        List values = value instanceof List ? (List) value : Arrays.asList(value);
        Field field = getReverseField().getKeyField();

        for (Object item : values) {
            result.add(item instanceof Model ?
                    ((Model) item).getValue(field) : new Variant(item).convertTo(field.getFieldClass()));
        }

        return result;
    }
View Full Code Here

        return Type.MANY_REFERENCE;
    }

    public Object getValue(Model obj) throws DBException {
        ModelClassBase middleCls = getMiddleClass();
        Field middleField = getMiddleField();
        Object keyValue = obj.getData().get(getKeyFieldName());
        return middleCls.filter(middleField.eq(keyValue)).target(middleField);
    }
View Full Code Here

        if (!values.containsKey(fieldName) || values.get(fieldName) == null) {
            return;
        }
        List keys = (List) values.get(fieldName);
        ModelClassBase middleModelClass = getMiddleClass();
        Field middleModelField = getMiddleField();
        Field middleModelReferenceField = getReverseField().getMiddleField();
        for (Object key : keys) {
            Model middleObj = middleModelClass.newInstance();
            middleObj.setValue(middleModelField, values.get(getKeyFieldName()));
            middleObj.setValue(middleModelReferenceField, key);
            middleObj.save();
View Full Code Here

        }
    }

    public void remove(Model obj) throws DBException {
        ModelClassBase middleModelClass = getMiddleClass();
        Field middleModelField = getMiddleField();
        middleModelClass.filter(middleModelField.eq(obj.getValue(getKeyFieldName()))).remove();
    }
View Full Code Here

        Object key = obj.getData().get(fieldName);
        return key != null ? getReferenceClass().filter(getReferenceModelKey().eq(key)).one() : null;
    }

    public Object cast(Object value) throws DBException {
        Field field = getReferenceModelKey();
        return value instanceof Model ? ((Model) value).getValue(field) : new Variant(value).convertTo(field.getFieldClass());
    }
View Full Code Here

    public void scanEntity(Class entryModelClass, Set exclude) {
        try {
            LinkedHashMap<String, Class> properties = ClassUtils.reflectBeanInterface(entryModelClass);
            for(String propertyName : properties.keySet()) {
                if (!exclude.contains(propertyName) && !getManager().getFieldMap().containsKey(propertyName)) {
                    Field field = mapFieldType(properties.get(propertyName));
                    if (field != null) {
                        field.setVerbose(caps(propertyName));
                        getManager().addField(propertyName, field);
                    } else {
                        log.debug("fieldName type mapping not found: " + propertyName);
                    }
                }
View Full Code Here

            e.printStackTrace();
        }
    }

    protected Field mapFieldType(Class entityClass) {
        Field field = null;

        if (entityClass.equals(String.class)) {
            field = new StringField();
        } else if (entityClass.equals(Integer.class) || entityClass.equals(int.class)) {
            field = new IntegerField();
View Full Code Here

        for (Field field : modelClass.getManager().getFields()) {
            if (field instanceof BaseReference) {
                BaseReference reference = (BaseReference) field;
                String reverseFieldName = reference.getReverseFieldName();
                if (reverseFieldName != null) {
                    Field reverseField = reference.newReverseField();
                    ModelClassBase referenceModelClass = reference.getReferenceClass();
                    if (referenceModelClass != null &&
                            !referenceModelClass.getManager().getFieldMap().containsValue(reverseFieldName)) {
                        referenceModelClass.getManager().addField(reverseFieldName, reverseField);
                    } else {
View Full Code Here

TOP

Related Classes of com.jengine.orm.model.field.Field

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.