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:org.kuali.kra.proposaldevelopment.bo.DevelopmentProposal.java

public ProposalPerson getProposalNonEmployee(Integer rolodexId) {
    for (ProposalPerson proposalPerson : getProposalPersons()) {
        if (rolodexId.equals(proposalPerson.getRolodexId())) {
            return proposalPerson;
        }/*from  ww  w. ja va2 s. c  om*/
    }
    return null;
}

From source file:com.clustercontrol.jobmanagement.factory.JobSessionJobImpl.java

/**
 * ????????/*from w ww .j av  a 2  s  .  c o  m*/
 *
 * @param sessionId ID
 * @param jobId ID
 * @return true??false??
 * @throws JobInfoNotFound
 * @throws InvalidRole
 * @throws HinemosUnknown
 * @throws FacilityNotFound 
 */
private boolean checkWaitCondition(String sessionId, String jobunitId, String jobId)
        throws JobInfoNotFound, InvalidRole, HinemosUnknown, FacilityNotFound {
    m_log.debug(
            "checkWaitCondition() : sessionId=" + sessionId + ", jobunitId=" + jobunitId + ", jobId=" + jobId);

    //ID?ID???
    JobSessionJobEntity sessionJob = QueryUtil.getJobSessionJobPK(sessionId, jobunitId, jobId);
    //??
    JobInfoEntity job = sessionJob.getJobInfoEntity();
    //???
    Collection<JobStartJobInfoEntity> startJobs = job.getJobStartJobInfoEntities();
    ArrayList<Boolean> jobResult = new ArrayList<Boolean>();

    //statusCheck ?????
    //AND??????? :false??????? :true
    //OR??? :true
    //????????true
    boolean statusCheck = true;

    //startCheck ?????????
    //AND?????????????ture
    //OR?????????????????true
    boolean startCheck = true;

    //allEndCheck ???????
    boolean allEndCheck = true;

    //possibilityCheck ??
    //??????
    //AND???????1??NG???
    //OR????????????????NG???
    boolean possibilityCheck = true;

    //???
    List<JobStartParamInfoEntity> jobStartParamInfonList = job.getJobStartParamInfoEntities();

    //replaceCheck ????????
    boolean replaceCheck = true;

    //?????????
    if ((startJobs == null || startJobs.size() == 0) && job.getStartTime() == null
            && job.getStartMinute() == null
            && (jobStartParamInfonList == null || jobStartParamInfonList.size() == 0)) {
        return true;
    }

    //??
    for (JobStartJobInfoEntity startJob : startJobs) {
        //???

        //ID?ID???
        JobSessionJobEntity targetSessionJob = QueryUtil.getJobSessionJobPK(sessionJob.getId().getSessionId(),
                startJob.getId().getTargetJobunitId(), startJob.getId().getTargetJobId());

        //()??
        if (StatusConstant.isEndGroup(targetSessionJob.getStatus())) {
            //??????

            if (startJob.getId().getTargetJobType() == JudgmentObjectConstant.TYPE_JOB_END_STATUS) {
                //??

                Integer endStatus = targetSessionJob.getEndStatus();
                if (endStatus != null) {
                    //?????
                    if ((startJob.getId().getTargetJobEndValue() == EndStatusConstant.TYPE_ANY)
                            || (endStatus.equals(startJob.getId().getTargetJobEndValue()))) {
                        jobResult.add(true);
                        //OR??????????
                        if (job.getConditionType() == ConditionTypeConstant.TYPE_OR) {
                            break;
                        }
                    } else {
                        jobResult.add(false);
                    }
                } else {
                    jobResult.add(false);
                }
            } else if (startJob.getId().getTargetJobType() == JudgmentObjectConstant.TYPE_JOB_END_VALUE) {
                //??
                Integer endValue = targetSessionJob.getEndValue();
                if (endValue != null) {
                    //?????
                    if (endValue.equals(startJob.getId().getTargetJobEndValue())) {
                        jobResult.add(true);
                        //OR??????????
                        if (job.getConditionType() == ConditionTypeConstant.TYPE_OR) {
                            break;
                        }
                    } else {
                        jobResult.add(false);
                    }
                } else {
                    jobResult.add(false);
                }
            } else {
                jobResult.add(false);
            }
        } else {
            // ??????????allEndCheckfalse?
            allEndCheck = false;
            if (job.getConditionType() == ConditionTypeConstant.TYPE_AND) {
                // ???AND???????
                statusCheck = false;
                startCheck = false;
                break;
            } else {
                // ???OR???
                jobResult.add(false);
            }
        }
    }

    // ??
    for (JobStartParamInfoEntity jobStartParamInfoEntity : jobStartParamInfonList) {

        // 1???
        String decisionValue01 = "";
        // 2???
        String decisionValue02 = "";
        String regex = "#\\[[a-zA-Z0-9-_:]+\\]";
        Pattern pattern = Pattern.compile(regex);
        // 1????????
        if (pattern.matcher(jobStartParamInfoEntity.getId().getStartDecisionValue01()).find()) {
            // 1??
            decisionValue01 = ParameterUtil.replaceSessionParameterValue(sessionId, job.getFacilityId(),
                    jobStartParamInfoEntity.getId().getStartDecisionValue01());

            // 1???????????????????????
            if (pattern.matcher(decisionValue01).find()) {
                replaceCheck = false;
                jobResult.add(false);
                continue;
            }
        } else {
            decisionValue01 = jobStartParamInfoEntity.getId().getStartDecisionValue01();
        }

        // 2????????
        if (pattern.matcher(jobStartParamInfoEntity.getId().getStartDecisionValue02()).find()) {
            // 2??
            decisionValue02 = ParameterUtil.replaceSessionParameterValue(sessionId, job.getFacilityId(),
                    jobStartParamInfoEntity.getId().getStartDecisionValue02());

            // 2???????????????????????
            if (pattern.matcher(decisionValue02).find()) {
                replaceCheck = false;
                jobResult.add(false);
                continue;
            }
        } else {
            decisionValue02 = jobStartParamInfoEntity.getId().getStartDecisionValue02();
        }

        if (jobStartParamInfoEntity.getId()
                .getStartDecisionCondition() == DecisionObjectConstant.EQUAL_NUMERIC) {
            try {
                if (checkDecisionValue(decisionValue01, decisionValue02) == 0) {
                    jobResult.add(true);
                    //OR??????????
                    if (job.getConditionType() == ConditionTypeConstant.TYPE_OR) {
                        break;
                    }
                } else {
                    jobResult.add(false);
                }
            } catch (NumberFormatException e) {
                jobResult.add(false);
            }
        } else if (jobStartParamInfoEntity.getId()
                .getStartDecisionCondition() == DecisionObjectConstant.NOT_EQUAL_NUMERIC) {
            try {
                if (checkDecisionValue(decisionValue01, decisionValue02) != 0) {
                    jobResult.add(true);
                    //OR??????????
                    if (job.getConditionType() == ConditionTypeConstant.TYPE_OR) {
                        break;
                    }
                } else {
                    jobResult.add(false);
                }
            } catch (NumberFormatException e) {
                jobResult.add(false);
            }
        } else if (jobStartParamInfoEntity.getId()
                .getStartDecisionCondition() == DecisionObjectConstant.GREATER_THAN) {
            try {
                if (checkDecisionValue(decisionValue01, decisionValue02) > 0) {
                    jobResult.add(true);
                    //OR??????????
                    if (job.getConditionType() == ConditionTypeConstant.TYPE_OR) {
                        break;
                    }
                } else {
                    jobResult.add(false);
                }
            } catch (NumberFormatException e) {
                jobResult.add(false);
            }
        } else if (jobStartParamInfoEntity.getId()
                .getStartDecisionCondition() == DecisionObjectConstant.GREATER_THAN_OR_EQUAL_TO) {
            try {
                if (checkDecisionValue(decisionValue01, decisionValue02) >= 0) {
                    jobResult.add(true);
                    //OR??????????
                    if (job.getConditionType() == ConditionTypeConstant.TYPE_OR) {
                        break;
                    }
                } else {
                    jobResult.add(false);
                }
            } catch (NumberFormatException e) {
                jobResult.add(false);
            }
        } else if (jobStartParamInfoEntity.getId()
                .getStartDecisionCondition() == DecisionObjectConstant.LESS_THAN) {
            try {
                if (checkDecisionValue(decisionValue01, decisionValue02) < 0) {
                    jobResult.add(true);
                    //OR??????????
                    if (job.getConditionType() == ConditionTypeConstant.TYPE_OR) {
                        break;
                    }
                } else {
                    jobResult.add(false);
                }
            } catch (NumberFormatException e) {
                jobResult.add(false);
            }
        } else if (jobStartParamInfoEntity.getId()
                .getStartDecisionCondition() == DecisionObjectConstant.LESS_THAN_OR_EQUAL_TO) {
            try {
                if (checkDecisionValue(decisionValue01, decisionValue02) <= 0) {
                    jobResult.add(true);
                    //OR??????????
                    if (job.getConditionType() == ConditionTypeConstant.TYPE_OR) {
                        break;
                    }
                } else {
                    jobResult.add(false);
                }
            } catch (NumberFormatException e) {
                jobResult.add(false);
            }
        } else if (jobStartParamInfoEntity.getId()
                .getStartDecisionCondition() == DecisionObjectConstant.EQUAL_STRING) {
            if (decisionValue01.equals(decisionValue02)) {
                jobResult.add(true);
                //OR??????????
                if (job.getConditionType() == ConditionTypeConstant.TYPE_OR) {
                    break;
                }
            } else {
                jobResult.add(false);
            }
        } else if (jobStartParamInfoEntity.getId()
                .getStartDecisionCondition() == DecisionObjectConstant.NOT_EQUAL_STRING) {
            if (!decisionValue01.equals(decisionValue02)) {
                jobResult.add(true);
                //OR??????????
                if (job.getConditionType() == ConditionTypeConstant.TYPE_OR) {
                    break;
                }
            } else {
                jobResult.add(false);
            }
        } else {
            m_log.warn("Outside of DecisionCondition : "
                    + jobStartParamInfoEntity.getId().getStartDecisionCondition());
        }
        m_log.debug("DecisionInfo " + jobStartParamInfoEntity.getId().getStartDecisionCondition()
                + ", value01 : " + decisionValue01 + ", value02 : " + decisionValue02);
    }

    // ??
    if (statusCheck) {
        //AND???OR?????
        if (job.getConditionType() == ConditionTypeConstant.TYPE_AND) {
            //AND???
            startCheck = true;
            for (Boolean flag : jobResult) {
                if (!flag) {
                    startCheck = false;
                    break;
                }
            }
        } else {
            //OR???
            startCheck = false;
            for (Boolean flag : jobResult) {
                if (flag) {
                    startCheck = true;
                    break;
                }
            }
        }

        //???
        //AND???OR?????????
        if (!startCheck) {
            if (job.getConditionType() == ConditionTypeConstant.TYPE_AND) {
                //AND???????1??NG???(startCheck?false?????)
                possibilityCheck = false;
            } else {
                //OR????????????????NG???
                if (job.getStartTime() == null && allEndCheck && job.getStartMinute() == null) {
                    possibilityCheck = false;
                }
            }
        }

        // ????
        if (job.getConditionType() == ConditionTypeConstant.TYPE_AND) {
            // ???AND???
            //???????????
            if (startCheck && job.getStartTime() != null) {
                startCheck = checkWaitTime(startCheck, sessionId, job.getStartTime());
            }
        } else {
            // ???OR???
            // ?????????????
            if (!startCheck && job.getStartTime() != null) {
                startCheck = checkWaitTime(startCheck, sessionId, job.getStartTime());
            }
        }

        // ??????
        if (job.getConditionType() == ConditionTypeConstant.TYPE_AND) {
            // ???AND???
            //?????????????
            if (startCheck && job.getStartMinute() != null) {
                startCheck = checkStartMinute(startCheck, sessionId, job.getStartMinute());
            }
        } else {
            // ???OR???
            //?????????????
            if (!startCheck && job.getStartMinute() != null) {
                startCheck = checkStartMinute(startCheck, sessionId, job.getStartMinute());
            }
        }
    }

    //???NG??
    //????????
    //????????
    if (!startCheck && !possibilityCheck && job.getUnmatchEndFlg().booleanValue() && replaceCheck) {
        m_log.debug("checkStartCondition() : unmatch end flg is true. end job : " + " jobid : " + jobId
                + " : status :" + sessionJob.getStatus());
        //??????????
        Integer endStatus = job.getUnmatchEndStatus();
        // 
        Integer endValue = job.getUnmatchEndValue();

        //???
        setEndStatus(sessionId, jobunitId, jobId, StatusConstant.TYPE_END_UNMATCH, endStatus, endValue, null);
        //?
        endJob(sessionId, jobunitId, jobId, null, false);
    }
    return startCheck;
}

