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

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

Introduction

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

Prototype

public static String toStringTrueFalse(boolean bool) 

Source Link

Document

Converts a boolean to a String returning 'true' or 'false'.

 BooleanUtils.toStringTrueFalse(true)   = "true" BooleanUtils.toStringTrueFalse(false)  = "false" 

Usage

From source file:de.hybris.platform.tx.TransactionConfigTest.java

@Test
public void testLogTransactionBeginTrails() {
    final boolean flagBefore = Config.getBoolean(Transaction.LOG_BEGIN_CONFIG_KEY, false);

    try {// ww  w  .  ja v a2 s .  c o m
        Config.setParameter(Transaction.LOG_BEGIN_CONFIG_KEY, "true");

        final Transaction current = Transaction.current();
        current.clearAddTxStackTrace();

        Assert.assertEquals("initial stack trail size should be 0", 0,
                current.getBeginTransactionStack().size());

        current.begin();
        Assert.assertEquals("stack trail size after begin should be 1", 1,
                current.getBeginTransactionStack().size());
        current.rollback();
        Assert.assertEquals("stack trail size after rollback should be 0", 0,
                current.getBeginTransactionStack().size());

        current.begin();
        Assert.assertEquals("stack trail size after begin should be 1", 1,
                current.getBeginTransactionStack().size());
        current.commit();
        Assert.assertEquals("stack trail size after commit should be 0", 0,
                current.getBeginTransactionStack().size());

        current.begin();
        Assert.assertEquals("stack trail size after begin should be 1", 1,
                current.getBeginTransactionStack().size());
        current.begin();
        Assert.assertEquals("stack trail size after nested begin should be 2", 2,
                current.getBeginTransactionStack().size());
        current.commit();
        Assert.assertEquals("stack trail size after nested commit should be 1", 1,
                current.getBeginTransactionStack().size());
        current.begin();
        Assert.assertEquals("stack trail size after nested begin should be 2", 2,
                current.getBeginTransactionStack().size());
        current.rollback();
        Assert.assertEquals("stack trail size after nested rollback should be 1", 1,
                current.getBeginTransactionStack().size());
        current.rollback();
        Assert.assertEquals("stack trail size after commit should be 0", 0,
                current.getBeginTransactionStack().size());

    } finally {
        Config.setParameter(Transaction.LOG_BEGIN_CONFIG_KEY, BooleanUtils.toStringTrueFalse(flagBefore));
    }
}

From source file:edu.cornell.med.icb.goby.R.FisherExact.java

/**
 * Performs Fisher's exact test for testing the null of independence of rows and columns
 * in a contingency table with fixed marginals.
 * <p/>//from   w ww . java  2s. com
 * The order of the values in the table are "by column" so that if the array contains
 * (1,2,3,11,12,13) and nrows = 3, ncols = 2, the following matrix is created:<br/>
 * <pre>
 *      C1  C2
 *  R1   1  11
 *  R2   2  12
 *  R3   3  13
 * </pre>
 *
 * @param vector                An array of integer values used to populate the matrtix to be evaluated.
 * @param nrows                 The number of rows in the resulting martrix
 * @param ncols                 The number of columns in the resulting matrix
 * @param alternativeHypothesis The alternative hypothesis to use for the calculation
 * @param hybrid                Whether exact probabilities are computed (false) or a hybrid approximation
 *                              (true) is made (only used if the data is larger than a 2 by 2 table)
 * @return The result from the fisher test (should never be null)
 */
