id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
6,600 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java
|
LoadBalancerPoolService.update
|
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)
);
}
|
java
|
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)
);
}
|
[
"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
@param loadBalancerPool load balancer pool
@param config load balancer pool config
@return OperationFuture wrapper for load balancer pool
|
[
"Update",
"load",
"balancer",
"pool"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java#L136-L152
|
6,601 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java
|
LoadBalancerPoolService.update
|
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())
)
);
}
|
java
|
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())
)
);
}
|
[
"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
@param loadBalancer load balancer pool
@param configs load balancer pool configs
@return OperationFuture wrapper for load balancer pool
|
[
"Update",
"load",
"balancer",
"pools",
"for",
"group"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java#L161-L177
|
6,602 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java
|
LoadBalancerPoolService.update
|
public OperationFuture<List<LoadBalancerPool>> update(
List<LoadBalancerPool> loadBalancerPoolList,
LoadBalancerPoolConfig config
) {
loadBalancerPoolList.forEach(pool -> update(pool, config));
return new OperationFuture<>(
loadBalancerPoolList,
new NoWaitingJobFuture()
);
}
|
java
|
public OperationFuture<List<LoadBalancerPool>> update(
List<LoadBalancerPool> loadBalancerPoolList,
LoadBalancerPoolConfig config
) {
loadBalancerPoolList.forEach(pool -> update(pool, config));
return new OperationFuture<>(
loadBalancerPoolList,
new NoWaitingJobFuture()
);
}
|
[
"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
@param loadBalancerPoolList load balancer pool list
@param config load balancer pool config
@return OperationFuture wrapper for load balancer pool list
|
[
"Update",
"load",
"balancer",
"pool",
"list"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java#L210-L220
|
6,603 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java
|
LoadBalancerPoolService.update
|
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);
}
|
java
|
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);
}
|
[
"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
@param loadBalancerPoolFilter load balancer pool filter
@param config load balancer pool config
@return OperationFuture wrapper for load balancer pool list
|
[
"Update",
"filtered",
"balancer",
"pools"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java#L229-L246
|
6,604 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java
|
LoadBalancerPoolService.delete
|
public OperationFuture<LoadBalancerPool> delete(LoadBalancerPool loadBalancerPool) {
LoadBalancerPoolMetadata loadBalancerPoolMetadata = findByRef(loadBalancerPool);
loadBalancerPoolClient.delete(
loadBalancerPoolMetadata.getDataCenterId(),
loadBalancerPoolMetadata.getLoadBalancerId(),
loadBalancerPoolMetadata.getId()
);
return new OperationFuture<>(
loadBalancerPool,
new NoWaitingJobFuture()
);
}
|
java
|
public OperationFuture<LoadBalancerPool> delete(LoadBalancerPool loadBalancerPool) {
LoadBalancerPoolMetadata loadBalancerPoolMetadata = findByRef(loadBalancerPool);
loadBalancerPoolClient.delete(
loadBalancerPoolMetadata.getDataCenterId(),
loadBalancerPoolMetadata.getLoadBalancerId(),
loadBalancerPoolMetadata.getId()
);
return new OperationFuture<>(
loadBalancerPool,
new NoWaitingJobFuture()
);
}
|
[
"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
@param loadBalancerPool load balancer pool
@return OperationFuture wrapper for load balancer pool
|
[
"Delete",
"load",
"balancer",
"pool"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java#L254-L267
|
6,605 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java
|
LoadBalancerPoolService.delete
|
public OperationFuture<List<LoadBalancerPool>> delete(LoadBalancerPool... loadBalancerPool) {
return delete(Arrays.asList(loadBalancerPool));
}
|
java
|
public OperationFuture<List<LoadBalancerPool>> delete(LoadBalancerPool... loadBalancerPool) {
return delete(Arrays.asList(loadBalancerPool));
}
|
[
"public",
"OperationFuture",
"<",
"List",
"<",
"LoadBalancerPool",
">",
">",
"delete",
"(",
"LoadBalancerPool",
"...",
"loadBalancerPool",
")",
"{",
"return",
"delete",
"(",
"Arrays",
".",
"asList",
"(",
"loadBalancerPool",
")",
")",
";",
"}"
] |
Delete array of load balancer pool
@param loadBalancerPool array of load balancer pool
@return OperationFuture wrapper for load balancer pool list
|
[
"Delete",
"array",
"of",
"load",
"balancer",
"pool"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java#L275-L277
|
6,606 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java
|
LoadBalancerPoolService.delete
|
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);
}
|
java
|
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);
}
|
[
"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
@param filter load balancer pool filter
@return OperationFuture wrapper for load balancer pool list
|
[
"Delete",
"filtered",
"load",
"balancer",
"pools"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java#L284-L296
|
6,607 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java
|
LoadBalancerPoolService.delete
|
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)
);
}
|
java
|
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)
);
}
|
[
"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
@param loadBalancerPoolList load balancer pool list
@return OperationFuture wrapper for load balancer pool list
|
[
"Delete",
"load",
"balancer",
"pool",
"list"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerPoolService.java#L304-L314
|
6,608 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/domain/filter/LoadBalancerPoolFilter.java
|
LoadBalancerPoolFilter.loadBalancerPools
|
public LoadBalancerPoolFilter loadBalancerPools(LoadBalancerPool... loadBalancerPools) {
predicate = predicate.and(Filter.or(
Streams.map(loadBalancerPools, LoadBalancerPool::asFilter)
).getPredicate());
return this;
}
|
java
|
public LoadBalancerPoolFilter loadBalancerPools(LoadBalancerPool... loadBalancerPools) {
predicate = predicate.and(Filter.or(
Streams.map(loadBalancerPools, LoadBalancerPool::asFilter)
).getPredicate());
return this;
}
|
[
"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.
@param loadBalancerPools is list of loadBalancerPool references
@return {@link LoadBalancerPoolFilter}
|
[
"Method",
"allow",
"to",
"filter",
"by",
"load",
"balancer",
"pool",
"references",
"."
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/domain/filter/LoadBalancerPoolFilter.java#L96-L102
|
6,609 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/template/filters/TemplateFilter.java
|
TemplateFilter.nameContains
|
public TemplateFilter nameContains(String... names) {
allItemsNotNull(names, "Name substrings");
predicate = predicate.and(combine(
TemplateMetadata::getName, in(asList(names), Predicates::containsIgnoreCase)
));
return this;
}
|
java
|
public TemplateFilter nameContains(String... names) {
allItemsNotNull(names, "Name substrings");
predicate = predicate.and(combine(
TemplateMetadata::getName, in(asList(names), Predicates::containsIgnoreCase)
));
return this;
}
|
[
"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.
@param names is not null list of name substrings
@return {@link TemplateFilter}
@throws java.lang.NullPointerException if {@code names} is null
|
[
"Method",
"allow",
"to",
"find",
"templates",
"that",
"contains",
"some",
"substring",
"in",
"name",
".",
"Filtering",
"is",
"case",
"insensitive",
"."
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/template/filters/TemplateFilter.java#L121-L129
|
6,610 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/template/filters/TemplateFilter.java
|
TemplateFilter.names
|
public TemplateFilter names(String... names) {
allItemsNotNull(names, "Template names");
predicate = predicate.and(combine(
TemplateMetadata::getName, in(names)
));
return this;
}
|
java
|
public TemplateFilter names(String... names) {
allItemsNotNull(names, "Template names");
predicate = predicate.and(combine(
TemplateMetadata::getName, in(names)
));
return this;
}
|
[
"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.
@param names is a set of names
@return {@link TemplateFilter}
|
[
"Method",
"allow",
"to",
"find",
"templates",
"by",
"its",
"names",
"Filtering",
"is",
"case",
"sensitive",
"."
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/template/filters/TemplateFilter.java#L138-L146
|
6,611 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/template/filters/TemplateFilter.java
|
TemplateFilter.osTypes
|
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;
}
|
java
|
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;
}
|
[
"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.
@param osFilter is a not null instance of
{@link OsFilter}
@return {@link TemplateFilter}
|
[
"Method",
"allow",
"to",
"find",
"templates",
"with",
"required",
"image",
"OS",
"."
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/template/filters/TemplateFilter.java#L172-L183
|
6,612 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/base/services/dsl/domain/datacenters/filters/DataCenterFilter.java
|
DataCenterFilter.id
|
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;
}
|
java
|
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;
}
|
[
"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.
@param ids is not null target datacenter IDs
@return {@link DataCenterFilter}
|
[
"Method",
"allow",
"to",
"filter",
"data",
"centers",
"by",
"IDs",
".",
"Filtering",
"is",
"by",
"full",
"match",
".",
"Comparison",
"is",
"case",
"insensitive",
"."
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/base/services/dsl/domain/datacenters/filters/DataCenterFilter.java#L72-L80
|
6,613 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/base/services/dsl/domain/datacenters/filters/DataCenterFilter.java
|
DataCenterFilter.dataCenters
|
public DataCenterFilter dataCenters(DataCenter... dataCenterRefs) {
allItemsNotNull(dataCenterRefs, "Datacenter references");
predicate = predicate.and(Filter.or(
Streams.map(dataCenterRefs, DataCenter::asFilter)
).getPredicate());
return this;
}
|
java
|
public DataCenterFilter dataCenters(DataCenter... dataCenterRefs) {
allItemsNotNull(dataCenterRefs, "Datacenter references");
predicate = predicate.and(Filter.or(
Streams.map(dataCenterRefs, DataCenter::asFilter)
).getPredicate());
return this;
}
|
[
"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.
@param dataCenterRefs is list of references to target dataCenter
@return {@link DataCenterFilter}
|
[
"Method",
"allow",
"to",
"filter",
"data",
"centers",
"by",
"references",
"."
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/base/services/dsl/domain/datacenters/filters/DataCenterFilter.java#L88-L96
|
6,614 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/base/services/dsl/domain/datacenters/filters/DataCenterFilter.java
|
DataCenterFilter.nameContains
|
public DataCenterFilter nameContains(String... names) {
allItemsNotNull(names, "Name keywords");
predicate = predicate.and(combine(
DataCenterMetadata::getName, in(asList(names), Predicates::containsIgnoreCase)
));
return this;
}
|
java
|
public DataCenterFilter nameContains(String... names) {
allItemsNotNull(names, "Name keywords");
predicate = predicate.and(combine(
DataCenterMetadata::getName, in(asList(names), Predicates::containsIgnoreCase)
));
return this;
}
|
[
"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.
@param names is a list of not nul name substring
@return {@link DataCenterFilter}
|
[
"Method",
"allow",
"to",
"filter",
"data",
"centers",
"by",
"name",
".",
"Filtering",
"is",
"case",
"insensitive",
"and",
"occurs",
"using",
"substring",
"search",
"."
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/base/services/dsl/domain/datacenters/filters/DataCenterFilter.java#L105-L113
|
6,615 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.importServer
|
public OperationFuture<ServerMetadata> importServer(ImportServerConfig config) {
BaseServerResponse response = client.importServer(
serverConverter.buildImportServerRequest(
config,
config.getCustomFields().isEmpty() ?
null :
client.getCustomFields()
)
);
return postProcessBuildServerResponse(response, config);
}
|
java
|
public OperationFuture<ServerMetadata> importServer(ImportServerConfig config) {
BaseServerResponse response = client.importServer(
serverConverter.buildImportServerRequest(
config,
config.getCustomFields().isEmpty() ?
null :
client.getCustomFields()
)
);
return postProcessBuildServerResponse(response, config);
}
|
[
"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
@param config server config
@return OperationFuture wrapper for ServerMetadata
|
[
"Import",
"server",
"from",
"ovf",
"image"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L156-L167
|
6,616 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.modify
|
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;
}
|
java
|
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;
}
|
[
"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
@param server server reference
@param modifyServerConfig server config
@return OperationFuture wrapper for ServerRef
|
[
"Modify",
"existing",
"server"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L204-L240
|
6,617 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.modify
|
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)
);
}
|
java
|
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)
);
}
|
[
"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
@param serverList server list
@param modifyServerConfig server config
@return OperationFuture wrapper for list of Servers
|
[
"Modify",
"list",
"of",
"servers"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L248-L260
|
6,618 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.modify
|
public OperationFuture<List<Server>> modify(ServerFilter serverFilter, ModifyServerConfig modifyServerConfig) {
List<Server> serverList = find(serverFilter)
.stream()
.map(ServerMetadata::asRefById)
.collect(toList());
return modify(serverList, modifyServerConfig);
}
|
java
|
public OperationFuture<List<Server>> modify(ServerFilter serverFilter, ModifyServerConfig modifyServerConfig) {
List<Server> serverList = find(serverFilter)
.stream()
.map(ServerMetadata::asRefById)
.collect(toList());
return modify(serverList, modifyServerConfig);
}
|
[
"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
@param serverFilter server filter
@param modifyServerConfig server config
@return OperationFuture wrapper for list of Servers
|
[
"Modify",
"servers",
"by",
"filter"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L268-L275
|
6,619 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.delete
|
public OperationFuture<Server> delete(Server server) {
BaseServerResponse response = client.delete(idByRef(server));
return new OperationFuture<>(
server,
response.findStatusId(),
queueClient
);
}
|
java
|
public OperationFuture<Server> delete(Server server) {
BaseServerResponse response = client.delete(idByRef(server));
return new OperationFuture<>(
server,
response.findStatusId(),
queueClient
);
}
|
[
"public",
"OperationFuture",
"<",
"Server",
">",
"delete",
"(",
"Server",
"server",
")",
"{",
"BaseServerResponse",
"response",
"=",
"client",
".",
"delete",
"(",
"idByRef",
"(",
"server",
")",
")",
";",
"return",
"new",
"OperationFuture",
"<>",
"(",
"server",
",",
"response",
".",
"findStatusId",
"(",
")",
",",
"queueClient",
")",
";",
"}"
] |
Delete existing server
@param server server reference
@return OperationFuture wrapper for ServerRef
|
[
"Delete",
"existing",
"server"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L296-L304
|
6,620 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.restore
|
public OperationFuture<Link> restore(Server server, Group group) {
return baseServerResponse(
restore(server, groupService.findByRef(group).getId())
);
}
|
java
|
public OperationFuture<Link> restore(Server server, Group group) {
return baseServerResponse(
restore(server, groupService.findByRef(group).getId())
);
}
|
[
"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
@param server server reference
@param group group reference
@return OperationFuture wrapper for BaseServerResponse
|
[
"Restore",
"a",
"given",
"archived",
"server",
"to",
"a",
"specified",
"group"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L753-L757
|
6,621 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.restore
|
OperationFuture<List<Server>> restore(String groupId, Server... servers) {
return restore(Arrays.asList(servers), groupId);
}
|
java
|
OperationFuture<List<Server>> restore(String groupId, Server... servers) {
return restore(Arrays.asList(servers), groupId);
}
|
[
"OperationFuture",
"<",
"List",
"<",
"Server",
">",
">",
"restore",
"(",
"String",
"groupId",
",",
"Server",
"...",
"servers",
")",
"{",
"return",
"restore",
"(",
"Arrays",
".",
"asList",
"(",
"servers",
")",
",",
"groupId",
")",
";",
"}"
] |
Restore a group of archived servers to a specified group
@param servers servers references
@return OperationFuture wrapper for list of ServerRef
|
[
"Restore",
"a",
"group",
"of",
"archived",
"servers",
"to",
"a",
"specified",
"group"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L772-L774
|
6,622 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.restore
|
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)
);
}
|
java
|
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)
);
}
|
[
"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
@param serverList server List references
@return OperationFuture wrapper for list of ServerRef
|
[
"Restore",
"a",
"list",
"of",
"archived",
"servers",
"to",
"a",
"specified",
"group"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L781-L798
|
6,623 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.revertToSnapshot
|
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)
);
}
|
java
|
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)
);
}
|
[
"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
@param servers server references
@return OperationFuture wrapper for list of ServerRef
|
[
"Revert",
"a",
"set",
"of",
"servers",
"to",
"snapshot"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L805-L823
|
6,624 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.addPublicIp
|
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
);
}
|
java
|
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
);
}
|
[
"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
@param serverRef server reference
@param publicIpConfig publicIp config
@return OperationFuture wrapper for ServerRef
|
[
"Add",
"public",
"IP",
"to",
"server"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L867-L877
|
6,625 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.modifyPublicIp
|
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
);
}
|
java
|
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
);
}
|
[
"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
@param server server reference
@param config publicIp config
@return OperationFuture wrapper for ServerRef
|
[
"Modify",
"ALL",
"existing",
"public",
"IPs",
"on",
"server"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L917-L936
|
6,626 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.modifyPublicIp
|
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
);
}
|
java
|
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
);
}
|
[
"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
@param server server reference
@param publicIp public ip
@param config publicIp config
@return OperationFuture wrapper for ServerRef
|
[
"Modify",
"provided",
"public",
"IP",
"on",
"server"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L945-L959
|
6,627 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.modifyPublicIp
|
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)
);
}
|
java
|
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)
);
}
|
[
"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
@param servers The list of server references
@param config publicIp config
@return OperationFuture wrapper for list of ServerRef
|
[
"Modify",
"ALL",
"existing",
"public",
"IPs",
"on",
"servers"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L967-L976
|
6,628 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.modifyPublicIp
|
public OperationFuture<List<Server>> modifyPublicIp(ServerFilter filter, ModifyPublicIpConfig config) {
return modifyPublicIp(Arrays.asList(getRefsFromFilter(filter)), config);
}
|
java
|
public OperationFuture<List<Server>> modifyPublicIp(ServerFilter filter, ModifyPublicIpConfig config) {
return modifyPublicIp(Arrays.asList(getRefsFromFilter(filter)), config);
}
|
[
"public",
"OperationFuture",
"<",
"List",
"<",
"Server",
">",
">",
"modifyPublicIp",
"(",
"ServerFilter",
"filter",
",",
"ModifyPublicIpConfig",
"config",
")",
"{",
"return",
"modifyPublicIp",
"(",
"Arrays",
".",
"asList",
"(",
"getRefsFromFilter",
"(",
"filter",
")",
")",
",",
"config",
")",
";",
"}"
] |
Modify existing public IP on servers
@param filter The server filter object
@param config publicIp config
@return OperationFuture wrapper for list of ServerRef
|
[
"Modify",
"existing",
"public",
"IP",
"on",
"servers"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L984-L986
|
6,629 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.getPublicIp
|
public PublicIpMetadata getPublicIp(Server serverRef, String publicIp) {
return this.getPublicIp(idByRef(serverRef), publicIp);
}
|
java
|
public PublicIpMetadata getPublicIp(Server serverRef, String publicIp) {
return this.getPublicIp(idByRef(serverRef), publicIp);
}
|
[
"public",
"PublicIpMetadata",
"getPublicIp",
"(",
"Server",
"serverRef",
",",
"String",
"publicIp",
")",
"{",
"return",
"this",
".",
"getPublicIp",
"(",
"idByRef",
"(",
"serverRef",
")",
",",
"publicIp",
")",
";",
"}"
] |
Get public IP object
@param serverRef server reference
@param publicIp existing public IP address
@return public IP response object
|
[
"Get",
"public",
"IP",
"object"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L1004-L1006
|
6,630 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.removePublicIp
|
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
);
}
|
java
|
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
);
}
|
[
"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
@param serverRef server reference
@param ipAddress existing public IP address
@return OperationFuture wrapper for ServerRef
|
[
"Remove",
"public",
"IP",
"from",
"server"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L1046-L1056
|
6,631 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.removePublicIp
|
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)
);
}
|
java
|
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)
);
}
|
[
"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
@param serverRef server reference
@return OperationFuture wrapper for ServerRef
|
[
"Remove",
"all",
"public",
"IPs",
"from",
"server"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L1064-L1079
|
6,632 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java
|
ServerService.removePublicIp
|
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)
);
}
|
java
|
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)
);
}
|
[
"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
@param servers server references
@return OperationFuture wrapper for list of ServerRef
|
[
"Remove",
"all",
"public",
"IPs",
"from",
"servers",
"array"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/ServerService.java#L1087-L1099
|
6,633 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/NetworkService.java
|
NetworkService.release
|
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());
}
|
java
|
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());
}
|
[
"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
@param dataCenter datacenter reference
@return OperationFuture wrapper for network
|
[
"Release",
"the",
"network",
"for",
"datacenter"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/NetworkService.java#L89-L99
|
6,634 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/NetworkService.java
|
NetworkService.claim
|
public OperationFuture<DataCenter> claim(DataCenter dataCenter) {
NetworkLink response = networkClient.claim(
dataCenterService.findByRef(dataCenter).getId()
);
return
new OperationFuture<>(
dataCenter,
response.getOperationId(),
queueClient
);
}
|
java
|
public OperationFuture<DataCenter> claim(DataCenter dataCenter) {
NetworkLink response = networkClient.claim(
dataCenterService.findByRef(dataCenter).getId()
);
return
new OperationFuture<>(
dataCenter,
response.getOperationId(),
queueClient
);
}
|
[
"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
@param dataCenter datacenter reference
@return OperationFuture wrapper for dataCenter
|
[
"Claim",
"a",
"network",
"for",
"datacenter"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/NetworkService.java#L158-L169
|
6,635 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AntiAffinityService.java
|
AntiAffinityService.create
|
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()
);
}
|
java
|
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()
);
}
|
[
"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
@param createConfig policy config
@return OperationFuture wrapper for AntiAffinityPolicy
|
[
"Create",
"Anti",
"-",
"affinity",
"policy"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AntiAffinityService.java#L67-L78
|
6,636 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AntiAffinityService.java
|
AntiAffinityService.modify
|
public OperationFuture<AntiAffinityPolicy> modify(AntiAffinityPolicy policyRef,
AntiAffinityPolicyConfig modifyConfig) {
client.modifyAntiAffinityPolicy(
findByRef(policyRef).getId(),
new AntiAffinityPolicyRequest()
.name(modifyConfig.getName())
);
return new OperationFuture<>(
policyRef,
new NoWaitingJobFuture()
);
}
|
java
|
public OperationFuture<AntiAffinityPolicy> modify(AntiAffinityPolicy policyRef,
AntiAffinityPolicyConfig modifyConfig) {
client.modifyAntiAffinityPolicy(
findByRef(policyRef).getId(),
new AntiAffinityPolicyRequest()
.name(modifyConfig.getName())
);
return new OperationFuture<>(
policyRef,
new NoWaitingJobFuture()
);
}
|
[
"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
@param policyRef policy reference
@param modifyConfig update policy config
@return OperationFuture wrapper for AntiAffinityPolicy
|
[
"Update",
"Anti",
"-",
"affinity",
"policy"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AntiAffinityService.java#L87-L100
|
6,637 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AntiAffinityService.java
|
AntiAffinityService.delete
|
public OperationFuture<AntiAffinityPolicy> delete(AntiAffinityPolicy policyRef) {
client.deleteAntiAffinityPolicy(findByRef(policyRef).getId());
return new OperationFuture<>(
policyRef,
new NoWaitingJobFuture()
);
}
|
java
|
public OperationFuture<AntiAffinityPolicy> delete(AntiAffinityPolicy policyRef) {
client.deleteAntiAffinityPolicy(findByRef(policyRef).getId());
return new OperationFuture<>(
policyRef,
new NoWaitingJobFuture()
);
}
|
[
"public",
"OperationFuture",
"<",
"AntiAffinityPolicy",
">",
"delete",
"(",
"AntiAffinityPolicy",
"policyRef",
")",
"{",
"client",
".",
"deleteAntiAffinityPolicy",
"(",
"findByRef",
"(",
"policyRef",
")",
".",
"getId",
"(",
")",
")",
";",
"return",
"new",
"OperationFuture",
"<>",
"(",
"policyRef",
",",
"new",
"NoWaitingJobFuture",
"(",
")",
")",
";",
"}"
] |
Remove Anti-affinity policy
@param policyRef policy reference
@return OperationFuture wrapper for AntiAffinityPolicy
|
[
"Remove",
"Anti",
"-",
"affinity",
"policy"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AntiAffinityService.java#L139-L146
|
6,638 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AntiAffinityService.java
|
AntiAffinityService.delete
|
public OperationFuture<List<AntiAffinityPolicy>> delete(AntiAffinityPolicyFilter filter) {
List<AntiAffinityPolicy> policyRefs = getRefsFromFilter(filter);
return delete(policyRefs.toArray(new AntiAffinityPolicy[policyRefs.size()]));
}
|
java
|
public OperationFuture<List<AntiAffinityPolicy>> delete(AntiAffinityPolicyFilter filter) {
List<AntiAffinityPolicy> policyRefs = getRefsFromFilter(filter);
return delete(policyRefs.toArray(new AntiAffinityPolicy[policyRefs.size()]));
}
|
[
"public",
"OperationFuture",
"<",
"List",
"<",
"AntiAffinityPolicy",
">",
">",
"delete",
"(",
"AntiAffinityPolicyFilter",
"filter",
")",
"{",
"List",
"<",
"AntiAffinityPolicy",
">",
"policyRefs",
"=",
"getRefsFromFilter",
"(",
"filter",
")",
";",
"return",
"delete",
"(",
"policyRefs",
".",
"toArray",
"(",
"new",
"AntiAffinityPolicy",
"[",
"policyRefs",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}"
] |
Remove Anti-affinity policies
@param filter the search policies criteria
@return OperationFuture wrapper for list of AntiAffinityPolicy
|
[
"Remove",
"Anti",
"-",
"affinity",
"policies"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AntiAffinityService.java#L173-L176
|
6,639 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/GroupService.java
|
GroupService.findGroup
|
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);
}
|
java
|
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);
}
|
[
"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
@param config group hierarchy config
@param parentGroupId parent group id
@return GroupMetadata
|
[
"Find",
"group",
"based",
"on",
"config",
"instance",
"and",
"parent",
"group",
"identifier"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/GroupService.java#L251-L258
|
6,640 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/GroupService.java
|
GroupService.delete
|
public OperationFuture<Group> delete(Group group) {
Link response = client.deleteGroup(idByRef(group));
return new OperationFuture<>(
group,
response.getId(),
queueClient
);
}
|
java
|
public OperationFuture<Group> delete(Group group) {
Link response = client.deleteGroup(idByRef(group));
return new OperationFuture<>(
group,
response.getId(),
queueClient
);
}
|
[
"public",
"OperationFuture",
"<",
"Group",
">",
"delete",
"(",
"Group",
"group",
")",
"{",
"Link",
"response",
"=",
"client",
".",
"deleteGroup",
"(",
"idByRef",
"(",
"group",
")",
")",
";",
"return",
"new",
"OperationFuture",
"<>",
"(",
"group",
",",
"response",
".",
"getId",
"(",
")",
",",
"queueClient",
")",
";",
"}"
] |
Delete provided group
@param group group reference
@return OperationFuture wrapper for group
|
[
"Delete",
"provided",
"group"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/GroupService.java#L389-L397
|
6,641 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/GroupService.java
|
GroupService.delete
|
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)
);
}
|
java
|
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)
);
}
|
[
"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
@param groups groups array
@return OperationFuture wrapper for list of groups
|
[
"Delete",
"set",
"of",
"groups"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/GroupService.java#L405-L416
|
6,642 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/GroupService.java
|
GroupService.getBillingStats
|
public BillingStats getBillingStats(Group group) {
return converter.convertBillingStats(
client.getGroupBillingStats(idByRef(group))
);
}
|
java
|
public BillingStats getBillingStats(Group group) {
return converter.convertBillingStats(
client.getGroupBillingStats(idByRef(group))
);
}
|
[
"public",
"BillingStats",
"getBillingStats",
"(",
"Group",
"group",
")",
"{",
"return",
"converter",
".",
"convertBillingStats",
"(",
"client",
".",
"getGroupBillingStats",
"(",
"idByRef",
"(",
"group",
")",
")",
")",
";",
"}"
] |
Get billing stats by single group
@param group Group
@return Group billing stats
|
[
"Get",
"billing",
"stats",
"by",
"single",
"group"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/GroupService.java#L689-L693
|
6,643 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/GroupService.java
|
GroupService.getBillingStats
|
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;
}
|
java
|
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;
}
|
[
"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
@param groups groups array
@return List of Group billing stats
|
[
"Get",
"billing",
"stats",
"by",
"Groups"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/GroupService.java#L701-L714
|
6,644 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/GroupService.java
|
GroupService.getBillingStats
|
public List<BillingStats> getBillingStats(GroupFilter groupFilter) {
return findLazy(groupFilter)
.map(
groupMetadata -> converter.convertBillingStats(
client.getGroupBillingStats(groupMetadata.getId())
)
)
.collect(toList());
}
|
java
|
public List<BillingStats> getBillingStats(GroupFilter groupFilter) {
return findLazy(groupFilter)
.map(
groupMetadata -> converter.convertBillingStats(
client.getGroupBillingStats(groupMetadata.getId())
)
)
.collect(toList());
}
|
[
"public",
"List",
"<",
"BillingStats",
">",
"getBillingStats",
"(",
"GroupFilter",
"groupFilter",
")",
"{",
"return",
"findLazy",
"(",
"groupFilter",
")",
".",
"map",
"(",
"groupMetadata",
"->",
"converter",
".",
"convertBillingStats",
"(",
"client",
".",
"getGroupBillingStats",
"(",
"groupMetadata",
".",
"getId",
"(",
")",
")",
")",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
";",
"}"
] |
Get billing stats by GroupFilter
@param groupFilter group filter
@return List of Group billing stats
|
[
"Get",
"billing",
"stats",
"by",
"GroupFilter"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/GroupService.java#L721-L729
|
6,645 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AutoscalePolicyService.java
|
AutoscalePolicyService.setAutoscalePolicyOnServer
|
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());
}
|
java
|
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());
}
|
[
"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
@param autoscalePolicy autoscale policy
@param server server
@return OperationFuture wrapper for autoscalePolicy
|
[
"Set",
"autoscale",
"policy",
"on",
"server"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AutoscalePolicyService.java#L77-L89
|
6,646 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AutoscalePolicyService.java
|
AutoscalePolicyService.setAutoscalePolicyOnServer
|
public OperationFuture<List<Server>> setAutoscalePolicyOnServer(
AutoscalePolicy autoscalePolicy,
ServerFilter serverFilter
) {
return
setAutoscalePolicyOnServer(
autoscalePolicy,
serverService
.findLazy(serverFilter)
.map(serverMetadata -> Server.refById(serverMetadata.getId()))
.collect(toList())
);
}
|
java
|
public OperationFuture<List<Server>> setAutoscalePolicyOnServer(
AutoscalePolicy autoscalePolicy,
ServerFilter serverFilter
) {
return
setAutoscalePolicyOnServer(
autoscalePolicy,
serverService
.findLazy(serverFilter)
.map(serverMetadata -> Server.refById(serverMetadata.getId()))
.collect(toList())
);
}
|
[
"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
@param autoscalePolicy autoscale policy
@param serverFilter server filter
@return OperationFuture wrapper for servers
|
[
"set",
"autoscale",
"policy",
"on",
"filtered",
"servers"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AutoscalePolicyService.java#L135-L147
|
6,647 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AutoscalePolicyService.java
|
AutoscalePolicyService.getAutoscalePolicyOnServer
|
public AutoscalePolicyMetadata getAutoscalePolicyOnServer(Server server) {
return
autoscalePolicyClient
.getAutoscalePolicyOnServer(
serverService
.findByRef(server)
.getId()
);
}
|
java
|
public AutoscalePolicyMetadata getAutoscalePolicyOnServer(Server server) {
return
autoscalePolicyClient
.getAutoscalePolicyOnServer(
serverService
.findByRef(server)
.getId()
);
}
|
[
"public",
"AutoscalePolicyMetadata",
"getAutoscalePolicyOnServer",
"(",
"Server",
"server",
")",
"{",
"return",
"autoscalePolicyClient",
".",
"getAutoscalePolicyOnServer",
"(",
"serverService",
".",
"findByRef",
"(",
"server",
")",
".",
"getId",
"(",
")",
")",
";",
"}"
] |
get autoscale policy on server
@param server server
@return AutoscalePolicyMetadata
|
[
"get",
"autoscale",
"policy",
"on",
"server"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AutoscalePolicyService.java#L155-L163
|
6,648 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AutoscalePolicyService.java
|
AutoscalePolicyService.removeAutoscalePolicyOnServer
|
public OperationFuture<Server> removeAutoscalePolicyOnServer(Server server) {
autoscalePolicyClient
.removeAutoscalePolicyOnServer(
serverService.findByRef(server).getId()
);
return new OperationFuture<>(server, new NoWaitingJobFuture());
}
|
java
|
public OperationFuture<Server> removeAutoscalePolicyOnServer(Server server) {
autoscalePolicyClient
.removeAutoscalePolicyOnServer(
serverService.findByRef(server).getId()
);
return new OperationFuture<>(server, new NoWaitingJobFuture());
}
|
[
"public",
"OperationFuture",
"<",
"Server",
">",
"removeAutoscalePolicyOnServer",
"(",
"Server",
"server",
")",
"{",
"autoscalePolicyClient",
".",
"removeAutoscalePolicyOnServer",
"(",
"serverService",
".",
"findByRef",
"(",
"server",
")",
".",
"getId",
"(",
")",
")",
";",
"return",
"new",
"OperationFuture",
"<>",
"(",
"server",
",",
"new",
"NoWaitingJobFuture",
"(",
")",
")",
";",
"}"
] |
remove autoscale policy on server
@param server server
@return OperationFuture wrapper for server
|
[
"remove",
"autoscale",
"policy",
"on",
"server"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AutoscalePolicyService.java#L171-L178
|
6,649 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AutoscalePolicyService.java
|
AutoscalePolicyService.removeAutoscalePolicyOnServer
|
public OperationFuture<List<Server>> removeAutoscalePolicyOnServer(ServerFilter serverFilter) {
return
removeAutoscalePolicyOnServer(
serverService
.findLazy(serverFilter)
.map(serverMetadata -> Server.refById(serverMetadata.getId()))
.collect(toList())
);
}
|
java
|
public OperationFuture<List<Server>> removeAutoscalePolicyOnServer(ServerFilter serverFilter) {
return
removeAutoscalePolicyOnServer(
serverService
.findLazy(serverFilter)
.map(serverMetadata -> Server.refById(serverMetadata.getId()))
.collect(toList())
);
}
|
[
"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
@param serverFilter server filter
@return OperationFuture wrapper for servers
|
[
"remove",
"autoscale",
"policy",
"on",
"filtered",
"servers"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AutoscalePolicyService.java#L215-L223
|
6,650 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/core/client/SdkClientBuilder.java
|
SdkClientBuilder.connectionCheckoutTimeout
|
public SdkClientBuilder connectionCheckoutTimeout(long timeout, TimeUnit unit)
{
this.connectionCheckoutTimeoutMs = (int) TimeUnit.MILLISECONDS.convert(timeout, unit);
return this;
}
|
java
|
public SdkClientBuilder connectionCheckoutTimeout(long timeout, TimeUnit unit)
{
this.connectionCheckoutTimeoutMs = (int) TimeUnit.MILLISECONDS.convert(timeout, unit);
return this;
}
|
[
"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?
@param timeout the timeout
@param unit the units the timeout is in
@return this builder
|
[
"If",
"connection",
"pooling",
"is",
"enabled",
"how",
"long",
"will",
"we",
"wait",
"to",
"get",
"a",
"connection?"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/core/client/SdkClientBuilder.java#L219-L223
|
6,651 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/core/client/SdkClientBuilder.java
|
SdkClientBuilder.defaultProxy
|
public SdkClientBuilder defaultProxy(String hostname, int port, final String scheme)
{
this.defaultProxy = new HttpHost(hostname, port, scheme);
return this;
}
|
java
|
public SdkClientBuilder defaultProxy(String hostname, int port, final String scheme)
{
this.defaultProxy = new HttpHost(hostname, port, scheme);
return this;
}
|
[
"public",
"SdkClientBuilder",
"defaultProxy",
"(",
"String",
"hostname",
",",
"int",
"port",
",",
"final",
"String",
"scheme",
")",
"{",
"this",
".",
"defaultProxy",
"=",
"new",
"HttpHost",
"(",
"hostname",
",",
"port",
",",
"scheme",
")",
";",
"return",
"this",
";",
"}"
] |
Specify default proxy.
@param hostname the proxy hostname
@param port the proxy port number
@param scheme the proxy scheme
@return current instance of SDK client builder
|
[
"Specify",
"default",
"proxy",
"."
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/core/client/SdkClientBuilder.java#L355-L359
|
6,652 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/core/client/SdkClientBuilder.java
|
SdkClientBuilder.proxyCredentials
|
public SdkClientBuilder proxyCredentials(String user, String password) {
this.proxyCredentials = new UsernamePasswordCredentials(user, password);
return this;
}
|
java
|
public SdkClientBuilder proxyCredentials(String user, String password) {
this.proxyCredentials = new UsernamePasswordCredentials(user, password);
return this;
}
|
[
"public",
"SdkClientBuilder",
"proxyCredentials",
"(",
"String",
"user",
",",
"String",
"password",
")",
"{",
"this",
".",
"proxyCredentials",
"=",
"new",
"UsernamePasswordCredentials",
"(",
"user",
",",
"password",
")",
";",
"return",
"this",
";",
"}"
] |
Specify proxy credentials.
@param user user
@param password password
@return current client builder
|
[
"Specify",
"proxy",
"credentials",
"."
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/core/client/SdkClientBuilder.java#L367-L370
|
6,653 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerNodeService.java
|
LoadBalancerNodeService.update
|
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()
);
}
|
java
|
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()
);
}
|
[
"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
@param loadBalancerPool load balancer pool
@param nodesList node balancer node list
@return OperationFuture wrapper for load balancer pool
|
[
"Update",
"load",
"balancer",
"node",
"list",
"of",
"the",
"load",
"balancer",
"pool"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/loadbalancer/services/dsl/LoadBalancerNodeService.java#L77-L96
|
6,654 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/group/GroupHierarchyConfig.java
|
GroupHierarchyConfig.subitems
|
public GroupHierarchyConfig subitems(InfrastructureItem... subitems) {
checkNotNull(subitems, "List of server configs must be not a null");
this.subitems.addAll(asList(subitems));
return this;
}
|
java
|
public GroupHierarchyConfig subitems(InfrastructureItem... subitems) {
checkNotNull(subitems, "List of server configs must be not a null");
this.subitems.addAll(asList(subitems));
return this;
}
|
[
"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
@param subitems items, that specified for group
@return current {@link GroupHierarchyConfig} instance
|
[
"Set",
"sub",
"items"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/group/GroupHierarchyConfig.java#L71-L75
|
6,655 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/group/GroupHierarchyConfig.java
|
GroupHierarchyConfig.getServerConfigs
|
public List<CreateServerConfig> getServerConfigs() {
List<CreateServerConfig> serverConfigs = new ArrayList<>();
collectConfigs(this, serverConfigs);
return serverConfigs;
}
|
java
|
public List<CreateServerConfig> getServerConfigs() {
List<CreateServerConfig> serverConfigs = new ArrayList<>();
collectConfigs(this, serverConfigs);
return serverConfigs;
}
|
[
"public",
"List",
"<",
"CreateServerConfig",
">",
"getServerConfigs",
"(",
")",
"{",
"List",
"<",
"CreateServerConfig",
">",
"serverConfigs",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"collectConfigs",
"(",
"this",
",",
"serverConfigs",
")",
";",
"return",
"serverConfigs",
";",
"}"
] |
Returns all configs for creating servers
@return all {@link CreateServerConfig} configs
|
[
"Returns",
"all",
"configs",
"for",
"creating",
"servers"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/group/GroupHierarchyConfig.java#L112-L116
|
6,656 |
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/group/GroupHierarchyConfig.java
|
GroupHierarchyConfig.collectConfigs
|
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);
}
});
}
|
java
|
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);
}
});
}
|
[
"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
@param hierarchyConfig group hierarchy config
@param serverConfigs list with server configs
|
[
"Collect",
"server",
"configs",
"in",
"current",
"group"
] |
c026322f077dea71b1acf9f2d665253d79d9bf85
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/group/GroupHierarchyConfig.java#L123-L131
|
6,657 |
tuenti/ButtonMenu
|
sample/src/main/java/com/tuenti/buttonmenu/sample/ui/activity/MainActivity.java
|
MainActivity.initializeButtonMenu
|
private void initializeButtonMenu() {
button_menu = (ButtonMenu) findViewById(R.id.button_menu);
button_menu.setButtonMenuVM(buttonMenuVM);
button_menu.initialize();
}
|
java
|
private void initializeButtonMenu() {
button_menu = (ButtonMenu) findViewById(R.id.button_menu);
button_menu.setButtonMenuVM(buttonMenuVM);
button_menu.initialize();
}
|
[
"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.
|
[
"Set",
"the",
"ButtonMenuVM",
"implementation",
"to",
"the",
"ButtonMenu",
"custom",
"view",
"and",
"initialize",
"it",
"."
] |
95791383f6f976933496542b54e8c6dbdd73e669
|
https://github.com/tuenti/ButtonMenu/blob/95791383f6f976933496542b54e8c6dbdd73e669/sample/src/main/java/com/tuenti/buttonmenu/sample/ui/activity/MainActivity.java#L84-L88
|
6,658 |
tuenti/ButtonMenu
|
sample/src/main/java/com/tuenti/buttonmenu/sample/ui/activity/MainActivity.java
|
MainActivity.initializeScrollAnimator
|
private void initializeScrollAnimator() {
ScrollAnimator scrollAnimator = new ScrollAnimator(button_menu, new ObjectAnimatorFactory());
scrollAnimator.configureListView(lv_contacts);
scrollAnimator.setDurationInMillis(300);
}
|
java
|
private void initializeScrollAnimator() {
ScrollAnimator scrollAnimator = new ScrollAnimator(button_menu, new ObjectAnimatorFactory());
scrollAnimator.configureListView(lv_contacts);
scrollAnimator.setDurationInMillis(300);
}
|
[
"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.
|
[
"Initialize",
"ScrollAnimator",
"to",
"work",
"with",
"ButtonMenu",
"custom",
"view",
"the",
"ListView",
"used",
"in",
"this",
"sample",
"and",
"an",
"animation",
"duration",
"of",
"200",
"milliseconds",
"."
] |
95791383f6f976933496542b54e8c6dbdd73e669
|
https://github.com/tuenti/ButtonMenu/blob/95791383f6f976933496542b54e8c6dbdd73e669/sample/src/main/java/com/tuenti/buttonmenu/sample/ui/activity/MainActivity.java#L105-L109
|
6,659 |
tuenti/ButtonMenu
|
library/src/main/java/com/tuenti/buttonmenu/animator/ScrollAnimator.java
|
ScrollAnimator.configureListView
|
public void configureListView(ListView listView) {
this.listView = listView;
this.listView.setOnScrollListener(new OnScrollListener() {
int scrollPosition;
@Override
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;
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
notifyScrollStateChangedToAdditionalScrollListener(view, scrollState);
}
});
}
|
java
|
public void configureListView(ListView listView) {
this.listView = listView;
this.listView.setOnScrollListener(new OnScrollListener() {
int scrollPosition;
@Override
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;
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
notifyScrollStateChangedToAdditionalScrollListener(view, scrollState);
}
});
}
|
[
"public",
"void",
"configureListView",
"(",
"ListView",
"listView",
")",
"{",
"this",
".",
"listView",
"=",
"listView",
";",
"this",
".",
"listView",
".",
"setOnScrollListener",
"(",
"new",
"OnScrollListener",
"(",
")",
"{",
"int",
"scrollPosition",
";",
"@",
"Override",
"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",
";",
"}",
"@",
"Override",
"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.
@param listView to listen.
|
[
"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",
"."
] |
95791383f6f976933496542b54e8c6dbdd73e669
|
https://github.com/tuenti/ButtonMenu/blob/95791383f6f976933496542b54e8c6dbdd73e669/library/src/main/java/com/tuenti/buttonmenu/animator/ScrollAnimator.java#L71-L101
|
6,660 |
tuenti/ButtonMenu
|
library/src/main/java/com/tuenti/buttonmenu/animator/ScrollAnimator.java
|
ScrollAnimator.showWithAnimationWithListener
|
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();
}
|
java
|
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();
}
|
[
"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.
|
[
"Show",
"the",
"animated",
"view",
"using",
"a",
"translationY",
"animation",
"and",
"configure",
"an",
"AnimatorListener",
"to",
"be",
"notified",
"during",
"the",
"animation",
"."
] |
95791383f6f976933496542b54e8c6dbdd73e669
|
https://github.com/tuenti/ButtonMenu/blob/95791383f6f976933496542b54e8c6dbdd73e669/library/src/main/java/com/tuenti/buttonmenu/animator/ScrollAnimator.java#L130-L138
|
6,661 |
tuenti/ButtonMenu
|
library/src/main/java/com/tuenti/buttonmenu/animator/ScrollAnimator.java
|
ScrollAnimator.hideWithAnimationWithListener
|
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();
}
|
java
|
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();
}
|
[
"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.
|
[
"Hide",
"the",
"animated",
"view",
"using",
"a",
"translationY",
"animation",
"and",
"configure",
"an",
"AnimatorListener",
"to",
"be",
"notified",
"during",
"the",
"animation",
"."
] |
95791383f6f976933496542b54e8c6dbdd73e669
|
https://github.com/tuenti/ButtonMenu/blob/95791383f6f976933496542b54e8c6dbdd73e669/library/src/main/java/com/tuenti/buttonmenu/animator/ScrollAnimator.java#L151-L159
|
6,662 |
tuenti/ButtonMenu
|
library/src/main/java/com/tuenti/buttonmenu/animator/ScrollAnimator.java
|
ScrollAnimator.animate
|
protected void animate(int translationY) {
ObjectAnimator animator = objectAnimatorFactory.getObjectAnimator(animatedView, ANIMATION_TYPE, translationY);
animator.setDuration(durationInMillis);
animator.start();
}
|
java
|
protected void animate(int translationY) {
ObjectAnimator animator = objectAnimatorFactory.getObjectAnimator(animatedView, ANIMATION_TYPE, translationY);
animator.setDuration(durationInMillis);
animator.start();
}
|
[
"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.
@param translationY final position.
|
[
"Animate",
"animated",
"view",
"from",
"the",
"current",
"position",
"to",
"a",
"translationY",
"position",
"."
] |
95791383f6f976933496542b54e8c6dbdd73e669
|
https://github.com/tuenti/ButtonMenu/blob/95791383f6f976933496542b54e8c6dbdd73e669/library/src/main/java/com/tuenti/buttonmenu/animator/ScrollAnimator.java#L166-L170
|
6,663 |
tuenti/ButtonMenu
|
library/src/main/java/com/tuenti/buttonmenu/animator/ScrollAnimator.java
|
ScrollAnimator.onScrollPositionChanged
|
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);
}
}
|
java
|
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);
}
}
|
[
"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.
@param oldScrollPosition
@param newScrollPosition
|
[
"Perform",
"the",
"translateY",
"animation",
"using",
"the",
"new",
"scroll",
"position",
"and",
"the",
"old",
"scroll",
"position",
"to",
"show",
"or",
"hide",
"the",
"animated",
"view",
"."
] |
95791383f6f976933496542b54e8c6dbdd73e669
|
https://github.com/tuenti/ButtonMenu/blob/95791383f6f976933496542b54e8c6dbdd73e669/library/src/main/java/com/tuenti/buttonmenu/animator/ScrollAnimator.java#L192-L204
|
6,664 |
orhanobut/wasp
|
wasp/src/main/java/com/orhanobut/wasp/utils/MockFactory.java
|
MockFactory.readMockResponse
|
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;
}
|
java
|
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;
}
|
[
"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.
@param context Context with file access
@param filePath Path to mock file
@return Response string
|
[
"Reads",
"mock",
"response",
"string",
"from",
"given",
"path",
"."
] |
295d8747aa7e410b185a620a6b87239816a38c11
|
https://github.com/orhanobut/wasp/blob/295d8747aa7e410b185a620a6b87239816a38c11/wasp/src/main/java/com/orhanobut/wasp/utils/MockFactory.java#L37-L50
|
6,665 |
orhanobut/wasp
|
wasp/src/main/java/com/orhanobut/wasp/utils/MockFactory.java
|
MockFactory.createMockObject
|
@SuppressWarnings("unchecked") // types must agree
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);
}
|
java
|
@SuppressWarnings("unchecked") // types must agree
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);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"// types must agree",
"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.
@param type Type of mock object
@param <T> Type of mock object
@return Mock Object of type T
|
[
"Creates",
"a",
"mock",
"object",
"and",
"populates",
"its",
"fields",
"."
] |
295d8747aa7e410b185a620a6b87239816a38c11
|
https://github.com/orhanobut/wasp/blob/295d8747aa7e410b185a620a6b87239816a38c11/wasp/src/main/java/com/orhanobut/wasp/utils/MockFactory.java#L59-L74
|
6,666 |
orhanobut/wasp
|
wasp/src/main/java/com/orhanobut/wasp/utils/MockFactory.java
|
MockFactory.instantiateObject
|
@SuppressWarnings("unchecked") // types must agree
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) {
// Default constructor failed, attempt Unsafe Allocation
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) {
// Give up
throw new RuntimeException("Failed to instantiate "
+ rawType.getCanonicalName(), e);
}
}
|
java
|
@SuppressWarnings("unchecked") // types must agree
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) {
// Default constructor failed, attempt Unsafe Allocation
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) {
// Give up
throw new RuntimeException("Failed to instantiate "
+ rawType.getCanonicalName(), e);
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"// types must agree",
"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",
")",
"{",
"// Default constructor failed, attempt Unsafe Allocation",
"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",
")",
"{",
"// Give up",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to instantiate \"",
"+",
"rawType",
".",
"getCanonicalName",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Creates a new instance of given raw type.
@param rawType Raw Type of object
@param <T> Type of object
@return Object instance
|
[
"Creates",
"a",
"new",
"instance",
"of",
"given",
"raw",
"type",
"."
] |
295d8747aa7e410b185a620a6b87239816a38c11
|
https://github.com/orhanobut/wasp/blob/295d8747aa7e410b185a620a6b87239816a38c11/wasp/src/main/java/com/orhanobut/wasp/utils/MockFactory.java#L83-L107
|
6,667 |
orhanobut/wasp
|
wasp/src/main/java/com/orhanobut/wasp/utils/MockFactory.java
|
MockFactory.populateObject
|
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.")) {
// Skip system classes
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;
}
|
java
|
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.")) {
// Skip system classes
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;
}
|
[
"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.\"",
")",
")",
"{",
"// Skip system classes",
"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.
@param object Object to populate
@param <T> Type of object
@return Populated object
|
[
"All",
"non",
"-",
"final",
"fields",
"in",
"object",
"are",
"populated",
"with",
"mock",
"values",
"."
] |
295d8747aa7e410b185a620a6b87239816a38c11
|
https://github.com/orhanobut/wasp/blob/295d8747aa7e410b185a620a6b87239816a38c11/wasp/src/main/java/com/orhanobut/wasp/utils/MockFactory.java#L116-L144
|
6,668 |
orhanobut/wasp
|
wasp/src/main/java/com/orhanobut/wasp/utils/MockFactory.java
|
MockFactory.generateValue
|
private static Object generateValue(Field field) {
Class<?> rawType = field.getType();
//TODO Objects other than Lists might need parametrized types.
if (List.class.isAssignableFrom(rawType)) {
ParameterizedType genericType = (ParameterizedType) field.getGenericType();
return createListObject(genericType);
}
return generateValue(rawType);
}
|
java
|
private static Object generateValue(Field field) {
Class<?> rawType = field.getType();
//TODO Objects other than Lists might need parametrized types.
if (List.class.isAssignableFrom(rawType)) {
ParameterizedType genericType = (ParameterizedType) field.getGenericType();
return createListObject(genericType);
}
return generateValue(rawType);
}
|
[
"private",
"static",
"Object",
"generateValue",
"(",
"Field",
"field",
")",
"{",
"Class",
"<",
"?",
">",
"rawType",
"=",
"field",
".",
"getType",
"(",
")",
";",
"//TODO Objects other than Lists might need parametrized types.",
"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.
@param field Field to generate value for
@return Generated value
|
[
"Generates",
"a",
"mock",
"value",
"assignable",
"to",
"provided",
"field",
".",
"Parametrized",
"types",
"are",
"only",
"supported",
"for",
"List",
"fields",
".",
"If",
"not",
"a",
"list",
"raw",
"type",
"is",
"used",
"."
] |
295d8747aa7e410b185a620a6b87239816a38c11
|
https://github.com/orhanobut/wasp/blob/295d8747aa7e410b185a620a6b87239816a38c11/wasp/src/main/java/com/orhanobut/wasp/utils/MockFactory.java#L154-L164
|
6,669 |
orhanobut/wasp
|
wasp/src/main/java/com/orhanobut/wasp/utils/MockFactory.java
|
MockFactory.generateValue
|
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);
}
//TODO Date and BigInteger classes may be considered.
// Field type is not supported.
Logger.w("Unsupported field type : " + rawType.getCanonicalName());
return null;
}
|
java
|
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);
}
//TODO Date and BigInteger classes may be considered.
// Field type is not supported.
Logger.w("Unsupported field type : " + rawType.getCanonicalName());
return null;
}
|
[
"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",
")",
";",
"}",
"//TODO Date and BigInteger classes may be considered.",
"// Field type is not supported.",
"Logger",
".",
"w",
"(",
"\"Unsupported field type : \"",
"+",
"rawType",
".",
"getCanonicalName",
"(",
")",
")",
";",
"return",
"null",
";",
"}"
] |
Generates a mock value assignable to provided raw type.
@param rawType Type of field
@return Generated value
|
[
"Generates",
"a",
"mock",
"value",
"assignable",
"to",
"provided",
"raw",
"type",
"."
] |
295d8747aa7e410b185a620a6b87239816a38c11
|
https://github.com/orhanobut/wasp/blob/295d8747aa7e410b185a620a6b87239816a38c11/wasp/src/main/java/com/orhanobut/wasp/utils/MockFactory.java#L172-L196
|
6,670 |
habernal/confusion-matrix
|
src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java
|
ConfusionMatrix.increaseValue
|
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;
}
}
|
java
|
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;
}
}
|
[
"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
@param goldValue exp
@param observedValue ac
@param times n-times
|
[
"Increases",
"value",
"of",
"goldValue",
"x",
"observedValue",
"n",
"times"
] |
d0310f0aeda0fa74a9d42bcb190db7250bf49ecc
|
https://github.com/habernal/confusion-matrix/blob/d0310f0aeda0fa74a9d42bcb190db7250bf49ecc/src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java#L98-L123
|
6,671 |
habernal/confusion-matrix
|
src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java
|
ConfusionMatrix.getMacroFMeasure
|
public double getMacroFMeasure()
{
Map<String, Double> fMeasureForLabels = getFMeasureForLabels();
double totalFMeasure = 0;
for (Double d : fMeasureForLabels.values()) {
totalFMeasure += d;
}
return totalFMeasure / fMeasureForLabels.size();
}
|
java
|
public double getMacroFMeasure()
{
Map<String, Double> fMeasureForLabels = getFMeasureForLabels();
double totalFMeasure = 0;
for (Double d : fMeasureForLabels.values()) {
totalFMeasure += d;
}
return totalFMeasure / fMeasureForLabels.size();
}
|
[
"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.
@return double
|
[
"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",
"."
] |
d0310f0aeda0fa74a9d42bcb190db7250bf49ecc
|
https://github.com/habernal/confusion-matrix/blob/d0310f0aeda0fa74a9d42bcb190db7250bf49ecc/src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java#L224-L235
|
6,672 |
habernal/confusion-matrix
|
src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java
|
ConfusionMatrix.getRecallForLabels
|
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;
}
|
java
|
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;
}
|
[
"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
@return double
|
[
"Return",
"recall",
"for",
"labels"
] |
d0310f0aeda0fa74a9d42bcb190db7250bf49ecc
|
https://github.com/habernal/confusion-matrix/blob/d0310f0aeda0fa74a9d42bcb190db7250bf49ecc/src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java#L318-L327
|
6,673 |
habernal/confusion-matrix
|
src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java
|
ConfusionMatrix.getRecallForLabel
|
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;
}
|
java
|
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;
}
|
[
"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
@param label label
@return double
|
[
"Return",
"recall",
"for",
"single",
"label"
] |
d0310f0aeda0fa74a9d42bcb190db7250bf49ecc
|
https://github.com/habernal/confusion-matrix/blob/d0310f0aeda0fa74a9d42bcb190db7250bf49ecc/src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java#L335-L351
|
6,674 |
habernal/confusion-matrix
|
src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java
|
ConfusionMatrix.getCohensKappa
|
public double getCohensKappa()
{
// compute p (which is actually accuracy)
double p = getAccuracy();
// System.out.println(p);
// compute pe
double pe = 0;
for (String label : this.allGoldLabels) {
double row = getRowSum(label);
double col = getColSum(label);
// System.out.println("Label " + label + ", sumCol: " + col + ", sumRow: " + row);
pe += (row * col) / getTotalSum();
}
pe = pe / getTotalSum();
return (p - pe) / (1 - pe);
}
|
java
|
public double getCohensKappa()
{
// compute p (which is actually accuracy)
double p = getAccuracy();
// System.out.println(p);
// compute pe
double pe = 0;
for (String label : this.allGoldLabels) {
double row = getRowSum(label);
double col = getColSum(label);
// System.out.println("Label " + label + ", sumCol: " + col + ", sumRow: " + row);
pe += (row * col) / getTotalSum();
}
pe = pe / getTotalSum();
return (p - pe) / (1 - pe);
}
|
[
"public",
"double",
"getCohensKappa",
"(",
")",
"{",
"// compute p (which is actually accuracy)",
"double",
"p",
"=",
"getAccuracy",
"(",
")",
";",
"//\t\tSystem.out.println(p);",
"// compute pe",
"double",
"pe",
"=",
"0",
";",
"for",
"(",
"String",
"label",
":",
"this",
".",
"allGoldLabels",
")",
"{",
"double",
"row",
"=",
"getRowSum",
"(",
"label",
")",
";",
"double",
"col",
"=",
"getColSum",
"(",
"label",
")",
";",
"//\t\t\tSystem.out.println(\"Label \" + label + \", sumCol: \" + col + \", sumRow: \" + row);",
"pe",
"+=",
"(",
"row",
"*",
"col",
")",
"/",
"getTotalSum",
"(",
")",
";",
"}",
"pe",
"=",
"pe",
"/",
"getTotalSum",
"(",
")",
";",
"return",
"(",
"p",
"-",
"pe",
")",
"/",
"(",
"1",
"-",
"pe",
")",
";",
"}"
] |
Computes Cohen's Kappa
@return double
|
[
"Computes",
"Cohen",
"s",
"Kappa"
] |
d0310f0aeda0fa74a9d42bcb190db7250bf49ecc
|
https://github.com/habernal/confusion-matrix/blob/d0310f0aeda0fa74a9d42bcb190db7250bf49ecc/src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java#L444-L465
|
6,675 |
habernal/confusion-matrix
|
src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java
|
ConfusionMatrix.toStringLatex
|
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();
}
|
java
|
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();
}
|
[
"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
@return string
|
[
"Prints",
"in",
"LaTeX",
"format"
] |
d0310f0aeda0fa74a9d42bcb190db7250bf49ecc
|
https://github.com/habernal/confusion-matrix/blob/d0310f0aeda0fa74a9d42bcb190db7250bf49ecc/src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java#L556-L584
|
6,676 |
habernal/confusion-matrix
|
src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java
|
ConfusionMatrix.createCumulativeMatrix
|
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;
}
|
java
|
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;
}
|
[
"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
@param matrices confusion matrices
@return confusion matrix
|
[
"Sums",
"up",
"all",
"matrices",
"into",
"a",
"new",
"one"
] |
d0310f0aeda0fa74a9d42bcb190db7250bf49ecc
|
https://github.com/habernal/confusion-matrix/blob/d0310f0aeda0fa74a9d42bcb190db7250bf49ecc/src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java#L646-L659
|
6,677 |
habernal/confusion-matrix
|
src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java
|
ConfusionMatrix.parseFromText
|
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);
}
}
|
java
|
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);
}
}
|
[
"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
@param text input text
@return confusion matrix
@throws IllegalArgumentException if input is malformed
|
[
"Confusion",
"matrix",
"printed",
"to",
"text",
"by",
"toString",
"can",
"be",
"parsed",
"back"
] |
d0310f0aeda0fa74a9d42bcb190db7250bf49ecc
|
https://github.com/habernal/confusion-matrix/blob/d0310f0aeda0fa74a9d42bcb190db7250bf49ecc/src/main/java/com/github/habernal/confusionmatrix/ConfusionMatrix.java#L735-L781
|
6,678 |
orhanobut/wasp
|
wasp/src/main/java/com/orhanobut/wasp/InternalImageHandler.java
|
InternalImageHandler.initImageView
|
private void initImageView(ImageCreator waspImageCreator) {
int defaultImage = waspImageCreator.getDefaultImage();
ImageView imageView = waspImageCreator.getImageView();
if (defaultImage != 0) {
imageView.setImageResource(defaultImage);
return;
}
imageView.setImageBitmap(null);
}
|
java
|
private void initImageView(ImageCreator waspImageCreator) {
int defaultImage = waspImageCreator.getDefaultImage();
ImageView imageView = waspImageCreator.getImageView();
if (defaultImage != 0) {
imageView.setImageResource(defaultImage);
return;
}
imageView.setImageBitmap(null);
}
|
[
"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
|
[
"clear",
"the",
"target",
"by",
"setting",
"null",
"or",
"default",
"placeholder"
] |
295d8747aa7e410b185a620a6b87239816a38c11
|
https://github.com/orhanobut/wasp/blob/295d8747aa7e410b185a620a6b87239816a38c11/wasp/src/main/java/com/orhanobut/wasp/InternalImageHandler.java#L131-L139
|
6,679 |
nextreports/nextreports-server
|
src/ro/nextreports/server/util/ConnectionUtil.java
|
ConnectionUtil.createTempConnection
|
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) {
// wait as long as driver manager (not deterministic)
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 {
// wait just the number of seconds configured (deterministic)
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;
}
}
|
java
|
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) {
// wait as long as driver manager (not deterministic)
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 {
// wait just the number of seconds configured (deterministic)
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;
}
}
|
[
"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",
")",
"{",
"// wait as long as driver manager (not deterministic)",
"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",
"{",
"// wait just the number of seconds configured (deterministic)",
"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
|
[
"this",
"is",
"useful",
"if",
"we",
"want",
"to",
"test",
"the",
"connection"
] |
cfce12f5c6d52cb6a739388d50142c6e2e07c55e
|
https://github.com/nextreports/nextreports-server/blob/cfce12f5c6d52cb6a739388d50142c6e2e07c55e/src/ro/nextreports/server/util/ConnectionUtil.java#L169-L231
|
6,680 |
nextreports/nextreports-server
|
src/ro/nextreports/server/util/FileUtil.java
|
FileUtil.copyDirToDir
|
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);
}
}
}
|
java
|
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);
}
}
}
|
[
"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!
|
[
"dest",
"directory",
"must",
"be",
"already",
"created!"
] |
cfce12f5c6d52cb6a739388d50142c6e2e07c55e
|
https://github.com/nextreports/nextreports-server/blob/cfce12f5c6d52cb6a739388d50142c6e2e07c55e/src/ro/nextreports/server/util/FileUtil.java#L242-L263
|
6,681 |
nextreports/nextreports-server
|
src/ro/nextreports/server/util/FileUtil.java
|
FileUtil.deleteDir
|
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;
}
}
}
// The directory is now empty so delete it
return dir.delete();
}
|
java
|
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;
}
}
}
// The directory is now empty so delete it
return dir.delete();
}
|
[
"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",
";",
"}",
"}",
"}",
"// The directory is now empty so delete it",
"return",
"dir",
".",
"delete",
"(",
")",
";",
"}"
] |
If a deletion fails, the method stops attempting to delete and returns false.
|
[
"If",
"a",
"deletion",
"fails",
"the",
"method",
"stops",
"attempting",
"to",
"delete",
"and",
"returns",
"false",
"."
] |
cfce12f5c6d52cb6a739388d50142c6e2e07c55e
|
https://github.com/nextreports/nextreports-server/blob/cfce12f5c6d52cb6a739388d50142c6e2e07c55e/src/ro/nextreports/server/util/FileUtil.java#L326-L339
|
6,682 |
nextreports/nextreports-server
|
src/ro/nextreports/server/web/dashboard/DashboardUtil.java
|
DashboardUtil.getEntity
|
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;
}
|
java
|
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;
}
|
[
"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
|
[
"if",
"it",
"is",
"not",
"set",
"we",
"load",
"it",
"and",
"we",
"set",
"it",
"on",
"widget"
] |
cfce12f5c6d52cb6a739388d50142c6e2e07c55e
|
https://github.com/nextreports/nextreports-server/blob/cfce12f5c6d52cb6a739388d50142c6e2e07c55e/src/ro/nextreports/server/web/dashboard/DashboardUtil.java#L74-L86
|
6,683 |
nextreports/nextreports-server
|
src/ro/nextreports/server/web/core/EntityBrowserPanel.java
|
EntityBrowserPanel.selectEntity
|
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"));
// reset
SectionContextUtil.setSelectedEntityPath(sectionId, null);
}
}
|
java
|
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"));
// reset
SectionContextUtil.setSelectedEntityPath(sectionId, null);
}
}
|
[
"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\"",
")",
")",
";",
"// reset",
"SectionContextUtil",
".",
"setSelectedEntityPath",
"(",
"sectionId",
",",
"null",
")",
";",
"}",
"}"
] |
select entity from GoTo actions
|
[
"select",
"entity",
"from",
"GoTo",
"actions"
] |
cfce12f5c6d52cb6a739388d50142c6e2e07c55e
|
https://github.com/nextreports/nextreports-server/blob/cfce12f5c6d52cb6a739388d50142c6e2e07c55e/src/ro/nextreports/server/web/core/EntityBrowserPanel.java#L347-L359
|
6,684 |
nextreports/nextreports-server
|
src/ro/nextreports/server/web/analysis/util/DatabaseUtil.java
|
DatabaseUtil.removeGroupColumns
|
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);
}
|
java
|
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);
}
|
[
"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
|
[
"Group",
"by",
"columns",
"must",
"be",
"removed",
"if",
"the",
"columns",
"from",
"select",
"sql",
"are",
"deleted"
] |
cfce12f5c6d52cb6a739388d50142c6e2e07c55e
|
https://github.com/nextreports/nextreports-server/blob/cfce12f5c6d52cb6a739388d50142c6e2e07c55e/src/ro/nextreports/server/web/analysis/util/DatabaseUtil.java#L203-L211
|
6,685 |
hexagonframework/spring-data-ebean
|
src/main/java/org/springframework/data/ebean/util/Converters.java
|
Converters.convertToEbeanOrderBy
|
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));
}
|
java
|
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));
}
|
[
"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.
@param sort
@param <T>
@return
|
[
"Convert",
"spring",
"data",
"Sort",
"to",
"Ebean",
"OrderBy",
"."
] |
dd11b97654982403b50dd1d5369cadad71fce410
|
https://github.com/hexagonframework/spring-data-ebean/blob/dd11b97654982403b50dd1d5369cadad71fce410/src/main/java/org/springframework/data/ebean/util/Converters.java#L45-L57
|
6,686 |
hexagonframework/spring-data-ebean
|
src/main/java/org/springframework/data/ebean/util/Converters.java
|
Converters.convertToSpringDataPage
|
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());
}
|
java
|
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());
}
|
[
"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.
@param pagedList
@param sort
@param <T>
@return
|
[
"Convert",
"Ebean",
"PagedList",
"with",
"Sort",
"to",
"Spring",
"data",
"Page",
"."
] |
dd11b97654982403b50dd1d5369cadad71fce410
|
https://github.com/hexagonframework/spring-data-ebean/blob/dd11b97654982403b50dd1d5369cadad71fce410/src/main/java/org/springframework/data/ebean/util/Converters.java#L67-L71
|
6,687 |
nextreports/nextreports-server
|
src/ro/nextreports/server/web/NextServerConfiguration.java
|
NextServerConfiguration.getConfiguration
|
public Configuration getConfiguration() {
if (configuration == null) {
try {
configuration = new PropertiesConfiguration(getClass().getResource("/nextserver.properties"));
} catch (ConfigurationException e) {
throw new RuntimeException(e);
}
}
return configuration;
}
|
java
|
public Configuration getConfiguration() {
if (configuration == null) {
try {
configuration = new PropertiesConfiguration(getClass().getResource("/nextserver.properties"));
} catch (ConfigurationException e) {
throw new RuntimeException(e);
}
}
return configuration;
}
|
[
"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
|
[
"used",
"by",
"StorageUpdate9",
"to",
"put",
"existing",
"properties",
"inside",
"JCR"
] |
cfce12f5c6d52cb6a739388d50142c6e2e07c55e
|
https://github.com/nextreports/nextreports-server/blob/cfce12f5c6d52cb6a739388d50142c6e2e07c55e/src/ro/nextreports/server/web/NextServerConfiguration.java#L41-L50
|
6,688 |
nextreports/nextreports-server
|
src/ro/nextreports/server/distribution/SmtpDistributor.java
|
SmtpDistributor.afterDistribute
|
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);
}
}
}
|
java
|
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);
}
}
}
|
[
"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
|
[
"update",
"acl",
"for",
"run",
"report",
"history"
] |
cfce12f5c6d52cb6a739388d50142c6e2e07c55e
|
https://github.com/nextreports/nextreports-server/blob/cfce12f5c6d52cb6a739388d50142c6e2e07c55e/src/ro/nextreports/server/distribution/SmtpDistributor.java#L170-L178
|
6,689 |
nextreports/nextreports-server
|
src/ro/nextreports/server/util/ChartUtil.java
|
ChartUtil.getGlobalRuntimeModel
|
public static WidgetRuntimeModel getGlobalRuntimeModel(Settings settings, String dashboardId, ReportService reportService, DataSourceService dataSourceService, DashboardService dashboardService) {
WidgetRuntimeModel runtimeModel = new WidgetRuntimeModel();
// must get dashboard from storage because when we add/remove widgets to a dashboard ,
// we do not refresh entire DashboardPanel, so dashboard.getWidgets() will not see the modifications
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);
// test to see if an entity used in a widget was deleted
for (int i=0, n=widgets.size(); i<n; i++) {
if (((EntityWidget)widgets.get(i)).getEntity() == null) {
return runtimeModel;
}
}
// use the parameters values of the first entity
Map<String, Object> parameterValues = firstWidget.getQueryRuntime().getParametersValues();
Map<String, Boolean> dynamicMap = firstWidget.getQueryRuntime().getDynamicMap();
// data source is used only if parameter has a source sql
// we do not consider widgets with different data sources in this case
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;
}
}
|
java
|
public static WidgetRuntimeModel getGlobalRuntimeModel(Settings settings, String dashboardId, ReportService reportService, DataSourceService dataSourceService, DashboardService dashboardService) {
WidgetRuntimeModel runtimeModel = new WidgetRuntimeModel();
// must get dashboard from storage because when we add/remove widgets to a dashboard ,
// we do not refresh entire DashboardPanel, so dashboard.getWidgets() will not see the modifications
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);
// test to see if an entity used in a widget was deleted
for (int i=0, n=widgets.size(); i<n; i++) {
if (((EntityWidget)widgets.get(i)).getEntity() == null) {
return runtimeModel;
}
}
// use the parameters values of the first entity
Map<String, Object> parameterValues = firstWidget.getQueryRuntime().getParametersValues();
Map<String, Boolean> dynamicMap = firstWidget.getQueryRuntime().getDynamicMap();
// data source is used only if parameter has a source sql
// we do not consider widgets with different data sources in this case
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;
}
}
|
[
"public",
"static",
"WidgetRuntimeModel",
"getGlobalRuntimeModel",
"(",
"Settings",
"settings",
",",
"String",
"dashboardId",
",",
"ReportService",
"reportService",
",",
"DataSourceService",
"dataSourceService",
",",
"DashboardService",
"dashboardService",
")",
"{",
"WidgetRuntimeModel",
"runtimeModel",
"=",
"new",
"WidgetRuntimeModel",
"(",
")",
";",
"// must get dashboard from storage because when we add/remove widgets to a dashboard , ",
"// we do not refresh entire DashboardPanel, so dashboard.getWidgets() will not see the modifications",
"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",
")",
";",
"// test to see if an entity used in a widget was deleted",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"widgets",
".",
"size",
"(",
")",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"if",
"(",
"(",
"(",
"EntityWidget",
")",
"widgets",
".",
"get",
"(",
"i",
")",
")",
".",
"getEntity",
"(",
")",
"==",
"null",
")",
"{",
"return",
"runtimeModel",
";",
"}",
"}",
"// use the parameters values of the first entity",
"Map",
"<",
"String",
",",
"Object",
">",
"parameterValues",
"=",
"firstWidget",
".",
"getQueryRuntime",
"(",
")",
".",
"getParametersValues",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Boolean",
">",
"dynamicMap",
"=",
"firstWidget",
".",
"getQueryRuntime",
"(",
")",
".",
"getDynamicMap",
"(",
")",
";",
"// data source is used only if parameter has a source sql",
"// we do not consider widgets with different data sources in this case",
"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
|
[
"it",
"is",
"partial",
"because",
"we",
"do",
"not",
"have",
"chart",
"type",
"or",
"some",
"of",
"the",
"parameters"
] |
cfce12f5c6d52cb6a739388d50142c6e2e07c55e
|
https://github.com/nextreports/nextreports-server/blob/cfce12f5c6d52cb6a739388d50142c6e2e07c55e/src/ro/nextreports/server/util/ChartUtil.java#L296-L350
|
6,690 |
nextreports/nextreports-server
|
src/ro/nextreports/server/report/jasper/JasperReportsUtil.java
|
JasperReportsUtil.getValueClassName
|
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);
//System.out.println("*** newType=" + list.get(0).getType());
return list.get(0).getType();
} finally {
ConnectionUtil.closeConnection(con);
}
}
} catch (Exception ex) {
ex.printStackTrace();
LOG.error(ex.getMessage(), ex);
throw ex;
}
return null;
}
|
java
|
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);
//System.out.println("*** newType=" + list.get(0).getType());
return list.get(0).getType();
} finally {
ConnectionUtil.closeConnection(con);
}
}
} catch (Exception ex) {
ex.printStackTrace();
LOG.error(ex.getMessage(), ex);
throw ex;
}
return null;
}
|
[
"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",
")",
";",
"//System.out.println(\"*** newType=\" + list.get(0).getType());",
"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
|
[
"get",
"value",
"class",
"name",
"for",
"the",
"first",
"column",
"on",
"a",
"select",
"sql",
"query"
] |
cfce12f5c6d52cb6a739388d50142c6e2e07c55e
|
https://github.com/nextreports/nextreports-server/blob/cfce12f5c6d52cb6a739388d50142c6e2e07c55e/src/ro/nextreports/server/report/jasper/JasperReportsUtil.java#L522-L549
|
6,691 |
hexagonframework/spring-data-ebean
|
src/main/java/org/springframework/data/ebean/repository/query/ParameterBinder.java
|
ParameterBinder.bind
|
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);
}
}
|
java
|
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);
}
}
|
[
"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.
@param query
@param parameter
@param value
@param position
|
[
"Perform",
"the",
"actual",
"query",
"parameter",
"binding",
"."
] |
dd11b97654982403b50dd1d5369cadad71fce410
|
https://github.com/hexagonframework/spring-data-ebean/blob/dd11b97654982403b50dd1d5369cadad71fce410/src/main/java/org/springframework/data/ebean/repository/query/ParameterBinder.java#L146-L152
|
6,692 |
nextreports/nextreports-server
|
src/ro/nextreports/server/web/dashboard/display/DisplayHTML5Panel.java
|
DisplayHTML5Panel.getResizeJavaScript
|
private String getResizeJavaScript() {
StringBuilder sb = new StringBuilder();
sb.append("$(window).bind(\'resizeEnd\',function(){");
sb.append(getDisplayCall());
sb.append("});");
return sb.toString();
}
|
java
|
private String getResizeJavaScript() {
StringBuilder sb = new StringBuilder();
sb.append("$(window).bind(\'resizeEnd\',function(){");
sb.append(getDisplayCall());
sb.append("});");
return sb.toString();
}
|
[
"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!
|
[
"display",
"call",
"will",
"be",
"made",
"only",
"when",
"resize",
"event",
"finished!"
] |
cfce12f5c6d52cb6a739388d50142c6e2e07c55e
|
https://github.com/nextreports/nextreports-server/blob/cfce12f5c6d52cb6a739388d50142c6e2e07c55e/src/ro/nextreports/server/web/dashboard/display/DisplayHTML5Panel.java#L78-L84
|
6,693 |
nextreports/nextreports-server
|
src/ro/nextreports/server/report/next/NextUtil.java
|
NextUtil.renameImagesAsUnique
|
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;
}
|
java
|
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;
}
|
[
"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
|
[
"Rename",
"images",
"so",
"that",
"their",
"name",
"is",
"unique"
] |
cfce12f5c6d52cb6a739388d50142c6e2e07c55e
|
https://github.com/nextreports/nextreports-server/blob/cfce12f5c6d52cb6a739388d50142c6e2e07c55e/src/ro/nextreports/server/report/next/NextUtil.java#L135-L164
|
6,694 |
nextreports/nextreports-server
|
src/ro/nextreports/server/web/dashboard/chart/ChartHTML5Panel.java
|
ChartHTML5Panel.getResizeJavaScript
|
private String getResizeJavaScript() {
StringBuilder sb = new StringBuilder();
sb.append("$(window).bind(\'resizeEnd\',function(){");
sb.append(getNextChartJavascriptCall());
sb.append("});");
return sb.toString();
}
|
java
|
private String getResizeJavaScript() {
StringBuilder sb = new StringBuilder();
sb.append("$(window).bind(\'resizeEnd\',function(){");
sb.append(getNextChartJavascriptCall());
sb.append("});");
return sb.toString();
}
|
[
"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!
|
[
"chart",
"call",
"will",
"be",
"made",
"only",
"when",
"resize",
"event",
"finished!"
] |
cfce12f5c6d52cb6a739388d50142c6e2e07c55e
|
https://github.com/nextreports/nextreports-server/blob/cfce12f5c6d52cb6a739388d50142c6e2e07c55e/src/ro/nextreports/server/web/dashboard/chart/ChartHTML5Panel.java#L104-L110
|
6,695 |
hexagonframework/spring-data-ebean
|
src/main/java/org/springframework/data/ebean/util/ExampleExpressionBuilder.java
|
ExampleExpressionBuilder.exampleExpression
|
public static <T> ExampleExpression exampleExpression(EbeanServer ebeanServer, Example<T> example) {
LikeType likeType;
switch (example.getMatcher().getDefaultStringMatcher()) {
case EXACT:
likeType = LikeType.EQUAL_TO;
break;
case CONTAINING:
likeType = LikeType.CONTAINS;
break;
case STARTING:
likeType = LikeType.STARTS_WITH;
break;
case ENDING:
likeType = LikeType.ENDS_WITH;
break;
default:
likeType = LikeType.RAW;
break;
}
return ebeanServer.getExpressionFactory().exampleLike(example.getProbe(),
example.getMatcher().isIgnoreCaseEnabled(),
likeType);
}
|
java
|
public static <T> ExampleExpression exampleExpression(EbeanServer ebeanServer, Example<T> example) {
LikeType likeType;
switch (example.getMatcher().getDefaultStringMatcher()) {
case EXACT:
likeType = LikeType.EQUAL_TO;
break;
case CONTAINING:
likeType = LikeType.CONTAINS;
break;
case STARTING:
likeType = LikeType.STARTS_WITH;
break;
case ENDING:
likeType = LikeType.ENDS_WITH;
break;
default:
likeType = LikeType.RAW;
break;
}
return ebeanServer.getExpressionFactory().exampleLike(example.getProbe(),
example.getMatcher().isIgnoreCaseEnabled(),
likeType);
}
|
[
"public",
"static",
"<",
"T",
">",
"ExampleExpression",
"exampleExpression",
"(",
"EbeanServer",
"ebeanServer",
",",
"Example",
"<",
"T",
">",
"example",
")",
"{",
"LikeType",
"likeType",
";",
"switch",
"(",
"example",
".",
"getMatcher",
"(",
")",
".",
"getDefaultStringMatcher",
"(",
")",
")",
"{",
"case",
"EXACT",
":",
"likeType",
"=",
"LikeType",
".",
"EQUAL_TO",
";",
"break",
";",
"case",
"CONTAINING",
":",
"likeType",
"=",
"LikeType",
".",
"CONTAINS",
";",
"break",
";",
"case",
"STARTING",
":",
"likeType",
"=",
"LikeType",
".",
"STARTS_WITH",
";",
"break",
";",
"case",
"ENDING",
":",
"likeType",
"=",
"LikeType",
".",
"ENDS_WITH",
";",
"break",
";",
"default",
":",
"likeType",
"=",
"LikeType",
".",
"RAW",
";",
"break",
";",
"}",
"return",
"ebeanServer",
".",
"getExpressionFactory",
"(",
")",
".",
"exampleLike",
"(",
"example",
".",
"getProbe",
"(",
")",
",",
"example",
".",
"getMatcher",
"(",
")",
".",
"isIgnoreCaseEnabled",
"(",
")",
",",
"likeType",
")",
";",
"}"
] |
Return a ExampleExpression from Spring data Example
@param ebeanServer
@param example
@param <T>
@return
|
[
"Return",
"a",
"ExampleExpression",
"from",
"Spring",
"data",
"Example"
] |
dd11b97654982403b50dd1d5369cadad71fce410
|
https://github.com/hexagonframework/spring-data-ebean/blob/dd11b97654982403b50dd1d5369cadad71fce410/src/main/java/org/springframework/data/ebean/util/ExampleExpressionBuilder.java#L39-L61
|
6,696 |
nextreports/nextreports-server
|
src/ro/nextreports/server/web/dashboard/WidgetPopupMenuModel.java
|
WidgetPopupMenuModel.resetSettings
|
private void resetSettings(FeedbackPanel feedbackPanel, Component component, Widget widget, AjaxRequestTarget target) {
// on reset settings we must delete UserWidgetParameters if any
try {
UserWidgetParameters wp = dashboardService.getUserWidgetParameters(widget.getId());
if (wp != null) {
storageService.removeEntityById(wp.getId());
dashboardService.resetCache(widget.getId());
final WidgetPanel widgetPanel = component.findParent(WidgetPanel.class);
ModalWindow.closeCurrent(target);
//target.add(widgetPanel);
// ChartRendererPanel uses container.replace("chart")
// we should add widgetView again instead of a simple target.add(widgetPanel), otherwise we will see two refreshes
widgetPanel.refresh(target);
return;
}
} catch (NotFoundException ex) {
// should not happen
Log.error(ex.getMessage(), ex);
}
if ((widget instanceof DrillDownWidget) && (((DrillDownWidget) widget).getEntity() instanceof Chart)) {
final WidgetPanel widgetPanel = component.findParent(WidgetPanel.class);
ChartUtil.updateWidget(widget, ChartUtil.getRuntimeModel(storageService.getSettings(), (EntityWidget) widget,
reportService, dataSourceService, false));
try {
if (component.findParent(DashboardPanel.class) == null) {
errorRefresh();
target.add(feedbackPanel);
return;
} else {
ModalWindow.closeCurrent(target);
}
dashboardService.modifyWidget(getDashboardId(widget.getId()), widget);
} catch (NotFoundException e) {
// never happening
}
widgetPanel.refresh(target);
} else if (widget instanceof ChartWidget) {
final WidgetPanel widgetPanel = component.findParent(WidgetPanel.class);
if (component.findParent(DashboardPanel.class) == null) {
errorRefresh();
target.add(feedbackPanel);
return;
} else {
ModalWindow.closeCurrent(target);
}
ChartUtil.updateWidget(widget, ChartUtil.getDefaultRuntimeModel(storageService.getSettings(), (ChartWidget) widget,
reportService, dataSourceService));
try {
dashboardService.modifyWidget(getDashboardId(widget.getId()), widget);
} catch (NotFoundException e) {
// never happening
}
//target.add(widgetPanel);
// ChartRendererPanel uses container.replace("chart")
// we should add widgetView again instead of a simple target.add(widgetPanel), otherwise we will see two refreshes
widgetPanel.refresh(target);
}
}
|
java
|
private void resetSettings(FeedbackPanel feedbackPanel, Component component, Widget widget, AjaxRequestTarget target) {
// on reset settings we must delete UserWidgetParameters if any
try {
UserWidgetParameters wp = dashboardService.getUserWidgetParameters(widget.getId());
if (wp != null) {
storageService.removeEntityById(wp.getId());
dashboardService.resetCache(widget.getId());
final WidgetPanel widgetPanel = component.findParent(WidgetPanel.class);
ModalWindow.closeCurrent(target);
//target.add(widgetPanel);
// ChartRendererPanel uses container.replace("chart")
// we should add widgetView again instead of a simple target.add(widgetPanel), otherwise we will see two refreshes
widgetPanel.refresh(target);
return;
}
} catch (NotFoundException ex) {
// should not happen
Log.error(ex.getMessage(), ex);
}
if ((widget instanceof DrillDownWidget) && (((DrillDownWidget) widget).getEntity() instanceof Chart)) {
final WidgetPanel widgetPanel = component.findParent(WidgetPanel.class);
ChartUtil.updateWidget(widget, ChartUtil.getRuntimeModel(storageService.getSettings(), (EntityWidget) widget,
reportService, dataSourceService, false));
try {
if (component.findParent(DashboardPanel.class) == null) {
errorRefresh();
target.add(feedbackPanel);
return;
} else {
ModalWindow.closeCurrent(target);
}
dashboardService.modifyWidget(getDashboardId(widget.getId()), widget);
} catch (NotFoundException e) {
// never happening
}
widgetPanel.refresh(target);
} else if (widget instanceof ChartWidget) {
final WidgetPanel widgetPanel = component.findParent(WidgetPanel.class);
if (component.findParent(DashboardPanel.class) == null) {
errorRefresh();
target.add(feedbackPanel);
return;
} else {
ModalWindow.closeCurrent(target);
}
ChartUtil.updateWidget(widget, ChartUtil.getDefaultRuntimeModel(storageService.getSettings(), (ChartWidget) widget,
reportService, dataSourceService));
try {
dashboardService.modifyWidget(getDashboardId(widget.getId()), widget);
} catch (NotFoundException e) {
// never happening
}
//target.add(widgetPanel);
// ChartRendererPanel uses container.replace("chart")
// we should add widgetView again instead of a simple target.add(widgetPanel), otherwise we will see two refreshes
widgetPanel.refresh(target);
}
}
|
[
"private",
"void",
"resetSettings",
"(",
"FeedbackPanel",
"feedbackPanel",
",",
"Component",
"component",
",",
"Widget",
"widget",
",",
"AjaxRequestTarget",
"target",
")",
"{",
"// on reset settings we must delete UserWidgetParameters if any",
"try",
"{",
"UserWidgetParameters",
"wp",
"=",
"dashboardService",
".",
"getUserWidgetParameters",
"(",
"widget",
".",
"getId",
"(",
")",
")",
";",
"if",
"(",
"wp",
"!=",
"null",
")",
"{",
"storageService",
".",
"removeEntityById",
"(",
"wp",
".",
"getId",
"(",
")",
")",
";",
"dashboardService",
".",
"resetCache",
"(",
"widget",
".",
"getId",
"(",
")",
")",
";",
"final",
"WidgetPanel",
"widgetPanel",
"=",
"component",
".",
"findParent",
"(",
"WidgetPanel",
".",
"class",
")",
";",
"ModalWindow",
".",
"closeCurrent",
"(",
"target",
")",
";",
"//target.add(widgetPanel);",
"// ChartRendererPanel uses container.replace(\"chart\")",
"// we should add widgetView again instead of a simple target.add(widgetPanel), otherwise we will see two refreshes",
"widgetPanel",
".",
"refresh",
"(",
"target",
")",
";",
"return",
";",
"}",
"}",
"catch",
"(",
"NotFoundException",
"ex",
")",
"{",
"// should not happen",
"Log",
".",
"error",
"(",
"ex",
".",
"getMessage",
"(",
")",
",",
"ex",
")",
";",
"}",
"if",
"(",
"(",
"widget",
"instanceof",
"DrillDownWidget",
")",
"&&",
"(",
"(",
"(",
"DrillDownWidget",
")",
"widget",
")",
".",
"getEntity",
"(",
")",
"instanceof",
"Chart",
")",
")",
"{",
"final",
"WidgetPanel",
"widgetPanel",
"=",
"component",
".",
"findParent",
"(",
"WidgetPanel",
".",
"class",
")",
";",
"ChartUtil",
".",
"updateWidget",
"(",
"widget",
",",
"ChartUtil",
".",
"getRuntimeModel",
"(",
"storageService",
".",
"getSettings",
"(",
")",
",",
"(",
"EntityWidget",
")",
"widget",
",",
"reportService",
",",
"dataSourceService",
",",
"false",
")",
")",
";",
"try",
"{",
"if",
"(",
"component",
".",
"findParent",
"(",
"DashboardPanel",
".",
"class",
")",
"==",
"null",
")",
"{",
"errorRefresh",
"(",
")",
";",
"target",
".",
"add",
"(",
"feedbackPanel",
")",
";",
"return",
";",
"}",
"else",
"{",
"ModalWindow",
".",
"closeCurrent",
"(",
"target",
")",
";",
"}",
"dashboardService",
".",
"modifyWidget",
"(",
"getDashboardId",
"(",
"widget",
".",
"getId",
"(",
")",
")",
",",
"widget",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"e",
")",
"{",
"// never happening",
"}",
"widgetPanel",
".",
"refresh",
"(",
"target",
")",
";",
"}",
"else",
"if",
"(",
"widget",
"instanceof",
"ChartWidget",
")",
"{",
"final",
"WidgetPanel",
"widgetPanel",
"=",
"component",
".",
"findParent",
"(",
"WidgetPanel",
".",
"class",
")",
";",
"if",
"(",
"component",
".",
"findParent",
"(",
"DashboardPanel",
".",
"class",
")",
"==",
"null",
")",
"{",
"errorRefresh",
"(",
")",
";",
"target",
".",
"add",
"(",
"feedbackPanel",
")",
";",
"return",
";",
"}",
"else",
"{",
"ModalWindow",
".",
"closeCurrent",
"(",
"target",
")",
";",
"}",
"ChartUtil",
".",
"updateWidget",
"(",
"widget",
",",
"ChartUtil",
".",
"getDefaultRuntimeModel",
"(",
"storageService",
".",
"getSettings",
"(",
")",
",",
"(",
"ChartWidget",
")",
"widget",
",",
"reportService",
",",
"dataSourceService",
")",
")",
";",
"try",
"{",
"dashboardService",
".",
"modifyWidget",
"(",
"getDashboardId",
"(",
"widget",
".",
"getId",
"(",
")",
")",
",",
"widget",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"e",
")",
"{",
"// never happening",
"}",
"//target.add(widgetPanel);",
"// ChartRendererPanel uses container.replace(\"chart\")",
"// we should add widgetView again instead of a simple target.add(widgetPanel), otherwise we will see two refreshes",
"widgetPanel",
".",
"refresh",
"(",
"target",
")",
";",
"}",
"}"
] |
return true if we reset settings for a dashboard link with UserWidgetParameters
|
[
"return",
"true",
"if",
"we",
"reset",
"settings",
"for",
"a",
"dashboard",
"link",
"with",
"UserWidgetParameters"
] |
cfce12f5c6d52cb6a739388d50142c6e2e07c55e
|
https://github.com/nextreports/nextreports-server/blob/cfce12f5c6d52cb6a739388d50142c6e2e07c55e/src/ro/nextreports/server/web/dashboard/WidgetPopupMenuModel.java#L341-L398
|
6,697 |
nextreports/nextreports-server
|
src/ro/nextreports/server/security/ExternalAuthenticationProvider.java
|
ExternalAuthenticationProvider.syncUsers
|
public void syncUsers(boolean createUsers, boolean deleteUsers) {
List<String> realmUserNames = externalUsersService.getUserNames();
if (LOG.isDebugEnabled()) {
LOG.debug("Synchronize for realm=" + realm + " users=" + realmUserNames.size() + " (createUsers = " + createUsers + ", deleteUsers = " + deleteUsers + ")");
}
for (String username : realmUserNames) {
User user = externalUsersService.getUser(username);
applyPatch(user);
if (createUsers) {
createOrUpdateUser(user);
} else if (userExists(user.getUsername())) {
updateUser(user);
}
List<String> groupNames = externalUsersService.getGroupNames(username);
updateUserGroups(username, groupNames);
}
if (deleteUsers) {
deleteAsyncUsers(realmUserNames);
}
}
|
java
|
public void syncUsers(boolean createUsers, boolean deleteUsers) {
List<String> realmUserNames = externalUsersService.getUserNames();
if (LOG.isDebugEnabled()) {
LOG.debug("Synchronize for realm=" + realm + " users=" + realmUserNames.size() + " (createUsers = " + createUsers + ", deleteUsers = " + deleteUsers + ")");
}
for (String username : realmUserNames) {
User user = externalUsersService.getUser(username);
applyPatch(user);
if (createUsers) {
createOrUpdateUser(user);
} else if (userExists(user.getUsername())) {
updateUser(user);
}
List<String> groupNames = externalUsersService.getGroupNames(username);
updateUserGroups(username, groupNames);
}
if (deleteUsers) {
deleteAsyncUsers(realmUserNames);
}
}
|
[
"public",
"void",
"syncUsers",
"(",
"boolean",
"createUsers",
",",
"boolean",
"deleteUsers",
")",
"{",
"List",
"<",
"String",
">",
"realmUserNames",
"=",
"externalUsersService",
".",
"getUserNames",
"(",
")",
";",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Synchronize for realm=\"",
"+",
"realm",
"+",
"\" users=\"",
"+",
"realmUserNames",
".",
"size",
"(",
")",
"+",
"\" (createUsers = \"",
"+",
"createUsers",
"+",
"\", deleteUsers = \"",
"+",
"deleteUsers",
"+",
"\")\"",
")",
";",
"}",
"for",
"(",
"String",
"username",
":",
"realmUserNames",
")",
"{",
"User",
"user",
"=",
"externalUsersService",
".",
"getUser",
"(",
"username",
")",
";",
"applyPatch",
"(",
"user",
")",
";",
"if",
"(",
"createUsers",
")",
"{",
"createOrUpdateUser",
"(",
"user",
")",
";",
"}",
"else",
"if",
"(",
"userExists",
"(",
"user",
".",
"getUsername",
"(",
")",
")",
")",
"{",
"updateUser",
"(",
"user",
")",
";",
"}",
"List",
"<",
"String",
">",
"groupNames",
"=",
"externalUsersService",
".",
"getGroupNames",
"(",
"username",
")",
";",
"updateUserGroups",
"(",
"username",
",",
"groupNames",
")",
";",
"}",
"if",
"(",
"deleteUsers",
")",
"{",
"deleteAsyncUsers",
"(",
"realmUserNames",
")",
";",
"}",
"}"
] |
from NextServerSession doesn't work
|
[
"from",
"NextServerSession",
"doesn",
"t",
"work"
] |
cfce12f5c6d52cb6a739388d50142c6e2e07c55e
|
https://github.com/nextreports/nextreports-server/blob/cfce12f5c6d52cb6a739388d50142c6e2e07c55e/src/ro/nextreports/server/security/ExternalAuthenticationProvider.java#L148-L170
|
6,698 |
hexagonframework/spring-data-ebean
|
src/main/java/org/springframework/data/ebean/querychannel/EbeanQueryChannelService.java
|
EbeanQueryChannelService.containsIfNoneBlank
|
public static <T> ExpressionList<T> containsIfNoneBlank(ExpressionList<T> expressionList,
String propertyName,
String value) {
Assert.notNull(expressionList, "expressionList must not null");
Assert.hasText(propertyName, "propertyName must not blank");
if (StringUtils.hasText(value)) {
return expressionList.contains(propertyName, value);
}
return expressionList;
}
|
java
|
public static <T> ExpressionList<T> containsIfNoneBlank(ExpressionList<T> expressionList,
String propertyName,
String value) {
Assert.notNull(expressionList, "expressionList must not null");
Assert.hasText(propertyName, "propertyName must not blank");
if (StringUtils.hasText(value)) {
return expressionList.contains(propertyName, value);
}
return expressionList;
}
|
[
"public",
"static",
"<",
"T",
">",
"ExpressionList",
"<",
"T",
">",
"containsIfNoneBlank",
"(",
"ExpressionList",
"<",
"T",
">",
"expressionList",
",",
"String",
"propertyName",
",",
"String",
"value",
")",
"{",
"Assert",
".",
"notNull",
"(",
"expressionList",
",",
"\"expressionList must not null\"",
")",
";",
"Assert",
".",
"hasText",
"(",
"propertyName",
",",
"\"propertyName must not blank\"",
")",
";",
"if",
"(",
"StringUtils",
".",
"hasText",
"(",
"value",
")",
")",
"{",
"return",
"expressionList",
".",
"contains",
"(",
"propertyName",
",",
"value",
")",
";",
"}",
"return",
"expressionList",
";",
"}"
] |
Return a ExpressionList specifying propertyName contains value.
@param expressionList the ExpressionList to add contains expression
@param propertyName the property name of entity bean.
@param value contains value, like %value%.
@param <T> the type of entity.
@return a ExpressionList specifying propertyName contains value.
|
[
"Return",
"a",
"ExpressionList",
"specifying",
"propertyName",
"contains",
"value",
"."
] |
dd11b97654982403b50dd1d5369cadad71fce410
|
https://github.com/hexagonframework/spring-data-ebean/blob/dd11b97654982403b50dd1d5369cadad71fce410/src/main/java/org/springframework/data/ebean/querychannel/EbeanQueryChannelService.java#L251-L260
|
6,699 |
hexagonframework/spring-data-ebean
|
src/main/java/org/springframework/data/ebean/querychannel/EbeanQueryChannelService.java
|
EbeanQueryChannelService.eqIfNotNull
|
public static <T> ExpressionList<T> eqIfNotNull(ExpressionList<T> expressionList,
String propertyName,
Object value) {
Assert.notNull(expressionList, "expressionList must not null");
Assert.hasText(propertyName, "propertyName must not null");
if (value != null) {
return expressionList.eq(propertyName, value);
}
return expressionList;
}
|
java
|
public static <T> ExpressionList<T> eqIfNotNull(ExpressionList<T> expressionList,
String propertyName,
Object value) {
Assert.notNull(expressionList, "expressionList must not null");
Assert.hasText(propertyName, "propertyName must not null");
if (value != null) {
return expressionList.eq(propertyName, value);
}
return expressionList;
}
|
[
"public",
"static",
"<",
"T",
">",
"ExpressionList",
"<",
"T",
">",
"eqIfNotNull",
"(",
"ExpressionList",
"<",
"T",
">",
"expressionList",
",",
"String",
"propertyName",
",",
"Object",
"value",
")",
"{",
"Assert",
".",
"notNull",
"(",
"expressionList",
",",
"\"expressionList must not null\"",
")",
";",
"Assert",
".",
"hasText",
"(",
"propertyName",
",",
"\"propertyName must not null\"",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"return",
"expressionList",
".",
"eq",
"(",
"propertyName",
",",
"value",
")",
";",
"}",
"return",
"expressionList",
";",
"}"
] |
Return a ExpressionList specifying propertyName equals value.
@param expressionList the ExpressionList to add contains expression
@param propertyName the property name of entity bean.
@param value equals value
@param <T> the type of entity.
@return a ExpressionList specifying propertyName equals value.
|
[
"Return",
"a",
"ExpressionList",
"specifying",
"propertyName",
"equals",
"value",
"."
] |
dd11b97654982403b50dd1d5369cadad71fce410
|
https://github.com/hexagonframework/spring-data-ebean/blob/dd11b97654982403b50dd1d5369cadad71fce410/src/main/java/org/springframework/data/ebean/querychannel/EbeanQueryChannelService.java#L271-L280
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.