Example usage for org.apache.commons.lang3 StringUtils equalsIgnoreCase

List of usage examples for org.apache.commons.lang3 StringUtils equalsIgnoreCase

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils equalsIgnoreCase.

Prototype

public static boolean equalsIgnoreCase(final CharSequence str1, final CharSequence str2) 

Source Link

Document

Compares two CharSequences, returning true if they represent equal sequences of characters, ignoring case.

null s are handled without exceptions.

Usage

From source file:mfi.filejuggler.responsibles.BasicApplication.java

@Responsible(conditions = { Condition.SYS_FJ_OPTIONS })
public void fjSystemOptionen(StringBuilder sb, Map<String, String> parameters, Model model) throws Exception {

    Condition backCondition = null;
    if (model.lookupConversation().getStepBackCondition() != null
            && model.lookupConversation().getEditingFile() != null) {
        backCondition = model.lookupConversation().getStepBackCondition();
    } else {//from   w  ww  . j av  a2s  .  c o m
        backCondition = Condition.FS_NAVIGATE;
    }

    sb.append(HTMLUtils.buildMenuNar(model, "Anwendung", backCondition, null, false));

    HTMLTable table = new HTMLTable();

    if (model.isPhone()) {
        table.addTD("Allgemein", 3, HTMLTable.TABLE_HEADER);
        table.addNewRow();
        table.addTDSource(
                new Button("Neues Fenster", FileJugglerMainServlet.SERVLETPFAD, true).printForUseInTable(), 3,
                null);
        table.addNewRow();
        table.addTDSource(new Button(model.getUser() + " abmelden", Condition.LOGOFF).printForUseInTable(), 3,
                null);
        table.addNewRow();
    }

    table.addTD("Einstellungen", 3, HTMLTable.TABLE_HEADER);
    table.addNewRow();

    table.addTDSource(HTMLUtils.buildCheckBox("Zeilennummern", "LINE_NUMBERS",
            model.lookupConversation().isTextViewNumbers(), Condition.FS_NUMBERS_TEXTVIEW), 3, null);
    table.addNewRow();
    table.addTDSource(
            HTMLUtils.buildCheckBox("Datei Details", "FILE_DETAILS",
                    model.lookupConversation().isFilesystemViewDetails(), Condition.FS_SWITCH_VIEW_DETAILS),
            3, null);
    table.addNewRow();
    table.addTDSource(HTMLUtils.buildCheckBox("Push Nachrichten", "PUSH",
            model.lookupConversation().isTextViewPush(), Condition.FS_PUSH_TEXTVIEW), 3, null);
    table.addNewRow();

    table.addTD("Verzeichnisse", 3, HTMLTable.TABLE_HEADER);
    table.addNewRow();

    List<String> fav = new LinkedList<String>();
    fav.addAll(model.getFavoriteFolders());
    for (String ber : model.getVerzeichnisBerechtigungen()) {
        if (!fav.contains(ber)) {
            fav.add(ber);
        }
    }
    table.addTDSource(HTMLUtils.buildDropDownListe("gotoFolder", fav, null), 3, " align='center'");
    table.addNewRow();
    table.addTDSource(new Button("wechseln", Condition.FS_GOTO).printForUseInTable(), 3, HTMLTable.NO_BORDER);
    table.addNewRow();
    table.addTD("Anwendungen", 3, HTMLTable.TABLE_HEADER);
    table.addNewRow();
    table.addTDSource(new Button("System-Info", Condition.SYS_SYSTEM_INFO).printForUseInTable(), 3, null);
    table.addNewRow();
    table.addTDSource(
            new Button("Lizenzen anzeigen / View Licence Attribution", Condition.VIEW_LICENCE_ATTRIBUTION)
                    .printForUseInTable(),
            3, null);
    table.addNewRow();
    boolean admin = StringUtils.equalsIgnoreCase(
            KVMemoryMap.getInstance().readValueFromKey("user." + model.getUser() + ".isAdmin"),
            Boolean.toString(true));
    if (admin) {
        table.addTDSource(new Button("Backups", Condition.BACKUPS_START).printForUseInTable(), 3, null);
        table.addNewRow();
        table.addTDSource(new Button("KVDB Editor", Condition.KVDB_EDIT_START).printForUseInTable(), 3, null);
        table.addNewRow();
    }

    sb.append(table.buildTable(model));
    return;
}

From source file:com.glaf.jbpm.manager.JbpmTaskManager.java

/**
 * ??//w ww  . j a  va 2s. c o  m
 * 
 * @param processInstanceId
 * @param taskName
 * @param actorIds
 */
