Example usage for org.apache.commons.lang BooleanUtils isTrue

List of usage examples for org.apache.commons.lang BooleanUtils isTrue

Introduction

In this page you can find the example usage for org.apache.commons.lang BooleanUtils isTrue.

Prototype

public static boolean isTrue(Boolean bool) 

Source Link

Document

Checks if a Boolean value is true, handling null by returning false.

 BooleanUtils.isTrue(Boolean.TRUE)  = true BooleanUtils.isTrue(Boolean.FALSE) = false BooleanUtils.isTrue(null)          = false 

Usage

From source file:com.haulmont.cuba.gui.components.filter.edit.CustomConditionFrame.java

@Override
public boolean commit() {
    if (!super.commit())
        return false;

    ParamType type = typeSelect.getValue();
    if (ParamType.ENTITY.equals(type) && entitySelect.getValue() == null) {
        showNotification("Select entity", NotificationType.HUMANIZED);
        return false;
    }/*from   ww w.  j  av a2s  . c o m*/

    if (nameField.isEnabled()) {
        String nameText = nameField.getValue();
        if (!Strings.isNullOrEmpty(nameText)) {
            condition.setLocCaption(nameText);
        }
    }

    condition.setJoin(joinField.<String>getValue());

    ConditionParamBuilder paramBuilder = AppBeans.get(ConditionParamBuilder.class);
    String paramName = condition.getParam() != null ? condition.getParam().getName()
            : paramBuilder.createParamName(condition);
    String where = whereField.getValue();
    if (where != null) {
        where = where.replace("?", ":" + paramName);
    }

    condition.setWhere(where);
    condition.setUnary(ParamType.UNARY.equals(type));
    condition.setInExpr(BooleanUtils.isTrue(inExprCb.getValue()));

    Class javaClass = getParamJavaClass(type);
    condition.setJavaClass(javaClass);

    String entityParamWhere = entityParamWhereField.getValue();
    condition.setEntityParamWhere(entityParamWhere);

    String entityParamView = entityParamViewField.getValue();
    condition.setEntityParamView(entityParamView);

    condition.setUseUserTimeZone(useUserTimeZone.getValue());

    Param param = Param.Builder.getInstance().setName(paramName).setJavaClass(javaClass)
            .setEntityWhere(entityParamWhere).setEntityView(entityParamView)
            .setDataSource(condition.getDatasource()).setInExpr(condition.getInExpr())
            .setRequired(condition.getRequired()).setUseUserTimeZone(condition.getUseUserTimeZone()).build();

    param.setDefaultValue(condition.getParam().getDefaultValue());

    condition.setParam(param);

    return true;
}

From source file:com.haulmont.cuba.gui.export.ExcelExporter.java

protected int createHierarhicalRow(TreeTable table, List<Table.Column> columns, Boolean exportExpanded,
        int rowNumber, Object itemId) {
    HierarchicalDatasource hd = table.getDatasource();
    createRow(table, columns, 0, ++rowNumber, itemId);
    if (BooleanUtils.isTrue(exportExpanded) && !table.isExpanded(itemId) && !hd.getChildren(itemId).isEmpty()) {
        return rowNumber;
    } else {/*ww  w  .java2s.co  m*/
        final Collection children = hd.getChildren(itemId);
        if (children != null && !children.isEmpty()) {
            for (Object id : children) {
                if (BooleanUtils.isTrue(exportExpanded) && !table.isExpanded(id)
                        && !hd.getChildren(id).isEmpty()) {
                    createRow(table, columns, 0, ++rowNumber, id);
                    continue;
                }
                rowNumber = createHierarhicalRow(table, columns, exportExpanded, rowNumber, id);
            }
        }
    }
    return rowNumber;
}

From source file:net.shopxx.entity.Order.java

