List of usage examples for java.lang Short equals
public boolean equals(Object obj)
From source file:com.jd.survey.web.survey.PublicSurveyController.java
/** * Helper method that computes the next page * @param survey//from w w w . j av a2 s . c om * @param thisPageOrder * @return */ private Short getNextPageOrder(List<SurveyPage> surveyPages, Short thisPageOrder) { try { if (thisPageOrder.equals((short) surveyPages.size())) { return 0;// go to the submit page } //The next page is the first visible page after this order for (SurveyPage surveyPage : surveyPages) { if (surveyPage.getOrder() > thisPageOrder) { if (surveyPage.getVisible()) { log.info("getNextPageOrder=" + surveyPage.getOrder()); return surveyPage.getOrder(); } } } return 0; // go to the submit page } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:dk.dma.vessel.track.model.VesselTarget.java
/** * Update the static information fields from the AIS message * @param message the AIS message//from w w w .j ava 2 s . co m * @param date the date of the message * @return if any fields were updated */ private boolean updateVesselStaticMessage(AisStaticCommon message, Date date) { // Check that this is a newer static update if (lastStaticReport != null && lastStaticReport.getTime() >= date.getTime()) { return false; } boolean updated = false; // Update the name String name = AisMessage.trimText(message.getName()); if (StringUtils.isNotBlank(name) && !name.equals(this.name)) { this.name = name; updated = true; } // Update the call-sign String callsign = AisMessage.trimText(message.getCallsign()); if (StringUtils.isNotBlank(callsign) && !callsign.equals(this.callsign)) { this.callsign = callsign; updated = true; } // Update the vessel type Integer vesselType = message.getShipType(); if (!vesselType.equals(this.vesselType)) { this.vesselType = vesselType; updated = true; } if (message instanceof AisMessage5) { AisMessage5 msg5 = (AisMessage5) message; AisTargetDimensions dim = new AisTargetDimensions(msg5); // Update length Short length = (short) (dim.getDimBow() + dim.getDimStern()); if (!length.equals(this.length)) { this.length = length; updated = true; } // Update width Short width = (short) (dim.getDimPort() + dim.getDimStarboard()); if (!width.equals(this.width)) { this.width = width; updated = true; } // Update destination String destination = StringUtils.defaultIfBlank(AisMessage.trimText(msg5.getDest()), null); if (destination != null && !destination.equals(this.destination)) { this.destination = destination; updated = true; } // Update draught Float draught = msg5.getDraught() / 10.0f; if (msg5.getDraught() > 0 && !compare(draught, this.draught)) { this.draught = draught; updated = true; } // Update ETA Date eta = msg5.getEtaDate(); if (eta != null && !eta.equals(this.eta)) { this.eta = eta; updated = true; } // Update IMO Long imo = msg5.getImo(); if (msg5.getImo() > 0 && !imo.equals(this.imoNo)) { this.imoNo = imo; updated = true; } } // Only update lastStaticReport if any static field has been updated if (updated) { lastStaticReport = date; } return updated; }
From source file:com.jd.survey.web.survey.PrivateSurveyController.java
/** * Helper method that computes the previous page * @param survey// w w w .j a v a 2 s . c o m * @param thisPageOrder * @return */ private Short getPreviousPageOrder(List<SurveyPage> surveyPages, Short thisPageOrder) { try { if (thisPageOrder.equals((short) 1)) { return 0; } //The previous page is the first visible page before this order for (int i = thisPageOrder - 1; i >= 0; i--) { SurveyPage surveyPage = surveyPages.get(i); if (surveyPage.getOrder() < thisPageOrder) { if (surveyPage.getVisible()) { log.info("getPreviousPageOrder=" + surveyPage.getOrder()); return surveyPage.getOrder(); } } } return null; } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:com.jd.survey.web.survey.PrivateSurveyController.java
/** * Helper method that computes the next page * @param survey// w ww .j a va 2 s .com * @param thisPageOrder * @return */ private Short getNextPageOrder(List<SurveyPage> surveyPages, Short thisPageOrder) { try { if (thisPageOrder.equals((short) surveyPages.size())) { return 0; // go to the submit page } //The next page is the first visible page after this order for (SurveyPage surveyPage : surveyPages) { if (surveyPage.getOrder() > thisPageOrder) { if (surveyPage.getVisible()) { log.info("getNextPageOrder=" + surveyPage.getOrder()); return surveyPage.getOrder(); } } } return 0; // go to the submit page } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:gr.abiss.calipso.domain.ItemSearch.java
/** * Get item visibility criteria for the spaces included in the search * @param spaces//from w w w.j a v a 2s . c om * @return */ private Disjunction getVisibilityCriteriaForItem(Collection<Space> spaces) { Disjunction itemRestrictions = Restrictions.disjunction(); List<Space> includedSpaces = new LinkedList<Space>(); for (Space space : spaces) { Short visibility = space.getItemVisibility(); boolean isLoggedIn = user.getId() != 0; boolean hasRegularRoleForSpace = user.hasRegularRoleForSpace(space); // for spaces allowing item view for anonymous users if (visibility.equals(Space.ITEMS_VISIBLE_TO_ANONYMOUS_USERS)) { itemRestrictions.add(Restrictions.eq("space", space)); includedSpaces.add(space); //logger.debug("Included space '" + space.getName() + "' since it allows anonymous"); } // for spaces allowing item view for loggedin users else if (isLoggedIn && visibility.equals(Space.ITEMS_VISIBLE_TO_ANY_LOGGEDIN_USER)) { itemRestrictions.add(Restrictions.eq("space", space)); //logger.debug("Included space '" + space.getName() + "' since the user is logged in"); } // for spaces allowing item view for item reporters else if (isLoggedIn && (visibility.equals(Space.ITEMS_VISIBLE_TO_LOGGEDIN_REPORTERS) || visibility.equals(Space.ITEMS_VISIBLE_TO_LOGGEDIN_REPORTERS_NO_COMMENTS))) { if (hasRegularRoleForSpace) { itemRestrictions.add(Restrictions.eq("space", space)); //logger.debug("Included space '" + space.getName() + "' since the user is a regular user"); } else { itemRestrictions.add(Restrictions.conjunction().add(Restrictions.eq("space", space)) .add(Restrictions.eq("reportedBy", user))); } //logger.debug("Included space '" + space.getName() + "' but only for items reported by user"); } // for spaces allowing item view users with explicit roles only else if (isLoggedIn /* && visibility.equals(Space.ITEMS_VISIBLE_TO_REGULAR_ROLES) */ && hasRegularRoleForSpace) { itemRestrictions.add(Restrictions.eq("space", space)); //logger.debug("Included space '" + space.getName() + "' since the user is a regular user"); } else { //itemRestrictions.add(Restrictions.ne("space", space)); //logger.debug("Did NOT include space '" + space.getName()+" user has regular roles for space: "+hasRegularRoleForSpace+", space visibility: "+space.getItemVisibility()); } } return itemRestrictions; }
From source file:org.mifos.application.servicefacade.ClientServiceFacadeWebTier.java
@Override public CustomerDetailsDto createNewClient(ClientCreationDetail clientCreationDetail, MeetingDto meetingDto, List<SavingsDetailDto> allowedSavingProducts) { MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); UserContext userContext = toUserContext(user); OfficeBO userOffice = this.officeDao.findOfficeById(userContext.getBranchId()); userContext.setBranchGlobalNum(userOffice.getGlobalOfficeNum()); try {/*from w w w. j ava 2 s.c o m*/ ClientBO client = null; List<AccountFeesEntity> feesForCustomerAccount = convertFeeViewsToAccountFeeEntities( clientCreationDetail.getFeesToApply()); List<SavingsOfferingBO> selectedOfferings = new ArrayList<SavingsOfferingBO>(); for (Short productId : clientCreationDetail.getSelectedSavingProducts()) { if (productId != null) { for (SavingsDetailDto savingsOffering : allowedSavingProducts) { if (productId.equals(savingsOffering.getPrdOfferingId())) { SavingsOfferingBO savingsProduct = savingsProductDao.findById(productId.intValue()); selectedOfferings.add(savingsProduct); } } } } List<ClientInitialSavingsOfferingEntity> offeringsAssociatedInCreate = new ArrayList<ClientInitialSavingsOfferingEntity>(); for (SavingsOfferingBO offering : selectedOfferings) { offeringsAssociatedInCreate.add(new ClientInitialSavingsOfferingEntity(null, offering)); } Short personnelId = null; Short officeId = null; ClientNameDetailDto spouseNameDetailView = null; if (ClientRules.isFamilyDetailsRequired()) { // actionForm.setFamilyDateOfBirth(); // actionForm.constructFamilyDetails(); } else { spouseNameDetailView = clientCreationDetail.getSpouseFatherName(); } String secondMiddleName = null; ClientNameDetailEntity clientNameDetailEntity = new ClientNameDetailEntity(null, secondMiddleName, clientCreationDetail.getClientNameDetailDto()); ClientNameDetailEntity spouseFatherNameDetailEntity = null; if (spouseNameDetailView != null) { spouseFatherNameDetailEntity = new ClientNameDetailEntity(null, secondMiddleName, spouseNameDetailView); } ClientDetailEntity clientDetailEntity = new ClientDetailEntity(); clientDetailEntity.updateClientDetails(clientCreationDetail.getClientPersonalDetailDto()); DateTime dob = new DateTime(clientCreationDetail.getDateOfBirth()); boolean trainedBool = clientCreationDetail.isTrained(); DateTime trainedDateTime = null; if (clientCreationDetail.getTrainedDate() != null) { trainedDateTime = new DateTime(clientCreationDetail.getTrainedDate()); } String clientFirstName = clientCreationDetail.getClientNameDetailDto().getFirstName(); String clientLastName = clientCreationDetail.getClientNameDetailDto().getLastName(); String secondLastName = clientCreationDetail.getClientNameDetailDto().getSecondLastName(); CustomerStatus clientStatus = CustomerStatus.fromInt(clientCreationDetail.getClientStatus()); PersonnelBO formedBy = this.personnelDao.findPersonnelById(clientCreationDetail.getFormedBy()); Address address = null; if (clientCreationDetail.getAddress() != null) { AddressDto dto = clientCreationDetail.getAddress(); address = new Address(dto.getLine1(), dto.getLine2(), dto.getLine3(), dto.getCity(), dto.getState(), dto.getCountry(), dto.getZip(), dto.getPhoneNumber()); } if (YesNoFlag.YES.getValue().equals(clientCreationDetail.getGroupFlag())) { Integer parentGroupId = Integer.parseInt(clientCreationDetail.getParentGroupId()); CustomerBO group = this.customerDao.findCustomerById(parentGroupId); if (group.getPersonnel() != null) { personnelId = group.getPersonnel().getPersonnelId(); } officeId = group.getOffice().getOfficeId(); client = ClientBO.createNewInGroupHierarchy(userContext, clientCreationDetail.getClientName(), clientStatus, new DateTime(clientCreationDetail.getMfiJoiningDate()), group, formedBy, clientNameDetailEntity, dob, clientCreationDetail.getGovernmentId(), trainedBool, trainedDateTime, clientCreationDetail.getGroupFlag(), clientFirstName, clientLastName, secondLastName, spouseFatherNameDetailEntity, clientDetailEntity, offeringsAssociatedInCreate, clientCreationDetail.getExternalId(), address, clientCreationDetail.getActivationDate()); if (ClientRules.isFamilyDetailsRequired()) { client.setFamilyAndNameDetailSets(clientCreationDetail.getFamilyNames(), clientCreationDetail.getFamilyDetails()); } this.customerService.createClient(client, client.getCustomerMeetingValue(), feesForCustomerAccount, selectedOfferings); } else { personnelId = clientCreationDetail.getLoanOfficerId(); officeId = clientCreationDetail.getOfficeId(); PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(personnelId); OfficeBO office = this.officeDao.findOfficeById(officeId); int lastSearchIdCustomerValue = customerDao .retrieveLastSearchIdValueForNonParentCustomersInOffice(officeId); MeetingBO clientMeeting = null; if (meetingDto != null) { clientMeeting = new MeetingFactory().create(meetingDto); clientMeeting.setUserContext(userContext); } client = ClientBO.createNewOutOfGroupHierarchy(userContext, clientCreationDetail.getClientName(), clientStatus, new DateTime(clientCreationDetail.getMfiJoiningDate()), office, loanOfficer, clientMeeting, formedBy, clientNameDetailEntity, dob, clientCreationDetail.getGovernmentId(), trainedBool, trainedDateTime, clientCreationDetail.getGroupFlag(), clientFirstName, clientLastName, secondLastName, spouseFatherNameDetailEntity, clientDetailEntity, offeringsAssociatedInCreate, clientCreationDetail.getExternalId(), address, lastSearchIdCustomerValue); if (ClientRules.isFamilyDetailsRequired()) { client.setFamilyAndNameDetailSets(clientCreationDetail.getFamilyNames(), clientCreationDetail.getFamilyDetails()); } this.customerService.createClient(client, clientMeeting, feesForCustomerAccount, selectedOfferings); } clientPhotoService.create(client.getCustomerId().longValue(), clientCreationDetail.getPicture()); return new CustomerDetailsDto(client.getCustomerId(), client.getGlobalCustNum()); } catch (CustomerException e) { throw new BusinessRuleException(e.getKey(), e.getValues(), e); } }
From source file:org.mifos.customers.client.business.ClientBO.java
@Override protected boolean isActiveForFirstTime(final Short oldStatus, final Short newStatusId) { return (oldStatus.equals(CustomerStatus.CLIENT_PARTIAL.getValue()) || oldStatus.equals(CustomerStatus.CLIENT_PENDING.getValue())) && newStatusId.equals(CustomerStatus.CLIENT_ACTIVE.getValue()); }
From source file:org.mifos.customers.client.business.ClientBO.java
private void checkIfClientStatusIsLower(final Short clientStatusId, final Short groupStatus) throws CustomerException { if ((clientStatusId.equals(CustomerStatus.CLIENT_ACTIVE.getValue()) || clientStatusId.equals(CustomerStatus.CLIENT_PENDING.getValue())) && this.isClientUnderGroup()) { if (groupStatus.equals(CustomerStatus.GROUP_CANCELLED.getValue())) { throw new CustomerException(ClientConstants.ERRORS_GROUP_CANCELLED, new Object[] { MessageLookup .getInstance().lookupLabel(ConfigurationConstants.GROUP, this.getUserContext()) }); }//www . j ava 2 s. c om if (isGroupStatusLower(clientStatusId, groupStatus)) { throw new CustomerException(ClientConstants.INVALID_CLIENT_STATUS_EXCEPTION, new Object[] { MessageLookup.getInstance().lookupLabel(ConfigurationConstants.GROUP, this.getUserContext()), MessageLookup.getInstance().lookupLabel(ConfigurationConstants.CLIENT, this.getUserContext()) }); } } }
From source file:org.mifos.customers.client.business.ClientBO.java
@Override public void changeStatus(final Short newStatusId, final Short flagId, final String comment) throws CustomerException { super.changeStatus(newStatusId, flagId, comment); if (newStatusId.equals(CustomerStatus.CLIENT_CLOSED.getValue()) || newStatusId.equals(CustomerStatus.CLIENT_CANCELLED.getValue())) { if (isClientUnderGroup()) { resetPositions(getParentCustomer()); getParentCustomer().setUserContext(getUserContext()); getParentCustomer().update(); CustomerBO center = getParentCustomer().getParentCustomer(); if (center != null) { resetPositions(center);/*from w w w . j av a 2 s . c o m*/ center.setUserContext(getUserContext()); center.update(); center = null; } } // close customer account - #MIFOS-1504 for (AccountBO account : getAccounts()) { if (account.isOfType(AccountTypes.CUSTOMER_ACCOUNT) && account.isOpen()) { try { account.setUserContext(getUserContext()); account.changeStatus(AccountState.CUSTOMER_ACCOUNT_INACTIVE, flagId, comment); account.update(); } catch (AccountException e) { throw new CustomerException(e); } } } } }
From source file:org.mifos.customers.client.business.ClientBO.java
@Override protected void validateStatusChange(final Short newStatusId) throws CustomerException { if (getParentCustomer() != null) { checkIfClientStatusIsLower(newStatusId, getParentCustomer().getCustomerStatus().getId()); }//from w ww.ja v a 2s . c o m if (newStatusId.equals(CustomerStatus.CLIENT_CLOSED.getValue())) { checkIfClientCanBeClosed(); } if (newStatusId.equals(CustomerStatus.CLIENT_ACTIVE.getValue())) { checkIfClientCanBeActive(newStatusId); } }