public static Result fexact(final int[] vector, final int nrows, final int ncols,
        final AlternativeHypothesis alternativeHypothesis, final boolean hybrid) {
    assert vector != null : "Input vector cannot be null";
    assert vector.length > 0 : "Input vector cannot be empty";
    assert nrows >= 2 && ncols >= 2 : "Must have at least 2 rows and columns";

    final Result result;
    final Rengine rengine = GobyRengine.getInstance().getRengine();
    if (rengine != null && rengine.isAlive()) {
        final boolean vectorAssignResult = rengine.assign("vector", vector);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Vector assigned: " + vectorAssignResult);
            final REXP vectorExpression = rengine.eval("vector");
            LOG.debug("Vector: " + vectorExpression);
        }

        final StringBuilder fisherExpression = new StringBuilder(128);
        fisherExpression.append("fisher.test(matrix(vector,");
        fisherExpression.append(nrows);
        fisherExpression.append(',');
        fisherExpression.append(ncols);
        fisherExpression.append("), hybrid=");
        fisherExpression.append(BooleanUtils.toStringTrueFalse(hybrid).toUpperCase(Locale.getDefault()));
        fisherExpression.append(", alternative=\"");
        fisherExpression.append(alternativeHypothesis);
        fisherExpression.append("\")");
        final boolean is2x2 = nrows == 2 && ncols == 2;
        result = evaluateFisherExpression(rengine, fisherExpression.toString(), is2x2);
    } else {
        LOG.warn(R_NOT_AVAILABLE);
        result = new Result();
    }
    return result;
}

From source file:de.hybris.platform.test.ThreadPoolTest.java

