Example usage for java.lang Integer equals

List of usage examples for java.lang Integer equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:com.clustercontrol.jobmanagement.composite.WaitRuleComposite.java

/**
 * ??????????/*from w ww  . j  a v a  2 s  .  c  o  m*/
 *
 * @return ??
 *
 * @see com.clustercontrol.jobmanagement.bean.JobWaitRuleInfo
 */
public ValidateResult createWaitRuleInfo() {
    m_log.debug("createWaitRuleInfo");
    ValidateResult result = null;

    //???
    ArrayList<JobObjectInfo> list = new ArrayList<JobObjectInfo>();
    ArrayList<?> tableData = (ArrayList<?>) m_viewer.getInput();
    HashMap<String, Integer> map = new HashMap<String, Integer>();

    for (int i = 0; i < tableData.size(); i++) {
        ArrayList<?> tableLineData = (ArrayList<?>) tableData.get(i);
        JobObjectInfo info = array2JobObjectInfo(tableLineData);
        // ????????
        if (info.getType() == JudgmentObjectConstant.TYPE_JOB_END_STATUS) {
            Integer checkValue = map.get(info.getJobId() + info.getType());
            if (checkValue == null || !checkValue.equals(info.getValue())) {
                list.add(info);
                map.put(info.getJobId() + info.getType(), info.getValue());
            }
        } else if (info.getType() == JudgmentObjectConstant.TYPE_JOB_END_VALUE) {
            Integer checkValue = map.get(info.getJobId() + info.getType());
            if (checkValue == null || checkValue.equals(info.getValue())) {
                list.add(info);
                map.put(info.getJobId() + info.getType(), info.getValue());
            }
        } else if (info.getType() == JudgmentObjectConstant.TYPE_TIME) {
            if (map.get("TIME") == null) {
                list.add(info);
                map.put("TIME", 1);
            }
        } else if (info.getType() == JudgmentObjectConstant.TYPE_START_MINUTE) {
            m_log.debug("info.getType=" + info.getType());
            m_log.debug("info.getStartMinute=" + info.getStartMinute());
            if (map.get(info.getType().toString()) == null) {
                list.add(info);
                map.put(info.getType().toString(), info.getValue());
            }
        } else if (info.getType() == JudgmentObjectConstant.TYPE_JOB_PARAMETER) {
            Integer checkValue = map.get(info.getType() + info.getDecisionValue01()
                    + info.getDecisionCondition() + info.getDecisionValue02());
            if (checkValue == null || !checkValue.equals(info.getValue())) {
                list.add(info);
                map.put(info.getType() + info.getDecisionValue01() + info.getDecisionCondition()
                        + info.getDecisionValue02(), info.getValue());
            }
        }
    }
    List<JobObjectInfo> jobObjectInfoList = m_waitRule.getObject();
    jobObjectInfoList.clear();
    jobObjectInfoList.addAll(list);

    //??
    if (m_andCondition.getSelection()) {
        m_waitRule.setCondition(ConditionTypeConstant.TYPE_AND);
    } else {
        m_waitRule.setCondition(ConditionTypeConstant.TYPE_OR);
    }

    //???????? 
    m_waitRule.setEndCondition(m_endCondition.getSelection());

    //?
    try {
        m_waitRule.setEndStatus(getSelectEndStatus(m_endStatus));
        m_waitRule.setEndValue(Integer.parseInt(m_endValue.getText()));
    } catch (NumberFormatException e) {
        if (m_waitRule.isEndCondition().booleanValue()) {
            result = new ValidateResult();
            result.setValid(false);
            result.setID(Messages.getString("message.hinemos.1"));
            result.setMessage(Messages.getString("message.job.21"));
            return result;
        }
    }

    return null;
}

From source file:edu.isi.misd.scanner.network.modules.worker.processors.ptr.PrepToResearchProcessor.java