public void reassignTask(JbpmContext jbpmContext, Long processInstanceId, String taskName,
        Set<String> actorIds) {
    if (LogUtils.isDebug()) {
        logger.debug("processInstanceId:" + processInstanceId);
        logger.debug("taskName:" + taskName);
        logger.debug("actorIds:" + actorIds);
    }
    if (processInstanceId == null) {
        throw new JbpmException("processInstanceId is null");
    }
    if (StringUtils.isEmpty(taskName)) {
        throw new JbpmException("taskName is null");
    }
    if (actorIds == null || actorIds.size() == 0) {
        throw new JbpmException("actorIds is null");
    }

    ProcessInstance processInstance = null;
    TaskInstance taskInstance = null;
    processInstance = jbpmContext.getProcessInstance(processInstanceId);

    if (processInstance == null) {
        throw new JbpmException("process instance is null");
    }
    if (processInstance.hasEnded()) {
        throw new JbpmException("process has finished");
    }

    TaskMgmtInstance tmi = processInstance.getTaskMgmtInstance();
    Collection<TaskInstance> taskInstances = tmi.getTaskInstances();
    List<TaskInstance> unfinishedTasks = new java.util.ArrayList<TaskInstance>();
    if (taskInstances != null) {
        Iterator<TaskInstance> iter = taskInstances.iterator();
        while (iter.hasNext()) {
            TaskInstance x = iter.next();
            if (StringUtils.equalsIgnoreCase(taskName, x.getName())) {
                if (x.isOpen() && !x.hasEnded()) {
                    unfinishedTasks.add(x);
                }
            }
        }
    }

    if (unfinishedTasks.size() > 1) {
        throw new JbpmException("too more unfinished tasks ");
    }

    if (unfinishedTasks.size() == 1) {
        taskInstance = unfinishedTasks.get(0);
    }

    if (taskInstance == null) {
        throw new JbpmException("task instance is null");
    }

    if (actorIds != null && actorIds.size() > 0) {
        if (actorIds.size() == 1) {
            String actorId = actorIds.iterator().next();
            taskInstance.setActorId(actorId);
        } else {
            int i = 0;
            String[] pooledActorIds = new String[actorIds.size()];
            Iterator<String> iterator = actorIds.iterator();
            while (iterator.hasNext()) {
                pooledActorIds[i++] = iterator.next();
            }
            taskInstance.setActorId(null);
            taskInstance.setPooledActors(pooledActorIds);
        }
    }
    jbpmContext.save(taskInstance);
}

From source file:gov.nih.nci.caintegrator.application.study.AbstractDeployStudyTestIntegration.java

private void loadClinicalData()
        throws IOException, ValidationException, ConnectionException, InvalidFieldDescriptorException {
    sourceConfiguration = studyManagementService.addClinicalAnnotationFile(studyConfiguration,
            getSubjectAnnotationFile(), getSubjectAnnotationFile().getName(), true);
    if (getAnnotationGroupFile() == null) {
        sourceConfiguration.getAnnotationFile().setIdentifierColumnIndex(0);
    }/* ww  w  .j a  v  a2  s.com*/
    assertTrue(sourceConfiguration.isLoadable());
    sourceConfiguration = studyManagementService.loadClinicalAnnotation(studyConfiguration.getId(),
            sourceConfiguration.getId());
    assertTrue(sourceConfiguration.isCurrentlyLoaded());

    if (getAuthorizeStudy()) {
        for (AnnotationFieldDescriptor afd : studyConfiguration.getClinicalConfigurationCollection().get(0)
                .getAnnotationDescriptors()) {
            if (StringUtils.equalsIgnoreCase(getQueryFieldDescriptorName(), afd.getName())) {
                afd.setShowInAuthorization(true);
                break;
            }
        }
        studyManagementService.save(studyConfiguration);
    }
}

From source file:com.glaf.core.service.impl.MxSysDataTableServiceImpl.java