@Test
public void testTransactionCleanUpSimple()
        throws InterruptedException, BrokenBarrierException, TimeoutException {
    final boolean flagBefore = Config.getBoolean("transaction.monitor.begin", false);
    Config.setParameter("transaction.monitor.begin", "true");
    ThreadPool pool = null;//from  w w w  . ja v a2  s.c  o m
    try {
        pool = new ThreadPool(Registry.getCurrentTenantNoFallback().getTenantID(), 1);

        final GenericObjectPool.Config config = new GenericObjectPool.Config();
        config.maxActive = 1;
        config.maxIdle = 1;
        config.maxWait = -1;
        config.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_BLOCK;
        config.testOnBorrow = true;
        config.testOnReturn = true;
        config.timeBetweenEvictionRunsMillis = 30 * 1000; // keep idle threads for at most 30 sec
        pool.setConfig(config);

        final CyclicBarrier gate = new CyclicBarrier(2);
        final AtomicReference<Throwable> threadError = new AtomicReference<Throwable>();
        final AtomicReference<RecordingTransaction> threadTransaction = new AtomicReference<ThreadPoolTest.RecordingTransaction>();
        final PoolableThread thread1 = pool.borrowThread();
        thread1.execute(new Runnable() {
            @Override
            public void run() {
                try {
                    final Transaction tx = new RecordingTransaction();
                    tx.activateAsCurrentTransaction();
                    tx.begin();
                    tx.begin(); // second time
                    tx.begin(); // third time
                    assertTrue(tx.isRunning());
                    assertEquals(3, tx.getOpenTransactionCount());
                    threadTransaction.set((RecordingTransaction) tx);
                    gate.await(10, TimeUnit.SECONDS);
                } catch (final Throwable t) {
                    threadError.set(t);
                }
            }
        });
        gate.await(10, TimeUnit.SECONDS);
        assertNull(threadError.get());
        // busy waiting for correct number of rollbacks - at the moment there is no hook for a better solution
        final RecordingTransaction tx = threadTransaction.get();
        final long maxWait = System.currentTimeMillis() + (15 * 1000);
        while (tx.rollbackCounter.get() < 3 && System.currentTimeMillis() < maxWait) {
            Thread.sleep(100);
        }
        assertEquals(3, tx.rollbackCounter.get());

        final PoolableThread thread2 = pool.borrowThread();
        assertNotSame(thread1, thread2);
    } finally {
        if (pool != null) {
            try {
                pool.close();
            } catch (final Exception e) {
                // can't help it
            }
        }
        Config.setParameter("transaction.monitor.begin", BooleanUtils.toStringTrueFalse(flagBefore));
    }
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopGroupBox.java

@Override
public boolean saveSettings(Element element) {
    if (!isSettingsEnabled()) {
        return false;
    }/*w w  w .j a v a  2 s.c o m*/

    Element groupBoxElement = element.element("groupBox");
    if (groupBoxElement != null) {
        element.remove(groupBoxElement);
    }
    groupBoxElement = element.addElement("groupBox");
    groupBoxElement.addAttribute("expanded", BooleanUtils.toStringTrueFalse(isExpanded()));
    return true;
}

From source file:com.wineaccess.winerypermit.WineryPermitHelper.java

/**
 * @param winePermitViewPO//  www  .  j av  a 2 s.co m
 * @return
 */
public static Map<String, Object> generateViewPermitResponse(WineryPermitViewPO wineryPermitViewPO) {
    response = new FailureResponse();
    Map<String, Object> outputViewPermit = new HashMap<String, Object>();
    Long wineryId = Long.parseLong(wineryPermitViewPO.getWineryId());
    WineryModel wineryModel = WineryRepository.getWineryById(wineryId);
    if (wineryModel == null) {
        response.addError(new WineaccessError(SystemErrorCode.PERMIT_WINERY_ERROR,
                SystemErrorCode.PERMIT_WINERY_ERROR_TEXT));
    } else {
        WineryPermitDetailVO wineryPermitViewVO = new WineryPermitDetailVO();

        wineryPermitViewVO.setWineryId(wineryModel.getId());
        wineryPermitViewVO.setIsSellInMainStates(wineryModel.getSellInMainStates());
        /*if(BooleanUtils.isTrue(wineryModel.getSellInAltStates()))
          {*/

        SellInAltStatesResultModel sellInAltStatesModel = new SellInAltStatesResultModel();
        if (BooleanUtils.isTrue(wineryModel.getSellInAltStates()))
            sellInAltStatesModel.setIsSelected(true);

        Integer optionSelected = wineryModel.getOptionSelectedAltstates();
        if (optionSelected != null && optionSelected.equals(0)) {
            sellInAltStatesModel.setIsOptionSelectedKachinaAlt(true);

        }

        if (optionSelected != null && optionSelected.equals(2)) {
            sellInAltStatesModel.setOptionSelectedNoPermit(true);

        }
        /*else if(optionSelected.equals(1))
             {*/
        List<PermitModelResult> permitModelResultsList = new ArrayList<PermitModelResult>();
        OptionSelectedAltStatesResult optionSelectedAltStates = new OptionSelectedAltStatesResult();
        List<WineryLicensePermitAltStates> wineryLicensePermitAltStates = WineryPermitRepository
                .findWineryLicensePermitAltStates(wineryId);

        /*if(wineLicensePermitAltStates != null && !wineLicensePermitAltStates.isEmpty())
                {*/
        //Set<MasterData> wineryPermitMasterDataList = MasterDataTypeAdapterHelper.getMasterDataListByMasterTypeName("Winery Licence Permit");

        for (WineryLicensePermitAltStates permitModelFromDB : wineryLicensePermitAltStates) {
            PermitModelResult permitModelResult = new PermitModelResult();
            WineryPermitModelWithMasterData wineryPermitModelWithMasterData = new WineryPermitModelWithMasterData();
            MasterDataModel masterDataModel = new MasterDataModel();
            Long masterDataForPermit = permitModelFromDB.getWineryPermit().getId();

            permitModelResult.setDtcPermitEndDate(permitModelFromDB.getDtcPermitEndDate());
            permitModelResult.setDtcPermitStartDate(permitModelFromDB.getDtcPermitStartDate());
            permitModelResult.setDtcPermitNumber(permitModelFromDB.getDtcPermitNumber());
            permitModelResult.setIsSelected(permitModelFromDB.getIsSelected());
            permitModelResult.setPermitDurationInMonths(permitModelFromDB.getDtcPermitDurationInMonths());

            masterDataModel.setId(masterDataForPermit);
            masterDataModel.setMasterDataTypeName("WineryLicencePermit");
            masterDataModel.setMasterDataName(permitModelFromDB.getWineryPermit().getName());
            wineryPermitModelWithMasterData.setMasterData(masterDataModel);
            //wineryPermitModelWithMasterData.setPermitModelResult(permitModelResult);

            permitModelResult.setWineryPermit(wineryPermitModelWithMasterData);
            permitModelResultsList.add(permitModelResult);

        }

        optionSelectedAltStates.setPermit(permitModelResultsList);
        /*}*/
        WineryLicenseFullfillAltStates fulfilModelFromDB = WineryPermitRepository
                .findFulfilModelByWineryId(wineryId);
        FulFillModel fulfiModel = new FulFillModel();
        if (fulfilModelFromDB != null) {

            if (BooleanUtils.isTrue(fulfilModelFromDB.getWaWillNotFullFill())) {

            }
            fulfiModel.setIsSelected(BooleanUtils.toStringTrueFalse(fulfilModelFromDB.getIsSelected()));
            fulfiModel.setEscrowContract(BooleanUtils.toStringTrueFalse(fulfilModelFromDB.getEscrowContract()));
            fulfiModel.setWaPlatformContract(
                    BooleanUtils.toStringTrueFalse(fulfilModelFromDB.getWaPlatformContract()));
            fulfiModel.setIsStorageContact(
                    BooleanUtils.toStringTrueFalse(fulfilModelFromDB.getWineryStorageContract()));

            optionSelectedAltStates.setFulfillDirectlyNotWA(fulfilModelFromDB.getWaWillNotFullFill());
        }
        /*else if()
             optionSelectedAltStates.setFulfillDirectlyNotWA(true);*/

        optionSelectedAltStates.setFulfill(fulfiModel);

        /*WineLicenseFullfillAltStates wineFullfillAltStatesModel =  WinePermitRepository.findFulfilModelByWineId(wineModel.getId());
                if(wineFullfillAltStatesModel!=null)
                {
                
                }
                sellInAltStatesModel.setOptionSelectedAltStates(optionSelectedAltStates);
             }
          }
           wineFullfillAltStatesModel =  WinePermitRepository.findFulfilModelByWineId(wineModel.getId());
          if(wineFullfillAltStatesModel!=null)
          {
                
          }*/
        sellInAltStatesModel.setOptionSelectedAltStates(optionSelectedAltStates);
        Integer optionSelect = wineryModel.getOptionSelectedAltstates();
        if (optionSelect != null) {
            if (0 == optionSelect) {
                sellInAltStatesModel.setIsOptionSelectedKachinaAlt(true);
            } else if (2 == optionSelect) {
                sellInAltStatesModel.setOptionSelectedNoPermit(true);
            }
        }
        wineryPermitViewVO.setSellInAltStates(sellInAltStatesModel);
        /*}*/
        response = new com.wineaccess.response.SuccessResponse(wineryPermitViewVO, 200);
    }

    outputViewPermit.put("FINAL-RESPONSE", response);
    return outputViewPermit;
}

From source file:edu.cornell.med.icb.goby.R.FisherExact.java

/**
 * Performs Fisher's exact test using two input vectors.
 *
 * @param factor1/*from  ww w  .j av a  2s. co  m*/
 * @param factor2
 * @param alternativeHypothesis The alternative hypothesis to use for the calculation
 * @param hybrid                Wheter exact probabilities are computed (false) or a hybrid approximation
 *                              (true) is made
 * @return The result from the fisher test (should never be null)
 */
public static Result fexact(final int[] factor1, final int[] factor2,
        final AlternativeHypothesis alternativeHypothesis, final boolean hybrid) {
    assert factor1 != null && factor2 != null : "Input vector cannot be null";
    assert factor1.length == factor2.length : "Length of the two input vectors must be equal";

    final Result result;
    final Rengine rengine = GobyRengine.getInstance().getRengine();
    if (rengine != null && rengine.isAlive()) {
        final boolean xAssignResult = rengine.assign("x", factor1);
        if (LOG.isDebugEnabled()) {
            LOG.debug("X assigned: " + xAssignResult);
            final REXP xExpression = rengine.eval("x");
            LOG.debug("X: " + xExpression);
        }

        final boolean yAssignResult = rengine.assign("y", factor2);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Y assigned: " + yAssignResult);
            final REXP yExpression = rengine.eval("y");
            LOG.debug("Y: " + yExpression);
        }

        final StringBuilder fisherExpression = new StringBuilder(128);
        fisherExpression.append("fisher.test(x, y, hybrid=");
        fisherExpression.append(BooleanUtils.toStringTrueFalse(hybrid).toUpperCase(Locale.getDefault()));
        fisherExpression.append(", alternative=\"");
        fisherExpression.append(alternativeHypothesis);
        fisherExpression.append("\")");

        final boolean is2x2 = factor1.length == 2 && factor2.length == 2;
        result = evaluateFisherExpression(rengine, fisherExpression.toString(), is2x2);
    } else {
        LOG.warn(R_NOT_AVAILABLE);
        result = new Result(); // return an empty/default result object
    }
    return result;
}

