Example usage for java.lang Integer intValue

List of usage examples for java.lang Integer intValue

Introduction

In this page you can find the example usage for java.lang Integer intValue.

Prototype

@HotSpotIntrinsicCandidate
public int intValue() 

Source Link

Document

Returns the value of this Integer as an int .

Usage

From source file:com.aurel.track.admin.customize.treeConfig.field.FieldBL.java

/**
 * Gets the system option type corresponding to the picker
 * @param fieldID//  w  w  w .j  a v  a2  s .  c o m
 * @return
 */
public static Integer getSystemOptionType(Integer fieldID) {
    if (fieldID != null) {
        IFieldTypeRT fieldTypeRT = null;
        if (fieldID.intValue() > 0) {
            //not a pseudo field
            fieldTypeRT = FieldTypeManager.getFieldTypeRT(fieldID);
        }
        if (fieldTypeRT != null && fieldTypeRT.isCustom() && fieldTypeRT.isLookup()) {
            CustomSelectBaseRT customSelectBaseRT = (CustomSelectBaseRT) fieldTypeRT;
            if (customSelectBaseRT.isCustomPicker()) {
                CustomPickerRT customPickerRT = (CustomPickerRT) customSelectBaseRT;
                return customPickerRT.getSystemOptionType();
            }
        }
    }
    return null;
}

From source file:com.aurel.track.exchange.excel.ExcelFieldMatchBL.java

/**
 * Gets a columnName to fieldID map/*from w  ww. j a v  a2  s .  c o m*/
 * @param columnIndexToFieldIDMap
 * @param columnIndexToColumNameMap
 * @return
 */
static Map<String, Integer> getColumnNameToFieldIDMap(Map<Integer, Integer> columnIndexToFieldIDMap,
        SortedMap<Integer, String> columnIndexToColumNameMap) {
    Map<String, Integer> columNameToFieldIDMap = new HashMap<String, Integer>();
    Iterator<Integer> iterator = columnIndexToColumNameMap.keySet().iterator();
    while (iterator.hasNext()) {
        Integer columnIndex = iterator.next();
        String columnName = columnIndexToColumNameMap.get(columnIndex);
        if (columnIndexToFieldIDMap.containsKey(columnIndex)) {
            Integer fieldID = columnIndexToFieldIDMap.get(columnIndex);
            if (fieldID != null && fieldID.intValue() != 0) {
                columNameToFieldIDMap.put(columnName, columnIndexToFieldIDMap.get(columnIndex));
            }
        }
    }
    return columNameToFieldIDMap;
}

From source file:com.aurel.track.admin.customize.treeConfig.field.FieldBL.java

/**
 * Whether the field is a tree based custom picker
 * @param fieldTypeRT/*  w  w w .j  a  v a 2s  .c o  m*/
 * @return
 */
public static boolean isTree(Integer fieldID) {
    if (fieldID != null) {
        IFieldTypeRT fieldTypeRT = null;
        if (fieldID.intValue() > 0) {
            //not a pseudo field
            fieldTypeRT = FieldTypeManager.getFieldTypeRT(fieldID);
        }
        if (fieldTypeRT != null && fieldTypeRT.isLookup()) {
            try {
                ILookup lookup = (ILookup) fieldTypeRT;
                return lookup.isTree();
            } catch (Exception e) {
                LOGGER.info(e.getMessage());
                LOGGER.debug(ExceptionUtils.getStackTrace(e));
                ;
            }
        }
    }
    return false;
}

From source file:com.aurel.track.admin.customize.treeConfig.field.FieldBL.java

/**
 * Whether the field is a custom select field
 * @param fieldID//from w  w w .  j a v a2 s .  com
 * @return
 */