From source file:com.mirth.connect.plugins.dashboardstatus.DashboardConnectorEventListener.java

@Override
protected void processEvent(Event event) {
    if (event instanceof ConnectionStatusEvent) {
        ConnectionStatusEvent connectionStatusEvent = (ConnectionStatusEvent) event;
        String channelId = connectionStatusEvent.getChannelId();
        Integer metaDataId = connectionStatusEvent.getMetaDataId();
        String information = connectionStatusEvent.getMessage();
        Timestamp timestamp = new Timestamp(event.getDateTime());

        String connectorId = channelId + "_" + metaDataId;

        ConnectionStatusEventType eventType = connectionStatusEvent.getState();

        ConnectionStatusEventType connectionStatusEventType = eventType;
        Integer connectorCount = null;
        Integer maximum = null;//w  ww  .  j a  va  2  s.  co  m

        if (event instanceof ConnectorCountEvent) {
            ConnectorCountEvent connectorCountEvent = (ConnectorCountEvent) connectionStatusEvent;

            maximum = connectorCountEvent.getMaximum();
            Boolean increment = connectorCountEvent.isIncrement();

            if (maximum != null) {
                maxConnectionMap.put(connectorId, maximum);
            } else {
                maximum = maxConnectionMap.get(connectorId);
            }

            AtomicInteger count = connectorCountMap.get(connectorId);

            if (count == null) {
                count = new AtomicInteger();
                connectorCountMap.put(connectorId, count);
            }

            if (increment != null) {
                if (increment) {
                    count.incrementAndGet();
                } else {
                    count.decrementAndGet();
                }
            }

            connectorCount = count.get();

            if (connectorCount == 0) {
                connectionStatusEventType = ConnectionStatusEventType.IDLE;
            } else {
                connectionStatusEventType = ConnectionStatusEventType.CONNECTED;
            }
        }

        String stateString = null;
        if (connectionStatusEventType.isState()) {
            Color color = getColor(connectionStatusEventType);
            stateString = connectionStatusEventType.toString();
            if (connectorCount != null) {
                if (maximum != null && connectorCount.equals(maximum)) {
                    stateString += " <font color='red'>(" + connectorCount + ")</font>";
                } else if (connectorCount > 0) {
                    stateString += " (" + connectorCount + ")";
                }
            }

            connectorStateMap.put(connectorId, new Object[] { color, stateString });
        }

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
        String channelName = "";
        String connectorType = "";

        LinkedList<String[]> channelLog = null;

        Channel channel = ControllerFactory.getFactory().createChannelController()
                .getDeployedChannelById(channelId);

        if (channel != null) {
            channelName = channel.getName();
            // grab the channel's log from the HashMap, if not exist, create
            // one.
            if (connectorInfoLogs.containsKey(channelId)) {
                channelLog = connectorInfoLogs.get(channelId);
            } else {
                channelLog = new LinkedList<String[]>();
            }

            if (metaDataId == 0) {
                connectorType = "Source: " + channel.getSourceConnector().getTransportName() + "  ("
                        + channel.getSourceConnector().getTransformer().getInboundDataType().toString() + " -> "
                        + channel.getSourceConnector().getTransformer().getOutboundDataType().toString() + ")";
            } else {
                Connector connector = getConnectorFromMetaDataId(channel.getDestinationConnectors(),
                        metaDataId);
                connectorType = "Destination: " + connector.getTransportName() + " - " + connector.getName();
            }
        }

        if (channelLog != null) {
            synchronized (this) {
                if (channelLog.size() == MAX_LOG_SIZE) {
                    channelLog.removeLast();
                }
                channelLog.addFirst(
                        new String[] { String.valueOf(logId), channelName, dateFormat.format(timestamp),
                                connectorType, ((ConnectionStatusEvent) event).getState().toString(),
                                information, channelId, Integer.toString(metaDataId) });

                if (entireConnectorInfoLogs.size() == MAX_LOG_SIZE) {
                    entireConnectorInfoLogs.removeLast();
                }
                entireConnectorInfoLogs.addFirst(
                        new String[] { String.valueOf(logId), channelName, dateFormat.format(timestamp),
                                connectorType, ((ConnectionStatusEvent) event).getState().toString(),
                                information, channelId, Integer.toString(metaDataId) });

                logId++;

                // put the channel log into the HashMap.
                connectorInfoLogs.put(channelId, channelLog);
            }
        }

    }
}

