List of usage examples for org.apache.commons.lang BooleanUtils isTrue
public static boolean isTrue(Boolean bool)
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
From source file:de.hybris.platform.ytelcoacceleratorstorefront.controllers.pages.payment.SilentOrderPostMockController.java
@RequestMapping(value = "/handle-form-post", method = RequestMethod.POST) public String handleFormPost(@Valid final SopPaymentDetailsForm form, final BindingResult bindingResult, @RequestParam("targetArea") final String targetArea, @RequestParam("editMode") final Boolean editMode, @RequestParam("paymentInfoId") final String paymentInfoId, final RedirectAttributes redirectAttributes) { getSopPaymentDetailsValidator().validate(form, bindingResult); if (bindingResult.hasErrors()) { redirectAttributes.addFlashAttribute(GlobalMessages.ERROR_MESSAGES_HOLDER, Collections.singletonList("checkout.error.paymentmethod.formentry.invalid")); redirectAttributes.addFlashAttribute( "org.springframework.validation.BindingResult.sopPaymentDetailsForm", bindingResult); redirectAttributes.addFlashAttribute("sopPaymentDetailsForm", bindingResult.getTarget()); return Boolean.TRUE.equals(editMode) ? REDIRECT_URL_EDIT_PAYMENT_DETAILS + paymentInfoId : REDIRECT_URL_ADD_PAYMENT_METHOD + targetArea; } else {/*from w w w . j av a2 s. com*/ final String authorizationRequestId = (String) getSessionService() .getAttribute("authorizationRequestId"); final String authorizationRequestToken = (String) getSessionService() .getAttribute("authorizationRequestToken"); try { if (BooleanUtils.isTrue(editMode)) { final CCPaymentInfoData ccPaymentInfoData = setupCCPaymentInfoData(form, paymentInfoId); if (null != ccPaymentInfoData) { final CCPaymentInfoData result = getSubscriptionFacade() .changePaymentMethod(ccPaymentInfoData, null, true, null); // enrich result data with form data, which is not provided from the facade call result.setId(paymentInfoId); result.getBillingAddress() .setTitleCode(ccPaymentInfoData.getBillingAddress().getTitleCode()); result.setStartMonth(ccPaymentInfoData.getStartMonth()); result.setStartYear(ccPaymentInfoData.getStartYear()); result.setIssueNumber(ccPaymentInfoData.getIssueNumber()); getUserFacade().updateCCPaymentInfo(result); if (form.getMakeAsDefault().booleanValue()) { getUserFacade().setDefaultPaymentInfo(result); } redirectAttributes.addFlashAttribute(GlobalMessages.CONF_MESSAGES_HOLDER, Collections.singletonList("text.account.paymentDetails.editSuccessful")); } else { redirectAttributes.addFlashAttribute(GlobalMessages.ERROR_MESSAGES_HOLDER, Collections.singletonList("text.account.paymentDetails.nonExisting.error")); } } else { final SubscriptionPaymentData result = getSubscriptionFacade().finalizeTransaction( authorizationRequestId, authorizationRequestToken, createPaymentDetailsMap(form, targetArea)); final CCPaymentInfoData newPaymentSubscription = getSubscriptionFacade() .createPaymentSubscription(result.getParameters()); // enrich result data with form data, which is not provided from the facade call if (BooleanUtils.isNotTrue(form.getNewBillingAddress()) && null != getCheckoutFacade().getCheckoutCart() && null != getCheckoutFacade().getCheckoutCart().getDeliveryAddress()) { newPaymentSubscription.getBillingAddress().setTitleCode( getCheckoutFacade().getCheckoutCart().getDeliveryAddress().getTitleCode()); } else if (null != form.getBillingAddress()) { newPaymentSubscription.getBillingAddress() .setTitleCode(form.getBillingAddress().getTitleCode()); } newPaymentSubscription.setStartMonth(form.getStartMonth()); newPaymentSubscription.setStartYear(form.getStartYear()); newPaymentSubscription.setIssueNumber(form.getIssueNumber()); newPaymentSubscription.setSaved(true); getUserFacade().updateCCPaymentInfo(newPaymentSubscription); if (form.getMakeAsDefault().booleanValue()) { getUserFacade().setDefaultPaymentInfo(newPaymentSubscription); } getCheckoutFacade().setPaymentDetails(newPaymentSubscription.getId()); redirectAttributes.addFlashAttribute(GlobalMessages.CONF_MESSAGES_HOLDER, Collections.singletonList("text.account.paymentDetails.addSuccessful")); } } catch (final SubscriptionFacadeException e) { LOG.error("Creating a new payment method failed", e); redirectAttributes.addFlashAttribute(GlobalMessages.ERROR_MESSAGES_HOLDER, Collections.singletonList("checkout.multi.paymentMethod.addPaymentDetails.incomplete")); return REDIRECT_URL_ADD_PAYMENT_METHOD + targetArea; } } if (StringUtils.equals(targetArea, "multiCheckoutArea")) { return REDIRECT_URL_SUMMARY; } return REDIRECT_URL_PAYMENT_INFO; }
From source file:jp.primecloud.auto.process.ProcessManager.java
protected boolean processStartInstance(final Farm farm) { // ??/*from w ww .j a v a 2 s . com*/ List<Instance> instances = new ArrayList<Instance>(); List<Instance> allInstances = instanceDao.readByFarmNo(farm.getFarmNo()); for (Instance instance : allInstances) { // ?? if (BooleanUtils.isTrue(instance.getLoadBalancer())) { continue; } if (BooleanUtils.isTrue(instance.getEnabled())) { instances.add(instance); } } // ???? if (instances.isEmpty()) { return true; } // ?? boolean processing = false; List<Long> targetInstanceNos = new ArrayList<Long>(); for (Instance instance : instances) { InstanceStatus status = InstanceStatus.fromStatus(instance.getStatus()); if (status != InstanceStatus.RUNNING && status != InstanceStatus.WARNING) { processing = true; if (status == InstanceStatus.STOPPED) { targetInstanceNos.add(instance.getInstanceNo()); } } } // ????? if (!targetInstanceNos.isEmpty()) { final User user = userDao.read(farm.getUserNo()); for (final Long instanceNo : targetInstanceNos) { Runnable runnable = new Runnable() { @Override public void run() { LoggingUtils.setUserNo(user.getMasterUser()); LoggingUtils.setUserName(user.getUsername()); LoggingUtils.setFarmNo(farm.getFarmNo()); LoggingUtils.setFarmName(farm.getFarmName()); LoggingUtils.setLoginUserNo(user.getUserNo()); try { instanceProcess.start(instanceNo); } catch (MultiCauseException ignore) { } catch (Throwable e) { log.error(e.getMessage(), e); // eventLogger.error("SystemError", new Object[] { e.getMessage() }); } finally { LoggingUtils.removeContext(); } } }; executorService.execute(runnable); } } // ????? if (processing) { return false; } return true; }
From source file:com.haulmont.cuba.gui.app.core.categories.CategoryAttrsFrame.java
protected void initDataTypeColumn() { categoryAttrsTable.removeGeneratedColumn("dataType"); categoryAttrsTable.addGeneratedColumn("dataType", new Table.ColumnGenerator<CategoryAttribute>() { @Override/* w w w . ja va2 s .c om*/ public Component generateCell(CategoryAttribute attribute) { Label dataTypeLabel = factory.createComponent(Label.class); String labelContent; if (BooleanUtils.isTrue(attribute.getIsEntity())) { Class clazz = attribute.getJavaClassForEntity(); if (clazz != null) { MetaClass metaClass = metadata.getSession().getClass(clazz); labelContent = messageTools.getEntityCaption(metaClass); } else { labelContent = "classNotFound"; } } else { labelContent = getMessage(attribute.getDataType().name()); } dataTypeLabel.setValue(labelContent); return dataTypeLabel; } }); }
From source file:com.haulmont.cuba.gui.presentations.PresentationsImpl.java
@Override public void modify(Presentation p) { checkLoad();//from w w w. j a v a 2 s. co m if (presentations.containsKey(p.getId())) { needToUpdate.add(p); if (BooleanUtils.isTrue(p.getDefault())) { setDefault(p); } else if (def != null && def.getId().equals(p.getId())) { setDefault(null); } } else { throw new IllegalStateException(String.format("Invalid presentation: %s", p.getId())); } }
From source file:com.haulmont.cuba.core.app.scheduling.Scheduling.java
@Override public List<ScheduledTask> getActiveTasks() { Coordinator.Context context = coordinator.begin(); coordinator.end(context);/* w w w . jav a 2 s .c om*/ List<ScheduledTask> tasks = context.getTasks(); for (ScheduledTask task : tasks) { if (!BooleanUtils.isTrue(task.getSingleton())) { Long time = lastStartCache.get(task); if (time != null) task.setLastStartTime(new Date(time)); } } return tasks; }
From source file:jp.primecloud.auto.process.lb.ElasticLoadBalancerProcess.java
public void configure(Long loadBalancerNo) { LoadBalancer loadBalancer = loadBalancerDao.read(loadBalancerNo); if (log.isInfoEnabled()) { log.info(//w w w.ja v a2s . co m MessageUtils.getMessage("IPROCESS-200230", loadBalancerNo, loadBalancer.getLoadBalancerName())); } //IaasGatewayWrapper? Farm farm = farmDao.read(loadBalancer.getFarmNo()); IaasGatewayWrapper gateway = iaasGatewayFactory.createIaasGateway(farm.getUserNo(), loadBalancer.getPlatformNo()); try { // ??????? if (BooleanUtils.isNotTrue(loadBalancer.getEnabled())) { elbZabbixHostProcess.stopTemplate(loadBalancerNo); } // ? gateway.configureLoadBalancer(loadBalancer.getLoadBalancerNo()); // ?????? if (BooleanUtils.isTrue(loadBalancer.getEnabled())) { elbZabbixHostProcess.startTemplate(loadBalancerNo); } } catch (RuntimeException e) { loadBalancer = loadBalancerDao.read(loadBalancerNo); // ? List<LoadBalancerListener> listeners = loadBalancerListenerDao.readByLoadBalancerNo(loadBalancerNo); for (LoadBalancerListener listener : listeners) { LoadBalancerListenerStatus status; if (BooleanUtils.isTrue(loadBalancer.getEnabled()) && BooleanUtils.isTrue(listener.getEnabled())) { status = LoadBalancerListenerStatus.WARNING; } else { status = LoadBalancerListenerStatus.STOPPED; } if (status != LoadBalancerListenerStatus.fromStatus(listener.getStatus()) || BooleanUtils.isTrue(listener.getConfigure())) { listener.setStatus(status.toString()); listener.setConfigure(false); loadBalancerListenerDao.update(listener); } } // ?? List<LoadBalancerInstance> lbInstances = loadBalancerInstanceDao.readByLoadBalancerNo(loadBalancerNo); List<Long> targetInstanceNos = new ArrayList<Long>(); for (LoadBalancerInstance lbInstance : lbInstances) { targetInstanceNos.add(lbInstance.getInstanceNo()); } List<Instance> targetInstances = instanceDao.readInInstanceNos(targetInstanceNos); Map<Long, Instance> targetInstanceMap = new HashMap<Long, Instance>(); for (Instance targetInstance : targetInstances) { targetInstanceMap.put(targetInstance.getInstanceNo(), targetInstance); } for (LoadBalancerInstance lbInstance : lbInstances) { LoadBalancerInstanceStatus status; Instance targetInstance = targetInstanceMap.get(lbInstance.getInstanceNo()); if (BooleanUtils.isTrue(loadBalancer.getEnabled()) && BooleanUtils.isTrue(lbInstance.getEnabled()) && BooleanUtils.isTrue(targetInstance.getEnabled())) { status = LoadBalancerInstanceStatus.WARNING; } else { status = LoadBalancerInstanceStatus.STOPPED; } if (status != LoadBalancerInstanceStatus.fromStatus(lbInstance.getStatus())) { lbInstance.setStatus(status.toString()); loadBalancerInstanceDao.update(lbInstance); } } throw e; } // ? List<LoadBalancerListener> listeners = loadBalancerListenerDao.readByLoadBalancerNo(loadBalancerNo); for (LoadBalancerListener listener : listeners) { LoadBalancerListenerStatus status; if (BooleanUtils.isTrue(loadBalancer.getEnabled()) && BooleanUtils.isTrue(listener.getEnabled())) { status = LoadBalancerListenerStatus.RUNNING; } else { status = LoadBalancerListenerStatus.STOPPED; } if (status != LoadBalancerListenerStatus.fromStatus(listener.getStatus()) || BooleanUtils.isTrue(listener.getConfigure())) { listener.setStatus(status.toString()); listener.setConfigure(false); loadBalancerListenerDao.update(listener); } } // ?? List<LoadBalancerInstance> lbInstances = loadBalancerInstanceDao.readByLoadBalancerNo(loadBalancerNo); List<Long> targetInstanceNos = new ArrayList<Long>(); for (LoadBalancerInstance lbInstance : lbInstances) { targetInstanceNos.add(lbInstance.getInstanceNo()); } List<Instance> targetInstances = instanceDao.readInInstanceNos(targetInstanceNos); Map<Long, Instance> targetInstanceMap = new HashMap<Long, Instance>(); for (Instance targetInstance : targetInstances) { targetInstanceMap.put(targetInstance.getInstanceNo(), targetInstance); } for (LoadBalancerInstance lbInstance : lbInstances) { LoadBalancerInstanceStatus status; Instance targetInstance = targetInstanceMap.get(lbInstance.getInstanceNo()); if (BooleanUtils.isTrue(loadBalancer.getEnabled()) && BooleanUtils.isTrue(lbInstance.getEnabled()) && BooleanUtils.isTrue(targetInstance.getEnabled())) { status = LoadBalancerInstanceStatus.RUNNING; } else { status = LoadBalancerInstanceStatus.STOPPED; } if (status != LoadBalancerInstanceStatus.fromStatus(lbInstance.getStatus())) { lbInstance.setStatus(status.toString()); loadBalancerInstanceDao.update(lbInstance); } } if (log.isInfoEnabled()) { log.info( MessageUtils.getMessage("IPROCESS-200231", loadBalancerNo, loadBalancer.getLoadBalancerName())); } }
From source file:com.haulmont.cuba.gui.components.filter.edit.CustomConditionFrame.java
@Override public void initComponents() { super.initComponents(); typeSelect.addValueChangeListener(e -> { boolean disableTypeCheckBox = ParamType.UNARY.equals(typeSelect.getValue()) || ParamType.BOOLEAN.equals(typeSelect.getValue()); inExprCb.setEnabled(!disableTypeCheckBox); if (disableTypeCheckBox) inExprCb.setValue(false);//w ww . java 2s . c o m boolean isEntity = ParamType.ENTITY.equals(typeSelect.getValue()); boolean isEnum = ParamType.ENUM.equals(typeSelect.getValue()); boolean isDate = ParamType.DATE.equals(typeSelect.getValue()); entityLab.setEnabled(isEntity || isEnum); entitySelect.setEnabled(isEntity || isEnum); entitySelect.setRequired(entitySelect.isEnabled()); paramWhereLab.setEnabled(isEntity); entityParamWhereField.setEnabled(isEntity); paramViewLab.setEnabled(isEntity); entityParamViewField.setEnabled(isEntity); useUserTimeZoneLab.setVisible(isDate); useUserTimeZone.setVisible(isDate); Param param = condition.getParam(); fillEntitySelect(param); //recreate default value component based on param type if (!initializing && defaultValueLayout.isVisible()) { ParamType paramType = (ParamType) e.getValue(); if ((isEntity || isEnum) && (entitySelect.getValue() == null)) { defaultValueLayout.remove(defaultValueComponent); param.setJavaClass(null); } else { Class paramJavaClass = getParamJavaClass(paramType); param.setJavaClass(paramJavaClass); param.setDefaultValue(null); createDefaultValueComponent(); } } }); inExprCb.addValueChangeListener(e -> { condition.getParam().setInExpr(BooleanUtils.isTrue((Boolean) e.getValue())); //recreate default value component based on "in list" checkbox value if (!initializing && defaultValueLayout.isVisible()) { condition.getParam().setDefaultValue(null); createDefaultValueComponent(); } }); useUserTimeZone.addValueChangeListener(e -> { if (defaultValueComponent != null) { if (defaultValueComponent instanceof DateField) { DateField dateField = (DateField) defaultValueComponent; if (Boolean.TRUE.equals(e.getValue())) { UserSession userSession = userSessionSource.getUserSession(); if (userSession.getTimeZone() != null) { dateField.setTimeZone(userSession.getTimeZone()); } dateField.setValue(null); dateField.setEditable(false); } else { dateField.setTimeZone(TimeZone.getDefault()); dateField.setEditable(true); } } } }); entitySelect.addValueChangeListener(e -> { if (initializing || !defaultValueLayout.isVisible()) { return; } if (e.getValue() == null) { defaultValueLayout.remove(defaultValueComponent); return; } Param param = condition.getParam(); Class paramJavaClass = e.getValue() instanceof Class ? (Class) e.getValue() : ((MetaClass) e.getValue()).getJavaClass(); param.setJavaClass(paramJavaClass); param.setDefaultValue(null); createDefaultValueComponent(); }); FilterHelper filterHelper = AppBeans.get(FilterHelper.class); filterHelper.setLookupNullSelectionAllowed(typeSelect, false); filterHelper.setLookupFieldPageLength(typeSelect, 12); joinField.setSuggester((source, text, cursorPosition) -> requestHint(joinField, text, cursorPosition)); joinField.setHighlightActiveLine(false); joinField.setShowGutter(false); whereField.setSuggester((source, text, cursorPosition) -> requestHint(whereField, text, cursorPosition)); whereField.setHighlightActiveLine(false); whereField.setShowGutter(false); entityParamWhereField.setSuggester((source, text, cursorPosition) -> requestHintParamWhere(entityParamWhereField, text, cursorPosition)); entityParamWhereField.setHighlightActiveLine(false); entityParamWhereField.setShowGutter(false); }
From source file:jp.primecloud.auto.api.ListEventLog.java
/** * * EventLog?????//from ww w .j a v a 2s . co m * * @param isFromCurrent ?/ * @param fromCurrent ??? * @param fromDate ?FROM * @param toDate ?TO * @param farmNo No * @param logLevel * @param componentNo ??No * @param instanceNo No * @param orderName ?? * @param orderBy /? * @return */ @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ListEventLogResponse login(@QueryParam(PARAM_NAME_USER) String userName, @QueryParam(PARAM_NAME_IS_FROM_CURRENT) String isFromCurrent, @QueryParam(PARAM_NAME_FROM_CURRENT) String fromCurrent, @QueryParam(PARAM_NAME_FROM_DATE) String fromDate, @QueryParam(PARAM_NAME_TO_DATE) String toDate, @QueryParam(PARAM_NAME_FARM_NO) String farmNo, @QueryParam(PARAM_NAME_LOG_LEVEL) String logLevel, @QueryParam(PARAM_NAME_COMPONENT_NO) String componentNo, @QueryParam(PARAM_NAME_INSTANCE_NO) String instanceNo, @QueryParam(PARAM_NAME_ORDER_NAME) String orderName, @QueryParam(PARAM_NAME_ORDER_ASC_DESC) String orderAscDesc) { ListEventLogResponse response = new ListEventLogResponse(); try { // ? // isFromCurrent ApiValidate.validateIsFromCurrent(isFromCurrent); if (Boolean.parseBoolean(isFromCurrent)) { // fromCurrent ApiValidate.validateFromCurrent(fromCurrent); } else { // fromDate ApiValidate.validateFromDate(fromDate); // toDate ApiValidate.validateToDate(toDate); } //farmNo if (StringUtils.isNotEmpty(farmNo) || StringUtils.isNotEmpty(componentNo) || StringUtils.isNotEmpty(instanceNo)) { ApiValidate.validateFarmNo(farmNo); } //logLevel ApiValidate.validateLogLevel(logLevel); //componentNo if (StringUtils.isNotEmpty(componentNo)) { ApiValidate.validateComponentNo(componentNo); } //instanceNo if (StringUtils.isNotEmpty(instanceNo)) { ApiValidate.validateInstanceNo(instanceNo); } //orderName if (StringUtils.isNotEmpty(orderAscDesc)) { ApiValidate.validateOrderName(orderName); } //orderAscDesc if (StringUtils.isNotEmpty(orderName)) { ApiValidate.validateOrderAscDesc(orderAscDesc); } if (StringUtils.isNotEmpty(farmNo)) { //? Farm farm = farmDao.read(Long.parseLong(farmNo)); if (farm == null) { // ???? throw new AutoApplicationException("EAPI-100000", "Farm", PARAM_NAME_FARM_NO, farmNo); } } if (StringUtils.isNotEmpty(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); } if (BooleanUtils.isFalse(instance.getFarmNo().equals(Long.parseLong(farmNo)))) { //????? throw new AutoApplicationException("EAPI-100022", "Instance", farmNo, PARAM_NAME_INSTANCE_NO, instanceNo); } } if (StringUtils.isNotEmpty(componentNo)) { // ??? Component component = componentDao.read(Long.parseLong(componentNo)); if (component == null || BooleanUtils.isTrue(component.getLoadBalancer())) { // ?????? ??? ??? throw new AutoApplicationException("EAPI-100000", "Component", PARAM_NAME_COMPONENT_NO, componentNo); } if (component.getFarmNo().equals(Long.parseLong(farmNo)) == false) { //??????? throw new AutoApplicationException("EAPI-100022", "Component", farmNo, PARAM_NAME_COMPONENT_NO, componentNo); } } // ? User user = userDao.readByUsername(userName); //? SearchCondition searchCondition = new SearchCondition(); searchCondition.setUserNo(user.getUserNo()); if (Boolean.parseBoolean(isFromCurrent)) { //fromCurrent searchCondition.setFromDate(getFromCurrentDate(fromCurrent)); } else { //fromDate searchCondition.setFromDate(sdf.parse(fromDate)); //toDate if (StringUtils.isNotEmpty(toDate)) { searchCondition.setToDate(sdf.parse(toDate)); } } if (StringUtils.isNotEmpty(farmNo)) { searchCondition.setFarmNo(Long.parseLong(farmNo)); } if (StringUtils.isNotEmpty(logLevel)) { searchCondition.setLogLevel(getLogLevelCode(logLevel)); } if (StringUtils.isNotEmpty(componentNo)) { searchCondition.setComponentNo(Long.parseLong(componentNo)); } if (StringUtils.isNotEmpty(instanceNo)) { searchCondition.setInstanceNo(Long.parseLong(instanceNo)); } searchCondition.setLimit(LIMIT); List<EventLog> eventLogs = eventLogService.readBySearchCondition(searchCondition); List<EventLogResponse> eventLogResponceList = new ArrayList<EventLogResponse>(); for (EventLog eventLog : eventLogs) { EventLogResponse eventLogResponse = new EventLogResponse(eventLog); eventLogResponse.setDate(sdf.format(eventLog.getLogDate())); eventLogResponse.setLogLevel(EventLogLevel.fromCode(eventLog.getLogLevel()).name()); eventLogResponceList.add(eventLogResponse); } //? comparatorEventLog = getComparator(orderName, orderAscDesc); Collections.sort(eventLogResponceList, comparatorEventLog); response.setEventLogs(eventLogResponceList); 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.wineaccess.winepermit.WinePermitHelper.java
/** * @param winePermitViewPO//from w w w.jav a 2 s. c o 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.haulmont.cuba.gui.presentations.PresentationsImpl.java
@Override public boolean isAutoSave(Presentation p) { p = getPresentation(p.getId()); return p != null && BooleanUtils.isTrue(p.getAutoSave()); }