From source file:gr.abiss.calipso.domain.State.java

private void copyTo(Element e) {
    // appending empty strings to create new objects for "clone" support
    e.addAttribute(STATUS, status + "");
    if (this.plugin != null && this.plugin.length() > 0) {
        e.addAttribute(PLUGIN, this.plugin);
    }//from   ww  w. j  av  a  2 s  .com
    // asset type id
    if (assetTypeId != null) {
        e.addAttribute(ASSET_TYPE_ID, assetTypeId.toString());
    }

    // asset type id
    if (existingAssetTypeId != null) {
        e.addAttribute(EXISTING_ASSET_TYPE_ID, existingAssetTypeId.toString());
    }
    // asset type id
    if (existingAssetTypeMultiple != null) {
        e.addAttribute(EXISTING_ASSET_TYPE_MULTIPLE, BooleanUtils.toStringTrueFalse(existingAssetTypeMultiple));
    }
    // max duration
    if (this.maxDuration != null) {
        e.addAttribute(MAX_DURATION, this.maxDuration.toString());
    }

    for (Integer toStatus : transitions) {
        Element t = e.addElement(TRANSITION);
        t.addAttribute(STATUS, toStatus + "");
    }

    for (Map.Entry<Field.Name, Integer> entry : fields.entrySet()) {
        Element f = e.addElement(FIELD);
        f.addAttribute(NAME, entry.getKey() + "");
        f.addAttribute(MASK, entry.getValue() + "");
    }
}

