List of usage examples for org.apache.commons.lang BooleanUtils toBooleanObject
public static Boolean toBooleanObject(String str)
Converts a String to a Boolean.
'true'
, 'on'
or 'yes'
(case insensitive) will return true
.
From source file:me.yyam.mongodbutils.MongoDbOperater.java
public QueryInfo sql2QueryInfo(String dbName, String sql) throws JSQLParserException { QueryInfo queryInfo = new QueryInfo(); queryInfo.dbName = dbName;/*from w w w . j av a 2 s .c o m*/ CCJSqlParserManager parserManager = new CCJSqlParserManager(); Statement statement = parserManager.parse(new StringReader(sql)); Expression whereExpression = null; List<OrderByElement> orderList = null; if (statement instanceof Select) { queryInfo.action = "select"; Select select = (Select) statement; PlainSelect selectBody = (PlainSelect) select.getSelectBody(); whereExpression = selectBody.getWhere(); queryInfo.collName = selectBody.getFromItem().toString(); orderList = selectBody.getOrderByElements(); Limit limit = selectBody.getLimit(); //Long limit = selectBody.getLimit().getRowCount(); if (null != limit) { queryInfo.skip = limit.getOffset(); queryInfo.limit = limit.getRowCount(); } } else if (statement instanceof Delete) { queryInfo.action = "delete"; Delete delete = (Delete) statement; whereExpression = delete.getWhere(); queryInfo.collName = delete.getTable().getName(); } else if (statement instanceof Update) { //throw new RuntimeException("update ??"); queryInfo.action = "update"; Update update = (Update) statement; whereExpression = update.getWhere(); queryInfo.collName = update.getTable().getName(); List<Column> columnList = update.getColumns(); List<Expression> expressionList = update.getExpressions(); queryInfo.updateObj = new BasicDBObject(); for (int i = 0; i < columnList.size(); i++) { String v = expressionList.get(i).toString(); String columnName = columnList.get(i).getColumnName(); if (v.startsWith("'") && v.endsWith("'")) { String v1 = v.substring(1, v.length() - 1); try { if (dateP.matcher(v1).find()) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); queryInfo.updateObj.put(columnList.get(i).getColumnName(), df.parse(v1)); } else if (timeP.matcher(v1).find()) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); queryInfo.updateObj.put(columnList.get(i).getColumnName(), df.parse(v1)); } else { queryInfo.updateObj.put(columnList.get(i).getColumnName(), v1); } } catch (ParseException e) { throw new JSQLParserException( "??yyyy-MM-dd yyyy-MM-dd HH:mm:ss value:" + v1, e); } } else { if (v.trim().equalsIgnoreCase("true") || v.trim().equalsIgnoreCase("false")) { queryInfo.updateObj.put(columnName, BooleanUtils.toBooleanObject(v.trim())); } else if (v.contains(".")) { try { Double dv = Double.valueOf(v); queryInfo.updateObj.put(columnName, dv); } catch (Exception ee) { queryInfo.updateObj.put(columnName, v); } } else { try { Integer iv = Integer.valueOf(v.trim()); queryInfo.updateObj.put(columnName, iv); } catch (Exception e) { queryInfo.updateObj.put(columnName, v); } } } } } else if (statement instanceof Insert) { throw new RuntimeException("insert ??"); } else { throw new JSQLParserException("??sql?:" + sql); } if (whereExpression != null) { Sql2MongoExpressVisitor visitor = new Sql2MongoExpressVisitor(); whereExpression.accept(visitor); queryInfo.query = visitor.getQuery(); } if (orderList != null) { queryInfo.order = new BasicDBObject(); for (OrderByElement ele : orderList) { queryInfo.order.put(ele.getExpression().toString(), ele.isAsc() ? 1 : -1); } } // System.out.println(queryInfo.debugStr()); return queryInfo; }
From source file:jp.primecloud.auto.service.impl.FarmServiceImpl.java
/** * {@inheritDoc}/* w w w .ja v a2s . c om*/ */ @Override public void deleteFarm(Long farmNo) { // ? if (farmNo == null) { throw new AutoApplicationException("ECOMMON-000003", "farmNo"); } // ?? Farm farm = farmDao.read(farmNo); if (farm == null) { // ????? return; } // ????????????? List<Component> components = componentDao.readByFarmNo(farmNo); for (Component component : components) { // ????????? if (BooleanUtils.isTrue(component.getLoadBalancer())) { continue; } List<ComponentInstance> componentInstances = componentInstanceDao .readByComponentNo(component.getComponentNo()); for (ComponentInstance componentInstance : componentInstances) { ComponentInstanceStatus status = ComponentInstanceStatus.fromStatus(componentInstance.getStatus()); if (status != ComponentInstanceStatus.STOPPED) { // ???????? throw new AutoApplicationException("ESERVICE-000202", component.getComponentName()); } } } // ??????????? List<Instance> instances = instanceDao.readByFarmNo(farmNo); for (Instance instance : instances) { // ??????? if (BooleanUtils.isTrue(instance.getLoadBalancer())) { continue; } if (InstanceStatus.fromStatus(instance.getStatus()) != InstanceStatus.STOPPED) { // ?????? throw new AutoApplicationException("ESERVICE-000203", instance.getInstanceName()); } } // ???????????? List<LoadBalancer> loadBalancers = loadBalancerDao.readByFarmNo(farmNo); for (LoadBalancer loadBalancer : loadBalancers) { if (LoadBalancerStatus.fromStatus(loadBalancer.getStatus()) != LoadBalancerStatus.STOPPED) { // ??????? throw new AutoApplicationException("ESERVICE-000207", loadBalancer.getLoadBalancerName()); } } // ?? Boolean useZabbix = BooleanUtils.toBooleanObject(Config.getProperty("zabbix.useZabbix")); if (BooleanUtils.isTrue(useZabbix)) { zabbixHostProcess.deleteFarmHostgroup(farmNo); } // ??? for (LoadBalancer loadBalancer : loadBalancers) { loadBalancerService.deleteLoadBalancer(loadBalancer.getLoadBalancerNo()); } // ???? for (Component component : components) { componentService.deleteComponent(component.getComponentNo()); } // ?? for (Instance instance : instances) { instanceService.deleteInstance(instance.getInstanceNo()); } // TODO CLOUD BRANCHING // AWS?? // AWS?? // TODO: ??????? List<AwsVolume> awsVolumes = awsVolumeDao.readByFarmNo(farmNo); for (AwsVolume awsVolume : awsVolumes) { if (StringUtils.isEmpty(awsVolume.getVolumeId())) { continue; } IaasGatewayWrapper gateway = iaasGatewayFactory.createIaasGateway(farm.getUserNo(), awsVolume.getPlatformNo()); try { // ? gateway.deleteVolume(awsVolume.getVolumeId()); // EC2??DeleteVolume???????Wait??? //awsProcessClient.waitDeleteVolume(volumeId); } catch (AutoException ignore) { // ?????????????? } } awsVolumeDao.deleteByFarmNo(farmNo); // VMware?? // VLAN?? List<VmwareNetwork> vmwareNetworks = vmwareNetworkDao.readByFarmNo(farmNo); for (VmwareNetwork vmwareNetwork : vmwareNetworks) { // PortGroup VmwareProcessClient vmwareProcessClient = vmwareProcessClientFactory .createVmwareProcessClient(vmwareNetwork.getPlatformNo()); try { vmwareNetworkProcess.removeNetwork(vmwareProcessClient, vmwareNetwork.getNetworkNo()); } finally { vmwareProcessClient.getVmwareClient().logout(); } // VLAN? vmwareNetwork.setFarmNo(null); vmwareNetworkDao.update(vmwareNetwork); } // VCloud?? // VCloud vApp?? List<Platform> platforms = platformDao.readAll(); for (Platform platform : platforms) { if (!PCCConstant.PLATFORM_TYPE_VCLOUD.equals(platform.getPlatformType())) { //VCloud???? continue; } IaasGatewayWrapper gateway = iaasGatewayFactory.createIaasGateway(farm.getUserNo(), platform.getPlatformNo()); try { if (BooleanUtils.isTrue(platform.getSelectable()) && vcloudCertificateDao.countByUserNoAndPlatformNo(farm.getUserNo(), platform.getPlatformNo()) > 0 && vcloudKeyPairDao.countByUserNoAndPlatformNo(farm.getUserNo(), platform.getPlatformNo()) > 0) { // myCloud(vApp)? gateway.deleteMyCloud(farmNo); } } catch (AutoException ignore) { // ??VCloud???? // ?????????????? } } // Azure?? // ???? // OpenStack?? // ???? //?? userAuthDao.deleteByFarmNo(farmNo); // ?? farmDao.deleteByFarmNo(farmNo); // eventLogger.log(EventLogLevel.INFO, farmNo, farm.getFarmName(), null, null, null, null, "FarmDelete", null, null, null); }
From source file:jp.primecloud.auto.service.impl.ComponentServiceImpl.java
/** * {@inheritDoc}/*from ww w.j a v a 2 s . com*/ */ @Override public Long createComponent(Long farmNo, String componentName, Long componentTypeNo, String comment, Integer diskSize) { // ? if (farmNo == null) { throw new AutoApplicationException("ECOMMON-000003", "farmNo"); } if (componentName == null || componentName.length() == 0) { throw new AutoApplicationException("ECOMMON-000003", "componentName"); } if (componentTypeNo == null) { throw new AutoApplicationException("ECOMMON-000003", "componentTypeNo"); } // ?? if (!Pattern.matches("^[0-9a-z]|[0-9a-z][0-9a-z-]*[0-9a-z]$", componentName)) { throw new AutoApplicationException("ECOMMON-000012", "componentName"); } // TODO: ?? // ??????? Component checkComponent = componentDao.readByFarmNoAndComponentName(farmNo, componentName); if (checkComponent != null) { // ????????? throw new AutoApplicationException("ESERVICE-000301", componentName); } // ?? Farm farm = farmDao.read(farmNo); if (farm == null) { throw new AutoApplicationException("ESERVICE-000305", farmNo); } // ???? Component component = new Component(); component.setFarmNo(farmNo); component.setComponentName(componentName); component.setComponentTypeNo(componentTypeNo); component.setComment(comment); componentDao.create(component); // ????? if (diskSize != null) { // ? ComponentConfig componentConfig = new ComponentConfig(); componentConfig.setComponentNo(component.getComponentNo()); componentConfig.setConfigName(ComponentConstants.CONFIG_NAME_DISK_SIZE); componentConfig.setConfigValue(diskSize.toString()); componentConfigDao.create(componentConfig); } ComponentType componentType = componentTypeDao.read(componentTypeNo); // TODO: ??phpMyAdmin??? // MySQL??????phpMyAdmin?? if (MySQLConstants.COMPONENT_TYPE_NAME.equals(componentType.getComponentTypeName())) { ComponentConfig componentConfig = new ComponentConfig(); componentConfig.setComponentNo(component.getComponentNo()); componentConfig.setConfigName(MySQLConstants.CONFIG_NAME_PHP_MY_ADMIN); componentConfig.setConfigValue("true"); componentConfigDao.create(componentConfig); } // ?? Boolean useZabbix = BooleanUtils.toBooleanObject(Config.getProperty("zabbix.useZabbix")); if (BooleanUtils.isTrue(useZabbix)) { zabbixHostProcess.createComponentHostgroup(component.getComponentNo()); } // eventLogger.log(EventLogLevel.INFO, farmNo, farm.getFarmName(), component.getComponentNo(), componentName, null, null, "ComponentCreate", null, null, new Object[] { componentType.getComponentTypeName() }); return component.getComponentNo(); }
From source file:fr.hoteia.qalingo.web.service.impl.WebBackofficeServiceImpl.java
private void updateProductCategoryMasterAttribute( final CatalogCategoryMasterAttribute productCategoryMasterAttribute, final String attributeValue) { AttributeDefinition attributeDefinition = productCategoryMasterAttribute.getAttributeDefinition(); if (AttributeDefinition.ATTRIBUTE_TYPE_STRING == attributeDefinition.getAttributeType()) { productCategoryMasterAttribute.setStringValue(attributeValue); } else if (AttributeDefinition.ATTRIBUTE_TYPE_DOUBLE == attributeDefinition.getAttributeType()) { productCategoryMasterAttribute.setDoubleValue(Double.parseDouble(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_FLOAT == attributeDefinition.getAttributeType()) { productCategoryMasterAttribute.setFloatValue(Float.parseFloat(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_INTEGER == attributeDefinition.getAttributeType()) { productCategoryMasterAttribute.setIntegerValue(Integer.parseInt(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_BLOB == attributeDefinition.getAttributeType()) { productCategoryMasterAttribute.setBlobValue(attributeValue.getBytes()); } else if (AttributeDefinition.ATTRIBUTE_TYPE_BOOLEAN == attributeDefinition.getAttributeType()) { productCategoryMasterAttribute.setBooleanValue(BooleanUtils.toBooleanObject(attributeValue)); }/*from ww w. j a va 2s . c o m*/ }
From source file:jp.primecloud.auto.process.zabbix.ZabbixHostProcess.java
protected void startTemplateHostgroup(ZabbixProcessClient zabbixProcessClient, Instance instance, Component component, String hostid) { // ????/*from w w w. j a v a 2 s . c om*/ List<Hostgroup> hostgroups = zabbixProcessClient.getHostgroupsByHostid(hostid); List<String> groupids = new ArrayList<String>(); for (Hostgroup hostgroup : hostgroups) { groupids.add(hostgroup.getGroupid()); } // ?????? Farm farm = farmDao.read(instance.getFarmNo()); User user = userDao.read(farm.getUserNo()); Platform platform = platformDao.read(instance.getPlatformNo()); String hostgroupName = getHostgroupName(user, farm, component); Hostgroup hostgroup = zabbixProcessClient.getHostgroupByName(hostgroupName); // ??????????? if (hostgroup != null && !groupids.contains(hostgroup.getGroupid())) { hostgroups.add(hostgroup); //??? String hostname = getHostName(instance.getFqdn()); //IP/DNS? Boolean useIp = BooleanUtils.toBooleanObject(Config.getProperty("zabbix.useIp")); //ZabbixID? String proxyHostid = getProxyHostid(zabbixProcessClient); //IP String zabbixListenIp = getZabbixListenIp(zabbixProcessClient, instance, platform); zabbixProcessClient.updateHost(hostid, hostname, instance.getFqdn(), hostgroups, null, useIp, zabbixListenIp, proxyHostid); } }
From source file:jp.primecloud.auto.service.impl.LoadBalancerServiceImpl.java
/** * {@inheritDoc}//from w w w .j a v a2 s.co m */ @Override public List<LoadBalancerDto> getLoadBalancers(Long farmNo) { // ? if (farmNo == null) { throw new AutoApplicationException("ECOMMON-000003", "farmNo"); } List<LoadBalancer> loadBalancers = loadBalancerDao.readByFarmNo(farmNo); // ??? List<Long> loadBalancerNos = new ArrayList<Long>(); for (LoadBalancer loadBalancer : loadBalancers) { loadBalancerNos.add(loadBalancer.getLoadBalancerNo()); } // (AWS)? List<PlatformAws> platformAwss = platformAwsDao.readAll(); Map<Long, PlatformAws> platformAwsMap = new LinkedHashMap<Long, PlatformAws>(); for (PlatformAws platformAws : platformAwss) { platformAwsMap.put(platformAws.getPlatformNo(), platformAws); } // (VMWare)? List<PlatformVmware> platformVmwares = platformVmwareDao.readAll(); Map<Long, PlatformVmware> platformVmwareMap = new LinkedHashMap<Long, PlatformVmware>(); for (PlatformVmware platformVmware : platformVmwares) { platformVmwareMap.put(platformVmware.getPlatformNo(), platformVmware); } // (Nifty)? List<PlatformNifty> platformNifties = platformNiftyDao.readAll(); Map<Long, PlatformNifty> platformNiftyMap = new LinkedHashMap<Long, PlatformNifty>(); for (PlatformNifty platformNifty : platformNifties) { platformNiftyMap.put(platformNifty.getPlatformNo(), platformNifty); } // (CloudStack)? List<PlatformCloudstack> platformCloudstacks = platformCloudstackDao.readAll(); Map<Long, PlatformCloudstack> platformCloudstackMap = new LinkedHashMap<Long, PlatformCloudstack>(); for (PlatformCloudstack platformCloudstack : platformCloudstacks) { platformCloudstackMap.put(platformCloudstack.getPlatformNo(), platformCloudstack); } // (Vcloud)? List<PlatformVcloud> platformVclouds = platformVcloudDao.readAll(); Map<Long, PlatformVcloud> platformVcloudMap = new LinkedHashMap<Long, PlatformVcloud>(); for (PlatformVcloud platformVcloud : platformVclouds) { platformVcloudMap.put(platformVcloud.getPlatformNo(), platformVcloud); } // (Azure)? List<PlatformAzure> platformAzures = platformAzureDao.readAll(); Map<Long, PlatformAzure> platformAzureMap = new LinkedHashMap<Long, PlatformAzure>(); for (PlatformAzure platformAzure : platformAzures) { platformAzureMap.put(platformAzure.getPlatformNo(), platformAzure); } // ? List<Platform> platforms = platformDao.readAll(); // PlatformDto? Map<Long, PlatformDto> platformDtoMap = new LinkedHashMap<Long, PlatformDto>(); for (Platform platform : platforms) { PlatformDto platformDto = new PlatformDto(); platformDto.setPlatform(platform); platformDto.setPlatformAws(platformAwsMap.get(platform.getPlatformNo())); platformDto.setPlatformCloudstack(platformCloudstackMap.get(platform.getPlatformNo())); platformDto.setPlatformVmware(platformVmwareMap.get(platform.getPlatformNo())); platformDto.setPlatformNifty(platformNiftyMap.get(platform.getPlatformNo())); platformDto.setPlatformVcloud(platformVcloudMap.get(platform.getPlatformNo())); platformDto.setPlatformAzure(platformAzureMap.get(platform.getPlatformNo())); platformDtoMap.put(platform.getPlatformNo(), platformDto); } // (AWS)? List<ImageAws> imageAwses = imageAwsDao.readAll(); Map<Long, ImageAws> imageAwsMap = new LinkedHashMap<Long, ImageAws>(); for (ImageAws imageAws : imageAwses) { imageAwsMap.put(imageAws.getImageNo(), imageAws); } // (Cloudstack)? List<ImageCloudstack> imageCloudstacks = imageCloudstackDao.readAll(); Map<Long, ImageCloudstack> imageCloudstackMap = new LinkedHashMap<Long, ImageCloudstack>(); for (ImageCloudstack imageCloudstack : imageCloudstacks) { imageCloudstackMap.put(imageCloudstack.getImageNo(), imageCloudstack); } // (VMWare)? List<ImageVmware> imageVmwares = imageVmwareDao.readAll(); Map<Long, ImageVmware> imageVmwareMap = new LinkedHashMap<Long, ImageVmware>(); for (ImageVmware imageVmware : imageVmwares) { imageVmwareMap.put(imageVmware.getImageNo(), imageVmware); } // (Nifty)? List<ImageNifty> imageNifties = imageNiftyDao.readAll(); Map<Long, ImageNifty> imageNiftyMap = new LinkedHashMap<Long, ImageNifty>(); for (ImageNifty imageNifty : imageNifties) { imageNiftyMap.put(imageNifty.getImageNo(), imageNifty); } // (VCloud)? List<ImageVcloud> imageVclouds = imageVcloudDao.readAll(); Map<Long, ImageVcloud> imageVcloudMap = new LinkedHashMap<Long, ImageVcloud>(); for (ImageVcloud imageVcloud : imageVclouds) { imageVcloudMap.put(imageVcloud.getImageNo(), imageVcloud); } // (Azure)? List<ImageAzure> imageAzures = imageAzureDao.readAll(); Map<Long, ImageAzure> imageAzureMap = new LinkedHashMap<Long, ImageAzure>(); for (ImageAzure imageAzure : imageAzures) { imageAzureMap.put(imageAzure.getImageNo(), imageAzure); } // ? List<Image> images = imageDao.readAll(); // ImageDto? Map<Long, ImageDto> imageDtoMap = new LinkedHashMap<Long, ImageDto>(); for (Image image : images) { ImageDto imageDto = new ImageDto(); imageDto.setImage(image); imageDto.setImageAws(imageAwsMap.get(image.getImageNo())); imageDto.setImageVmware(imageVmwareMap.get(image.getImageNo())); imageDto.setImageCloudstack(imageCloudstackMap.get(image.getImageNo())); imageDto.setImageNifty(imageNiftyMap.get(image.getImageNo())); imageDto.setImageVcloud(imageVcloudMap.get(image.getImageNo())); imageDto.setImageAzure(imageAzureMap.get(image.getImageNo())); imageDtoMap.put(image.getImageNo(), imageDto); } // AWS?? List<AwsLoadBalancer> awsLoadBalancers = awsLoadBalancerDao.readInLoadBalancerNos(loadBalancerNos); Map<Long, AwsLoadBalancer> awsLoadBalancerMap = new LinkedHashMap<Long, AwsLoadBalancer>(); for (AwsLoadBalancer awsLoadBalancer : awsLoadBalancers) { awsLoadBalancerMap.put(awsLoadBalancer.getLoadBalancerNo(), awsLoadBalancer); } // CloudStack?? List<CloudstackLoadBalancer> cloudstackLoadBalancers = cloudstackLoadBalancerDao .readInLoadBalancerNos(loadBalancerNos); Map<Long, CloudstackLoadBalancer> cloudstackLoadBalancerMap = new LinkedHashMap<Long, CloudstackLoadBalancer>(); for (CloudstackLoadBalancer cloudstackLoadBalancer : cloudstackLoadBalancers) { cloudstackLoadBalancerMap.put(cloudstackLoadBalancer.getLoadBalancerNo(), cloudstackLoadBalancer); } // ???? List<ComponentLoadBalancer> componentLoadBalancers = componentLoadBalancerDao .readInLoadBalancerNos(loadBalancerNos); Map<Long, ComponentLoadBalancer> componentLoadBalancerMap = new LinkedHashMap<Long, ComponentLoadBalancer>(); for (ComponentLoadBalancer componentLoadBalancer : componentLoadBalancers) { componentLoadBalancerMap.put(componentLoadBalancer.getLoadBalancerNo(), componentLoadBalancer); } // ? List<LoadBalancerListener> allListeners = loadBalancerListenerDao.readInLoadBalancerNos(loadBalancerNos); Map<Long, List<LoadBalancerListener>> listenersMap = new LinkedHashMap<Long, List<LoadBalancerListener>>(); for (LoadBalancerListener listener : allListeners) { List<LoadBalancerListener> listeners = listenersMap.get(listener.getLoadBalancerNo()); if (listeners == null) { listeners = new ArrayList<LoadBalancerListener>(); listenersMap.put(listener.getLoadBalancerNo(), listeners); } listeners.add(listener); } // ?? List<LoadBalancerHealthCheck> allHealthChecks = loadBalancerHealthCheckDao .readInLoadBalancerNos(loadBalancerNos); Map<Long, LoadBalancerHealthCheck> healthCheckMap = new LinkedHashMap<Long, LoadBalancerHealthCheck>(); for (LoadBalancerHealthCheck healthCheck : allHealthChecks) { healthCheckMap.put(healthCheck.getLoadBalancerNo(), healthCheck); } // ? List<AutoScalingConf> autoScalingConfs = autoScalingConfDao.readInLoadBalancerNos(loadBalancerNos); Map<Long, AutoScalingConf> autoScalingConfMap = new LinkedHashMap<Long, AutoScalingConf>(); for (AutoScalingConf autoScalingConf : autoScalingConfs) { autoScalingConfMap.put(autoScalingConf.getLoadBalancerNo(), autoScalingConf); } // ?? List<LoadBalancerInstance> allLbInstances = loadBalancerInstanceDao.readInLoadBalancerNos(loadBalancerNos); Map<Long, List<LoadBalancerInstance>> lbInstancesMap = new LinkedHashMap<Long, List<LoadBalancerInstance>>(); for (LoadBalancerInstance lbInstance : allLbInstances) { List<LoadBalancerInstance> lbInstances = lbInstancesMap.get(lbInstance.getLoadBalancerNo()); if (lbInstances == null) { lbInstances = new ArrayList<LoadBalancerInstance>(); lbInstancesMap.put(lbInstance.getLoadBalancerNo(), lbInstances); } lbInstances.add(lbInstance); } // ? Set<Long> targetInstanceNos = new HashSet<Long>(); for (LoadBalancerInstance lbInstance : allLbInstances) { 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); } List<LoadBalancerDto> dtos = new ArrayList<LoadBalancerDto>(); for (LoadBalancer loadBalancer : loadBalancers) { Long loadBalancerNo = loadBalancer.getLoadBalancerNo(); AwsLoadBalancer awsLoadBalancer = awsLoadBalancerMap.get(loadBalancerNo); CloudstackLoadBalancer cloudstackLoadBalancer = cloudstackLoadBalancerMap.get(loadBalancerNo); ComponentLoadBalancer componentLoadBalancer = componentLoadBalancerMap .get(loadBalancer.getLoadBalancerNo()); List<LoadBalancerListener> listeners = listenersMap.get(loadBalancerNo); if (listeners == null) { listeners = new ArrayList<LoadBalancerListener>(); } LoadBalancerHealthCheck healthCheck = healthCheckMap.get(loadBalancerNo); AutoScalingConfDto autoScalingConfDto = null; if (BooleanUtils.toBoolean(Config.getProperty("autoScaling.useAutoScaling"))) { autoScalingConfDto = new AutoScalingConfDto(); AutoScalingConf autoScalingConf = autoScalingConfMap.get(loadBalancerNo); autoScalingConfDto.setAutoScalingConf(autoScalingConf); autoScalingConfDto.setPlatform(platformDtoMap.get(autoScalingConf.getPlatformNo())); autoScalingConfDto.setImage(imageDtoMap.get(autoScalingConf.getImageNo())); } List<LoadBalancerInstance> lbInstances = lbInstancesMap.get(loadBalancerNo); if (lbInstances == null) { lbInstances = new ArrayList<LoadBalancerInstance>(); } // ?????? ComponentLoadBalancerDto componentLoadBalancerDto = null; if (componentLoadBalancer != null) { Component component = componentDao.read(componentLoadBalancer.getComponentNo()); List<Long> instanceNos = new ArrayList<Long>(); List<ComponentInstance> componentInstances = componentInstanceDao .readByComponentNo(componentLoadBalancer.getComponentNo()); for (ComponentInstance componentInstance : componentInstances) { instanceNos.add(componentInstance.getInstanceNo()); } List<Instance> instances = instanceDao.readInInstanceNos(instanceNos); // IP String ipAddress = null; if (!instances.isEmpty()) { Boolean showPublicIp = BooleanUtils.toBooleanObject(Config.getProperty("ui.showPublicIp")); if (BooleanUtils.isTrue(showPublicIp)) { //ui.showPublicIp = true ???URL?PublicIp ipAddress = instances.get(0).getPublicIp(); } else { //ui.showPublicIp = false ???URL?PrivateIp ipAddress = instances.get(0).getPrivateIp(); } } componentLoadBalancerDto = new ComponentLoadBalancerDto(); componentLoadBalancerDto.setComponentLoadBalancer(componentLoadBalancer); componentLoadBalancerDto.setComponent(component); componentLoadBalancerDto.setInstances(instances); componentLoadBalancerDto.setIpAddress(ipAddress); } // Collections.sort(listeners, Comparators.COMPARATOR_LOAD_BALANCER_LISTENER); Collections.sort(lbInstances, Comparators.COMPARATOR_LOAD_BALANCER_INSTANCE); // TODO: ???????????????? // ?? LoadBalancerStatus status = LoadBalancerStatus.fromStatus(loadBalancer.getStatus()); if (BooleanUtils.isTrue(loadBalancer.getEnabled())) { if (status == LoadBalancerStatus.STOPPED) { status = LoadBalancerStatus.STARTING; } else if (status == LoadBalancerStatus.RUNNING && BooleanUtils.isTrue(loadBalancer.getConfigure())) { status = LoadBalancerStatus.CONFIGURING; } } else { if (status == LoadBalancerStatus.RUNNING || status == LoadBalancerStatus.WARNING) { status = LoadBalancerStatus.STOPPING; } } loadBalancer.setStatus(status.toString()); // ? for (LoadBalancerListener listener : listeners) { LoadBalancerListenerStatus status2 = LoadBalancerListenerStatus.fromStatus(listener.getStatus()); if (BooleanUtils.isTrue(loadBalancer.getEnabled()) && BooleanUtils.isTrue(listener.getEnabled())) { if (status2 == LoadBalancerListenerStatus.STOPPED) { status2 = LoadBalancerListenerStatus.STARTING; } else if (status2 == LoadBalancerListenerStatus.RUNNING && BooleanUtils.isTrue(listener.getConfigure())) { status2 = LoadBalancerListenerStatus.CONFIGURING; } } else { if (status2 == LoadBalancerListenerStatus.RUNNING || status2 == LoadBalancerListenerStatus.WARNING) { status2 = LoadBalancerListenerStatus.STOPPING; } } listener.setStatus(status2.toString()); } LoadBalancerDto dto = new LoadBalancerDto(); dto.setLoadBalancer(loadBalancer); dto.setPlatform(platformDtoMap.get(loadBalancer.getPlatformNo())); dto.setAwsLoadBalancer(awsLoadBalancer); dto.setCloudstackLoadBalancer(cloudstackLoadBalancer); dto.setComponentLoadBalancerDto(componentLoadBalancerDto); dto.setLoadBalancerListeners(listeners); dto.setLoadBalancerHealthCheck(healthCheck); dto.setLoadBalancerInstances(lbInstances); dto.setAutoScalingConf(autoScalingConfDto); dtos.add(dto); } // Collections.sort(dtos, Comparators.COMPARATOR_LOAD_BALANCER_DTO); return dtos; }
From source file:jp.primecloud.auto.service.impl.InstanceServiceImpl.java
/** * {@inheritDoc}//from w ww . j a v a 2 s .c o m */ @Override public InstanceDto getInstance(Long instanceNo) { // ? Instance instance = instanceDao.read(instanceNo); // ZabbixInstance? ZabbixInstance zabbixInstance = zabbixInstanceDao.read(instanceNo); // ? Platform platform = platformDao.read(instance.getPlatformNo()); // ? Image image = imageDao.read(instance.getImageNo()); // ?????? Map<Long, List<ComponentInstance>> componentInstanceMap = new LinkedHashMap<Long, List<ComponentInstance>>(); componentInstanceMap.put(instanceNo, new ArrayList<ComponentInstance>()); List<ComponentInstance> tmpComponentInstances = componentInstanceDao.readByInstanceNo(instanceNo); for (ComponentInstance componentInstance : tmpComponentInstances) { // ????????? if (BooleanUtils.isNotTrue(componentInstance.getAssociate())) { ComponentInstanceStatus status = ComponentInstanceStatus.fromStatus(componentInstance.getStatus()); if (status == ComponentInstanceStatus.STOPPED) { continue; } } componentInstanceMap.get(componentInstance.getInstanceNo()).add(componentInstance); } // ??? Map<Long, Component> componentMap = new HashMap<Long, Component>(); Set<Long> componentNos = new HashSet<Long>(); for (ComponentInstance componentInstance : tmpComponentInstances) { componentNos.add(componentInstance.getComponentNo()); } List<Component> components = componentDao.readInComponentNos(componentNos); for (Component component : components) { componentMap.put(component.getComponentNo(), component); } // ?????? Farm farm = farmDao.read(instance.getFarmNo()); PlatformDto platformDto = new PlatformDto(); platformDto.setPlatform(platform); ImageDto imageDto = new ImageDto(); imageDto.setImage(image); AwsInstance awsInstance = null; AwsAddress awsAddress = null; List<AwsVolume> awsVolumes = null; AwsCertificate awsCertificate = null; CloudstackInstance cloudstackInstance = null; CloudstackAddress cloudstackAddress = null; List<CloudstackVolume> cloudstackVolumes = null; VmwareInstance vmwareInstance = null; VmwareAddress vmwareAddress = null; VmwareKeyPair vmwareKeyPair = null; List<VmwareDisk> vmwareDisks = null; NiftyInstance niftyInstance = null; NiftyKeyPair niftyKeyPair = null; VcloudInstance vcloudInstance = null; List<VcloudDisk> vcloudDisks = null; VcloudKeyPair vcloudKeyPair = null; List<VcloudInstanceNetwork> vcloudInstanceNetworks = null; PlatformVcloudStorageType platformVcloudStorageType = null; AzureCertificate azureCertificate = null; AzureInstance azureInstance = null; List<AzureDisk> azureDisks = null; // List<AzureNetwork> azureNetworks = null; // List<AzureStorage> azureStorages = null; OpenstackCertificate openstackCertificate = null; OpenstackInstance openstackInstance = null; // TODO CLOUD BRANCHING if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())) { PlatformAws platformAws = platformAwsDao.read(platform.getPlatformNo()); ImageAws imageAws = imageAwsDao.read(instance.getImageNo()); platformDto.setPlatformAws(platformAws); imageDto.setImageAws(imageAws); // AWS? awsInstance = awsInstanceDao.read(instanceNo); // AWS? List<AwsAddress> awsAddresses = awsAddressDao.readByInstanceNo(instanceNo); for (AwsAddress address : awsAddresses) { awsAddress = address; break; } // AWS? awsVolumes = awsVolumeDao.readByInstanceNo(instanceNo); // AWS?? awsCertificate = awsCertificateDao.read(farm.getUserNo(), instance.getPlatformNo()); } else if (PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(platform.getPlatformType())) { PlatformCloudstack platformCloudstack = platformCloudstackDao.read(platform.getPlatformNo()); ImageCloudstack imageCloudstack = imageCloudstackDao.read(instance.getImageNo()); platformDto.setPlatformCloudstack(platformCloudstack); imageDto.setImageCloudstack(imageCloudstack); // CloudStack? cloudstackInstance = cloudstackInstanceDao.read(instanceNo); // CloudStack? List<CloudstackAddress> cloudstackAddresses = cloudstackAddressDao.readByInstanceNo(instanceNo); for (CloudstackAddress address : cloudstackAddresses) { cloudstackAddress = address; break; } // CloudStack? cloudstackVolumes = cloudstackVolumeDao.readByInstanceNo(instanceNo); } else if (PCCConstant.PLATFORM_TYPE_VMWARE.equals(platform.getPlatformType())) { PlatformVmware platformVmware = platformVmwareDao.read(platform.getPlatformNo()); ImageVmware imageVmware = imageVmwareDao.read(instance.getImageNo()); platformDto.setPlatformVmware(platformVmware); imageDto.setImageVmware(imageVmware); // VMware? vmwareInstance = vmwareInstanceDao.read(instanceNo); // VMwareAddress? vmwareAddress = vmwareAddressDao.readByInstanceNo(instanceNo); // VMware? vmwareKeyPair = vmwareKeyPairDao.read(vmwareInstance.getKeyPairNo()); // VMware? vmwareDisks = vmwareDiskDao.readByInstanceNo(instanceNo); } else if (PCCConstant.PLATFORM_TYPE_NIFTY.equals(platform.getPlatformType())) { PlatformNifty platformNiftie = platformNiftyDao.read(platform.getPlatformNo()); ImageNifty imageNiftie = imageNiftyDao.read(instance.getImageNo()); platformDto.setPlatformNifty(platformNiftie); imageDto.setImageNifty(imageNiftie); // Nifty? niftyInstance = niftyInstanceDao.read(instanceNo); // Nifty? niftyKeyPair = niftyKeyPairDao.read(niftyInstance.getKeyPairNo()); } else if (PCCConstant.PLATFORM_TYPE_VCLOUD.equals(platform.getPlatformType())) { PlatformVcloud platformVcloud = platformVcloudDao.read(platform.getPlatformNo()); ImageVcloud imageVcloud = imageVcloudDao.read(instance.getImageNo()); platformDto.setPlatformVcloud(platformVcloud); imageDto.setImageVcloud(imageVcloud); // VCloudInstance? vcloudInstance = vcloudInstanceDao.read(instanceNo); // VCloudDisks? vcloudDisks = vcloudDiskDao.readByInstanceNo(instanceNo); // VCloudKeyPair? vcloudKeyPair = vcloudKeyPairDao.read(vcloudInstance.getKeyPairNo()); // VCloudInstanceNetwork? vcloudInstanceNetworks = vcloudInstanceNetworkDao.readByInstanceNo(instanceNo); Collections.sort(vcloudInstanceNetworks, Comparators.COMPARATOR_VCLOUD_INSTANCE_NETWORK); // PlatformVCloudStrogeType? platformVcloudStorageType = platformVcloudStorageTypeDao.read(vcloudInstance.getStorageTypeNo()); } else if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platform.getPlatformType())) { PlatformAzure platformAzure = platformAzureDao.read(platform.getPlatformNo()); ImageAzure imageAzure = imageAzureDao.read(instance.getImageNo()); platformDto.setPlatformAzure(platformAzure); imageDto.setImageAzure(imageAzure); // AzureInstance? azureInstance = azureInstanceDao.read(instanceNo); // AzureDisks? azureDisks = azureDiskDao.readByInstanceNo(instanceNo); // Azure?? azureCertificate = azureCertificateDao.read(farm.getUserNo(), instance.getPlatformNo()); // AzureInstance? // vcloudKeyPair = vcloudKeyPairDao.read(vcloudInstance.getKeyPairNo()); // AzureStroge? // platformVcloudStorageType = platformVcloudStorageTypeDao.read(vcloudInstance.getStorageTypeNo()); } else if (PCCConstant.PLATFORM_TYPE_OPENSTACK.equals(platform.getPlatformType())) { PlatformOpenstack platformOpenstack = platformOpenstackDao.read(platform.getPlatformNo()); ImageOpenstack imageOpenstack = imageOpenstackDao.read(instance.getImageNo()); platformDto.setPlatformOpenstack(platformOpenstack); imageDto.setImageOpenstack(imageOpenstack); // OpenstackInstance? openstackInstance = openstackInstanceDao.read(instanceNo); // Openstack?? openstackCertificate = openstackCertificateDao.read(farm.getUserNo(), instance.getPlatformNo()); } List<InstanceConfig> instanceConfigs = instanceConfigDao.readByInstanceNo(instance.getInstanceNo()); List<ComponentInstanceDto> componentInstances = new ArrayList<ComponentInstanceDto>(); for (ComponentInstance componentInstance : componentInstanceMap.get(instance.getInstanceNo())) { ComponentInstanceDto componentInstanceDto = new ComponentInstanceDto(); componentInstanceDto.setComponentInstance(componentInstance); Component component = componentMap.get(componentInstance.getComponentNo()); String url; Boolean showPublicIp = BooleanUtils.toBooleanObject(Config.getProperty("ui.showPublicIp")); if (BooleanUtils.isTrue(showPublicIp)) { //ui.showPublicIp = true ???URL?PublicIp url = createUrl(instance.getPublicIp(), component.getComponentTypeNo()); } else { //ui.showPublicIp = false ???URL?PrivateIp url = createUrl(instance.getPrivateIp(), component.getComponentTypeNo()); } componentInstanceDto.setUrl(url); componentInstances.add(componentInstanceDto); } // ????? InstanceStatus instanceStatus = InstanceStatus.fromStatus(instance.getStatus()); if (BooleanUtils.isTrue(instance.getEnabled())) { if (instanceStatus == InstanceStatus.STOPPED) { instance.setStatus(InstanceStatus.STARTING.toString()); } } else { if (instanceStatus == InstanceStatus.RUNNING || instanceStatus == InstanceStatus.WARNING) { instance.setStatus(InstanceStatus.STOPPING.toString()); } } // ??? // ? ? ?? // Running Coodinating Configuring // Running Warning Warning instanceStatus = InstanceStatus.fromStatus(instance.getStatus()); InstanceCoodinateStatus insCoodiStatus = InstanceCoodinateStatus.fromStatus(instance.getCoodinateStatus()); // ?(Running)???(Coodinating)Configuring? if (instanceStatus == InstanceStatus.RUNNING && insCoodiStatus == InstanceCoodinateStatus.COODINATING) { instance.setStatus(InstanceStatus.CONFIGURING.toString()); // ?(Running)???(Warning)Warning? } else if (instanceStatus == InstanceStatus.RUNNING && insCoodiStatus == InstanceCoodinateStatus.WARNING) { instance.setStatus(InstanceStatus.WARNING.toString()); } // ???????? instanceStatus = InstanceStatus.fromStatus(instance.getStatus()); for (ComponentInstanceDto componentInstanceDto : componentInstances) { ComponentInstance componentInstance = componentInstanceDto.getComponentInstance(); ComponentInstanceStatus status = ComponentInstanceStatus.fromStatus(componentInstance.getStatus()); if (BooleanUtils.isTrue(componentInstance.getEnabled())) { if (status == ComponentInstanceStatus.STOPPED) { if (instanceStatus == InstanceStatus.WARNING) { // ?Waring??????Warning?? componentInstance.setStatus(ComponentInstanceStatus.WARNING.toString()); } else if (BooleanUtils.isTrue(farm.getScheduled())) { componentInstance.setStatus(ComponentInstanceStatus.STARTING.toString()); } } } else { if (status == ComponentInstanceStatus.RUNNING || status == ComponentInstanceStatus.WARNING) { if (BooleanUtils.isTrue(farm.getScheduled())) { // ??????Stopping?? componentInstance.setStatus(ComponentInstanceStatus.STOPPING.toString()); } } } } // Collections.sort(componentInstances, Comparators.COMPARATOR_COMPONENT_INSTANCE_DTO); //? // TODO CLOUD BRANCHING InstanceDto dto = new InstanceDto(); dto.setInstance(instance); dto.setZabbixInstance(zabbixInstance); dto.setPlatform(platformDto); dto.setImage(imageDto); dto.setInstanceConfigs(instanceConfigs); dto.setComponentInstances(componentInstances); dto.setAwsInstance(awsInstance); dto.setAwsAddress(awsAddress); dto.setAwsVolumes(awsVolumes); dto.setAwsCertificate(awsCertificate); dto.setCloudstackInstance(cloudstackInstance); dto.setCloudstackAddress(cloudstackAddress); dto.setCloudstackVolumes(cloudstackVolumes); dto.setVmwareInstance(vmwareInstance); dto.setVmwareAddress(vmwareAddress); dto.setVmwareKeyPair(vmwareKeyPair); dto.setVmwareDisks(vmwareDisks); dto.setNiftyInstance(niftyInstance); dto.setNiftyKeyPair(niftyKeyPair); dto.setVcloudInstance(vcloudInstance); dto.setVcloudDisks(vcloudDisks); dto.setVcloudKeyPair(vcloudKeyPair); dto.setVcloudInstanceNetworks(vcloudInstanceNetworks); dto.setPlatformVcloudStorageType(platformVcloudStorageType); dto.setAzureCertificate(azureCertificate); dto.setAzureInstance(azureInstance); dto.setAzureDisks(azureDisks); dto.setOpenstackInstance(openstackInstance); dto.setOpenstackCertificate(openstackCertificate); return dto; }
From source file:fr.hoteia.qalingo.web.service.impl.WebBackofficeServiceImpl.java
private CatalogCategoryMasterAttribute buildProductCategoryMasterAttribute(final MarketArea currentMarketArea, final Localization currentLocalization, final String attributeKey, final String attributeValue, boolean isGlobal) { //TODO : denis : 20130125 : add cache AttributeDefinition attributeDefinition = attributeService.getAttributeDefinitionByCode(attributeKey); CatalogCategoryMasterAttribute productCategoryMasterAttribute = new CatalogCategoryMasterAttribute(); productCategoryMasterAttribute.setAttributeDefinition(attributeDefinition); productCategoryMasterAttribute.setLocalizationCode(currentLocalization.getCode()); productCategoryMasterAttribute.setMarketAreaId(currentMarketArea.getId()); productCategoryMasterAttribute.setStartDate(new Date()); if (AttributeDefinition.ATTRIBUTE_TYPE_STRING == attributeDefinition.getAttributeType()) { productCategoryMasterAttribute.setStringValue(attributeValue); } else if (AttributeDefinition.ATTRIBUTE_TYPE_DOUBLE == attributeDefinition.getAttributeType()) { productCategoryMasterAttribute.setDoubleValue(Double.parseDouble(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_FLOAT == attributeDefinition.getAttributeType()) { productCategoryMasterAttribute.setFloatValue(Float.parseFloat(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_INTEGER == attributeDefinition.getAttributeType()) { productCategoryMasterAttribute.setIntegerValue(Integer.parseInt(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_BLOB == attributeDefinition.getAttributeType()) { productCategoryMasterAttribute.setBlobValue(attributeValue.getBytes()); } else if (AttributeDefinition.ATTRIBUTE_TYPE_BOOLEAN == attributeDefinition.getAttributeType()) { productCategoryMasterAttribute.setBooleanValue(BooleanUtils.toBooleanObject(attributeValue)); }/* w ww.j a v a 2s . c o m*/ return productCategoryMasterAttribute; }
From source file:com.wineaccess.winepermit.WinePermitHelper.java
private static void populateNoPermitData(WinePermitPO winePermitPO, WineModel wineModel) { Boolean optionSelectedNoPermit = BooleanUtils .toBooleanObject(winePermitPO.getSellInAltStates().getIsSelectedNoPermit()); Map<Long, Long> noPermitIdsMap = new ConcurrentHashMap<Long, Long>(); List<Object[]> noPermitIdsList = WinePermitRepository.findWineNoPermitIdByWineId(wineModel.getId()); for (Object[] ids : noPermitIdsList) { noPermitIdsMap.put((Long) ids[0], (Long) ids[1]); }//from w w w.j ava 2 s .c o m List<OptionSelectedNoPermit> noPermitList = winePermitPO.getSellInAltStates().getOptionSelectedNoPermit(); if (CollectionUtils.isNotEmpty(noPermitList)) { for (OptionSelectedNoPermit noPermitModel : noPermitList) { WineLicenseNoPermit wineLicenseNoPermit = new WineLicenseNoPermit(); Long masterDataId = Long.valueOf(noPermitModel.getMasterDataId()); wineLicenseNoPermit.setWineNoPermit(MasterDataRepository.getMasterDataById(masterDataId)); wineLicenseNoPermit.setProductId(wineModel); wineLicenseNoPermit.setId(noPermitIdsMap.get(masterDataId)); if (BooleanUtils.isTrue(optionSelectedNoPermit)) { wineModel.setOptionSelectedAltstates( EnumTypes.OptionSelectedAltStatesEnum.NO_PERMIT_FOR_ALT_STATES .getOptionSelectedaltStates()); wineLicenseNoPermit.setIsSelected(BooleanUtils.toBoolean(noPermitModel.getIsSelected())); wineLicenseNoPermit.setPriceFiled(noPermitModel.getNoPermitdate()); wineLicenseNoPermit.setStatus(noPermitModel.getSc3TStatus()); } else { wineLicenseNoPermit.setIsSelected(false); wineLicenseNoPermit.setPriceFiled(null); wineLicenseNoPermit.setStatus(null); } WinePermitRepository.saveWineLicenseNoPermit(wineLicenseNoPermit); } } }
From source file:fr.hoteia.qalingo.web.service.impl.WebBackofficeServiceImpl.java
private void updateProductCategoryVirtualAttribute( final CatalogCategoryVirtualAttribute productCategoryVirtualAttribute, final String attributeValue) { AttributeDefinition attributeDefinition = productCategoryVirtualAttribute.getAttributeDefinition(); if (AttributeDefinition.ATTRIBUTE_TYPE_STRING == attributeDefinition.getAttributeType()) { productCategoryVirtualAttribute.setStringValue(attributeValue); } else if (AttributeDefinition.ATTRIBUTE_TYPE_DOUBLE == attributeDefinition.getAttributeType()) { productCategoryVirtualAttribute.setDoubleValue(Double.parseDouble(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_FLOAT == attributeDefinition.getAttributeType()) { productCategoryVirtualAttribute.setFloatValue(Float.parseFloat(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_INTEGER == attributeDefinition.getAttributeType()) { productCategoryVirtualAttribute.setIntegerValue(Integer.parseInt(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_BLOB == attributeDefinition.getAttributeType()) { productCategoryVirtualAttribute.setBlobValue(attributeValue.getBytes()); } else if (AttributeDefinition.ATTRIBUTE_TYPE_BOOLEAN == attributeDefinition.getAttributeType()) { productCategoryVirtualAttribute.setBooleanValue(BooleanUtils.toBooleanObject(attributeValue)); }//from w w w . java 2 s . com }