From source file:edu.ku.brc.specify.tasks.DataEntryTask.java

/**
 * @return a loan invoice if one exists.
 * //from  w w w .  j a va 2s .c om
 * If more than one report is defined for loan then user must choose.
 * 
 * Fairly goofy code. Eventually may want to add ui to allow labeling resources as "invoice" (see printLoan()).
 */
public InfoForTaskReport getLabelReportInfo() {
    DataProviderSessionIFace session = null;
    ChooseFromListDlg<InfoForTaskReport> dlg = null;
    try {
        session = DataProviderFactory.getInstance().createSession();
        List<AppResourceIFace> reps = AppContextMgr.getInstance()
                .getResourceByMimeType(ReportsBaseTask.LABELS_MIME);
        reps.addAll(AppContextMgr.getInstance().getResourceByMimeType(ReportsBaseTask.REPORTS_MIME));
        Vector<InfoForTaskReport> repInfo = new Vector<InfoForTaskReport>();

        for (AppResourceIFace rep : reps) {
            Properties params = rep.getMetaDataMap();
            String tableid = params.getProperty("tableid");
            SpReport spReport = null;
            boolean includeIt = false;
            try {
                Integer tblId = null;
                try {
                    tblId = Integer.valueOf(tableid);
                } catch (NumberFormatException ex) {
                    //continue;
                }
                if (tblId == null) {
                    continue;
                }

                if (tblId.equals(CollectionObject.getClassTableId())) {
                    includeIt = true;
                } else if (tblId.equals(-1)) {
                    QueryIFace q = session.createQuery("from SpReport spr join spr.appResource apr "
                            + "join spr.query spq " + "where apr.id = " + ((SpAppResource) rep).getId()
                            + " and spq.contextTableId = " + CollectionObject.getClassTableId(), false);
                    List<?> spReps = q.list();
                    if (spReps.size() > 0) {
                        includeIt = true;
                        spReport = (SpReport) ((Object[]) spReps.get(0))[0];
                        spReport.forceLoad();
                        if (spReps.size() > 1) {
                            //should never happen
                            log.error("More than SpReport exists for " + rep.getName());
                        }
                    }
                }
            } catch (Exception ex) {
                UsageTracker.incrHandledUsageCount();
                edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(InteractionsTask.class, ex);
                //skip this res
            }
            if (includeIt) {
                repInfo.add(new InfoForTaskReport((SpAppResource) rep, spReport));
            }
        }

        if (repInfo.size() == 0) {
            UIRegistry.displayInfoMsgDlgLocalized("InteractionsTask.NoInvoiceFound",
                    DBTableIdMgr.getInstance().getTitleForId(CollectionObject.getClassTableId()));
            return null;
        }

        if (repInfo.size() == 1) {
            return repInfo.get(0);
        }

        dlg = new ChooseFromListDlg<InfoForTaskReport>((Frame) UIRegistry.getTopWindow(),
                getResourceString("REP_CHOOSE_INVOICE"), repInfo);
        dlg.setVisible(true);
        if (dlg.isCancelled()) {
            return null;
        }
        return dlg.getSelectedObject();

    } finally {
        session.close();
        if (dlg != null) {
            dlg.dispose();
        }
    }
}

