Example usage for java.lang Boolean booleanValue

List of usage examples for java.lang Boolean booleanValue

Introduction

In this page you can find the example usage for java.lang Boolean booleanValue.

Prototype

@HotSpotIntrinsicCandidate
public boolean booleanValue() 

Source Link

Document

Returns the value of this Boolean object as a boolean primitive.

Usage

From source file:com.glaf.jbpm.action.SQLAction.java

public void execute(ExecutionContext ctx) throws Exception {
    logger.debug("---------------------------------------------------");
    logger.debug("----------------------SQLAction--------------------");
    logger.debug("---------------------------------------------------");

    ContextInstance contextInstance = ctx.getContextInstance();

    Map<String, Object> params = new java.util.HashMap<String, Object>();

    Map<String, Object> variables = contextInstance.getVariables();
    if (variables != null && variables.size() > 0) {
        Set<Entry<String, Object>> entrySet = variables.entrySet();
        for (Entry<String, Object> entry : entrySet) {
            String name = entry.getKey();
            Object value = entry.getValue();
            if (name != null && value != null && params.get(name) == null) {
                params.put(name, value);
            }// w ww  . ja  v a 2  s.co  m
        }
    }

    ProcessInstance processInstance = ctx.getProcessInstance();
    ProcessDefinition processDefinition = processInstance.getProcessDefinition();

    params.put("processInstanceId", processInstance.getId());
    params.put("processName", processDefinition.getName());
    params.put("processDefinitionId", processDefinition.getId());
    params.put("processDefinition", processDefinition);
    params.put("processInstance", processInstance);

    boolean executable = true;

    if (StringUtils.isNotEmpty(expression)) {
        if (expression.startsWith("#{") && expression.endsWith("}")) {
            Object value = DefaultExpressionEvaluator.evaluate(expression, params);
            if (value != null) {
                if (value instanceof Boolean) {
                    Boolean b = (Boolean) value;
                    executable = b.booleanValue();
                }
            }
        }
    }

    if (!executable) {
        logger.debug("???false??");
        return;
    }

    List<Object> values = new java.util.ArrayList<Object>();

    if (elements != null) {
        values = ExpressionUtils.getValues(ctx, elements);
    }

    sql = QueryUtils.replaceSQLParas(sql, params);

    if (sql.indexOf("#{tableName}") != -1) {
        String tableName = (String) contextInstance.getVariable("tableName");
        if (StringUtils.isNotEmpty(tableName)) {
            sql = StringTools.replace(sql, "#{tableName}", tableName);
        }
    }

    if (sql.indexOf("#{") != -1 && sql.indexOf("}") != -1) {
        sql = (String) DefaultExpressionEvaluator.evaluate(sql, params);
    }

    if (LogUtils.isDebug()) {
        logger.debug(sql);
        logger.debug(values);
    }

    Connection con = null;
    PreparedStatement psmt = null;
    try {
        con = ctx.getJbpmContext().getConnection();
        psmt = con.prepareStatement(sql);
        JdbcUtils.fillStatement(psmt, values);
        psmt.executeUpdate();
        psmt.close();
        psmt = null;
    } finally {
        if (psmt != null) {
            psmt.close();
            psmt = null;
        }
    }
}

From source file:org.focusns.web.modules.profile.ProjectLinkWidget.java

@RequiresProject
@RequestMapping("/link-list")
public String doList(@WidgetPref(defaultValue = "6") Integer limit,
        @WidgetPref(defaultValue = "false") Boolean reverse,
        @WidgetPref(defaultValue = "people") String category, @WidgetAttribute Project project, Model model) {
    ///*from  ww w.j ava  2s  .c  o  m*/
    Page<ProjectLink> page = new Page<ProjectLink>(limit);
    if (reverse.booleanValue()) {
        page = projectLinkService.fetchPageByToProjectId(page, project.getId(), category);
    } else {
        page = projectLinkService.fetchPageByFromProjectId(page, project.getId(), category);
    }
    model.addAttribute(Page.KEY, page);
    model.addAttribute("reverse", reverse.booleanValue());
    //
    return "modules/profile/link-list";
}

From source file:com.zaizi.sensefy.jscript.SensefySearch.java

/**
 * Retrieve the sorting preferences from the serializable object.
 * @param sort the list serializable maps from JavaScript.
 * @return a list of the SortColumn object representing which colomns to sort on in what order.
 *///from w  ww  .  j ava  2  s.c o  m
