Example usage for org.apache.commons.lang WordUtils uncapitalize

List of usage examples for org.apache.commons.lang WordUtils uncapitalize

Introduction

In this page you can find the example usage for org.apache.commons.lang WordUtils uncapitalize.

Prototype

public static String uncapitalize(String str) 

Source Link

Document

Uncapitalizes all the whitespace separated words in a String.

Usage

From source file:org.codehaus.groovy.grails.plugins.springsecurity.AnnotationFilterInvocationDefinition.java

private void findControllerAnnotations(final GrailsControllerClass controllerClass,
        final Map<String, Map<String, Set<String>>> actionRoleMap,
        final Map<String, Set<String>> classRoleMap) {

    Class<?> clazz = controllerClass.getClazz();
    String controllerName = WordUtils.uncapitalize(controllerClass.getName());

    Secured annotation = clazz.getAnnotation(Secured.class);
    if (annotation != null) {
        classRoleMap.put(controllerName, asSet(annotation.value()));
    }// ww  w .j  a v  a  2 s. co  m

    Map<String, Set<String>> annotatedClosureNames = findActionRoles(clazz);
    if (annotatedClosureNames != null) {
        actionRoleMap.put(controllerName, annotatedClosureNames);
    }
}

From source file:org.gradle.api.Attribute.java

/**
 * Creates a new attribute of  the given type, inferring the name of the attribute from the simple type name.
 * This method is useful when there's supposely only one attribute of a specific type in a container, so there's
 * no need to distinguish by name (but the returned type doesn't enforce it_. There's no guarantee that subsequent
 * calls to this method with the same attributes would either return the same instance or different instances
 * of {@link Attribute}, so consumers are required to compare the attributes with the {@link #equals(Object)}
 * method./* w  w  w  . j a va2  s . c  o m*/
 * @param type the class of the attribute
 * @param <T> the type of the attribute
 * @return an attribute with the given name and type
 */
public static <T> Attribute<T> of(Class<T> type) {
    return of(WordUtils.uncapitalize(type.getSimpleName()), type);
}

From source file:org.gradle.jvm.plugins.JvmTestSuiteBasePlugin.java

@BinaryTasks
void createJvmTestSuiteTasks(ModelMap<Task> tasks, final JvmTestSuiteBinarySpecInternal binary,
        final @Path("buildDir") File buildDir) {
    final JvmAssembly jvmAssembly = ((WithJvmAssembly) binary).getAssembly();
    tasks.create(testTaskNameFor(binary), Test.class, new Action<Test>() {
        @Override/*from  w ww .ja  v  a 2 s .  c  o m*/
        public void execute(final Test test) {
            test.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
            test.setDescription(String.format("Runs %s.", WordUtils.uncapitalize(binary.getDisplayName())));
            test.dependsOn(jvmAssembly);
            test.setTestClassesDir(binary.getClassesDir());
            test.setClasspath(binary.getRuntimeClasspath());
            configureReports((JvmTestSuiteBinarySpecInternal) binary, test);
        }

        private void configureReports(JvmTestSuiteBinarySpecInternal binary, Test test) {
            // todo: improve configuration of reports
            TestTaskReports reports = test.getReports();
            File reportsDirectory = new File(buildDir, "reports");
            File reportsOutputDirectory = binary.getNamingScheme().getOutputDirectory(reportsDirectory);
            File htmlDir = new File(reportsOutputDirectory, "tests");
            File xmlDir = new File(buildDir, "test-results");
            File xmlDirOutputDirectory = binary.getNamingScheme().getOutputDirectory(xmlDir);
            File binDir = new File(xmlDirOutputDirectory, "binary");
            reports.getHtml().setDestination(htmlDir);
            reports.getJunitXml().setDestination(xmlDirOutputDirectory);
            test.setBinResultsDir(binDir);
        }
    });
}

From source file:org.gradle.jvm.test.internal.JvmTestSuiteRules.java

