Subversion Repositories bacoAlunos

Rev

Blame | Last modification | View Log | RSS feed

package pt.estgp.estgweb.domain;

/**
 * Created by jorgemachado on 02/01/17.
 */

public abstract class OlapDimensionImpl extends DomainObject //implements OlapFieldContainer
{

    /*
    @Override
    public String[] getFieldsNamesArray()
    {
        List<String> fieldsNames = new ArrayList<String>();
        if(!canPublishFields())
            return new String[0];
        List<Method> methods = Arrays.asList(this.getClass().getMethods());
        methods.sort(new Comparator<Method>() {
            @Override
            public int compare(Method o1, Method o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });
        for(Method method:methods)
        {
            if(method.getReturnType() != null && method.getParameters().length == 0 && method.getName().startsWith("get") || method.getName().startsWith("is"))
            {
                //is a bean getter
                if(!Arrays.asList(getFieldsNotAllowed()).contains(method.getName()))
                {
                    fieldsNames.add(method.getName());
                }
            }
        }
        return fieldsNames.toArray(new String[0]);
    }

    @Override
    public String[] getFieldsArray()
    {
        List<String> fieldsValues = new ArrayList<String>();
        if(!canPublishFields())
            return new String[0];
        List<Method> methods = Arrays.asList(this.getClass().getMethods());
        methods.sort(new Comparator<Method>() {
            @Override
            public int compare(Method o1, Method o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });
        for(Method method:methods)
        {
            if(method.getReturnType() != null && method.getParameters().length == 0 && method.getName().startsWith("get") || method.getName().startsWith("is"))
            {
                //is a bean getter
                if(!Arrays.asList(getFieldsNotAllowed()).contains(method.getName()))
                {
                    try {
                        fieldsValues.add(method.invoke(this).toString());
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    } catch (InvocationTargetException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        return fieldsValues.toArray(new String[0]);
    }

    @Override
    public String[] getFieldsNotAllowed()
    {
        return new String[]{"getSaveDate","getUpdateDate","getId"};
    }

    @Override
    public boolean canPublishFields() {
        if(this instanceof OlapEntityQuestionarioUser)
        {
            return false;
        }
        return true;
    }
    */

    public abstract 1.5.0/docs/api/java/lang/String.html">String[] getFields();
    public abstract 1.5.0/docs/api/java/lang/String.html">String[] getFieldsValues();
}