idx
int64 0
41.2k
| question
stringlengths 74
4.21k
| target
stringlengths 5
888
|
|---|---|---|
1,900
|
public OperationFuture < AlertPolicy > modify ( AlertPolicy policyRef , AlertPolicyConfig modifyConfig ) { AlertPolicyMetadata policyToUpdate = findByRef ( policyRef ) ; client . modifyAlertPolicy ( policyToUpdate . getId ( ) , converter . buildModifyAlertPolicyRequest ( modifyConfig , policyToUpdate ) ) ; return new OperationFuture < > ( policyRef , new NoWaitingJobFuture ( ) ) ; }
|
Update Alert policy
|
1,901
|
public OperationFuture < AlertPolicy > delete ( AlertPolicy policyRef ) { client . deleteAlertPolicy ( findByRef ( policyRef ) . getId ( ) ) ; return new OperationFuture < > ( policyRef , new NoWaitingJobFuture ( ) ) ; }
|
Remove Alert policy
|
1,902
|
public LoadBalancerFilter nameContains ( String ... names ) { allItemsNotNull ( names , "Load balancer" ) ; predicate = predicate . and ( combine ( LoadBalancerMetadata :: getName , in ( asList ( names ) , Predicates :: containsIgnoreCase ) ) ) ; return this ; }
|
Method allow to find load balancers that contains some substring in name . Filtering is case insensitive .
|
1,903
|
public LoadBalancerFilter names ( String ... names ) { allItemsNotNull ( names , "Load balancer names" ) ; predicate = predicate . and ( combine ( LoadBalancerMetadata :: getName , in ( names ) ) ) ; return this ; }
|
Method allow to find load balancers by its names Filtering is case sensitive .
|
1,904
|
public OperationFuture < LoadBalancerPool > create ( LoadBalancerPoolConfig config ) { LoadBalancer loadBalancer = config . getLoadBalancer ( ) ; LoadBalancerMetadata loadBalancerMetadata = loadBalancerService . findByRef ( loadBalancer ) ; LoadBalancerPoolMetadata metadata = loadBalancerPoolClient . create ( loadBalancerMetadata . getDataCenterId ( ) , loadBalancerMetadata . getId ( ) , new LoadBalancerPoolRequest ( ) . port ( config . getPort ( ) ) . method ( config . getMethod ( ) ) . persistence ( config . getPersistence ( ) ) ) ; LoadBalancerPool pool = LoadBalancerPool . refById ( metadata . getId ( ) , loadBalancer ) ; return new OperationFuture < > ( pool , addLoadBalancerNodes ( config , pool ) ) ; }
|
Create load balancer pool
|
1,905
|
public OperationFuture < LoadBalancerPool > update ( LoadBalancerPool loadBalancerPool , LoadBalancerPoolConfig config ) { LoadBalancerPoolMetadata loadBalancerPoolMetadata = findByRef ( loadBalancerPool ) ; loadBalancerPoolClient . update ( loadBalancerPoolMetadata . getDataCenterId ( ) , loadBalancerPoolMetadata . getLoadBalancerId ( ) , loadBalancerPoolMetadata . getId ( ) , new LoadBalancerPoolRequest ( ) . method ( config . getMethod ( ) ) . persistence ( config . getPersistence ( ) ) ) ; return new OperationFuture < > ( loadBalancerPool , addLoadBalancerNodes ( config , loadBalancerPool ) ) ; }
|
Update load balancer pool
|
1,906
|
public OperationFuture < LoadBalancer > update ( LoadBalancer loadBalancer , List < LoadBalancerPoolConfig > configs ) { List < LoadBalancerPoolMetadata > poolsForGroup = find ( new LoadBalancerPoolFilter ( ) . loadBalancers ( loadBalancer ) ) ; return new OperationFuture < > ( loadBalancer , new ParallelJobsFuture ( configs . stream ( ) . map ( poolConfig -> createOrUpdate ( poolConfig , loadBalancer , poolsForGroup ) ) . map ( OperationFuture :: jobFuture ) . collect ( toList ( ) ) ) ) ; }
|
Update load balancer pools for group
|
1,907
|
public OperationFuture < List < LoadBalancerPool > > update ( List < LoadBalancerPool > loadBalancerPoolList , LoadBalancerPoolConfig config ) { loadBalancerPoolList . forEach ( pool -> update ( pool , config ) ) ; return new OperationFuture < > ( loadBalancerPoolList , new NoWaitingJobFuture ( ) ) ; }
|
Update load balancer pool list
|
1,908
|
public OperationFuture < List < LoadBalancerPool > > update ( LoadBalancerPoolFilter loadBalancerPoolFilter , LoadBalancerPoolConfig config ) { checkNotNull ( loadBalancerPoolFilter , "Load balancer pool filter must be not null" ) ; List < LoadBalancerPool > loadBalancerPoolList = findLazy ( loadBalancerPoolFilter ) . map ( metadata -> LoadBalancerPool . refById ( metadata . getId ( ) , LoadBalancer . refById ( metadata . getLoadBalancerId ( ) , DataCenter . refById ( metadata . getDataCenterId ( ) ) ) ) ) . collect ( toList ( ) ) ; return update ( loadBalancerPoolList , config ) ; }
|
Update filtered balancer pools
|
1,909
|
public OperationFuture < LoadBalancerPool > delete ( LoadBalancerPool loadBalancerPool ) { LoadBalancerPoolMetadata loadBalancerPoolMetadata = findByRef ( loadBalancerPool ) ; loadBalancerPoolClient . delete ( loadBalancerPoolMetadata . getDataCenterId ( ) , loadBalancerPoolMetadata . getLoadBalancerId ( ) , loadBalancerPoolMetadata . getId ( ) ) ; return new OperationFuture < > ( loadBalancerPool , new NoWaitingJobFuture ( ) ) ; }
|
Delete load balancer pool
|
1,910
|
public OperationFuture < List < LoadBalancerPool > > delete ( LoadBalancerPool ... loadBalancerPool ) { return delete ( Arrays . asList ( loadBalancerPool ) ) ; }
|
Delete array of load balancer pool
|
1,911
|
public OperationFuture < List < LoadBalancerPool > > delete ( LoadBalancerPoolFilter filter ) { List < LoadBalancerPool > loadBalancerPoolList = findLazy ( filter ) . map ( metadata -> LoadBalancerPool . refById ( metadata . getId ( ) , LoadBalancer . refById ( metadata . getLoadBalancerId ( ) , DataCenter . refById ( metadata . getDataCenterId ( ) ) ) ) ) . collect ( toList ( ) ) ; return delete ( loadBalancerPoolList ) ; }
|
Delete filtered load balancer pools
|
1,912
|
public OperationFuture < List < LoadBalancerPool > > delete ( List < LoadBalancerPool > loadBalancerPoolList ) { List < JobFuture > jobs = loadBalancerPoolList . stream ( ) . map ( reference -> delete ( reference ) . jobFuture ( ) ) . collect ( toList ( ) ) ; return new OperationFuture < > ( loadBalancerPoolList , new ParallelJobsFuture ( jobs ) ) ; }
|
Delete load balancer pool list
|
1,913
|
public LoadBalancerPoolFilter loadBalancerPools ( LoadBalancerPool ... loadBalancerPools ) { predicate = predicate . and ( Filter . or ( Streams . map ( loadBalancerPools , LoadBalancerPool :: asFilter ) ) . getPredicate ( ) ) ; return this ; }
|
Method allow to filter by load balancer pool references .
|
1,914
|
public TemplateFilter nameContains ( String ... names ) { allItemsNotNull ( names , "Name substrings" ) ; predicate = predicate . and ( combine ( TemplateMetadata :: getName , in ( asList ( names ) , Predicates :: containsIgnoreCase ) ) ) ; return this ; }
|
Method allow to find templates that contains some substring in name . Filtering is case insensitive .
|
1,915
|
public TemplateFilter names ( String ... names ) { allItemsNotNull ( names , "Template names" ) ; predicate = predicate . and ( combine ( TemplateMetadata :: getName , in ( names ) ) ) ; return this ; }
|
Method allow to find templates by its names Filtering is case sensitive .
|
1,916
|
public TemplateFilter osTypes ( OsFilter ... osFilter ) { allItemsNotNull ( osFilter , "OS templates" ) ; predicate = predicate . and ( Stream . of ( osFilter ) . filter ( notNull ( ) ) . map ( OsFilter :: getPredicate ) . reduce ( alwaysFalse ( ) , Predicate :: or ) ) ; return this ; }
|
Method allow to find templates with required image OS .
|
1,917
|
public DataCenterFilter id ( String ... ids ) { allItemsNotNull ( ids , "Data center ID list" ) ; this . predicate = this . predicate . and ( combine ( DataCenterMetadata :: getId , in ( asList ( ids ) , Predicates :: equalsIgnoreCase ) ) ) ; return this ; }
|
Method allow to filter data centers by IDs . Filtering is by full match . Comparison is case insensitive .
|
1,918
|
public DataCenterFilter dataCenters ( DataCenter ... dataCenterRefs ) { allItemsNotNull ( dataCenterRefs , "Datacenter references" ) ; predicate = predicate . and ( Filter . or ( Streams . map ( dataCenterRefs , DataCenter :: asFilter ) ) . getPredicate ( ) ) ; return this ; }
|
Method allow to filter data centers by references .
|
1,919
|
public DataCenterFilter nameContains ( String ... names ) { allItemsNotNull ( names , "Name keywords" ) ; predicate = predicate . and ( combine ( DataCenterMetadata :: getName , in ( asList ( names ) , Predicates :: containsIgnoreCase ) ) ) ; return this ; }
|
Method allow to filter data centers by name . Filtering is case insensitive and occurs using substring search .
|
1,920
|
public OperationFuture < ServerMetadata > importServer ( ImportServerConfig config ) { BaseServerResponse response = client . importServer ( serverConverter . buildImportServerRequest ( config , config . getCustomFields ( ) . isEmpty ( ) ? null : client . getCustomFields ( ) ) ) ; return postProcessBuildServerResponse ( response , config ) ; }
|
Import server from ovf image
|
1,921
|
public OperationFuture < Server > modify ( Server server , ModifyServerConfig modifyServerConfig ) { List < ModifyServerRequest > request = serverConverter . buildModifyServerRequest ( modifyServerConfig , modifyServerConfig . getCustomFields ( ) . isEmpty ( ) ? null : client . getCustomFields ( ) ) ; Link response = client . modify ( idByRef ( server ) , request ) ; OperationFuture < Server > modifyServerFuture ; if ( response == null ) { modifyServerFuture = new OperationFuture < > ( server , new NoWaitingJobFuture ( ) ) ; } else { modifyServerFuture = new OperationFuture < > ( server , response . getId ( ) , queueClient ) ; } if ( modifyServerConfig . getMachineConfig ( ) != null && modifyServerConfig . getMachineConfig ( ) . getAutoscalePolicy ( ) != null ) { return new OperationFuture < > ( server , new ParallelJobsFuture ( modifyServerFuture . jobFuture ( ) , autoscalePolicyServiceSupplier . get ( ) . setAutoscalePolicyOnServer ( modifyServerConfig . getMachineConfig ( ) . getAutoscalePolicy ( ) , server ) . jobFuture ( ) ) ) ; } return modifyServerFuture ; }
|
Modify existing server
|
1,922
|
public OperationFuture < List < Server > > modify ( List < Server > serverList , ModifyServerConfig modifyServerConfig ) { List < JobFuture > futures = serverList . stream ( ) . map ( server -> modify ( server , modifyServerConfig ) . jobFuture ( ) ) . collect ( toList ( ) ) ; return new OperationFuture < > ( serverList , new ParallelJobsFuture ( futures ) ) ; }
|
Modify list of servers
|
1,923
|
public OperationFuture < List < Server > > modify ( ServerFilter serverFilter , ModifyServerConfig modifyServerConfig ) { List < Server > serverList = find ( serverFilter ) . stream ( ) . map ( ServerMetadata :: asRefById ) . collect ( toList ( ) ) ; return modify ( serverList , modifyServerConfig ) ; }
|
Modify servers by filter
|
1,924
|
public OperationFuture < Server > delete ( Server server ) { BaseServerResponse response = client . delete ( idByRef ( server ) ) ; return new OperationFuture < > ( server , response . findStatusId ( ) , queueClient ) ; }
|
Delete existing server
|
1,925
|
public OperationFuture < Link > restore ( Server server , Group group ) { return baseServerResponse ( restore ( server , groupService . findByRef ( group ) . getId ( ) ) ) ; }
|
Restore a given archived server to a specified group
|
1,926
|
OperationFuture < List < Server > > restore ( String groupId , Server ... servers ) { return restore ( Arrays . asList ( servers ) , groupId ) ; }
|
Restore a group of archived servers to a specified group
|
1,927
|
OperationFuture < List < Server > > restore ( List < Server > serverList , String groupId ) { List < JobFuture > futures = serverList . stream ( ) . map ( server -> baseServerResponse ( client . restore ( idByRef ( server ) , new RestoreServerRequest ( ) . targetGroupId ( groupId ) ) ) . jobFuture ( ) ) . collect ( toList ( ) ) ; return new OperationFuture < > ( serverList , new ParallelJobsFuture ( futures ) ) ; }
|
Restore a list of archived servers to a specified group
|
1,928
|
public OperationFuture < List < Server > > revertToSnapshot ( Server ... servers ) { List < Server > serverList = Arrays . asList ( servers ) ; List < JobFuture > futures = serverList . stream ( ) . map ( this :: findByRef ) . flatMap ( metadata -> metadata . getDetails ( ) . getSnapshots ( ) . stream ( ) ) . map ( snapshot -> baseServerResponse ( client . revertToSnapshot ( snapshot . getServerId ( ) , snapshot . getId ( ) ) ) . jobFuture ( ) ) . collect ( toList ( ) ) ; return new OperationFuture < > ( serverList , new ParallelJobsFuture ( futures ) ) ; }
|
Revert a set of servers to snapshot
|
1,929
|
public OperationFuture < Server > addPublicIp ( Server serverRef , CreatePublicIpConfig publicIpConfig ) { checkNotNull ( serverRef , "Server reference must be not null" ) ; checkNotNull ( publicIpConfig , CHECK_PUBLIC_IP_CONFIG ) ; Link response = client . addPublicIp ( idByRef ( serverRef ) , publicIpConverter . createPublicIpRequest ( publicIpConfig ) ) ; return new OperationFuture < > ( serverRef , response . getId ( ) , queueClient ) ; }
|
Add public IP to server
|
1,930
|
public OperationFuture < Server > modifyPublicIp ( Server server , ModifyPublicIpConfig config ) { checkNotNull ( config , CHECK_PUBLIC_IP_CONFIG ) ; List < IpAddress > ipAddresses = findByRef ( server ) . getDetails ( ) . getIpAddresses ( ) ; List < String > responseIds = ipAddresses . stream ( ) . map ( IpAddress :: getPublicIp ) . filter ( notNull ( ) ) . map ( ipAddress -> client . modifyPublicIp ( idByRef ( server ) , ipAddress , publicIpConverter . createPublicIpRequest ( config ) ) ) . map ( Link :: getId ) . collect ( toList ( ) ) ; return new OperationFuture < > ( server , responseIds , queueClient ) ; }
|
Modify ALL existing public IPs on server
|
1,931
|
public OperationFuture < Server > modifyPublicIp ( Server server , String publicIp , ModifyPublicIpConfig config ) { checkNotNull ( config , "PublicIpConfig must be not null" ) ; checkNotNull ( publicIp , "public ip must not be null" ) ; Link response = client . modifyPublicIp ( idByRef ( server ) , publicIp , publicIpConverter . createPublicIpRequest ( config ) ) ; return new OperationFuture < > ( server , response . getId ( ) , queueClient ) ; }
|
Modify provided public IP on server
|
1,932
|
public OperationFuture < List < Server > > modifyPublicIp ( List < Server > servers , ModifyPublicIpConfig config ) { List < JobFuture > futures = servers . stream ( ) . map ( serverRef -> modifyPublicIp ( serverRef , config ) . jobFuture ( ) ) . collect ( toList ( ) ) ; return new OperationFuture < > ( servers , new ParallelJobsFuture ( futures ) ) ; }
|
Modify ALL existing public IPs on servers
|
1,933
|
public OperationFuture < List < Server > > modifyPublicIp ( ServerFilter filter , ModifyPublicIpConfig config ) { return modifyPublicIp ( Arrays . asList ( getRefsFromFilter ( filter ) ) , config ) ; }
|
Modify existing public IP on servers
|
1,934
|
public PublicIpMetadata getPublicIp ( Server serverRef , String publicIp ) { return this . getPublicIp ( idByRef ( serverRef ) , publicIp ) ; }
|
Get public IP object
|
1,935
|
public OperationFuture < Server > removePublicIp ( Server serverRef , String ipAddress ) { checkNotNull ( ipAddress , "ipAddress must be not null" ) ; Link response = client . removePublicIp ( idByRef ( serverRef ) , ipAddress ) ; return new OperationFuture < > ( serverRef , response . getId ( ) , queueClient ) ; }
|
Remove public IP from server
|
1,936
|
public OperationFuture < Server > removePublicIp ( Server serverRef ) { checkNotNull ( serverRef , "Server reference must be not null" ) ; ServerMetadata serverMetadata = findByRef ( serverRef ) ; List < JobFuture > jobFutures = serverMetadata . getDetails ( ) . getIpAddresses ( ) . stream ( ) . map ( IpAddress :: getPublicIp ) . filter ( notNull ( ) ) . map ( address -> removePublicIp ( serverRef , address ) . jobFuture ( ) ) . collect ( toList ( ) ) ; return new OperationFuture < > ( serverRef , new ParallelJobsFuture ( jobFutures ) ) ; }
|
Remove all public IPs from server
|
1,937
|
public OperationFuture < List < Server > > removePublicIp ( Server ... servers ) { checkNotNull ( servers , "Server references must be not null" ) ; List < Server > serverList = Arrays . asList ( servers ) ; List < JobFuture > futures = serverList . stream ( ) . map ( serverRef -> removePublicIp ( serverRef ) . jobFuture ( ) ) . collect ( toList ( ) ) ; return new OperationFuture < > ( serverList , new ParallelJobsFuture ( futures ) ) ; }
|
Remove all public IPs from servers array
|
1,938
|
public OperationFuture < Network > release ( Network network , DataCenter dataCenter ) { DataCenterMetadata dataCenterMetadata = dataCenterService . findByRef ( dataCenter ) ; NetworkMetadata networkMetadata = findByRef ( network ) ; networkClient . release ( networkMetadata . getId ( ) , dataCenterMetadata . getId ( ) ) ; return new OperationFuture < > ( network , new NoWaitingJobFuture ( ) ) ; }
|
Release the network for datacenter
|
1,939
|
public OperationFuture < DataCenter > claim ( DataCenter dataCenter ) { NetworkLink response = networkClient . claim ( dataCenterService . findByRef ( dataCenter ) . getId ( ) ) ; return new OperationFuture < > ( dataCenter , response . getOperationId ( ) , queueClient ) ; }
|
Claim a network for datacenter
|
1,940
|
public OperationFuture < AntiAffinityPolicy > create ( AntiAffinityPolicyConfig createConfig ) { AntiAffinityPolicyMetadata policy = client . createAntiAffinityPolicy ( new AntiAffinityPolicyRequest ( ) . name ( createConfig . getName ( ) ) . location ( dataCenterService . findByRef ( createConfig . getDataCenter ( ) ) . getId ( ) ) ) ; return new OperationFuture < > ( AntiAffinityPolicy . refById ( policy . getId ( ) ) , new NoWaitingJobFuture ( ) ) ; }
|
Create Anti - affinity policy
|
1,941
|
public OperationFuture < AntiAffinityPolicy > modify ( AntiAffinityPolicy policyRef , AntiAffinityPolicyConfig modifyConfig ) { client . modifyAntiAffinityPolicy ( findByRef ( policyRef ) . getId ( ) , new AntiAffinityPolicyRequest ( ) . name ( modifyConfig . getName ( ) ) ) ; return new OperationFuture < > ( policyRef , new NoWaitingJobFuture ( ) ) ; }
|
Update Anti - affinity policy
|
1,942
|
public OperationFuture < AntiAffinityPolicy > delete ( AntiAffinityPolicy policyRef ) { client . deleteAntiAffinityPolicy ( findByRef ( policyRef ) . getId ( ) ) ; return new OperationFuture < > ( policyRef , new NoWaitingJobFuture ( ) ) ; }
|
Remove Anti - affinity policy
|
1,943
|
public OperationFuture < List < AntiAffinityPolicy > > delete ( AntiAffinityPolicyFilter filter ) { List < AntiAffinityPolicy > policyRefs = getRefsFromFilter ( filter ) ; return delete ( policyRefs . toArray ( new AntiAffinityPolicy [ policyRefs . size ( ) ] ) ) ; }
|
Remove Anti - affinity policies
|
1,944
|
private GroupMetadata findGroup ( GroupHierarchyConfig config , String parentGroupId ) { GroupMetadata parentGroup = findByRef ( Group . refById ( parentGroupId ) ) ; return parentGroup . getGroups ( ) . stream ( ) . filter ( group -> group . getName ( ) . equals ( config . getName ( ) ) ) . findFirst ( ) . orElse ( null ) ; }
|
Find group based on config instance and parent group identifier
|
1,945
|
public OperationFuture < Group > delete ( Group group ) { Link response = client . deleteGroup ( idByRef ( group ) ) ; return new OperationFuture < > ( group , response . getId ( ) , queueClient ) ; }
|
Delete provided group
|
1,946
|
public OperationFuture < List < Group > > delete ( Group ... groups ) { List < Group > groupList = Arrays . asList ( groups ) ; List < JobFuture > jobs = groupList . stream ( ) . map ( group -> delete ( group ) . jobFuture ( ) ) . collect ( toList ( ) ) ; return new OperationFuture < > ( groupList , new ParallelJobsFuture ( jobs ) ) ; }
|
Delete set of groups
|
1,947
|
public BillingStats getBillingStats ( Group group ) { return converter . convertBillingStats ( client . getGroupBillingStats ( idByRef ( group ) ) ) ; }
|
Get billing stats by single group
|
1,948
|
public List < BillingStats > getBillingStats ( Group ... groups ) { List < BillingStats > result = new ArrayList < > ( ) ; List < Group > groupList = Arrays . asList ( groups ) ; groupList . forEach ( group -> result . add ( converter . convertBillingStats ( client . getGroupBillingStats ( idByRef ( group ) ) ) ) ) ; return result ; }
|
Get billing stats by Groups
|
1,949
|
public List < BillingStats > getBillingStats ( GroupFilter groupFilter ) { return findLazy ( groupFilter ) . map ( groupMetadata -> converter . convertBillingStats ( client . getGroupBillingStats ( groupMetadata . getId ( ) ) ) ) . collect ( toList ( ) ) ; }
|
Get billing stats by GroupFilter
|
1,950
|
public OperationFuture < Server > setAutoscalePolicyOnServer ( AutoscalePolicy autoscalePolicy , Server server ) { autoscalePolicyClient . setAutoscalePolicyOnServer ( serverService . findByRef ( server ) . getId ( ) , new SetAutoscalePolicyRequest ( ) . id ( findByRef ( autoscalePolicy ) . getId ( ) ) ) ; return new OperationFuture < > ( server , new NoWaitingJobFuture ( ) ) ; }
|
Set autoscale policy on server
|
1,951
|
public OperationFuture < List < Server > > setAutoscalePolicyOnServer ( AutoscalePolicy autoscalePolicy , ServerFilter serverFilter ) { return setAutoscalePolicyOnServer ( autoscalePolicy , serverService . findLazy ( serverFilter ) . map ( serverMetadata -> Server . refById ( serverMetadata . getId ( ) ) ) . collect ( toList ( ) ) ) ; }
|
set autoscale policy on filtered servers
|
1,952
|
public AutoscalePolicyMetadata getAutoscalePolicyOnServer ( Server server ) { return autoscalePolicyClient . getAutoscalePolicyOnServer ( serverService . findByRef ( server ) . getId ( ) ) ; }
|
get autoscale policy on server
|
1,953
|
public OperationFuture < Server > removeAutoscalePolicyOnServer ( Server server ) { autoscalePolicyClient . removeAutoscalePolicyOnServer ( serverService . findByRef ( server ) . getId ( ) ) ; return new OperationFuture < > ( server , new NoWaitingJobFuture ( ) ) ; }
|
remove autoscale policy on server
|
1,954
|
public OperationFuture < List < Server > > removeAutoscalePolicyOnServer ( ServerFilter serverFilter ) { return removeAutoscalePolicyOnServer ( serverService . findLazy ( serverFilter ) . map ( serverMetadata -> Server . refById ( serverMetadata . getId ( ) ) ) . collect ( toList ( ) ) ) ; }
|
remove autoscale policy on filtered servers
|
1,955
|
public SdkClientBuilder connectionCheckoutTimeout ( long timeout , TimeUnit unit ) { this . connectionCheckoutTimeoutMs = ( int ) TimeUnit . MILLISECONDS . convert ( timeout , unit ) ; return this ; }
|
If connection pooling is enabled how long will we wait to get a connection?
|
1,956
|
public SdkClientBuilder defaultProxy ( String hostname , int port , final String scheme ) { this . defaultProxy = new HttpHost ( hostname , port , scheme ) ; return this ; }
|
Specify default proxy .
|
1,957
|
public SdkClientBuilder proxyCredentials ( String user , String password ) { this . proxyCredentials = new UsernamePasswordCredentials ( user , password ) ; return this ; }
|
Specify proxy credentials .
|
1,958
|
public OperationFuture < LoadBalancerPool > update ( LoadBalancerPool loadBalancerPool , List < LoadBalancerNodeMetadata > nodesList ) { LoadBalancerPoolMetadata loadBalancerPoolMetadata = loadBalancerPoolService . findByRef ( loadBalancerPool ) ; loadBalancerNodeClient . update ( loadBalancerPoolMetadata . getDataCenterId ( ) , loadBalancerPoolMetadata . getLoadBalancerId ( ) , loadBalancerPoolMetadata . getId ( ) , nodesList ) ; return new OperationFuture < > ( loadBalancerPool , new NoWaitingJobFuture ( ) ) ; }
|
Update load balancer node list of the load balancer pool
|
1,959
|
public GroupHierarchyConfig subitems ( InfrastructureItem ... subitems ) { checkNotNull ( subitems , "List of server configs must be not a null" ) ; this . subitems . addAll ( asList ( subitems ) ) ; return this ; }
|
Set sub items
|
1,960
|
public List < CreateServerConfig > getServerConfigs ( ) { List < CreateServerConfig > serverConfigs = new ArrayList < > ( ) ; collectConfigs ( this , serverConfigs ) ; return serverConfigs ; }
|
Returns all configs for creating servers
|
1,961
|
private void collectConfigs ( GroupHierarchyConfig hierarchyConfig , List < CreateServerConfig > serverConfigs ) { hierarchyConfig . getSubitems ( ) . stream ( ) . forEach ( config -> { if ( config instanceof ServerConfig ) { serverConfigs . addAll ( Arrays . asList ( ( ( ServerConfig ) config ) . getServerConfig ( ) ) ) ; } else { collectConfigs ( ( GroupHierarchyConfig ) config , serverConfigs ) ; } } ) ; }
|
Collect server configs in current group
|
1,962
|
private void initializeButtonMenu ( ) { button_menu = ( ButtonMenu ) findViewById ( R . id . button_menu ) ; button_menu . setButtonMenuVM ( buttonMenuVM ) ; button_menu . initialize ( ) ; }
|
Set the ButtonMenuVM implementation to the ButtonMenu custom view and initialize it .
|
1,963
|
private void initializeScrollAnimator ( ) { ScrollAnimator scrollAnimator = new ScrollAnimator ( button_menu , new ObjectAnimatorFactory ( ) ) ; scrollAnimator . configureListView ( lv_contacts ) ; scrollAnimator . setDurationInMillis ( 300 ) ; }
|
Initialize ScrollAnimator to work with ButtonMenu custom view the ListView used in this sample and an animation duration of 200 milliseconds .
|
1,964
|
public void configureListView ( ListView listView ) { this . listView = listView ; this . listView . setOnScrollListener ( new OnScrollListener ( ) { int scrollPosition ; public void onScroll ( AbsListView view , int firstVisibleItem , int visibleItemCount , int totalItemCount ) { notifyScrollToAdditionalScrollListener ( view , firstVisibleItem , visibleItemCount , totalItemCount ) ; View topChild = view . getChildAt ( 0 ) ; int newScrollPosition ; if ( topChild == null ) { newScrollPosition = 0 ; } else { newScrollPosition = view . getFirstVisiblePosition ( ) * topChild . getHeight ( ) - topChild . getTop ( ) ; } if ( Math . abs ( newScrollPosition - scrollPosition ) >= SCROLL_DIRECTION_CHANGE_THRESHOLD ) { onScrollPositionChanged ( scrollPosition , newScrollPosition ) ; } scrollPosition = newScrollPosition ; } public void onScrollStateChanged ( AbsListView view , int scrollState ) { notifyScrollStateChangedToAdditionalScrollListener ( view , scrollState ) ; } } ) ; }
|
Associate a ListView to listen in order to perform the translationY animation when the ListView scroll is updated . This method is going to set a OnScrollListener to the ListView passed as argument .
|
1,965
|
public void showWithAnimationWithListener ( Animator . AnimatorListener animatorListener ) { scrollDirection = SCROLL_TO_TOP ; ObjectAnimator objectAnimator = objectAnimatorFactory . getObjectAnimator ( animatedView , ANIMATION_TYPE , HIDDEN_Y_POSITION ) ; if ( animatorListener != null ) { objectAnimator . addListener ( animatorListener ) ; } objectAnimator . setDuration ( durationInMillis ) ; objectAnimator . start ( ) ; }
|
Show the animated view using a translationY animation and configure an AnimatorListener to be notified during the animation .
|
1,966
|
public void hideWithAnimationWithListener ( Animator . AnimatorListener animatorListener ) { scrollDirection = SCROLL_TO_BOTTOM ; ObjectAnimator objectAnimator = objectAnimatorFactory . getObjectAnimator ( animatedView , ANIMATION_TYPE , animatedView . getHeight ( ) ) ; if ( animatorListener != null ) { objectAnimator . addListener ( animatorListener ) ; } objectAnimator . setDuration ( durationInMillis ) ; objectAnimator . start ( ) ; }
|
Hide the animated view using a translationY animation and configure an AnimatorListener to be notified during the animation .
|
1,967
|
protected void animate ( int translationY ) { ObjectAnimator animator = objectAnimatorFactory . getObjectAnimator ( animatedView , ANIMATION_TYPE , translationY ) ; animator . setDuration ( durationInMillis ) ; animator . start ( ) ; }
|
Animate animated view from the current position to a translationY position .
|
1,968
|
private void onScrollPositionChanged ( int oldScrollPosition , int newScrollPosition ) { int newScrollDirection ; if ( newScrollPosition < oldScrollPosition ) { newScrollDirection = SCROLL_TO_TOP ; } else { newScrollDirection = SCROLL_TO_BOTTOM ; } if ( directionHasChanged ( newScrollDirection ) ) { translateYAnimatedView ( newScrollDirection ) ; } }
|
Perform the translateY animation using the new scroll position and the old scroll position to show or hide the animated view .
|
1,969
|
public static String readMockResponse ( Context context , String filePath ) { String responseString ; try { responseString = IOUtils . readFileFromAssets ( context , filePath ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } if ( TextUtils . isEmpty ( responseString ) ) { throw new RuntimeException ( "Mock file \"" + filePath + "\" is empty" ) ; } return responseString ; }
|
Reads mock response string from given path .
|
1,970
|
@ SuppressWarnings ( "unchecked" ) public static < T > T createMockObject ( Type type ) { Class < T > rawType ; if ( type instanceof ParameterizedType ) { rawType = ( Class < T > ) ( ( ParameterizedType ) type ) . getRawType ( ) ; } else if ( type instanceof Class ) { rawType = ( Class < T > ) type ; } else { throw new UnsupportedOperationException ( "Unsupported type: " + type . getClass ( ) . getSimpleName ( ) ) ; } T instance = instantiateObject ( rawType ) ; return populateObject ( instance ) ; }
|
Creates a mock object and populates its fields .
|
1,971
|
@ SuppressWarnings ( "unchecked" ) public static < T > T instantiateObject ( Class < T > rawType ) { try { Constructor < ? > constructor = rawType . getDeclaredConstructor ( ) ; if ( ! constructor . isAccessible ( ) ) { constructor . setAccessible ( true ) ; } return ( T ) constructor . newInstance ( ( Object [ ] ) null ) ; } catch ( Exception e ) { Logger . w ( "Default constructor failed for " + rawType . getCanonicalName ( ) + "\nWith exception : " + e . getMessage ( ) + "\nAttempting unsafe allocation of object." ) ; } try { UnsafeAllocator unsafeAllocator = UnsafeAllocator . create ( ) ; return unsafeAllocator . newInstance ( rawType ) ; } catch ( Exception e ) { throw new RuntimeException ( "Failed to instantiate " + rawType . getCanonicalName ( ) , e ) ; } }
|
Creates a new instance of given raw type .
|
1,972
|
private static < T > T populateObject ( T object ) { Class clazz = object . getClass ( ) ; while ( clazz != null ) { String name = clazz . getName ( ) ; if ( name . startsWith ( "java." ) || name . startsWith ( "javax." ) || name . startsWith ( "android." ) ) { break ; } Field [ ] fields = clazz . getDeclaredFields ( ) ; for ( Field field : fields ) { if ( ! Modifier . isFinal ( field . getModifiers ( ) ) ) { Object value = generateValue ( field ) ; field . setAccessible ( true ) ; try { field . set ( object , value ) ; } catch ( Exception e ) { throw new RuntimeException ( "Failed to populate object of type " + object . getClass ( ) . getCanonicalName ( ) , e ) ; } } } clazz = clazz . getSuperclass ( ) ; } return object ; }
|
All non - final fields in object are populated with mock values .
|
1,973
|
private static Object generateValue ( Field field ) { Class < ? > rawType = field . getType ( ) ; if ( List . class . isAssignableFrom ( rawType ) ) { ParameterizedType genericType = ( ParameterizedType ) field . getGenericType ( ) ; return createListObject ( genericType ) ; } return generateValue ( rawType ) ; }
|
Generates a mock value assignable to provided field . Parametrized types are only supported for List fields . If not a list raw type is used .
|
1,974
|
private static Object generateValue ( Class < ? > rawType ) { if ( String . class . isAssignableFrom ( rawType ) ) { return "test" ; } else if ( int . class . isAssignableFrom ( rawType ) || Integer . class . isAssignableFrom ( rawType ) ) { return 10 ; } else if ( float . class . isAssignableFrom ( rawType ) || Float . class . isAssignableFrom ( rawType ) ) { return 10F ; } else if ( double . class . isAssignableFrom ( rawType ) || Double . class . isAssignableFrom ( rawType ) ) { return 10D ; } else if ( long . class . isAssignableFrom ( rawType ) || Long . class . isAssignableFrom ( rawType ) ) { return 10L ; } else if ( boolean . class . isAssignableFrom ( rawType ) || Boolean . class . isAssignableFrom ( rawType ) ) { return true ; } else if ( BigDecimal . class . isAssignableFrom ( rawType ) ) { return new BigDecimal ( 10 ) ; } else if ( ! rawType . isArray ( ) ) { return createMockObject ( rawType ) ; } Logger . w ( "Unsupported field type : " + rawType . getCanonicalName ( ) ) ; return null ; }
|
Generates a mock value assignable to provided raw type .
|
1,975
|
public void increaseValue ( String goldValue , String observedValue , int times ) { allGoldLabels . add ( goldValue ) ; allPredictedLabels . add ( observedValue ) ; for ( int i = 0 ; i < times ; i ++ ) { labelSeries . add ( observedValue ) ; } if ( ! map . containsKey ( goldValue ) ) { map . put ( goldValue , new TreeMap < String , Integer > ( ) ) ; } if ( ! map . get ( goldValue ) . containsKey ( observedValue ) ) { map . get ( goldValue ) . put ( observedValue , 0 ) ; } int currentValue = this . map . get ( goldValue ) . get ( observedValue ) ; this . map . get ( goldValue ) . put ( observedValue , currentValue + times ) ; total += times ; if ( goldValue . equals ( observedValue ) ) { correct += times ; } }
|
Increases value of goldValue x observedValue n times
|
1,976
|
public double getMacroFMeasure ( ) { Map < String , Double > fMeasureForLabels = getFMeasureForLabels ( ) ; double totalFMeasure = 0 ; for ( Double d : fMeasureForLabels . values ( ) ) { totalFMeasure += d ; } return totalFMeasure / fMeasureForLabels . size ( ) ; }
|
Macro - averaged F - measure gives equal weight to each category regardless of its frequency . It is influenced more by the classifier performance on rare categories .
|
1,977
|
public Map < String , Double > getRecallForLabels ( ) { Map < String , Double > recalls = new LinkedHashMap < > ( ) ; for ( String label : allGoldLabels ) { double recall = getRecallForLabel ( label ) ; recalls . put ( label , recall ) ; } return recalls ; }
|
Return recall for labels
|
1,978
|
public double getRecallForLabel ( String label ) { int fnAndTp = 0 ; double recall = 0 ; int tp = 0 ; if ( map . containsKey ( label ) && map . get ( label ) . containsKey ( label ) ) { tp = this . map . get ( label ) . get ( label ) ; fnAndTp = getRowSum ( label ) ; } if ( fnAndTp > 0 ) { recall = ( double ) tp / ( double ) ( fnAndTp ) ; } return recall ; }
|
Return recall for single label
|
1,979
|
public double getCohensKappa ( ) { double p = getAccuracy ( ) ; double pe = 0 ; for ( String label : this . allGoldLabels ) { double row = getRowSum ( label ) ; double col = getColSum ( label ) ; pe += ( row * col ) / getTotalSum ( ) ; } pe = pe / getTotalSum ( ) ; return ( p - pe ) / ( 1 - pe ) ; }
|
Computes Cohen s Kappa
|
1,980
|
public String toStringLatex ( ) { List < List < String > > table = prepareToString ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < table . size ( ) ; i ++ ) { List < String > row = table . get ( i ) ; for ( int j = 0 ; j < row . size ( ) ; j ++ ) { String value = row . get ( j ) ; if ( ( i == 0 || j == 0 ) && ! value . isEmpty ( ) ) { sb . append ( "\\textbf{" ) . append ( value ) . append ( "} " ) ; } else { sb . append ( value ) ; sb . append ( " " ) ; } if ( j < row . size ( ) - 1 ) { sb . append ( "& " ) ; } } sb . append ( "\\\\\n" ) ; } return sb . toString ( ) ; }
|
Prints in LaTeX format
|
1,981
|
public static ConfusionMatrix createCumulativeMatrix ( ConfusionMatrix ... matrices ) { ConfusionMatrix result = new ConfusionMatrix ( ) ; for ( ConfusionMatrix matrix : matrices ) { for ( Map . Entry < String , Map < String , Integer > > gold : matrix . map . entrySet ( ) ) { for ( Map . Entry < String , Integer > actual : gold . getValue ( ) . entrySet ( ) ) { result . increaseValue ( gold . getKey ( ) , actual . getKey ( ) , actual . getValue ( ) ) ; } } } return result ; }
|
Sums up all matrices into a new one
|
1,982
|
public static ConfusionMatrix parseFromText ( String text ) throws IllegalArgumentException { try { String [ ] lines = text . split ( "\n" ) ; String [ ] l = lines [ 0 ] . split ( "\\s+" ) ; List < String > labels = new ArrayList < > ( ) ; for ( String aL : l ) { if ( ! aL . isEmpty ( ) ) { labels . add ( aL ) ; } } ConfusionMatrix result = new ConfusionMatrix ( ) ; for ( int i = 1 ; i < lines . length ; i ++ ) { String line = lines [ i ] ; String [ ] split = line . split ( "\\s+" ) ; List < String > row = new ArrayList < > ( ) ; for ( String aSplit : split ) { if ( ! aSplit . isEmpty ( ) ) { row . add ( aSplit ) ; } } String predictedLabel = row . get ( 0 ) ; for ( int r = 1 ; r < row . size ( ) ; r ++ ) { String s = row . get ( r ) ; Integer val = Integer . valueOf ( s ) ; String acutalLabel = labels . get ( r - 1 ) ; result . increaseValue ( predictedLabel , acutalLabel , val ) ; } } return result ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Wrong input format" , e ) ; } }
|
Confusion matrix printed to text by toString can be parsed back
|
1,983
|
private void initImageView ( ImageCreator waspImageCreator ) { int defaultImage = waspImageCreator . getDefaultImage ( ) ; ImageView imageView = waspImageCreator . getImageView ( ) ; if ( defaultImage != 0 ) { imageView . setImageResource ( defaultImage ) ; return ; } imageView . setImageBitmap ( null ) ; }
|
clear the target by setting null or default placeholder
|
1,984
|
public static Connection createTempConnection ( StorageService storageService , final DataSource dataSource ) throws RepositoryException { if ( DataSource . JNDI_VENDOR . equals ( dataSource . getVendor ( ) ) ) { return getJNDIConnection ( storageService , dataSource ) ; } final String driver = dataSource . getDriver ( ) ; try { Class . forName ( driver ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; LOG . error ( e . getMessage ( ) , e ) ; throw new RepositoryException ( "Driver '" + driver + "' not found." , e ) ; } final String url = dataSource . getUrl ( ) ; final String username = dataSource . getUsername ( ) ; final String password = dataSource . getPassword ( ) ; Settings settings = storageService . getSettings ( ) ; int connectionTimeout = settings . getConnectionTimeout ( ) ; if ( connectionTimeout <= 0 ) { try { if ( driver . equals ( CSVDialect . DRIVER_CLASS ) ) { return DriverManager . getConnection ( url , convertListToProperties ( dataSource . getProperties ( ) ) ) ; } else { return DriverManager . getConnection ( url , username , password ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; LOG . error ( e . getMessage ( ) , e ) ; Locale locale = LanguageManager . getInstance ( ) . getLocale ( storageService . getSettings ( ) . getLanguage ( ) ) ; ResourceBundle bundle = ResourceBundle . getBundle ( "ro.nextreports.server.web.NextServerApplication" , locale ) ; throw new RepositoryException ( bundle . getString ( "Connection.failed" ) + " '" + dataSource . getPath ( ) + "'" , e ) ; } } else { Connection connection ; FutureTask < Connection > createConnectionTask = null ; try { createConnectionTask = new FutureTask < Connection > ( new Callable < Connection > ( ) { public Connection call ( ) throws Exception { if ( driver . equals ( CSVDialect . DRIVER_CLASS ) ) { return DriverManager . getConnection ( url , convertListToProperties ( dataSource . getProperties ( ) ) ) ; } else { return DriverManager . getConnection ( url , username , password ) ; } } } ) ; new Thread ( createConnectionTask ) . start ( ) ; connection = createConnectionTask . get ( connectionTimeout , TimeUnit . SECONDS ) ; } catch ( Exception e ) { Locale locale = LanguageManager . getInstance ( ) . getLocale ( storageService . getSettings ( ) . getLanguage ( ) ) ; ResourceBundle bundle = ResourceBundle . getBundle ( "ro.nextreports.server.web.NextServerApplication" , locale ) ; throw new RepositoryException ( bundle . getString ( "Connection.failed" ) + " '" + dataSource . getPath ( ) + "'" , e ) ; } return connection ; } }
|
this is useful if we want to test the connection
|
1,985
|
public static void copyDirToDir ( File source , File dest , FilenameFilter filter ) throws IOException { if ( ! source . isDirectory ( ) || ! dest . isDirectory ( ) ) { return ; } List < File > files = listFiles ( source , filter , true ) ; String sourcePath = source . getAbsolutePath ( ) ; String destPath = dest . getAbsolutePath ( ) ; for ( File file : files ) { String filePath = file . getAbsolutePath ( ) ; if ( sourcePath . equals ( filePath ) ) { continue ; } String newPath = destPath + File . separator + filePath . substring ( sourcePath . length ( ) ) ; File destFile = new File ( newPath ) ; if ( file . isDirectory ( ) ) { destFile . mkdirs ( ) ; } else { copy ( file , destFile ) ; } } }
|
dest directory must be already created!
|
1,986
|
public static boolean deleteDir ( File dir ) { if ( dir . isDirectory ( ) ) { String [ ] children = dir . list ( ) ; for ( String file : children ) { boolean success = deleteDir ( new File ( dir , file ) ) ; if ( ! success ) { return false ; } } } return dir . delete ( ) ; }
|
If a deletion fails the method stops attempting to delete and returns false .
|
1,987
|
public static Entity getEntity ( EntityWidget widget , StorageService storageService ) { Entity entity = widget . getEntity ( ) ; if ( entity == null ) { String entityId = widget . getInternalSettings ( ) . get ( EntityWidget . ENTITY_ID ) ; try { entity = storageService . getEntityById ( entityId ) ; } catch ( NotFoundException e ) { e . printStackTrace ( ) ; } widget . setEntity ( entity ) ; } return entity ; }
|
if it is not set we load it and we set it on widget
|
1,988
|
private void selectEntity ( Entity entity , Item < Entity > item , String sectionId ) { SectionContext sectionContext = NextServerSession . get ( ) . getSectionContext ( sectionId ) ; if ( sectionContext == null ) { return ; } String entityPath = SectionContextUtil . getSelectedEntityPath ( sectionId ) ; if ( ( entityPath != null ) && entity . getPath ( ) . equals ( entityPath ) ) { item . add ( AttributeModifier . replace ( "class" , "tr-selected" ) ) ; SectionContextUtil . setSelectedEntityPath ( sectionId , null ) ; } }
|
select entity from GoTo actions
|
1,989
|
public static void removeGroupColumns ( List < String > selectColumns , List < String > groups ) { List < String > removedGroups = new ArrayList < String > ( ) ; for ( String group : groups ) { if ( ! containsColumnByAlias ( selectColumns , group ) ) { removedGroups . add ( group ) ; } } groups . removeAll ( removedGroups ) ; }
|
Group by columns must be removed if the columns from select sql are deleted
|
1,990
|
public static < T > OrderBy < T > convertToEbeanOrderBy ( Sort sort ) { if ( sort == null ) { return null ; } List < String > list = new ArrayList < > ( ) ; Iterator < Sort . Order > orderIterator = sort . iterator ( ) ; while ( orderIterator . hasNext ( ) ) { Sort . Order so = orderIterator . next ( ) ; list . add ( so . getProperty ( ) + " " + so . getDirection ( ) ) ; } return new OrderBy < T > ( StringUtils . collectionToCommaDelimitedString ( list ) ) ; }
|
Convert spring data Sort to Ebean OrderBy .
|
1,991
|
public static < T > Page < T > convertToSpringDataPage ( PagedList < T > pagedList , Sort sort ) { return new PageImpl < T > ( pagedList . getList ( ) , PageRequest . of ( pagedList . getPageIndex ( ) , pagedList . getPageSize ( ) , sort ) , pagedList . getTotalCount ( ) ) ; }
|
Convert Ebean PagedList with Sort to Spring data Page .
|
1,992
|
public Configuration getConfiguration ( ) { if ( configuration == null ) { try { configuration = new PropertiesConfiguration ( getClass ( ) . getResource ( "/nextserver.properties" ) ) ; } catch ( ConfigurationException e ) { throw new RuntimeException ( e ) ; } } return configuration ; }
|
used by StorageUpdate9 to put existing properties inside JCR
|
1,993
|
public void afterDistribute ( RunReportHistory history , DistributionContext context ) { for ( String username : users ) { try { context . getSecurityService ( ) . grantUser ( history . getPath ( ) , username , PermissionUtil . getRead ( ) , false ) ; } catch ( Exception e ) { LOG . error ( e . getMessage ( ) , e ) ; } } }
|
update acl for run report history
|
1,994
|
public static WidgetRuntimeModel getGlobalRuntimeModel ( Settings settings , String dashboardId , ReportService reportService , DataSourceService dataSourceService , DashboardService dashboardService ) { WidgetRuntimeModel runtimeModel = new WidgetRuntimeModel ( ) ; List < Widget > widgets = DashboardUtil . getDashboard ( dashboardId , dashboardService ) . getWidgets ( ) ; if ( widgets . size ( ) == 0 ) { return runtimeModel ; } else if ( widgets . size ( ) == 1 ) { return ChartUtil . getRuntimeModel ( settings , ( EntityWidget ) widgets . get ( 0 ) , reportService , dataSourceService , true ) ; } else { EntityWidget firstWidget = ( EntityWidget ) widgets . get ( 0 ) ; String refreshTime = firstWidget . getSettings ( ) . get ( ChartWidget . REFRESH_TIME ) ; if ( refreshTime == null ) { refreshTime = "0" ; } runtimeModel . setRefreshTime ( Integer . parseInt ( refreshTime ) ) ; String timeout = firstWidget . getSettings ( ) . get ( AbstractWidget . TIMEOUT ) ; if ( timeout == null ) { timeout = String . valueOf ( ChartWidget . DEFAULT_TIMEOUT ) ; } runtimeModel . setTimeout ( Integer . parseInt ( timeout ) ) ; runtimeModel . setEdit ( true ) ; for ( int i = 0 , n = widgets . size ( ) ; i < n ; i ++ ) { if ( ( ( EntityWidget ) widgets . get ( i ) ) . getEntity ( ) == null ) { return runtimeModel ; } } Map < String , Object > parameterValues = firstWidget . getQueryRuntime ( ) . getParametersValues ( ) ; Map < String , Boolean > dynamicMap = firstWidget . getQueryRuntime ( ) . getDynamicMap ( ) ; DataSource dataSource = getDataSource ( ( EntityWidget ) widgets . get ( 0 ) ) ; List < ro . nextreports . engine . Report > reports = new ArrayList < ro . nextreports . engine . Report > ( ) ; for ( int i = 0 , n = widgets . size ( ) ; i < n ; i ++ ) { reports . add ( getReport ( settings , ( EntityWidget ) widgets . get ( i ) ) ) ; } Map < String , QueryParameter > paramMap = ParameterUtil . intersectParametersMap ( reports ) ; runtimeModel . setParameters ( new HashMap < String , ReportRuntimeParameterModel > ( ) ) ; for ( String key : paramMap . keySet ( ) ) { QueryParameter qp = paramMap . get ( key ) ; ReportRuntimeParameterModel parameterModel = createRuntimeModel ( dataSource , parameterValues , qp , dataSourceService , dynamicMap ) ; runtimeModel . getParameters ( ) . put ( key , parameterModel ) ; } return runtimeModel ; } }
|
it is partial because we do not have chart type or some of the parameters
|
1,995
|
public static String getValueClassName ( StorageService storageService , DataSource ds , String sql ) throws Exception { try { if ( ( sql != null ) && ! sql . trim ( ) . equals ( "" ) ) { Connection con = null ; try { con = ConnectionUtil . createConnection ( storageService , ds ) ; int index = sql . toLowerCase ( ) . indexOf ( "where" ) ; int index2 = sql . indexOf ( "${" ) ; String newSql = sql ; if ( ( index > 0 ) && ( index2 > 0 ) ) { newSql = sql . substring ( 0 , index ) + " where 1 = 0" ; } QueryUtil qu = new QueryUtil ( con , DialectUtil . getDialect ( con ) ) ; List < NameType > list = qu . executeQueryForColumnNames ( newSql ) ; return list . get ( 0 ) . getType ( ) ; } finally { ConnectionUtil . closeConnection ( con ) ; } } } catch ( Exception ex ) { ex . printStackTrace ( ) ; LOG . error ( ex . getMessage ( ) , ex ) ; throw ex ; } return null ; }
|
get value class name for the first column on a select sql query
|
1,996
|
protected void bind ( EbeanQueryWrapper query , Parameter parameter , Object value , int position ) { if ( parameter . isNamedParameter ( ) ) { query . setParameter ( parameter . getName ( ) . get ( ) , value ) ; } else { query . setParameter ( position , value ) ; } }
|
Perform the actual query parameter binding .
|
1,997
|
private String getResizeJavaScript ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "$(window).bind(\'resizeEnd\',function(){" ) ; sb . append ( getDisplayCall ( ) ) ; sb . append ( "});" ) ; return sb . toString ( ) ; }
|
display call will be made only when resize event finished!
|
1,998
|
public static ro . nextreports . server . domain . Report renameImagesAsUnique ( ro . nextreports . server . domain . Report report ) { NextContent reportContent = ( NextContent ) report . getContent ( ) ; try { String masterContent = new String ( reportContent . getNextFile ( ) . getDataProvider ( ) . getBytes ( ) , "UTF-8" ) ; for ( JcrFile imageFile : reportContent . getImageFiles ( ) ) { String oldName = imageFile . getName ( ) ; int index = oldName . lastIndexOf ( ro . nextreports . server . report . util . ReportUtil . EXTENSION_SEPARATOR ) ; String newName = oldName . substring ( 0 , index ) + ro . nextreports . server . report . util . ReportUtil . IMAGE_DELIM + UUID . randomUUID ( ) . toString ( ) + oldName . substring ( index ) ; masterContent = masterContent . replaceAll ( oldName , newName ) ; imageFile . setName ( newName ) ; } JcrFile templateFile = reportContent . getTemplateFile ( ) ; if ( templateFile != null ) { String oldName = templateFile . getName ( ) ; int index = oldName . lastIndexOf ( ro . nextreports . server . report . util . ReportUtil . EXTENSION_SEPARATOR ) ; String newName = oldName . substring ( 0 , index ) + ro . nextreports . server . report . util . ReportUtil . IMAGE_DELIM + UUID . randomUUID ( ) . toString ( ) + oldName . substring ( index ) ; masterContent = masterContent . replaceAll ( oldName , newName ) ; templateFile . setName ( newName ) ; } reportContent . getNextFile ( ) . setDataProvider ( new JcrDataProviderImpl ( masterContent . getBytes ( "UTF-8" ) ) ) ; } catch ( UnsupportedEncodingException e ) { LOG . error ( "Error inside renameImagesAsUnique: " + e . getMessage ( ) , e ) ; e . printStackTrace ( ) ; } return report ; }
|
Rename images so that their name is unique
|
1,999
|
private String getResizeJavaScript ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "$(window).bind(\'resizeEnd\',function(){" ) ; sb . append ( getNextChartJavascriptCall ( ) ) ; sb . append ( "});" ) ; return sb . toString ( ) ; }
|
chart call will be made only when resize event finished!
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.