private static void createJvmTestSuiteTasks(final JvmTestSuiteBinarySpec binary, final JvmAssembly jvmAssembly,
        final File buildDir) {
    binary.getTasks().create(testTaskNameFor(binary), Test.class, new Action<Test>() {
        @Override//from  w w w .j a v  a  2  s  .  co  m
        public void execute(final Test test) {
            test.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
            test.setDescription(String.format("Runs %s.", WordUtils.uncapitalize(binary.getDisplayName())));
            test.dependsOn(jvmAssembly);
            test.setTestClassesDir(binary.getClassesDir());
            test.setClasspath(binary.getRuntimeClasspath());
            configureReports((JvmTestSuiteBinarySpecInternal) binary, test);
        }

        private void configureReports(JvmTestSuiteBinarySpecInternal binary, Test test) {
            // todo: improve configuration of reports
            TestTaskReports reports = test.getReports();
            File reportsDirectory = new File(buildDir, "reports");
            File reportsOutputDirectory = binary.getNamingScheme().getOutputDirectory(reportsDirectory);
            File htmlDir = new File(reportsOutputDirectory, "tests");
            File xmlDir = new File(buildDir, "test-results");
            File xmlDirOutputDirectory = binary.getNamingScheme().getOutputDirectory(xmlDir);
            File binDir = new File(xmlDirOutputDirectory, "binary");
            reports.getHtml().setDestination(htmlDir);
            reports.getJunitXml().setDestination(xmlDirOutputDirectory);
            test.setBinResultsDir(binDir);
        }
    });
}

From source file:org.gradle.jvm.test.internal.JvmTestSuites.java

public static void createJvmTestSuiteTasks(final ModelMap<Task> tasks, final JvmTestSuiteBinarySpec binary,
        final JvmAssembly jvmAssembly, final ServiceRegistry registry, final ModelSchemaStore schemaStore,
        final File buildDir) {
    tasks.create(testTaskNameFor(binary), Test.class, new Action<Test>() {
        @Override/*from   w  w  w .j a va2s  .  c  o m*/
        public void execute(final Test test) {
            test.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
            test.setDescription(String.format("Runs %s.", WordUtils.uncapitalize(binary.getDisplayName())));
            test.dependsOn(jvmAssembly);
            test.setTestClassesDir(binary.getClassesDir());
            String testedComponentName = binary.getTestSuite().getTestedComponent();
            JvmComponentSpec testedComponent = testedComponentName != null
                    ? getTestedComponent(registry, testedComponentName)
                    : null;
            test.setClasspath(runtimeClasspathForTestBinary(binary, testedComponent, registry, schemaStore));
            configureReports(test);
            binary.getTasks().add(test);
        }

        private void configureReports(Test test) {
            // todo: improve configuration of reports
            TestTaskReports reports = test.getReports();
            File reportsDirectory = new File(buildDir, "reports");
            File htmlDir = new File(reportsDirectory, "tests");
            File xmlDir = new File(buildDir, "test-results");
            File binDir = new File(xmlDir, "binary");
            reports.getHtml().setDestination(htmlDir);
            reports.getJunitXml().setDestination(xmlDir);
            test.setBinResultsDir(binDir);
        }
    });
}

From source file:org.gradle.play.plugins.PlayTestPlugin.java

