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:jp.primecloud.auto.process.vmware.VmwareDiskProcess.java

/**
 * TODO: //www  .  j  av a  2s  .c  o m
 *
 * @param vmwareProcessClient
 * @param instanceNo
 * @param diskNo
 */
public void attachDisk(VmwareProcessClient vmwareProcessClient, Long instanceNo, Long diskNo) {
    VmwareDisk vmwareDisk = vmwareDiskDao.read(diskNo);

    if (BooleanUtils.isTrue(vmwareDisk.getAttached())) {
        // ??????
        return;
    }

    VmwareInstance vmwareInstance = vmwareInstanceDao.read(instanceNo);

    //
    Component component = componentDao.read(vmwareDisk.getComponentNo());
    Instance instance = instanceDao.read(instanceNo);
    Platform platform = platformDao.read(vmwareProcessClient.getPlatformNo());
    if (StringUtils.isEmpty(vmwareDisk.getFileName())) {
        processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, component, instance, "VmwareDiskCreate",
                new Object[] { platform.getPlatformName() });
    } else {
        processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, component, instance, "VmwareDiskAttach",
                new Object[] { platform.getPlatformName(), vmwareDisk.getFileName() });
    }

    // ??
    VirtualDisk disk = vmwareProcessClient.attachDisk(vmwareInstance.getMachineName(), vmwareDisk.getScsiId(),
            vmwareDisk.getSize(), vmwareDisk.getFileName());

    // ??
    VirtualDeviceFileBackingInfo backingInfo = VirtualDeviceFileBackingInfo.class.cast(disk.getBacking());
    Datastore datastore = new Datastore(
            vmwareProcessClient.getVmwareClient().getServiceInstance().getServerConnection(),
            backingInfo.getDatastore());

    //
    if (StringUtils.isEmpty(vmwareDisk.getFileName())) {
        processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, component, instance, "VmwareDiskCreateFinish",
                new Object[] { platform.getPlatformName(), backingInfo.getFileName(), vmwareDisk.getSize() });
    } else {
        processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, component, instance, "VmwareDiskAttachFinish",
                new Object[] { platform.getPlatformName(), vmwareDisk.getFileName(), vmwareDisk.getSize() });
    }

    // 
    vmwareDisk = vmwareDiskDao.read(diskNo);
    vmwareDisk.setAttached(true);
    vmwareDisk.setDatastore(datastore.getName());
    vmwareDisk.setFileName(backingInfo.getFileName());
    vmwareDiskDao.update(vmwareDisk);
}

From source file:com.haulmont.cuba.gui.presentations.PresentationsImpl.java

@Override
public void add(Presentation p) {
    checkLoad();//from  w ww  . java 2  s  . c  o m
    presentations.put(p.getId(), p);
    if (PersistenceHelper.isNew(p)) {
        needToUpdate.add(p);

        if (BooleanUtils.isTrue(p.getDefault())) {
            def = p;
        }
    }
    firePresentationsSetChanged();
}

From source file:com.baasbox.BBConfiguration.java

public static Boolean getPushMock() {
    if (pushMock == null)
        pushMock = BooleanUtils.isTrue(configuration.getBoolean(PUSH_MOCK));
    return pushMock;
}

From source file:com.haulmont.cuba.gui.app.core.scheduled.ScheduledTaskBrowser.java

@Override
public void init(Map<String, Object> params) {
    ComponentsHelper.createActions(tasksTable);

    final Action editAction = tasksTable.getActionNN(EditAction.ACTION_ID);
    editAction.setEnabled(false);//from  w  ww . ja va  2 s.co m

    final Action removeAction = tasksTable.getActionNN(RemoveAction.ACTION_ID);
    removeAction.setEnabled(false);

    activateBtn.setAction(new AbstractAction("activate") {
        @Override
        public void actionPerform(Component component) {
            Set<ScheduledTask> tasks = tasksTable.getSelected();
            service.setActive(tasks, !BooleanUtils.isTrue(tasks.iterator().next().getActive()));
            tasksDs.refresh();
        }
    });

    activateBtn.setEnabled(false);

    final ShowExecutionsAction showExecutionsAction = new ShowExecutionsAction();
    showExecutionsAction.setEnabled(false);
    tasksTable.addAction(showExecutionsAction);

    tasksDs.addItemChangeListener(e -> {
        ScheduledTask singleSelected = tasksTable.getSingleSelected();
        Set<ScheduledTask> selected = tasksTable.getSelected();
        boolean isSingleSelected = selected.size() == 1;
        boolean enableEdit = isSingleSelected && !BooleanUtils.isTrue(singleSelected.getActive());

        editAction.setEnabled(enableEdit);
        removeAction.setEnabled(checkAllTasksIsNotActive(selected));
        activateBtn.setEnabled(checkAllTasksHaveSameStatus(selected));

        if (singleSelected == null) {
            activateBtn.setCaption(getMessage("activate"));
        } else {
            activateBtn.setCaption(BooleanUtils.isTrue(singleSelected.getActive()) ? getMessage("deactivate")
                    : getMessage("activate"));
        }

        showExecutionsAction.setEnabled(isSingleSelected);
    });
}

From source file:com.haulmont.restapi.controllers.QueriesController.java