public static boolean isCustomPicker(Integer fieldID) {
    if (fieldID != null) {
        IFieldTypeRT fieldTypeRT = null;
        if (fieldID.intValue() > 0) {
            //not a pseudo field
            fieldTypeRT = FieldTypeManager.getFieldTypeRT(fieldID);
        }
        if (fieldTypeRT != null && fieldTypeRT.isCustom()) {
            ICustomFieldTypeRT customFieldTypeRT = (ICustomFieldTypeRT) fieldTypeRT;
            if (customFieldTypeRT.isCustomSelect()) {
                try {
                    CustomSelectBaseRT customSelectBaseRT = (CustomSelectBaseRT) customFieldTypeRT;
                    if (customSelectBaseRT != null) {
                        return customSelectBaseRT.isCustomPicker();
                    }
                } catch (Exception e) {
                    LOGGER.info(e.getMessage());
                    LOGGER.debug(ExceptionUtils.getStackTrace(e));
                }
            }
        }
    }
    return false;
}

From source file:com.aurel.track.itemNavigator.filterInMenu.FilterInMenuBL.java

/**
 * Gets the last executed queries for a person
 * @param personID//w ww.  j  a v  a  2 s. c  om
 * @param locale
 * @return
 */
public static List<FilterInMenuTO> getLastExecutedQueries(TPersonBean personBean, Locale locale) {
    Integer personID = personBean.getObjectID();
    List<TLastExecutedQueryBean> lastQueries = LastExecutedBL.loadByPerson(personID);
    List<FilterInMenuTO> result = new ArrayList<FilterInMenuTO>();
    if (lastQueries != null) {
        List<Integer> clobIDs = new LinkedList<Integer>();
        Map<Integer, Integer> instantLastExecutedObjectIDToClobIDMap = new HashMap<Integer, Integer>();
        Map<Integer, Integer> savedLastExecutedObjectIDToFilterIDMap = new HashMap<Integer, Integer>();
        Map<Integer, String> savedQueryIDToViewIDMap = new HashMap<Integer, String>();
        Set<Integer> savedQueryIDs = new HashSet<Integer>();
        Set<Integer> dashboardIDs = new HashSet<Integer>();
        Set<Integer> basketIDs = new HashSet<Integer>();
        Set<Integer> projectReleaseIDs = new HashSet<Integer>();
        Map<Integer, Integer> luceneLastExecutedObjectIDToClobIDMap = new HashMap<Integer, Integer>();
        Set<Integer> statusIDs = new HashSet<Integer>();
        for (TLastExecutedQueryBean lastExecutedQueryBean : lastQueries) {
            Integer lastExecutedID = lastExecutedQueryBean.getObjectID();
            Integer queryID = lastExecutedQueryBean.getQueryKey();
            Integer clobID = lastExecutedQueryBean.getQueryClob();
            Integer queryType = lastExecutedQueryBean.getQueryType();
            if (queryType != null) {
                switch (queryType.intValue()) {
                case QUERY_TYPE.INSTANT:
                    if (clobID != null) {
                        instantLastExecutedObjectIDToClobIDMap.put(lastExecutedID, clobID);
                        clobIDs.add(clobID);
                    }
                    break;
                case QUERY_TYPE.SAVED:
                    savedLastExecutedObjectIDToFilterIDMap.put(lastExecutedID, queryID);
                    savedQueryIDs.add(queryID);
                    break;
                case QUERY_TYPE.DASHBOARD:
                    dashboardIDs.add(queryID);
                    break;
                case QUERY_TYPE.BASKET:
                    basketIDs.add(queryID);
                    break;
                case QUERY_TYPE.PROJECT_RELEASE:
                    projectReleaseIDs.add(queryID);
                    break;
                case QUERY_TYPE.LUCENE_SEARCH:
                    if (clobID != null) {
                        luceneLastExecutedObjectIDToClobIDMap.put(lastExecutedID, clobID);
                        clobIDs.add(clobID);
                    }
                    break;
                case QUERY_TYPE.STATUS:
                    statusIDs.add(queryID);
                    break;
                }
            }
        }
        Map<Integer, TDashboardFieldBean> dashboardMap = new HashMap<Integer, TDashboardFieldBean>();
        if (!dashboardIDs.isEmpty()) {
            List<TDashboardFieldBean> dasboardFields = DAOFactory.getFactory().getDashboardFieldDAO()
                    .loadByKeys(dashboardIDs);
            if (dasboardFields != null) {
                for (TDashboardFieldBean dashboardFieldBean : dasboardFields) {
                    dashboardMap.put(dashboardFieldBean.getObjectID(), dashboardFieldBean);
                }
            }
        }
        Map<Integer, TBasketBean> basketMap = new HashMap<Integer, TBasketBean>();
        if (!basketIDs.isEmpty()) {
            List<TBasketBean> basketBeans = BasketBL.loadByPrimaryKeys(basketIDs);
            if (basketBeans != null) {
                for (TBasketBean basketBean : basketBeans) {
                    basketMap.put(basketBean.getObjectID(), basketBean);
                }
            }
        }
        Map<Integer, TQueryRepositoryBean> savedFilterMap = new HashMap<Integer, TQueryRepositoryBean>();
        Map<Integer, Integer> savedLastExecutedObjectIDToClobIDMap = new HashMap<Integer, Integer>();
        if (!savedQueryIDs.isEmpty()) {
            List<TQueryRepositoryBean> savedFilterBeans = FilterBL
                    .loadByPrimaryKeys(GeneralUtils.createIntegerListFromCollection(savedQueryIDs));
            Map<Integer, Integer> savedQueryIDToClobIDMap = new HashMap<Integer, Integer>();
            if (savedFilterBeans != null) {
                for (TQueryRepositoryBean queryRepositoryBean : savedFilterBeans) {
                    Integer filterID = queryRepositoryBean.getObjectID();
                    Integer clobKey = queryRepositoryBean.getQueryKey();
                    clobIDs.add(clobKey);
                    savedQueryIDToViewIDMap.put(filterID, queryRepositoryBean.getViewID());
                    savedQueryIDToClobIDMap.put(filterID, clobKey);
                    savedFilterMap.put(filterID, queryRepositoryBean);
                }
            }
            for (Map.Entry<Integer, Integer> lastExecutedToFilterIDEntry : savedLastExecutedObjectIDToFilterIDMap
                    .entrySet()) {
                Integer lastExecutedObjectID = lastExecutedToFilterIDEntry.getKey();
                Integer filterID = lastExecutedToFilterIDEntry.getValue();
                if (savedQueryIDToClobIDMap.containsKey(filterID)) {
                    savedLastExecutedObjectIDToClobIDMap.put(lastExecutedObjectID,
                            savedQueryIDToClobIDMap.get(filterID));
                }
            }
        }
        List<TCLOBBean> clobBeans = ClobBL.loadByPrimaryKeys(clobIDs);
        Map<Integer, String> clobIDToClobValueMap = new HashMap<Integer, String>();
        for (TCLOBBean clobBean : clobBeans) {
            clobIDToClobValueMap.put(clobBean.getObjectID(), clobBean.getCLOBValue());
        }
        Map<Integer, String> lastExecutedObjectIDToClobValueMap = new HashMap<Integer, String>();
        appendLastExecutedIDToClobValue(instantLastExecutedObjectIDToClobIDMap, clobIDToClobValueMap,
                lastExecutedObjectIDToClobValueMap);
        appendLastExecutedIDToClobValue(savedLastExecutedObjectIDToClobIDMap, clobIDToClobValueMap,
                lastExecutedObjectIDToClobValueMap);
        appendLastExecutedIDToClobValue(luceneLastExecutedObjectIDToClobIDMap, clobIDToClobValueMap,
                lastExecutedObjectIDToClobValueMap);
        for (TLastExecutedQueryBean lastExecutedQuery : lastQueries) {
            Integer lastExecutedQueryID = lastExecutedQuery.getObjectID();
            Integer queryID = lastExecutedQuery.getQueryKey();
            Integer queryType = lastExecutedQuery.getQueryType();
            Object entityBean = null;
            if (queryType != null) {
                switch (queryType.intValue()) {
                case QUERY_TYPE.SAVED:
                    entityBean = savedFilterMap.get(queryID);
                    break;
                case QUERY_TYPE.DASHBOARD:
                    entityBean = dashboardMap.get(queryID);
                    break;
                case QUERY_TYPE.BASKET:
                    entityBean = basketMap.get(queryID);
                    break;
                }
            }
            String filterExpression = lastExecutedObjectIDToClobValueMap.get(lastExecutedQueryID);
            try {
                IFilterInMenu filterInMenu = FilterInMenuFactory.getInstance().getFilterInMenuFacade(queryType,
                        queryID);
                String label = filterInMenu.getLabel(entityBean, filterExpression, locale);
                String tooltip = filterInMenu.getTooltip(entityBean, filterExpression, locale);
                if (tooltip == null) {
                    tooltip = label;
                }
                String icon = filterInMenu.getIcon();
                String iconCls = null;
                if (icon == null) {
                    iconCls = filterInMenu.getIconCls(entityBean);
                }
                FilterInMenuTO filterInMenuTO = new FilterInMenuTO();
                filterInMenuTO.setObjectID(queryID);
                filterInMenuTO.setLabel(label);
                filterInMenuTO.setTooltip(tooltip);
                filterInMenuTO.setType(queryType);
                filterInMenuTO.setIcon(icon);
                filterInMenuTO.setIconCls(iconCls);
                filterInMenuTO.setLastExecutedQueryID(lastExecutedQueryID);
                String viewID = savedQueryIDToViewIDMap.get(queryID);
                if (viewID == null) {
                    filterInMenuTO.setMaySaveFilterLayout(false);
                } else {
                    filterInMenuTO.setViewID(viewID);
                    filterInMenuTO.setMaySaveFilterLayout(
                            filterInMenu.maySaveFilterWithViewLayout(entityBean, personBean));
                }
                result.add(filterInMenuTO);
            } catch (Exception ex) {
                LOGGER.info("Loading the last executed query " + queryID + " of type " + queryType
                        + " failed with " + ex.getMessage());
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.error(ExceptionUtils.getStackTrace(ex));
                }
            }
        }
    }
    return result;
}