private SortColumn[] getSortParameter(List<Map<Serializable, Serializable>> sort) {
    SortColumn[] sortColumns = null;
    if (sort != null) {
        sortColumns = new SortColumn[sort.size()];
        int index = 0;
        for (Map<Serializable, Serializable> column : sort) {
            String strCol = (String) column.get(SORT_COLUMN_FIELD);
            if (strCol != null && !strCol.isEmpty()) {
                Boolean boolAsc = (Boolean) column.get(SORT_ASCENDING_FIELD);
                boolean ascending = boolAsc != null ? boolAsc.booleanValue() : false;
                sortColumns[index++] = new SortColumn(strCol, ascending);
            }
        }
    }
    return sortColumns;
}

From source file:com.glaf.jbpm.action.SequenceTaskInstanceAction.java

public void execute(ExecutionContext ctx) throws Exception {
    boolean isAgree = true;

    Map<String, Object> params = new java.util.HashMap<String, Object>();

    ContextInstance contextInstance = ctx.getContextInstance();
    Map<String, Object> variables = contextInstance.getVariables();
    if (variables != null && variables.size() > 0) {
        Iterator<String> iterator = variables.keySet().iterator();
        while (iterator.hasNext()) {
            String variableName = iterator.next();
            if (params.get(variableName) == null) {
                Object value = contextInstance.getVariable(variableName);
                params.put(variableName, value);
            }//from w  ww . j a va  2s.  c  om
        }
    }

    if (StringUtils.isNotEmpty(expression)) {
        if (expression.startsWith("#{") && expression.endsWith("}")) {
            Object value = DefaultExpressionEvaluator.evaluate(expression, params);
            if (value != null) {
                if (value instanceof Boolean) {
                    Boolean b = (Boolean) value;
                    isAgree = b.booleanValue();
                }
            }
        }
    }

    /**
     * ???
     */
    if ((!isAgree) && leaveNodeIfActorNotAgree) {
        if (StringUtils.isNotEmpty(transitionName)) {
            ctx.leaveNode(transitionName);
        } else {
            ctx.leaveNode();
        }
        return;
    }

    boolean hasActors = false;

    List<String> actorIds = null;

    Task task = null;
    if (StringUtils.isNotEmpty(taskName)) {
        Node node = ctx.getNode();
        if (node instanceof TaskNode) {
            TaskNode taskNode = (TaskNode) node;
            task = taskNode.getTask(taskName);
        }
    }

    if (task == null) {
        task = ctx.getTask();
    }

    if (StringUtils.isNotEmpty(dynamicActors)) {
        String rowIds = (String) contextInstance.getVariable(dynamicActors);
        if (StringUtils.isNotEmpty(rowIds)) {
            actorIds = StringTools.split(rowIds);
        }
    }

    if (actorIds != null) {
        if (actorIds.size() > 0) {
            String actorId = actorIds.get(0);
            Token token = ctx.getToken();
            TaskMgmtInstance tmi = ctx.getTaskMgmtInstance();
            TaskInstance taskInstance = tmi.createTaskInstance(task, token);
            taskInstance.setActorId(actorId);
            taskInstance.setCreate(new Date());
            taskInstance.setSignalling(task.isSignalling());
            actorIds.remove(0);
            hasActors = true;
        }

        if (actorIds.size() > 0) {
            StringBuilder buffer = new StringBuilder();
            String delim = "";
            for (String element : actorIds) {
                buffer.append(delim);
                buffer.append(element);
                delim = ",";
            }
            contextInstance.setVariable(dynamicActors, buffer.toString());
        }
    }

    if (!hasActors) {
        if (leaveNodeIfActorNotAvailable) {
            contextInstance.setVariable(Constant.IS_AGREE, "true");
            if (StringUtils.isNotEmpty(transitionName)) {
                ctx.leaveNode(transitionName);
            } else {
                ctx.leaveNode();
            }
        }
    }
}

From source file:com.aurel.track.admin.server.sendEmail.SendEmailAction.java

/**
 * Send an e-mail to the selected persons or all persons in the selected departments
 * @return// w  w  w.  ja  v  a2  s .c o  m
 */