@GetMapping("/{entityName}/{queryName}")
public ResponseEntity<String> executeQueryGet(@PathVariable String entityName, @PathVariable String queryName,
        @RequestParam(required = false) Integer limit, @RequestParam(required = false) Integer offset,
        @RequestParam(required = false) String view, @RequestParam(required = false) Boolean returnNulls,
        @RequestParam(required = false) Boolean dynamicAttributes,
        @RequestParam(required = false) Boolean returnCount,
        @RequestParam(required = false) String modelVersion, @RequestParam Map<String, String> params) {
    String resultJson = queriesControllerManager.executeQueryGet(entityName, queryName, limit, offset, view,
            returnNulls, dynamicAttributes, modelVersion, params);
    ResponseEntity.BodyBuilder responseBuilder = ResponseEntity.status(HttpStatus.OK);
    if (BooleanUtils.isTrue(returnCount)) {
        String count = queriesControllerManager.getCountGet(entityName, queryName, modelVersion, params);
        responseBuilder.header("X-Total-Count", count);
    }/* ww w  . j  a  va2 s .c  om*/
    return responseBuilder.body(resultJson);
}

From source file:com.opengamma.financial.security.equity.EquitySecurityFudgeBuilder.java

public static void fromFudgeMsg(FudgeDeserializer deserializer, FudgeMsg msg, EquitySecurity object) {
    FinancialSecurityFudgeBuilder.fromFudgeMsg(deserializer, msg, object);
    object.setShortName(msg.getString(SHORT_NAME_FIELD_NAME));
    object.setExchange(msg.getString(EXCHANGE_FIELD_NAME));
    object.setExchangeCode(msg.getString(EXCHANGE_CODE_FIELD_NAME));
    object.setCompanyName(msg.getString(COMPANY_NAME_FIELD_NAME));
    object.setCurrency(msg.getValue(Currency.class, CURRENCY_FIELD_NAME));
    object.setGicsCode(msg.getValue(GICSCode.class, GICS_CODE_FIELD_NAME));
    object.setPreferred(BooleanUtils.isTrue(msg.getBoolean(PREFERRED_FIELD_NAME)));
}

From source file:com.haulmont.cuba.core.jmx.Scheduling.java

@Override
public String printActiveScheduledTasks() {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    StringBuilder sb = new StringBuilder();
    List<ScheduledTask> tasks = scheduling.getActiveTasks();
    for (ScheduledTask task : tasks) {
        sb.append(task).append(", lastStart=");
        if (task.getLastStartTime() != null) {
            sb.append(dateFormat.format(task.getLastStartTime()));
            if (BooleanUtils.isTrue(task.getSingleton()))
                sb.append(" on ").append(task.getLastStartServer());
        } else {/*from w  w  w . j a  v  a  2  s  . c  o m*/
            sb.append("<never>");
        }
        sb.append("\n");
    }
    return sb.toString();
}

From source file:com.haulmont.cuba.gui.WindowParams.java

/**
 * Get boolean value from the WindowContext.
 * @param context   window context/*from  w w w. ja  va 2s . c  o m*/
 * @return          parameter value
 */
public boolean getBool(@Nullable FrameContext context) {
    return context != null && BooleanUtils.isTrue((Boolean) context.getParams().get(name()));
}

From source file:jp.primecloud.auto.api.instance.StoptInstance.java

/**
 *
 * ???/*from ww  w  . j av a2s.  c om*/
 *
 * @param farmNo ?
 * @param instanceNo ?
 *
 * @return StopInstanceResponse
 */
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public StopInstanceResponse stoptInstance(@QueryParam(PARAM_NAME_FARM_NO) String farmNo,
        @QueryParam(PARAM_NAME_INSTANCE_NO) String instanceNo) {

    StopInstanceResponse response = new StopInstanceResponse();

    try {
        // ?
        // FarmNo
        ApiValidate.validateFarmNo(farmNo);
        // InstanceNo
        ApiValidate.validateInstanceNo(instanceNo);

        // ?
        Instance instance = instanceDao.read(Long.parseLong(instanceNo));
        if (instance == null || BooleanUtils.isTrue(instance.getLoadBalancer())) {
            // ???? or ????
            throw new AutoApplicationException("EAPI-100000", "Instance", PARAM_NAME_INSTANCE_NO, instanceNo);
        }

        InstanceStatus status = InstanceStatus.fromStatus(instance.getStatus());
        if (InstanceStatus.RUNNING != status && InstanceStatus.WARNING != status) {
            // ?? ? or  ????
            throw new AutoApplicationException("EAPI-100024", instanceNo);
        }

        if (BooleanUtils.isFalse(instance.getFarmNo().equals(Long.parseLong(farmNo)))) {
            //?????
            throw new AutoApplicationException("EAPI-100022", "Instance", farmNo, PARAM_NAME_INSTANCE_NO,
                    instanceNo);
        }

        // ???
        List<Long> instanceNos = new ArrayList<Long>();
        instanceNos.add(Long.parseLong(instanceNo));
        processService.stopInstances(Long.parseLong(farmNo), instanceNos);

        response.setSuccess(true);
    } catch (Throwable e) {
        String message = "";
        if (e instanceof AutoException || e instanceof AutoApplicationException) {
            message = e.getMessage();
        } else {
            message = MessageUtils.getMessage("EAPI-000000");
        }
        log.error(message, e);
        response.setMessage(message);
        response.setSuccess(false);
    }

    return response;
}

From source file:com.evolveum.midpoint.common.refinery.RefinedAssociationDefinition.java

public boolean isExclusiveStrong() {
    return BooleanUtils.isTrue(resourceObjectAssociationType.isExclusiveStrong());
}