From source file:Main.java

/**
 * <p>Converts an Integer to a Boolean using the convention that {@code zero}
 * is {@code false}.</p>/* www .  j a  v a 2 s .  c  o m*/
 *
 * <p>{@code null} will be converted to {@code null}.</p>
 *
 * <p>NOTE: This returns null and will throw a NullPointerException if autoboxed to a boolean. </p>
 *
 * <pre>
 *   BooleanUtils.toBoolean(Integer.valueOf(0))    = Boolean.FALSE
 *   BooleanUtils.toBoolean(Integer.valueOf(1))    = Boolean.TRUE
 *   BooleanUtils.toBoolean(Integer.valueOf(null)) = null
 * </pre>
 *
 * @param value  the Integer to convert
 * @return Boolean.TRUE if non-zero, Boolean.FALSE if zero,
 *  {@code null} if {@code null} input
 */
public static Boolean toBooleanObject(final Integer value) {
    if (value == null) {
        return null;
    }
    return value.intValue() == 0 ? Boolean.FALSE : Boolean.TRUE;
}

From source file:com.glaf.base.utils.ParamUtil.java

public static int getInt(Map<String, Object> dataMap, String key) {
    int result = 0;
    Object value = dataMap.get(key);
    if (value != null && StringUtils.isNotEmpty(value.toString())) {
        if (value instanceof String) {
            String tmp = (String) value;
            result = Integer.valueOf(tmp);
        } else if (value instanceof Integer) {
            Integer x = (Integer) value;
            result = x.intValue();
        } else if (value instanceof Long) {
            Long x = (Long) value;
            result = x.intValue();//from   w  w  w . ja v  a  2s .co m
        } else if (value instanceof Double) {
            Double x = (Double) value;
            result = x.intValue();
        }
    }
    return result;
}

