/*
 * Arrebol Consultancy copyright.
 * 
 * This code belongs to Arrebol Consultancy
 * its use, redistribution or modification are prohibited 
 * without written authorization from Arrebol Consultancy.
 */
package com.arrebol.apc.service.catalog;

import com.arrebol.apc.model.ModelParameter;
import com.arrebol.apc.model.core.Office;
import com.arrebol.apc.model.core.constance.LoanTypeCfg;
import com.arrebol.apc.model.loan.LoanType;
import com.arrebol.apc.repository.LazyDataModelDAORepository;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.RequestScoped;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 *
 * @author Carlos Janitzio Zavala Lopez <janitzio.zavala@arrebol.com.mx>
 */
@RequestScoped
public class LoanTypeServiceImpl extends LazyDataModelDAORepository<LoanType> implements LoanTypeService {

    @Override
    public LoanType getLoanTypeById(String loanTypeId) {
        logger.debug("getLoanTypeById");

        return (LoanType) findAPCEntity(LoanType.class, loanTypeId);
    }

    @Override
    public List<LoanType> fillLoanTypeDatatable(String officeId) {
        logger.debug("fillLoanTypeDatatable");
        List<ModelParameter> parameters = new ArrayList<>();

        parameters.add(new ModelParameter(LoanTypeCfg.FIELD_OFFICE, new Office(officeId)));

        return xmlQueryAPCEntities(LoanType.class, LoanTypeCfg.QUERY_FIND_ALL_DATA_LOAN_TYPE_BY_OFFICE, parameters);
    }

    final Logger logger = LogManager.getLogger(getClass());

}
