/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package servis.impl;

import dao.DaoPoslovniPartner;
import domen.AbstractPoslovniPartner;
import domen.FizickoLice;
import domen.PravnoLice;
import servis.ServisPoslovniPartner;

/**
 *
 * @author student
 */
public class ServisPoslovniPartnerImpl implements ServisPoslovniPartner {
    private DaoPoslovniPartner daoPP;

    public ServisPoslovniPartnerImpl(DaoPoslovniPartner daoPP) {
        this.daoPP = daoPP;
    }
    
    
    
    @Override
    public void sacuvaj(AbstractPoslovniPartner app) throws Exception {
        if (app instanceof PravnoLice) {
            PravnoLice pl = (PravnoLice) app;
            PravnoLice pl_db = daoPP.pronadjiPravnoLice(pl);
            
            if (pl_db == null) daoPP.sacuvaj(app);
            else throw new Exception("Pravno lice vec postoji.");                          
        }
        if (app instanceof FizickoLice) {
            FizickoLice fl = (FizickoLice) app;
        }
        //daoPP.sacuvaj(app);
        
        
        
    }
    
}