From source file:com.glaf.base.utils.ParamUtil.java

public static long getLong(Map<String, Object> dataMap, String key) {
    long result = 0;
    Object value = dataMap.get(key);
    if (value != null && StringUtils.isNotEmpty(value.toString())) {
        if (value instanceof String) {
            String tmp = (String) value;
            result = Long.valueOf(tmp);
        } else if (value instanceof Integer) {
            Integer x = (Integer) value;
            result = x.intValue();
        } else if (value instanceof Long) {
            Long x = (Long) value;
            result = x.longValue();//  w w  w.j  a  v  a  2s  .c om
        } else if (value instanceof Double) {
            Double x = (Double) value;
            result = x.longValue();
        }
    }
    return result;
}

From source file:com.aurel.track.item.ItemActionJSON.java

public static String encodeFieldValues(Set<Integer> presentFields, WorkItemContext workItemContext,
        boolean useProjectSpecificID, boolean isMobileApplication) {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    for (Iterator<Integer> iterator = presentFields.iterator(); iterator.hasNext();) {
        Integer fieldID = iterator.next();
        Object value = workItemContext.getWorkItemBean().getAttribute(fieldID);
        String jsonValue = null;//from   w  w w.  java 2 s.com
        if (useProjectSpecificID && fieldID.intValue() == SystemFields.ISSUENO) {
            jsonValue = "\"" + ItemBL.getSpecificProjectID(workItemContext) + "\"";
        } else {
            FieldType fieldType = FieldTypeManager.getInstance().getType(fieldID);
            fieldType.setFieldID(fieldID);
            //set
            if (fieldType != null) {
                TypeRendererRT fieldTypeRendererRT = fieldType.getRendererRT();
                int valueType = fieldType.getFieldTypeRT().getValueType();
                switch (valueType) {
                case ValueType.DATE:
                    jsonValue = "\"" + DateTimeUtils.getInstance().formatGUIDate((Date) value,
                            workItemContext.getLocale()) + "\"";
                    break;
                case ValueType.LONGTEXT:
                    if (value != null) {
                        List<MacroDef> macroDefList = MacroBL.parseMacros(value.toString(),
                                MacroManager.MACRO_ISSUE);
                        if (macroDefList != null) {
                            IMacro macro = new MacroIssueDecorate();
                            MacroContext macroContext = new MacroContext();
                            macroContext.setUseProjectSpecificID(useProjectSpecificID);
                            value = MacroBL.replaceMacros(macroDefList, value.toString(), macroContext, macro);
                        }
                    }

                    jsonValue = value == null ? null : "\"" + JSONUtility.escape(value.toString()) + "\"";
                    //
                    break;
                default:
                    jsonValue = fieldTypeRendererRT.encodeJsonValue(value);
                    break;
                }
            }
        }

        //append "," after each value. we need to remove the last one
        JSONUtility.appendJSONValue(sb, "f" + fieldID, jsonValue);
    }
    if (sb.length() > 1) {
        //remove last ","
        sb.deleteCharAt(sb.length() - 1);
    }

    sb.append("}");
    return sb.toString();
}

From source file:com.htmlhifive.tools.rhino.Util.java

/**
 * ??.//from  w  w  w . j av  a2s.c  om
 *
 * @param node
 * @param prop
 * @return
 */
public static int getPropValue(Node node, int prop) {

    if (null == node) {
        return 0;
    }
    Integer propObj = (Integer) node.getProp(prop);
    if (null != propObj) {
        return propObj.intValue();
    }
    return 0;
}