public String sendEmail() {
    LOGGER.debug("SendMailAction.sendMail()");
    TSiteBean siteBean = ApplicationBean.getInstance().getSiteBean();
    SMTPMailSettings smtpMailSettings = OutgoingEmailBL.getSMTPMailSettings(siteBean);
    if (smtpMailSettings.getHost() == null || "".equals(smtpMailSettings.getHost().trim())) {
        //It's acceptable that there is no SMTP server :)
        LOGGER.info("No SMTP host found, e-mail sending is impossible");
        return encodeFailure("No SMTP host found, e-mail sending is impossible",
                SendItemEmailBL.ERROR_EMAIL_NOT_SEND);
    }
    List<TPersonBean> groups = PersonBL.loadGroups();

    List<TPersonBean> recipients = SendItemEmailBL.validateEmails(toCustom, groups);
    if (recipients == null) {
        return encodeFailure(getText("item.action.sendItemEmail.err.invalidEmail"),
                SendItemEmailBL.ERROR_INVALID_EMAIL);
    }
    if (recipients.isEmpty()) {
        return encodeFailure(getText("admin.server.sendEmail.err.needPerson"),
                SendItemEmailBL.ERROR_NEED_PERSON);
    }
    if (subject == null || "".equals(subject.trim())) {
        return encodeFailure(getText("admin.server.sendEmail.err.needSubject"),
                SendItemEmailBL.ERROR_NEED_SUBJECT);
    }
    if (mailBody == null || "".equals(mailBody.trim())) {
        return encodeFailure(getText("admin.server.sendEmail.err.needBody"), SendItemEmailBL.ERROR_NEED_BODY);
    }
    List<TPersonBean> recipientsCC = SendItemEmailBL.validateEmails(ccCustom, groups);
    List<TPersonBean> recipientsBCC = SendItemEmailBL.validateEmails(bccCustom, groups);

    Boolean emailSent = SendEmailBL.sendEmail(tPerson, recipients, recipientsCC, recipientsBCC, subject,
            mailBody);

    if (emailSent != null) {
        if (emailSent.booleanValue()) {
            JSONUtility.encodeJSONSuccess(ServletActionContext.getResponse());
            return null;
        } else {
            return encodeFailure(getText("item.action.sendItemEmail.err.mailNotSent"),
                    SendItemEmailBL.ERROR_EMAIL_NOT_SEND);
        }
    }

    return encodeFailure(getText("item.action.sendItemEmail.lbl.toMuchTimeNeed"),
            SendItemEmailBL.ERROR_NEED_MORE_TIME);
}

From source file:com.aurel.track.item.action.MoveItemActionPlugin.java

@Override
public WorkItemContext next(Locale locale, TPersonBean user, Integer workItemID, Integer parentID,
        Map<String, Object> params, String synopsis, String description) throws PluginItemActionException {
    ItemLocationForm form = extractItemLocation(locale, user, params, workItemID, parentID);
    Integer projectID = form.getProjectID();
    Integer issueTypeID = form.getIssueTypeID();
    if (projectID == null) {
        LOGGER.warn("Can't execute next().Project is required!");
        PluginItemActionException ex = new PluginItemActionException("Project is required!");
        ex.setFieldName("projectID");
        ex.setLocalizedErrorKey("common.err.required");
        throw ex;
    }/* w  w  w . j ava 2  s.  c om*/
    if (issueTypeID == null) {
        LOGGER.warn("Can't execute next().Issue type is required!");
        PluginItemActionException ex = new PluginItemActionException("IssueType is required!");
        ex.setFieldName("issuTypeID");
        ex.setLocalizedErrorKey("common.err.required");
        throw ex;
    }
    TWorkItemBean workItem = ItemBL.loadWorkItemSystemAttributes(workItemID);
    if (workItem.getProjectID().equals(projectID) && workItem.getListTypeID().equals(issueTypeID)) {
        PluginItemActionException ex = new PluginItemActionException();
        ex.setFieldName("projectID");
        ex.setLocalizedErrorKey("item.action.move.err.same");
        throw ex;
    }
    Integer stateID = parseInt(params.get("statusID"));
    if (stateID == null) {
        boolean stateValid = StatusWorkflow.statusIsValid(projectID, issueTypeID, workItem.getStateID());
        if (!stateValid) {
            params.put("statusNeeded", Boolean.valueOf(true));
            PluginItemActionException ex = new PluginItemActionException();
            ex.setFieldName("projectID");
            ex.setLocalizedErrorKey("item.action.move.err.invalidState");
            throw ex;
        } else {
            params.put("statusNeeded", Boolean.valueOf(false));
        }
    }
    WorkItemContext ctx = ItemBL.moveItem(workItemID, user.getObjectID(), locale, projectID, issueTypeID,
            stateID);
    Boolean moveChildren = parseBoolean(params.get("moveChildren"));
    ctx.getWorkItemBean().setMoveChildren(moveChildren.booleanValue());
    Set<Integer> presentFields = ctx.getPresentFieldIDs();
    presentFields.add(SystemFields.INTEGER_PROJECT);
    presentFields.add(SystemFields.INTEGER_ISSUETYPE);
    return ctx;
}

From source file:com.jada.taglib.language.LanguageTagSupport.java