@Mutate
void createTestTasks(ModelMap<Task> tasks,
        @Path("binaries") ModelMap<PlayApplicationBinarySpecInternal> playBinaries,
        final PlayPluginConfigurations configurations, final FileResolver fileResolver,
        final ProjectIdentifier projectIdentifier, @Path("buildDir") final File buildDir) {
    for (final PlayApplicationBinarySpecInternal binary : playBinaries) {
        final PlayToolProvider playToolProvider = binary.getToolChain().select(binary.getTargetPlatform());
        final FileCollection testCompileClasspath = getTestCompileClasspath(binary, playToolProvider,
                configurations);//from   w ww .  ja va  2 s. c  o m

        final String testCompileTaskName = binary.getTasks().taskName("compile", "tests");
        final File testSourceDir = fileResolver.resolve("test");
        final FileCollection testSources = new SimpleFileCollection(testSourceDir).getAsFileTree()
                .matching(new PatternSet().include("**/*.scala", "**/*.java"));
        final File testClassesDir = new File(buildDir,
                String.format("%s/testClasses", binary.getProjectScopedName()));
        tasks.create(testCompileTaskName, PlatformScalaCompile.class, new Action<PlatformScalaCompile>() {
            public void execute(PlatformScalaCompile scalaCompile) {
                scalaCompile.setDescription(
                        "Compiles the scala and java test sources for the " + binary.getDisplayName() + ".");

                scalaCompile.setClasspath(testCompileClasspath);

                scalaCompile.dependsOn(binary.getBuildTask());
                scalaCompile.setPlatform(binary.getTargetPlatform().getScalaPlatform());
                scalaCompile.setDestinationDir(testClassesDir);
                scalaCompile.setSource(testSources);
                String targetCompatibility = binary.getTargetPlatform().getJavaPlatform()
                        .getTargetCompatibility().getMajorVersion();
                scalaCompile.setSourceCompatibility(targetCompatibility);
                scalaCompile.setTargetCompatibility(targetCompatibility);

                IncrementalCompileOptions incrementalOptions = scalaCompile.getScalaCompileOptions()
                        .getIncrementalOptions();
                incrementalOptions.setAnalysisFile(new File(buildDir,
                        String.format("tmp/scala/compilerAnalysis/%s.analysis", testCompileTaskName)));
            }
        });

        final String testTaskName = binary.getTasks().taskName("test");
        final File binaryBuildDir = new File(buildDir, binary.getProjectScopedName());
        tasks.create(testTaskName, Test.class, new Action<Test>() {
            public void execute(Test test) {
                test.setDescription(String.format("Runs %s.", WordUtils.uncapitalize(binary.getDisplayName())));

                test.setClasspath(getRuntimeClasspath(testClassesDir, testCompileClasspath));

                test.setTestClassesDir(testClassesDir);
                test.setBinResultsDir(new File(binaryBuildDir, String.format("results/%s/bin", testTaskName)));
                test.getReports().getJunitXml().setDestination(new File(binaryBuildDir, "reports/test/xml"));
                test.getReports().getHtml().setDestination(new File(binaryBuildDir, "reports/test"));
                test.dependsOn(testCompileTaskName);
                test.setTestSrcDirs(Arrays.asList(testSourceDir));
                test.setWorkingDir(projectIdentifier.getProjectDir());
            }
        });
        binary.getTasks().add(tasks.get(testTaskName));
    }
}

From source file:org.onehippo.cms7.essentials.dashboard.utils.TemplateUtils.java

private static String extractPropertyName(final String identifier) {
    if (identifier.startsWith("get")) {
        final String methodName = identifier.substring(3);
        if (methodName.length() > 0) {
            return WordUtils.uncapitalize(methodName);
        }//from  w  ww.  j a  v  a  2s .  c  o m
    }

    return null;
}

From source file:org.oscarehr.common.web.CodeSearchService.java

@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    List<LabelValueBean> results = new ArrayList<LabelValueBean>();
    String codingSystem = request.getParameter("codingSystem");

    AbstractCodeSystemDao dao = (AbstractCodeSystemDao) SpringUtils
            .getBean(WordUtils.uncapitalize(codingSystem) + "Dao");

    if (request.getParameter("term") != null && request.getParameter("term").length() > 0) {
        List<AbstractCodeSystemModel> r = dao.searchCode(request.getParameter("term"));
        for (AbstractCodeSystemModel result : r) {
            results.add(new LabelValueBean(result.getDescription(), result.getCode()));
        }/*from   w w  w. j  a va  2 s .  c o  m*/
    }
    response.setContentType("text/x-json");
    JSONArray jsonArray = JSONArray.fromObject(results);
    jsonArray.write(response.getWriter());

    return null;
}

From source file:org.oscarehr.common.web.PregnancyAction.java