private PrepToResearchResponse analyzeFile(PrepToResearchRequest request, File analysisFile) throws Exception {
    PrepToResearchResponse response = new PrepToResearchResponse();
    Integer requestedOmopConceptID = request.getOmopConceptID();
    CSVFormat csvFormat = CSVFormat.newFormat(',').withHeader().withCommentMarker('#').withQuote('"');
    CSVParser parser = CSVParser.parse(analysisFile, Charset.defaultCharset(), csvFormat);
    for (CSVRecord csvRecord : parser) {
        try {/*from ww  w  .j  a v  a  2 s .  c o  m*/
            this.validateCSVRecord(csvRecord);

            // check the ID first, if no match continue
            Integer omopConceptID = Integer
                    .parseInt(csvRecord.get(ExpectedColumnName.OMOP_CONCEPT_ID.toString()));
            if (!requestedOmopConceptID.equals(omopConceptID)) {
                continue;
            }

            // match found, create response output record
            if (log.isDebugEnabled()) {
                log.debug(String.format("Found a match for requested ID %s, record: %s", requestedOmopConceptID,
                        csvRecord.toString()));
            }
            PrepToResearchRecord ptrRecord = new PrepToResearchRecord();
            ptrRecord.setOmopConceptID(omopConceptID);
            ptrRecord.setOmopConceptName(csvRecord.get(ExpectedColumnName.OMOP_CONCEPT_NAME));
            ptrRecord.setCategory(csvRecord.get(ExpectedColumnName.CATEGORY));
            ptrRecord.setCategoryValue(csvRecord.get(ExpectedColumnName.CATEGORY_VALUE));
            ptrRecord.setCountFemales(Integer.parseInt(csvRecord.get(ExpectedColumnName.COUNT_FEMALES)));
            ptrRecord.setCountMales(Integer.parseInt(csvRecord.get(ExpectedColumnName.COUNT_MALES)));
            ptrRecord.setCountTotal(Integer.parseInt(csvRecord.get(ExpectedColumnName.COUNT_TOTAL)));

            response.getPrepToResearchRecord().add(ptrRecord);
        } catch (Exception e) {
            String error = String.format(
                    "An exception occured while processing row number %s with the following values %s: %s",
                    csvRecord.getRecordNumber(), csvRecord.toString(), e.toString());
            parser.close();
            throw new RuntimeException(error);
        }
    }
    parser.close();
    return response;
}

From source file:com.aurel.track.item.link.ItemLinkBL.java

/**
 * Gets the link data for a link/*from   w ww. ja v  a 2s  .  c  om*/
 * @param workItemID
 * @param workItemLinkBean
 * @return
 */