public boolean isFieldDisabled() throws Exception {
    if (disabled != null) {
        if (disabled.equalsIgnoreCase("true")) {
            return true;
        }// w w w . j a  v  a2 s .  c  o m
        if (disabled.equalsIgnoreCase("false")) {
            return false;
        }
    }
    if (isSiteProfileDefault() && isSiteCurrencyDefault()) {
        return false;
    }
    String langFieldName = property + "LangFlag";
    String currFieldName = property + "CurrFlag";
    Object result = null;

    if (currency != null && currency.toLowerCase().equals("true")) {
        try {
            result = TagUtils.getInstance().lookup(super.pageContext, name, currFieldName, null);
        } catch (Exception e) {
        }
        ;
    } else if (language != null && language.toLowerCase().equals("true")) {
        try {
            result = TagUtils.getInstance().lookup(super.pageContext, name, langFieldName, null);
        } catch (Exception e) {
        }
        ;
    } else {
        try {
            result = TagUtils.getInstance().lookup(super.pageContext, name, langFieldName, null);
        } catch (Exception e) {
        }
        ;
        try {
            if (result == null) {
                result = TagUtils.getInstance().lookup(super.pageContext, name, currFieldName, null);
            }
        } catch (Exception e) {
        }
        ;
    }

    if (result == null) {
        return true;
    }
    Boolean b = (Boolean) result;
    if (b.booleanValue()) {
        return false;
    }
    return true;
}

From source file:com.aurel.track.item.action.CopyItemActionPlugin.java

@Override
public WorkItemContext next(Locale locale, TPersonBean user, Integer workItemID, Integer parentID,
        Map<String, Object> params, String synopsis, String description) throws PluginItemActionException {

    WorkItemContext ctx = ItemBL.editCopyWorkItem(workItemID, user.getObjectID(), locale);

    TWorkItemBean workItemBean = ctx.getWorkItemBean();
    Boolean deepCopy = parseBoolean(params.get("deepCopy"));
    Boolean copyAttachments = parseBoolean(params.get("copyAttachments"));
    Boolean copyChildren = parseBoolean(params.get("copyChildren"));
    workItemBean.setDeepCopy(deepCopy.booleanValue());
    workItemBean.setCopyAttachments(copyAttachments.booleanValue());
    workItemBean.setCopyChildren(copyChildren.booleanValue());

    String[] msgArguments = new String[] { workItemBean.getSynopsis() };
    String newSysnopsys = LocalizeUtil.getParametrizedString("common.copy", msgArguments, locale);
    workItemBean.setSynopsis(newSysnopsys);
    return ctx;//  ww w  .  j  a v a  2s . co m
}

From source file:org.slc.sli.dashboard.web.controller.ConfigController.java

/**
 * Controller to return configs (driver and all edOrg levels), without waterfall logic.
 * The 'params' parameter contains a map of url query parameters. The parameters are matched
 * to the attributes in the JSON config files.
 *
 * @param configType//ww w  .  j a  v a  2 s . c  om
 * @param request
 * @param response
 * @return DriverConfig and all EdOrg hierarchy JSON.
 */
@RequestMapping(value = CONFIG_ALL, method = RequestMethod.GET)
@ResponseBody
public List<ConfigWrapper> handleConfigPanels(@RequestParam Map<String, String> configType,
        final HttpServletRequest request, HttpServletResponse response) {

    String token = SecurityUtil.getToken();
    Boolean isAdmin = SecurityUtil.isAdmin();
    if (isAdmin != null && isAdmin.booleanValue()) {
        Map<String, Collection<Config>> mapConfigs = configManager.getAllConfigByType(token,
                userEdOrgManager.getUserEdOrg(token), configType);

        // re-organize config objects. group by Education Agency Name
        Map<String, List<ConfigWrapper>> mapConfigWrappers = new HashMap<String, List<ConfigWrapper>>();
        if (mapConfigs != null) {
            Set<String> edOrgNames = mapConfigs.keySet();
            for (String edOrgName : edOrgNames) {
                // get Collection of Config by edOrgName
                Collection<Config> configs = mapConfigs.get(edOrgName);
                for (Config config : configs) {
                    ConfigWrapper configWrapper = new ConfigWrapper(config);
                    configWrapper.setEducationAgencyName(edOrgName);
                    List<ConfigWrapper> configWrappers = mapConfigWrappers.get(configWrapper.getId());
                    if (configWrappers == null) {
                        configWrappers = new LinkedList<ConfigWrapper>();
                        mapConfigWrappers.put(configWrapper.getId(), configWrappers);
                    }
                    configWrappers.add(configWrapper);
                }
            }
        }

        // make a single array of ConfigWrapper
        List<ConfigWrapper> listConfigWrapper = new LinkedList<ConfigWrapper>();
        for (String idName : mapConfigWrappers.keySet()) {
            listConfigWrapper.addAll(mapConfigWrappers.get(idName));
        }

        // make alphabetical order (1st. Config.id 2nd. EdOrgName)
        Collections.sort(listConfigWrapper);
        return listConfigWrapper;
    }
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    return null;
}