@Transactional
public void saveDataList(String datatableId, List<Map<String, Object>> dataList) {
    SysDataTable dataTable = this.getDataTableById(datatableId);
    Map<String, Object> newData = new HashMap<String, Object>();

    SysDataField idField = null;/*w w w  .jav a 2  s  .co  m*/
    List<SysDataField> fields = dataTable.getFields();
    if (fields != null && !fields.isEmpty()) {
        for (SysDataField field : fields) {
            if (StringUtils.equalsIgnoreCase("1", field.getPrimaryKey())
                    || StringUtils.equalsIgnoreCase("y", field.getPrimaryKey())
                    || StringUtils.equalsIgnoreCase("true", field.getPrimaryKey())) {
                idField = field;
                break;
            }
        }
    }

    if (idField == null) {
        throw new java.lang.RuntimeException("primary key not found.");
    }

    for (Map<String, Object> dataMap : dataList) {
        newData.clear();
        Set<Entry<String, Object>> entrySet = dataMap.entrySet();
        for (Entry<String, Object> entry : entrySet) {
            String key = entry.getKey();
            Object value = entry.getValue();
            if (value != null) {
                newData.put(key, value);
                newData.put(key.toUpperCase(), value);
            }
        }

        Object idValue = newData.get(idField.getColumnName().toUpperCase());
        if (idValue == null) {
            idValue = newData.get(idField.getName().toUpperCase());
        }

        TableModel row = new TableModel();
        row.setTableName(dataTable.getTablename());

        ColumnModel col01 = new ColumnModel();
        col01.setColumnName(idField.getColumnName());

        if (idValue == null) {
            if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Integer")) {
                col01.setJavaType("Long");
                Long id = idGenerator.nextId();
                col01.setIntValue(id.intValue());
                col01.setValue(Integer.valueOf(id.intValue()));
            } else if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Long")) {
                col01.setJavaType("Long");
                Long id = idGenerator.nextId();
                col01.setLongValue(id);
                col01.setValue(id);
            } else {
                col01.setJavaType("String");
                String id = idGenerator.getNextId();
                col01.setStringValue(id);
                col01.setValue(id);
            }
            row.setIdColumn(col01);
        } else {
            if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Integer")) {
                col01.setJavaType("Long");
                String id = idValue.toString();
                col01.setIntValue(Integer.parseInt(id));
                col01.setValue(col01.getIntValue());
            } else if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Long")) {
                col01.setJavaType("Long");
                String id = idValue.toString();
                col01.setLongValue(Long.parseLong(id));
                col01.setValue(col01.getLongValue());
            } else {
                col01.setJavaType("String");
                String id = idValue.toString();
                col01.setStringValue(id);
                col01.setValue(id);
            }
            row.setIdColumn(col01);
        }

        if (fields != null && !fields.isEmpty()) {
            for (SysDataField field : fields) {
                if (StringUtils.equalsIgnoreCase(idField.getColumnName(), field.getColumnName())) {
                    continue;
                }
                String name = field.getColumnName().toUpperCase();
                String javaType = field.getDataType();
                ColumnModel c = new ColumnModel();
                c.setColumnName(field.getColumnName());
                c.setJavaType(javaType);
                Object value = newData.get(name);
                if (value != null) {
                    if ("Integer".equals(javaType)) {
                        value = ParamUtils.getInt(newData, name);
                    } else if ("Long".equals(javaType)) {
                        value = ParamUtils.getLong(newData, name);
                    } else if ("Double".equals(javaType)) {
                        value = ParamUtils.getDouble(newData, name);
                    } else if ("Date".equals(javaType)) {
                        value = ParamUtils.getTimestamp(newData, name);
                    } else if ("String".equals(javaType)) {
                        value = ParamUtils.getString(newData, name);
                    } else if ("Clob".equals(javaType)) {
                        value = ParamUtils.getString(newData, name);
                    }
                    c.setValue(value);
                    row.addColumn(c);
                } else {
                    name = field.getName().toUpperCase();
                    value = newData.get(name);
                    if (value != null) {
                        if ("Integer".equals(javaType)) {
                            value = ParamUtils.getInt(newData, name);
                        } else if ("Long".equals(javaType)) {
                            value = ParamUtils.getLong(newData, name);
                        } else if ("Double".equals(javaType)) {
                            value = ParamUtils.getDouble(newData, name);
                        } else if ("Date".equals(javaType)) {
                            value = ParamUtils.getTimestamp(newData, name);
                        } else if ("String".equals(javaType)) {
                            value = ParamUtils.getString(newData, name);
                        } else if ("Clob".equals(javaType)) {
                            value = ParamUtils.getString(newData, name);
                        }
                        c.setValue(value);
                        row.addColumn(c);
                    }
                }
            }
        }
        if (idValue == null) {
            tableDataMapper.insertTableData(row);
        } else {
            tableDataMapper.updateTableDataByPrimaryKey(row);
        }
    }
}

From source file:mfi.filejuggler.responsibles.BasicApplication.java

