List of usage examples for org.apache.commons.lang StringUtils isNumeric
public static boolean isNumeric(String str)
Checks if the String contains only unicode digits.
From source file:edu.ku.brc.specify.dbsupport.cleanuptools.AgentNameCleanupParserDlg.java
/** * @param str/*from ww w . j a v a2 s.co m*/ * @return */ private boolean doIncludeStr(final String str) { if (StringUtils.isNotEmpty(str)) { String lower = StringUtils.remove(str.toLowerCase(), '.'); if (lower.startsWith("ltd") || lower.startsWith("exp") || lower.equals("party") || lower.equals("etal") || lower.equals("et al") || lower.equals("et") || lower.equals("mrs") || lower.equals("mr") || StringUtils.isNumeric(lower)) { return false; } return true; } return true; }
From source file:fr.paris.lutece.plugins.workflow.modules.appointment.web.UpdateAdminAppointmentTaskComponent.java
/** * {@inheritDoc}/* w w w . j av a 2 s . c om*/ */ @Override public String doValidateTask(int nIdResource, String strResourceType, HttpServletRequest request, Locale locale, ITask task) { String strIdAdminUser = request.getParameter(PARAMETER_ID_ADMIN_USER); if (StringUtils.isBlank(strIdAdminUser) || !StringUtils.isNumeric(strIdAdminUser)) { return AdminMessageService.getMessageUrl(request, MESSAGE_MANDATORY_FIELD, AdminMessage.TYPE_STOP); } int nIdAdminUser = Integer.parseInt(strIdAdminUser); AdminUser adminUser = AdminUserHome.findByPrimaryKey(nIdAdminUser); if (adminUser == null) { return AdminMessageService.getMessageUrl(request, MESSAGE_MANDATORY_FIELD, AdminMessage.TYPE_STOP); } Appointment appointment = AppointmentHome.findByPrimaryKey(nIdResource); AppointmentFilter filter = new AppointmentFilter(); filter.setIdAdminUser(nIdAdminUser); filter.setDateAppointment(appointment.getDateAppointment()); List<Appointment> listAppointments = AppointmentHome.getAppointmentListByFilter(filter); if (listAppointments.size() > 0) { AppointmentSlot slot = AppointmentSlotHome.findByPrimaryKey(appointment.getIdSlot()); AppointmentSlot slotOfMatchingAppointment = null; for (Appointment appointmentFound : listAppointments) { if ((appointmentFound.getStatus() != Appointment.Status.STATUS_UNRESERVED.getValeur()) && (appointment.getIdAppointment() != appointmentFound.getIdAppointment())) { if (appointment.getIdSlot() == appointmentFound.getIdSlot()) { slotOfMatchingAppointment = slot; break; } AppointmentSlot slotFound = AppointmentSlotHome.findByPrimaryKey(appointmentFound.getIdSlot()); if (slot.getIdForm() != slotFound.getIdDay()) { int nTimeStart = (slot.getStartingHour() * 100) + slot.getStartingMinute(); int nTimeEnd = (slot.getEndingHour() * 100) + slot.getEndingMinute(); int nTimeStartFound = (slotFound.getStartingHour() * 100) + slotFound.getStartingMinute(); int nTimeEndFound = (slotFound.getEndingHour() * 100) + slotFound.getEndingMinute(); if (((nTimeStartFound > nTimeStart) && (nTimeStartFound < nTimeEnd)) || ((nTimeStart > nTimeStartFound) && (nTimeStart < nTimeEndFound))) { slotOfMatchingAppointment = slotFound; break; } } } } if (slotOfMatchingAppointment != null) { AppointmentForm form = AppointmentFormHome.findByPrimaryKey(slotOfMatchingAppointment.getIdForm()); Object[] args = { form.getTitle() }; AdminMessageService.getMessageUrl(request, ERROR_MESSAGE_ADMIN_USER_BUSY, args, AdminMessage.TYPE_STOP); } } return null; }
From source file:fr.paris.lutece.plugins.notifygru.modules.directory.services.NotifyGruDirectoryService.java
/** * Fill list entry types./*from w w w. ja v a2s . c om*/ * * @param strPropertyEntryTypes the str property entry types * @return the list */ private static List<Integer> fillListEntryTypes(String strPropertyEntryTypes) { List<Integer> listEntryTypes = new ArrayList<Integer>(); String strEntryTypes = AppPropertiesService.getProperty(strPropertyEntryTypes); if (StringUtils.isNotBlank(strEntryTypes)) { String[] listAcceptEntryTypesForIdDemand = strEntryTypes.split(NotifyGruDirectoryConstants.COMMA); for (String strAcceptEntryType : listAcceptEntryTypesForIdDemand) { if (StringUtils.isNotBlank(strAcceptEntryType) && StringUtils.isNumeric(strAcceptEntryType)) { int nAcceptedEntryType = Integer.parseInt(strAcceptEntryType); listEntryTypes.add(nAcceptedEntryType); } } } return listEntryTypes; }
From source file:fr.paris.lutece.plugins.extend.modules.rating.web.type.VoteTypeJspBean.java
/** * Gets the modify vote type./*from w w w . j a v a2s.c o m*/ * * @param request the request * @param response the response * @return the modify vote type * @throws AccessDeniedException the access denied exception */ public IPluginActionResult getModifyVoteType(HttpServletRequest request, HttpServletResponse response) throws AccessDeniedException { setPageTitleProperty(RatingConstants.PROPERTY_MANAGE_VOTE_TYPES_PAGE_TITLE); String strHtml = StringUtils.EMPTY; IPluginActionResult result = new DefaultPluginActionResult(); String strIdVoteType = request.getParameter(RatingConstants.PARAMETER_ID_VOTE_TYPE); if (StringUtils.isNotBlank(strIdVoteType) && StringUtils.isNumeric(strIdVoteType)) { int nIdVoteType = Integer.parseInt(strIdVoteType); Map<String, Object> model = new HashMap<String, Object>(); model.put(RatingConstants.MARK_VOTE_TYPE, _voteService.findByPrimaryKey(nIdVoteType, true)); model.put(RatingConstants.MARK_WEBAPP_URL, AppPathService.getBaseUrl(request)); model.put(RatingConstants.MARK_LOCALE, getLocale()); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_MODIFY_VOTE_TYPE, request.getLocale(), model); strHtml = template.getHtml(); } if (StringUtils.isNotBlank(strHtml)) { result.setHtmlContent(strHtml); } else { result.setRedirect( AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP)); } return result; }
From source file:fr.paris.lutece.plugins.suggest.web.action.MassChangeCategorySuggestSubmitAction.java
/** * {@inheritDoc}/*from w w w .java 2s . c o m*/ */ @Override public IPluginActionResult process(HttpServletRequest request, HttpServletResponse response, AdminUser adminUser, SuggestAdminSearchFields searchFields) throws AccessDeniedException { IPluginActionResult result = new DefaultPluginActionResult(); String strIdCategory = request.getParameter(PARAMETER_ID_CATEGORY); Plugin plugin = getPlugin(); int nIdCategory = SuggestUtils.getIntegerParameter(strIdCategory); int nIdSuggestSubmit; String strRedirect = StringUtils.EMPTY; if ((searchFields.getSelectedSuggestSubmit() != null) && !searchFields.getSelectedSuggestSubmit().isEmpty()) { UrlItem url = new UrlItem( AppPathService.getBaseUrl(request) + JSP_CONFIRM_CHANGE_SUGGEST_SUBMIT_CATEGORY); url.addParameter(PARAMETER_ID_CATEGORY, nIdCategory); //test All ressource selected before update for (String strIdSuggestSubmit : searchFields.getSelectedSuggestSubmit()) { if (StringUtils.isNotBlank(strIdSuggestSubmit) && StringUtils.isNumeric(strIdSuggestSubmit)) { nIdSuggestSubmit = SuggestUtils.getIntegerParameter(strIdSuggestSubmit); SuggestSubmit suggestSubmit = SuggestSubmitService.getService() .findByPrimaryKey(nIdSuggestSubmit, false, plugin); if ((suggestSubmit == null) || !RBACService.isAuthorized(Suggest.RESOURCE_TYPE, SuggestUtils.EMPTY_STRING + suggestSubmit.getSuggest().getIdSuggest(), SuggestResourceIdService.PERMISSION_MANAGE_SUGGEST_SUBMIT, adminUser)) { throw new AccessDeniedException(); } url.addParameter(PARAMETER_SELECTED_SUGGEST_SUBMIT, nIdSuggestSubmit); } } strRedirect = url.getUrl(); } else { strRedirect = AdminMessageService.getMessageUrl(request, MESSAGE_YOU_MUST_SELECT_SUGGEST_SUBMIT, AdminMessage.TYPE_INFO); } result.setRedirect(strRedirect); return result; }
From source file:fr.paris.lutece.plugins.directory.modules.pdfproducerarchive.web.action.MassExportZipAction.java
/** * {@inheritDoc}/*from w w w .ja v a2 s . com*/ */ public IPluginActionResult process(HttpServletRequest request, HttpServletResponse response, AdminUser adminUser, DirectoryAdminSearchFields sessionFields) throws AccessDeniedException { IPluginActionResult result = new DefaultPluginActionResult(); String strRedirect = StringUtils.EMPTY; if ((sessionFields.getSelectedRecords() != null) && !sessionFields.getSelectedRecords().isEmpty()) { String strIdDirectory = request.getParameter(DirectoryUtils.PARAMETER_ID_DIRECTORY); UrlItem url = new UrlItem(AppPathService.getBaseUrl(request) + JSP_CONFIRM_ADD_ZIP_BASKET); url.addParameter(DirectoryUtils.PARAMETER_ID_DIRECTORY, strIdDirectory); for (String strIdRecord : sessionFields.getSelectedRecords()) { if (StringUtils.isNotBlank(strIdRecord) && StringUtils.isNumeric(strIdRecord)) { url.addParameter(DirectoryUtils.PARAMETER_ID_DIRECTORY_RECORD, strIdRecord); } } strRedirect = url.getUrl(); } else { strRedirect = AdminMessageService.getMessageUrl(request, DirectoryUtils.MESSAGE_SELECT_RECORDS, AdminMessage.TYPE_INFO); } result.setRedirect(strRedirect); return result; }
From source file:edu.ku.brc.specify.utilapps.morphbank.BaseFileNameParser.java
/** * @param fieldValue/*from ww w . j a v a 2 s . c o m*/ * @return */ private String getTrimmedFileName(final String fieldNameValue) { UIFieldFormatterIFace fmtr = fldInfo.getFormatter(); if (fmtr != null) { if (fmtr.isNumeric()) { String[] tokens = pattern.split(fieldNameValue); if (tokens.length == 0 || !StringUtils.isNumeric(tokens[0])) return null; return (String) fmtr.formatFromUI(tokens[0]); } if (fieldNameValue.length() > fmtr.getLength()) { String baseValue = fieldNameValue.substring(0, fmtr.getLength()); if (fmtr.isValid(baseValue)) { return baseValue; } return null; } } return fieldNameValue; }
From source file:com.impetus.client.oraclenosql.schemamanager.OracleNoSQLSchemaManager.java
@Override protected boolean initiateClient() { String[] hostsList = new String[hosts.length]; int count = 0; for (String host : hosts) { if (host == null || !StringUtils.isNumeric(port) || port.isEmpty()) { logger.error("Host or port should not be null / port should be numeric"); throw new IllegalArgumentException("Host or port should not be null / port should be numeric"); }//from w w w . ja v a2 s . c o m hostsList[count] = host + ":" + port; count++; } KVStoreConfig kconfig = new KVStoreConfig(databaseName, hostsList); if (!securityProps.isEmpty()) { kconfig.setSecurityProperties(securityProps); } try { if (userName != null && password != null) { kvStore = KVStoreFactory.getStore(kconfig, new PasswordCredentials(userName, password.toCharArray()), null); } else { kvStore = KVStoreFactory.getStore(kconfig); } tableAPI = kvStore.getTableAPI(); } catch (FaultException e) { logger.error("Unable to get KVStore. Caused by ", e); throw new KunderaException("Unable to get KVStore. Caused by ", e); } return true; }
From source file:edu.ku.brc.specify.toycode.RegAdder.java
/** * @param trackItemId/*from w w w . ja va 2 s .c o m*/ * @param value * @param pStmt */ private void doTrackUpdate(final int trackItemId, final String value, final PreparedStatement pStmt) throws SQLException { if (!StringUtils.contains(value, ".") && StringUtils.isNumeric(value) && value.length() < 10) { pStmt.setInt(1, Integer.parseInt(value)); pStmt.setNull(2, java.sql.Types.VARCHAR); } else if (value.length() < STR_SIZE + 1) { pStmt.setNull(1, java.sql.Types.INTEGER); pStmt.setString(2, value); } else { String v = value.substring(0, STR_SIZE); System.err.println( "Error - On line " + lineNo + " Value[" + value + "] too big trunccating to[" + v + "]"); pStmt.setNull(1, java.sql.Types.INTEGER); pStmt.setString(2, v); } pStmt.setInt(3, trackItemId); int rv = pStmt.executeUpdate(); if (rv != 1) { throw new RuntimeException("Error insert trackitem for Id: " + trackItemId); } }
From source file:edu.ku.brc.specify.prefs.FormattingPrefsPanel.java
/** * //w w w. j a v a2 s. c o m */ protected void fillDateFormat() { String currentFormat = AppPreferences.getRemote().get("ui.formatting.scrdateformat", null); TimeZone tz = TimeZone.getDefault(); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()); dateFormatter.setTimeZone(tz); String dateStr = dateFormatter.format(Calendar.getInstance().getTime()); Character ch = null; for (int i = 0; i < 10; i++) { if (!StringUtils.isNumeric(dateStr.substring(i, i + 1))) { ch = dateStr.charAt(i); break; } } if (ch != null) { boolean skip = false; Vector<String> formats = new Vector<String>(); if (ch == '/') { addFormats(formats, '/'); skip = true; } if (ch != '.') { addFormats(formats, '.'); skip = true; } if (ch != '-') { addFormats(formats, '-'); skip = true; } if (!skip) { addFormats(formats, ch); } int selectedInx = 0; int inx = 0; DefaultComboBoxModel model = (DefaultComboBoxModel) dateFieldCBX.getModel(); for (String fmt : formats) { model.addElement(fmt); if (currentFormat != null && currentFormat.equals(fmt)) { selectedInx = inx; } inx++; } dateFieldCBX.getComboBox().setSelectedIndex(selectedInx); } }