List of usage examples for org.apache.commons.lang3 StringUtils equals
public static boolean equals(final CharSequence cs1, final CharSequence cs2)
Compares two CharSequences, returning true if they represent equal sequences of characters.
null s are handled without exceptions.
From source file:com.glaf.base.district.web.springmvc.DistrictController.java
@RequestMapping("/edit") public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) { LoginContext loginContext = RequestUtils.getLoginContext(request); RequestUtils.setRequestParameterToAttribute(request); DistrictEntity district = districtService.getDistrict(RequestUtils.getLong(request, "id")); if (district != null && (StringUtils.equals(district.getCreateBy(), loginContext.getActorId()) || loginContext.isSystemAdministrator())) { request.setAttribute("district", district); }/*from ww w . jav a 2 s . c o m*/ Long parentId = RequestUtils.getLong(request, "parentId", 0); List<DistrictEntity> districts = districtService.getDistrictList(parentId); if (district != null) { List<DistrictEntity> children = districtService.getDistrictList(district.getId()); if (districts != null && !districts.isEmpty()) { if (children != null && !children.isEmpty()) { districts.removeAll(children); } districts.remove(district); } } if (parentId > 0) { DistrictEntity parent = districtService.getDistrict(parentId); if (districts == null) { districts = new java.util.ArrayList<DistrictEntity>(); } districts.add(parent); } request.setAttribute("districts", districts); String view = request.getParameter("view"); if (StringUtils.isNotEmpty(view)) { return new ModelAndView(view, modelMap); } String x_view = ViewProperties.getString("district.edit"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/modules/sys/district/edit", modelMap); }
From source file:com.inkubator.hrm.web.career.EmpCareerTransitionApprovalFormController.java
@PostConstruct @Override/*from w w w .j ava 2 s . c o m*/ public void initialization() { try { super.initialization(); String id = FacesUtil.getRequestParameter("execution"); /** initial data for approval activity tracking */ currentActivity = approvalActivityService.getEntiyByPK(Long.parseLong(id.substring(1))); askingRevisedActivity = approvalActivityService.getEntityByActivityNumberAndSequence( currentActivity.getActivityNumber(), currentActivity.getSequence() - 1); isWaitingApproval = currentActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_APPROVAL; isWaitingRevised = currentActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_REVISED; isApprover = StringUtils.equals(UserInfoUtil.getUserName(), currentActivity.getApprovedBy()); isRequester = StringUtils.equals(UserInfoUtil.getUserName(), currentActivity.getRequestBy()); /** start binding data that needed (from json) to object */ Gson gson = JsonUtil.getHibernateEntityGsonBuilder().create(); model = gson.fromJson(currentActivity.getPendingData(), EmpCareerHistoryModel.class); //relational object EmpData empData = empDataService.getByEmpIdWithDetail(model.getEmpData().getId()); model.setEmpData(empData); model.setCompanyName(empData.getJabatanByJabatanId().getDepartment().getCompany().getName()); model.setCopyOfLetterTo(empDataService.getByEmpIdWithDetail(model.getCopyOfLetterTo().getId())); model.setCareerTransitionName( careerTransitionService.getEntiyByPK(model.getCareerTransitionId()).getTransitionName()); model.setDepartmentName(departmentService.getEntiyByPK(model.getDepartmentId()).getDepartmentName()); model.setJabatanName(jabatanService.getEntiyByPK(model.getJabatanId()).getName()); GolonganJabatan golonganJabatan = golonganJabatanService .getEntityByPkFetchAttendPangkat(model.getGolonganJabatanId()); model.setGolonganJabatanName( golonganJabatan.getCode() + " " + golonganJabatan.getPangkat().getPangkatName()); model.setEmployeeTypeName(employeeTypeService.getEntiyByPK(model.getEmployeeTypeId()).getName()); //additional information model.setCurrentCompany(empData.getJabatanByJabatanId().getDepartment().getCompany().getName()); model.setCurrentDepartment(empData.getJabatanByJabatanId().getDepartment().getDepartmentName()); model.setCurrentEmployeeType(empData.getEmployeeType().getName()); model.setCurrentGolJab(empData.getGolonganJabatan().getCode() + " " + empData.getGolonganJabatan().getPangkat().getPangkatName()); model.setCurrentJabatan(empData.getJabatanByJabatanId().getName()); model.setCurrentJoinDate(empData.getJoinDate()); model.setCurrentNik(empData.getNik()); } catch (Exception ex) { LOGGER.error("Error", ex); } }
From source file:fr.scc.elo.controller.ServiceController.java
@GET @Produces({ MediaType.TEXT_HTML }) @Path("/connections/sort/{sort}/{previous}/{updown}") public Response checkConnectionsSorted(@Context HttpServletRequest http, @PathParam("sort") String sort, @PathParam("previous") String previous, @PathParam("updown") String prevUpdown) { Map<String, Object> map = new HashMap<>(); List<ConnectionData> values = null; String updown = "up"; if (StringUtils.equals(sort, previous) && StringUtils.equals(prevUpdown, "up")) { updown = "down"; }/*w w w . j a v a 2 s . c om*/ if (connectionService.acceptIPUpdate(http.getRemoteAddr())) { Map<String, ConnectionData> connectionDataMap = ConnectionFilter.getConnectionDataMap(); values = new ArrayList<>(connectionDataMap.values()); Collections.sort(values, getComparator(sort, updown)); } else { values = new ArrayList<>(); } map.put("coData", values); map.put("previous", sort); map.put("updown", updown); return Response.ok(new Viewable("/allConnections", map)).build(); }
From source file:info.magnolia.imaging.ImagingServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String generatorName = getImageGeneratorName(request); final ImageGenerator generator = getGenerator(generatorName); if (generator == null) { throw new IllegalArgumentException("No ImageGenerator with name " + generatorName); }/*from w w w. j a v a 2 s. c om*/ final ParameterProviderFactory parameterProviderFactory = generator.getParameterProviderFactory(); final ParameterProvider p = parameterProviderFactory.newParameterProviderFor(request); if (validateFileExtension) { String outputFormat = generator.getOutputFormat(p).getFormatName(); String requestedPath = StringUtils.substringAfterLast(request.getPathInfo(), "/"); // don't take part of node name as extension, we support dots in node names! String requestedFormat = StringUtils.substringAfterLast(requestedPath, "."); if (!StringUtils.equals(outputFormat, requestedFormat)) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } } try { // TODO -- mimetype etc. final ImageStreamer streamer = getStreamer(parameterProviderFactory); streamer.serveImage(generator, p, response.getOutputStream()); response.flushBuffer(); // IOUtils.closeQuietly(response.getOutputStream()); } catch (ImagingException e) { throw new ServletException(e); // TODO } }
From source file:edu.cornell.kfs.vnd.document.service.impl.CUVendorServiceImpl.java
/** * /*from ww w . j a va2 s .c om*/ */ public VendorDetail getVendorByNamePlusLastFourOfTaxID(String vendorName, String lastFour) { LOG.debug("Entering getVendorByNamePlusLastFourOfTaxID for vendorName:" + vendorName + ", last four :" + lastFour); // Map criteria = new HashMap(); // criteria.put(VendorPropertyConstants.VENDOR_NAME, vendorName); // List<VendorDetail> vds = (List) businessObjectService.findMatching(VendorDetail.class, criteria); HashMap<String, String> attributes = new HashMap<String, String>(); attributes.put(VendorPropertyConstants.VENDOR_NAME, "*" + vendorName + "*"); vendorLookupableHelperServiceImpl.setBusinessObjectClass(VendorDetail.class); List<VendorDetail> vds = (List) vendorLookupableHelperServiceImpl.getSearchResults(attributes); List<VendorDetail> matches = new ArrayList<VendorDetail>(); for (VendorDetail detail : vds) { String taxId = detail.getVendorHeader().getVendorTaxNumber(); if (StringUtils.isNotBlank(taxId)) { String compareTo = taxId.substring(taxId.length() - 4); if (StringUtils.equals(lastFour, compareTo)) { matches.add(detail); } } } LOG.debug("Exiting getVendorByNamePlusLastFourOfTaxID."); // TODO : not sure about this. vendor may have division and have the same tax id ? // if > 1, then should we also return matches.get(0) ? if (matches.size() > 1 || matches.isEmpty()) { return null; } return matches.get(0); }
From source file:com.inkubator.hrm.web.organisation.AnnouncementApprovalFormController.java
@PostConstruct @Override//from w w w. j a v a 2s .c o m public void initialization() { try { super.initialization(); /** initial data for approval activity tracking */ String approvalActivityId = FacesUtil.getRequestParameter("execution"); selectedApprovalActivity = approvalActivityService .getEntiyByPK(Long.parseLong(approvalActivityId.substring(1))); isWaitingApproval = selectedApprovalActivity .getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_APPROVAL; isWaitingRevised = selectedApprovalActivity .getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_REVISED; isApprover = StringUtils.equals(UserInfoUtil.getUserName(), selectedApprovalActivity.getApprovedBy()); isRequester = StringUtils.equals(UserInfoUtil.getUserName(), selectedApprovalActivity.getRequestBy()); /** start binding data that needed (from json) to object */ Gson gson = JsonUtil.getHibernateEntityGsonBuilder().create(); announcement = gson.fromJson(selectedApprovalActivity.getPendingData(), Announcement.class); //relational object Company company = companyService.getEntiyByPK(announcement.getCompany().getId()); announcement.setCompany(company); JsonObject jsonObject = (JsonObject) gson.fromJson(selectedApprovalActivity.getPendingData(), JsonObject.class); List<Long> listEmployeeTypeId = new GsonBuilder().create() .fromJson(jsonObject.get("listEmployeeTypeId").getAsString(), new TypeToken<List<Long>>() { }.getType()); listEmployeeType = new ArrayList<EmployeeType>(); for (Long id : listEmployeeTypeId) { EmployeeType employeeType = employeeTypeService.getEntiyByPK(id); if (employeeType != null) { listEmployeeType.add(employeeType); } } List<Long> listGolonganJabatanId = new GsonBuilder().create() .fromJson(jsonObject.get("listGolonganJabatanId").getAsString(), new TypeToken<List<Long>>() { }.getType()); listGolonganJabatan = new ArrayList<GolonganJabatan>(); for (Long id : listGolonganJabatanId) { GolonganJabatan golonganJabatan = golonganJabatanService.getEntiyByPK(id); if (golonganJabatan != null) { listGolonganJabatan.add(golonganJabatan); } } List<Long> listUnitKerjaId = new GsonBuilder().create() .fromJson(jsonObject.get("listUnitKerjaId").getAsString(), new TypeToken<List<Long>>() { }.getType()); listUnitKerja = new ArrayList<UnitKerja>(); for (Long id : listUnitKerjaId) { UnitKerja unitKerja = unitKerjaService.getEntiyByPK(id); if (unitKerja != null) { listUnitKerja.add(unitKerja); } } //attachment file isHaveAttachment = StringUtils.isNotEmpty(announcement.getAttachmentPath()); } catch (Exception ex) { LOGGER.error("Error", ex); } }
From source file:co.rsk.peg.BridgeUtils.java
public static boolean isFreeBridgeTx(org.ethereum.core.Transaction rskTx, long blockNumber) { BlockchainNetConfig blockchainConfig = SystemProperties.CONFIG.getBlockchainConfig(); byte[] receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress == null) return false; return StringUtils.equals(Hex.toHexString(receiveAddress), PrecompiledContracts.BRIDGE_ADDR) && blockchainConfig.getConfigForBlock(blockNumber).areBridgeTxsFree() && rskTx.getSignature() != null && blockchainConfig.getCommonConstants().getBridgeConstants().getFederatorPublicKeys() .contains(co.rsk.bitcoinj.core.BtcECKey.fromPublicOnly(rskTx.getKey().getPubKey())); }
From source file:io.relution.jenkins.awssqs.model.CodeCommitMessageParser.java
private boolean isCodeCommitEvent(final io.relution.jenkins.awssqs.model.entities.codecommit.Record record) { return StringUtils.equals(EVENT_SOURCE_CODECOMMIT, record.getEventSource()); }
From source file:com.glaf.core.config.SystemConfig.java
public static String getInputYYYYMM() { String value = getString("input_yyyymm"); if (StringUtils.isEmpty(value) || StringUtils.equals("input_yyyymm", value) || StringUtils.equals(INPUT_YYYYMM, value)) { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); int day = calendar.get(Calendar.DAY_OF_MONTH); calendar.set(year, month, day - 1); year = calendar.get(Calendar.YEAR); month = calendar.get(Calendar.MONTH); month = month + 1;//from w w w.j av a 2s. co m logger.debug(year + ":" + month); StringBuffer sb = new StringBuffer(50); sb.append(year); if (month <= 9) { sb.append("0").append(month); } else { sb.append(month); } value = sb.toString(); } logger.debug("input_yyyymm:" + value); return value; }
From source file:com.glaf.core.query.BaseQuery.java
public void ensureInitialized() { if (isInitialized) { return;/*from w w w . ja v a2s. c o m*/ } if (loginContext != null) { if (StringUtils.equals(createBy, loginContext.getActorId())) { isFilterPermission = false; } if (StringUtils.isNotEmpty(createBy)) { isFilterPermission = false; } if (isFilterPermission) { /** * ????+? */ // /////////////////////////////////////////////////////// // ??? // /////////////////////////////////////////////////////// /** * */ if (loginContext.getActorId() != null) { this.actorIds.add(loginContext.getActorId()); } /** * */ if (loginContext.getDeptId() != 0) { } } } isInitialized = true; }