From source file:com.haulmont.cuba.web.WebWindowManager.java

protected ComponentContainer findTab(Integer hashCode) {
    Set<Map.Entry<ComponentContainer, WindowBreadCrumbs>> set = tabs.entrySet();
    for (Map.Entry<ComponentContainer, WindowBreadCrumbs> entry : set) {
        Window currentWindow = entry.getValue().getCurrentWindow();
        if (hashCode.equals(getWindowHashCode(currentWindow))) {
            return entry.getKey();
        }/*from  w  w w  . ja va 2 s .c om*/
    }
    return null;
}

From source file:com.haulmont.cuba.web.WebWindowManager.java

@Override
protected Window getWindow(Integer hashCode) {
    AppWorkArea workArea = getConfiguredWorkArea(null);
    if (workArea == null || workArea.getMode() == Mode.SINGLE) {
        return null;
    }/* w ww .  ja va  2 s .c o  m*/

    for (Map.Entry<Window, Integer> entry : windows.entrySet()) {
        if (hashCode.equals(entry.getValue())) {
            return entry.getKey();
        }
    }
    return null;
}

From source file:org.kuali.kra.proposaldevelopment.bo.DevelopmentProposal.java

public ContactRole getProposalNonEmployeeRole(Integer rolodexId) {
    ProposalPerson principalInvestigator = getPrincipalInvestigator();
    if (principalInvestigator != null && rolodexId.equals(principalInvestigator.getRolodexId())) {
        return principalInvestigator.getRole();
    }//from  w  ww  . j a  v a 2 s. c o m
    for (ProposalPerson proposalPerson : getInvestigators()) {
        if (rolodexId.equals(proposalPerson.getRolodexId())) {
            return proposalPerson.getRole();
        }
    }
    for (ProposalPerson proposalPerson : getProposalPersons()) {
        if (rolodexId.equals(proposalPerson.getRolodexId())) {
            return proposalPerson.getRole();
        }
    }
    return null;
}

From source file:edu.ku.brc.specify.tools.ireportspecify.MainFrameSpecify.java

/**
 * @param reportId id of deleted report//from w w  w  . j  a v a2  s  .com
 */
protected void removeFrameForDeletedReport(final Integer reportId) {
    if (reportId != null) {
        javax.swing.JInternalFrame[] frames = getJMDIDesktopPane().getAllFrames();
        JReportFrame jrf;
        Vector<Component> toRemove = new Vector<Component>();
        for (int i = 0; i < frames.length; ++i) {
            if (frames[i] instanceof JReportFrame) {
                jrf = (JReportFrame) frames[i];
                if (jrf.getReport() instanceof ReportSpecify
                        && ((ReportSpecify) (jrf.getReport())).getSpReport() != null) {
                    if (reportId.equals(((ReportSpecify) (jrf.getReport())).getSpReport().getId())) {
                        toRemove.add(jrf);
                    }
                }
            }
        }
        for (Component c : toRemove) {
            getJMDIDesktopPane().remove(c);
        }
    }
}

From source file:jp.primecloud.auto.service.impl.ComponentServiceImpl.java

/**
 * {@inheritDoc}/*  w  w  w.  j ava2s. c  om*/
 */
@Override
public void updateComponent(Long componentNo, String comment, Integer diskSize, String customParam1,
        String customParam2, String customParam3) {
    // ?
    if (componentNo == null) {
        throw new AutoApplicationException("ECOMMON-000003", "componentNo");
    }

    // TODO: ??

    // ????
    Component component = componentDao.read(componentNo);
    if (component == null) {
        throw new AutoApplicationException("ESERVICE-000303", componentNo);
    }

    // ??
    Integer oldDiskSize = null;
    ComponentConfig componentConfig = componentConfigDao.readByComponentNoAndConfigName(componentNo,
            ComponentConstants.CONFIG_NAME_DISK_SIZE);
    if (componentConfig != null && StringUtils.isNotEmpty(componentConfig.getConfigValue())) {
        oldDiskSize = Integer.valueOf(componentConfig.getConfigValue());
    }

    // ???????????
    if (oldDiskSize != null && !oldDiskSize.equals(diskSize)) {
        // TODO CLOUD BRANCHING
        long count = awsVolumeDao.countByComponentNo(componentNo);
        count += vmwareDiskDao.countByComponentNo(componentNo);
        count += cloudstackVolumeDao.countByComponentNo(componentNo);
        count += vcloudDiskDao.countByComponentNo(componentNo);
        count += niftyVolumeDao.countByComponentNo(componentNo);
        count += azureDiskDao.countByComponentNo(componentNo);
        count += openstackVolumeDao.countByComponentNo(componentNo);
        if (count > 0) {
            throw new AutoApplicationException("ESERVICE-000307", componentNo);
        }
    }

    // ?
    Farm farm = farmDao.read(component.getFarmNo());
    // ???
    List<ComponentInstance> componentInstances = componentInstanceDao.readByComponentNo(componentNo);
    for (ComponentInstance componentInstance : componentInstances) {
        Instance instance = instanceDao.read(componentInstance.getInstanceNo());
        componentInstance.setStatus(getComponentInstanceStatus(farm, componentInstance, instance).toString());
    }
    ComponentStatus componentStatus = getComponentStatus(componentInstances);

    // ?1?
    ComponentConfig compConfCustomParam1 = componentConfigDao.readByComponentNoAndConfigName(componentNo,
            ComponentConstants.CONFIG_NAME_CUSTOM_PARAM_1);
    String oldCustomParam1 = null;
    if (compConfCustomParam1 != null) {
        oldCustomParam1 = compConfCustomParam1.getConfigValue();
    }

    // ?2?
    ComponentConfig compConfCustomParam2 = componentConfigDao.readByComponentNoAndConfigName(componentNo,
            ComponentConstants.CONFIG_NAME_CUSTOM_PARAM_2);
    String oldCustomParam2 = null;
    if (compConfCustomParam2 != null) {
        oldCustomParam2 = compConfCustomParam2.getConfigValue();
    }

    // ?3?
    ComponentConfig compConfCustomParam3 = componentConfigDao.readByComponentNoAndConfigName(componentNo,
            ComponentConstants.CONFIG_NAME_CUSTOM_PARAM_3);
    String oldCustomParam3 = null;
    if (compConfCustomParam3 != null) {
        oldCustomParam3 = compConfCustomParam3.getConfigValue();
    }

    // ?Stopped????
    if (ComponentStatus.STOPPED != componentStatus) {
        // 1
        if (oldCustomParam1 != null && !oldCustomParam1.equals(customParam1)) {
            throw new AutoApplicationException("ESERVICE-000311", component.getComponentName());
        }
        // 2
        if (oldCustomParam2 != null && !oldCustomParam2.equals(customParam2)) {
            throw new AutoApplicationException("ESERVICE-000312", component.getComponentName());
        }
        // 3
        if (oldCustomParam3 != null && !oldCustomParam3.equals(customParam3)) {
            throw new AutoApplicationException("ESERVICE-000313", component.getComponentName());
        }
    }

    // ???
    component.setComment(comment);
    componentDao.update(component);

    // ?
    if (diskSize != null && !diskSize.equals(oldDiskSize)) {
        if (componentConfig != null) {
            componentConfig.setConfigValue(diskSize.toString());
            componentConfigDao.update(componentConfig);
        } else {
            componentConfig = new ComponentConfig();
            componentConfig.setComponentNo(componentNo);
            componentConfig.setConfigName(ComponentConstants.CONFIG_NAME_DISK_SIZE);
            componentConfig.setConfigValue(diskSize.toString());
            componentConfigDao.create(componentConfig);
        }
    } else if (diskSize == null && oldDiskSize != null) {
        componentConfig.setConfigValue(null);
        componentConfigDao.update(componentConfig);
    }

    // 1?
    if (compConfCustomParam1 != null) {
        compConfCustomParam1.setConfigValue(customParam1);
        componentConfigDao.update(compConfCustomParam1);
    } else {
        compConfCustomParam1 = new ComponentConfig();
        compConfCustomParam1.setComponentNo(componentNo);
        compConfCustomParam1.setConfigName(ComponentConstants.CONFIG_NAME_CUSTOM_PARAM_1);
        compConfCustomParam1.setConfigValue(customParam1);
        componentConfigDao.create(compConfCustomParam1);
    }

    // 2?
    if (compConfCustomParam2 != null) {
        compConfCustomParam2.setConfigValue(customParam2);
        componentConfigDao.update(compConfCustomParam2);
    } else {
        compConfCustomParam2 = new ComponentConfig();
        compConfCustomParam2.setComponentNo(componentNo);
        compConfCustomParam2.setConfigName(ComponentConstants.CONFIG_NAME_CUSTOM_PARAM_2);
        compConfCustomParam2.setConfigValue(customParam2);
        componentConfigDao.create(compConfCustomParam2);
    }

    // 3?
    if (compConfCustomParam3 != null) {
        compConfCustomParam3.setConfigValue(customParam3);
        componentConfigDao.update(compConfCustomParam3);
    } else {
        compConfCustomParam3 = new ComponentConfig();
        compConfCustomParam3.setComponentNo(componentNo);
        compConfCustomParam3.setConfigName(ComponentConstants.CONFIG_NAME_CUSTOM_PARAM_3);
        compConfCustomParam3.setConfigValue(customParam3);
        componentConfigDao.create(compConfCustomParam3);
    }

    // 
    eventLogger.log(EventLogLevel.INFO, farm.getFarmNo(), farm.getFarmName(), componentNo,
            component.getComponentName(), null, null, "ComponentUpdate", null, null, null);
}

From source file:com.flexive.shared.value.FxValue.java

/**
 * Attach additional data per language to this value instance
 *
 * @param language language to attach data for
 * @param valueData value data to attach
 * @param allowUseAsFallback if the value may be used as a fallback for other languages (only relevant when no other value data is set)
 * @return this/*from  w ww.  ja v a 2s  .  c o  m*/
 * @since 3.2.1
 */
public TDerived setValueData(long language, Integer valueData, boolean allowUseAsFallback) {
    if (isMultiLanguage()) {
        if (multiLangData != null && multiLangData.containsKey(language)) {
            // clean reset of the default value to avoid losing the association with
            // the fallback valueData instance - which needs to be cleared if this value was the last one
            clearValueData(language);
        }
        if (this.valueData == null && allowUseAsFallback) {
            this.valueData = valueData;
        }
        if (valueData != null) {
            final Integer specValue = multiLangData != null ? multiLangData.get(language) : null;
            if (specValue != null) {
                // replace existing value
                multiLangData.put(language, valueData);
            } else if (!valueData.equals(this.valueData) || multiLangData == null || multiLangData.isEmpty()) {
                // store only "non-default" flags (and the initial value) in the hashmap
                if (multiLangData == null)
                    multiLangData = Maps.newHashMap();
                multiLangData.put(language, valueData);
            }
        }
    } else
        this.valueData = valueData;
    //noinspection unchecked
    return (TDerived) this;
}