@Transient
public boolean getIsDelivery() {
    return CollectionUtils.exists(getOrderItems(), new Predicate() {
        @Override/*from w w  w. ja v  a 2 s .  co  m*/
        public boolean evaluate(Object object) {
            OrderItem orderItem = (OrderItem) object;
            return orderItem != null && BooleanUtils.isTrue(orderItem.getIsDelivery());
        }
    });
}

From source file:com.haulmont.cuba.core.app.scheduling.Scheduling.java

protected Integer getServerPriority(ScheduledTask task, String serverId) {
    String permittedServers = task.getPermittedServers();

    if (StringUtils.isBlank(permittedServers)) {
        if (BooleanUtils.isTrue(task.getSingleton()) && !clusterManager.isMaster())
            return null;
        else/*from  w w  w.j a  v  a 2s.c o  m*/
            return 0;
    }

    String[] parts = permittedServers.trim().split("[,;]");
    for (int i = 0; i < parts.length; i++) {
        if (serverId.equals(parts[i].trim())) {
            return i + 1;
        }
    }

    return null;
}

From source file:jp.primecloud.auto.process.lb.ComponentLoadBalancerProcess.java

protected void stopInstances(Long loadBalancerNo, List<Long> instanceNos) {
    // ??//from   www  .  j a va  2  s. co  m
    List<Instance> instances = instanceDao.readInInstanceNos(instanceNos);
    for (Instance instance : instances) {
        if (BooleanUtils.isTrue(instance.getEnabled())) {
            instance.setEnabled(false);
            instanceDao.update(instance);
        }
    }

    // ??????
    List<Instance> targetInstances = new ArrayList<Instance>();
    for (Instance instance : instances) {
        InstanceStatus status = InstanceStatus.fromStatus(instance.getStatus());
        if (status == InstanceStatus.RUNNING || status == InstanceStatus.WARNING) {
            targetInstances.add(instance);
        }
    }

    // ????????
    if (targetInstances.isEmpty()) {
        return;
    }

    // ??????
    final LoadBalancer loadBalancer = loadBalancerDao.read(loadBalancerNo);
    List<Callable<Void>> callables = new ArrayList<Callable<Void>>();
    final Map<String, Object> loggingContext = LoggingUtils.getContext();
    for (final Instance instance : targetInstances) {
        Callable<Void> callable = new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                LoggingUtils.setContext(loggingContext);
                try {
                    if (log.isInfoEnabled()) {
                        log.info(MessageUtils.getMessage("IPROCESS-200213", loadBalancer.getLoadBalancerNo(),
                                instance.getInstanceNo(), loadBalancer.getLoadBalancerName(),
                                instance.getInstanceName()));
                    }

                    instanceProcess.stop(instance.getInstanceNo());

                    if (log.isInfoEnabled()) {
                        log.info(MessageUtils.getMessage("IPROCESS-200214", loadBalancer.getLoadBalancerNo(),
                                instance.getInstanceNo(), loadBalancer.getLoadBalancerName(),
                                instance.getInstanceName()));
                    }
                } catch (Exception e) {
                    log.error(e.getMessage(), e);
                    throw e;
                } finally {
                    LoggingUtils.removeContext();
                }
                return null;
            }
        };
        callables.add(callable);
    }

    try {
        List<Future<Void>> futures = executorService.invokeAll(callables);

        // ???
        List<Throwable> throwables = new ArrayList<Throwable>();
        for (Future<Void> future : futures) {
            try {
                future.get();
            } catch (ExecutionException e) {
                throwables.add(e.getCause());
            } catch (InterruptedException ignore) {
            }
        }

        // ??
        if (throwables.size() > 0) {
            throw new MultiCauseException(throwables.toArray(new Throwable[throwables.size()]));
        }
    } catch (InterruptedException e) {
    }
}

From source file:com.haulmont.cuba.web.gui.components.WebAbstractTable.java