static ItemLinkTO getLinkData(Integer workItemID, TWorkItemLinkBean workItemLinkBean) {
    ItemLinkTO itemLinkTO = new ItemLinkTO();
    if (workItemLinkBean != null) {
        Integer linkPred = workItemLinkBean.getLinkPred();
        Integer linkSucc = workItemLinkBean.getLinkSucc();
        Integer linkDirection = workItemLinkBean.getLinkDirection();
        //Integer direction = linkDirection;
        //1. current item is linkPred: the link is visible from linkPred as current item if link is bidirectional or or UNIDIRECTIONAL_OUTWARD
        if (linkSucc != null && (workItemID == null || //for new item
                workItemID.equals(linkPred))) { //for existing item
            //the edited item  (new or existing) is predecessor: load the the successor linked item details
            itemLinkTO.setLinkedWorkItemID(linkSucc);
            try {
                TWorkItemBean linkedWorkItemBean = workItemDAO.loadByPrimaryKey(linkSucc);
                if (linkedWorkItemBean != null) {
                    itemLinkTO.setLinkedWorkItemTitle(linkedWorkItemBean.getSynopsis());
                }
            } catch (ItemLoaderException e) {
                LOGGER.error("Loading the linkSucc failed with " + e.getMessage());
            }

        } else {
            //2. current item is linkSucc: the link is visible from linkSucc as current item if  link is bidirectional (in this case the reverse direction)
            //or UNIDIRECTIONAL_INWARD: the successor sees the predecessor but not vice versa
            if (linkPred != null && (workItemID == null || workItemID.equals(linkSucc))) {
                //the edited item is successor: load the predecessor item details
                boolean isBidirectional = false;
                String linkTypePluginClass = LinkTypeBL.getLinkTypePluginString(workItemLinkBean.getLinkType());
                if (linkTypePluginClass != null) {
                    ILinkType linkType = (ILinkType) PluginManager.getInstance()
                            .getPluginClass(PluginManager.LINKTYPE_ELEMENT, linkTypePluginClass);
                    if (linkType != null) {
                        isBidirectional = ILinkType.LINK_DIRECTION.BIDIRECTIONAL == linkType
                                .getPossibleDirection();
                    }
                }
                if (isBidirectional) {
                    //by bidirectional links if the edited item is the successor the saved direction (which was saved when the edited item was considered predecessor) should be inverted.
                    //by save it will not  be inverted, only for correct rendering
                    linkDirection = LinkTypeBL.getReverseDirection(linkDirection);
                }
                itemLinkTO.setLinkedWorkItemID(linkPred);
                try {
                    TWorkItemBean linkedWorkItemBean = workItemDAO.loadByPrimaryKey(linkPred);
                    if (linkedWorkItemBean != null) {
                        itemLinkTO.setLinkedWorkItemTitle(linkedWorkItemBean.getSynopsis());
                    }
                } catch (ItemLoaderException e) {
                    LOGGER.error("Loading the linkPred failed with " + e.getMessage());
                }

            }
        }
        //itemLinkTO.setLinkTypeWithDirection(MergeUtil.mergeKey(workItemLinkBean.getLinkType(), direction));
        itemLinkTO.setLinkType(workItemLinkBean.getLinkType());
        itemLinkTO.setLinkDirection(linkDirection);
        itemLinkTO.setDescription(workItemLinkBean.getDescription());

        ILinkType linkTypeInstance = LinkTypeBL
                .getLinkTypePluginInstanceByLinkTypeKey(workItemLinkBean.getLinkType());
        if (linkTypeInstance != null) {
            itemLinkTO.setParameterMap(linkTypeInstance.prepareParametersMap(workItemLinkBean));
        }
    }
    return itemLinkTO;
}

From source file:fr.dutra.confluence2wordpress.action.SyncAction.java

private void checkPostSlugAvailability() throws WordpressXmlRpcException {
    WordpressClient client = pluginSettingsManager.getWordpressClient();
    Integer retrievedPostId = client.findPageIdBySlug(getMetadata().getPostSlug());
    if (retrievedPostId != null && !retrievedPostId.equals(getMetadata().getPostId())) {
        addActionError(getText(ERRORS_POST_SLUG_AVAILABILITY_KEY, new Object[] { retrievedPostId }));
    }//from w  ww. ja  v  a2s  .c o  m
}

From source file:com.qcadoo.mes.productionScheduling.listeners.OperationDurationDetailsInOrderListeners.java

