All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.wadpam.open.io.Mardao2Extractor Maven / Gradle / Ivy

package com.wadpam.open.io;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import net.sf.mardao.core.CursorPage;
import net.sf.mardao.core.dao.Dao;

/**
 *
 * @author os
 */
public class Mardao2Extractor implements Extractor {
    
    Map> daoHeaders = new HashMap>();

    @Override
    public Iterable getColumns(Object arg, Dao dao) {
        final ArrayList columns = new ArrayList(dao.getColumnNames());
        
        columns.add(0, dao.getPrimaryKeyColumnName());
        
        if (null != dao.getParentKeyColumnName()) {
            columns.add(0, dao.getParentKeyColumnName());
        }
        
        return columns;
    }
    
    @Override
    public Map getHeaderNames(Object arg, Dao dao) {
        final Map map = daoHeaders.get(dao.getTableName());
        return null != map ? map : Collections.EMPTY_MAP;
    }
    
    public void setHeaderNames(Map headerNames, Dao dao) {
        daoHeaders.put(dao.getTableName(), headerNames);
    }

    @Override
    public Map getValues(Object arg, Dao dao, Object entity) {
        return dao.getDomainProperties(entity);
    }

    @Override
    public String getTableName(Object arg, Dao dao) {
        return dao.getTableName();
    }

    @Override
    public Object postDao(Object arg, Object preExport, Object preDao, Dao dao) {
        return null;
    }

    @Override
    public Object postExport(Object arg, Object preExport, Dao[] daos) {
        return null;
    }

    @Override
    public Object preDao(Object arg, Object preExport, Dao dao) {
        return null;
    }

    @Override
    public Object preExport(Object arg, Dao[] daos) {
        return null;
    }

    @Override
    public Iterable queryIterable(Object arg, Dao dao, int offset, int limit) {
        return dao.queryChunk(offset, limit, null, null, null, false, null, false);
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy