IPersonFunction personFunction = DomainFactory.makePersonFunction();  personFunction.setPerson(person); personFunction.setFunction(function); personFunction.setCredits(credits); personFunction.setBeginDate(beginDate); personFunction.setEndDate(endDate);
if(RulesRepository.isElegible(person, function.getUnit(), function.getName())){ IPersonFunction personFunction = DomainFactory.makePersonFunction(); personFunction.setPerson(person); personFunction.setFunction(function); personFunction.setCredits(credits); personFunction.setBeginDate(beginDate); personFunction.setEndDate(endDate); } else{ throw new FenixServiceException("error.associateFunction"); }
    public void run(Integer functionID, Integer personID, Integer credits,            Date beginDate, Date endDate) throws ExcepcaoPersistencia, FenixServiceException {        ISuportePersistente suportePersistente = PersistenceSupportFactory.getDefaultPersistenceSupport();                IPerson person = (IPerson) suportePersistente.getIPessoaPersistente().readByOID(Person.class, personID);                if(person == null){            throw new FenixServiceException("error.noPerson");        }                               IFunction function = (IFunction) suportePersistente.getIPersistentObject().readByOID(Function.class, functionID);                if(function == null){            throw new FenixServiceException("error.noFunction");        }                IPersonFunction personFunction = DomainFactory.makePersonFunction();                personFunction.setPerson(person);        personFunction.setFunction(function);        personFunction.setCredits(credits);        personFunction.setBeginDate(beginDate);        personFunction.setEndDate(endDate);            }