@Override
public void setEditable(boolean editable) {
    if (this.editable != editable) {
        this.editable = editable;

        component.disableContentBufferRefreshing();

        if (datasource != null) {
            com.vaadin.data.Container ds = component.getContainerDataSource();

            @SuppressWarnings("unchecked")
            final Collection<MetaPropertyPath> propertyIds = (Collection<MetaPropertyPath>) ds
                    .getContainerPropertyIds();

            if (editable) {
                MetaClass metaClass = datasource.getMetaClass();

                final List<MetaPropertyPath> editableColumns = new ArrayList<>(propertyIds.size());
                for (final MetaPropertyPath propertyId : propertyIds) {
                    if (!security.isEntityAttrUpdatePermitted(metaClass, propertyId.toString())) {
                        continue;
                    }/*  ww w.  java  2  s  . c  o  m*/

                    final Table.Column column = getColumn(propertyId.toString());
                    if (BooleanUtils.isTrue(column.isEditable())) {
                        com.vaadin.ui.Table.ColumnGenerator generator = component
                                .getColumnGenerator(column.getId());
                        if (generator != null) {
                            if (generator instanceof SystemTableColumnGenerator) {
                                // remove default generator
                                component.removeGeneratedColumn(propertyId);
                            } else {
                                // do not edit generated columns
                                continue;
                            }
                        }

                        editableColumns.add(propertyId);
                    }
                }
                setEditableColumns(editableColumns);
            } else {
                setEditableColumns(Collections.emptyList());

                Window window = ComponentsHelper.getWindowImplementation(this);
                boolean isLookup = window instanceof Window.Lookup;

                // restore generators for some type of attributes
                for (MetaPropertyPath propertyId : propertyIds) {
                    final Table.Column column = columns.get(propertyId);
                    if (column != null) {
                        final String isLink = column.getXmlDescriptor() == null ? null
                                : column.getXmlDescriptor().attributeValue("link");

                        if (component.getColumnGenerator(column.getId()) == null) {
                            if (propertyId.getRange().isClass()) {
                                if (!isLookup && StringUtils.isNotEmpty(isLink)) {
                                    setClickListener(propertyId.toString(), new LinkCellClickListener());
                                }
                            } else if (propertyId.getRange().isDatatype()) {
                                if (!isLookup && !StringUtils.isEmpty(isLink)) {
                                    setClickListener(propertyId.toString(), new LinkCellClickListener());
                                } else {
                                    if (column.getMaxTextLength() != null) {
                                        addGeneratedColumn(propertyId, new AbbreviatedColumnGenerator(column));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        component.setEditable(editable);

        component.enableContentBufferRefreshing(true);
    }
}

From source file:com.square.core.service.implementations.PersonneServiceImplementation.java

@Override
public RemotePagingResultsDto<RelationInfosDto<? extends PersonneRelationDto>> rechercherRelationsParCritreres(
        RemotePagingCriteriasDto<RelationCriteresRechercheDto> remotePagingCriterias) {
    if (remotePagingCriterias == null || remotePagingCriterias.getCriterias() == null) {
        throw new BusinessException(messageSourceUtil.get(PersonneKeyUtil.MESSAGE_ERREUR_REL_RECH_CRITERE));
    }//from w  w  w.  j ava 2  s  .  c  o m
    final RelationCriteresRechercheDto criteres = remotePagingCriterias.getCriterias();
    final List<Relation> listRelation = relationDao.rechercherRelationsParCriteres(remotePagingCriterias);

    final List<RelationInfosDto<? extends PersonneRelationDto>> resultats = new ArrayList<RelationInfosDto<? extends PersonneRelationDto>>();

    for (Relation relation : listRelation) {
        // PARAMETRE DYNAMIQUE EN FONCTION DU SENS DE LA RELATION
        Personne personne = null;
        IdentifiantLibelleDto typeRelationDto = null;
        Long idPersonnePrincipal = null;
        Long idPersonneCible = null;
        if (criteres.getIdPersonne() != null) {
            idPersonnePrincipal = relation.getPersonneSource().getId().equals(criteres.getIdPersonne())
                    ? relation.getPersonneSource().getId()
                    : relation.getPersonneCible().getId();
            idPersonneCible = !relation.getPersonneSource().getId().equals(criteres.getIdPersonne())
                    ? relation.getPersonneSource().getId()
                    : relation.getPersonneCible().getId();
            personne = relation.getPersonneSource().getId().equals(criteres.getIdPersonne())
                    ? relation.getPersonneCible()
                    : relation.getPersonneSource();
            typeRelationDto = new IdentifiantLibelleDto(relation.getType().getId(),
                    relation.getPersonneSource().getId().equals(criteres.getIdPersonne())
                            ? relation.getType().getLibelle()
                            : relation.getType().getInverse());
        } else {
            typeRelationDto = new IdentifiantLibelleDto(relation.getType().getId(),
                    relation.getType().getLibelle());
            idPersonnePrincipal = criteres.getIdPersonneSource();
            personne = relation.getPersonneCible();
            idPersonneCible = personne.getId();
        }
        if (personne instanceof PersonnePhysique) {
            final RelationInfosDto<PersonnePhysiqueRelationDto> relationDto = new RelationInfosDto<PersonnePhysiqueRelationDto>();
            mapperDozerBean.map(relation, relationDto);
            final PersonnePhysiqueRelationDto personnePhysique = mapperDozerBean.map(personne,
                    PersonnePhysiqueRelationDto.class);
            final Calendar dateNaissance = personnePhysique.getDateNaissance();
            final Calendar dateActuelle = Calendar.getInstance();

            if (dateNaissance != null) {
                final int age = dateActuelle.get(Calendar.YEAR) - dateNaissance.get(Calendar.YEAR);
                personnePhysique.setAge(age);
            }
            final PersonnePhysique pPhysique = (PersonnePhysique) personne;
            if (pPhysique.getInfoSante() != null) {
                personnePhysique.setNumSS(pPhysique.getInfoSante().getNumSecuriteSocial());
                personnePhysique.setCleNumSS(pPhysique.getInfoSante().getCleSecuriteSocial());
                if (pPhysique.getInfoSante() != null && pPhysique.getInfoSante().getCaisse() != null) {
                    final CaisseSimpleDto caisse = new CaisseSimpleDto(
                            pPhysique.getInfoSante().getCaisse().getId(),
                            pPhysique.getInfoSante().getCaisse().getNom(),
                            pPhysique.getInfoSante().getCaisse().getCode());
                    caisse.setCentre(pPhysique.getInfoSante().getCaisse().getCentre());
                    personnePhysique.setCaisse(caisse);
                    if (pPhysique.getInfoSante().getCaisse().getRegime() != null) {
                        final IdentifiantLibelleDto regime = new IdentifiantLibelleDto(
                                pPhysique.getInfoSante().getCaisse().getRegime().getId(),
                                pPhysique.getInfoSante().getCaisse().getRegime().getLibelle());
                        personnePhysique.setRegime(regime);
                    }
                }
            }
            personnePhysique.setNaturePersonne((IdentifiantLibelleDto) mapperDozerBean
                    .map(pPhysique.getNature(), IdentifiantLibelleDto.class));

            relationDto.setPersonne(personnePhysique);
            relationDto.setIdPersonnePrincipale(idPersonnePrincipal);
            relationDto.setIdPersonne(idPersonneCible);
            relationDto.setType(typeRelationDto);
            relationDto.setActif(relation.isTopActif());
            if (BooleanUtils.isTrue(criteres.getRelationsSansContrat())) {
                if (contratService.countContrats(personnePhysique.getId(), false) == 0) {
                    resultats.add(relationDto);
                }
            } else {
                resultats.add(relationDto);
            }
        } else if (personne instanceof PersonneMorale) {
            final RelationInfosDto<PersonneMoraleRelationDto> relationDto = new RelationInfosDto<PersonneMoraleRelationDto>();
            mapperDozerBean.map(relation, relationDto);
            relationDto.setPersonne(
                    (PersonneMoraleRelationDto) mapperDozerBean.map(personne, PersonneMoraleRelationDto.class));
            relationDto.setIdPersonnePrincipale(idPersonnePrincipal);
            relationDto.setIdPersonne(idPersonneCible);
            relationDto.setType(typeRelationDto);
            relationDto.setActif(relation.isTopActif());
            resultats.add(relationDto);
        }
    }
    final RemotePagingResultsDto<RelationInfosDto<? extends PersonneRelationDto>> resultsDto = new RemotePagingResultsDto<RelationInfosDto<? extends PersonneRelationDto>>();
    resultsDto.setListResults(resultats);
    resultsDto.setTotalResults(relationDao.countRelationsParCriteres(criteres));
    return resultsDto;
}

From source file:com.evolveum.midpoint.wf.impl.tasks.WfTaskController.java

@SuppressWarnings("unchecked")
public void onTaskEvent(WorkItemType workItem, TaskEvent taskEvent, OperationResult result)
        throws WorkflowException, SchemaException {

    final TaskType shadowTaskType = WfContextUtil.getTask(workItem);
    if (shadowTaskType == null) {
        LOGGER.warn("No task in workItem " + workItem + ", audit and notifications couldn't be performed.");
        return;/*from w w  w .  j  a v  a  2 s . c om*/
    }
    final Task shadowTask = taskManager.createTaskInstance(shadowTaskType.asPrismObject(), result);
    final WfTask wfTask = recreateWfTask(shadowTask);

    // auditing & notifications & event
    if (taskEvent instanceof TaskCreatedEvent) {
        AuditEventRecord auditEventRecord = getChangeProcessor(taskEvent)
                .prepareWorkItemCreatedAuditRecord(workItem, taskEvent, wfTask, result);
        auditService.audit(auditEventRecord, wfTask.getTask());
        try {
            List<ObjectReferenceType> assigneesAndDeputies = getAssigneesAndDeputies(workItem, wfTask, result);
            for (ObjectReferenceType assigneesOrDeputy : assigneesAndDeputies) {
                notifyWorkItemCreated(assigneesOrDeputy, workItem, wfTask, result); // we assume originalAssigneeRef == assigneeRef in this case
            }
            WorkItemAllocationChangeOperationInfo operationInfo = new WorkItemAllocationChangeOperationInfo(
                    null, Collections.emptyList(), assigneesAndDeputies);
            notifyWorkItemAllocationChangeNewActors(workItem, operationInfo, null, wfTask.getTask(), result);
        } catch (SchemaException e) {
            LoggingUtils.logUnexpectedException(LOGGER,
                    "Couldn't send notification about work item create event", e);
        }
    } else if (taskEvent instanceof TaskDeletedEvent) {
        // this might be cancellation because of:
        //  (1) user completion of this task
        //  (2) timed completion of this task
        //  (3) user completion of another task
        //  (4) timed completion of another task
        //  (5) process stop/deletion
        //
        // Actually, when the source is (4) timed completion of another task, it is quite probable that this task
        // would be closed for the same reason. For a user it would be misleading if we would simply view this task
        // as 'cancelled', while, in fact, it is e.g. approved/rejected because of a timed action.

        WorkItemOperationKindType operationKind = BooleanUtils.isTrue(ActivitiUtil.getVariable(
                taskEvent.getVariables(), CommonProcessVariableNames.VARIABLE_WORK_ITEM_WAS_COMPLETED,
                Boolean.class, prismContext)) ? WorkItemOperationKindType.COMPLETE
                        : WorkItemOperationKindType.CANCEL;
        WorkItemEventCauseInformationType cause = ActivitiUtil.getVariable(taskEvent.getVariables(),
                CommonProcessVariableNames.VARIABLE_CAUSE, WorkItemEventCauseInformationType.class,
                prismContext);
        boolean genuinelyCompleted = operationKind == WorkItemOperationKindType.COMPLETE;

        MidPointPrincipal user;
        try {
            user = SecurityUtil.getPrincipal();
        } catch (SecurityViolationException e) {
            throw new SystemException("Couldn't determine current user: " + e.getMessage(), e);
        }

        ObjectReferenceType userRef = user != null ? user.toObjectReference() : workItem.getPerformerRef(); // partial fallback

        if (!genuinelyCompleted) {
            TaskType task = wfTask.getTask().getTaskPrismObject().asObjectable();
            int foundTimedActions = 0;
            for (TriggerType trigger : task.getTrigger()) {
                if (!WfTimedActionTriggerHandler.HANDLER_URI.equals(trigger.getHandlerUri())) {
                    continue;
                }
                String workItemId = ObjectTypeUtil.getExtensionItemRealValue(trigger.getExtension(),
                        SchemaConstants.MODEL_EXTENSION_WORK_ITEM_ID);
                if (!taskEvent.getTaskId().equals(workItemId)) {
                    continue;
                }
                Duration timeBeforeAction = ObjectTypeUtil.getExtensionItemRealValue(trigger.getExtension(),
                        SchemaConstants.MODEL_EXTENSION_TIME_BEFORE_ACTION);
                if (timeBeforeAction != null) {
                    continue;
                }
                WorkItemActionsType actions = ObjectTypeUtil.getExtensionItemRealValue(trigger.getExtension(),
                        SchemaConstants.MODEL_EXTENSION_WORK_ITEM_ACTIONS);
                if (actions == null || actions.getComplete() == null) {
                    continue;
                }
                long diff = XmlTypeConverter.toMillis(trigger.getTimestamp()) - clock.currentTimeMillis();
                if (diff >= COMPLETION_TRIGGER_EQUALITY_THRESHOLD) {
                    continue;
                }
                CompleteWorkItemActionType completeAction = actions.getComplete();
                operationKind = WorkItemOperationKindType.COMPLETE;
                cause = new WorkItemEventCauseInformationType();
                cause.setType(WorkItemEventCauseTypeType.TIMED_ACTION);
                cause.setName(completeAction.getName());
                cause.setDisplayName(completeAction.getDisplayName());
                foundTimedActions++;
                WorkItemResultType workItemOutput = new WorkItemResultType();
                workItemOutput.setOutcome(completeAction.getOutcome() != null ? completeAction.getOutcome()
                        : SchemaConstants.MODEL_APPROVAL_OUTCOME_REJECT);
                workItem.setOutput(workItemOutput);
            }
            if (foundTimedActions > 1) {
                LOGGER.warn("Multiple 'work item complete' timed actions ({}) for {}: {}", foundTimedActions,
                        ObjectTypeUtil.toShortString(task), task.getTrigger());
            }
        }

        // We don't pass userRef (initiator) to the audit method. It does need the whole object (not only the reference),
        // so it fetches it directly from the security enforcer (logged-in user). This could change in the future.
        AuditEventRecord auditEventRecord = getChangeProcessor(taskEvent)
                .prepareWorkItemDeletedAuditRecord(workItem, cause, taskEvent, wfTask, result);
        auditService.audit(auditEventRecord, wfTask.getTask());
        try {
            List<ObjectReferenceType> assigneesAndDeputies = getAssigneesAndDeputies(workItem, wfTask, result);
            WorkItemAllocationChangeOperationInfo operationInfo = new WorkItemAllocationChangeOperationInfo(
                    operationKind, assigneesAndDeputies, null);
            WorkItemOperationSourceInfo sourceInfo = new WorkItemOperationSourceInfo(userRef, cause, null);
            if (workItem.getAssigneeRef().isEmpty()) {
                notifyWorkItemDeleted(null, workItem, operationInfo, sourceInfo, wfTask, result);
            } else {
                for (ObjectReferenceType assigneeOrDeputy : assigneesAndDeputies) {
                    notifyWorkItemDeleted(assigneeOrDeputy, workItem, operationInfo, sourceInfo, wfTask,
                            result);
                }
            }
            notifyWorkItemAllocationChangeCurrentActors(workItem, operationInfo, sourceInfo, null,
                    wfTask.getTask(), result);
        } catch (SchemaException e) {
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't audit work item complete event", e);
        }

        AbstractWorkItemOutputType output = workItem.getOutput();
        if (genuinelyCompleted || output != null) {
            WorkItemCompletionEventType event = new WorkItemCompletionEventType();
            ActivitiUtil.fillInWorkItemEvent(event, user, taskEvent.getTaskId(), taskEvent.getVariables(),
                    prismContext);
            event.setCause(cause);
            event.setOutput(output);
            ObjectDeltaType additionalDelta = output instanceof WorkItemResultType
                    && ((WorkItemResultType) output).getAdditionalDeltas() != null
                            ? ((WorkItemResultType) output).getAdditionalDeltas().getFocusPrimaryDelta()
                            : null;
            MidpointUtil.recordEventInTask(event, additionalDelta, wfTask.getTask().getOid(), result);
        }

        MidpointUtil.removeTriggersForWorkItem(wfTask.getTask(), taskEvent.getTaskId(), result);
    }
}

From source file:com.haulmont.cuba.gui.components.filter.Param.java

protected CheckBox createUnaryField(final ValueProperty valueProperty) {
    CheckBox field = componentsFactory.createComponent(CheckBox.class);
    field.addValueChangeListener(e -> {
        Object newValue = BooleanUtils.isTrue((Boolean) e.getValue()) ? true : null;
        _setValue(newValue, valueProperty);
    });/*from   w w  w .j  a v a2 s.  c  o  m*/
    field.setValue(_getValue(valueProperty));
    field.setAlignment(Component.Alignment.MIDDLE_LEFT);
    return field;
}

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

/**
 * {@inheritDoc}/*from  w ww. j  av a  2s.c  om*/
 */
@Override
public void stopComponents(Long farmNo, Long componentNo, List<Long> instanceNos, boolean stopInstance) {
    // ????
    List<ComponentInstance> componentInstances = componentInstanceDao.readByComponentNo(componentNo);
    for (ComponentInstance componentInstance : componentInstances) {
        if (!instanceNos.contains(componentInstance.getInstanceNo())) {
            continue;
        }
        if (BooleanUtils.isTrue(componentInstance.getEnabled())
                || BooleanUtils.isNotTrue(componentInstance.getConfigure())) {
            componentInstance.setEnabled(false);
            componentInstance.setConfigure(true);
            componentInstanceDao.update(componentInstance);
        }
    }

    if (stopInstance) {
        // ?????????
        for (ComponentInstance componentInstance : componentInstances) {
            instanceNos.add(componentInstance.getInstanceNo());
        }
        List<Instance> instances = instanceDao.readInInstanceNos(instanceNos);
        for (Instance instance : instances) {
            if (BooleanUtils.isNotTrue(instance.getEnabled())) {
                continue;
            }

            // ???????????
            boolean allDisabled = true;
            List<ComponentInstance> componentInstances2 = componentInstanceDao
                    .readByInstanceNo(instance.getInstanceNo());
            for (ComponentInstance componentInstance : componentInstances2) {
                if (BooleanUtils.isTrue(componentInstance.getEnabled())) {
                    allDisabled = false;
                    break;
                }
            }

            // ???????
            if (allDisabled) {
                instance.setEnabled(false);
                instanceDao.update(instance);
            }
        }
    }

    // ????
    scheduleFarm(farmNo);
}