From source file:com.wineaccess.winepermit.WinePermitHelper.java

/**
 * @param winePermitViewPO/*from   www.  ja  v  a  2 s. co m*/
 * @return
 */
public static Map<String, Object> generateViewPermitResponse(WinePermitViewPO winePermitViewPO) {
    response = new FailureResponse();
    Map<String, Object> outputViewPermit = new HashMap<String, Object>();
    Long wineId = Long.parseLong(winePermitViewPO.getProductId());
    final ProductItemModel productModel = ProductItemRepository.getProductItemById(wineId);
    if (productModel == null) {
        response.addError(
                new WineaccessError(SystemErrorCode.PERMIT_WINE_ERROR, SystemErrorCode.PERMIT_WINE_ERROR_TEXT));
    }

    else {

        WineModel wineModel = WineRepository.getWineById(productModel.getItemId());
        if (wineModel == null) {
            response.addError(new WineaccessError(SystemErrorCode.PERMIT_WINE_ERROR,
                    SystemErrorCode.PERMIT_WINE_ERROR_TEXT));
        } else {
            WineryModel wineryModel = wineModel.getWineryId();
            if (BooleanUtils.isNotTrue(wineModel.getSellInAltStates())
                    && BooleanUtils.isNotTrue(wineModel.getSellInMainStates())
                    && (BooleanUtils.isNotFalse(wineryModel.getSellInAltStates())
                            || BooleanUtils.isNotFalse(wineryModel.getSellInMainStates()))) {
                copyFulfilModelFromWinery(wineModel);
                copyPermitModelFromWinery(wineModel);
                createNoPermitData(wineModel);
                wineModel.setSellInAltStates(wineryModel.getSellInAltStates());
                wineModel.setSellInMainStates(wineryModel.getSellInMainStates());
                wineModel.setOptionSelectedAltstates(wineryModel.getOptionSelectedAltstates());
                WineRepository.update(wineModel);
            }
            WinePermitDetailVO winePermitViewVO = new WinePermitDetailVO();

            winePermitViewVO.setWineId(wineModel.getId());
            winePermitViewVO.setIsSellInMainStates(wineModel.getSellInMainStates());

            SellInAltStatesResultModel sellInAltStatesModel = new SellInAltStatesResultModel();
            if (BooleanUtils.isTrue(wineModel.getSellInAltStates()))
                sellInAltStatesModel.setIsSelected(true);

            Integer optionSelected = wineModel.getOptionSelectedAltstates();
            if (optionSelected != null && optionSelected.equals(0)) {
                sellInAltStatesModel.setIsOptionSelectedKachinaAlt(true);

            }

            if (optionSelected != null && optionSelected.equals(2)) {

                sellInAltStatesModel.setIsOptionSelectedNoPermit(true);

            }

            List<PermitModelResult> permitModelResultsList = new ArrayList<PermitModelResult>();
            OptionSelectedAltStatesResult optionSelectedAltStates = new OptionSelectedAltStatesResult();
            List<WineLicensePermitAltStates> wineLicensePermitAltStates = WinePermitRepository
                    .findWineLicensePermitAltStates(wineId);

            for (WineLicensePermitAltStates permitModelFromDB : wineLicensePermitAltStates) {
                PermitModelResult permitModelResult = new PermitModelResult();
                WinePermitModelWithMasterData winePermitModelWithMasterData = new WinePermitModelWithMasterData();
                MasterDataModel masterDataModel = new MasterDataModel();
                Long masterDataForPermit = permitModelFromDB.getWineryPermit().getId();

                permitModelResult.setDtcPermitEndDate(permitModelFromDB.getDtcPermitEndDate());
                permitModelResult.setDtcPermitStartDate(permitModelFromDB.getDtcPermitStartDate());
                permitModelResult.setDtcPermitNumber(permitModelFromDB.getDtcPermitNumber());
                permitModelResult.setIsSelected(permitModelFromDB.getIsSelected());
                permitModelResult.setPermitDurationInMonths(permitModelFromDB.getDtcPermitDurationInMonths());

                masterDataModel.setId(masterDataForPermit);
                masterDataModel.setMasterDataTypeName(EnumTypes.MasterDataTypeEnum.WineryLicencePermit.name());
                masterDataModel.setMasterDataName(permitModelFromDB.getWineryPermit().getName());
                winePermitModelWithMasterData.setMasterData(masterDataModel);

                permitModelResult.setWinePermit(winePermitModelWithMasterData);
                permitModelResultsList.add(permitModelResult);

            }

            optionSelectedAltStates.setPermit(permitModelResultsList);
            /*}*/
            WineLicenseFullfillAltStates fulfilModelFromDB = WinePermitRepository
                    .findFulfilModelByWineId(wineId);
            FulFillModel fulfiModel = new FulFillModel();
            if (fulfilModelFromDB != null) {

                if (BooleanUtils.isTrue(fulfilModelFromDB.getWaWillNotFullFill())) {

                }
                fulfiModel.setIsSelected(BooleanUtils.toStringTrueFalse(fulfilModelFromDB.getIsSelected()));
                fulfiModel.setEscrowContract(
                        BooleanUtils.toStringTrueFalse(fulfilModelFromDB.getEscrowContract()));
                fulfiModel.setWaPlatformContract(
                        BooleanUtils.toStringTrueFalse(fulfilModelFromDB.getWaPlatformContract()));
                fulfiModel.setIsStorageContact(
                        BooleanUtils.toStringTrueFalse(fulfilModelFromDB.getWineryStorageContract()));

                optionSelectedAltStates.setFulfillDirectlyNotWA(fulfilModelFromDB.getWaWillNotFullFill());
            }

            optionSelectedAltStates.setFulfill(fulfiModel);

            /*WineLicenseFullfillAltStates wineFullfillAltStatesModel =  WinePermitRepository.findFulfilModelByWineId(wineModel.getId());
                     if(wineFullfillAltStatesModel!=null)
                     {
                    
                     }
                     sellInAltStatesModel.setOptionSelectedAltStates(optionSelectedAltStates);
                  }
               }
                wineFullfillAltStatesModel =  WinePermitRepository.findFulfilModelByWineId(wineModel.getId());
               if(wineFullfillAltStatesModel!=null)
               {
                    
               }*/
            Long mappedWineryId = wineModel.getMappedWineryWithPermit();
            if (mappedWineryId != null) {
                CustomWineryModel customWineryModel = new CustomWineryModel();

                if (WineryRepository.getWineryById(mappedWineryId) != null) {
                    customWineryModel.setWineryId(mappedWineryId);
                    customWineryModel
                            .setWineryName(WineryRepository.getWineryById(mappedWineryId).getWineryName());
                    optionSelectedAltStates.setMappedWineryWithPermit(customWineryModel);
                }
            }

            sellInAltStatesModel.setOptionSelectedAltStates(optionSelectedAltStates);
            Integer optionSelect = wineModel.getOptionSelectedAltstates();
            if (optionSelect != null) {
                if (0 == optionSelect) {
                    sellInAltStatesModel.setIsOptionSelectedKachinaAlt(true);
                }

            }

            List<WineLicenseNoPermit> wineLicenseNoPermit = WinePermitRepository
                    .findWineLicenseNoPermitAltStates(wineId);
            List<OptionSelectedNoPermitResult> optionSelectedNoPermitResult = new ArrayList<OptionSelectedNoPermitResult>();

            for (WineLicenseNoPermit wineLicenseNoPermitList : wineLicenseNoPermit) {
                OptionSelectedNoPermitResult noPermitResult = new OptionSelectedNoPermitResult();
                WinePermitModelWithMasterData winePermitModelWithMasterData = new WinePermitModelWithMasterData();
                MasterDataModel masterDataModel = new MasterDataModel();
                Long masterDataForNoPermit = wineLicenseNoPermitList.getWineNoPermit().getId();

                noPermitResult.setPriceFiled(wineLicenseNoPermitList.getPriceFiled());
                noPermitResult.setSc3TStatus(wineLicenseNoPermitList.getStatus());
                noPermitResult.setIsSelected(wineLicenseNoPermitList.getIsSelected());
                masterDataModel.setId(masterDataForNoPermit);
                masterDataModel
                        .setMasterDataTypeName(EnumTypes.MasterDataTypeEnum.WineryLicenceNoPermit.name());
                masterDataModel.setMasterDataName(wineLicenseNoPermitList.getWineNoPermit().getName());
                winePermitModelWithMasterData.setMasterData(masterDataModel);
                noPermitResult.setWinePermit(winePermitModelWithMasterData);
                optionSelectedNoPermitResult.add(noPermitResult);

            }

            sellInAltStatesModel.setOptionSelectedNoPermit(optionSelectedNoPermitResult);

            winePermitViewVO.setSellInAltStates(sellInAltStatesModel);
            /*}*/
            response = new com.wineaccess.response.SuccessResponse(winePermitViewVO, 200);
        }
    }
    outputViewPermit.put("FINAL-RESPONSE", response);
    return outputViewPermit;
}