public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {//from   w  w w  .ja  va 2s  .c om
    Integer demographicNo = Integer.parseInt(request.getParameter("demographicNo"));
    String code = request.getParameter("code");
    String codeType = request.getParameter("codetype");

    //check for an existing pregnancy
    List<String> codes = new ArrayList<String>();
    codes.add("72892002");
    codes.add("47200007");
    codes.add("16356006");
    codes.add("34801009");
    List<Episode> existingEpisodes = episodeDao.findCurrentByCodeTypeAndCodes(demographicNo, "SnomedCore",
            codes);
    if (existingEpisodes.size() > 0) {
        request.setAttribute("error",
                "There is already a pregnancy in progress. Please close the existing one before creating a new one.");
        return mapping.findForward("success");
    }

    AbstractCodeSystemDao dao = (AbstractCodeSystemDao) SpringUtils
            .getBean(WordUtils.uncapitalize(codeType) + "Dao");
    AbstractCodeSystemModel mod = dao.findByCode(code);

    if (mod == null) {
        request.setAttribute("error",
                "There was an internal error processing this request, please contact your system administrator");
        return mapping.findForward("success");
    }

    //create pregnancy episode
    Episode e = new Episode();
    e.setCode(code);
    e.setCodingSystem(codeType);
    e.setDemographicNo(demographicNo);
    e.setDescription("");
    e.setLastUpdateTime(new Date());
    e.setLastUpdateUser(LoggedInInfo.loggedInInfo.get().loggedInProvider.getProviderNo());
    e.setStatus("Current");
    e.setStartDate(new Date());
    e.setDescription(mod.getDescription());
    episodeDao.persist(e);

    //start up a new ar on enhanced form
    try {
        FrmONAREnhancedRecord f = new FrmONAREnhancedRecord();
        Properties p = f.getFormRecord(demographicNo, 0);
        p.setProperty("episodeId", String.valueOf(e.getId()));
        f.saveFormRecord(p);
    } catch (SQLException ee) {
        MiscUtils.getLogger().error("Error", ee);
    }

    return mapping.findForward("success");
}

From source file:org.oscarehr.common.web.PregnancyAction.java

