List of usage examples for java.lang Short intValue
public int intValue()
From source file:org.mifos.application.servicefacade.PersonnelServiceFacadeWebTier.java
@Override public PersonnelInformationDto getPersonnelInformationDto(final Long userId, final String globalNumber) { PersonnelBO personnel = null;// w ww. j a va 2 s. c o m if (userId != null) { personnel = personnelDao.findPersonnelById(userId.shortValue()); } else { personnel = personnelDao.findByGlobalPersonnelNum(globalNumber); } if (personnel == null) { throw new MifosRuntimeException("personnel not found for id" + userId); } String displayName = personnel.getDisplayName(); PersonnelStatusEntity personnelStatus = personnel.getStatus(); String statusName = ApplicationContextProvider.getBean(MessageLookup.class) .lookup(personnelStatus.getLookUpValue()); ListElement status = new ListElement(new Integer(personnelStatus.getId()), statusName); boolean locked = personnel.isLocked(); PersonnelDetailsEntity personnelDetailsEntity = personnel.getPersonnelDetails(); Address address = personnelDetailsEntity.getAddress(); AddressDto addressDto = new AddressDto(address.getLine1(), address.getLine2(), address.getLine3(), address.getCity(), address.getState(), address.getCountry(), address.getZip(), address.getPhoneNumber()); Name name = personnelDetailsEntity.getName(); PersonnelDetailsDto personnelDetails = new PersonnelDetailsDto( personnelDetailsEntity.getGovernmentIdNumber(), new DateTime(personnelDetailsEntity.getDob()).toDateMidnight().toDateTime(), personnelDetailsEntity.getMaritalStatus(), personnelDetailsEntity.getGender(), new DateTime(personnelDetailsEntity.getDateOfJoiningMFI()).toDateMidnight().toDateTime(), new DateTime(personnelDetailsEntity.getDateOfJoiningBranch()).toDateMidnight().toDateTime(), new DateTime(personnelDetailsEntity.getDateOfLeavingBranch()).toDateMidnight().toDateTime(), addressDto, name.getFirstName(), name.getMiddleName(), name.getSecondLastName(), name.getLastName()); String emailId = personnel.getEmailId(); Short preferredLocale = personnel.getPreferredLocale(); String languageName = Localization.getInstance().getDisplayName(preferredLocale); if (preferredLocale != null) { languageName = Localization.getInstance().getDisplayName(preferredLocale); } PersonnelLevelEntity level = personnel.getLevel(); OfficeBO office = personnel.getOffice(); Integer title = personnel.getTitle(); Set<PersonnelRoleEntity> personnelRoleEntities = personnel.getPersonnelRoles(); Set<ListElement> personnelRoles = new LinkedHashSet<ListElement>(); for (PersonnelRoleEntity entity : personnelRoleEntities) { ListElement element = new ListElement(entity.getRole().getId().intValue(), entity.getRole().getName()); personnelRoles.add(element); } Short personnelId = personnel.getPersonnelId(); String userName = personnel.getUserName(); Set<PersonnelCustomFieldEntity> personnelCustomFields = personnel.getCustomFields(); Set<CustomFieldDto> customFields = new LinkedHashSet<CustomFieldDto>(); for (PersonnelCustomFieldEntity fieldDef : personnelCustomFields) { customFields.add(new CustomFieldDto(fieldDef.getFieldId(), fieldDef.getFieldValue())); } Set<PersonnelNotesEntity> personnelNotesEntity = personnel.getPersonnelNotes(); Set<PersonnelNoteDto> personnelNotes = new LinkedHashSet<PersonnelNoteDto>(); for (PersonnelNotesEntity entity : personnelNotesEntity) { personnelNotes.add(new PersonnelNoteDto(new DateTime(entity.getCommentDate()), entity.getComment(), entity.getPersonnelName())); } return new PersonnelInformationDto(personnel.getPersonnelId().intValue(), personnel.getGlobalPersonnelNum(), displayName, status, locked, personnelDetails, emailId, languageName, preferredLocale.intValue(), level.getId(), office.getOfficeId().intValue(), office.getOfficeName(), title, personnelRoles, personnelId, userName, customFields, personnelNotes); }
From source file:org.mifos.config.Localization.java
public List<ValueListElement> getLocaleForUI() { List<ValueListElement> localeForUI = new ArrayList<ValueListElement>(); for (Short key : LOCALE_MAP.keySet()) { String displayName = getDisplayName(key); ValueListElement localeValue = new BusinessActivityEntity(key.intValue(), displayName, displayName); localeForUI.add(localeValue);// www . j a va2 s . c om Collections.sort(localeForUI, new ValueListElementSortByName()); } return localeForUI; }
From source file:org.mifos.config.Localization.java
public List<ListElement> getLocaleList() { List<ListElement> localeForUI = new ArrayList<ListElement>(); for (Short key : LOCALE_MAP.keySet()) { String displayName = getDisplayName(key); ListElement localeValue = new ListElement(key.intValue(), displayName); localeForUI.add(localeValue);/*w w w. java2 s . com*/ Collections.sort(localeForUI, new ListElementSortByName()); } return localeForUI; }
From source file:org.mifos.customers.office.business.service.OfficeServiceFacadeWebTier.java
@Override public ListElement createOffice(Short operationMode, OfficeDto officeDto) { MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); UserContext userContext = new UserContextFactory().create(user); OfficeLevel level = OfficeLevel.getOfficeLevel(officeDto.getLevelId()); OfficeBO parentOffice = officeDao.findOfficeById(officeDto.getParentId()); AddressDto addressDto = officeDto.getAddress(); Address address = new Address(addressDto.getLine1(), addressDto.getLine2(), addressDto.getLine3(), addressDto.getCity(), addressDto.getState(), addressDto.getCountry(), addressDto.getZip(), addressDto.getPhoneNumber()); try {/* w w w. j av a 2 s.c om*/ OfficeBO officeBO = new OfficeBO(userContext, level, parentOffice, officeDto.getCustomFields(), officeDto.getName(), officeDto.getOfficeShortName(), address, OperationMode.fromInt(operationMode.intValue())); OfficePersistence officePersistence = new OfficePersistence(); if (officePersistence.isOfficeNameExist(officeDto.getName())) { throw new OfficeValidationException(OfficeConstants.OFFICENAMEEXIST); } if (officePersistence.isOfficeShortNameExist(officeDto.getOfficeShortName())) { throw new OfficeValidationException(OfficeConstants.OFFICESHORTNAMEEXIST); } String searchId = generateSearchId(parentOffice); officeBO.setSearchId(searchId); String globalOfficeNum = generateOfficeGlobalNo(); officeBO.setGlobalOfficeNum(globalOfficeNum); StaticHibernateUtil.startTransaction(); this.officeDao.save(officeBO); StaticHibernateUtil.commitTransaction(); //Shahid - this is hackish solution to return officeId and globalOfficeNum via ListElement, it should be fixed, at least //a proper data storage class can be created ListElement element = new ListElement(new Integer(officeBO.getOfficeId()), officeBO.getGlobalOfficeNum()); // if we are here it means office created sucessfully // we need to update hierarchy manager cache OfficeSearch os = new OfficeSearch(officeBO.getOfficeId(), officeBO.getSearchId(), officeBO.getParentOffice().getOfficeId()); List<OfficeSearch> osList = new ArrayList<OfficeSearch>(); osList.add(os); EventManger.postEvent(Constants.CREATE, osList, SecurityConstants.OFFICECHANGEEVENT); return element; } catch (OfficeValidationException e) { StaticHibernateUtil.rollbackTransaction(); throw new BusinessRuleException(e.getMessage()); } catch (PersistenceException e) { StaticHibernateUtil.rollbackTransaction(); throw new MifosRuntimeException(e); } catch (OfficeException e) { StaticHibernateUtil.rollbackTransaction(); throw new BusinessRuleException(e.getKey(), e); } finally { StaticHibernateUtil.closeSession(); } }
From source file:org.mifos.framework.util.helpers.NumberUtils.java
public static Integer convertShortToInteger(Short shortValue) { if (shortValue == null) { return null; }//from w ww .ja v a 2 s . co m return shortValue.intValue(); }
From source file:serposcope.controllers.google.GoogleSearchController.java
public Result exportSerp(Context context, @PathParam("searchId") Integer searchId, @Param("date") String pdate) { GoogleSerp serp = null;/*from w w w . j av a 2s .c om*/ LocalDate date = null; try { date = LocalDate.parse(pdate); } catch (Exception ex) { } if (date != null) { List<Run> runs = baseDB.run.findByDay(Module.GOOGLE, date); if (!runs.isEmpty()) { GoogleSearch search = getSearch(context, searchId); if (search != null) { serp = googleDB.serp.get(runs.get(0).getId(), search.getId()); } } } if (serp == null) { return Results.ok().text().renderRaw("SERP not found"); } boolean exportRank = context.getParameter("rank") != null; boolean exportD1 = context.getParameter("d1") != null; boolean exportD7 = context.getParameter("d7") != null; boolean exportD30 = context.getParameter("d30") != null; boolean exportD90 = context.getParameter("d90") != null; int position = 0; StringBuilder builder = new StringBuilder(); for (GoogleSerpEntry entry : serp.getEntries()) { ++position; if (exportRank) { builder.append(position).append(","); } builder.append(StringEscapeUtils.escapeCsv(entry.getUrl())).append(","); if (exportD1) { Short rank = entry.getMap().getOrDefault((short) 1, (short) GoogleRank.UNRANKED); builder.append(rank != GoogleRank.UNRANKED ? rank.intValue() : "").append(","); } if (exportD7) { Short rank = entry.getMap().getOrDefault((short) 7, (short) GoogleRank.UNRANKED); builder.append(rank != GoogleRank.UNRANKED ? rank.intValue() : "").append(","); } if (exportD30) { Short rank = entry.getMap().getOrDefault((short) 30, (short) GoogleRank.UNRANKED); builder.append(rank != GoogleRank.UNRANKED ? rank.intValue() : "").append(","); } if (exportD90) { Short rank = entry.getMap().getOrDefault((short) 90, (short) GoogleRank.UNRANKED); builder.append(rank != GoogleRank.UNRANKED ? rank.intValue() : "").append(","); } if (builder.length() > 0) { builder.setCharAt(builder.length() - 1, '\n'); } } return Results.text() .addHeader("Content-Disposition", "attachment; filename=\"" + serp.getRunDay().toLocalDate() + ".csv\"") .renderRaw(builder.toString()); }