From source file:com.ibm.jaql.lang.Jaql.java

public String getProperty(String name) {
    if (name.equalsIgnoreCase("enableRewrite")) {
        return BooleanUtils.toStringTrueFalse(doRewrite);
    } else if (name.equalsIgnoreCase("stopOnException")) {
        return BooleanUtils.toStringTrueFalse(stopOnException);
    } else if (name.equalsIgnoreCase("JaqlPrinter") && printer != null) {
        return printer.getClass().getName();
    } else {/* w w  w.  j a  v  a2 s  . co  m*/
        return null;
    }
}

From source file:de.hybris.platform.test.ThreadPoolTest.java

/**
 * CORE-66PLA-10816 Potential chance to fetch a PoolableThread with pending transaction from previous run
 * //from   ww  w . j  a v  a 2s.com
 * together with setting logger level for a log4j.logger.de.hybris.platform.util.threadpool=DEBUG prints out
 * information who/where started the stale transaction
 */
@Test
public void testTransactionCleanUp() throws Exception {
    final Queue<Transaction> recordedTransactions = new ConcurrentLinkedQueue<Transaction>();

    final boolean flagBefore = Config.getBoolean("transaction.monitor.begin", false);
    Config.setParameter("transaction.monitor.begin", "true");
    ThreadPool pool = null;

    try {
        // create own pool since we don't want to mess up the system
        pool = new ThreadPool(Registry.getCurrentTenantNoFallback().getTenantID(), MAX_THREADS);

        final GenericObjectPool.Config config = new GenericObjectPool.Config();
        config.maxActive = MAX_THREADS;
        config.maxIdle = 1;
        config.maxWait = -1;
        config.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_BLOCK;
        config.testOnBorrow = true;
        config.testOnReturn = true;
        config.timeBetweenEvictionRunsMillis = 30 * 1000; // keep idle threads for at most 30 sec
        pool.setConfig(config);

        final int maxSize = pool.getMaxActive();
        final int activeBefore = pool.getNumActive();
        final List<NoClosingTransactionProcess> started = new ArrayList<NoClosingTransactionProcess>(maxSize);
        for (int i = activeBefore; i < maxSize; i++) {
            final PoolableThread poolableThread = pool.borrowThread();
            final NoClosingTransactionProcess noClosingTransactionProcess = new NoClosingTransactionProcess();
            started.add(noClosingTransactionProcess);
            poolableThread.execute(noClosingTransactionProcess);
        }
        Thread.sleep(1000);

        transacationStartingBarrier.await(); //await for all transacations to start

        //record all started  transactions
        for (final NoClosingTransactionProcess singleStarted : started) {
            recordedTransactions.add(singleStarted.getStartedTransaction());
        }

        finishedStaleTransactionLatch.await(180, TimeUnit.SECONDS);
        Thread.sleep(1000);//give them 1 second to finish

        final List<HasNoCurrentRunningTransactionProcess> ranAfter = new ArrayList<HasNoCurrentRunningTransactionProcess>(
                maxSize);
        Transaction recordedTransaction = recordedTransactions.poll();
        do {
            final PoolableThread poolableThread = pool.borrowThread();
            final HasNoCurrentRunningTransactionProcess hasNoCurrentRunningTransactionProcess = new HasNoCurrentRunningTransactionProcess(
                    recordedTransaction);
            ranAfter.add(hasNoCurrentRunningTransactionProcess);
            poolableThread.execute(hasNoCurrentRunningTransactionProcess);
            recordedTransaction = recordedTransactions.poll();
        } while (recordedTransaction != null);
        //still can borrow
        Assert.assertNotNull(pool.borrowThread());
        Thread.sleep(1000);

        //verify if really Thread had a non started transaction on the enter
        for (final HasNoCurrentRunningTransactionProcess singleRanAfter : ranAfter) {
            if (singleRanAfter.getException() != null) {
                singleRanAfter.getException().printException();
                Assert.fail("Some of the thread(s) captured not finshied transaction in the pool ");
            }
        }
    } finally {
        if (pool != null) {
            try {
                pool.close();
            } catch (final Exception e) {
                // can't help it
            }
        }
        Config.setParameter("transaction.monitor.begin", BooleanUtils.toStringTrueFalse(flagBefore));

    }
}