@Responsible(conditions = { Condition.SYS_SYSTEM_INFO, Condition.SYS_EXECUTE_JOB })
public void fjSystemInfo(StringBuilder sb, Map<String, String> parameters, Model model) throws Exception {

    if (model.lookupConversation().getCondition().equals(Condition.SYS_EXECUTE_JOB)) {
        String executeJob = StringUtils.trimToEmpty(parameters.get("execute_job"));
        for (String schedulerName : CronSchedulers.getInstance().getSchedulersIDs().keySet()) {
            if (StringUtils.equalsIgnoreCase(schedulerName, executeJob)) {
                Runnable r = CronSchedulers.getInstance().getSchedulersInstances().get(schedulerName);
                r.run();//from w  w  w.  j  av a2s  . c  om
                model.lookupConversation().getMeldungen().add(r.getClass().getName() + " wurde gestartet");
                break;
            }
        }
    }

    String warfilename = KVMemoryMap.getInstance().readValueFromKey("application.warfile");
    String builddate = KVMemoryMap.getInstance().readValueFromKey("application.builddate");
    if (warfilename == null) {
        warfilename = "Development Version";
    }
    if (builddate == null) {
        builddate = "n/v";
    }

    ButtonBar buttonBar = new ButtonBar();
    buttonBar.getButtons().add(new Button("Reload", Condition.SYS_SYSTEM_INFO));
    sb.append(HTMLUtils.buildMenuNar(model, "Systeminformationen", Condition.FS_NAVIGATE, buttonBar, false));

    String attributeLeftCol = model.isPhone() ? HTMLUtils.buildAttribute("width", "40%") : null;

    HTMLTable table = new HTMLTable();

    table.addTD("Anwendungsvariablen:", 2, HTMLTable.TABLE_HEADER);
    table.addNewRow();
    table.addTD("Build:", 1, null);
    table.addTD(builddate, 1, null);
    table.addNewRow();
    table.addTD("Systemzeit:", 1, null);
    table.addTD(Hilfsklasse.zeitstempelAlsString(), 1, null);
    table.addNewRow();
    table.addTD("Zwischenablage:", 1, attributeLeftCol);
    String clip;
    if (model.getZwischenablage() != null) {
        clip = HTMLUtils.spacifyFilePath(model.getZwischenablage(), model);
    } else {
        clip = "[ leer ]";
    }
    table.addTD(clip, 1, null);
    table.addNewRow();
    table.addTD("Session:", 1, null);
    table.addTD(StringHelper.langenStringFuerAnzeigeAufbereiten(model.getSessionID()), 1, null);
    table.addNewRow();
    table.addTD("Login:", 1, null);
    table.addTD(StringHelper.langenStringFuerAnzeigeAufbereiten(model.getLoginCookieID()), 1, null);
    table.addNewRow();
    if (model.lookupConversation().getCookiesReadFromRequest() != null && model.isDevelopmentMode()) {
        for (Cookie cookieReadFromRequest : model.lookupConversation().getCookiesReadFromRequest()) {
            String cookieName = cookieReadFromRequest.getName();
            String cookieValue = cookieReadFromRequest.getValue();
            table.addTD("Cookie (Request):", 1, null);
            table.addTD(cookieName, 1, null);
            table.addNewRow();
            table.addTD("", 1, null);
            table.addTD(StringHelper.langenStringFuerAnzeigeAufbereiten(cookieValue), 1, null);
            table.addNewRow();
        }
    }
    table.addTD("Conversation ID:", 1, null);
    table.addTD(model.lookupConversation().getConversationID().toString(), 1, null);
    table.addNewRow();
    table.addTD("Remote IP:", 1, null);
    table.addTD(parameters.get(ServletHelper.SERVLET_REMOTE_IP), 1, null);
    table.addNewRow();
    table.addTD("LocalNetwork:", 1, null);
    table.addTD(ServletHelper.isLocalNetworkClient(parameters) + "", 1, null);
    table.addNewRow();
    table.addTD("Touch / Phone / Tablet:", 1, null);
    table.addTD(Boolean.toString(model.isClientTouchDevice()) + " / " + Boolean.toString(model.isPhone())
            + " / " + Boolean.toString(model.isTablet()), 1, null);
    table.addNewRow();
    table.addTD("Ist FullScreen:", 1, null);
    table.addTD(Boolean.toString(model.isIstWebApp()), 1, null);
    table.addNewRow();
    table.addTD("Ajax / current request:", 1, null);
    table.addTD(Boolean.toString(ServletHelper.lookupUseAjax()) + " / "
            + ServletHelper.lookupIsCurrentRequestTypeAjax(parameters), 1, null);
    table.addNewRow();
    table.addTD("Gzip Response:", 1, null);
    table.addTD(Boolean.toString(ServletHelper.lookupUseGzip(parameters)), 1, null);
    table.addNewRow();

    if (model.isPhone()) {
        sb.append(table.buildTable(model));
        table = new HTMLTable();
    }

    table.addTD("Java", 2, HTMLTable.TABLE_HEADER);
    table.addNewRow();
    table.addTD("total / max memory:", 1, attributeLeftCol);
    table.addTD(DateiZugriff.speicherGroesseFormatieren(Runtime.getRuntime().totalMemory()) + " / "
            + DateiZugriff.speicherGroesseFormatieren(Runtime.getRuntime().maxMemory()), 1, null);
    table.addNewRow();
    table.addTD("freeMemory:", 1, null);
    table.addTD(DateiZugriff.speicherGroesseFormatieren(Runtime.getRuntime().freeMemory()), 1, null);
    table.addNewRow();
    table.addTD("catalina.home:", 1, null);
    table.addTD(
            HTMLUtils.spacifyFilePath(
                    System.getProperties().getProperty(ServletHelper.SYSTEM_PROPERTY_CATALINA_HOME), model),
            1, null);
    table.addNewRow();
    table.addTD("catalina.base:", 1, null);
    table.addTD(
            HTMLUtils.spacifyFilePath(
                    System.getProperties().getProperty(ServletHelper.SYSTEM_PROPERTY_CATALINA_BASE), model),
            1, null);
    table.addNewRow();
    table.addTD("WarFile:", 1, HTMLTable.NO_BORDER);
    table.addTD(HTMLUtils.spacifyFilePath(warfilename, model), 1, HTMLTable.NO_BORDER);
    table.addNewRow();

    if (model.isPhone()) {
        sb.append(table.buildTable(model));
        table = new HTMLTable();
    }

    table.addTD("Hardware / Software", 2, HTMLTable.TABLE_HEADER);
    table.addNewRow();
    table.addTD("CPU Cores:", 1, attributeLeftCol);
    table.addTD(Runtime.getRuntime().availableProcessors() + "", 1, null);
    table.addNewRow();
    table.addTD("Architecture:", 1, null);
    table.addTD(System.getProperty("sun.arch.data.model", "") + " bit", 1, null);
    table.addNewRow();
    table.addTD("Java Version:", 1, null);
    table.addTD(System.getProperty("java.version", ""), 1, null);
    table.addNewRow();
    table.addTD("Java VM:", 1, null);
    table.addTD(System.getProperty("java.vm.name", ""), 1, null);
    table.addNewRow();
    table.addTD("Server:", 1, null);
    table.addTD(KVMemoryMap.getInstance().readValueFromKey("application.server"), 1, null);
    table.addNewRow();

    if (model.isPhone()) {
        sb.append(table.buildTable(model));
        table = new HTMLTable();
    }

    table.addTD("Cron Jobs", 2, HTMLTable.TABLE_HEADER);
    table.addNewRow();

    int a = 0;
    List<String> jobs = new LinkedList<String>();
    jobs.add("");
    for (String schedulerName : CronSchedulers.getInstance().getSchedulersIDs().keySet()) {
        jobs.add(schedulerName);
        String cssClass = a % 2 != 0 ? attributeLeftCol : HTMLUtils.buildAttribute("class", "alt");
        Scheduler s = CronSchedulers.getInstance().getSchedulers().get(schedulerName);
        table.addTD(schedulerName, 1, cssClass);
        table.addTD(((s != null && s.isStarted()) ? "@ " : "not running")
                + CronSchedulers.getInstance().lookupCronStringOfScheduler(schedulerName), 1, cssClass);
        table.addNewRow();
        table.addTD("", 1, cssClass);
        table.addTD(CronSchedulers.getInstance().getSchedulersInstances().get(schedulerName).status(), 1,
                cssClass);
        table.addNewRow();
        a++;
    }

    if (model.isPhone()) {
        sb.append(table.buildTable(model));
        table = new HTMLTable();
    }

    table.addTD("Manueller Job-Start", 2, HTMLTable.TABLE_HEADER);
    table.addNewRow();
    table.addTDSource(HTMLUtils.buildDropDownListe("execute_job", jobs, null), 2, null);
    table.addNewRow();
    String buttonJobStart = new Button("Job starten", Condition.SYS_EXECUTE_JOB).printForUseInTable();
    table.addTDSource(buttonJobStart, 2, HTMLTable.NO_BORDER);
    table.addNewRow();

    sb.append(table.buildTable(model));
    return;
}

