Subversion Repositories bacoAlunos

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1586 jmachado 1
package pt.estgp.estgweb.domain;
2
 
3
/**
4
 * Created by jorgemachado on 02/01/17.
5
 */
6
public abstract class OlapDimensionImpl extends DomainObject //implements OlapFieldContainer
7
{
8
 
9
    /*
10
    @Override
11
    public String[] getFieldsNamesArray()
12
    {
13
        List<String> fieldsNames = new ArrayList<String>();
14
        if(!canPublishFields())
15
            return new String[0];
16
        List<Method> methods = Arrays.asList(this.getClass().getMethods());
17
        methods.sort(new Comparator<Method>() {
18
            @Override
19
            public int compare(Method o1, Method o2) {
20
                return o1.getName().compareTo(o2.getName());
21
            }
22
        });
23
        for(Method method:methods)
24
        {
25
            if(method.getReturnType() != null && method.getParameters().length == 0 && method.getName().startsWith("get") || method.getName().startsWith("is"))
26
            {
27
                //is a bean getter
28
                if(!Arrays.asList(getFieldsNotAllowed()).contains(method.getName()))
29
                {
30
                    fieldsNames.add(method.getName());
31
                }
32
            }
33
        }
34
        return fieldsNames.toArray(new String[0]);
35
    }
36
 
37
    @Override
38
    public String[] getFieldsArray()
39
    {
40
        List<String> fieldsValues = new ArrayList<String>();
41
        if(!canPublishFields())
42
            return new String[0];
43
        List<Method> methods = Arrays.asList(this.getClass().getMethods());
44
        methods.sort(new Comparator<Method>() {
45
            @Override
46
            public int compare(Method o1, Method o2) {
47
                return o1.getName().compareTo(o2.getName());
48
            }
49
        });
50
        for(Method method:methods)
51
        {
52
            if(method.getReturnType() != null && method.getParameters().length == 0 && method.getName().startsWith("get") || method.getName().startsWith("is"))
53
            {
54
                //is a bean getter
55
                if(!Arrays.asList(getFieldsNotAllowed()).contains(method.getName()))
56
                {
57
                    try {
58
                        fieldsValues.add(method.invoke(this).toString());
59
                    } catch (IllegalAccessException e) {
60
                        e.printStackTrace();
61
                    } catch (InvocationTargetException e) {
62
                        e.printStackTrace();
63
                    }
64
                }
65
            }
66
        }
67
        return fieldsValues.toArray(new String[0]);
68
    }
69
 
70
    @Override
71
    public String[] getFieldsNotAllowed()
72
    {
73
        return new String[]{"getSaveDate","getUpdateDate","getId"};
74
    }
75
 
76
    @Override
77
    public boolean canPublishFields() {
78
        if(this instanceof OlapEntityQuestionarioUser)
79
        {
80
            return false;
81
        }
82
        return true;
83
    }
84
    */
85
    public abstract 1.5.0/docs/api/java/lang/String.html">String[] getFields();
86
    public abstract 1.5.0/docs/api/java/lang/String.html">String[] getFieldsValues();
87
}