public ActionForward doMigrate(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {/*from   w ww.  ja  va2  s  .  com*/
    Integer demographicNo = Integer.parseInt(request.getParameter("demographicNo"));
    Episode e = null;
    //check for an existing pregnancy
    List<String> codes = new ArrayList<String>();
    codes.add("72892002");
    codes.add("47200007");
    codes.add("16356006");
    codes.add("34801009");
    List<Episode> existingEpisodes = episodeDao.findCurrentByCodeTypeAndCodes(demographicNo, "SnomedCore",
            codes);
    if (existingEpisodes.size() == 0) {
        //create the pregnancy episode 
        AbstractCodeSystemDao dao = (AbstractCodeSystemDao) SpringUtils
                .getBean(WordUtils.uncapitalize("SnomedCore") + "Dao");
        AbstractCodeSystemModel mod = dao.findByCode("72892002");

        if (mod == null) {
            request.setAttribute("error",
                    "There was an internal error processing this request, please contact your system administrator");
            return mapping.findForward("success");
        }

        //create pregnancy episode
        e = new Episode();
        e.setCode("72892002");
        e.setCodingSystem("SnomedCore");
        e.setDemographicNo(demographicNo);
        e.setDescription("");
        e.setLastUpdateTime(new Date());
        e.setLastUpdateUser(LoggedInInfo.loggedInInfo.get().loggedInProvider.getProviderNo());
        e.setStatus("Current");
        e.setStartDate(new Date());
        e.setDescription(mod.getDescription());
        episodeDao.persist(e);
    } else {
        e = existingEpisodes.get(0);
    }

    EctFormData.PatientForm[] pforms = EctFormData.getPatientForms(String.valueOf(demographicNo), "formONAR");
    if (pforms == null || pforms.length == 0) {
        request.setAttribute("message", "Error: Couldn't find existing AR2005 form");
        return mapping.findForward("migrate");
    }

    String formId = pforms[0].getFormId();

    FrmONARRecord ar2005 = new FrmONARRecord();
    Properties p = null;
    try {
        p = ar2005.getFormRecord(demographicNo, Integer.parseInt(formId));
    } catch (SQLException ex) {
        request.setAttribute("message", "Error: Couldn't read existing AR2005 form");
        return mapping.findForward("migrate");
    }

    FrmONAREnhancedRecord f = new FrmONAREnhancedRecord();
    Properties newProps = null;
    try {
        newProps = f.getFormRecord(demographicNo, 0);
    } catch (SQLException ex) {
        request.setAttribute("message", "Error: Couldn't create new enhanced form");
        return mapping.findForward("migrate");
    }
    newProps.setProperty("episodeId", String.valueOf(e.getId()));

    for (Object key : p.keySet()) {
        String val = p.getProperty((String) key);
        newProps.setProperty((String) key, val);
    }

    if (p.getProperty("pg1_msMarried", "").length() > 0) {
        newProps.setProperty("pg1_maritalStatus", "M");
    }
    if (p.getProperty("pg1_msCommonLaw", "").length() > 0) {
        newProps.setProperty("pg1_maritalStatus", "CL");
    }
    if (p.getProperty("pg1_msSingle", "").length() > 0) {
        newProps.setProperty("pg1_maritalStatus", "S");
    }

    if (p.getProperty("pg1_naDietRes", "").length() > 0) {
        newProps.setProperty("pg1_naDiet", "on");
    }
    if (p.getProperty("pg1_naDietBal", "").length() > 0) {
        newProps.setProperty("pg1_naDietN", "on");
    }
    if (p.getProperty("pg1_pExOther", "").length() > 0) {
        newProps.setProperty("pg1_pExOtherDesc", p.getProperty("pg1_pExOther", ""));
    }

    if (p.getProperty("pg1_pExOtherN", "").length() > 0) {
        newProps.setProperty("pg1_pExOther", "on");
    }
    if (p.getProperty("pg1_pExOtherA", "").length() > 0) {
        newProps.setProperty("pg1_pExOtherA", "on");
    }
    if (p.getProperty("pg1_geneticD", "").length() > 0) {
        newProps.setProperty("pg1_geneticD", "checked/checked");
    }

    int obxNum = 0;
    for (int x = 0; x < 6; x++) {
        int n = x + 1;
        if (p.getProperty("pg1_year" + n, "").length() > 0 || p.getProperty("pg1_sex" + n, "").length() > 0
                || p.getProperty("pg1_oh_gest" + n, "").length() > 0
                || p.getProperty("pg1_weight" + n, "").length() > 0
                || p.getProperty("pg1_length" + n, "").length() > 0
                || p.getProperty("pg1_place" + n, "").length() > 0
                || p.getProperty("pg1_svb" + n, "").length() > 0 || p.getProperty("pg1_cs" + n, "").length() > 0
                || p.getProperty("pg1_ass" + n, "").length() > 0
                || p.getProperty("pg1_oh_comments" + n, "").length() > 0) {
            obxNum = n;
        }
    }
    newProps.setProperty("obxhx_num", String.valueOf(obxNum));

    int rfNum = 0;
    for (int x = 0; x < 7; x++) {
        int n = x + 1;
        if (p.getProperty("c_riskFactors" + n, "").length() > 0
                || p.getProperty("c_planManage" + n, "").length() > 0) {
            rfNum = n;
        }
    }
    newProps.setProperty("rf_num", String.valueOf(rfNum));

    int svNum = 0;
    for (int x = 0; x < 18; x++) {
        int n = x + 1;
        if (p.getProperty("pg2_year" + n, "").length() > 0 || p.getProperty("pg2_gest" + n, "").length() > 0
                || p.getProperty("pg2_wt" + n, "").length() > 0 || p.getProperty("pg2_BP" + n, "").length() > 0
                || p.getProperty("pg2_urinePr" + n, "")
                        .length() > 0 /*|| p.getProperty("pg2_urineGl"+n,"").length()>0*/
                || p.getProperty("pg2_presn1" + n, "").length() > 0
                || p.getProperty("pg2_FHR" + n, "").length() > 0
                || p.getProperty("pg2_comments" + n, "").length() > 0) {
            svNum = n;
        }
    }
    for (int x = 0; x < 18; x++) {
        int n = x + 19;
        if (p.getProperty("pg3_year" + n, "").length() > 0 || p.getProperty("pg3_gest" + n, "").length() > 0
                || p.getProperty("pg3_wt" + n, "").length() > 0 || p.getProperty("pg3_BP" + n, "").length() > 0
                || p.getProperty("pg3_urinePr" + n, "")
                        .length() > 0 /*|| p.getProperty("pg3_urineGl"+n,"").length()>0*/
                || p.getProperty("pg3_presn1" + n, "").length() > 0
                || p.getProperty("pg3_FHR" + n, "").length() > 0
                || p.getProperty("pg3_comments" + n, "").length() > 0) {
            svNum = n;
        }
    }

    for (int x = 0; x < 18; x++) {
        int n = x + 37;
        if (p.getProperty("pg4_year" + n, "").length() > 0 || p.getProperty("pg4_gest" + n, "").length() > 0
                || p.getProperty("pg4_wt" + n, "").length() > 0 || p.getProperty("pg4_BP" + n, "").length() > 0
                || p.getProperty("pg4_urinePr" + n, "")
                        .length() > 0 /*|| p.getProperty("pg4_urineGl"+n,"").length()>0*/
                || p.getProperty("pg4_presn1" + n, "").length() > 0
                || p.getProperty("pg4_FHR" + n, "").length() > 0
                || p.getProperty("pg4_comments" + n, "").length() > 0) {
            svNum = n;
        }
    }

    newProps.setProperty("sv_num", String.valueOf(svNum));

    int usNum = 0;
    for (int x = 0; x < 4; x++) {
        int n = x + 1;
        if (p.getProperty("ar2_uDate" + n, "").length() > 0 || p.getProperty("ar2_uGA" + n, "").length() > 0
                || p.getProperty("ar2_uResults" + n, "").length() > 0) {
            usNum = n;
        }
    }
    newProps.setProperty("us_num", String.valueOf(usNum));

    //convert the subsequent visits in pages 3/4 to pg2_
    for (Object key : p.keySet()) {
        String val = p.getProperty((String) key);
        if (((String) key).startsWith("pg3")) {
            newProps.setProperty(((String) key).replaceAll("pg3", "pg2"), val);
        }
        if (((String) key).startsWith("pg4")) {
            newProps.setProperty(((String) key).replaceAll("pg4", "pg2"), val);
        }
    }

    //grab manual ones from the form
    newProps.setProperty("c_province", request.getParameter("c_province"));
    newProps.setProperty("pg1_language", request.getParameter("pg1_language"));
    newProps.setProperty("pg1_partnerEduLevel", request.getParameter("pg1_partnerEduLevel"));
    newProps.setProperty("pg1_eduLevel", request.getParameter("pg1_eduLevel"));
    newProps.setProperty("pg1_ethnicBgMother", request.getParameter("pg1_ethnicBgMother"));
    newProps.setProperty("pg1_ethnicBgFather", request.getParameter("pg1_ethnicBgFather"));
    newProps.setProperty("c_hinType", request.getParameter("c_hinType"));
    newProps.setProperty("pg1_box3", request.getParameter("pg1_box3"));
    newProps.setProperty("pg1_labHIV", request.getParameter("pg1_labHIV"));
    newProps.setProperty("pg1_labABO", request.getParameter("pg1_labABO"));
    newProps.setProperty("pg1_labRh", request.getParameter("pg1_labRh"));
    newProps.setProperty("pg1_labGC", request.getParameter("pg1_labGC"));
    newProps.setProperty("pg1_labChlamydia", request.getParameter("pg1_labChlamydia"));
    newProps.setProperty("pg1_labRubella", request.getParameter("pg1_labRubella"));
    newProps.setProperty("pg1_labHBsAg", request.getParameter("pg1_labHBsAg"));
    newProps.setProperty("pg1_labVDRL", request.getParameter("pg1_labVDRL"));
    newProps.setProperty("pg1_labSickle", request.getParameter("pg1_labSickle"));
    newProps.setProperty("ar2_bloodGroup", request.getParameter("ar2_bloodGroup"));
    newProps.setProperty("ar2_rh", request.getParameter("ar2_rh"));
    newProps.setProperty("ar2_strep", request.getParameter("ar2_strep"));
    newProps.setProperty("ar2_lab2GTT", request.getParameter("ar2_lab2GTT"));

    try {
        f.saveFormRecord(newProps);
    } catch (SQLException ex) {
        request.setAttribute("message", "Error: Couldn't save new enhanced form");
        return mapping.findForward("migrate");
    }

    request.setAttribute("message", "Migration Successful");

    return mapping.findForward("migrate");
}