Examples of PersistentAttribute


Examples of org.paquitosoft.lml.model.annotation.PersistentAttribute

        try {

            // We first need to find the attribute in the related entity representing the main entity in this action
            List<Field> fields = ModelUtilities.getAllPersistentEntityFields(relatedEntity.getClass());
            for (Field f : fields) {
                PersistentAttribute a = f.getAnnotation(PersistentAttribute.class);
                if (a != null && columnName.equalsIgnoreCase(a.columnName())) {
                    f.setAccessible(true);

                    if (f.getClass().getAnnotation(PersistentEntity.class) != null) {
                        List<Field> pkFields = ModelUtilities.getEntityIdentifierFields(f.getClass());
                        if (pkFields.size() == 1) {
View Full Code Here

Examples of org.paquitosoft.lml.model.annotation.PersistentAttribute

            ArrayList<Field> fields = getAllPersistentEntityFields(entityType);

            for (Field f : fields) {
                f.setAccessible(true); // VERY IMPORTANT!!!
                PersistentAttribute annot = f.getAnnotation(PersistentAttribute.class);
                // If this field is not annotated we must ignore it
                if (annot == null) {
                    continue;
                }
                String columnName = getColumnName(f);
                boolean readField = true;
                if (annot.entity()) {

                    // If it is a custom type we need to create a instance an populate its identifier
                    List<Field> pkFields = getEntityIdentifierFields(f.getType());               
                    if (pkFields.size() == 1) {
View Full Code Here

Examples of org.paquitosoft.lml.model.annotation.PersistentAttribute

   
        List<Field> result = new ArrayList<Field>();
       
        Field[] fs = entityClass.getDeclaredFields();
        for (int i = 0; i < fs.length; i++) {
            PersistentAttribute fieldAT = fs[i].getAnnotation(PersistentAttribute.class);           
            if (fieldAT != null && fieldAT.primaryKey()) {
                result.add(fs[i]);
            }
        }
       
        // Sort fileds by name
View Full Code Here

Examples of org.paquitosoft.lml.model.annotation.PersistentAttribute

     * @return column name for the field provided
     */
    public static String getColumnName(Field f) {
       
        String result = f.getName();       
        PersistentAttribute att = f.getAnnotation(PersistentAttribute.class);           
        if (att != null) {
            result = (att.columnName().length() > 0) ? att.columnName().toUpperCase(): f.getName().toUpperCase();
        }           
        return result;
    }
View Full Code Here

Examples of org.paquitosoft.lml.model.annotation.PersistentAttribute

    public static Object getFieldValue(String fieldName, Object entity) throws ReflectionException {
       
        Object result = null;
       
        for (Field f : getAllPersistentEntityFields(entity.getClass())) {
            PersistentAttribute antt = f.getAnnotation(PersistentAttribute.class);           
            if ((antt.columnName().length() > 0 && fieldName.equalsIgnoreCase(antt.columnName())) ||
                    fieldName.equalsIgnoreCase(f.getName())){
                try {
                    f.setAccessible(true);
                    if (antt.entity()) {
                        result = getEntityIdentifier(f.get(entity))// TODO Does it worth it to check the identifier here?
                    } else {
                        result = f.get(entity);
                    }                   
                    break;
View Full Code Here

Examples of org.paquitosoft.lml.model.annotation.PersistentAttribute

        Object result = null;
       
        int pkCounter = 0;
        Field[] fs = entity.getClass().getDeclaredFields();
        for (int i = 0; i < fs.length; i++) {
            PersistentAttribute fieldAT = fs[i].getAnnotation(PersistentAttribute.class);           
            if (fieldAT != null && fieldAT.primaryKey()) {
                pkCounter++;
            }
        }
       
        if (pkCounter == 1) {
View Full Code Here

Examples of org.paquitosoft.lml.model.annotation.PersistentAttribute

        Class result = null;
       
        int pkCounter = 0;
        Field[] fs = entityType.getDeclaredFields();
        for (int i = 0; i < fs.length; i++) {
            PersistentAttribute fieldAT = fs[i].getAnnotation(PersistentAttribute.class);           
            if (fieldAT != null && fieldAT.primaryKey()) {
                fs[0].setAccessible(true);
                result = fs[0].getType();
                if (++pkCounter > 1) {
                    return null;
                }
View Full Code Here

Examples of org.paquitosoft.lml.model.annotation.PersistentAttribute

    public static AssociationType getAssociationType(Field persistentField, byte persistenceMode) {
   
        AssociationType result = AssociationType.NONE;
       
        if (PERSIST_MODE_DELETE == persistenceMode) {
            PersistentAttribute att = persistentField.getAnnotation(PersistentAttribute.class);
            if (att != null) {
                result = att.removeAssociationType();
            } else {
                result = persistentField.getAnnotation(AssociatedEntityList.class).removeAssociationType();
            }
        } else if (PERSIST_MODE_SAVE == persistenceMode) {
            PersistentAttribute att = persistentField.getAnnotation(PersistentAttribute.class);
            if (att != null) {
                result = att.saveAssociationType();
            } else {
                result = persistentField.getAnnotation(AssociatedEntityList.class).saveAssociationType();
            }
        } else if (PERSIST_MODE_UPDATE == persistenceMode) {
            PersistentAttribute att = persistentField.getAnnotation(PersistentAttribute.class);
            if (att != null) {
                result = att.updateAssociationType();
            } else {
                result = persistentField.getAnnotation(AssociatedEntityList.class).updateAssociationType();
            }
        }
               
View Full Code Here

Examples of org.paquitosoft.lml.model.annotation.PersistentAttribute

     * @return <b>true</b> when it represents a primary key
     */
    public static boolean isPKField(Field f) {
        boolean result = false;
        if (f != null) {
            PersistentAttribute pa = f.getAnnotation(PersistentAttribute.class);
            if (pa != null && pa.primaryKey()) {
                result = true;
            }
        }       
        return result;
    }
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.