From source file:com.glaf.core.web.springmvc.MxSystemDbTableController.java

@ResponseBody
@RequestMapping("/save")
public byte[] save(HttpServletRequest request, ModelMap modelMap) {
    RequestUtils.setRequestParameterToAttribute(request);
    String tableName = request.getParameter("tableName_enc");
    if (StringUtils.isNotEmpty(tableName)) {
        tableName = RequestUtils.decodeString(tableName);
    } else {//  w  w w . j  av a  2 s  .  c  o  m
        tableName = request.getParameter("tableName");
    }

    Collection<String> rejects = new java.util.ArrayList<String>();
    rejects.add("FILEATT");
    rejects.add("ATTACHMENT");
    rejects.add("CMS_PUBLICINFO");
    rejects.add("SYS_LOB");
    rejects.add("SYS_MAIL_FILE");
    rejects.add("SYS_DBID");
    rejects.add("SYS_PROPERTY");

    if (conf.get("table.rejects") != null) {
        String str = conf.get("table.rejects");
        List<String> list = StringTools.split(str);
        for (String t : list) {
            rejects.add(t.toUpperCase());
        }
    }

    String businessKey = request.getParameter("businessKey");
    String primaryKey = null;
    ColumnDefinition idColumn = null;
    List<ColumnDefinition> columns = null;
    try {
        /**
         * ??????
         */
        if (StringUtils.isNotEmpty(tableName) && !rejects.contains(tableName.toUpperCase())
                && !StringUtils.startsWithIgnoreCase(tableName, "user")
                && !StringUtils.startsWithIgnoreCase(tableName, "net")
                && !StringUtils.startsWithIgnoreCase(tableName, "sys")
                && !StringUtils.startsWithIgnoreCase(tableName, "jbpm")
                && !StringUtils.startsWithIgnoreCase(tableName, "act")) {
            columns = DBUtils.getColumnDefinitions(tableName);
            modelMap.put("tableName", tableName);
            modelMap.put("tableName_enc", RequestUtils.encodeString(tableName));
            List<String> pks = DBUtils.getPrimaryKeys(tableName);
            if (pks != null && !pks.isEmpty()) {
                if (pks.size() == 1) {
                    primaryKey = pks.get(0);
                }
            }
            if (primaryKey != null) {
                for (ColumnDefinition column : columns) {
                    if (StringUtils.equalsIgnoreCase(primaryKey, column.getColumnName())) {
                        idColumn = column;
                        break;
                    }
                }
            }
            if (idColumn != null) {
                TableModel tableModel = new TableModel();
                tableModel.setTableName(tableName);
                ColumnModel idCol = new ColumnModel();
                idCol.setColumnName(idColumn.getColumnName());
                idCol.setJavaType(idColumn.getJavaType());
                if ("Integer".equals(idColumn.getJavaType())) {
                    idCol.setValue(Integer.parseInt(businessKey));
                } else if ("Long".equals(idColumn.getJavaType())) {
                    idCol.setValue(Long.parseLong(businessKey));
                } else {
                    idCol.setValue(businessKey);
                }
                tableModel.setIdColumn(idCol);

                for (ColumnDefinition column : columns) {
                    String value = request.getParameter(column.getColumnName());
                    ColumnModel col = new ColumnModel();
                    col.setColumnName(column.getColumnName());
                    col.setJavaType(column.getJavaType());
                    if (value != null && value.trim().length() > 0 && !value.equals("null")) {
                        if ("Integer".equals(column.getJavaType())) {
                            col.setValue(Integer.parseInt(value));
                            tableModel.addColumn(col);
                        } else if ("Long".equals(column.getJavaType())) {
                            col.setValue(Long.parseLong(value));
                            tableModel.addColumn(col);
                        } else if ("Double".equals(column.getJavaType())) {
                            col.setValue(Double.parseDouble(value));
                            tableModel.addColumn(col);
                        } else if ("Date".equals(column.getJavaType())) {
                            col.setValue(DateUtils.toDate(value));
                            tableModel.addColumn(col);
                        } else if ("String".equals(column.getJavaType())) {
                            col.setValue(value);
                            tableModel.addColumn(col);
                        }
                    }
                }

                tableDataService.updateTableData(tableModel);

                return ResponseUtils.responseJsonResult(true);
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        logger.error(ex);
    }
    return ResponseUtils.responseJsonResult(false);
}

From source file:com.ottogroup.bi.streaming.operator.json.JsonProcessingUtils.java

/**
 * Extracts from a {@link JSONObject} the value of the field referenced by the provided path. The received content is treated as
 * {@link Boolean} value. If the value is a plain {@link Boolean} value it is returned right away. Boolean values contained inside {@link String}
 * instances are parsed out by {@link Boolean#parseBoolean(String)}.
 * @param jsonObject/*from   w w  w.  j av  a2  s .  co m*/
 *          The {@link JSONObject} to read the value from (null is not permitted as input)
 * @param fieldPath
 *          Path inside the {@link JSONObject} pointing towards the value of interest (null is not permitted as input)
 * @param required
 *          Field is required to exist at the end of the given path 
 * @return
 *          Value found at the end of the provided path. An empty path simply returns the input
 * @throws JSONException
 *          Thrown in case extracting values from the {@link JSONObject} fails for any reason
 * @throws IllegalArgumentException
 *          Thrown in case a provided parameter does not comply with the restrictions
 * @throws NoSuchElementException
 *          Thrown in case an element referenced inside the path does not exist at the expected location inside the {@link JSONObject}
 * @throws ParseException
 *          Thrown in case parsing out an {@link ZonedDateTime} from the retrieved field value fails for any format related reason 
 */
public Boolean getBooleanFieldValue(final JSONObject jsonObject, final String[] fieldPath,
        final boolean required)
        throws JSONException, IllegalArgumentException, NoSuchElementException, ParseException {

    Object value = getFieldValue(jsonObject, fieldPath);
    if (value == null && !required)
        return null;

    if (value instanceof Boolean)
        return (Boolean) value;
    else if (value instanceof String)
        return StringUtils.equalsIgnoreCase((String) value, "true");

    throw new ParseException("Types of " + (value != null ? value.getClass().getName() : "null")
            + " cannot be parsed into a valid boolean representation", 0);
}

From source file:com.bekwam.resignator.ResignatorAppMainViewController.java

void recordRecentProfile(String newProfileName) {

    if (activeConfiguration.getRecentProfiles().contains(newProfileName)) {
        return; // can assume activeConfiguration is accurate
    }/*from w w  w  .  j  ava  2  s.  co  m*/

    //
    // #18 record recent history on save
    //
    List<MenuItem> rpItems = mRecentProfiles.getItems();
    MenuItem rpItem = new MenuItem(newProfileName);
    rpItem.setOnAction(recentProfileLoadHandler);

    if (CollectionUtils.isNotEmpty(rpItems)) {
        if (CollectionUtils.size(rpItems) == 1) {
            if (StringUtils.equalsIgnoreCase(rpItems.get(0).getText(), MI_NO_PROFILES.getText())) {
                rpItems.set(0, rpItem);
            } else {
                rpItems.add(0, rpItem);
            }
        } else {
            rpItems.add(0, rpItem);
            if (CollectionUtils.size(rpItems) > numRecentProfiles) {
                for (int i = (CollectionUtils.size(rpItems) - 1); i >= numRecentProfiles; i--) {
                    rpItems.remove(i);
                }
            }
        }
    } else {
        // should never have no items (at least one < None >)
        rpItems.add(rpItem);
    }

    // reconcile with active record
    activeConfiguration.getRecentProfiles().clear();
    if (!(CollectionUtils.size(rpItems) == 1
            && StringUtils.equalsIgnoreCase(rpItems.get(0).getText(), MI_NO_PROFILES.getText()))) {
        // there's more than just a < None > element
        activeConfiguration
                .setRecentProfiles(rpItems.stream().map((mi) -> mi.getText()).collect(Collectors.toList()));
    }
    // end #18
}

From source file:com.ottogroup.bi.spqr.pipeline.MicroPipelineFactory.java

/**
 * Instantiates, initializes and returns the {@link DelayedResponseOperatorWaitStrategy} configured for the {@link DelayedResponseOperator}
 * whose {@link MicroPipelineComponentConfiguration configuration} is provided when calling this method. 
 * @param delayedResponseOperatorCfg/*  w  ww.  j a va2 s  .c  om*/
 * @return
 */
protected DelayedResponseOperatorWaitStrategy getResponseWaitStrategy(
        final MicroPipelineComponentConfiguration delayedResponseOperatorCfg)
        throws RequiredInputMissingException, UnknownWaitStrategyException {

    /////////////////////////////////////////////////////////////////////////////////////
    // validate input
    if (delayedResponseOperatorCfg == null)
        throw new RequiredInputMissingException("Missing required delayed response operator configuration");
    if (delayedResponseOperatorCfg.getSettings() == null)
        throw new RequiredInputMissingException("Missing required delayed response operator settings");
    String strategyName = StringUtils.lowerCase(StringUtils.trim(delayedResponseOperatorCfg.getSettings()
            .getProperty(DelayedResponseOperator.CFG_WAIT_STRATEGY_NAME)));
    if (StringUtils.isBlank(strategyName))
        throw new RequiredInputMissingException(
                "Missing required strategy name expected as part of operator settings ('"
                        + DelayedResponseOperator.CFG_WAIT_STRATEGY_NAME + "')");
    //
    /////////////////////////////////////////////////////////////////////////////////////

    if (logger.isDebugEnabled())
        logger.debug("Settings provided for strategy '" + strategyName + "'");
    Properties strategyProperties = new Properties();
    for (Enumeration<Object> keyEnumerator = delayedResponseOperatorCfg.getSettings().keys(); keyEnumerator
            .hasMoreElements();) {
        String key = (String) keyEnumerator.nextElement();
        if (StringUtils.startsWith(key, DelayedResponseOperator.CFG_WAIT_STRATEGY_SETTINGS_PREFIX)) {
            String waitStrategyCfgKey = StringUtils.substring(key, StringUtils.lastIndexOf(key, ".") + 1);
            if (StringUtils.isNoneBlank(waitStrategyCfgKey)) {
                String waitStrategyCfgValue = delayedResponseOperatorCfg.getSettings().getProperty(key);
                strategyProperties.put(waitStrategyCfgKey, waitStrategyCfgValue);

                if (logger.isDebugEnabled())
                    logger.debug("\t" + waitStrategyCfgKey + ": " + waitStrategyCfgValue);

            }
        }
    }

    if (StringUtils.equalsIgnoreCase(strategyName, MessageCountResponseWaitStrategy.WAIT_STRATEGY_NAME)) {
        MessageCountResponseWaitStrategy strategy = new MessageCountResponseWaitStrategy();
        strategy.initialize(strategyProperties);
        return strategy;
    } else if (StringUtils.equalsIgnoreCase(strategyName, TimerBasedResponseWaitStrategy.WAIT_STRATEGY_NAME)) {
        TimerBasedResponseWaitStrategy strategy = new TimerBasedResponseWaitStrategy();
        strategy.initialize(strategyProperties);
        return strategy;
    } else if (StringUtils.equalsIgnoreCase(strategyName, OperatorTriggeredWaitStrategy.WAIT_STRATEGY_NAME)) {
        OperatorTriggeredWaitStrategy strategy = new OperatorTriggeredWaitStrategy();
        strategy.initialize(strategyProperties);
        return strategy;
    }

    throw new UnknownWaitStrategyException("Unknown wait strategy '" + strategyName + "'");

}

From source file:ffx.xray.MTZFilter.java

private void parseColumns(boolean print) {

    int nc = 0;/*from  w  w  w  .  j a v a 2 s.  c  om*/
    StringBuilder sb = new StringBuilder();
    for (Iterator i = columns.iterator(); i.hasNext(); nc++) {
        Column c = (Column) i.next();
        String label = c.label.trim();
        if (label.equalsIgnoreCase("H") && c.type == 'H') {
            h = nc;
        } else if (label.equalsIgnoreCase("K") && c.type == 'H') {
            k = nc;
        } else if (label.equalsIgnoreCase("L") && c.type == 'H') {
            l = nc;
        } else if ((label.equalsIgnoreCase("free") || label.equalsIgnoreCase("freer")
                || label.equalsIgnoreCase("freerflag") || label.equalsIgnoreCase("freer_flag")
                || label.equalsIgnoreCase("rfree") || label.equalsIgnoreCase("rfreeflag")
                || label.equalsIgnoreCase("r-free-flags") || label.equalsIgnoreCase("test")
                || StringUtils.equalsIgnoreCase(label, rfreeString)) && c.type == 'I') {
            sb.append(String.format(" Reading R Free column: \"%s\"\n", c.label));
            rfree = nc;
        } else if ((label.equalsIgnoreCase("free(+)") || label.equalsIgnoreCase("freer(+)")
                || label.equalsIgnoreCase("freerflag(+)") || label.equalsIgnoreCase("freer_flag(+)")
                || label.equalsIgnoreCase("rfree(+)") || label.equalsIgnoreCase("rfreeflag(+)")
                || label.equalsIgnoreCase("r-free-flags(+)") || label.equalsIgnoreCase("test(+)")
                || StringUtils.equalsIgnoreCase(label + "(+)", rfreeString)) && c.type == 'I') {
            rfreeplus = nc;
        } else if ((label.equalsIgnoreCase("free(-)") || label.equalsIgnoreCase("freer(-)")
                || label.equalsIgnoreCase("freerflag(-)") || label.equalsIgnoreCase("freer_flag(-)")
                || label.equalsIgnoreCase("rfree(-)") || label.equalsIgnoreCase("rfreeflag(-)")
                || label.equalsIgnoreCase("r-free-flags(-)") || label.equalsIgnoreCase("test(-)")
                || StringUtils.equalsIgnoreCase(label + "(-)", rfreeString)) && c.type == 'I') {
            rfreeminus = nc;
        } else if ((label.equalsIgnoreCase("f") || label.equalsIgnoreCase("fp") || label.equalsIgnoreCase("fo")
                || label.equalsIgnoreCase("fobs") || label.equalsIgnoreCase("f-obs")
                || StringUtils.equalsIgnoreCase(label, foString)) && c.type == 'F') {
            sb.append(String.format(" Reading Fo column: \"%s\"\n", c.label));
            fo = nc;
        } else if ((label.equalsIgnoreCase("f(+)") || label.equalsIgnoreCase("fp(+)")
                || label.equalsIgnoreCase("fo(+)") || label.equalsIgnoreCase("fobs(+)")
                || label.equalsIgnoreCase("f-obs(+)") || StringUtils.equalsIgnoreCase(label + "(+)", foString))
                && c.type == 'G') {
            fplus = nc;
        } else if ((label.equalsIgnoreCase("f(-)") || label.equalsIgnoreCase("fp(-)")
                || label.equalsIgnoreCase("fo(-)") || label.equalsIgnoreCase("fobs(-)")
                || label.equalsIgnoreCase("f-obs(-)") || StringUtils.equalsIgnoreCase(label + "(-)", foString))
                && c.type == 'G') {
            fminus = nc;
        } else if ((label.equalsIgnoreCase("sigf") || label.equalsIgnoreCase("sigfp")
                || label.equalsIgnoreCase("sigfo") || label.equalsIgnoreCase("sigfobs")
                || label.equalsIgnoreCase("sigf-obs") || StringUtils.equalsIgnoreCase(label, sigfoString))
                && c.type == 'Q') {
            sb.append(String.format(" Reading sigFo column: \"%s\"\n", c.label));
            sigfo = nc;
        } else if ((label.equalsIgnoreCase("sigf(+)") || label.equalsIgnoreCase("sigfp(+)")
                || label.equalsIgnoreCase("sigfo(+)") || label.equalsIgnoreCase("sigfobs(+)")
                || label.equalsIgnoreCase("sigf-obs(+)")
                || StringUtils.equalsIgnoreCase(label + "(+)", sigfoString)) && c.type == 'L') {
            sigfplus = nc;
        } else if ((label.equalsIgnoreCase("sigf(-)") || label.equalsIgnoreCase("sigfp(-)")
                || label.equalsIgnoreCase("sigfo(-)") || label.equalsIgnoreCase("sigfobs(-)")
                || label.equalsIgnoreCase("sigf-obs(-)")
                || StringUtils.equalsIgnoreCase(label + "(-)", sigfoString)) && c.type == 'L') {
            sigfminus = nc;
        }
    }
    if (fo < 0 && sigfo < 0 && fplus > 0 && sigfplus > 0 && fminus > 0 && sigfminus > 0) {
        sb.append(String.format(" Reading Fplus/Fminus column to fill in Fo\n"));
    }
    if (logger.isLoggable(Level.INFO) && print) {
        logger.info(sb.toString());
    }
}