private void scheduleOrder(final Long orderId) {
    Entity order = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER)
            .get(orderId);//from ww  w  .j ava2  s  .c o  m

    if (order == null) {
        return;
    }

    Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);

    if (technology == null) {
        return;
    }

    DataDefinition technologyOperationComponentDD = dataDefinitionService.get(
            TechnologiesConstants.PLUGIN_IDENTIFIER,
            TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT);

    List<Entity> operations = technologyOperationComponentDD.find()
            .add(SearchRestrictions.belongsTo(TechnologyOperationComponentFields.TECHNOLOGY, technology)).list()
            .getEntities();

    Date orderStartDate = order.getDateField(OrderFields.START_DATE);
    for (Entity operation : operations) {
        Entity techOperCompTimeCalculation = operation
                .getBelongsToField(TechnologyOperationComponentFieldsTNFO.TECH_OPER_COMP_TIME_CALCULATION);

        if (techOperCompTimeCalculation == null) {
            continue;
        }

        Integer offset = techOperCompTimeCalculation
                .getIntegerField(TechOperCompTimeCalculationsFields.OPERATION_OFF_SET);
        Integer duration = techOperCompTimeCalculation
                .getIntegerField(TechOperCompTimeCalculationsFields.EFFECTIVE_OPERATION_REALIZATION_TIME);

        techOperCompTimeCalculation.setField(TechOperCompTimeCalculationsFields.EFFECTIVE_DATE_FROM, null);
        techOperCompTimeCalculation.setField(TechOperCompTimeCalculationsFields.EFFECTIVE_DATE_TO, null);

        if (offset == null || duration == null) {
            continue;
        }

        if (duration.equals(0)) {
            duration = duration + 1;
        }

        Date dateFrom = shiftsService.findDateToForOrder(orderStartDate, offset);
        if (dateFrom == null) {
            continue;
        }

        Date dateTo = shiftsService.findDateToForOrder(orderStartDate, offset + duration);
        if (dateTo == null) {
            continue;
        }

        techOperCompTimeCalculation.setField(TechOperCompTimeCalculationsFields.EFFECTIVE_DATE_FROM, dateFrom);
        techOperCompTimeCalculation.setField(TechOperCompTimeCalculationsFields.EFFECTIVE_DATE_TO, dateTo);

        techOperCompTimeCalculation.getDataDefinition().save(techOperCompTimeCalculation);
    }
}

From source file:com.cloud.hypervisor.kvm.resource.LibvirtDomainXMLParser.java

