return guideSituation.getState().equals(new State(State.ACTIVE));
return guideSituation.getState().getState().equals(State.ACTIVE);
    public void run(Integer guideNumber, Integer guideYear, Integer guideVersion, Date paymentDate,            String remarks, String situationOfGuideString, String paymentType, IUserView userView)            throws ExcepcaoInexistente, FenixServiceException, ExistingPersistentException,            ExcepcaoPersistencia {        Guide guide = Guide.readByNumberAndYearAndVersion(guideNumber, guideYear, guideVersion);        if (guide == null) {            throw new ExcepcaoInexistente("Unknown Guide !!");        }        GuideSituation activeGuideSituation = (GuideSituation) CollectionUtils.find(guide                .getGuideSituations(), new Predicate() {            public boolean evaluate(Object arg0) {                GuideSituation guideSituation = (GuideSituation) arg0;                return guideSituation.getState().equals(new State(State.ACTIVE));            }        });        GuideState newSituationOfGuide = GuideState.valueOf(situationOfGuideString);        // check if the change is valid        if (!verifyChangeValidation(activeGuideSituation, newSituationOfGuide)) {            throw new NonValidChangeServiceException();        }        if (newSituationOfGuide.equals(activeGuideSituation.getSituation())) {            activeGuideSituation.setRemarks(remarks);            if (activeGuideSituation.getSituation().equals(GuideState.PAYED)) {                guide.setPaymentDate(paymentDate);                guide.setPaymentType(PaymentType.valueOf(paymentType));            }            // guide.addGuideSituations(activeGuideSituation);        } else {            // Create The New Situation            activeGuideSituation.setState(new State(State.INACTIVE));            GuideSituation newGuideSituation = DomainFactory.makeGuideSituation();            Calendar date = Calendar.getInstance();            newGuideSituation.setDate(date.getTime());            newGuideSituation.setRemarks(remarks);            newGuideSituation.setSituation(newSituationOfGuide);            newGuideSituation.setState(new State(State.ACTIVE));            if (newSituationOfGuide.equals(GuideState.PAYED)) {                guide.setPaymentDate(paymentDate);                guide.setPaymentType(PaymentType.valueOf(paymentType));                // For Transactions Creation                PersonAccount personAccount = guide.getPerson().getAssociatedPersonAccount();                if (personAccount == null) {                    personAccount = DomainFactory.makePersonAccount(guide.getPerson());                }                Person employeePerson = Person.readPersonByUsername(userView.getUtilizador());                Person studentPerson = guide.getPerson();                Student student = studentPerson.readStudentByDegreeType(DegreeType.MASTER_DEGREE);                ExecutionDegree executionDegree = guide.getExecutionDegree();                // Iterate Guide Entries to create Transactions                for (GuideEntry guideEntry : guide.getGuideEntries()) {                    // Write Gratuity Transaction                    if (guideEntry.getDocumentType().equals(DocumentType.GRATUITY)) {                        GratuitySituation gratuitySituation = student                                .readGratuitySituationByExecutionDegree(executionDegree);                        Double value = new Double(guideEntry.getPrice().doubleValue()                                * guideEntry.getQuantity().intValue());                        PaymentTransaction paymentTransaction = DomainFactory.makeGratuityTransaction(                                value, new Timestamp(Calendar.getInstance().getTimeInMillis()),                                guideEntry.getDescription(), guide.getPaymentType(),                                TransactionType.GRATUITY_ADHOC_PAYMENT, Boolean.FALSE, employeePerson,                                personAccount, guideEntry, gratuitySituation);                        // Update GratuitySituation                        Double remainingValue = gratuitySituation.getRemainingValue();                        gratuitySituation.setRemainingValue(new Double(remainingValue.doubleValue()                                - paymentTransaction.getValue().doubleValue()));                    }                    // Write Insurance Transaction                    if (guideEntry.getDocumentType().equals(DocumentType.INSURANCE)) {                        List insuranceTransactionList = student                                .readAllNonReimbursedInsuranceTransactionsByExecutionYear(executionDegree                                        .getExecutionYear());                        if (!insuranceTransactionList.isEmpty()) {                            throw new ExistingServiceException(                                    "error.message.transaction.insuranceTransactionAlreadyExists");                        }                        DomainFactory.makeInsuranceTransaction(guideEntry.getPrice(), new Timestamp(                                Calendar.getInstance().getTimeInMillis()), guideEntry.getDescription(),                                guide.getPaymentType(), TransactionType.INSURANCE_PAYMENT,                                Boolean.FALSE, guide.getPerson(), personAccount, guideEntry,                                executionDegree.getExecutionYear(), student);                    }                }            }            // Write the new Situation            guide.addGuideSituations(newGuideSituation);        }    }