Integer guideNumber = null;  guideNumber = Guide.generateGuideNumber(infoGuide.getYear());
Integer guideNumber = Guide.generateGuideNumber();
    public InfoGuide run(InfoGuide infoGuide, String remarks, GuideState situationOfGuide,            List transactionsIDs) throws FenixServiceException, ExcepcaoPersistencia {        Guide guide = DomainFactory.makeGuide();        GuideSituation guideSituation = null;        // Check the Guide Situation        if (situationOfGuide.equals(GuideState.ANNULLED))            throw new InvalidSituationServiceException();        // Get the Guide Number        Integer guideNumber = null;        guideNumber = Guide.generateGuideNumber(infoGuide.getYear());        infoGuide.setNumber(guideNumber);        // Create the new Guide Situation        InfoGuideSituation infoGuideSituation = new InfoGuideSituation();        infoGuideSituation.setState(new State(State.ACTIVE));        infoGuideSituation.setRemarks(remarks);        infoGuideSituation.setInfoGuide(infoGuide);        Calendar calendar = Calendar.getInstance();        infoGuideSituation.setSituation(situationOfGuide);        guide.setCreationDate(infoGuide.getCreationDate());        guide.setGuideRequester(infoGuide.getGuideRequester());        guide.setNumber(infoGuide.getNumber());        guide.setPaymentDate(infoGuide.getPaymentDate());        guide.setPaymentType(infoGuide.getPaymentType());        guide.setRemarks(infoGuide.getRemarks());        guide.setTotal(infoGuide.getTotal());        guide.setVersion(infoGuide.getVersion());        guide.setYear(infoGuide.getYear());        if (situationOfGuide.equals(GuideState.PAYED)) {            guide.setPaymentType(PaymentType.SIBS);            guide.setPaymentDate(calendar.getTime());        }        // Get the Execution Degree        ExecutionDegree executionDegree = rootDomainObject.readExecutionDegreeByOID(infoGuide                .getInfoExecutionDegree().getIdInternal());        Contributor contributor = Contributor.readByContributorNumber(infoGuide.getInfoContributor()                .getContributorNumber());        Person person = Person.readPersonByUsername(infoGuide.getInfoPerson().getUsername());        guide.setExecutionDegree(executionDegree);        guide.setContributor(contributor);        guide.setPerson(person);        // Write the new Guide        // Write the new Entries of the Guide        Iterator iterator = transactionsIDs.iterator();        PaymentTransaction transaction = null;        Integer transactionId = null;        GuideEntry guideEntry = null;        double guideTotal = 0;        while (iterator.hasNext()) {            transactionId = (Integer) iterator.next();            transaction = (PaymentTransaction) rootDomainObject.readTransactionByOID(transactionId);            if (transaction == null) {                throw new ExcepcaoInexistente();            }            guideEntry = DomainFactory.makeGuideEntry();            if (transaction instanceof GratuityTransaction) {                guideEntry.setDocumentType(DocumentType.GRATUITY);            } else if (transaction instanceof InsuranceTransaction) {                guideEntry.setDocumentType(DocumentType.INSURANCE);            }            guideEntry.setPrice(transaction.getValue());            guideEntry.setQuantity(new Integer(1));            guideTotal += transaction.getValue().doubleValue();            guideEntry.setGraduationType(GraduationType.MASTER_DEGREE);            guideEntry.setDescription("");            guideEntry.setGuide(guide);            transaction.setGuideEntry(guideEntry);            guide.setCreationDate(transaction.getTransactionDate());            guide.setPaymentDate(transaction.getTransactionDate());            infoGuideSituation.setDate(transaction.getTransactionDate());        }        // Guide Total Price        guide.setTotal(NumberUtils.formatNumber(new Double(guideTotal), 2));        // Write the New Guide Situation        guideSituation = DomainFactory.makeGuideSituation(infoGuideSituation.getSituation(),                infoGuideSituation.getRemarks(), infoGuideSituation.getDate(), guide, infoGuideSituation                        .getState());        guide.getGuideSituations().add(guideSituation);        InfoGuide result = InfoGuideWithPersonAndExecutionDegreeAndContributor.newInfoFromDomain(guide);        result.setInfoGuideEntries(infoGuide.getInfoGuideEntries());        return result;    }