public boolean parseDomainXML(String domXML) {
    DocumentBuilder builder;/* ww w  .j a va 2 s. c  o  m*/
    try {
        builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

        InputSource is = new InputSource();
        is.setCharacterStream(new StringReader(domXML));
        Document doc = builder.parse(is);

        Element rootElement = doc.getDocumentElement();

        desc = getTagValue("description", rootElement);

        Element devices = (Element) rootElement.getElementsByTagName("devices").item(0);
        NodeList disks = devices.getElementsByTagName("disk");
        for (int i = 0; i < disks.getLength(); i++) {
            Element disk = (Element) disks.item(i);
            String type = disk.getAttribute("type");
            DiskDef def = new DiskDef();
            if (type.equalsIgnoreCase("network")) {
                String diskFmtType = getAttrValue("driver", "type", disk);
                String diskCacheMode = getAttrValue("driver", "cache", disk);
                String diskPath = getAttrValue("source", "name", disk);
                String protocol = getAttrValue("source", "protocol", disk);
                String authUserName = getAttrValue("auth", "username", disk);
                String poolUuid = getAttrValue("secret", "uuid", disk);
                String host = getAttrValue("host", "name", disk);
                int port = Integer.parseInt(getAttrValue("host", "port", disk));
                String diskLabel = getAttrValue("target", "dev", disk);
                String bus = getAttrValue("target", "bus", disk);

                DiskDef.DiskFmtType fmt = null;
                if (diskFmtType != null) {
                    fmt = DiskDef.DiskFmtType.valueOf(diskFmtType.toUpperCase());
                }

                def.defNetworkBasedDisk(diskPath, host, port, authUserName, poolUuid, diskLabel,
                        DiskDef.DiskBus.valueOf(bus.toUpperCase()),
                        DiskDef.DiskProtocol.valueOf(protocol.toUpperCase()), fmt);
                def.setCacheMode(DiskDef.DiskCacheMode.valueOf(diskCacheMode.toUpperCase()));
            } else {
                String diskFmtType = getAttrValue("driver", "type", disk);
                String diskCacheMode = getAttrValue("driver", "cache", disk);
                String diskFile = getAttrValue("source", "file", disk);
                String diskDev = getAttrValue("source", "dev", disk);

                String diskLabel = getAttrValue("target", "dev", disk);
                String bus = getAttrValue("target", "bus", disk);
                String device = disk.getAttribute("device");

                if (type.equalsIgnoreCase("file")) {
                    if (device.equalsIgnoreCase("disk")) {
                        DiskDef.DiskFmtType fmt = null;
                        if (diskFmtType != null) {
                            fmt = DiskDef.DiskFmtType.valueOf(diskFmtType.toUpperCase());
                        }
                        def.defFileBasedDisk(diskFile, diskLabel, DiskDef.DiskBus.valueOf(bus.toUpperCase()),
                                fmt);
                    } else if (device.equalsIgnoreCase("cdrom")) {
                        def.defISODisk(diskFile);
                    }
                } else if (type.equalsIgnoreCase("block")) {
                    def.defBlockBasedDisk(diskDev, diskLabel, DiskDef.DiskBus.valueOf(bus.toUpperCase()));
                }
                if (diskCacheMode != null) {
                    def.setCacheMode(DiskDef.DiskCacheMode.valueOf(diskCacheMode.toUpperCase()));
                }
            }

            NodeList iotune = disk.getElementsByTagName("iotune");
            if ((iotune != null) && (iotune.getLength() != 0)) {
                String bytesReadRateStr = getTagValue("read_bytes_sec", (Element) iotune.item(0));
                if (bytesReadRateStr != null) {
                    Long bytesReadRate = Long.parseLong(bytesReadRateStr);
                    def.setBytesReadRate(bytesReadRate);
                }
                String bytesWriteRateStr = getTagValue("write_bytes_sec", (Element) iotune.item(0));
                if (bytesWriteRateStr != null) {
                    Long bytesWriteRate = Long.parseLong(bytesWriteRateStr);
                    def.setBytesWriteRate(bytesWriteRate);
                }
                String iopsReadRateStr = getTagValue("read_iops_sec", (Element) iotune.item(0));
                if (iopsReadRateStr != null) {
                    Long iopsReadRate = Long.parseLong(iopsReadRateStr);
                    def.setIopsReadRate(iopsReadRate);
                }
                String iopsWriteRateStr = getTagValue("write_iops_sec", (Element) iotune.item(0));
                if (iopsWriteRateStr != null) {
                    Long iopsWriteRate = Long.parseLong(iopsWriteRateStr);
                    def.setIopsWriteRate(iopsWriteRate);
                }
            }

            diskDefs.add(def);
        }

        NodeList nics = devices.getElementsByTagName("interface");
        for (int i = 0; i < nics.getLength(); i++) {
            Element nic = (Element) nics.item(i);

            String type = nic.getAttribute("type");
            String mac = getAttrValue("mac", "address", nic);
            String dev = getAttrValue("target", "dev", nic);
            String model = getAttrValue("model", "type", nic);
            String slot = StringUtils.removeStart(getAttrValue("address", "slot", nic), "0x");

            InterfaceDef def = new InterfaceDef();
            NodeList bandwidth = nic.getElementsByTagName("bandwidth");
            Integer networkRateKBps = 0;
            if ((bandwidth != null) && (bandwidth.getLength() != 0)) {
                Integer inbound = Integer
                        .valueOf(getAttrValue("inbound", "average", (Element) bandwidth.item(0)));
                Integer outbound = Integer
                        .valueOf(getAttrValue("outbound", "average", (Element) bandwidth.item(0)));
                if (inbound.equals(outbound)) {
                    networkRateKBps = inbound;
                }
            }
            if (type.equalsIgnoreCase("network")) {
                String network = getAttrValue("source", "network", nic);
                def.defPrivateNet(network, dev, mac, NicModel.valueOf(model.toUpperCase()), networkRateKBps);
            } else if (type.equalsIgnoreCase("bridge")) {
                String bridge = getAttrValue("source", "bridge", nic);
                def.defBridgeNet(bridge, dev, mac, NicModel.valueOf(model.toUpperCase()), networkRateKBps);
            } else if (type.equalsIgnoreCase("ethernet")) {
                String scriptPath = getAttrValue("script", "path", nic);
                def.defEthernet(dev, mac, NicModel.valueOf(model.toUpperCase()), scriptPath, networkRateKBps);
            }

            if (StringUtils.isNotBlank(slot)) {
                def.setSlot(Integer.parseInt(slot, 16));
            }

            interfaces.add(def);
        }

        NodeList ports = devices.getElementsByTagName("channel");
        for (int i = 0; i < ports.getLength(); i++) {
            Element channel = (Element) ports.item(i);

            String type = channel.getAttribute("type");
            String path = getAttrValue("source", "path", channel);
            String name = getAttrValue("target", "name", channel);
            String state = getAttrValue("target", "state", channel);

            ChannelDef def = null;
            if (!StringUtils.isNotBlank(state)) {
                def = new ChannelDef(name, ChannelDef.ChannelType.valueOf(type.toUpperCase()), new File(path));
            } else {
                def = new ChannelDef(name, ChannelDef.ChannelType.valueOf(type.toUpperCase()),
                        ChannelDef.ChannelState.valueOf(state.toUpperCase()), new File(path));
            }

            channels.add(def);
        }

        Element graphic = (Element) devices.getElementsByTagName("graphics").item(0);

        if (graphic != null) {
            String port = graphic.getAttribute("port");
            if (port != null) {
                try {
                    vncPort = Integer.parseInt(port);
                    if (vncPort != -1) {
                        vncPort = vncPort - 5900;
                    } else {
                        vncPort = null;
                    }
                } catch (NumberFormatException nfe) {
                    vncPort = null;
                }
            }
        }

        NodeList rngs = devices.getElementsByTagName("rng");
        for (int i = 0; i < rngs.getLength(); i++) {
            RngDef def = null;
            Element rng = (Element) rngs.item(i);
            String backendModel = getAttrValue("backend", "model", rng);
            String path = getTagValue("backend", rng);
            String bytes = getAttrValue("rate", "bytes", rng);
            String period = getAttrValue("rate", "period", rng);

            if (Strings.isNullOrEmpty(backendModel)) {
                def = new RngDef(path, Integer.parseInt(bytes), Integer.parseInt(period));
            } else {
                def = new RngDef(path, RngBackendModel.valueOf(backendModel.toUpperCase()),
                        Integer.parseInt(bytes), Integer.parseInt(period));
            }

            rngDefs.add(def);
        }

        NodeList watchDogs = devices.getElementsByTagName("watchdog");
        for (int i = 0; i < watchDogs.getLength(); i++) {
            WatchDogDef def = null;
            Element watchDog = (Element) watchDogs.item(i);
            String action = watchDog.getAttribute("action");
            String model = watchDog.getAttribute("model");

            if (Strings.isNullOrEmpty(model)) {
                continue;
            }

            if (Strings.isNullOrEmpty(action)) {
                def = new WatchDogDef(WatchDogModel.valueOf(model.toUpperCase()));
            } else {
                def = new WatchDogDef(WatchDogAction.valueOf(action.toUpperCase()),
                        WatchDogModel.valueOf(model.toUpperCase()));
            }

            watchDogDefs.add(def);
        }

        return true;
    } catch (ParserConfigurationException e) {
        s_logger.debug(e.toString());
    } catch (SAXException e) {
        s_logger.debug(e.toString());
    } catch (IOException e) {
        s_logger.debug(e.toString());
    }
    return false;
}

