List of usage examples for org.apache.commons.lang StringUtils upperCase
public static String upperCase(String str)
Converts a String to upper case as per String#toUpperCase() .
From source file:org.dspace.storage.rdbms.MigrationUtils.java
/** * Drop a given Database Constraint (based on the current database type). * Returns a "checksum" for this migration which can be used as part of * a Flyway Java migration/*from w w w . j a v a2 s. c o m*/ * * @param connection the current Database connection * @param tableName the name of the table the constraint applies to * @param columnName the name of the column the constraint applies to * @param constraintSuffix Only used for PostgreSQL, whose constraint naming convention depends on a suffix (key, fkey, etc) * @return migration checksum as an Integer * @throws SQLException if a database error occurs */ public static Integer dropDBConstraint(Connection connection, String tableName, String columnName, String constraintSuffix) throws SQLException { Integer checksum = -1; // First, in order to drop the appropriate Database constraint, we // must determine the unique name of the constraint. As constraint // naming is DB specific, this is dependent on our DB Type DatabaseMetaData meta = connection.getMetaData(); // NOTE: We use "findDbKeyword()" here as it won't cause // DatabaseManager.initialize() to be called (which in turn re-calls Flyway) String dbtype = DatabaseManager.findDbKeyword(meta); String constraintName = null; String constraintNameSQL = null; switch (dbtype) { case DatabaseManager.DBMS_POSTGRES: // In Postgres, constraints are always named: // {tablename}_{columnname(s)}_{suffix} // see: http://stackoverflow.com/a/4108266/3750035 constraintName = StringUtils.lowerCase(tableName) + "_" + StringUtils.lowerCase(columnName) + "_" + StringUtils.lowerCase(constraintSuffix); break; case DatabaseManager.DBMS_ORACLE: // In Oracle, constraints are listed in the USER_CONS_COLUMNS table constraintNameSQL = "SELECT CONSTRAINT_NAME " + "FROM USER_CONS_COLUMNS " + "WHERE TABLE_NAME = ? AND COLUMN_NAME = ?"; break; case DatabaseManager.DBMS_H2: // In H2, constraints are listed in the "information_schema.constraints" table constraintNameSQL = "SELECT DISTINCT CONSTRAINT_NAME " + "FROM information_schema.constraints " + "WHERE table_name = ? AND column_list = ?"; break; default: throw new SQLException("DBMS " + dbtype + " is unsupported in this migration."); } // If we have a SQL query to run for the constraint name, then run it if (constraintNameSQL != null) { // Run the query to obtain the constraint name, passing it the parameters PreparedStatement statement = connection.prepareStatement(constraintNameSQL); statement.setString(1, StringUtils.upperCase(tableName)); statement.setString(2, StringUtils.upperCase(columnName)); try { ResultSet results = statement.executeQuery(); if (results.next()) { constraintName = results.getString("CONSTRAINT_NAME"); } results.close(); } finally { statement.close(); } } // As long as we have a constraint name, drop it if (constraintName != null && !constraintName.isEmpty()) { // This drop constaint SQL should be the same in all databases String dropConstraintSQL = "ALTER TABLE " + tableName + " DROP CONSTRAINT " + constraintName; PreparedStatement statement = connection.prepareStatement(dropConstraintSQL); try { statement.execute(); } finally { statement.close(); } // Return the size of the query we just ran // This will be our "checksum" for this Flyway migration (see getChecksum()) checksum = dropConstraintSQL.length(); } return checksum; }
From source file:org.eclipse.smarthome.binding.homematic.internal.communicator.AbstractHomematicGateway.java
/** * Creates a virtual device for handling variables, scripts and other special gateway functions. *//*from w ww .j a v a2 s . c o m*/ private HmDevice createGatewayDevice() { String type = String.format("%s-%s", HmDevice.TYPE_GATEWAY_EXTRAS, StringUtils.upperCase(id)); HmDevice device = new HmDevice(HmDevice.ADDRESS_GATEWAY_EXTRAS, getDefaultInterface(), type, config.getGatewayInfo().getId(), null, null); device.setName(HmDevice.TYPE_GATEWAY_EXTRAS); device.addChannel(new HmChannel(HmChannel.TYPE_GATEWAY_EXTRAS, HmChannel.CHANNEL_NUMBER_EXTRAS)); device.addChannel(new HmChannel(HmChannel.TYPE_GATEWAY_VARIABLE, HmChannel.CHANNEL_NUMBER_VARIABLE)); device.addChannel(new HmChannel(HmChannel.TYPE_GATEWAY_SCRIPT, HmChannel.CHANNEL_NUMBER_SCRIPT)); return device; }
From source file:org.egov.stms.transactions.service.SewerageReassignService.java
public Map<String, String> getEmployees() { final String designationStr = sewerageWorkflowService.getDesignationForCscOperatorWorkFlow(); final String departmentStr = sewerageWorkflowService.getDepartmentForReassignment(); List<String> departmentCodes = departmentService .getDepartmentsByNames(Arrays.asList(departmentStr.split(","))).stream().map(Department::getCode) .collect(Collectors.toList()); List<String> designationCodes = designationService .getDesignationsByNames(Arrays.asList(StringUtils.upperCase(designationStr).split(","))).stream() .map(Designation::getCode).collect(Collectors.toList()); List<Assignment> assignments = new ArrayList<>(); departmentCodes.stream().forEach(deptCode -> assignments .addAll(assignmentService.findByDepartmentCodeAndDesignationCode(deptCode, designationCodes))); assignments.removeAll(assignmentService.getAllAssignmentsByEmpId(ApplicationThreadLocals.getUserId())); return assignments.stream() .collect(Collectors.toMap( assignment -> new StringBuffer().append(assignment.getId()).append("-") .append(assignment.getPosition().getId()).toString(), assignment -> new StringBuffer().append(assignment.getEmployee().getName()).append("-") .append(assignment.getPosition().getName()).toString())); }
From source file:org.fosstrak.ale.util.ECReportSetEnum.java
/** * compare a given input string to the report set enumerations values. * the method is save for illegal input arguments (eg. null or not existing report set type). * further the method is case insensitive * @param setEnum the enumeration value to compare to. * @param name the value to check from the enumeration. * @return true if same enumeration value, false otherwise. *///from w ww. jav a 2 s . co m public static boolean isSameECReportSet(ECReportSetEnum setEnum, String name) { try { return setEnum.equals(ECReportSetEnum.valueOf(StringUtils.upperCase(name))); } catch (Exception ex) { LOG.error("you provided an illegal report set enum value: " + name, ex); } return false; }
From source file:org.fosstrak.alecc.util.CCReportSetEnum.java
/** * compare a given input string to the report set enumerations values. * the method is save for illegal input arguments (eg. null or not existing report set type). * further the method is case insensitive * @param setEnum the enumeration value to compare to. * @param name the value to check from the enumeration. * @return true if same enumeration value, false otherwise. *//* w w w. ja va 2s. co m*/ public static boolean isSameCCReportSet(CCReportSetEnum setEnum, String name) { try { return setEnum.equals(CCReportSetEnum.valueOf(StringUtils.upperCase(name))); } catch (Exception ex) { LOG.error("you provided an illegal report set enum value: " + name, ex); } return false; }
From source file:org.geoserver.security.iride.entity.IrideRole.java
/** * Constructor.//from ww w.j a va2 s . co m * * @param code <code>IRIDE</code> Role code * @param domain <code>IRIDE</code> Role domain code * @throws IllegalArgumentException if code or domain are either {@code null} * or empty (as per {@link StringUtils#isEmpty(String)}) strings */ public IrideRole(String code, String domain) { Preconditions.checkArgument(StringUtils.isNotBlank(code)); Preconditions.checkArgument(StringUtils.isNotBlank(domain)); this.code = StringUtils.upperCase(code); this.domain = StringUtils.upperCase(domain); }
From source file:org.homemotion.util.impl.IpLocatorImpl.java
/** * Other than the getters & setters, this is the only method visible to the * outside world//from ww w . j a va 2s . c o m * * @param ip * The ip address to be located * @return IPLocator instance * @throws IOException * in case of any error/exception */ public IpLocation locate(String ip) throws IOException { final String url = HOSTIP_LOOKUP_URL + ip; final URL u = new URL(url); final List<String> response = getContent(u); final Pattern splitterPattern = Pattern.compile(":"); final IpLocation ipl = new IpLocation(); for (final String token : response) { final String[] keyValue = splitterPattern.split(token); if (keyValue.length != 2) { continue; } final String key = StringUtils.upperCase(keyValue[0]); final String value = keyValue[1]; if (KEY_COUNTRY.equals(key)) { ipl.setCountry(value); } else if (KEY_CITY.equals(key)) { ipl.setCity(value); } else if (KEY_LATITUDE.equals(key)) { ipl.setLatitude(stringToFloat(value)); } else if (KEY_LONGITUDE.equals(key)) { ipl.setLongitude(stringToFloat(value)); } } return ipl; }
From source file:org.isatools.isatab.export.sra.SraExportPipelineComponent.java
/** * Builds the SRA {@link PlatformType}, this is partly taken from the ISATAB "sequencing" protocol and partly from the * "platform" field in the ISATAB assay section (investigation file). * <p/>//from w w w. j a v a2 s.c o m * Some of these parameters are mandatory in SRA, and/or constrained to certain values, so the method raises an * exception in case they're not defined. * TODO: this could be replaced by relying on the ISA Parameter Value[sequencing instrument] available from latest configuration */ protected PlatformType buildExportedPlatform(final Assay assay) { ProtocolApplication pApp = getProtocol(assay, "nucleic acid sequencing"); if (pApp == null) { return null; } Protocol proto = pApp.getProtocol(); // Get the instrument information associated to that sequencing protocol // TODO: PRS: rely on a ISA Parameter Value[sequencing instrument] instead to obtain the information // TODO: PRS: check against the declared ISA assay platform String sequencinginst = getParameterValue(assay, pApp, "sequencing instrument", true); PlatformType.LS454.INSTRUMENTMODEL.Enum.forString(sequencinginst); if (("454 GS".equalsIgnoreCase(sequencinginst) || "454 GS 20".equalsIgnoreCase(sequencinginst) || "454 GS FLX".equalsIgnoreCase(sequencinginst) || "454 GS FLX Titanium".equalsIgnoreCase(sequencinginst) || "454 GS Junior".equalsIgnoreCase(sequencinginst) || "GS20".equalsIgnoreCase(sequencinginst) || "GS FLX".equalsIgnoreCase(sequencinginst))) { // todo finish } String xinstrument = null; for (ProtocolComponent pcomp : proto.getComponents()) { for (OntologyTerm ctype : pcomp.getOntologyTerms()) { String pctypeStr = ctype.getName().toLowerCase(); if (pctypeStr.contains("instrument") || pctypeStr.contains("sequencer")) { xinstrument = pcomp.getValue(); break; } } } if (xinstrument == null) { String msg = MessageFormat.format( "The assay file of type {0} / {1} for study {2} has no Instrument declared in the ISA Sequencing Protocol", assay.getMeasurement().getName(), assay.getTechnologyName(), assay.getStudy().getAcc()); throw new TabMissingValueException(msg); } PlatformType xplatform = PlatformType.Factory.newInstance(); String platform = StringUtils.upperCase(assay.getAssayPlatform()); if (platform.toLowerCase().contains("454")) { //if ("LS454".equalsIgnoreCase(platform)) { PlatformType.LS454 ls454 = PlatformType.LS454.Factory.newInstance(); ls454.setINSTRUMENTMODEL(PlatformType.LS454.INSTRUMENTMODEL.Enum.forString(xinstrument)); //String keyseqStr = "TACG"; //ls454.setKEYSEQUENCE(keyseqStr); String flowSeqstr = "TACG"; ls454.setFLOWSEQUENCE(flowSeqstr); int flowCount = 800; //String flowCountStr = getParameterValue(assay, pApp, "Flow Count", false); //ls454.setFLOWCOUNT(new BigInteger(checkNumericParameter(flowCountStr))); ls454.setFLOWCOUNT(BigInteger.valueOf(flowCount)); xplatform.setLS454(ls454); } else if (platform.toLowerCase().contains("illumina")) { PlatformType.ILLUMINA illumina = PlatformType.ILLUMINA.Factory.newInstance(); illumina.setINSTRUMENTMODEL(PlatformType.ILLUMINA.INSTRUMENTMODEL.Enum.forString(xinstrument)); illumina.setCYCLESEQUENCE(getParameterValue(assay, pApp, "Cycle Sequence", true)); illumina.setCYCLECOUNT( new BigInteger(checkNumericParameter(getParameterValue(assay, pApp, "Cycle Count", true)))); xplatform.setILLUMINA(illumina); } else if (platform.toLowerCase().contains("helicos")) { //("HELICOS".equalsIgnoreCase(platform)) { PlatformType.HELICOS helicos = PlatformType.HELICOS.Factory.newInstance(); helicos.setINSTRUMENTMODEL(PlatformType.HELICOS.INSTRUMENTMODEL.Enum.forString(xinstrument)); helicos.setFLOWSEQUENCE(getParameterValue(assay, pApp, "Flow Sequence", true)); helicos.setFLOWCOUNT( new BigInteger(checkNumericParameter(getParameterValue(assay, pApp, "Flow Count", true)))); xplatform.setHELICOS(helicos); } else if (platform.toLowerCase().contains("solid")) { // ("ABI SOLID".equalsIgnoreCase(platform) || "ABI_SOLID".equalsIgnoreCase(platform)) { PlatformType.ABISOLID abisolid = PlatformType.ABISOLID.Factory.newInstance(); abisolid.setINSTRUMENTMODEL(PlatformType.ABISOLID.INSTRUMENTMODEL.Enum.forString(xinstrument)); { String colorMatrix = getParameterValue(assay, pApp, "Color Matrix", false); // single dibase colours are semicolon-separated if (colorMatrix != null) { PlatformType.ABISOLID.COLORMATRIX xcolorMatrix = PlatformType.ABISOLID.COLORMATRIX.Factory .newInstance(); String dibases[] = colorMatrix.split("\\;"); if (dibases != null && dibases.length > 0) { PlatformType.ABISOLID.COLORMATRIX.COLOR xcolors[] = new PlatformType.ABISOLID.COLORMATRIX.COLOR[dibases.length]; int i = 0; for (String dibase : dibases) { PlatformType.ABISOLID.COLORMATRIX.COLOR xcolor = PlatformType.ABISOLID.COLORMATRIX.COLOR.Factory .newInstance(); xcolor.setDibase(dibase); xcolors[i++] = xcolor; } xcolorMatrix.setCOLORArray(xcolors); abisolid.setCOLORMATRIX(xcolorMatrix); } } } { String colorMatrixCode = getParameterValue(assay, pApp, "Color Matrix Code", false); if (colorMatrixCode != null) { abisolid.setCOLORMATRIXCODE(colorMatrixCode); } } // TODO: remove, deprecated abisolid.setCYCLECOUNT ( new BigInteger ( getParameterValue ( assay, papp, "Cycle Count", true ) ) ); abisolid.setSEQUENCELENGTH( new BigInteger(checkNumericParameter(getParameterValue(assay, pApp, "Cycle Count", false)))); xplatform.setABISOLID(abisolid); } else { throw new TabInvalidValueException(MessageFormat.format( "The SRA platform ''{0}'' for the assay ''{1}''/''{2}'' in the study ''{3}'' is invalid. Please supply the Platform information for the Assay in the Investigation file", platform, assay.getMeasurement().getName(), assay.getTechnologyName(), assay.getStudy().getAcc())); } return xplatform; }
From source file:org.jamwiki.parser.jflex.ParserFunctionUtil.java
/** * Parse the {{uc:}} parser function./* w w w .java 2 s.c o m*/ */ private static String parseUpperCase(ParserInput parserInput, String[] parserFunctionArgumentArray) { return StringUtils.upperCase(parserFunctionArgumentArray[0]); }
From source file:org.jboss.bqt.jdbc.sql.lang.Symbol.java
private void computeCanonicalNameAndHash() { if (canonicalName == null) { canonicalName = StringUtils.upperCase(name); } }