From source file:com.aurel.track.admin.customize.category.filter.FilterAction.java

/**
 * Loads the filter detail for add or edit 
 * @return/*from  ww  w.jav a  2 s. co  m*/
 */
public String edit() {
    boolean modifiable = false;
    FilterFacade filterFacade = null;
    Integer objectID = null;
    Integer projectID = null;
    boolean includeHeader = false;
    boolean includePathPicker = false;
    boolean applyInstant = false;
    if (instant) {
        //load for instant filter dialog
        filterFacade = TreeFilterFacade.getInstance();
        modifiable = true;
        includeHeader = false;
        add = false;
        LOGGER.debug("Load for instant filter dialog");
    } else {
        Integer type = null;
        if (node != null) {
            includeHeader = true;
            //load dialog from manage filters (add or edit)
            CategoryTokens categoryTokens = CategoryTokens.decodeNode(node);
            String categoryType = categoryTokens.getCategoryType();
            Integer repository = categoryTokens.getRepository();
            type = categoryTokens.getType();
            if (repository != null && repository.equals(CategoryBL.REPOSITORY_TYPE.PROJECT)) {
                projectID = CategoryBL.getProjectID(categoryType, repository, type, objectID);
            }
            objectID = categoryTokens.getObjectID();
            if (add) {
                LOGGER.debug("Add new filter from manage filters");
                filterFacade = (FilterFacade) CategoryFacadeFactory.getInstance().getLeafFacade(categoryType);
            } else {
                LOGGER.debug("Edit filter " + objectID + " from manage filters");
                filterFacade = (FilterFacade) CategoryFacadeFactory.getInstance().getLeafFacade(categoryType,
                        objectID);
            }
            modifiable = CategoryBL.isModifiable(filterFacade, categoryType, repository, type, objectID, add,
                    personBean);
        } else {
            if (filterID != null && filterType != null) {
                if (fromNavigatorContextMenu) {
                    //possible enter/change name etc.
                    includeHeader = true;
                } else {
                    //from instant in the navigator upper part
                    applyInstant = true;
                    includeHeader = false;
                }
                //load filter in item navigator upper area
                //in this case modifiable has another meaning: the filter is freely editable anyway (for "instant apply" and "save as"),
                //but the save button is available only if there is already a saved filter behind and this is modifiable by the current user
                //so modifiable in this case means whether "Save" button is active ("Save as" is always active)
                modifiable = false;
                String categoryType = CATEGORY_TYPE.ISSUE_FILTER_CATEGORY;
                switch (filterType) {
                case QUERY_TYPE.BASKET:
                case QUERY_TYPE.DASHBOARD:
                    //basket and dashboard can't be translated to a tree filter: render as a new filter
                    add = true;
                    break;
                case QUERY_TYPE.INSTANT:
                    //render the last instant
                    instant = true;
                    LOGGER.debug("Load last instant for item navigator");
                    break;
                case QUERY_TYPE.LUCENE_SEARCH:
                    //load later in getDetailJSON() using queryContextID
                    break;
                case QUERY_TYPE.PROJECT_RELEASE:
                    //transform the project/release to a tree filter
                    //filterID is actually a projectID or releaseID
                    objectID = filterID;
                    LOGGER.debug("Load project/release based (" + filterID + ") for item navigator");
                    break;
                case QUERY_TYPE.SAVED:
                    objectID = filterID;
                    TQueryRepositoryBean queryRepositoryBean = FilterBL.loadByPrimaryKey(objectID);
                    Integer repository = null;
                    if (queryRepositoryBean != null) {
                        repository = queryRepositoryBean.getRepositoryType();
                        type = TYPE.LEAF;
                        if (repository != null && repository.equals(CategoryBL.REPOSITORY_TYPE.PROJECT)) {
                            projectID = CategoryBL.getProjectID(categoryType, repository, type, objectID);
                        }
                    }
                    filterFacade = (FilterFacade) CategoryFacadeFactory.getInstance()
                            .getLeafFacade(categoryType, objectID);
                    //a saved filter is behind
                    modifiable = CategoryBL.isModifiable(filterFacade, categoryType, repository, type, objectID,
                            false, personBean);
                    LOGGER.debug("Load saved filter based (" + filterID + ") for item navigator");
                    break;
                case QUERY_TYPE.STATUS:
                    objectID = filterID;
                    LOGGER.debug("Load status based (" + filterID + ") for item navigator");
                    break;
                }
                if (filterFacade == null) {
                    filterFacade = TreeFilterFacade.getInstance();
                }
            } else {
                if (add) {
                    //add from item navigator menu (accordion left), filter context menu 
                    filterFacade = TreeFilterFacade.getInstance();
                    modifiable = true;
                    includeHeader = true;
                    includePathPicker = true;
                }
            }
        }
    }
    JSONUtility.encodeJSON(servletResponse,
            filterFacade.getDetailJSON(includeHeader, includePathPicker, objectID, filterType, queryContextID,
                    add, modifiable, instant, clearFilter, applyInstant, personBean, projectID, locale));
    return null;
}

From source file:com.bizintelapps.bugtracker.service.impl.ReportServiceImpl.java

@Override
public List<UserReportDto> getUserReports(Integer user, Integer maxReports, String requestedBy) {
    if (maxReports == null || maxReports < 1) {
        maxReports = 3;/*from   w  w  w  .  j a v a2s.com*/
    }
    Users requestedUser = usersDao.findByUsername(requestedBy);
    List<UserReportDto> dtos = new ArrayList<UserReportDto>();
    if (user == null || user.equals(0)) {
        user = requestedUser.getId();
    }
    // only admin, self can see graph
    if (user.equals(requestedUser.getId()) || requestedUser.isIsAdministrator()) {
        List<UserReport> list = userReportDao.findByUser(user, maxReports);
        if (list == null || list.size() == 0) {
            Calendar c = Calendar.getInstance();
            UserReport up = new UserReport(user, c.get(Calendar.MONTH), c.get(Calendar.YEAR), 0);
            up.setUser(user);
            list.add(up);
        }
        // copy for display
        for (UserReport ur : list) {
            dtos.add(userReportDtoA.copyForDisplay(ur));
        }
    }
    return dtos;
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.NASAOtherProjectInformationV1_0Generator.java

/**
 * //from   w  ww.  ja v a  2s.co  m
 * This method is used to get the answerList for a particular Questionnaire question
 * question based on the question id.
 * 
 * @param questionSeqId
 *            the question seq id to be passed.
 * @return returns the answerList for a particular
 *         question based on the question id passed.
 */
private List<String> getAnswerList(Integer questionSeqId) {
    List<String> answerList = new ArrayList<>();
    for (AnswerHeaderContract answerHeader : answerHeaders) {
        List<? extends AnswerContract> answerDetails = answerHeader.getAnswers();
        for (AnswerContract answers : answerDetails) {
            if (questionSeqId.equals(
                    getQuestionAnswerService().findQuestionById(answers.getQuestionId()).getQuestionSeqId())) {
                if (answers.getAnswer() != null) {
                    answerList.add(answers.getAnswer());
                }
            }
        }
    }
    return answerList;
}

From source file:au.org.intersect.dms.webapp.controller.LocationController.java

private StockServer getStockServer(Integer connectionId) {
    if (WorkerNode.HDD_CONNECTION_ID.equals(connectionId)) {
        return StockServer.findStockServersByProtocol("hdd").getSingleResult();
    }/*ww w .  j av a2  s .  co  m*/
    List<LocationConnectForm> currentConnections = getCurrentConnections();
    StockServer server = null;
    for (LocationConnectForm locationConnectForm : currentConnections) {
        if (connectionId.equals(locationConnectForm.getConnectionId())) {
            server = StockServer.findStockServer(locationConnectForm.getStockId());
            break;
        }
    }
    if (server == null) {
        throw new IllegalArgumentException("Can't resolve server by connection ID " + connectionId);
    } else {
        return server;
    }
}