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
|
---|---|---|---|---|---|---|---|---|---|---|---|
3,900 |
Stratio/deep-spark
|
deep-commons/src/main/java/com/stratio/deep/commons/config/ExtractorConfig.java
|
ExtractorConfig.getStringArray
|
public String[] getStringArray(String key) {
try {
return getValue(String[].class, key);
} catch (ClassCastException e) {
return new String[] { getString(key) };
}
}
|
java
|
public String[] getStringArray(String key) {
try {
return getValue(String[].class, key);
} catch (ClassCastException e) {
return new String[] { getString(key) };
}
}
|
[
"public",
"String",
"[",
"]",
"getStringArray",
"(",
"String",
"key",
")",
"{",
"try",
"{",
"return",
"getValue",
"(",
"String",
"[",
"]",
".",
"class",
",",
"key",
")",
";",
"}",
"catch",
"(",
"ClassCastException",
"e",
")",
"{",
"return",
"new",
"String",
"[",
"]",
"{",
"getString",
"(",
"key",
")",
"}",
";",
"}",
"}"
] |
Get string array.
@param key the key
@return the string [ ]
|
[
"Get",
"string",
"array",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/config/ExtractorConfig.java#L144-L151
|
3,901 |
Stratio/deep-spark
|
deep-commons/src/main/java/com/stratio/deep/commons/config/ExtractorConfig.java
|
ExtractorConfig.getPair
|
public <K, V> Pair<K, V> getPair(String key, Class<K> keyClass, Class<V> valueClass) {
return getValue(Pair.class, key);
}
|
java
|
public <K, V> Pair<K, V> getPair(String key, Class<K> keyClass, Class<V> valueClass) {
return getValue(Pair.class, key);
}
|
[
"public",
"<",
"K",
",",
"V",
">",
"Pair",
"<",
"K",
",",
"V",
">",
"getPair",
"(",
"String",
"key",
",",
"Class",
"<",
"K",
">",
"keyClass",
",",
"Class",
"<",
"V",
">",
"valueClass",
")",
"{",
"return",
"getValue",
"(",
"Pair",
".",
"class",
",",
"key",
")",
";",
"}"
] |
Gets pair.
@param key the key
@param keyClass the key class
@param valueClass the value class
@return the pair
|
[
"Gets",
"pair",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/config/ExtractorConfig.java#L221-L223
|
3,902 |
Stratio/deep-spark
|
deep-jdbc/src/main/java/com/stratio/deep/jdbc/config/JdbcDeepJobConfig.java
|
JdbcDeepJobConfig.validate
|
private void validate() {
if(driverClass == null) {
throw new IllegalArgumentException("Driver class must be specified");
}
if(catalog == null || catalog.isEmpty()) {
throw new IllegalArgumentException("Schema name must be specified");
}
if(table == null || table.isEmpty()) {
throw new IllegalArgumentException("Table name must be specified");
}
if(connectionUrl == null || connectionUrl.isEmpty()) {
if((host != null && !host.isEmpty()) && (port > 0)) {
connectionUrl(getJdbcUrl());
} else {
throw new IllegalArgumentException("You must specify at least one of connectionUrl or host and port properties");
}
}
if(partitionKey == null && numPartitions > 1) {
throw new IllegalArgumentException("You must define a valid partition key for using more than one partition.");
}
}
|
java
|
private void validate() {
if(driverClass == null) {
throw new IllegalArgumentException("Driver class must be specified");
}
if(catalog == null || catalog.isEmpty()) {
throw new IllegalArgumentException("Schema name must be specified");
}
if(table == null || table.isEmpty()) {
throw new IllegalArgumentException("Table name must be specified");
}
if(connectionUrl == null || connectionUrl.isEmpty()) {
if((host != null && !host.isEmpty()) && (port > 0)) {
connectionUrl(getJdbcUrl());
} else {
throw new IllegalArgumentException("You must specify at least one of connectionUrl or host and port properties");
}
}
if(partitionKey == null && numPartitions > 1) {
throw new IllegalArgumentException("You must define a valid partition key for using more than one partition.");
}
}
|
[
"private",
"void",
"validate",
"(",
")",
"{",
"if",
"(",
"driverClass",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Driver class must be specified\"",
")",
";",
"}",
"if",
"(",
"catalog",
"==",
"null",
"||",
"catalog",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Schema name must be specified\"",
")",
";",
"}",
"if",
"(",
"table",
"==",
"null",
"||",
"table",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Table name must be specified\"",
")",
";",
"}",
"if",
"(",
"connectionUrl",
"==",
"null",
"||",
"connectionUrl",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"(",
"host",
"!=",
"null",
"&&",
"!",
"host",
".",
"isEmpty",
"(",
")",
")",
"&&",
"(",
"port",
">",
"0",
")",
")",
"{",
"connectionUrl",
"(",
"getJdbcUrl",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"You must specify at least one of connectionUrl or host and port properties\"",
")",
";",
"}",
"}",
"if",
"(",
"partitionKey",
"==",
"null",
"&&",
"numPartitions",
">",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"You must define a valid partition key for using more than one partition.\"",
")",
";",
"}",
"}"
] |
Validates configuration object.
|
[
"Validates",
"configuration",
"object",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-jdbc/src/main/java/com/stratio/deep/jdbc/config/JdbcDeepJobConfig.java#L194-L214
|
3,903 |
Stratio/deep-spark
|
deep-mongodb/src/main/java/com/stratio/deep/mongodb/config/MongoConfigFactory.java
|
MongoConfigFactory.createMongoDB
|
public static <T extends IDeepType> MongoDeepJobConfig<T> createMongoDB(Class<T> entityClass) {
return new MongoDeepJobConfig<>(entityClass);
}
|
java
|
public static <T extends IDeepType> MongoDeepJobConfig<T> createMongoDB(Class<T> entityClass) {
return new MongoDeepJobConfig<>(entityClass);
}
|
[
"public",
"static",
"<",
"T",
"extends",
"IDeepType",
">",
"MongoDeepJobConfig",
"<",
"T",
">",
"createMongoDB",
"(",
"Class",
"<",
"T",
">",
"entityClass",
")",
"{",
"return",
"new",
"MongoDeepJobConfig",
"<>",
"(",
"entityClass",
")",
";",
"}"
] |
Creates a new entity-based MongoDB job configuration object.
@param entityClass the class instance of the entity class that will be used to map db objects to Java objects.
@param <T> the generic type of the entity object implementing IDeepType.
@return a new entity-based MongoDB job configuration object.
|
[
"Creates",
"a",
"new",
"entity",
"-",
"based",
"MongoDB",
"job",
"configuration",
"object",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/config/MongoConfigFactory.java#L50-L52
|
3,904 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/extractor/CassandraExtractor.java
|
CassandraExtractor.getPreferredLocations
|
@Override
public List<String> getPreferredLocations(Partition tokenRange) {
return ((DeepPartition) tokenRange).splitWrapper().getReplicas();
}
|
java
|
@Override
public List<String> getPreferredLocations(Partition tokenRange) {
return ((DeepPartition) tokenRange).splitWrapper().getReplicas();
}
|
[
"@",
"Override",
"public",
"List",
"<",
"String",
">",
"getPreferredLocations",
"(",
"Partition",
"tokenRange",
")",
"{",
"return",
"(",
"(",
"DeepPartition",
")",
"tokenRange",
")",
".",
"splitWrapper",
"(",
")",
".",
"getReplicas",
"(",
")",
";",
"}"
] |
Returns a list of hosts on which the given split resides.
|
[
"Returns",
"a",
"list",
"of",
"hosts",
"on",
"which",
"the",
"given",
"split",
"resides",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/extractor/CassandraExtractor.java#L147-L151
|
3,905 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/extractor/CassandraExtractor.java
|
CassandraExtractor.initRecordReader
|
private DeepRecordReader initRecordReader(final DeepPartition dp,
CassandraDeepJobConfig<T> config) {
DeepRecordReader recordReader = new DeepRecordReader(config, dp.splitWrapper());
return recordReader;
}
|
java
|
private DeepRecordReader initRecordReader(final DeepPartition dp,
CassandraDeepJobConfig<T> config) {
DeepRecordReader recordReader = new DeepRecordReader(config, dp.splitWrapper());
return recordReader;
}
|
[
"private",
"DeepRecordReader",
"initRecordReader",
"(",
"final",
"DeepPartition",
"dp",
",",
"CassandraDeepJobConfig",
"<",
"T",
">",
"config",
")",
"{",
"DeepRecordReader",
"recordReader",
"=",
"new",
"DeepRecordReader",
"(",
"config",
",",
"dp",
".",
"splitWrapper",
"(",
")",
")",
";",
"return",
"recordReader",
";",
"}"
] |
Instantiates a new deep record reader object associated to the provided partition.
@param dp a spark deep partition
@return the deep record reader associated to the provided partition.
|
[
"Instantiates",
"a",
"new",
"deep",
"record",
"reader",
"object",
"associated",
"to",
"the",
"provided",
"partition",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/extractor/CassandraExtractor.java#L159-L166
|
3,906 |
Stratio/deep-spark
|
deep-commons/src/main/java/com/stratio/deep/commons/utils/Pair.java
|
Pair.create
|
public static <L, R> Pair<L, R> create(L left, R right) {
return new Pair<>(left, right);
}
|
java
|
public static <L, R> Pair<L, R> create(L left, R right) {
return new Pair<>(left, right);
}
|
[
"public",
"static",
"<",
"L",
",",
"R",
">",
"Pair",
"<",
"L",
",",
"R",
">",
"create",
"(",
"L",
"left",
",",
"R",
"right",
")",
"{",
"return",
"new",
"Pair",
"<>",
"(",
"left",
",",
"right",
")",
";",
"}"
] |
Creates a new immutable pair of objects.
@param left the left element.
@param right the right element.
@param <L> the type of the left element.
@param <R> the type of the right element.
@return a new pair.
|
[
"Creates",
"a",
"new",
"immutable",
"pair",
"of",
"objects",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Pair.java#L58-L60
|
3,907 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/thrift/ThriftRangeUtils.java
|
ThriftRangeUtils.getSplits
|
public List<DeepTokenRange> getSplits() {
// Get the cluster token ranges
List<DeepTokenRange> tokenRanges = getRanges();
// Get the cluster token ranges splits
List<DeepTokenRange> splits = new ArrayList<>();
for (DeepTokenRange tokenRange : tokenRanges) {
List<DeepTokenRange> nodeSplits = getSplits(tokenRange);
splits.addAll(nodeSplits);
}
return splits;
}
|
java
|
public List<DeepTokenRange> getSplits() {
// Get the cluster token ranges
List<DeepTokenRange> tokenRanges = getRanges();
// Get the cluster token ranges splits
List<DeepTokenRange> splits = new ArrayList<>();
for (DeepTokenRange tokenRange : tokenRanges) {
List<DeepTokenRange> nodeSplits = getSplits(tokenRange);
splits.addAll(nodeSplits);
}
return splits;
}
|
[
"public",
"List",
"<",
"DeepTokenRange",
">",
"getSplits",
"(",
")",
"{",
"// Get the cluster token ranges",
"List",
"<",
"DeepTokenRange",
">",
"tokenRanges",
"=",
"getRanges",
"(",
")",
";",
"// Get the cluster token ranges splits",
"List",
"<",
"DeepTokenRange",
">",
"splits",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"DeepTokenRange",
"tokenRange",
":",
"tokenRanges",
")",
"{",
"List",
"<",
"DeepTokenRange",
">",
"nodeSplits",
"=",
"getSplits",
"(",
"tokenRange",
")",
";",
"splits",
".",
"addAll",
"(",
"nodeSplits",
")",
";",
"}",
"return",
"splits",
";",
"}"
] |
Returns the token range splits of the Cassandra ring that will be mapped to Spark partitions.
@return the list of computed token ranges.
|
[
"Returns",
"the",
"token",
"range",
"splits",
"of",
"the",
"Cassandra",
"ring",
"that",
"will",
"be",
"mapped",
"to",
"Spark",
"partitions",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/thrift/ThriftRangeUtils.java#L104-L117
|
3,908 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/thrift/ThriftRangeUtils.java
|
ThriftRangeUtils.getRanges
|
public List<DeepTokenRange> getRanges() {
try {
List<TokenRange> tokenRanges;
ThriftClient client = ThriftClient.build(host, rpcPort);
try {
tokenRanges = client.describe_local_ring(keyspace);
} catch (TApplicationException e) {
if (e.getType() == TApplicationException.UNKNOWN_METHOD) {
tokenRanges = client.describe_ring(keyspace);
} else {
throw new DeepGenericException("Unknown server error", e);
}
}
client.close();
List<DeepTokenRange> deepTokenRanges = new ArrayList<>(tokenRanges.size());
for (TokenRange tokenRange : tokenRanges) {
Comparable start = tokenAsComparable(tokenRange.getStart_token());
Comparable end = tokenAsComparable(tokenRange.getEnd_token());
deepTokenRanges.add(new DeepTokenRange(start, end, tokenRange.getEndpoints()));
}
return deepTokenRanges;
} catch (TException e) {
throw new DeepGenericException("No available replicas for get ring token ranges", e);
}
}
|
java
|
public List<DeepTokenRange> getRanges() {
try {
List<TokenRange> tokenRanges;
ThriftClient client = ThriftClient.build(host, rpcPort);
try {
tokenRanges = client.describe_local_ring(keyspace);
} catch (TApplicationException e) {
if (e.getType() == TApplicationException.UNKNOWN_METHOD) {
tokenRanges = client.describe_ring(keyspace);
} else {
throw new DeepGenericException("Unknown server error", e);
}
}
client.close();
List<DeepTokenRange> deepTokenRanges = new ArrayList<>(tokenRanges.size());
for (TokenRange tokenRange : tokenRanges) {
Comparable start = tokenAsComparable(tokenRange.getStart_token());
Comparable end = tokenAsComparable(tokenRange.getEnd_token());
deepTokenRanges.add(new DeepTokenRange(start, end, tokenRange.getEndpoints()));
}
return deepTokenRanges;
} catch (TException e) {
throw new DeepGenericException("No available replicas for get ring token ranges", e);
}
}
|
[
"public",
"List",
"<",
"DeepTokenRange",
">",
"getRanges",
"(",
")",
"{",
"try",
"{",
"List",
"<",
"TokenRange",
">",
"tokenRanges",
";",
"ThriftClient",
"client",
"=",
"ThriftClient",
".",
"build",
"(",
"host",
",",
"rpcPort",
")",
";",
"try",
"{",
"tokenRanges",
"=",
"client",
".",
"describe_local_ring",
"(",
"keyspace",
")",
";",
"}",
"catch",
"(",
"TApplicationException",
"e",
")",
"{",
"if",
"(",
"e",
".",
"getType",
"(",
")",
"==",
"TApplicationException",
".",
"UNKNOWN_METHOD",
")",
"{",
"tokenRanges",
"=",
"client",
".",
"describe_ring",
"(",
"keyspace",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"DeepGenericException",
"(",
"\"Unknown server error\"",
",",
"e",
")",
";",
"}",
"}",
"client",
".",
"close",
"(",
")",
";",
"List",
"<",
"DeepTokenRange",
">",
"deepTokenRanges",
"=",
"new",
"ArrayList",
"<>",
"(",
"tokenRanges",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"TokenRange",
"tokenRange",
":",
"tokenRanges",
")",
"{",
"Comparable",
"start",
"=",
"tokenAsComparable",
"(",
"tokenRange",
".",
"getStart_token",
"(",
")",
")",
";",
"Comparable",
"end",
"=",
"tokenAsComparable",
"(",
"tokenRange",
".",
"getEnd_token",
"(",
")",
")",
";",
"deepTokenRanges",
".",
"add",
"(",
"new",
"DeepTokenRange",
"(",
"start",
",",
"end",
",",
"tokenRange",
".",
"getEndpoints",
"(",
")",
")",
")",
";",
"}",
"return",
"deepTokenRanges",
";",
"}",
"catch",
"(",
"TException",
"e",
")",
"{",
"throw",
"new",
"DeepGenericException",
"(",
"\"No available replicas for get ring token ranges\"",
",",
"e",
")",
";",
"}",
"}"
] |
Returns the token ranges of the Cassandra ring that will be mapped to Spark partitions.
The returned ranges are the Cassandra's physical ones, without any splitting.
@return the list of Cassandra ring token ranges.
|
[
"Returns",
"the",
"token",
"ranges",
"of",
"the",
"Cassandra",
"ring",
"that",
"will",
"be",
"mapped",
"to",
"Spark",
"partitions",
".",
"The",
"returned",
"ranges",
"are",
"the",
"Cassandra",
"s",
"physical",
"ones",
"without",
"any",
"splitting",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/thrift/ThriftRangeUtils.java#L125-L152
|
3,909 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/thrift/ThriftRangeUtils.java
|
ThriftRangeUtils.getSplits
|
public List<DeepTokenRange> getSplits(DeepTokenRange deepTokenRange) {
String start = tokenAsString((Comparable) deepTokenRange.getStartToken());
String end = tokenAsString((Comparable) deepTokenRange.getEndToken());
List<String> endpoints = deepTokenRange.getReplicas();
for (String endpoint : endpoints) {
try {
ThriftClient client = ThriftClient.build(endpoint, rpcPort, keyspace);
List<CfSplit> splits = client.describe_splits_ex(columnFamily, start, end, splitSize);
client.close();
return deepTokenRanges(splits, endpoints);
} catch (TException e) {
LOG.warn("Endpoint %s failed while splitting range %s", endpoint, deepTokenRange);
}
}
throw new DeepGenericException("No available replicas for splitting range " + deepTokenRange);
}
|
java
|
public List<DeepTokenRange> getSplits(DeepTokenRange deepTokenRange) {
String start = tokenAsString((Comparable) deepTokenRange.getStartToken());
String end = tokenAsString((Comparable) deepTokenRange.getEndToken());
List<String> endpoints = deepTokenRange.getReplicas();
for (String endpoint : endpoints) {
try {
ThriftClient client = ThriftClient.build(endpoint, rpcPort, keyspace);
List<CfSplit> splits = client.describe_splits_ex(columnFamily, start, end, splitSize);
client.close();
return deepTokenRanges(splits, endpoints);
} catch (TException e) {
LOG.warn("Endpoint %s failed while splitting range %s", endpoint, deepTokenRange);
}
}
throw new DeepGenericException("No available replicas for splitting range " + deepTokenRange);
}
|
[
"public",
"List",
"<",
"DeepTokenRange",
">",
"getSplits",
"(",
"DeepTokenRange",
"deepTokenRange",
")",
"{",
"String",
"start",
"=",
"tokenAsString",
"(",
"(",
"Comparable",
")",
"deepTokenRange",
".",
"getStartToken",
"(",
")",
")",
";",
"String",
"end",
"=",
"tokenAsString",
"(",
"(",
"Comparable",
")",
"deepTokenRange",
".",
"getEndToken",
"(",
")",
")",
";",
"List",
"<",
"String",
">",
"endpoints",
"=",
"deepTokenRange",
".",
"getReplicas",
"(",
")",
";",
"for",
"(",
"String",
"endpoint",
":",
"endpoints",
")",
"{",
"try",
"{",
"ThriftClient",
"client",
"=",
"ThriftClient",
".",
"build",
"(",
"endpoint",
",",
"rpcPort",
",",
"keyspace",
")",
";",
"List",
"<",
"CfSplit",
">",
"splits",
"=",
"client",
".",
"describe_splits_ex",
"(",
"columnFamily",
",",
"start",
",",
"end",
",",
"splitSize",
")",
";",
"client",
".",
"close",
"(",
")",
";",
"return",
"deepTokenRanges",
"(",
"splits",
",",
"endpoints",
")",
";",
"}",
"catch",
"(",
"TException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Endpoint %s failed while splitting range %s\"",
",",
"endpoint",
",",
"deepTokenRange",
")",
";",
"}",
"}",
"throw",
"new",
"DeepGenericException",
"(",
"\"No available replicas for splitting range \"",
"+",
"deepTokenRange",
")",
";",
"}"
] |
Returns the computed token range splits of the specified token range.
@param deepTokenRange the token range to be splitted.
@return the list of token range splits, which are also token ranges.
|
[
"Returns",
"the",
"computed",
"token",
"range",
"splits",
"of",
"the",
"specified",
"token",
"range",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/thrift/ThriftRangeUtils.java#L160-L177
|
3,910 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/thrift/ThriftRangeUtils.java
|
ThriftRangeUtils.deepTokenRanges
|
public List<DeepTokenRange> deepTokenRanges(List<CfSplit> splits, List<String> endpoints) {
List<DeepTokenRange> result = new ArrayList<>();
for (CfSplit split : splits) {
Comparable splitStart = tokenAsComparable(split.getStart_token());
Comparable splitEnd = tokenAsComparable(split.getEnd_token());
if (splitStart.equals(splitEnd)) {
result.add(new DeepTokenRange(minToken, minToken, endpoints));
} else if (splitStart.compareTo(splitEnd) > 0) {
result.add(new DeepTokenRange(splitStart, minToken, endpoints));
result.add(new DeepTokenRange(minToken, splitEnd, endpoints));
} else {
result.add(new DeepTokenRange(splitStart, splitEnd, endpoints));
}
}
return result;
}
|
java
|
public List<DeepTokenRange> deepTokenRanges(List<CfSplit> splits, List<String> endpoints) {
List<DeepTokenRange> result = new ArrayList<>();
for (CfSplit split : splits) {
Comparable splitStart = tokenAsComparable(split.getStart_token());
Comparable splitEnd = tokenAsComparable(split.getEnd_token());
if (splitStart.equals(splitEnd)) {
result.add(new DeepTokenRange(minToken, minToken, endpoints));
} else if (splitStart.compareTo(splitEnd) > 0) {
result.add(new DeepTokenRange(splitStart, minToken, endpoints));
result.add(new DeepTokenRange(minToken, splitEnd, endpoints));
} else {
result.add(new DeepTokenRange(splitStart, splitEnd, endpoints));
}
}
return result;
}
|
[
"public",
"List",
"<",
"DeepTokenRange",
">",
"deepTokenRanges",
"(",
"List",
"<",
"CfSplit",
">",
"splits",
",",
"List",
"<",
"String",
">",
"endpoints",
")",
"{",
"List",
"<",
"DeepTokenRange",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"CfSplit",
"split",
":",
"splits",
")",
"{",
"Comparable",
"splitStart",
"=",
"tokenAsComparable",
"(",
"split",
".",
"getStart_token",
"(",
")",
")",
";",
"Comparable",
"splitEnd",
"=",
"tokenAsComparable",
"(",
"split",
".",
"getEnd_token",
"(",
")",
")",
";",
"if",
"(",
"splitStart",
".",
"equals",
"(",
"splitEnd",
")",
")",
"{",
"result",
".",
"add",
"(",
"new",
"DeepTokenRange",
"(",
"minToken",
",",
"minToken",
",",
"endpoints",
")",
")",
";",
"}",
"else",
"if",
"(",
"splitStart",
".",
"compareTo",
"(",
"splitEnd",
")",
">",
"0",
")",
"{",
"result",
".",
"add",
"(",
"new",
"DeepTokenRange",
"(",
"splitStart",
",",
"minToken",
",",
"endpoints",
")",
")",
";",
"result",
".",
"add",
"(",
"new",
"DeepTokenRange",
"(",
"minToken",
",",
"splitEnd",
",",
"endpoints",
")",
")",
";",
"}",
"else",
"{",
"result",
".",
"add",
"(",
"new",
"DeepTokenRange",
"(",
"splitStart",
",",
"splitEnd",
",",
"endpoints",
")",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Returns the Deep splits represented by the specified Thrift splits using the specified endpoints for all of them.
Note that the returned list can contain one more ranges than the specified because the range containing the
partitioner's minimum token are divided into two ranges.
@param splits the Thrift splits to be converted.
@param endpoints the endpoints list to be set in each generated Deep split
@return the {@link com.stratio.deep.commons.rdd.DeepTokenRange}s represented by the specified
{@link org.apache.cassandra.thrift.CfSplit}s
|
[
"Returns",
"the",
"Deep",
"splits",
"represented",
"by",
"the",
"specified",
"Thrift",
"splits",
"using",
"the",
"specified",
"endpoints",
"for",
"all",
"of",
"them",
".",
"Note",
"that",
"the",
"returned",
"list",
"can",
"contain",
"one",
"more",
"ranges",
"than",
"the",
"specified",
"because",
"the",
"range",
"containing",
"the",
"partitioner",
"s",
"minimum",
"token",
"are",
"divided",
"into",
"two",
"ranges",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/thrift/ThriftRangeUtils.java#L189-L204
|
3,911 |
Stratio/deep-spark
|
deep-aerospike/src/main/java/com/stratio/deep/aerospike/config/AerospikeDeepJobConfig.java
|
AerospikeDeepJobConfig.port
|
public AerospikeDeepJobConfig<T> port(Integer[] ports) {
this.portList.addAll(Arrays.asList(ports));
return this;
}
|
java
|
public AerospikeDeepJobConfig<T> port(Integer[] ports) {
this.portList.addAll(Arrays.asList(ports));
return this;
}
|
[
"public",
"AerospikeDeepJobConfig",
"<",
"T",
">",
"port",
"(",
"Integer",
"[",
"]",
"ports",
")",
"{",
"this",
".",
"portList",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"ports",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Set Aerospike nodes' ports.
@param ports
@return
|
[
"Set",
"Aerospike",
"nodes",
"ports",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-aerospike/src/main/java/com/stratio/deep/aerospike/config/AerospikeDeepJobConfig.java#L133-L136
|
3,912 |
Stratio/deep-spark
|
deep-aerospike/src/main/java/com/stratio/deep/aerospike/config/AerospikeDeepJobConfig.java
|
AerospikeDeepJobConfig.validate
|
private void validate() {
if (host.isEmpty()) {
throw new IllegalArgumentException("host cannot be null");
}
if (catalog == null) {
throw new IllegalArgumentException("namespace cannot be null");
}
if (table == null) {
throw new IllegalArgumentException("set cannot be null");
}
if (portList.isEmpty()) {
if(port>0){
port(port);
}else{
throw new IllegalArgumentException("port cannot be null");
}
}
if (host.size() != portList.size()) {
throw new IllegalArgumentException("Host and ports cardinality must be the same");
}
}
|
java
|
private void validate() {
if (host.isEmpty()) {
throw new IllegalArgumentException("host cannot be null");
}
if (catalog == null) {
throw new IllegalArgumentException("namespace cannot be null");
}
if (table == null) {
throw new IllegalArgumentException("set cannot be null");
}
if (portList.isEmpty()) {
if(port>0){
port(port);
}else{
throw new IllegalArgumentException("port cannot be null");
}
}
if (host.size() != portList.size()) {
throw new IllegalArgumentException("Host and ports cardinality must be the same");
}
}
|
[
"private",
"void",
"validate",
"(",
")",
"{",
"if",
"(",
"host",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"host cannot be null\"",
")",
";",
"}",
"if",
"(",
"catalog",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"namespace cannot be null\"",
")",
";",
"}",
"if",
"(",
"table",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"set cannot be null\"",
")",
";",
"}",
"if",
"(",
"portList",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"port",
">",
"0",
")",
"{",
"port",
"(",
"port",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"port cannot be null\"",
")",
";",
"}",
"}",
"if",
"(",
"host",
".",
"size",
"(",
")",
"!=",
"portList",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Host and ports cardinality must be the same\"",
")",
";",
"}",
"}"
] |
Validates connection parameters.
|
[
"Validates",
"connection",
"parameters",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-aerospike/src/main/java/com/stratio/deep/aerospike/config/AerospikeDeepJobConfig.java#L259-L281
|
3,913 |
Stratio/deep-spark
|
deep-aerospike/src/main/java/com/stratio/deep/aerospike/config/AerospikeDeepJobConfig.java
|
AerospikeDeepJobConfig.filterQuery
|
public AerospikeDeepJobConfig<T> filterQuery(Filter[] filters) {
if (filters.length > 1) {
throw new UnsupportedOperationException("Aerospike currently accepts only one filter operations");
} else if (filters.length > 0) {
Filter deepFilter = filters[0];
if (!isValidAerospikeFilter(deepFilter)) {
throw new UnsupportedOperationException(
"Aerospike currently supports only equality and range filter operations");
} else if (!deepFilter.getFilterType().equals(FilterType.EQ)) {
operation("numrange");
setAerospikeNumrange(deepFilter);
} else {
operation("scan");
setAerospikeEqualsFilter(deepFilter);
}
}
return this;
}
|
java
|
public AerospikeDeepJobConfig<T> filterQuery(Filter[] filters) {
if (filters.length > 1) {
throw new UnsupportedOperationException("Aerospike currently accepts only one filter operations");
} else if (filters.length > 0) {
Filter deepFilter = filters[0];
if (!isValidAerospikeFilter(deepFilter)) {
throw new UnsupportedOperationException(
"Aerospike currently supports only equality and range filter operations");
} else if (!deepFilter.getFilterType().equals(FilterType.EQ)) {
operation("numrange");
setAerospikeNumrange(deepFilter);
} else {
operation("scan");
setAerospikeEqualsFilter(deepFilter);
}
}
return this;
}
|
[
"public",
"AerospikeDeepJobConfig",
"<",
"T",
">",
"filterQuery",
"(",
"Filter",
"[",
"]",
"filters",
")",
"{",
"if",
"(",
"filters",
".",
"length",
">",
"1",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Aerospike currently accepts only one filter operations\"",
")",
";",
"}",
"else",
"if",
"(",
"filters",
".",
"length",
">",
"0",
")",
"{",
"Filter",
"deepFilter",
"=",
"filters",
"[",
"0",
"]",
";",
"if",
"(",
"!",
"isValidAerospikeFilter",
"(",
"deepFilter",
")",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Aerospike currently supports only equality and range filter operations\"",
")",
";",
"}",
"else",
"if",
"(",
"!",
"deepFilter",
".",
"getFilterType",
"(",
")",
".",
"equals",
"(",
"FilterType",
".",
"EQ",
")",
")",
"{",
"operation",
"(",
"\"numrange\"",
")",
";",
"setAerospikeNumrange",
"(",
"deepFilter",
")",
";",
"}",
"else",
"{",
"operation",
"(",
"\"scan\"",
")",
";",
"setAerospikeEqualsFilter",
"(",
"deepFilter",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] |
Configure Aerospike filters with the received Deep Filter objects.
@param filters
@return
|
[
"Configure",
"Aerospike",
"filters",
"with",
"the",
"received",
"Deep",
"Filter",
"objects",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-aerospike/src/main/java/com/stratio/deep/aerospike/config/AerospikeDeepJobConfig.java#L323-L340
|
3,914 |
Stratio/deep-spark
|
deep-jdbc/src/main/java/com/stratio/deep/jdbc/utils/UtilJdbc.java
|
UtilJdbc.getObjectFromRow
|
public static <T, S extends DeepJobConfig> T getObjectFromRow(Class<T> classEntity, Map<String, Object> row, DeepJobConfig<T, S> config) throws IllegalAccessException, InstantiationException, InvocationTargetException {
T t = classEntity.newInstance();
Field[] fields = AnnotationUtils.filterDeepFields(classEntity);
for (Field field : fields) {
Object currentRow = null;
Method method = null;
Class<?> classField = field.getType();
try {
method = Utils.findSetter(field.getName(), classEntity, field.getType());
currentRow = row.get(AnnotationUtils.deepFieldName(field));
if (currentRow != null) {
method.invoke(t, currentRow);
}
} catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException e) {
LOG.error("impossible to create a java object from column:" + field.getName() + " and type:"
+ field.getType() + " and value:" + t + "; recordReceived:" + currentRow);
method.invoke(t, Utils.castNumberType(currentRow, classField));
}
}
return t;
}
|
java
|
public static <T, S extends DeepJobConfig> T getObjectFromRow(Class<T> classEntity, Map<String, Object> row, DeepJobConfig<T, S> config) throws IllegalAccessException, InstantiationException, InvocationTargetException {
T t = classEntity.newInstance();
Field[] fields = AnnotationUtils.filterDeepFields(classEntity);
for (Field field : fields) {
Object currentRow = null;
Method method = null;
Class<?> classField = field.getType();
try {
method = Utils.findSetter(field.getName(), classEntity, field.getType());
currentRow = row.get(AnnotationUtils.deepFieldName(field));
if (currentRow != null) {
method.invoke(t, currentRow);
}
} catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException e) {
LOG.error("impossible to create a java object from column:" + field.getName() + " and type:"
+ field.getType() + " and value:" + t + "; recordReceived:" + currentRow);
method.invoke(t, Utils.castNumberType(currentRow, classField));
}
}
return t;
}
|
[
"public",
"static",
"<",
"T",
",",
"S",
"extends",
"DeepJobConfig",
">",
"T",
"getObjectFromRow",
"(",
"Class",
"<",
"T",
">",
"classEntity",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"row",
",",
"DeepJobConfig",
"<",
"T",
",",
"S",
">",
"config",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"InvocationTargetException",
"{",
"T",
"t",
"=",
"classEntity",
".",
"newInstance",
"(",
")",
";",
"Field",
"[",
"]",
"fields",
"=",
"AnnotationUtils",
".",
"filterDeepFields",
"(",
"classEntity",
")",
";",
"for",
"(",
"Field",
"field",
":",
"fields",
")",
"{",
"Object",
"currentRow",
"=",
"null",
";",
"Method",
"method",
"=",
"null",
";",
"Class",
"<",
"?",
">",
"classField",
"=",
"field",
".",
"getType",
"(",
")",
";",
"try",
"{",
"method",
"=",
"Utils",
".",
"findSetter",
"(",
"field",
".",
"getName",
"(",
")",
",",
"classEntity",
",",
"field",
".",
"getType",
"(",
")",
")",
";",
"currentRow",
"=",
"row",
".",
"get",
"(",
"AnnotationUtils",
".",
"deepFieldName",
"(",
"field",
")",
")",
";",
"if",
"(",
"currentRow",
"!=",
"null",
")",
"{",
"method",
".",
"invoke",
"(",
"t",
",",
"currentRow",
")",
";",
"}",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"InvocationTargetException",
"|",
"IllegalArgumentException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"impossible to create a java object from column:\"",
"+",
"field",
".",
"getName",
"(",
")",
"+",
"\" and type:\"",
"+",
"field",
".",
"getType",
"(",
")",
"+",
"\" and value:\"",
"+",
"t",
"+",
"\"; recordReceived:\"",
"+",
"currentRow",
")",
";",
"method",
".",
"invoke",
"(",
"t",
",",
"Utils",
".",
"castNumberType",
"(",
"currentRow",
",",
"classField",
")",
")",
";",
"}",
"}",
"return",
"t",
";",
"}"
] |
Returns a Stratio Entity from a Jdbc row represented as a map.
@param classEntity Stratio Entity.
@param row Jdbc row represented as a Map.
@param config JDBC Deep Job configuration.
@param <T> Stratio Entity class.
@return Stratio Entity from a Jdbc row represented as a map.
@throws IllegalAccessException
@throws InstantiationException
@throws InvocationTargetException
|
[
"Returns",
"a",
"Stratio",
"Entity",
"from",
"a",
"Jdbc",
"row",
"represented",
"as",
"a",
"map",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-jdbc/src/main/java/com/stratio/deep/jdbc/utils/UtilJdbc.java#L53-L76
|
3,915 |
Stratio/deep-spark
|
deep-jdbc/src/main/java/com/stratio/deep/jdbc/utils/UtilJdbc.java
|
UtilJdbc.getRowFromObject
|
public static <T> Map<String, Object> getRowFromObject(T entity) throws IllegalAccessException, InstantiationException,
InvocationTargetException {
Field[] fields = AnnotationUtils.filterDeepFields(entity.getClass());
Map<String, Object> row = new HashMap<>();
for (Field field : fields) {
Method method = Utils.findGetter(field.getName(), entity.getClass());
Object object = method.invoke(entity);
if (object != null) {
row.put(AnnotationUtils.deepFieldName(field), object);
}
}
return row;
}
|
java
|
public static <T> Map<String, Object> getRowFromObject(T entity) throws IllegalAccessException, InstantiationException,
InvocationTargetException {
Field[] fields = AnnotationUtils.filterDeepFields(entity.getClass());
Map<String, Object> row = new HashMap<>();
for (Field field : fields) {
Method method = Utils.findGetter(field.getName(), entity.getClass());
Object object = method.invoke(entity);
if (object != null) {
row.put(AnnotationUtils.deepFieldName(field), object);
}
}
return row;
}
|
[
"public",
"static",
"<",
"T",
">",
"Map",
"<",
"String",
",",
"Object",
">",
"getRowFromObject",
"(",
"T",
"entity",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"InvocationTargetException",
"{",
"Field",
"[",
"]",
"fields",
"=",
"AnnotationUtils",
".",
"filterDeepFields",
"(",
"entity",
".",
"getClass",
"(",
")",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"row",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Field",
"field",
":",
"fields",
")",
"{",
"Method",
"method",
"=",
"Utils",
".",
"findGetter",
"(",
"field",
".",
"getName",
"(",
")",
",",
"entity",
".",
"getClass",
"(",
")",
")",
";",
"Object",
"object",
"=",
"method",
".",
"invoke",
"(",
"entity",
")",
";",
"if",
"(",
"object",
"!=",
"null",
")",
"{",
"row",
".",
"put",
"(",
"AnnotationUtils",
".",
"deepFieldName",
"(",
"field",
")",
",",
"object",
")",
";",
"}",
"}",
"return",
"row",
";",
"}"
] |
Returns a JDBC row data structure from a Stratio Deep Entity.
@param entity Stratio Deep entity.
@param <T> Stratio Deep entity type.
@return JDBC row data structure from a Stratio Deep Entity.
@throws IllegalAccessException
@throws InstantiationException
@throws InvocationTargetException
|
[
"Returns",
"a",
"JDBC",
"row",
"data",
"structure",
"from",
"a",
"Stratio",
"Deep",
"Entity",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-jdbc/src/main/java/com/stratio/deep/jdbc/utils/UtilJdbc.java#L87-L101
|
3,916 |
Stratio/deep-spark
|
deep-jdbc/src/main/java/com/stratio/deep/jdbc/utils/UtilJdbc.java
|
UtilJdbc.getCellsFromObject
|
public static<T extends DeepJobConfig> Cells getCellsFromObject(Map<String, Object> row, DeepJobConfig<Cells, T> config) {
Cells result = new Cells(config.getCatalog() + "." + config.getTable());
for(Map.Entry<String, Object> entry:row.entrySet()) {
Cell cell = Cell.create(entry.getKey(), entry.getValue());
result.add(cell);
}
return result;
}
|
java
|
public static<T extends DeepJobConfig> Cells getCellsFromObject(Map<String, Object> row, DeepJobConfig<Cells, T> config) {
Cells result = new Cells(config.getCatalog() + "." + config.getTable());
for(Map.Entry<String, Object> entry:row.entrySet()) {
Cell cell = Cell.create(entry.getKey(), entry.getValue());
result.add(cell);
}
return result;
}
|
[
"public",
"static",
"<",
"T",
"extends",
"DeepJobConfig",
">",
"Cells",
"getCellsFromObject",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"row",
",",
"DeepJobConfig",
"<",
"Cells",
",",
"T",
">",
"config",
")",
"{",
"Cells",
"result",
"=",
"new",
"Cells",
"(",
"config",
".",
"getCatalog",
"(",
")",
"+",
"\".\"",
"+",
"config",
".",
"getTable",
"(",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"row",
".",
"entrySet",
"(",
")",
")",
"{",
"Cell",
"cell",
"=",
"Cell",
".",
"create",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"result",
".",
"add",
"(",
"cell",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Returns a Cells object from a JDBC row data structure.
@param row JDBC row data structure as a Map.
@param config JDBC Deep Job config.
@return Cells object from a JDBC row data structure.
|
[
"Returns",
"a",
"Cells",
"object",
"from",
"a",
"JDBC",
"row",
"data",
"structure",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-jdbc/src/main/java/com/stratio/deep/jdbc/utils/UtilJdbc.java#L109-L116
|
3,917 |
Stratio/deep-spark
|
deep-jdbc/src/main/java/com/stratio/deep/jdbc/utils/UtilJdbc.java
|
UtilJdbc.getObjectFromCells
|
public static Map<String, Object> getObjectFromCells(Cells cells) {
Map<String, Object> result = new HashMap<>();
for(Cell cell:cells.getCells()) {
result.put(cell.getName(), cell.getValue());
}
return result;
}
|
java
|
public static Map<String, Object> getObjectFromCells(Cells cells) {
Map<String, Object> result = new HashMap<>();
for(Cell cell:cells.getCells()) {
result.put(cell.getName(), cell.getValue());
}
return result;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"getObjectFromCells",
"(",
"Cells",
"cells",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Cell",
"cell",
":",
"cells",
".",
"getCells",
"(",
")",
")",
"{",
"result",
".",
"put",
"(",
"cell",
".",
"getName",
"(",
")",
",",
"cell",
".",
"getValue",
"(",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Returns a JDBC row data structure from a Cells object.
@param cells Cells object carrying information.
@return JDBC row data structure from a Cells object.
|
[
"Returns",
"a",
"JDBC",
"row",
"data",
"structure",
"from",
"a",
"Cells",
"object",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-jdbc/src/main/java/com/stratio/deep/jdbc/utils/UtilJdbc.java#L123-L129
|
3,918 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/thrift/ThriftClient.java
|
ThriftClient.build
|
public static ThriftClient build(String host, int port, String keyspace) throws TException {
TTransport transport = new TFramedTransport(new TSocket(host, port));
TProtocol protocol = new TBinaryProtocol(transport);
ThriftClient client = new ThriftClient(protocol);
transport.open();
if (keyspace != null) {
client.set_keyspace(keyspace);
}
return client;
}
|
java
|
public static ThriftClient build(String host, int port, String keyspace) throws TException {
TTransport transport = new TFramedTransport(new TSocket(host, port));
TProtocol protocol = new TBinaryProtocol(transport);
ThriftClient client = new ThriftClient(protocol);
transport.open();
if (keyspace != null) {
client.set_keyspace(keyspace);
}
return client;
}
|
[
"public",
"static",
"ThriftClient",
"build",
"(",
"String",
"host",
",",
"int",
"port",
",",
"String",
"keyspace",
")",
"throws",
"TException",
"{",
"TTransport",
"transport",
"=",
"new",
"TFramedTransport",
"(",
"new",
"TSocket",
"(",
"host",
",",
"port",
")",
")",
";",
"TProtocol",
"protocol",
"=",
"new",
"TBinaryProtocol",
"(",
"transport",
")",
";",
"ThriftClient",
"client",
"=",
"new",
"ThriftClient",
"(",
"protocol",
")",
";",
"transport",
".",
"open",
"(",
")",
";",
"if",
"(",
"keyspace",
"!=",
"null",
")",
"{",
"client",
".",
"set_keyspace",
"(",
"keyspace",
")",
";",
"}",
"return",
"client",
";",
"}"
] |
Returns a new client for the specified host, setting the specified keyspace.
@param host the Cassandra host address.
@param port the Cassandra host RPC port.
@param keyspace the name of the Cassandra keyspace to set.
@return a new client for the specified host, setting the specified keyspace.
@throws TException if there is any problem with the {@code set_keyspace} call.
|
[
"Returns",
"a",
"new",
"client",
"for",
"the",
"specified",
"host",
"setting",
"the",
"specified",
"keyspace",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/thrift/ThriftClient.java#L53-L62
|
3,919 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/thrift/ThriftClient.java
|
ThriftClient.build
|
public static ThriftClient build(String host, int port) throws TException {
return build(host, port, null);
}
|
java
|
public static ThriftClient build(String host, int port) throws TException {
return build(host, port, null);
}
|
[
"public",
"static",
"ThriftClient",
"build",
"(",
"String",
"host",
",",
"int",
"port",
")",
"throws",
"TException",
"{",
"return",
"build",
"(",
"host",
",",
"port",
",",
"null",
")",
";",
"}"
] |
Returns a new client for the specified host.
@param host the Cassandra host address.
@param port the Cassandra host RPC port.
@return a new client for the specified host.
@throws TException if there is any problem with the {@code set_keyspace} call.
|
[
"Returns",
"a",
"new",
"client",
"for",
"the",
"specified",
"host",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/thrift/ThriftClient.java#L72-L74
|
3,920 |
Stratio/deep-spark
|
deep-commons/src/main/java/com/stratio/deep/commons/utils/CellsUtils.java
|
CellsUtils.getRowFromCells
|
public static Row getRowFromCells(Cells cells) {
Object[] values = cells.getCellValues().toArray();
return RowFactory.create(values);
}
|
java
|
public static Row getRowFromCells(Cells cells) {
Object[] values = cells.getCellValues().toArray();
return RowFactory.create(values);
}
|
[
"public",
"static",
"Row",
"getRowFromCells",
"(",
"Cells",
"cells",
")",
"{",
"Object",
"[",
"]",
"values",
"=",
"cells",
".",
"getCellValues",
"(",
")",
".",
"toArray",
"(",
")",
";",
"return",
"RowFactory",
".",
"create",
"(",
"values",
")",
";",
"}"
] |
Creates a SparkSQL Row object from a Stratio Cells object
@param cells Stratio Cells object for transforming.
@return SparkSQL Row created from Cells.
|
[
"Creates",
"a",
"SparkSQL",
"Row",
"object",
"from",
"a",
"Stratio",
"Cells",
"object"
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/CellsUtils.java#L289-L292
|
3,921 |
Stratio/deep-spark
|
deep-commons/src/main/java/com/stratio/deep/commons/utils/CellsUtils.java
|
CellsUtils.getRowsFromsCells
|
public static Collection<Row> getRowsFromsCells(Collection<Cells> cellsCol) {
Collection<Row> result = new ArrayList<>();
for (Cells cells : cellsCol) {
result.add(getRowFromCells(cells));
}
return result;
}
|
java
|
public static Collection<Row> getRowsFromsCells(Collection<Cells> cellsCol) {
Collection<Row> result = new ArrayList<>();
for (Cells cells : cellsCol) {
result.add(getRowFromCells(cells));
}
return result;
}
|
[
"public",
"static",
"Collection",
"<",
"Row",
">",
"getRowsFromsCells",
"(",
"Collection",
"<",
"Cells",
">",
"cellsCol",
")",
"{",
"Collection",
"<",
"Row",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Cells",
"cells",
":",
"cellsCol",
")",
"{",
"result",
".",
"add",
"(",
"getRowFromCells",
"(",
"cells",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Returns a Collection of SparkSQL Row objects from a collection of Stratio Cells
objects
@param cellsCol Collection of Cells for transforming
@return Collection of SparkSQL Row created from Cells.
|
[
"Returns",
"a",
"Collection",
"of",
"SparkSQL",
"Row",
"objects",
"from",
"a",
"collection",
"of",
"Stratio",
"Cells",
"objects"
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/CellsUtils.java#L301-L307
|
3,922 |
Stratio/deep-spark
|
deep-commons/src/main/java/com/stratio/deep/commons/entity/Cells.java
|
Cells.getCellsByTable
|
private List<Cell> getCellsByTable(String nameSpace) {
String tName = StringUtils.isEmpty(nameSpace) ? this.nameSpace : nameSpace;
List<Cell> res = cells.get(tName);
if (res == null) {
res = new ArrayList<>();
cells.put(tName, res);
}
return res;
}
|
java
|
private List<Cell> getCellsByTable(String nameSpace) {
String tName = StringUtils.isEmpty(nameSpace) ? this.nameSpace : nameSpace;
List<Cell> res = cells.get(tName);
if (res == null) {
res = new ArrayList<>();
cells.put(tName, res);
}
return res;
}
|
[
"private",
"List",
"<",
"Cell",
">",
"getCellsByTable",
"(",
"String",
"nameSpace",
")",
"{",
"String",
"tName",
"=",
"StringUtils",
".",
"isEmpty",
"(",
"nameSpace",
")",
"?",
"this",
".",
"nameSpace",
":",
"nameSpace",
";",
"List",
"<",
"Cell",
">",
"res",
"=",
"cells",
".",
"get",
"(",
"tName",
")",
";",
"if",
"(",
"res",
"==",
"null",
")",
"{",
"res",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"cells",
".",
"put",
"(",
"tName",
",",
"res",
")",
";",
"}",
"return",
"res",
";",
"}"
] |
Given the table name, returns the List of Cell object associated to that table.
@param nameSpace the table name.
@return the List of Cell object associated to that table.
|
[
"Given",
"the",
"table",
"name",
"returns",
"the",
"List",
"of",
"Cell",
"object",
"associated",
"to",
"that",
"table",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/entity/Cells.java#L72-L83
|
3,923 |
Stratio/deep-spark
|
deep-commons/src/main/java/com/stratio/deep/commons/entity/Cells.java
|
Cells.add
|
public boolean add(Cell c) {
if (c == null) {
throw new DeepGenericException(new IllegalArgumentException("cell parameter cannot be null"));
}
return getCellsByTable(nameSpace).add(c);
}
|
java
|
public boolean add(Cell c) {
if (c == null) {
throw new DeepGenericException(new IllegalArgumentException("cell parameter cannot be null"));
}
return getCellsByTable(nameSpace).add(c);
}
|
[
"public",
"boolean",
"add",
"(",
"Cell",
"c",
")",
"{",
"if",
"(",
"c",
"==",
"null",
")",
"{",
"throw",
"new",
"DeepGenericException",
"(",
"new",
"IllegalArgumentException",
"(",
"\"cell parameter cannot be null\"",
")",
")",
";",
"}",
"return",
"getCellsByTable",
"(",
"nameSpace",
")",
".",
"add",
"(",
"c",
")",
";",
"}"
] |
Adds a new Cell object to this Cells instance. Associates the provided Cell to the default table.
@param c the Cell we want to add to this Cells object.
@return either true/false if the Cell has been added successfully or not.
|
[
"Adds",
"a",
"new",
"Cell",
"object",
"to",
"this",
"Cells",
"instance",
".",
"Associates",
"the",
"provided",
"Cell",
"to",
"the",
"default",
"table",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/entity/Cells.java#L128-L134
|
3,924 |
Stratio/deep-spark
|
deep-commons/src/main/java/com/stratio/deep/commons/entity/Cells.java
|
Cells.getCells
|
public Collection<Cell> getCells() {
List<Cell> res = new ArrayList<>();
for (Map.Entry<String, List<Cell>> entry : cells.entrySet()) {
res.addAll(entry.getValue());
}
return Collections.unmodifiableList(res);
}
|
java
|
public Collection<Cell> getCells() {
List<Cell> res = new ArrayList<>();
for (Map.Entry<String, List<Cell>> entry : cells.entrySet()) {
res.addAll(entry.getValue());
}
return Collections.unmodifiableList(res);
}
|
[
"public",
"Collection",
"<",
"Cell",
">",
"getCells",
"(",
")",
"{",
"List",
"<",
"Cell",
">",
"res",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"List",
"<",
"Cell",
">",
">",
"entry",
":",
"cells",
".",
"entrySet",
"(",
")",
")",
"{",
"res",
".",
"addAll",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"return",
"Collections",
".",
"unmodifiableList",
"(",
"res",
")",
";",
"}"
] |
Returns an immutable collection of all the Cell objects contained in this Cells. Beware that internally each list
of cells is associated to the table owning those cells, this method flattens the lists of cells known to this
object to just one list, thus losing the table information.
@return the request list of Cell objects.
|
[
"Returns",
"an",
"immutable",
"collection",
"of",
"all",
"the",
"Cell",
"objects",
"contained",
"in",
"this",
"Cells",
".",
"Beware",
"that",
"internally",
"each",
"list",
"of",
"cells",
"is",
"associated",
"to",
"the",
"table",
"owning",
"those",
"cells",
"this",
"method",
"flattens",
"the",
"lists",
"of",
"cells",
"known",
"to",
"this",
"object",
"to",
"just",
"one",
"list",
"thus",
"losing",
"the",
"table",
"information",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/entity/Cells.java#L346-L354
|
3,925 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/DeepCqlRecordWriter.java
|
DeepCqlRecordWriter.write
|
public void write(Cells keys, Cells values) {
if (!hasCurrentTask) {
String localCql = queryBuilder.prepareQuery(keys, values);
currentTask = new WriteTask(localCql);
hasCurrentTask = true;
}
// add primary key columns to the bind variables
List<Object> allValues = new ArrayList<>(values.getCellValues());
allValues.addAll(keys.getCellValues());
currentTask.add(allValues);
if (isBatchSizeReached()) {
executeTaskAsync();
}
}
|
java
|
public void write(Cells keys, Cells values) {
if (!hasCurrentTask) {
String localCql = queryBuilder.prepareQuery(keys, values);
currentTask = new WriteTask(localCql);
hasCurrentTask = true;
}
// add primary key columns to the bind variables
List<Object> allValues = new ArrayList<>(values.getCellValues());
allValues.addAll(keys.getCellValues());
currentTask.add(allValues);
if (isBatchSizeReached()) {
executeTaskAsync();
}
}
|
[
"public",
"void",
"write",
"(",
"Cells",
"keys",
",",
"Cells",
"values",
")",
"{",
"if",
"(",
"!",
"hasCurrentTask",
")",
"{",
"String",
"localCql",
"=",
"queryBuilder",
".",
"prepareQuery",
"(",
"keys",
",",
"values",
")",
";",
"currentTask",
"=",
"new",
"WriteTask",
"(",
"localCql",
")",
";",
"hasCurrentTask",
"=",
"true",
";",
"}",
"// add primary key columns to the bind variables",
"List",
"<",
"Object",
">",
"allValues",
"=",
"new",
"ArrayList",
"<>",
"(",
"values",
".",
"getCellValues",
"(",
")",
")",
";",
"allValues",
".",
"addAll",
"(",
"keys",
".",
"getCellValues",
"(",
")",
")",
";",
"currentTask",
".",
"add",
"(",
"allValues",
")",
";",
"if",
"(",
"isBatchSizeReached",
"(",
")",
")",
"{",
"executeTaskAsync",
"(",
")",
";",
"}",
"}"
] |
Adds the provided row to a batch. If the batch size reaches the threshold configured in
IDeepJobConfig.getBatchSize the batch will be sent to the data store.
@param keys the Cells object containing the row keys.
@param values the Cells object containing all the other row columns.
|
[
"Adds",
"the",
"provided",
"row",
"to",
"a",
"batch",
".",
"If",
"the",
"batch",
"size",
"reaches",
"the",
"threshold",
"configured",
"in",
"IDeepJobConfig",
".",
"getBatchSize",
"the",
"batch",
"will",
"be",
"sent",
"to",
"the",
"data",
"store",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/DeepCqlRecordWriter.java#L107-L123
|
3,926 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/DeepCqlRecordWriter.java
|
DeepCqlRecordWriter.executeTaskAsync
|
private void executeTaskAsync() {
final String taskId = currentTask.getId();
ListenableFuture<?> future = taskExecutorService.submit(currentTask);
pendingTasks.put(taskId, future);
future.addListener(new Runnable() {
@Override
public void run() {
pendingTasks.remove(taskId);
}
}, MoreExecutors.sameThreadExecutor());
hasCurrentTask = false;
}
|
java
|
private void executeTaskAsync() {
final String taskId = currentTask.getId();
ListenableFuture<?> future = taskExecutorService.submit(currentTask);
pendingTasks.put(taskId, future);
future.addListener(new Runnable() {
@Override
public void run() {
pendingTasks.remove(taskId);
}
}, MoreExecutors.sameThreadExecutor());
hasCurrentTask = false;
}
|
[
"private",
"void",
"executeTaskAsync",
"(",
")",
"{",
"final",
"String",
"taskId",
"=",
"currentTask",
".",
"getId",
"(",
")",
";",
"ListenableFuture",
"<",
"?",
">",
"future",
"=",
"taskExecutorService",
".",
"submit",
"(",
"currentTask",
")",
";",
"pendingTasks",
".",
"put",
"(",
"taskId",
",",
"future",
")",
";",
"future",
".",
"addListener",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"pendingTasks",
".",
"remove",
"(",
"taskId",
")",
";",
"}",
"}",
",",
"MoreExecutors",
".",
"sameThreadExecutor",
"(",
")",
")",
";",
"hasCurrentTask",
"=",
"false",
";",
"}"
] |
Submits the task for future execution. Task is added to pending tasks
and removed when the execution is done.
|
[
"Submits",
"the",
"task",
"for",
"future",
"execution",
".",
"Task",
"is",
"added",
"to",
"pending",
"tasks",
"and",
"removed",
"when",
"the",
"execution",
"is",
"done",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/DeepCqlRecordWriter.java#L136-L150
|
3,927 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/DeepCqlRecordWriter.java
|
DeepCqlRecordWriter.waitForCompletion
|
private void waitForCompletion() {
for (ListenableFuture<?> future : pendingTasks.values()) {
try {
future.get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("[" + this + "] Error waiting for writes to complete: " + e.getMessage());
}
}
}
|
java
|
private void waitForCompletion() {
for (ListenableFuture<?> future : pendingTasks.values()) {
try {
future.get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("[" + this + "] Error waiting for writes to complete: " + e.getMessage());
}
}
}
|
[
"private",
"void",
"waitForCompletion",
"(",
")",
"{",
"for",
"(",
"ListenableFuture",
"<",
"?",
">",
"future",
":",
"pendingTasks",
".",
"values",
"(",
")",
")",
"{",
"try",
"{",
"future",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"|",
"ExecutionException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"[\"",
"+",
"this",
"+",
"\"] Error waiting for writes to complete: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Waits until all pending tasks completed.
|
[
"Waits",
"until",
"all",
"pending",
"tasks",
"completed",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/DeepCqlRecordWriter.java#L155-L163
|
3,928 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/entity/CellValidator.java
|
CellValidator.cellValidator
|
public static <T> CellValidator cellValidator(T obj) {
if (obj == null) {
return null;
}
Kind kind = Kind.objectToKind(obj);
AbstractType<?> tAbstractType = CassandraUtils.marshallerInstance(obj);
String validatorClassName = tAbstractType.getClass().getCanonicalName();
Collection<String> validatorTypes = null;
DataType.Name cqlTypeName = MAP_JAVA_TYPE_TO_DATA_TYPE_NAME.get(validatorClassName);// tAbstractType.get
return new CellValidator(validatorClassName, kind, validatorTypes, cqlTypeName);
}
|
java
|
public static <T> CellValidator cellValidator(T obj) {
if (obj == null) {
return null;
}
Kind kind = Kind.objectToKind(obj);
AbstractType<?> tAbstractType = CassandraUtils.marshallerInstance(obj);
String validatorClassName = tAbstractType.getClass().getCanonicalName();
Collection<String> validatorTypes = null;
DataType.Name cqlTypeName = MAP_JAVA_TYPE_TO_DATA_TYPE_NAME.get(validatorClassName);// tAbstractType.get
return new CellValidator(validatorClassName, kind, validatorTypes, cqlTypeName);
}
|
[
"public",
"static",
"<",
"T",
">",
"CellValidator",
"cellValidator",
"(",
"T",
"obj",
")",
"{",
"if",
"(",
"obj",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Kind",
"kind",
"=",
"Kind",
".",
"objectToKind",
"(",
"obj",
")",
";",
"AbstractType",
"<",
"?",
">",
"tAbstractType",
"=",
"CassandraUtils",
".",
"marshallerInstance",
"(",
"obj",
")",
";",
"String",
"validatorClassName",
"=",
"tAbstractType",
".",
"getClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
";",
"Collection",
"<",
"String",
">",
"validatorTypes",
"=",
"null",
";",
"DataType",
".",
"Name",
"cqlTypeName",
"=",
"MAP_JAVA_TYPE_TO_DATA_TYPE_NAME",
".",
"get",
"(",
"validatorClassName",
")",
";",
"// tAbstractType.get",
"return",
"new",
"CellValidator",
"(",
"validatorClassName",
",",
"kind",
",",
"validatorTypes",
",",
"cqlTypeName",
")",
";",
"}"
] |
Generates a CellValidator for a generic instance of an object.
We need the actual instance in order to differentiate between an UUID and a TimeUUID.
@param obj an instance to use to build the new CellValidator.
@param <T> the generic type of the provided object instance.
@return a new CellValidator associated to the provided object.
|
[
"Generates",
"a",
"CellValidator",
"for",
"a",
"generic",
"instance",
"of",
"an",
"object",
".",
"We",
"need",
"the",
"actual",
"instance",
"in",
"order",
"to",
"differentiate",
"between",
"an",
"UUID",
"and",
"a",
"TimeUUID",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/entity/CellValidator.java#L247-L259
|
3,929 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/entity/CellValidator.java
|
CellValidator.getCollectionInnerType
|
private static String getCollectionInnerType(Class<?> type) {
CQL3Type.Native nativeType = MAP_JAVA_TYPE_TO_CQL_TYPE.get(type);
return nativeType.name().toLowerCase();
}
|
java
|
private static String getCollectionInnerType(Class<?> type) {
CQL3Type.Native nativeType = MAP_JAVA_TYPE_TO_CQL_TYPE.get(type);
return nativeType.name().toLowerCase();
}
|
[
"private",
"static",
"String",
"getCollectionInnerType",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"CQL3Type",
".",
"Native",
"nativeType",
"=",
"MAP_JAVA_TYPE_TO_CQL_TYPE",
".",
"get",
"(",
"type",
")",
";",
"return",
"nativeType",
".",
"name",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"}"
] |
private constructor.
|
[
"private",
"constructor",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/entity/CellValidator.java#L275-L278
|
3,930 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/config/CassandraConfigFactory.java
|
CassandraConfigFactory.create
|
public static <T extends IDeepType> CassandraDeepJobConfig<T> create(Class<T> entityClass) {
return new EntityDeepJobConfig<>(entityClass);
}
|
java
|
public static <T extends IDeepType> CassandraDeepJobConfig<T> create(Class<T> entityClass) {
return new EntityDeepJobConfig<>(entityClass);
}
|
[
"public",
"static",
"<",
"T",
"extends",
"IDeepType",
">",
"CassandraDeepJobConfig",
"<",
"T",
">",
"create",
"(",
"Class",
"<",
"T",
">",
"entityClass",
")",
"{",
"return",
"new",
"EntityDeepJobConfig",
"<>",
"(",
"entityClass",
")",
";",
"}"
] |
Creates an entity-based configuration object.
@param entityClass the class instance of the entity class that will be used to map db objects to Java objects.
@param <T> the generic type of the entity object implementing IDeepType.
@return a new an entity-based configuration object.
|
[
"Creates",
"an",
"entity",
"-",
"based",
"configuration",
"object",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/config/CassandraConfigFactory.java#L68-L70
|
3,931 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/config/CassandraConfigFactory.java
|
CassandraConfigFactory.createWriteConfig
|
public static <T extends IDeepType> CassandraDeepJobConfig<T> createWriteConfig(Class<T> entityClass) {
return new EntityDeepJobConfig<>(entityClass, true);
}
|
java
|
public static <T extends IDeepType> CassandraDeepJobConfig<T> createWriteConfig(Class<T> entityClass) {
return new EntityDeepJobConfig<>(entityClass, true);
}
|
[
"public",
"static",
"<",
"T",
"extends",
"IDeepType",
">",
"CassandraDeepJobConfig",
"<",
"T",
">",
"createWriteConfig",
"(",
"Class",
"<",
"T",
">",
"entityClass",
")",
"{",
"return",
"new",
"EntityDeepJobConfig",
"<>",
"(",
"entityClass",
",",
"true",
")",
";",
"}"
] |
Creates an entity-based write configuration object.
@return an entity-based write configuration object.
|
[
"Creates",
"an",
"entity",
"-",
"based",
"write",
"configuration",
"object",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/config/CassandraConfigFactory.java#L77-L79
|
3,932 |
Stratio/deep-spark
|
deep-mongodb/src/main/java/com/stratio/deep/mongodb/utils/UtilMongoDB.java
|
UtilMongoDB.getObjectFromBson
|
public static <T> T getObjectFromBson(Class<T> classEntity, BSONObject bsonObject)
throws IllegalAccessException, InstantiationException, InvocationTargetException {
T t = classEntity.newInstance();
Field[] fields = AnnotationUtils.filterDeepFields(classEntity);
Object insert = null;
for (Field field : fields) {
Object currentBson = null;
Method method = null;
try {
method = Utils.findSetter(field.getName(), classEntity, field.getType());
Class<?> classField = field.getType();
currentBson = bsonObject.get(AnnotationUtils.deepFieldName(field));
if (currentBson != null) {
if (Iterable.class.isAssignableFrom(classField)) {
Type type = field.getGenericType();
insert = subDocumentListCase(type, (List) bsonObject.get(AnnotationUtils.deepFieldName(field)));
} else if (IDeepType.class.isAssignableFrom(classField)) {
insert = getObjectFromBson(classField, (BSONObject) bsonObject.get(AnnotationUtils.deepFieldName
(field)));
} else {
insert = currentBson;
}
method.invoke(t, insert);
}
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | IllegalArgumentException e) {
LOG.error("impossible to create a java object from Bson field:" + field.getName() + " and type:" + field
.getType() + " and value:" + t + "; bsonReceived:" + currentBson + ", bsonClassReceived:"
+ currentBson.getClass());
method.invoke(t, Utils.castNumberType(insert, t.getClass()));
}
}
return t;
}
|
java
|
public static <T> T getObjectFromBson(Class<T> classEntity, BSONObject bsonObject)
throws IllegalAccessException, InstantiationException, InvocationTargetException {
T t = classEntity.newInstance();
Field[] fields = AnnotationUtils.filterDeepFields(classEntity);
Object insert = null;
for (Field field : fields) {
Object currentBson = null;
Method method = null;
try {
method = Utils.findSetter(field.getName(), classEntity, field.getType());
Class<?> classField = field.getType();
currentBson = bsonObject.get(AnnotationUtils.deepFieldName(field));
if (currentBson != null) {
if (Iterable.class.isAssignableFrom(classField)) {
Type type = field.getGenericType();
insert = subDocumentListCase(type, (List) bsonObject.get(AnnotationUtils.deepFieldName(field)));
} else if (IDeepType.class.isAssignableFrom(classField)) {
insert = getObjectFromBson(classField, (BSONObject) bsonObject.get(AnnotationUtils.deepFieldName
(field)));
} else {
insert = currentBson;
}
method.invoke(t, insert);
}
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | IllegalArgumentException e) {
LOG.error("impossible to create a java object from Bson field:" + field.getName() + " and type:" + field
.getType() + " and value:" + t + "; bsonReceived:" + currentBson + ", bsonClassReceived:"
+ currentBson.getClass());
method.invoke(t, Utils.castNumberType(insert, t.getClass()));
}
}
return t;
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"getObjectFromBson",
"(",
"Class",
"<",
"T",
">",
"classEntity",
",",
"BSONObject",
"bsonObject",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"InvocationTargetException",
"{",
"T",
"t",
"=",
"classEntity",
".",
"newInstance",
"(",
")",
";",
"Field",
"[",
"]",
"fields",
"=",
"AnnotationUtils",
".",
"filterDeepFields",
"(",
"classEntity",
")",
";",
"Object",
"insert",
"=",
"null",
";",
"for",
"(",
"Field",
"field",
":",
"fields",
")",
"{",
"Object",
"currentBson",
"=",
"null",
";",
"Method",
"method",
"=",
"null",
";",
"try",
"{",
"method",
"=",
"Utils",
".",
"findSetter",
"(",
"field",
".",
"getName",
"(",
")",
",",
"classEntity",
",",
"field",
".",
"getType",
"(",
")",
")",
";",
"Class",
"<",
"?",
">",
"classField",
"=",
"field",
".",
"getType",
"(",
")",
";",
"currentBson",
"=",
"bsonObject",
".",
"get",
"(",
"AnnotationUtils",
".",
"deepFieldName",
"(",
"field",
")",
")",
";",
"if",
"(",
"currentBson",
"!=",
"null",
")",
"{",
"if",
"(",
"Iterable",
".",
"class",
".",
"isAssignableFrom",
"(",
"classField",
")",
")",
"{",
"Type",
"type",
"=",
"field",
".",
"getGenericType",
"(",
")",
";",
"insert",
"=",
"subDocumentListCase",
"(",
"type",
",",
"(",
"List",
")",
"bsonObject",
".",
"get",
"(",
"AnnotationUtils",
".",
"deepFieldName",
"(",
"field",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"IDeepType",
".",
"class",
".",
"isAssignableFrom",
"(",
"classField",
")",
")",
"{",
"insert",
"=",
"getObjectFromBson",
"(",
"classField",
",",
"(",
"BSONObject",
")",
"bsonObject",
".",
"get",
"(",
"AnnotationUtils",
".",
"deepFieldName",
"(",
"field",
")",
")",
")",
";",
"}",
"else",
"{",
"insert",
"=",
"currentBson",
";",
"}",
"method",
".",
"invoke",
"(",
"t",
",",
"insert",
")",
";",
"}",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"InstantiationException",
"|",
"InvocationTargetException",
"|",
"IllegalArgumentException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"impossible to create a java object from Bson field:\"",
"+",
"field",
".",
"getName",
"(",
")",
"+",
"\" and type:\"",
"+",
"field",
".",
"getType",
"(",
")",
"+",
"\" and value:\"",
"+",
"t",
"+",
"\"; bsonReceived:\"",
"+",
"currentBson",
"+",
"\", bsonClassReceived:\"",
"+",
"currentBson",
".",
"getClass",
"(",
")",
")",
";",
"method",
".",
"invoke",
"(",
"t",
",",
"Utils",
".",
"castNumberType",
"(",
"insert",
",",
"t",
".",
"getClass",
"(",
")",
")",
")",
";",
"}",
"}",
"return",
"t",
";",
"}"
] |
converts from BsonObject to an entity class with deep's anotations
@param classEntity the entity name.
@param bsonObject the instance of the BSONObjet to convert.
@return the provided bsonObject converted to an instance of T.
@throws IllegalAccessException the illegal access exception
@throws IllegalAccessException the instantiation exception
@throws IllegalAccessException the invocation target exception
|
[
"converts",
"from",
"BsonObject",
"to",
"an",
"entity",
"class",
"with",
"deep",
"s",
"anotations"
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/utils/UtilMongoDB.java#L77-L120
|
3,933 |
Stratio/deep-spark
|
deep-mongodb/src/main/java/com/stratio/deep/mongodb/utils/UtilMongoDB.java
|
UtilMongoDB.getBsonFromObject
|
public static <T> DBObject getBsonFromObject(T t)
throws IllegalAccessException, InstantiationException, InvocationTargetException {
Field[] fields = AnnotationUtils.filterDeepFields(t.getClass());
DBObject bson = new BasicDBObject();
for (Field field : fields) {
Method method = Utils.findGetter(field.getName(), t.getClass());
Object object = method.invoke(t);
if (object != null) {
if (Collection.class.isAssignableFrom(field.getType())) {
Collection c = (Collection) object;
Iterator iterator = c.iterator();
List innerBsonList = new ArrayList<>();
while (iterator.hasNext()) {
innerBsonList.add(getBsonFromObject(iterator.next()));
}
bson.put(AnnotationUtils.deepFieldName(field), innerBsonList);
} else if (IDeepType.class.isAssignableFrom(field.getType())) {
bson.put(AnnotationUtils.deepFieldName(field), getBsonFromObject((IDeepType) object));
} else {
bson.put(AnnotationUtils.deepFieldName(field), object);
}
}
}
return bson;
}
|
java
|
public static <T> DBObject getBsonFromObject(T t)
throws IllegalAccessException, InstantiationException, InvocationTargetException {
Field[] fields = AnnotationUtils.filterDeepFields(t.getClass());
DBObject bson = new BasicDBObject();
for (Field field : fields) {
Method method = Utils.findGetter(field.getName(), t.getClass());
Object object = method.invoke(t);
if (object != null) {
if (Collection.class.isAssignableFrom(field.getType())) {
Collection c = (Collection) object;
Iterator iterator = c.iterator();
List innerBsonList = new ArrayList<>();
while (iterator.hasNext()) {
innerBsonList.add(getBsonFromObject(iterator.next()));
}
bson.put(AnnotationUtils.deepFieldName(field), innerBsonList);
} else if (IDeepType.class.isAssignableFrom(field.getType())) {
bson.put(AnnotationUtils.deepFieldName(field), getBsonFromObject((IDeepType) object));
} else {
bson.put(AnnotationUtils.deepFieldName(field), object);
}
}
}
return bson;
}
|
[
"public",
"static",
"<",
"T",
">",
"DBObject",
"getBsonFromObject",
"(",
"T",
"t",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"InvocationTargetException",
"{",
"Field",
"[",
"]",
"fields",
"=",
"AnnotationUtils",
".",
"filterDeepFields",
"(",
"t",
".",
"getClass",
"(",
")",
")",
";",
"DBObject",
"bson",
"=",
"new",
"BasicDBObject",
"(",
")",
";",
"for",
"(",
"Field",
"field",
":",
"fields",
")",
"{",
"Method",
"method",
"=",
"Utils",
".",
"findGetter",
"(",
"field",
".",
"getName",
"(",
")",
",",
"t",
".",
"getClass",
"(",
")",
")",
";",
"Object",
"object",
"=",
"method",
".",
"invoke",
"(",
"t",
")",
";",
"if",
"(",
"object",
"!=",
"null",
")",
"{",
"if",
"(",
"Collection",
".",
"class",
".",
"isAssignableFrom",
"(",
"field",
".",
"getType",
"(",
")",
")",
")",
"{",
"Collection",
"c",
"=",
"(",
"Collection",
")",
"object",
";",
"Iterator",
"iterator",
"=",
"c",
".",
"iterator",
"(",
")",
";",
"List",
"innerBsonList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"innerBsonList",
".",
"add",
"(",
"getBsonFromObject",
"(",
"iterator",
".",
"next",
"(",
")",
")",
")",
";",
"}",
"bson",
".",
"put",
"(",
"AnnotationUtils",
".",
"deepFieldName",
"(",
"field",
")",
",",
"innerBsonList",
")",
";",
"}",
"else",
"if",
"(",
"IDeepType",
".",
"class",
".",
"isAssignableFrom",
"(",
"field",
".",
"getType",
"(",
")",
")",
")",
"{",
"bson",
".",
"put",
"(",
"AnnotationUtils",
".",
"deepFieldName",
"(",
"field",
")",
",",
"getBsonFromObject",
"(",
"(",
"IDeepType",
")",
"object",
")",
")",
";",
"}",
"else",
"{",
"bson",
".",
"put",
"(",
"AnnotationUtils",
".",
"deepFieldName",
"(",
"field",
")",
",",
"object",
")",
";",
"}",
"}",
"}",
"return",
"bson",
";",
"}"
] |
converts from an entity class with deep's anotations to BsonObject.
@param t an instance of an object of type T to convert to BSONObject.
@return the provided object converted to BSONObject.
@throws IllegalAccessException the illegal access exception
@throws IllegalAccessException the instantiation exception
@throws IllegalAccessException the invocation target exception
|
[
"converts",
"from",
"an",
"entity",
"class",
"with",
"deep",
"s",
"anotations",
"to",
"BsonObject",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/utils/UtilMongoDB.java#L156-L184
|
3,934 |
Stratio/deep-spark
|
deep-mongodb/src/main/java/com/stratio/deep/mongodb/utils/UtilMongoDB.java
|
UtilMongoDB.getCellFromBson
|
public static Cells getCellFromBson(BSONObject bsonObject, String tableName) {
Cells cells = tableName != null ? new Cells(tableName) : new Cells();
Map<String, Object> map = bsonObject.toMap();
Set<Map.Entry<String, Object>> entryBson = map.entrySet();
for (Map.Entry<String, Object> entry : entryBson) {
try {
if (List.class.isAssignableFrom(entry.getValue().getClass())) {
List innerCell = new ArrayList<>();
for (Object innerBson : (List)entry.getValue()) {
if(innerBson instanceof DBObject){
innerCell.add(getCellFromBson((DBObject)innerBson, null));
}else{
innerCell.add(innerBson);
}
}
cells.add(Cell.create(entry.getKey(), innerCell));
} else if (BSONObject.class.isAssignableFrom(entry.getValue().getClass())) {
Cells innerCells = getCellFromBson((BSONObject) entry.getValue(), null);
cells.add(Cell.create(entry.getKey(), innerCells));
} else {
cells.add(Cell.create(entry.getKey(), entry.getValue()));
}
} catch (IllegalArgumentException e) {
LOG.error("impossible to create a java cell from Bson field:" + entry.getKey() + ", type:" + entry
.getValue().getClass() + ", value:" + entry.getValue());
}
}
return cells;
}
|
java
|
public static Cells getCellFromBson(BSONObject bsonObject, String tableName) {
Cells cells = tableName != null ? new Cells(tableName) : new Cells();
Map<String, Object> map = bsonObject.toMap();
Set<Map.Entry<String, Object>> entryBson = map.entrySet();
for (Map.Entry<String, Object> entry : entryBson) {
try {
if (List.class.isAssignableFrom(entry.getValue().getClass())) {
List innerCell = new ArrayList<>();
for (Object innerBson : (List)entry.getValue()) {
if(innerBson instanceof DBObject){
innerCell.add(getCellFromBson((DBObject)innerBson, null));
}else{
innerCell.add(innerBson);
}
}
cells.add(Cell.create(entry.getKey(), innerCell));
} else if (BSONObject.class.isAssignableFrom(entry.getValue().getClass())) {
Cells innerCells = getCellFromBson((BSONObject) entry.getValue(), null);
cells.add(Cell.create(entry.getKey(), innerCells));
} else {
cells.add(Cell.create(entry.getKey(), entry.getValue()));
}
} catch (IllegalArgumentException e) {
LOG.error("impossible to create a java cell from Bson field:" + entry.getKey() + ", type:" + entry
.getValue().getClass() + ", value:" + entry.getValue());
}
}
return cells;
}
|
[
"public",
"static",
"Cells",
"getCellFromBson",
"(",
"BSONObject",
"bsonObject",
",",
"String",
"tableName",
")",
"{",
"Cells",
"cells",
"=",
"tableName",
"!=",
"null",
"?",
"new",
"Cells",
"(",
"tableName",
")",
":",
"new",
"Cells",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"bsonObject",
".",
"toMap",
"(",
")",
";",
"Set",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
">",
"entryBson",
"=",
"map",
".",
"entrySet",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"entryBson",
")",
"{",
"try",
"{",
"if",
"(",
"List",
".",
"class",
".",
"isAssignableFrom",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"getClass",
"(",
")",
")",
")",
"{",
"List",
"innerCell",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Object",
"innerBson",
":",
"(",
"List",
")",
"entry",
".",
"getValue",
"(",
")",
")",
"{",
"if",
"(",
"innerBson",
"instanceof",
"DBObject",
")",
"{",
"innerCell",
".",
"add",
"(",
"getCellFromBson",
"(",
"(",
"DBObject",
")",
"innerBson",
",",
"null",
")",
")",
";",
"}",
"else",
"{",
"innerCell",
".",
"add",
"(",
"innerBson",
")",
";",
"}",
"}",
"cells",
".",
"add",
"(",
"Cell",
".",
"create",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"innerCell",
")",
")",
";",
"}",
"else",
"if",
"(",
"BSONObject",
".",
"class",
".",
"isAssignableFrom",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"getClass",
"(",
")",
")",
")",
"{",
"Cells",
"innerCells",
"=",
"getCellFromBson",
"(",
"(",
"BSONObject",
")",
"entry",
".",
"getValue",
"(",
")",
",",
"null",
")",
";",
"cells",
".",
"add",
"(",
"Cell",
".",
"create",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"innerCells",
")",
")",
";",
"}",
"else",
"{",
"cells",
".",
"add",
"(",
"Cell",
".",
"create",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"impossible to create a java cell from Bson field:\"",
"+",
"entry",
".",
"getKey",
"(",
")",
"+",
"\", type:\"",
"+",
"entry",
".",
"getValue",
"(",
")",
".",
"getClass",
"(",
")",
"+",
"\", value:\"",
"+",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"return",
"cells",
";",
"}"
] |
converts from BsonObject to cell class with deep's anotations
@param bsonObject the bson object
@param tableName the table name
@return cell from bson
@throws IllegalAccessException the illegal access exception
@throws IllegalAccessException the instantiation exception
@throws IllegalAccessException the invocation target exception
|
[
"converts",
"from",
"BsonObject",
"to",
"cell",
"class",
"with",
"deep",
"s",
"anotations"
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/utils/UtilMongoDB.java#L219-L254
|
3,935 |
Stratio/deep-spark
|
deep-mongodb/src/main/java/com/stratio/deep/mongodb/utils/UtilMongoDB.java
|
UtilMongoDB.getDBObjectFromCell
|
public static DBObject getDBObjectFromCell(Cells cells) {
DBObject bson = new BasicDBObject();
for (Cell cell : cells) {
if (cell.getValue() != null) {
if (Collection.class.isAssignableFrom(cell.getCellValue().getClass())) {
Collection c = (Collection) cell.getCellValue();
Iterator iterator = c.iterator();
List<Object> innerBsonList = new ArrayList<>();
while (iterator.hasNext()) {
Object currentO = iterator.next();
if(currentO instanceof Cells){
innerBsonList.add(getDBObjectFromCell((Cells) currentO));
}else{
innerBsonList.add(currentO);
}
}
bson.put(cell.getCellName(), innerBsonList);
} else if (Cells.class.isAssignableFrom(cell.getCellValue().getClass())) {
bson.put(cell.getCellName(), getDBObjectFromCell((Cells) cell.getCellValue()));
} else {
bson.put(cell.getCellName(), cell.getCellValue());
}
}
}
return bson;
}
|
java
|
public static DBObject getDBObjectFromCell(Cells cells) {
DBObject bson = new BasicDBObject();
for (Cell cell : cells) {
if (cell.getValue() != null) {
if (Collection.class.isAssignableFrom(cell.getCellValue().getClass())) {
Collection c = (Collection) cell.getCellValue();
Iterator iterator = c.iterator();
List<Object> innerBsonList = new ArrayList<>();
while (iterator.hasNext()) {
Object currentO = iterator.next();
if(currentO instanceof Cells){
innerBsonList.add(getDBObjectFromCell((Cells) currentO));
}else{
innerBsonList.add(currentO);
}
}
bson.put(cell.getCellName(), innerBsonList);
} else if (Cells.class.isAssignableFrom(cell.getCellValue().getClass())) {
bson.put(cell.getCellName(), getDBObjectFromCell((Cells) cell.getCellValue()));
} else {
bson.put(cell.getCellName(), cell.getCellValue());
}
}
}
return bson;
}
|
[
"public",
"static",
"DBObject",
"getDBObjectFromCell",
"(",
"Cells",
"cells",
")",
"{",
"DBObject",
"bson",
"=",
"new",
"BasicDBObject",
"(",
")",
";",
"for",
"(",
"Cell",
"cell",
":",
"cells",
")",
"{",
"if",
"(",
"cell",
".",
"getValue",
"(",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"Collection",
".",
"class",
".",
"isAssignableFrom",
"(",
"cell",
".",
"getCellValue",
"(",
")",
".",
"getClass",
"(",
")",
")",
")",
"{",
"Collection",
"c",
"=",
"(",
"Collection",
")",
"cell",
".",
"getCellValue",
"(",
")",
";",
"Iterator",
"iterator",
"=",
"c",
".",
"iterator",
"(",
")",
";",
"List",
"<",
"Object",
">",
"innerBsonList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"Object",
"currentO",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"currentO",
"instanceof",
"Cells",
")",
"{",
"innerBsonList",
".",
"add",
"(",
"getDBObjectFromCell",
"(",
"(",
"Cells",
")",
"currentO",
")",
")",
";",
"}",
"else",
"{",
"innerBsonList",
".",
"add",
"(",
"currentO",
")",
";",
"}",
"}",
"bson",
".",
"put",
"(",
"cell",
".",
"getCellName",
"(",
")",
",",
"innerBsonList",
")",
";",
"}",
"else",
"if",
"(",
"Cells",
".",
"class",
".",
"isAssignableFrom",
"(",
"cell",
".",
"getCellValue",
"(",
")",
".",
"getClass",
"(",
")",
")",
")",
"{",
"bson",
".",
"put",
"(",
"cell",
".",
"getCellName",
"(",
")",
",",
"getDBObjectFromCell",
"(",
"(",
"Cells",
")",
"cell",
".",
"getCellValue",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"bson",
".",
"put",
"(",
"cell",
".",
"getCellName",
"(",
")",
",",
"cell",
".",
"getCellValue",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"bson",
";",
"}"
] |
converts from and entity class with deep's anotations to BsonObject
@param cells the cells
@return bson from cell
|
[
"converts",
"from",
"and",
"entity",
"class",
"with",
"deep",
"s",
"anotations",
"to",
"BsonObject"
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/utils/UtilMongoDB.java#L263-L291
|
3,936 |
Stratio/deep-spark
|
deep-jdbc/src/main/java/com/stratio/deep/jdbc/extractor/JdbcNativeEntityExtractor.java
|
JdbcNativeEntityExtractor.transformElement
|
@Override
protected T transformElement(Map<String, Object> entity) {
try {
return (T)UtilJdbc.getObjectFromRow(jdbcDeepJobConfig.getEntityClass(), entity, jdbcDeepJobConfig);
} catch(IllegalAccessException | InvocationTargetException | InstantiationException e) {
throw new DeepTransformException(e);
}
}
|
java
|
@Override
protected T transformElement(Map<String, Object> entity) {
try {
return (T)UtilJdbc.getObjectFromRow(jdbcDeepJobConfig.getEntityClass(), entity, jdbcDeepJobConfig);
} catch(IllegalAccessException | InvocationTargetException | InstantiationException e) {
throw new DeepTransformException(e);
}
}
|
[
"@",
"Override",
"protected",
"T",
"transformElement",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"entity",
")",
"{",
"try",
"{",
"return",
"(",
"T",
")",
"UtilJdbc",
".",
"getObjectFromRow",
"(",
"jdbcDeepJobConfig",
".",
"getEntityClass",
"(",
")",
",",
"entity",
",",
"jdbcDeepJobConfig",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"InvocationTargetException",
"|",
"InstantiationException",
"e",
")",
"{",
"throw",
"new",
"DeepTransformException",
"(",
"e",
")",
";",
"}",
"}"
] |
Transforms a database row represented as a Map into a Stratio Deep Entity.
@param entity Database row represented as a Map of column_name:column_value.
@return Stratio Deep Entity carrying row data.
|
[
"Transforms",
"a",
"database",
"row",
"represented",
"as",
"a",
"Map",
"into",
"a",
"Stratio",
"Deep",
"Entity",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-jdbc/src/main/java/com/stratio/deep/jdbc/extractor/JdbcNativeEntityExtractor.java#L46-L53
|
3,937 |
Stratio/deep-spark
|
deep-jdbc/src/main/java/com/stratio/deep/jdbc/extractor/JdbcNativeEntityExtractor.java
|
JdbcNativeEntityExtractor.transformElement
|
@Override
protected Map<String, Object> transformElement(T entity) {
try {
return UtilJdbc.getRowFromObject(entity);
} catch(IllegalAccessException | InvocationTargetException | InstantiationException e) {
throw new DeepTransformException(e);
}
}
|
java
|
@Override
protected Map<String, Object> transformElement(T entity) {
try {
return UtilJdbc.getRowFromObject(entity);
} catch(IllegalAccessException | InvocationTargetException | InstantiationException e) {
throw new DeepTransformException(e);
}
}
|
[
"@",
"Override",
"protected",
"Map",
"<",
"String",
",",
"Object",
">",
"transformElement",
"(",
"T",
"entity",
")",
"{",
"try",
"{",
"return",
"UtilJdbc",
".",
"getRowFromObject",
"(",
"entity",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"InvocationTargetException",
"|",
"InstantiationException",
"e",
")",
"{",
"throw",
"new",
"DeepTransformException",
"(",
"e",
")",
";",
"}",
"}"
] |
Trasforms a Stratio Deep Entity into a database row represented as a Map.
@param entity Stratio Deep entity.
@return Database row represented as a Map of column_name:column_value.
|
[
"Trasforms",
"a",
"Stratio",
"Deep",
"Entity",
"into",
"a",
"database",
"row",
"represented",
"as",
"a",
"Map",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-jdbc/src/main/java/com/stratio/deep/jdbc/extractor/JdbcNativeEntityExtractor.java#L60-L67
|
3,938 |
Stratio/deep-spark
|
deep-aerospike/src/main/java/com/stratio/deep/aerospike/utils/UtilAerospike.java
|
UtilAerospike.getObjectFromAerospikeRecord
|
public static <T> T getObjectFromAerospikeRecord(Class<T> classEntity, AerospikeRecord aerospikeRecord,
AerospikeDeepJobConfig aerospikeConfig)
throws IllegalAccessException, InstantiationException,
InvocationTargetException {
Tuple2<String, Object> equalsFilter = aerospikeConfig.getEqualsFilter();
String equalsFilterBin = equalsFilter != null ? equalsFilter._1() : null;
Object equalsFilterValue = equalsFilter != null ? equalsFilter._2() : null;
Map<String, Object> bins = aerospikeRecord.bins;
T t = classEntity.newInstance();
if (equalsFilter == null || checkEqualityFilter(bins, equalsFilterBin, equalsFilterValue)) {
Field[] fields = AnnotationUtils.filterDeepFields(classEntity);
Object insert = null;
List<String> inputColumns = null;
if (aerospikeConfig.getInputColumns() != null) {
inputColumns = Arrays.asList(aerospikeConfig.getInputColumns());
}
for (Field field : fields) {
if (inputColumns != null && !inputColumns.contains(AnnotationUtils.deepFieldName(field))) {
continue;
}
Object currentBin = null;
Method method = null;
Class<?> classField = field.getType();
try {
method = Utils.findSetter(field.getName(), classEntity, field.getType());
currentBin = bins.get(AnnotationUtils.deepFieldName(field));
if (currentBin != null) {
if (currentBin instanceof Integer && classField.equals(Long.class)) {
currentBin = new Long((Integer) currentBin);
}
if (currentBin instanceof String || currentBin instanceof Integer
|| currentBin instanceof Long) {
insert = currentBin;
} else {
throw new DeepGenericException("Data type [" + classField.toString()
+ "] not supported in Aerospike entity extractor (only Strings and Integers)");
}
method.invoke(t, insert);
}
} catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException e) {
LOG.error("impossible to create a java object from Bin:" + field.getName() + " and type:"
+ field.getType() + " and value:" + t + "; recordReceived:" + currentBin);
method.invoke(t, Utils.castNumberType(insert, classField));
}
}
}
return t;
}
|
java
|
public static <T> T getObjectFromAerospikeRecord(Class<T> classEntity, AerospikeRecord aerospikeRecord,
AerospikeDeepJobConfig aerospikeConfig)
throws IllegalAccessException, InstantiationException,
InvocationTargetException {
Tuple2<String, Object> equalsFilter = aerospikeConfig.getEqualsFilter();
String equalsFilterBin = equalsFilter != null ? equalsFilter._1() : null;
Object equalsFilterValue = equalsFilter != null ? equalsFilter._2() : null;
Map<String, Object> bins = aerospikeRecord.bins;
T t = classEntity.newInstance();
if (equalsFilter == null || checkEqualityFilter(bins, equalsFilterBin, equalsFilterValue)) {
Field[] fields = AnnotationUtils.filterDeepFields(classEntity);
Object insert = null;
List<String> inputColumns = null;
if (aerospikeConfig.getInputColumns() != null) {
inputColumns = Arrays.asList(aerospikeConfig.getInputColumns());
}
for (Field field : fields) {
if (inputColumns != null && !inputColumns.contains(AnnotationUtils.deepFieldName(field))) {
continue;
}
Object currentBin = null;
Method method = null;
Class<?> classField = field.getType();
try {
method = Utils.findSetter(field.getName(), classEntity, field.getType());
currentBin = bins.get(AnnotationUtils.deepFieldName(field));
if (currentBin != null) {
if (currentBin instanceof Integer && classField.equals(Long.class)) {
currentBin = new Long((Integer) currentBin);
}
if (currentBin instanceof String || currentBin instanceof Integer
|| currentBin instanceof Long) {
insert = currentBin;
} else {
throw new DeepGenericException("Data type [" + classField.toString()
+ "] not supported in Aerospike entity extractor (only Strings and Integers)");
}
method.invoke(t, insert);
}
} catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException e) {
LOG.error("impossible to create a java object from Bin:" + field.getName() + " and type:"
+ field.getType() + " and value:" + t + "; recordReceived:" + currentBin);
method.invoke(t, Utils.castNumberType(insert, classField));
}
}
}
return t;
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"getObjectFromAerospikeRecord",
"(",
"Class",
"<",
"T",
">",
"classEntity",
",",
"AerospikeRecord",
"aerospikeRecord",
",",
"AerospikeDeepJobConfig",
"aerospikeConfig",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"InvocationTargetException",
"{",
"Tuple2",
"<",
"String",
",",
"Object",
">",
"equalsFilter",
"=",
"aerospikeConfig",
".",
"getEqualsFilter",
"(",
")",
";",
"String",
"equalsFilterBin",
"=",
"equalsFilter",
"!=",
"null",
"?",
"equalsFilter",
".",
"_1",
"(",
")",
":",
"null",
";",
"Object",
"equalsFilterValue",
"=",
"equalsFilter",
"!=",
"null",
"?",
"equalsFilter",
".",
"_2",
"(",
")",
":",
"null",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"bins",
"=",
"aerospikeRecord",
".",
"bins",
";",
"T",
"t",
"=",
"classEntity",
".",
"newInstance",
"(",
")",
";",
"if",
"(",
"equalsFilter",
"==",
"null",
"||",
"checkEqualityFilter",
"(",
"bins",
",",
"equalsFilterBin",
",",
"equalsFilterValue",
")",
")",
"{",
"Field",
"[",
"]",
"fields",
"=",
"AnnotationUtils",
".",
"filterDeepFields",
"(",
"classEntity",
")",
";",
"Object",
"insert",
"=",
"null",
";",
"List",
"<",
"String",
">",
"inputColumns",
"=",
"null",
";",
"if",
"(",
"aerospikeConfig",
".",
"getInputColumns",
"(",
")",
"!=",
"null",
")",
"{",
"inputColumns",
"=",
"Arrays",
".",
"asList",
"(",
"aerospikeConfig",
".",
"getInputColumns",
"(",
")",
")",
";",
"}",
"for",
"(",
"Field",
"field",
":",
"fields",
")",
"{",
"if",
"(",
"inputColumns",
"!=",
"null",
"&&",
"!",
"inputColumns",
".",
"contains",
"(",
"AnnotationUtils",
".",
"deepFieldName",
"(",
"field",
")",
")",
")",
"{",
"continue",
";",
"}",
"Object",
"currentBin",
"=",
"null",
";",
"Method",
"method",
"=",
"null",
";",
"Class",
"<",
"?",
">",
"classField",
"=",
"field",
".",
"getType",
"(",
")",
";",
"try",
"{",
"method",
"=",
"Utils",
".",
"findSetter",
"(",
"field",
".",
"getName",
"(",
")",
",",
"classEntity",
",",
"field",
".",
"getType",
"(",
")",
")",
";",
"currentBin",
"=",
"bins",
".",
"get",
"(",
"AnnotationUtils",
".",
"deepFieldName",
"(",
"field",
")",
")",
";",
"if",
"(",
"currentBin",
"!=",
"null",
")",
"{",
"if",
"(",
"currentBin",
"instanceof",
"Integer",
"&&",
"classField",
".",
"equals",
"(",
"Long",
".",
"class",
")",
")",
"{",
"currentBin",
"=",
"new",
"Long",
"(",
"(",
"Integer",
")",
"currentBin",
")",
";",
"}",
"if",
"(",
"currentBin",
"instanceof",
"String",
"||",
"currentBin",
"instanceof",
"Integer",
"||",
"currentBin",
"instanceof",
"Long",
")",
"{",
"insert",
"=",
"currentBin",
";",
"}",
"else",
"{",
"throw",
"new",
"DeepGenericException",
"(",
"\"Data type [\"",
"+",
"classField",
".",
"toString",
"(",
")",
"+",
"\"] not supported in Aerospike entity extractor (only Strings and Integers)\"",
")",
";",
"}",
"method",
".",
"invoke",
"(",
"t",
",",
"insert",
")",
";",
"}",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"InvocationTargetException",
"|",
"IllegalArgumentException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"impossible to create a java object from Bin:\"",
"+",
"field",
".",
"getName",
"(",
")",
"+",
"\" and type:\"",
"+",
"field",
".",
"getType",
"(",
")",
"+",
"\" and value:\"",
"+",
"t",
"+",
"\"; recordReceived:\"",
"+",
"currentBin",
")",
";",
"method",
".",
"invoke",
"(",
"t",
",",
"Utils",
".",
"castNumberType",
"(",
"insert",
",",
"classField",
")",
")",
";",
"}",
"}",
"}",
"return",
"t",
";",
"}"
] |
Converts from AerospikeRecord to an entity class with deep's anotations.
@param classEntity the entity name.
@param aerospikeRecord the instance of the AerospikeRecord to convert.
@param aerospikeConfig Aerospike configuration object.
@param <T> return type.
@return the provided aerospikeRecord converted to an instance of T.
@throws IllegalAccessException
@throws InstantiationException
@throws java.lang.reflect.InvocationTargetException
|
[
"Converts",
"from",
"AerospikeRecord",
"to",
"an",
"entity",
"class",
"with",
"deep",
"s",
"anotations",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-aerospike/src/main/java/com/stratio/deep/aerospike/utils/UtilAerospike.java#L68-L121
|
3,939 |
Stratio/deep-spark
|
deep-aerospike/src/main/java/com/stratio/deep/aerospike/utils/UtilAerospike.java
|
UtilAerospike.getAerospikeRecordFromObject
|
public static <T> Pair<Object, AerospikeRecord> getAerospikeRecordFromObject(T t) throws IllegalAccessException, InstantiationException,
InvocationTargetException {
Field[] fields = AnnotationUtils.filterDeepFields(t.getClass());
Pair<Field[], Field[]> keysAndFields = AnnotationUtils.filterKeyFields(t.getClass());
Field[] keys = keysAndFields.left;
Object key;
Map<String, Object> bins = new HashMap<>();
if(keys.length == 0) {
throw new InvocationTargetException(new Exception("One key field must be defined."));
} else if(keys.length > 1) {
throw new InvocationTargetException(new Exception("Aerospike only supports one key field"));
} else {
Field keyField = keys[0];
Method method = Utils.findGetter(keyField.getName(), t.getClass());
key = method.invoke(t);
}
for (Field field : fields) {
Method method = Utils.findGetter(field.getName(), t.getClass());
Object object = method.invoke(t);
if (object != null) {
bins.put(AnnotationUtils.deepFieldName(field), object);
}
}
Record record = new Record(bins, 0, 0);
AerospikeRecord aerospikeRecord = new AerospikeRecord(record);
Pair<Object, AerospikeRecord> result = Pair.create(key, aerospikeRecord);
return result;
}
|
java
|
public static <T> Pair<Object, AerospikeRecord> getAerospikeRecordFromObject(T t) throws IllegalAccessException, InstantiationException,
InvocationTargetException {
Field[] fields = AnnotationUtils.filterDeepFields(t.getClass());
Pair<Field[], Field[]> keysAndFields = AnnotationUtils.filterKeyFields(t.getClass());
Field[] keys = keysAndFields.left;
Object key;
Map<String, Object> bins = new HashMap<>();
if(keys.length == 0) {
throw new InvocationTargetException(new Exception("One key field must be defined."));
} else if(keys.length > 1) {
throw new InvocationTargetException(new Exception("Aerospike only supports one key field"));
} else {
Field keyField = keys[0];
Method method = Utils.findGetter(keyField.getName(), t.getClass());
key = method.invoke(t);
}
for (Field field : fields) {
Method method = Utils.findGetter(field.getName(), t.getClass());
Object object = method.invoke(t);
if (object != null) {
bins.put(AnnotationUtils.deepFieldName(field), object);
}
}
Record record = new Record(bins, 0, 0);
AerospikeRecord aerospikeRecord = new AerospikeRecord(record);
Pair<Object, AerospikeRecord> result = Pair.create(key, aerospikeRecord);
return result;
}
|
[
"public",
"static",
"<",
"T",
">",
"Pair",
"<",
"Object",
",",
"AerospikeRecord",
">",
"getAerospikeRecordFromObject",
"(",
"T",
"t",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"InvocationTargetException",
"{",
"Field",
"[",
"]",
"fields",
"=",
"AnnotationUtils",
".",
"filterDeepFields",
"(",
"t",
".",
"getClass",
"(",
")",
")",
";",
"Pair",
"<",
"Field",
"[",
"]",
",",
"Field",
"[",
"]",
">",
"keysAndFields",
"=",
"AnnotationUtils",
".",
"filterKeyFields",
"(",
"t",
".",
"getClass",
"(",
")",
")",
";",
"Field",
"[",
"]",
"keys",
"=",
"keysAndFields",
".",
"left",
";",
"Object",
"key",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"bins",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"keys",
".",
"length",
"==",
"0",
")",
"{",
"throw",
"new",
"InvocationTargetException",
"(",
"new",
"Exception",
"(",
"\"One key field must be defined.\"",
")",
")",
";",
"}",
"else",
"if",
"(",
"keys",
".",
"length",
">",
"1",
")",
"{",
"throw",
"new",
"InvocationTargetException",
"(",
"new",
"Exception",
"(",
"\"Aerospike only supports one key field\"",
")",
")",
";",
"}",
"else",
"{",
"Field",
"keyField",
"=",
"keys",
"[",
"0",
"]",
";",
"Method",
"method",
"=",
"Utils",
".",
"findGetter",
"(",
"keyField",
".",
"getName",
"(",
")",
",",
"t",
".",
"getClass",
"(",
")",
")",
";",
"key",
"=",
"method",
".",
"invoke",
"(",
"t",
")",
";",
"}",
"for",
"(",
"Field",
"field",
":",
"fields",
")",
"{",
"Method",
"method",
"=",
"Utils",
".",
"findGetter",
"(",
"field",
".",
"getName",
"(",
")",
",",
"t",
".",
"getClass",
"(",
")",
")",
";",
"Object",
"object",
"=",
"method",
".",
"invoke",
"(",
"t",
")",
";",
"if",
"(",
"object",
"!=",
"null",
")",
"{",
"bins",
".",
"put",
"(",
"AnnotationUtils",
".",
"deepFieldName",
"(",
"field",
")",
",",
"object",
")",
";",
"}",
"}",
"Record",
"record",
"=",
"new",
"Record",
"(",
"bins",
",",
"0",
",",
"0",
")",
";",
"AerospikeRecord",
"aerospikeRecord",
"=",
"new",
"AerospikeRecord",
"(",
"record",
")",
";",
"Pair",
"<",
"Object",
",",
"AerospikeRecord",
">",
"result",
"=",
"Pair",
".",
"create",
"(",
"key",
",",
"aerospikeRecord",
")",
";",
"return",
"result",
";",
"}"
] |
Converts from an entity class with deep's anotations to AerospikeRecord.
@param t an instance of an object of type T to convert to AerospikeRecord.
@param <T> the type of the object to convert.
@return A pair with the Record key and the Record itself.
@throws IllegalAccessException
@throws InstantiationException
@throws InvocationTargetException
|
[
"Converts",
"from",
"an",
"entity",
"class",
"with",
"deep",
"s",
"anotations",
"to",
"AerospikeRecord",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-aerospike/src/main/java/com/stratio/deep/aerospike/utils/UtilAerospike.java#L133-L163
|
3,940 |
Stratio/deep-spark
|
deep-aerospike/src/main/java/com/stratio/deep/aerospike/utils/UtilAerospike.java
|
UtilAerospike.getCellFromAerospikeRecord
|
public static Cells getCellFromAerospikeRecord(AerospikeKey key, AerospikeRecord aerospikeRecord,
AerospikeDeepJobConfig aerospikeConfig) throws IllegalAccessException,
InstantiationException, InvocationTargetException {
String namespace = aerospikeConfig.getNamespace() + "." + aerospikeConfig.getSet();
String setName = aerospikeConfig.getSet();
String[] inputColumns = aerospikeConfig.getInputColumns();
Tuple2<String, Object> equalsFilter = aerospikeConfig.getEqualsFilter();
String equalsFilterBin = equalsFilter != null ? equalsFilter._1() : null;
Object equalsFilterValue = equalsFilter != null ? equalsFilter._2() : null;
Cells cells = namespace != null ? new Cells(namespace) : new Cells();
Map<String, Object> map = aerospikeRecord.bins;
if (inputColumns != null) {
if (equalsFilter == null || checkEqualityFilter(map, equalsFilterBin, equalsFilterValue)) {
for (int i = 0; i < inputColumns.length; i++) {
String binName = inputColumns[i];
if (map.containsKey(binName)) {
Cell cell = Cell.create(binName, map.get(binName));
if(i == 0) {
cell.setIsClusterKey(true);
cell.setIsKey(true);
}
cells.add(namespace, cell);
} else {
throw new InvocationTargetException(new Exception("There is no [" + binName
+ "] on aerospike [" + namespace + "." + setName + "] set"));
}
}
}
} else {
if (equalsFilter == null || checkEqualityFilter(map, equalsFilterBin, equalsFilterValue)) {
int index = 0;
for (Map.Entry<String, Object> bin : map.entrySet()) {
Cell cell = Cell.create(bin.getKey(), bin.getValue());
if(index == 0) {
cell.setIsClusterKey(true);
cell.setIsKey(true);
}
cells.add(namespace, cell);
index ++;
}
}
}
return cells;
}
|
java
|
public static Cells getCellFromAerospikeRecord(AerospikeKey key, AerospikeRecord aerospikeRecord,
AerospikeDeepJobConfig aerospikeConfig) throws IllegalAccessException,
InstantiationException, InvocationTargetException {
String namespace = aerospikeConfig.getNamespace() + "." + aerospikeConfig.getSet();
String setName = aerospikeConfig.getSet();
String[] inputColumns = aerospikeConfig.getInputColumns();
Tuple2<String, Object> equalsFilter = aerospikeConfig.getEqualsFilter();
String equalsFilterBin = equalsFilter != null ? equalsFilter._1() : null;
Object equalsFilterValue = equalsFilter != null ? equalsFilter._2() : null;
Cells cells = namespace != null ? new Cells(namespace) : new Cells();
Map<String, Object> map = aerospikeRecord.bins;
if (inputColumns != null) {
if (equalsFilter == null || checkEqualityFilter(map, equalsFilterBin, equalsFilterValue)) {
for (int i = 0; i < inputColumns.length; i++) {
String binName = inputColumns[i];
if (map.containsKey(binName)) {
Cell cell = Cell.create(binName, map.get(binName));
if(i == 0) {
cell.setIsClusterKey(true);
cell.setIsKey(true);
}
cells.add(namespace, cell);
} else {
throw new InvocationTargetException(new Exception("There is no [" + binName
+ "] on aerospike [" + namespace + "." + setName + "] set"));
}
}
}
} else {
if (equalsFilter == null || checkEqualityFilter(map, equalsFilterBin, equalsFilterValue)) {
int index = 0;
for (Map.Entry<String, Object> bin : map.entrySet()) {
Cell cell = Cell.create(bin.getKey(), bin.getValue());
if(index == 0) {
cell.setIsClusterKey(true);
cell.setIsKey(true);
}
cells.add(namespace, cell);
index ++;
}
}
}
return cells;
}
|
[
"public",
"static",
"Cells",
"getCellFromAerospikeRecord",
"(",
"AerospikeKey",
"key",
",",
"AerospikeRecord",
"aerospikeRecord",
",",
"AerospikeDeepJobConfig",
"aerospikeConfig",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"InvocationTargetException",
"{",
"String",
"namespace",
"=",
"aerospikeConfig",
".",
"getNamespace",
"(",
")",
"+",
"\".\"",
"+",
"aerospikeConfig",
".",
"getSet",
"(",
")",
";",
"String",
"setName",
"=",
"aerospikeConfig",
".",
"getSet",
"(",
")",
";",
"String",
"[",
"]",
"inputColumns",
"=",
"aerospikeConfig",
".",
"getInputColumns",
"(",
")",
";",
"Tuple2",
"<",
"String",
",",
"Object",
">",
"equalsFilter",
"=",
"aerospikeConfig",
".",
"getEqualsFilter",
"(",
")",
";",
"String",
"equalsFilterBin",
"=",
"equalsFilter",
"!=",
"null",
"?",
"equalsFilter",
".",
"_1",
"(",
")",
":",
"null",
";",
"Object",
"equalsFilterValue",
"=",
"equalsFilter",
"!=",
"null",
"?",
"equalsFilter",
".",
"_2",
"(",
")",
":",
"null",
";",
"Cells",
"cells",
"=",
"namespace",
"!=",
"null",
"?",
"new",
"Cells",
"(",
"namespace",
")",
":",
"new",
"Cells",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"aerospikeRecord",
".",
"bins",
";",
"if",
"(",
"inputColumns",
"!=",
"null",
")",
"{",
"if",
"(",
"equalsFilter",
"==",
"null",
"||",
"checkEqualityFilter",
"(",
"map",
",",
"equalsFilterBin",
",",
"equalsFilterValue",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"inputColumns",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"binName",
"=",
"inputColumns",
"[",
"i",
"]",
";",
"if",
"(",
"map",
".",
"containsKey",
"(",
"binName",
")",
")",
"{",
"Cell",
"cell",
"=",
"Cell",
".",
"create",
"(",
"binName",
",",
"map",
".",
"get",
"(",
"binName",
")",
")",
";",
"if",
"(",
"i",
"==",
"0",
")",
"{",
"cell",
".",
"setIsClusterKey",
"(",
"true",
")",
";",
"cell",
".",
"setIsKey",
"(",
"true",
")",
";",
"}",
"cells",
".",
"add",
"(",
"namespace",
",",
"cell",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InvocationTargetException",
"(",
"new",
"Exception",
"(",
"\"There is no [\"",
"+",
"binName",
"+",
"\"] on aerospike [\"",
"+",
"namespace",
"+",
"\".\"",
"+",
"setName",
"+",
"\"] set\"",
")",
")",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"equalsFilter",
"==",
"null",
"||",
"checkEqualityFilter",
"(",
"map",
",",
"equalsFilterBin",
",",
"equalsFilterValue",
")",
")",
"{",
"int",
"index",
"=",
"0",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"bin",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"Cell",
"cell",
"=",
"Cell",
".",
"create",
"(",
"bin",
".",
"getKey",
"(",
")",
",",
"bin",
".",
"getValue",
"(",
")",
")",
";",
"if",
"(",
"index",
"==",
"0",
")",
"{",
"cell",
".",
"setIsClusterKey",
"(",
"true",
")",
";",
"cell",
".",
"setIsKey",
"(",
"true",
")",
";",
"}",
"cells",
".",
"add",
"(",
"namespace",
",",
"cell",
")",
";",
"index",
"++",
";",
"}",
"}",
"}",
"return",
"cells",
";",
"}"
] |
Converts from AerospikeRecord to cell class with deep's anotations.
@param aerospikeRecord
@param key
@param aerospikeConfig
@return
@throws IllegalAccessException
@throws InstantiationException
@throws InvocationTargetException
|
[
"Converts",
"from",
"AerospikeRecord",
"to",
"cell",
"class",
"with",
"deep",
"s",
"anotations",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-aerospike/src/main/java/com/stratio/deep/aerospike/utils/UtilAerospike.java#L176-L223
|
3,941 |
Stratio/deep-spark
|
deep-aerospike/src/main/java/com/stratio/deep/aerospike/utils/UtilAerospike.java
|
UtilAerospike.getAerospikeRecordFromCell
|
public static Pair<Object, AerospikeRecord> getAerospikeRecordFromCell(Cells cells) throws IllegalAccessException, InstantiationException,
InvocationTargetException {
Map<String, Object> bins = new HashMap<>();
Object key = null;
for (Cell cell : cells.getCells()) {
if(key == null) {
if(cell.isKey()) {
key = cell.getValue();
}
} else {
if(cell.isKey()) {
throw new InvocationTargetException(new Exception("Aerospike records must have only one key"));
}
}
bins.put(cell.getCellName(), cell.getValue());
}
if(key == null) {
throw new InvocationTargetException(new Exception("Aerospike records must have one primary key"));
}
// Expiration time = 0, defaults to namespace configuration ("default-ttl")
Record record = new Record(bins, 0, 0);
return Pair.create(key, new AerospikeRecord(record));
}
|
java
|
public static Pair<Object, AerospikeRecord> getAerospikeRecordFromCell(Cells cells) throws IllegalAccessException, InstantiationException,
InvocationTargetException {
Map<String, Object> bins = new HashMap<>();
Object key = null;
for (Cell cell : cells.getCells()) {
if(key == null) {
if(cell.isKey()) {
key = cell.getValue();
}
} else {
if(cell.isKey()) {
throw new InvocationTargetException(new Exception("Aerospike records must have only one key"));
}
}
bins.put(cell.getCellName(), cell.getValue());
}
if(key == null) {
throw new InvocationTargetException(new Exception("Aerospike records must have one primary key"));
}
// Expiration time = 0, defaults to namespace configuration ("default-ttl")
Record record = new Record(bins, 0, 0);
return Pair.create(key, new AerospikeRecord(record));
}
|
[
"public",
"static",
"Pair",
"<",
"Object",
",",
"AerospikeRecord",
">",
"getAerospikeRecordFromCell",
"(",
"Cells",
"cells",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"InvocationTargetException",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"bins",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Object",
"key",
"=",
"null",
";",
"for",
"(",
"Cell",
"cell",
":",
"cells",
".",
"getCells",
"(",
")",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"if",
"(",
"cell",
".",
"isKey",
"(",
")",
")",
"{",
"key",
"=",
"cell",
".",
"getValue",
"(",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"cell",
".",
"isKey",
"(",
")",
")",
"{",
"throw",
"new",
"InvocationTargetException",
"(",
"new",
"Exception",
"(",
"\"Aerospike records must have only one key\"",
")",
")",
";",
"}",
"}",
"bins",
".",
"put",
"(",
"cell",
".",
"getCellName",
"(",
")",
",",
"cell",
".",
"getValue",
"(",
")",
")",
";",
"}",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"throw",
"new",
"InvocationTargetException",
"(",
"new",
"Exception",
"(",
"\"Aerospike records must have one primary key\"",
")",
")",
";",
"}",
"// Expiration time = 0, defaults to namespace configuration (\"default-ttl\")",
"Record",
"record",
"=",
"new",
"Record",
"(",
"bins",
",",
"0",
",",
"0",
")",
";",
"return",
"Pair",
".",
"create",
"(",
"key",
",",
"new",
"AerospikeRecord",
"(",
"record",
")",
")",
";",
"}"
] |
Converts from and entity class with deep's anotations to AerospikeRecord.
@param cells
@return
@throws IllegalAccessException
@throws InstantiationException
@throws InvocationTargetException
|
[
"Converts",
"from",
"and",
"entity",
"class",
"with",
"deep",
"s",
"anotations",
"to",
"AerospikeRecord",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-aerospike/src/main/java/com/stratio/deep/aerospike/utils/UtilAerospike.java#L242-L264
|
3,942 |
Stratio/deep-spark
|
deep-elasticsearch/src/main/java/com/stratio/deep/es/utils/UtilES.java
|
UtilES.getObjectFromJson
|
public static <T> T getObjectFromJson(Class<T> classEntity, LinkedMapWritable jsonObject)
throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
T t = classEntity.newInstance();
Field[] fields = AnnotationUtils.filterDeepFields(classEntity);
Object insert;
for (Field field : fields) {
Method method = Utils.findSetter(field.getName(), classEntity, field.getType());
Class<?> classField = field.getType();
String key = AnnotationUtils.deepFieldName(field);
Text text = new org.apache.hadoop.io.Text(key);
Writable currentJson = jsonObject.get(text);
if (currentJson != null) {
if (Iterable.class.isAssignableFrom(classField)) {
Type type = field.getGenericType();
insert = subDocumentListCase(type, (ArrayWritable) currentJson);
method.invoke(t, (insert));
} else if (IDeepType.class.isAssignableFrom(classField)) {
insert = getObjectFromJson(classField, (LinkedMapWritable) currentJson);
method.invoke(t, (insert));
} else {
insert = currentJson;
try {
method.invoke(t, getObjectFromWritable((Writable) insert));
} catch (Exception e) {
LOG.error("impossible to convert field " + t + " :" + field + " error: " + e.getMessage());
method.invoke(t, Utils.castNumberType(getObjectFromWritable((Writable) insert), t.getClass()));
}
}
}
}
return t;
}
|
java
|
public static <T> T getObjectFromJson(Class<T> classEntity, LinkedMapWritable jsonObject)
throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
T t = classEntity.newInstance();
Field[] fields = AnnotationUtils.filterDeepFields(classEntity);
Object insert;
for (Field field : fields) {
Method method = Utils.findSetter(field.getName(), classEntity, field.getType());
Class<?> classField = field.getType();
String key = AnnotationUtils.deepFieldName(field);
Text text = new org.apache.hadoop.io.Text(key);
Writable currentJson = jsonObject.get(text);
if (currentJson != null) {
if (Iterable.class.isAssignableFrom(classField)) {
Type type = field.getGenericType();
insert = subDocumentListCase(type, (ArrayWritable) currentJson);
method.invoke(t, (insert));
} else if (IDeepType.class.isAssignableFrom(classField)) {
insert = getObjectFromJson(classField, (LinkedMapWritable) currentJson);
method.invoke(t, (insert));
} else {
insert = currentJson;
try {
method.invoke(t, getObjectFromWritable((Writable) insert));
} catch (Exception e) {
LOG.error("impossible to convert field " + t + " :" + field + " error: " + e.getMessage());
method.invoke(t, Utils.castNumberType(getObjectFromWritable((Writable) insert), t.getClass()));
}
}
}
}
return t;
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"getObjectFromJson",
"(",
"Class",
"<",
"T",
">",
"classEntity",
",",
"LinkedMapWritable",
"jsonObject",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"InvocationTargetException",
",",
"NoSuchMethodException",
"{",
"T",
"t",
"=",
"classEntity",
".",
"newInstance",
"(",
")",
";",
"Field",
"[",
"]",
"fields",
"=",
"AnnotationUtils",
".",
"filterDeepFields",
"(",
"classEntity",
")",
";",
"Object",
"insert",
";",
"for",
"(",
"Field",
"field",
":",
"fields",
")",
"{",
"Method",
"method",
"=",
"Utils",
".",
"findSetter",
"(",
"field",
".",
"getName",
"(",
")",
",",
"classEntity",
",",
"field",
".",
"getType",
"(",
")",
")",
";",
"Class",
"<",
"?",
">",
"classField",
"=",
"field",
".",
"getType",
"(",
")",
";",
"String",
"key",
"=",
"AnnotationUtils",
".",
"deepFieldName",
"(",
"field",
")",
";",
"Text",
"text",
"=",
"new",
"org",
".",
"apache",
".",
"hadoop",
".",
"io",
".",
"Text",
"(",
"key",
")",
";",
"Writable",
"currentJson",
"=",
"jsonObject",
".",
"get",
"(",
"text",
")",
";",
"if",
"(",
"currentJson",
"!=",
"null",
")",
"{",
"if",
"(",
"Iterable",
".",
"class",
".",
"isAssignableFrom",
"(",
"classField",
")",
")",
"{",
"Type",
"type",
"=",
"field",
".",
"getGenericType",
"(",
")",
";",
"insert",
"=",
"subDocumentListCase",
"(",
"type",
",",
"(",
"ArrayWritable",
")",
"currentJson",
")",
";",
"method",
".",
"invoke",
"(",
"t",
",",
"(",
"insert",
")",
")",
";",
"}",
"else",
"if",
"(",
"IDeepType",
".",
"class",
".",
"isAssignableFrom",
"(",
"classField",
")",
")",
"{",
"insert",
"=",
"getObjectFromJson",
"(",
"classField",
",",
"(",
"LinkedMapWritable",
")",
"currentJson",
")",
";",
"method",
".",
"invoke",
"(",
"t",
",",
"(",
"insert",
")",
")",
";",
"}",
"else",
"{",
"insert",
"=",
"currentJson",
";",
"try",
"{",
"method",
".",
"invoke",
"(",
"t",
",",
"getObjectFromWritable",
"(",
"(",
"Writable",
")",
"insert",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"impossible to convert field \"",
"+",
"t",
"+",
"\" :\"",
"+",
"field",
"+",
"\" error: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"method",
".",
"invoke",
"(",
"t",
",",
"Utils",
".",
"castNumberType",
"(",
"getObjectFromWritable",
"(",
"(",
"Writable",
")",
"insert",
")",
",",
"t",
".",
"getClass",
"(",
")",
")",
")",
";",
"}",
"}",
"}",
"}",
"return",
"t",
";",
"}"
] |
converts from JSONObject to an entity class with deep's anotations
@param classEntity the entity name.
@param jsonObject the instance of the JSONObject to convert.
@param <T> return type.
@return the provided JSONObject converted to an instance of T.
@throws IllegalAccessException
@throws InstantiationException
@throws java.lang.reflect.InvocationTargetException
|
[
"converts",
"from",
"JSONObject",
"to",
"an",
"entity",
"class",
"with",
"deep",
"s",
"anotations"
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-elasticsearch/src/main/java/com/stratio/deep/es/utils/UtilES.java#L88-L128
|
3,943 |
Stratio/deep-spark
|
deep-elasticsearch/src/main/java/com/stratio/deep/es/utils/UtilES.java
|
UtilES.getCellFromJson
|
public static Cells getCellFromJson(LinkedMapWritable jsonObject, String tableName) throws IllegalAccessException,
InstantiationException, InvocationTargetException, NoSuchMethodException {
Cells cells = tableName != null ? new Cells(tableName) : new Cells();
Set<Map.Entry<Writable, Writable>> entryJson = jsonObject.entrySet();
for (Map.Entry<Writable, Writable> entry : entryJson) {
if (LinkedMapWritable.class.isAssignableFrom(entry.getValue().getClass())) {
Cells innerCells = getCellFromJson((LinkedMapWritable) entry.getValue(), null);
cells.add(Cell.create(entry.getKey().toString(), innerCells));
} else if (ArrayWritable.class.isAssignableFrom(entry.getValue().getClass())) {
Writable[] writetable = ((ArrayWritable) entry.getValue()).get();
List innerCell = new ArrayList<>();
for (int i = 0; i < writetable.length; i++) {
if(writetable[i] instanceof LinkedMapWritable){
innerCell.add(getCellFromJson((LinkedMapWritable) writetable[i], null));
}else{
innerCell.add(getObjectFromWritable(entry.getValue()));
}
}
cells.add(Cell.create(entry.getKey().toString(), innerCell));
} else {
cells.add(Cell.create(entry.getKey().toString(), getObjectFromWritable(entry.getValue())));
}
}
return cells;
}
|
java
|
public static Cells getCellFromJson(LinkedMapWritable jsonObject, String tableName) throws IllegalAccessException,
InstantiationException, InvocationTargetException, NoSuchMethodException {
Cells cells = tableName != null ? new Cells(tableName) : new Cells();
Set<Map.Entry<Writable, Writable>> entryJson = jsonObject.entrySet();
for (Map.Entry<Writable, Writable> entry : entryJson) {
if (LinkedMapWritable.class.isAssignableFrom(entry.getValue().getClass())) {
Cells innerCells = getCellFromJson((LinkedMapWritable) entry.getValue(), null);
cells.add(Cell.create(entry.getKey().toString(), innerCells));
} else if (ArrayWritable.class.isAssignableFrom(entry.getValue().getClass())) {
Writable[] writetable = ((ArrayWritable) entry.getValue()).get();
List innerCell = new ArrayList<>();
for (int i = 0; i < writetable.length; i++) {
if(writetable[i] instanceof LinkedMapWritable){
innerCell.add(getCellFromJson((LinkedMapWritable) writetable[i], null));
}else{
innerCell.add(getObjectFromWritable(entry.getValue()));
}
}
cells.add(Cell.create(entry.getKey().toString(), innerCell));
} else {
cells.add(Cell.create(entry.getKey().toString(), getObjectFromWritable(entry.getValue())));
}
}
return cells;
}
|
[
"public",
"static",
"Cells",
"getCellFromJson",
"(",
"LinkedMapWritable",
"jsonObject",
",",
"String",
"tableName",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"InvocationTargetException",
",",
"NoSuchMethodException",
"{",
"Cells",
"cells",
"=",
"tableName",
"!=",
"null",
"?",
"new",
"Cells",
"(",
"tableName",
")",
":",
"new",
"Cells",
"(",
")",
";",
"Set",
"<",
"Map",
".",
"Entry",
"<",
"Writable",
",",
"Writable",
">",
">",
"entryJson",
"=",
"jsonObject",
".",
"entrySet",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Writable",
",",
"Writable",
">",
"entry",
":",
"entryJson",
")",
"{",
"if",
"(",
"LinkedMapWritable",
".",
"class",
".",
"isAssignableFrom",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"getClass",
"(",
")",
")",
")",
"{",
"Cells",
"innerCells",
"=",
"getCellFromJson",
"(",
"(",
"LinkedMapWritable",
")",
"entry",
".",
"getValue",
"(",
")",
",",
"null",
")",
";",
"cells",
".",
"add",
"(",
"Cell",
".",
"create",
"(",
"entry",
".",
"getKey",
"(",
")",
".",
"toString",
"(",
")",
",",
"innerCells",
")",
")",
";",
"}",
"else",
"if",
"(",
"ArrayWritable",
".",
"class",
".",
"isAssignableFrom",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"getClass",
"(",
")",
")",
")",
"{",
"Writable",
"[",
"]",
"writetable",
"=",
"(",
"(",
"ArrayWritable",
")",
"entry",
".",
"getValue",
"(",
")",
")",
".",
"get",
"(",
")",
";",
"List",
"innerCell",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"writetable",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"writetable",
"[",
"i",
"]",
"instanceof",
"LinkedMapWritable",
")",
"{",
"innerCell",
".",
"add",
"(",
"getCellFromJson",
"(",
"(",
"LinkedMapWritable",
")",
"writetable",
"[",
"i",
"]",
",",
"null",
")",
")",
";",
"}",
"else",
"{",
"innerCell",
".",
"add",
"(",
"getObjectFromWritable",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"}",
"cells",
".",
"add",
"(",
"Cell",
".",
"create",
"(",
"entry",
".",
"getKey",
"(",
")",
".",
"toString",
"(",
")",
",",
"innerCell",
")",
")",
";",
"}",
"else",
"{",
"cells",
".",
"add",
"(",
"Cell",
".",
"create",
"(",
"entry",
".",
"getKey",
"(",
")",
".",
"toString",
"(",
")",
",",
"getObjectFromWritable",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
")",
")",
";",
"}",
"}",
"return",
"cells",
";",
"}"
] |
converts from JSONObject to cell class
@param jsonObject
@return
@throws IllegalAccessException
@throws InstantiationException
@throws InvocationTargetException
|
[
"converts",
"from",
"JSONObject",
"to",
"cell",
"class"
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-elasticsearch/src/main/java/com/stratio/deep/es/utils/UtilES.java#L255-L286
|
3,944 |
Stratio/deep-spark
|
deep-cassandra/src/main/java/com/stratio/deep/cassandra/entity/CassandraCell.java
|
CassandraCell.create
|
public static Cell create(String cellName, DataType cellType, Boolean isPartitionKey,
Boolean isClusterKey) {
return new CassandraCell(cellName, cellType, isPartitionKey, isClusterKey);
}
|
java
|
public static Cell create(String cellName, DataType cellType, Boolean isPartitionKey,
Boolean isClusterKey) {
return new CassandraCell(cellName, cellType, isPartitionKey, isClusterKey);
}
|
[
"public",
"static",
"Cell",
"create",
"(",
"String",
"cellName",
",",
"DataType",
"cellType",
",",
"Boolean",
"isPartitionKey",
",",
"Boolean",
"isClusterKey",
")",
"{",
"return",
"new",
"CassandraCell",
"(",
"cellName",
",",
"cellType",
",",
"isPartitionKey",
",",
"isClusterKey",
")",
";",
"}"
] |
Factory method, creates a new metadata Cell, i.e. a Cell without value.
@param cellName the cell name
@param cellType the cell value type.
@param isPartitionKey true if this cell is part of the cassandra's partition key.
@param isClusterKey true if this cell is part of the cassandra's clustering key.
@return an instance of a Cell object for the provided parameters.
|
[
"Factory",
"method",
"creates",
"a",
"new",
"metadata",
"Cell",
"i",
".",
"e",
".",
"a",
"Cell",
"without",
"value",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/entity/CassandraCell.java#L110-L113
|
3,945 |
Stratio/deep-spark
|
deep-jdbc/src/main/java/com/stratio/deep/jdbc/extractor/JdbcNativeCellExtractor.java
|
JdbcNativeCellExtractor.transformElement
|
@Override
protected Cells transformElement(Map<String, Object> entity) {
return UtilJdbc.getCellsFromObject(entity, jdbcDeepJobConfig);
}
|
java
|
@Override
protected Cells transformElement(Map<String, Object> entity) {
return UtilJdbc.getCellsFromObject(entity, jdbcDeepJobConfig);
}
|
[
"@",
"Override",
"protected",
"Cells",
"transformElement",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"entity",
")",
"{",
"return",
"UtilJdbc",
".",
"getCellsFromObject",
"(",
"entity",
",",
"jdbcDeepJobConfig",
")",
";",
"}"
] |
Transforms a database row represented as a Map into a Cells object.
@param entity Database row represented as a Map of column name:column value.
@return Cells object with database row data.
|
[
"Transforms",
"a",
"database",
"row",
"represented",
"as",
"a",
"Map",
"into",
"a",
"Cells",
"object",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-jdbc/src/main/java/com/stratio/deep/jdbc/extractor/JdbcNativeCellExtractor.java#L48-L51
|
3,946 |
Stratio/deep-spark
|
deep-jdbc/src/main/java/com/stratio/deep/jdbc/extractor/JdbcNativeCellExtractor.java
|
JdbcNativeCellExtractor.transformElement
|
@Override
protected Map<String, Object> transformElement(Cells cells) {
return UtilJdbc.getObjectFromCells(cells);
}
|
java
|
@Override
protected Map<String, Object> transformElement(Cells cells) {
return UtilJdbc.getObjectFromCells(cells);
}
|
[
"@",
"Override",
"protected",
"Map",
"<",
"String",
",",
"Object",
">",
"transformElement",
"(",
"Cells",
"cells",
")",
"{",
"return",
"UtilJdbc",
".",
"getObjectFromCells",
"(",
"cells",
")",
";",
"}"
] |
Transforms a Cells object into a database row represented as a Map.
@param cells Cells data object.
@return Database row represented as a Map of column name:column value.
|
[
"Transforms",
"a",
"Cells",
"object",
"into",
"a",
"database",
"row",
"represented",
"as",
"a",
"Map",
"."
] |
b9621c9b7a6d996f80fce1d073d696a157bed095
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-jdbc/src/main/java/com/stratio/deep/jdbc/extractor/JdbcNativeCellExtractor.java#L58-L61
|
3,947 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/archive/ArchiveExtractor.java
|
ArchiveExtractor.extractDockerImageLayers
|
public void extractDockerImageLayers(File imageTarFile, File imageExtractionDir, Boolean deleteTarFiles) {
FilesScanner filesScanner = new FilesScanner();
boolean success = false;
// docker layers are saved as TAR file (we save it as TAR)
if (imageTarFile.getName().endsWith(TAR_SUFFIX)) {
success = unTar(imageTarFile.getName().toLowerCase(), imageExtractionDir.getAbsolutePath(), imageTarFile.getPath());
boolean deleted = false;
if (deleteTarFiles) {
deleted = imageTarFile.delete();
}
if (!deleted) {
logger.warn("Was not able to delete {} (docker image TAR file)", imageTarFile.getName());
}
}
if (success) {
String[] fileNames = filesScanner.getDirectoryContent(imageExtractionDir.getAbsolutePath(), new String[]{LAYER_TAR}, new String[]{}, true, false);
for (String filename : fileNames) {
File layerToExtract = new File(imageExtractionDir + File.separator + filename);
extractDockerImageLayers(layerToExtract, layerToExtract.getParentFile(), deleteTarFiles);
}
} else {
logger.warn("Was not able to extract {} (docker image TAR file)", imageTarFile.getName());
}
}
|
java
|
public void extractDockerImageLayers(File imageTarFile, File imageExtractionDir, Boolean deleteTarFiles) {
FilesScanner filesScanner = new FilesScanner();
boolean success = false;
// docker layers are saved as TAR file (we save it as TAR)
if (imageTarFile.getName().endsWith(TAR_SUFFIX)) {
success = unTar(imageTarFile.getName().toLowerCase(), imageExtractionDir.getAbsolutePath(), imageTarFile.getPath());
boolean deleted = false;
if (deleteTarFiles) {
deleted = imageTarFile.delete();
}
if (!deleted) {
logger.warn("Was not able to delete {} (docker image TAR file)", imageTarFile.getName());
}
}
if (success) {
String[] fileNames = filesScanner.getDirectoryContent(imageExtractionDir.getAbsolutePath(), new String[]{LAYER_TAR}, new String[]{}, true, false);
for (String filename : fileNames) {
File layerToExtract = new File(imageExtractionDir + File.separator + filename);
extractDockerImageLayers(layerToExtract, layerToExtract.getParentFile(), deleteTarFiles);
}
} else {
logger.warn("Was not able to extract {} (docker image TAR file)", imageTarFile.getName());
}
}
|
[
"public",
"void",
"extractDockerImageLayers",
"(",
"File",
"imageTarFile",
",",
"File",
"imageExtractionDir",
",",
"Boolean",
"deleteTarFiles",
")",
"{",
"FilesScanner",
"filesScanner",
"=",
"new",
"FilesScanner",
"(",
")",
";",
"boolean",
"success",
"=",
"false",
";",
"// docker layers are saved as TAR file (we save it as TAR)",
"if",
"(",
"imageTarFile",
".",
"getName",
"(",
")",
".",
"endsWith",
"(",
"TAR_SUFFIX",
")",
")",
"{",
"success",
"=",
"unTar",
"(",
"imageTarFile",
".",
"getName",
"(",
")",
".",
"toLowerCase",
"(",
")",
",",
"imageExtractionDir",
".",
"getAbsolutePath",
"(",
")",
",",
"imageTarFile",
".",
"getPath",
"(",
")",
")",
";",
"boolean",
"deleted",
"=",
"false",
";",
"if",
"(",
"deleteTarFiles",
")",
"{",
"deleted",
"=",
"imageTarFile",
".",
"delete",
"(",
")",
";",
"}",
"if",
"(",
"!",
"deleted",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Was not able to delete {} (docker image TAR file)\"",
",",
"imageTarFile",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"success",
")",
"{",
"String",
"[",
"]",
"fileNames",
"=",
"filesScanner",
".",
"getDirectoryContent",
"(",
"imageExtractionDir",
".",
"getAbsolutePath",
"(",
")",
",",
"new",
"String",
"[",
"]",
"{",
"LAYER_TAR",
"}",
",",
"new",
"String",
"[",
"]",
"{",
"}",
",",
"true",
",",
"false",
")",
";",
"for",
"(",
"String",
"filename",
":",
"fileNames",
")",
"{",
"File",
"layerToExtract",
"=",
"new",
"File",
"(",
"imageExtractionDir",
"+",
"File",
".",
"separator",
"+",
"filename",
")",
";",
"extractDockerImageLayers",
"(",
"layerToExtract",
",",
"layerToExtract",
".",
"getParentFile",
"(",
")",
",",
"deleteTarFiles",
")",
";",
"}",
"}",
"else",
"{",
"logger",
".",
"warn",
"(",
"\"Was not able to extract {} (docker image TAR file)\"",
",",
"imageTarFile",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] |
extract image layers
|
[
"extract",
"image",
"layers"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/archive/ArchiveExtractor.java#L226-L249
|
3,948 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/archive/ArchiveExtractor.java
|
ArchiveExtractor.unZip
|
private boolean unZip(String innerDir, String archiveFile) {
boolean success = true;
ZipFile zipFile;
try {
zipFile = new ZipFile(archiveFile);
// Get the list of file headers from the zip file before unpacking
List fileHeaderList = zipFile.getFileHeaders();
List<PathMatcher> matchers = Arrays.stream(filesExcludes).map(fileExclude ->
FileSystems.getDefault().getPathMatcher(GLOB_PREFIX + fileExclude)).collect(Collectors.toList());
// Loop through the file headers and extract only files that are not matched by fileExcludes patterns
for (int i = 0; i < fileHeaderList.size(); i++) {
FileHeader fileHeader = (FileHeader) fileHeaderList.get(i);
String fileName = fileHeader.getFileName();
if (filesExcludes.length > 0) {
Predicate<PathMatcher> matchesExcludes = pathMatcher -> pathMatcher.matches(Paths.get(innerDir, fileName));
if (matchers.stream().noneMatch(matchesExcludes)) {
zipFile.extractFile(fileHeader, innerDir);
}
} else {
zipFile.extractFile(fileHeader, innerDir);
}
}
} catch (Exception e) {
success = false;
logger.warn("Error extracting file {}: {}", archiveFile, e.getMessage());
logger.debug("Error extracting file {}: {}", archiveFile, e.getStackTrace());
} finally {
// remove reference to zip file
zipFile = null;
}
return success;
}
|
java
|
private boolean unZip(String innerDir, String archiveFile) {
boolean success = true;
ZipFile zipFile;
try {
zipFile = new ZipFile(archiveFile);
// Get the list of file headers from the zip file before unpacking
List fileHeaderList = zipFile.getFileHeaders();
List<PathMatcher> matchers = Arrays.stream(filesExcludes).map(fileExclude ->
FileSystems.getDefault().getPathMatcher(GLOB_PREFIX + fileExclude)).collect(Collectors.toList());
// Loop through the file headers and extract only files that are not matched by fileExcludes patterns
for (int i = 0; i < fileHeaderList.size(); i++) {
FileHeader fileHeader = (FileHeader) fileHeaderList.get(i);
String fileName = fileHeader.getFileName();
if (filesExcludes.length > 0) {
Predicate<PathMatcher> matchesExcludes = pathMatcher -> pathMatcher.matches(Paths.get(innerDir, fileName));
if (matchers.stream().noneMatch(matchesExcludes)) {
zipFile.extractFile(fileHeader, innerDir);
}
} else {
zipFile.extractFile(fileHeader, innerDir);
}
}
} catch (Exception e) {
success = false;
logger.warn("Error extracting file {}: {}", archiveFile, e.getMessage());
logger.debug("Error extracting file {}: {}", archiveFile, e.getStackTrace());
} finally {
// remove reference to zip file
zipFile = null;
}
return success;
}
|
[
"private",
"boolean",
"unZip",
"(",
"String",
"innerDir",
",",
"String",
"archiveFile",
")",
"{",
"boolean",
"success",
"=",
"true",
";",
"ZipFile",
"zipFile",
";",
"try",
"{",
"zipFile",
"=",
"new",
"ZipFile",
"(",
"archiveFile",
")",
";",
"// Get the list of file headers from the zip file before unpacking",
"List",
"fileHeaderList",
"=",
"zipFile",
".",
"getFileHeaders",
"(",
")",
";",
"List",
"<",
"PathMatcher",
">",
"matchers",
"=",
"Arrays",
".",
"stream",
"(",
"filesExcludes",
")",
".",
"map",
"(",
"fileExclude",
"->",
"FileSystems",
".",
"getDefault",
"(",
")",
".",
"getPathMatcher",
"(",
"GLOB_PREFIX",
"+",
"fileExclude",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"// Loop through the file headers and extract only files that are not matched by fileExcludes patterns",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fileHeaderList",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"FileHeader",
"fileHeader",
"=",
"(",
"FileHeader",
")",
"fileHeaderList",
".",
"get",
"(",
"i",
")",
";",
"String",
"fileName",
"=",
"fileHeader",
".",
"getFileName",
"(",
")",
";",
"if",
"(",
"filesExcludes",
".",
"length",
">",
"0",
")",
"{",
"Predicate",
"<",
"PathMatcher",
">",
"matchesExcludes",
"=",
"pathMatcher",
"->",
"pathMatcher",
".",
"matches",
"(",
"Paths",
".",
"get",
"(",
"innerDir",
",",
"fileName",
")",
")",
";",
"if",
"(",
"matchers",
".",
"stream",
"(",
")",
".",
"noneMatch",
"(",
"matchesExcludes",
")",
")",
"{",
"zipFile",
".",
"extractFile",
"(",
"fileHeader",
",",
"innerDir",
")",
";",
"}",
"}",
"else",
"{",
"zipFile",
".",
"extractFile",
"(",
"fileHeader",
",",
"innerDir",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"success",
"=",
"false",
";",
"logger",
".",
"warn",
"(",
"\"Error extracting file {}: {}\"",
",",
"archiveFile",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Error extracting file {}: {}\"",
",",
"archiveFile",
",",
"e",
".",
"getStackTrace",
"(",
")",
")",
";",
"}",
"finally",
"{",
"// remove reference to zip file",
"zipFile",
"=",
"null",
";",
"}",
"return",
"success",
";",
"}"
] |
Open and extract data from zip pattern files
|
[
"Open",
"and",
"extract",
"data",
"from",
"zip",
"pattern",
"files"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/archive/ArchiveExtractor.java#L407-L439
|
3,949 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/archive/ArchiveExtractor.java
|
ArchiveExtractor.unTar
|
private boolean unTar(String fileName, String innerDir, String archiveFile) {
boolean success = true;
TarUnArchiver unArchiver = new TarUnArchiver();
try {
File destDir = new File(innerDir);
if (!destDir.exists()) {
destDir.mkdirs();
}
if (fileName.endsWith(TAR_GZ_SUFFIX) || fileName.endsWith(TGZ_SUFFIX)) {
unArchiver = new TarGZipUnArchiver();
} else if (fileName.endsWith(TAR_BZ2_SUFFIX)) {
unArchiver = new TarBZip2UnArchiver();
} else if (fileName.endsWith(XZ_SUFFIX)) {
String destFileUrl = destDir.getCanonicalPath() + Constants.BACK_SLASH + XZ_UN_ARCHIVER_FILE_NAME;
success = unXz(new File(archiveFile), destFileUrl);
archiveFile = destFileUrl;
}
if (success) {
unArchiver.enableLogging(new ConsoleLogger(ConsoleLogger.LEVEL_DISABLED, UN_ARCHIVER_LOGGER));
unArchiver.setSourceFile(new File(archiveFile));
unArchiver.setDestDirectory(destDir);
unArchiver.extract();
}
} catch (Exception e) {
success = false;
logger.warn("Error extracting file {}: {}", fileName, e.getMessage());
}
return success;
}
|
java
|
private boolean unTar(String fileName, String innerDir, String archiveFile) {
boolean success = true;
TarUnArchiver unArchiver = new TarUnArchiver();
try {
File destDir = new File(innerDir);
if (!destDir.exists()) {
destDir.mkdirs();
}
if (fileName.endsWith(TAR_GZ_SUFFIX) || fileName.endsWith(TGZ_SUFFIX)) {
unArchiver = new TarGZipUnArchiver();
} else if (fileName.endsWith(TAR_BZ2_SUFFIX)) {
unArchiver = new TarBZip2UnArchiver();
} else if (fileName.endsWith(XZ_SUFFIX)) {
String destFileUrl = destDir.getCanonicalPath() + Constants.BACK_SLASH + XZ_UN_ARCHIVER_FILE_NAME;
success = unXz(new File(archiveFile), destFileUrl);
archiveFile = destFileUrl;
}
if (success) {
unArchiver.enableLogging(new ConsoleLogger(ConsoleLogger.LEVEL_DISABLED, UN_ARCHIVER_LOGGER));
unArchiver.setSourceFile(new File(archiveFile));
unArchiver.setDestDirectory(destDir);
unArchiver.extract();
}
} catch (Exception e) {
success = false;
logger.warn("Error extracting file {}: {}", fileName, e.getMessage());
}
return success;
}
|
[
"private",
"boolean",
"unTar",
"(",
"String",
"fileName",
",",
"String",
"innerDir",
",",
"String",
"archiveFile",
")",
"{",
"boolean",
"success",
"=",
"true",
";",
"TarUnArchiver",
"unArchiver",
"=",
"new",
"TarUnArchiver",
"(",
")",
";",
"try",
"{",
"File",
"destDir",
"=",
"new",
"File",
"(",
"innerDir",
")",
";",
"if",
"(",
"!",
"destDir",
".",
"exists",
"(",
")",
")",
"{",
"destDir",
".",
"mkdirs",
"(",
")",
";",
"}",
"if",
"(",
"fileName",
".",
"endsWith",
"(",
"TAR_GZ_SUFFIX",
")",
"||",
"fileName",
".",
"endsWith",
"(",
"TGZ_SUFFIX",
")",
")",
"{",
"unArchiver",
"=",
"new",
"TarGZipUnArchiver",
"(",
")",
";",
"}",
"else",
"if",
"(",
"fileName",
".",
"endsWith",
"(",
"TAR_BZ2_SUFFIX",
")",
")",
"{",
"unArchiver",
"=",
"new",
"TarBZip2UnArchiver",
"(",
")",
";",
"}",
"else",
"if",
"(",
"fileName",
".",
"endsWith",
"(",
"XZ_SUFFIX",
")",
")",
"{",
"String",
"destFileUrl",
"=",
"destDir",
".",
"getCanonicalPath",
"(",
")",
"+",
"Constants",
".",
"BACK_SLASH",
"+",
"XZ_UN_ARCHIVER_FILE_NAME",
";",
"success",
"=",
"unXz",
"(",
"new",
"File",
"(",
"archiveFile",
")",
",",
"destFileUrl",
")",
";",
"archiveFile",
"=",
"destFileUrl",
";",
"}",
"if",
"(",
"success",
")",
"{",
"unArchiver",
".",
"enableLogging",
"(",
"new",
"ConsoleLogger",
"(",
"ConsoleLogger",
".",
"LEVEL_DISABLED",
",",
"UN_ARCHIVER_LOGGER",
")",
")",
";",
"unArchiver",
".",
"setSourceFile",
"(",
"new",
"File",
"(",
"archiveFile",
")",
")",
";",
"unArchiver",
".",
"setDestDirectory",
"(",
"destDir",
")",
";",
"unArchiver",
".",
"extract",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"success",
"=",
"false",
";",
"logger",
".",
"warn",
"(",
"\"Error extracting file {}: {}\"",
",",
"fileName",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"success",
";",
"}"
] |
Open and extract data from Tar pattern files
|
[
"Open",
"and",
"extract",
"data",
"from",
"Tar",
"pattern",
"files"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/archive/ArchiveExtractor.java#L442-L470
|
3,950 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/archive/ArchiveExtractor.java
|
ArchiveExtractor.unXz
|
public boolean unXz(File srcFileToArchive, String destFilePath) {
boolean success = true;
try {
XZUnArchiver XZUnArchiver = new XZUnArchiver();
XZUnArchiver.enableLogging(new ConsoleLogger(ConsoleLogger.LEVEL_DISABLED, UN_ARCHIVER_LOGGER));
XZUnArchiver.setSourceFile(srcFileToArchive);
XZUnArchiver.setDestFile(new File(destFilePath));
XZUnArchiver.extract();
} catch (Exception e) {
success = false;
logger.warn("Failed to extract Xz file : {} - {}", srcFileToArchive.getPath(), e.getMessage());
}
return success;
}
|
java
|
public boolean unXz(File srcFileToArchive, String destFilePath) {
boolean success = true;
try {
XZUnArchiver XZUnArchiver = new XZUnArchiver();
XZUnArchiver.enableLogging(new ConsoleLogger(ConsoleLogger.LEVEL_DISABLED, UN_ARCHIVER_LOGGER));
XZUnArchiver.setSourceFile(srcFileToArchive);
XZUnArchiver.setDestFile(new File(destFilePath));
XZUnArchiver.extract();
} catch (Exception e) {
success = false;
logger.warn("Failed to extract Xz file : {} - {}", srcFileToArchive.getPath(), e.getMessage());
}
return success;
}
|
[
"public",
"boolean",
"unXz",
"(",
"File",
"srcFileToArchive",
",",
"String",
"destFilePath",
")",
"{",
"boolean",
"success",
"=",
"true",
";",
"try",
"{",
"XZUnArchiver",
"XZUnArchiver",
"=",
"new",
"XZUnArchiver",
"(",
")",
";",
"XZUnArchiver",
".",
"enableLogging",
"(",
"new",
"ConsoleLogger",
"(",
"ConsoleLogger",
".",
"LEVEL_DISABLED",
",",
"UN_ARCHIVER_LOGGER",
")",
")",
";",
"XZUnArchiver",
".",
"setSourceFile",
"(",
"srcFileToArchive",
")",
";",
"XZUnArchiver",
".",
"setDestFile",
"(",
"new",
"File",
"(",
"destFilePath",
")",
")",
";",
"XZUnArchiver",
".",
"extract",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"success",
"=",
"false",
";",
"logger",
".",
"warn",
"(",
"\"Failed to extract Xz file : {} - {}\"",
",",
"srcFileToArchive",
".",
"getPath",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"success",
";",
"}"
] |
extract xz files
|
[
"extract",
"xz",
"files"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/archive/ArchiveExtractor.java#L473-L486
|
3,951 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/archive/ArchiveExtractor.java
|
ArchiveExtractor.getFileName
|
private String getFileName(String name) {
//check if the environment is linux or windows
if (name.contains(Constants.FORWARD_SLASH)) {
name = name.substring(name.lastIndexOf(Constants.FORWARD_SLASH) + 1, name.length());
} else if (name.contains(Constants.BACK_SLASH)) {
name = name.substring(name.lastIndexOf(Constants.BACK_SLASH) + 1, name.length());
}
return name;
}
|
java
|
private String getFileName(String name) {
//check if the environment is linux or windows
if (name.contains(Constants.FORWARD_SLASH)) {
name = name.substring(name.lastIndexOf(Constants.FORWARD_SLASH) + 1, name.length());
} else if (name.contains(Constants.BACK_SLASH)) {
name = name.substring(name.lastIndexOf(Constants.BACK_SLASH) + 1, name.length());
}
return name;
}
|
[
"private",
"String",
"getFileName",
"(",
"String",
"name",
")",
"{",
"//check if the environment is linux or windows",
"if",
"(",
"name",
".",
"contains",
"(",
"Constants",
".",
"FORWARD_SLASH",
")",
")",
"{",
"name",
"=",
"name",
".",
"substring",
"(",
"name",
".",
"lastIndexOf",
"(",
"Constants",
".",
"FORWARD_SLASH",
")",
"+",
"1",
",",
"name",
".",
"length",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"name",
".",
"contains",
"(",
"Constants",
".",
"BACK_SLASH",
")",
")",
"{",
"name",
"=",
"name",
".",
"substring",
"(",
"name",
".",
"lastIndexOf",
"(",
"Constants",
".",
"BACK_SLASH",
")",
"+",
"1",
",",
"name",
".",
"length",
"(",
")",
")",
";",
"}",
"return",
"name",
";",
"}"
] |
parse name without directories
|
[
"parse",
"name",
"without",
"directories"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/archive/ArchiveExtractor.java#L589-L597
|
3,952 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/docker/remotedocker/AbstractRemoteDocker.java
|
AbstractRemoteDocker.executeCommand
|
protected Pair<Integer, InputStream> executeCommand(String command) {
int resultVal = 1;
InputStream inputStream = null;
try {
logger.debug("Executing command: {}", command);
Process process = Runtime.getRuntime().exec(command);
resultVal = process.waitFor();
inputStream = process.getInputStream();
} catch (InterruptedException e) {
logger.info("Execution of {} failed: code - {} ; message - {}", command, resultVal, e.getMessage());
Thread.currentThread().interrupt();
} catch (IOException e) {
logger.info("Execution of {} failed: code - {} ; message - {}", command, resultVal, e.getMessage());
}
if (inputStream == null) {
// Create an empty InputStream instead of returning a null
inputStream = new InputStream() {
@Override
public int read() throws IOException {
return -1;
}
} ;
}
return new Pair<>(resultVal, inputStream);
}
|
java
|
protected Pair<Integer, InputStream> executeCommand(String command) {
int resultVal = 1;
InputStream inputStream = null;
try {
logger.debug("Executing command: {}", command);
Process process = Runtime.getRuntime().exec(command);
resultVal = process.waitFor();
inputStream = process.getInputStream();
} catch (InterruptedException e) {
logger.info("Execution of {} failed: code - {} ; message - {}", command, resultVal, e.getMessage());
Thread.currentThread().interrupt();
} catch (IOException e) {
logger.info("Execution of {} failed: code - {} ; message - {}", command, resultVal, e.getMessage());
}
if (inputStream == null) {
// Create an empty InputStream instead of returning a null
inputStream = new InputStream() {
@Override
public int read() throws IOException {
return -1;
}
} ;
}
return new Pair<>(resultVal, inputStream);
}
|
[
"protected",
"Pair",
"<",
"Integer",
",",
"InputStream",
">",
"executeCommand",
"(",
"String",
"command",
")",
"{",
"int",
"resultVal",
"=",
"1",
";",
"InputStream",
"inputStream",
"=",
"null",
";",
"try",
"{",
"logger",
".",
"debug",
"(",
"\"Executing command: {}\"",
",",
"command",
")",
";",
"Process",
"process",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"exec",
"(",
"command",
")",
";",
"resultVal",
"=",
"process",
".",
"waitFor",
"(",
")",
";",
"inputStream",
"=",
"process",
".",
"getInputStream",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"logger",
".",
"info",
"(",
"\"Execution of {} failed: code - {} ; message - {}\"",
",",
"command",
",",
"resultVal",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"info",
"(",
"\"Execution of {} failed: code - {} ; message - {}\"",
",",
"command",
",",
"resultVal",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"if",
"(",
"inputStream",
"==",
"null",
")",
"{",
"// Create an empty InputStream instead of returning a null",
"inputStream",
"=",
"new",
"InputStream",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"read",
"(",
")",
"throws",
"IOException",
"{",
"return",
"-",
"1",
";",
"}",
"}",
";",
"}",
"return",
"new",
"Pair",
"<>",
"(",
"resultVal",
",",
"inputStream",
")",
";",
"}"
] |
from old command's stream and the new command's stream
|
[
"from",
"old",
"command",
"s",
"stream",
"and",
"the",
"new",
"command",
"s",
"stream"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/docker/remotedocker/AbstractRemoteDocker.java#L313-L339
|
3,953 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationViewCallback.java
|
NotificationViewCallback.onContentViewChanged
|
public void onContentViewChanged(NotificationView view, View contentView, int layoutId) {
if (DBG) Log.v(TAG, "onContentViewChanged");
ChildViewManager mgr = view.getChildViewManager();
if (layoutId == R.layout.notification_simple ||
layoutId == R.layout.notification_large_icon ||
layoutId == R.layout.notification_full) {
view.setNotificationTransitionEnabled(false);
mgr.setView(ICON, contentView.findViewById(R.id.switcher_icon));
mgr.setView(TITLE, contentView.findViewById(R.id.switcher_title));
mgr.setView(TEXT, contentView.findViewById(R.id.switcher_text));
mgr.setView(WHEN, contentView.findViewById(R.id.switcher_when));
} else if (layoutId == R.layout.notification_simple_2) {
view.setNotificationTransitionEnabled(true);
mgr.setView(ICON, contentView.findViewById(R.id.icon));
mgr.setView(TITLE, contentView.findViewById(R.id.title));
mgr.setView(TEXT, contentView.findViewById(R.id.text));
mgr.setView(WHEN, contentView.findViewById(R.id.when));
}
}
|
java
|
public void onContentViewChanged(NotificationView view, View contentView, int layoutId) {
if (DBG) Log.v(TAG, "onContentViewChanged");
ChildViewManager mgr = view.getChildViewManager();
if (layoutId == R.layout.notification_simple ||
layoutId == R.layout.notification_large_icon ||
layoutId == R.layout.notification_full) {
view.setNotificationTransitionEnabled(false);
mgr.setView(ICON, contentView.findViewById(R.id.switcher_icon));
mgr.setView(TITLE, contentView.findViewById(R.id.switcher_title));
mgr.setView(TEXT, contentView.findViewById(R.id.switcher_text));
mgr.setView(WHEN, contentView.findViewById(R.id.switcher_when));
} else if (layoutId == R.layout.notification_simple_2) {
view.setNotificationTransitionEnabled(true);
mgr.setView(ICON, contentView.findViewById(R.id.icon));
mgr.setView(TITLE, contentView.findViewById(R.id.title));
mgr.setView(TEXT, contentView.findViewById(R.id.text));
mgr.setView(WHEN, contentView.findViewById(R.id.when));
}
}
|
[
"public",
"void",
"onContentViewChanged",
"(",
"NotificationView",
"view",
",",
"View",
"contentView",
",",
"int",
"layoutId",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"onContentViewChanged\"",
")",
";",
"ChildViewManager",
"mgr",
"=",
"view",
".",
"getChildViewManager",
"(",
")",
";",
"if",
"(",
"layoutId",
"==",
"R",
".",
"layout",
".",
"notification_simple",
"||",
"layoutId",
"==",
"R",
".",
"layout",
".",
"notification_large_icon",
"||",
"layoutId",
"==",
"R",
".",
"layout",
".",
"notification_full",
")",
"{",
"view",
".",
"setNotificationTransitionEnabled",
"(",
"false",
")",
";",
"mgr",
".",
"setView",
"(",
"ICON",
",",
"contentView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"switcher_icon",
")",
")",
";",
"mgr",
".",
"setView",
"(",
"TITLE",
",",
"contentView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"switcher_title",
")",
")",
";",
"mgr",
".",
"setView",
"(",
"TEXT",
",",
"contentView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"switcher_text",
")",
")",
";",
"mgr",
".",
"setView",
"(",
"WHEN",
",",
"contentView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"switcher_when",
")",
")",
";",
"}",
"else",
"if",
"(",
"layoutId",
"==",
"R",
".",
"layout",
".",
"notification_simple_2",
")",
"{",
"view",
".",
"setNotificationTransitionEnabled",
"(",
"true",
")",
";",
"mgr",
".",
"setView",
"(",
"ICON",
",",
"contentView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"icon",
")",
")",
";",
"mgr",
".",
"setView",
"(",
"TITLE",
",",
"contentView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"title",
")",
")",
";",
"mgr",
".",
"setView",
"(",
"TEXT",
",",
"contentView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"text",
")",
")",
";",
"mgr",
".",
"setView",
"(",
"WHEN",
",",
"contentView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"when",
")",
")",
";",
"}",
"}"
] |
Called when content view is changed. All child-views were cleared due the
change of content view. You need to re-setup the associated child-views.
@param view
@param contentView
@param layoutId
|
[
"Called",
"when",
"content",
"view",
"is",
"changed",
".",
"All",
"child",
"-",
"views",
"were",
"cleared",
"due",
"the",
"change",
"of",
"content",
"view",
".",
"You",
"need",
"to",
"re",
"-",
"setup",
"the",
"associated",
"child",
"-",
"views",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationViewCallback.java#L72-L97
|
3,954 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationViewCallback.java
|
NotificationViewCallback.onShowNotification
|
public void onShowNotification(NotificationView view, View contentView, NotificationEntry entry, int layoutId) {
if (DBG) Log.v(TAG, "onShowNotification - " + entry.ID);
final Drawable icon = entry.iconDrawable;
final CharSequence title = entry.title;
final CharSequence text = entry.text;
final CharSequence when = entry.showWhen ? entry.whenFormatted : null;
ChildViewManager mgr = view.getChildViewManager();
if (layoutId == R.layout.notification_simple ||
layoutId == R.layout.notification_large_icon ||
layoutId == R.layout.notification_full) {
boolean titleChanged = true;
boolean contentChanged = view.isContentLayoutChanged();
NotificationEntry lastEntry = view.getLastNotification();
if (!contentChanged && title != null &&
lastEntry != null && title.equals(lastEntry.title)) {
titleChanged = false;
}
mgr.setImageDrawable(ICON, icon, titleChanged);
mgr.setText(TITLE, title, titleChanged);
mgr.setText(TEXT, text);
mgr.setText(WHEN, when);
} else if (layoutId == R.layout.notification_simple_2) {
mgr.setImageDrawable(ICON, icon);
mgr.setText(TITLE, title);
mgr.setText(TEXT, text);
mgr.setText(WHEN, when);
}
}
|
java
|
public void onShowNotification(NotificationView view, View contentView, NotificationEntry entry, int layoutId) {
if (DBG) Log.v(TAG, "onShowNotification - " + entry.ID);
final Drawable icon = entry.iconDrawable;
final CharSequence title = entry.title;
final CharSequence text = entry.text;
final CharSequence when = entry.showWhen ? entry.whenFormatted : null;
ChildViewManager mgr = view.getChildViewManager();
if (layoutId == R.layout.notification_simple ||
layoutId == R.layout.notification_large_icon ||
layoutId == R.layout.notification_full) {
boolean titleChanged = true;
boolean contentChanged = view.isContentLayoutChanged();
NotificationEntry lastEntry = view.getLastNotification();
if (!contentChanged && title != null &&
lastEntry != null && title.equals(lastEntry.title)) {
titleChanged = false;
}
mgr.setImageDrawable(ICON, icon, titleChanged);
mgr.setText(TITLE, title, titleChanged);
mgr.setText(TEXT, text);
mgr.setText(WHEN, when);
} else if (layoutId == R.layout.notification_simple_2) {
mgr.setImageDrawable(ICON, icon);
mgr.setText(TITLE, title);
mgr.setText(TEXT, text);
mgr.setText(WHEN, when);
}
}
|
[
"public",
"void",
"onShowNotification",
"(",
"NotificationView",
"view",
",",
"View",
"contentView",
",",
"NotificationEntry",
"entry",
",",
"int",
"layoutId",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"onShowNotification - \"",
"+",
"entry",
".",
"ID",
")",
";",
"final",
"Drawable",
"icon",
"=",
"entry",
".",
"iconDrawable",
";",
"final",
"CharSequence",
"title",
"=",
"entry",
".",
"title",
";",
"final",
"CharSequence",
"text",
"=",
"entry",
".",
"text",
";",
"final",
"CharSequence",
"when",
"=",
"entry",
".",
"showWhen",
"?",
"entry",
".",
"whenFormatted",
":",
"null",
";",
"ChildViewManager",
"mgr",
"=",
"view",
".",
"getChildViewManager",
"(",
")",
";",
"if",
"(",
"layoutId",
"==",
"R",
".",
"layout",
".",
"notification_simple",
"||",
"layoutId",
"==",
"R",
".",
"layout",
".",
"notification_large_icon",
"||",
"layoutId",
"==",
"R",
".",
"layout",
".",
"notification_full",
")",
"{",
"boolean",
"titleChanged",
"=",
"true",
";",
"boolean",
"contentChanged",
"=",
"view",
".",
"isContentLayoutChanged",
"(",
")",
";",
"NotificationEntry",
"lastEntry",
"=",
"view",
".",
"getLastNotification",
"(",
")",
";",
"if",
"(",
"!",
"contentChanged",
"&&",
"title",
"!=",
"null",
"&&",
"lastEntry",
"!=",
"null",
"&&",
"title",
".",
"equals",
"(",
"lastEntry",
".",
"title",
")",
")",
"{",
"titleChanged",
"=",
"false",
";",
"}",
"mgr",
".",
"setImageDrawable",
"(",
"ICON",
",",
"icon",
",",
"titleChanged",
")",
";",
"mgr",
".",
"setText",
"(",
"TITLE",
",",
"title",
",",
"titleChanged",
")",
";",
"mgr",
".",
"setText",
"(",
"TEXT",
",",
"text",
")",
";",
"mgr",
".",
"setText",
"(",
"WHEN",
",",
"when",
")",
";",
"}",
"else",
"if",
"(",
"layoutId",
"==",
"R",
".",
"layout",
".",
"notification_simple_2",
")",
"{",
"mgr",
".",
"setImageDrawable",
"(",
"ICON",
",",
"icon",
")",
";",
"mgr",
".",
"setText",
"(",
"TITLE",
",",
"title",
")",
";",
"mgr",
".",
"setText",
"(",
"TEXT",
",",
"text",
")",
";",
"mgr",
".",
"setText",
"(",
"WHEN",
",",
"when",
")",
";",
"}",
"}"
] |
Called when a notification is being displayed. This is the place to update
the user interface of child-views for the new notification.
@param view
@param contentView
@param entry
@param layoutId
|
[
"Called",
"when",
"a",
"notification",
"is",
"being",
"displayed",
".",
"This",
"is",
"the",
"place",
"to",
"update",
"the",
"user",
"interface",
"of",
"child",
"-",
"views",
"for",
"the",
"new",
"notification",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationViewCallback.java#L108-L143
|
3,955 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationViewCallback.java
|
NotificationViewCallback.onUpdateNotification
|
public void onUpdateNotification(NotificationView view, View contentView, NotificationEntry entry, int layoutId) {
if (DBG) Log.v(TAG, "onUpdateNotification - " + entry.ID);
final Drawable icon = entry.iconDrawable;
final CharSequence title = entry.title;
final CharSequence text = entry.text;
final CharSequence when = entry.showWhen ? entry.whenFormatted : null;
ChildViewManager mgr = view.getChildViewManager();
mgr.setImageDrawable(ICON, icon, false);
mgr.setText(TITLE, title, false);
mgr.setText(TEXT, text, false);
mgr.setText(WHEN, when, false);
}
|
java
|
public void onUpdateNotification(NotificationView view, View contentView, NotificationEntry entry, int layoutId) {
if (DBG) Log.v(TAG, "onUpdateNotification - " + entry.ID);
final Drawable icon = entry.iconDrawable;
final CharSequence title = entry.title;
final CharSequence text = entry.text;
final CharSequence when = entry.showWhen ? entry.whenFormatted : null;
ChildViewManager mgr = view.getChildViewManager();
mgr.setImageDrawable(ICON, icon, false);
mgr.setText(TITLE, title, false);
mgr.setText(TEXT, text, false);
mgr.setText(WHEN, when, false);
}
|
[
"public",
"void",
"onUpdateNotification",
"(",
"NotificationView",
"view",
",",
"View",
"contentView",
",",
"NotificationEntry",
"entry",
",",
"int",
"layoutId",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"onUpdateNotification - \"",
"+",
"entry",
".",
"ID",
")",
";",
"final",
"Drawable",
"icon",
"=",
"entry",
".",
"iconDrawable",
";",
"final",
"CharSequence",
"title",
"=",
"entry",
".",
"title",
";",
"final",
"CharSequence",
"text",
"=",
"entry",
".",
"text",
";",
"final",
"CharSequence",
"when",
"=",
"entry",
".",
"showWhen",
"?",
"entry",
".",
"whenFormatted",
":",
"null",
";",
"ChildViewManager",
"mgr",
"=",
"view",
".",
"getChildViewManager",
"(",
")",
";",
"mgr",
".",
"setImageDrawable",
"(",
"ICON",
",",
"icon",
",",
"false",
")",
";",
"mgr",
".",
"setText",
"(",
"TITLE",
",",
"title",
",",
"false",
")",
";",
"mgr",
".",
"setText",
"(",
"TEXT",
",",
"text",
",",
"false",
")",
";",
"mgr",
".",
"setText",
"(",
"WHEN",
",",
"when",
",",
"false",
")",
";",
"}"
] |
Called when a notification is being updated.
@param view
@param contentView
@param entry
@param layoutId
|
[
"Called",
"when",
"a",
"notification",
"is",
"being",
"updated",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationViewCallback.java#L153-L167
|
3,956 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationViewCallback.java
|
NotificationViewCallback.onClickContentView
|
public void onClickContentView(NotificationView view, View contentView, NotificationEntry entry) {
if (DBG) Log.v(TAG, "onClickContentView - " + entry.ID);
}
|
java
|
public void onClickContentView(NotificationView view, View contentView, NotificationEntry entry) {
if (DBG) Log.v(TAG, "onClickContentView - " + entry.ID);
}
|
[
"public",
"void",
"onClickContentView",
"(",
"NotificationView",
"view",
",",
"View",
"contentView",
",",
"NotificationEntry",
"entry",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"onClickContentView - \"",
"+",
"entry",
".",
"ID",
")",
";",
"}"
] |
Called when the view has been clicked.
@param view
@param contentView
@param entry
@return boolean true, if handled.
|
[
"Called",
"when",
"the",
"view",
"has",
"been",
"clicked",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationViewCallback.java#L177-L179
|
3,957 |
lamydev/Android-Notification
|
core/src/zemin/notification/AnimationFactory.java
|
AnimationFactory.pushDownIn
|
public static Animation pushDownIn() {
AnimationSet animationSet = new AnimationSet(true);
animationSet.setFillAfter(true);
animationSet.addAnimation(new TranslateAnimation(0, 0, -100, 0));
animationSet.addAnimation(new AlphaAnimation(0.0f, 1.0f));
return animationSet;
}
|
java
|
public static Animation pushDownIn() {
AnimationSet animationSet = new AnimationSet(true);
animationSet.setFillAfter(true);
animationSet.addAnimation(new TranslateAnimation(0, 0, -100, 0));
animationSet.addAnimation(new AlphaAnimation(0.0f, 1.0f));
return animationSet;
}
|
[
"public",
"static",
"Animation",
"pushDownIn",
"(",
")",
"{",
"AnimationSet",
"animationSet",
"=",
"new",
"AnimationSet",
"(",
"true",
")",
";",
"animationSet",
".",
"setFillAfter",
"(",
"true",
")",
";",
"animationSet",
".",
"addAnimation",
"(",
"new",
"TranslateAnimation",
"(",
"0",
",",
"0",
",",
"-",
"100",
",",
"0",
")",
")",
";",
"animationSet",
".",
"addAnimation",
"(",
"new",
"AlphaAnimation",
"(",
"0.0f",
",",
"1.0f",
")",
")",
";",
"return",
"animationSet",
";",
"}"
] |
Create push down animation for entering.
@return Animation
|
[
"Create",
"push",
"down",
"animation",
"for",
"entering",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/AnimationFactory.java#L34-L40
|
3,958 |
whitesource/fs-agent
|
src/main/java/org/whitesource/fs/configuration/ConfigurationValidation.java
|
ConfigurationValidation.getConfigurationErrors
|
public List<String> getConfigurationErrors(boolean projectPerFolder, String configProjectToken, String configProjectName, String configApiToken, String configFilePath,
int archiveDepth, String[] includes, String[] projectPerFolderIncludes, String[] pythonIncludes, String scanComment) {
List<String> errors = new ArrayList<>();
String[] requirements = pythonIncludes[Constants.ZERO].split(Constants.WHITESPACE);
if (StringUtils.isBlank(configApiToken)) {
String error = "Could not retrieve " + ORG_TOKEN_PROPERTY_KEY + " property from " + configFilePath;
errors.add(error);
}
boolean noProjectToken = StringUtils.isBlank(configProjectToken);
boolean noProjectName = StringUtils.isBlank(configProjectName);
if (noProjectToken && noProjectName && !projectPerFolder) {
String error = "Could not retrieve properties " + PROJECT_NAME_PROPERTY_KEY + " and " + PROJECT_TOKEN_PROPERTY_KEY + " from " + configFilePath;
errors.add(error);
} else if (!noProjectToken && !noProjectName) {
String error = "Please choose just one of either " + PROJECT_NAME_PROPERTY_KEY + " or " + PROJECT_TOKEN_PROPERTY_KEY + " (and not both)";
errors.add(error);
}
if (archiveDepth < Constants.ZERO || archiveDepth > Constants.MAX_EXTRACTION_DEPTH) {
errors.add("Error: archiveExtractionDepth value should be greater than 0 and less than " + Constants.MAX_EXTRACTION_DEPTH);
}
if (includes.length < Constants.ONE || StringUtils.isBlank(includes[Constants.ZERO])) {
errors.add("Error: includes parameter must have at list one scanning pattern");
}
if (projectPerFolder && projectPerFolderIncludes == null) {
errors.add("projectPerFolderIncludes parameter is empty, specify folders to include or mark as comment to scan all folders");
}
if (requirements.length > Constants.ZERO) {
for (String requirement : requirements) {
if (!requirement.endsWith(Constants.TXT_EXTENSION)) {
String error = "Invalid file name: " + requirement + Constants.WHITESPACE + "in property" + PYTHON_REQUIREMENTS_FILE_INCLUDES + "from " + configFilePath;
errors.add(error);
}
}
}
// get user comment & check max valid size
if (!StringUtils.isBlank(scanComment)) {
if (scanComment.length() > Constants.COMMENT_MAX_LENGTH) {
errors.add("Error: scanComment parameters is longer than 1000 characters");
}
}
return errors;
}
|
java
|
public List<String> getConfigurationErrors(boolean projectPerFolder, String configProjectToken, String configProjectName, String configApiToken, String configFilePath,
int archiveDepth, String[] includes, String[] projectPerFolderIncludes, String[] pythonIncludes, String scanComment) {
List<String> errors = new ArrayList<>();
String[] requirements = pythonIncludes[Constants.ZERO].split(Constants.WHITESPACE);
if (StringUtils.isBlank(configApiToken)) {
String error = "Could not retrieve " + ORG_TOKEN_PROPERTY_KEY + " property from " + configFilePath;
errors.add(error);
}
boolean noProjectToken = StringUtils.isBlank(configProjectToken);
boolean noProjectName = StringUtils.isBlank(configProjectName);
if (noProjectToken && noProjectName && !projectPerFolder) {
String error = "Could not retrieve properties " + PROJECT_NAME_PROPERTY_KEY + " and " + PROJECT_TOKEN_PROPERTY_KEY + " from " + configFilePath;
errors.add(error);
} else if (!noProjectToken && !noProjectName) {
String error = "Please choose just one of either " + PROJECT_NAME_PROPERTY_KEY + " or " + PROJECT_TOKEN_PROPERTY_KEY + " (and not both)";
errors.add(error);
}
if (archiveDepth < Constants.ZERO || archiveDepth > Constants.MAX_EXTRACTION_DEPTH) {
errors.add("Error: archiveExtractionDepth value should be greater than 0 and less than " + Constants.MAX_EXTRACTION_DEPTH);
}
if (includes.length < Constants.ONE || StringUtils.isBlank(includes[Constants.ZERO])) {
errors.add("Error: includes parameter must have at list one scanning pattern");
}
if (projectPerFolder && projectPerFolderIncludes == null) {
errors.add("projectPerFolderIncludes parameter is empty, specify folders to include or mark as comment to scan all folders");
}
if (requirements.length > Constants.ZERO) {
for (String requirement : requirements) {
if (!requirement.endsWith(Constants.TXT_EXTENSION)) {
String error = "Invalid file name: " + requirement + Constants.WHITESPACE + "in property" + PYTHON_REQUIREMENTS_FILE_INCLUDES + "from " + configFilePath;
errors.add(error);
}
}
}
// get user comment & check max valid size
if (!StringUtils.isBlank(scanComment)) {
if (scanComment.length() > Constants.COMMENT_MAX_LENGTH) {
errors.add("Error: scanComment parameters is longer than 1000 characters");
}
}
return errors;
}
|
[
"public",
"List",
"<",
"String",
">",
"getConfigurationErrors",
"(",
"boolean",
"projectPerFolder",
",",
"String",
"configProjectToken",
",",
"String",
"configProjectName",
",",
"String",
"configApiToken",
",",
"String",
"configFilePath",
",",
"int",
"archiveDepth",
",",
"String",
"[",
"]",
"includes",
",",
"String",
"[",
"]",
"projectPerFolderIncludes",
",",
"String",
"[",
"]",
"pythonIncludes",
",",
"String",
"scanComment",
")",
"{",
"List",
"<",
"String",
">",
"errors",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"String",
"[",
"]",
"requirements",
"=",
"pythonIncludes",
"[",
"Constants",
".",
"ZERO",
"]",
".",
"split",
"(",
"Constants",
".",
"WHITESPACE",
")",
";",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"configApiToken",
")",
")",
"{",
"String",
"error",
"=",
"\"Could not retrieve \"",
"+",
"ORG_TOKEN_PROPERTY_KEY",
"+",
"\" property from \"",
"+",
"configFilePath",
";",
"errors",
".",
"add",
"(",
"error",
")",
";",
"}",
"boolean",
"noProjectToken",
"=",
"StringUtils",
".",
"isBlank",
"(",
"configProjectToken",
")",
";",
"boolean",
"noProjectName",
"=",
"StringUtils",
".",
"isBlank",
"(",
"configProjectName",
")",
";",
"if",
"(",
"noProjectToken",
"&&",
"noProjectName",
"&&",
"!",
"projectPerFolder",
")",
"{",
"String",
"error",
"=",
"\"Could not retrieve properties \"",
"+",
"PROJECT_NAME_PROPERTY_KEY",
"+",
"\" and \"",
"+",
"PROJECT_TOKEN_PROPERTY_KEY",
"+",
"\" from \"",
"+",
"configFilePath",
";",
"errors",
".",
"add",
"(",
"error",
")",
";",
"}",
"else",
"if",
"(",
"!",
"noProjectToken",
"&&",
"!",
"noProjectName",
")",
"{",
"String",
"error",
"=",
"\"Please choose just one of either \"",
"+",
"PROJECT_NAME_PROPERTY_KEY",
"+",
"\" or \"",
"+",
"PROJECT_TOKEN_PROPERTY_KEY",
"+",
"\" (and not both)\"",
";",
"errors",
".",
"add",
"(",
"error",
")",
";",
"}",
"if",
"(",
"archiveDepth",
"<",
"Constants",
".",
"ZERO",
"||",
"archiveDepth",
">",
"Constants",
".",
"MAX_EXTRACTION_DEPTH",
")",
"{",
"errors",
".",
"add",
"(",
"\"Error: archiveExtractionDepth value should be greater than 0 and less than \"",
"+",
"Constants",
".",
"MAX_EXTRACTION_DEPTH",
")",
";",
"}",
"if",
"(",
"includes",
".",
"length",
"<",
"Constants",
".",
"ONE",
"||",
"StringUtils",
".",
"isBlank",
"(",
"includes",
"[",
"Constants",
".",
"ZERO",
"]",
")",
")",
"{",
"errors",
".",
"add",
"(",
"\"Error: includes parameter must have at list one scanning pattern\"",
")",
";",
"}",
"if",
"(",
"projectPerFolder",
"&&",
"projectPerFolderIncludes",
"==",
"null",
")",
"{",
"errors",
".",
"add",
"(",
"\"projectPerFolderIncludes parameter is empty, specify folders to include or mark as comment to scan all folders\"",
")",
";",
"}",
"if",
"(",
"requirements",
".",
"length",
">",
"Constants",
".",
"ZERO",
")",
"{",
"for",
"(",
"String",
"requirement",
":",
"requirements",
")",
"{",
"if",
"(",
"!",
"requirement",
".",
"endsWith",
"(",
"Constants",
".",
"TXT_EXTENSION",
")",
")",
"{",
"String",
"error",
"=",
"\"Invalid file name: \"",
"+",
"requirement",
"+",
"Constants",
".",
"WHITESPACE",
"+",
"\"in property\"",
"+",
"PYTHON_REQUIREMENTS_FILE_INCLUDES",
"+",
"\"from \"",
"+",
"configFilePath",
";",
"errors",
".",
"add",
"(",
"error",
")",
";",
"}",
"}",
"}",
"// get user comment & check max valid size",
"if",
"(",
"!",
"StringUtils",
".",
"isBlank",
"(",
"scanComment",
")",
")",
"{",
"if",
"(",
"scanComment",
".",
"length",
"(",
")",
">",
"Constants",
".",
"COMMENT_MAX_LENGTH",
")",
"{",
"errors",
".",
"add",
"(",
"\"Error: scanComment parameters is longer than 1000 characters\"",
")",
";",
"}",
"}",
"return",
"errors",
";",
"}"
] |
Check configuration errors
|
[
"Check",
"configuration",
"errors"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/fs/configuration/ConfigurationValidation.java#L32-L75
|
3,959 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/FileSystemScanner.java
|
FileSystemScanner.createProjects
|
@Deprecated
public List<DependencyInfo> createProjects(List<String> scannerBaseDirs, Map<String, Set<String>> appPathsToDependencyDirs, boolean scmConnector,
String[] includes, String[] excludes, boolean globCaseSensitive, int archiveExtractionDepth,
String[] archiveIncludes, String[] archiveExcludes, boolean archiveFastUnpack, boolean followSymlinks,
Collection<String> excludedCopyrights, boolean partialSha1Match, String[] pythonRequirementsFileIncludes) {
Collection<AgentProjectInfo> projects = createProjects(scannerBaseDirs, appPathsToDependencyDirs, scmConnector, includes, excludes, globCaseSensitive, archiveExtractionDepth,
archiveIncludes, archiveExcludes, archiveFastUnpack, followSymlinks, excludedCopyrights, partialSha1Match,
false, false, pythonRequirementsFileIncludes).keySet();
return projects.stream().flatMap(project -> project.getDependencies().stream()).collect(Collectors.toList());
}
|
java
|
@Deprecated
public List<DependencyInfo> createProjects(List<String> scannerBaseDirs, Map<String, Set<String>> appPathsToDependencyDirs, boolean scmConnector,
String[] includes, String[] excludes, boolean globCaseSensitive, int archiveExtractionDepth,
String[] archiveIncludes, String[] archiveExcludes, boolean archiveFastUnpack, boolean followSymlinks,
Collection<String> excludedCopyrights, boolean partialSha1Match, String[] pythonRequirementsFileIncludes) {
Collection<AgentProjectInfo> projects = createProjects(scannerBaseDirs, appPathsToDependencyDirs, scmConnector, includes, excludes, globCaseSensitive, archiveExtractionDepth,
archiveIncludes, archiveExcludes, archiveFastUnpack, followSymlinks, excludedCopyrights, partialSha1Match,
false, false, pythonRequirementsFileIncludes).keySet();
return projects.stream().flatMap(project -> project.getDependencies().stream()).collect(Collectors.toList());
}
|
[
"@",
"Deprecated",
"public",
"List",
"<",
"DependencyInfo",
">",
"createProjects",
"(",
"List",
"<",
"String",
">",
"scannerBaseDirs",
",",
"Map",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
"appPathsToDependencyDirs",
",",
"boolean",
"scmConnector",
",",
"String",
"[",
"]",
"includes",
",",
"String",
"[",
"]",
"excludes",
",",
"boolean",
"globCaseSensitive",
",",
"int",
"archiveExtractionDepth",
",",
"String",
"[",
"]",
"archiveIncludes",
",",
"String",
"[",
"]",
"archiveExcludes",
",",
"boolean",
"archiveFastUnpack",
",",
"boolean",
"followSymlinks",
",",
"Collection",
"<",
"String",
">",
"excludedCopyrights",
",",
"boolean",
"partialSha1Match",
",",
"String",
"[",
"]",
"pythonRequirementsFileIncludes",
")",
"{",
"Collection",
"<",
"AgentProjectInfo",
">",
"projects",
"=",
"createProjects",
"(",
"scannerBaseDirs",
",",
"appPathsToDependencyDirs",
",",
"scmConnector",
",",
"includes",
",",
"excludes",
",",
"globCaseSensitive",
",",
"archiveExtractionDepth",
",",
"archiveIncludes",
",",
"archiveExcludes",
",",
"archiveFastUnpack",
",",
"followSymlinks",
",",
"excludedCopyrights",
",",
"partialSha1Match",
",",
"false",
",",
"false",
",",
"pythonRequirementsFileIncludes",
")",
".",
"keySet",
"(",
")",
";",
"return",
"projects",
".",
"stream",
"(",
")",
".",
"flatMap",
"(",
"project",
"->",
"project",
".",
"getDependencies",
"(",
")",
".",
"stream",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] |
This method is usually called from outside by different other tools
@param scannerBaseDirs folders to scan
@param scmConnector use scmConnector
@param includes includes glob patterns
@param excludes excludes glob patterns
@param globCaseSensitive global case sensitive
@param archiveExtractionDepth depth of recursive extraction
@param archiveIncludes includes glob patterns for extraction
@param archiveExcludes exclude glob patterns for extraction
@param archiveFastUnpack use fast extraction
@param followSymlinks use followSymlinks
@param excludedCopyrights use excludedCopyrights
@param partialSha1Match use partialSha1Match
@return list of all the dependencies for project
|
[
"This",
"method",
"is",
"usually",
"called",
"from",
"outside",
"by",
"different",
"other",
"tools"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/FileSystemScanner.java#L103-L112
|
3,960 |
whitesource/fs-agent
|
src/main/java/org/whitesource/scm/ScmConnector.java
|
ScmConnector.cloneRepository
|
public File cloneRepository() {
String scmTempFolder = new FilesUtils().createTmpFolder(false, TempFolders.UNIQUE_SCM_TEMP_FOLDER);
cloneDirectory = new File(scmTempFolder, getType().toString().toLowerCase() + Constants.UNDERSCORE +
getUrlName() + Constants.UNDERSCORE + getBranch());
FilesUtils.deleteDirectory(cloneDirectory); // delete just in case it's not empty
logger.info("Cloning repository {} ...this may take a few minutes", getUrl());
File branchDirectory = cloneRepository(cloneDirectory);
return branchDirectory;
}
|
java
|
public File cloneRepository() {
String scmTempFolder = new FilesUtils().createTmpFolder(false, TempFolders.UNIQUE_SCM_TEMP_FOLDER);
cloneDirectory = new File(scmTempFolder, getType().toString().toLowerCase() + Constants.UNDERSCORE +
getUrlName() + Constants.UNDERSCORE + getBranch());
FilesUtils.deleteDirectory(cloneDirectory); // delete just in case it's not empty
logger.info("Cloning repository {} ...this may take a few minutes", getUrl());
File branchDirectory = cloneRepository(cloneDirectory);
return branchDirectory;
}
|
[
"public",
"File",
"cloneRepository",
"(",
")",
"{",
"String",
"scmTempFolder",
"=",
"new",
"FilesUtils",
"(",
")",
".",
"createTmpFolder",
"(",
"false",
",",
"TempFolders",
".",
"UNIQUE_SCM_TEMP_FOLDER",
")",
";",
"cloneDirectory",
"=",
"new",
"File",
"(",
"scmTempFolder",
",",
"getType",
"(",
")",
".",
"toString",
"(",
")",
".",
"toLowerCase",
"(",
")",
"+",
"Constants",
".",
"UNDERSCORE",
"+",
"getUrlName",
"(",
")",
"+",
"Constants",
".",
"UNDERSCORE",
"+",
"getBranch",
"(",
")",
")",
";",
"FilesUtils",
".",
"deleteDirectory",
"(",
"cloneDirectory",
")",
";",
"// delete just in case it's not empty",
"logger",
".",
"info",
"(",
"\"Cloning repository {} ...this may take a few minutes\"",
",",
"getUrl",
"(",
")",
")",
";",
"File",
"branchDirectory",
"=",
"cloneRepository",
"(",
"cloneDirectory",
")",
";",
"return",
"branchDirectory",
";",
"}"
] |
Clones the given repository.
@return The folder in which the specific branch/tag resides.
|
[
"Clones",
"the",
"given",
"repository",
"."
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/scm/ScmConnector.java#L85-L94
|
3,961 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/nuget/packagesConfig/NugetPackagesConfigXmlParser.java
|
NugetPackagesConfigXmlParser.parsePackagesConfigFile
|
public Set<DependencyInfo> parsePackagesConfigFile(boolean getDependenciesFromReferenceTag, String nugetDependencyFile) {
Persister persister = new Persister();
Set<DependencyInfo> dependencies = new HashSet<>();
try {
// case of packages.config file
if (this.nugetConfigFileType == NugetConfigFileType.CONFIG_FILE_TYPE) {
NugetPackages packages = persister.read(NugetPackages.class, xml);
if (!getDependenciesFromReferenceTag) {
dependencies.addAll(collectDependenciesFromNugetConfig(packages, nugetDependencyFile));
}
// case of csproj file
} else {
NugetCsprojPackages csprojPackages = persister.read(NugetCsprojPackages.class, xml);
NugetPackages packages = getNugetPackagesFromCsproj(csprojPackages);
if (!getDependenciesFromReferenceTag) {
dependencies.addAll(collectDependenciesFromNugetConfig(packages, nugetDependencyFile));
}
dependencies.addAll(getDependenciesFromReferencesTag(csprojPackages));
}
dependencies.stream().forEach(dependencyInfo -> dependencyInfo.setSystemPath(this.xml.getPath()));
} catch (Exception e) {
logger.warn("Unable to parse suspected Nuget package configuration file {}", xml, e.getMessage());
}
return dependencies;
}
|
java
|
public Set<DependencyInfo> parsePackagesConfigFile(boolean getDependenciesFromReferenceTag, String nugetDependencyFile) {
Persister persister = new Persister();
Set<DependencyInfo> dependencies = new HashSet<>();
try {
// case of packages.config file
if (this.nugetConfigFileType == NugetConfigFileType.CONFIG_FILE_TYPE) {
NugetPackages packages = persister.read(NugetPackages.class, xml);
if (!getDependenciesFromReferenceTag) {
dependencies.addAll(collectDependenciesFromNugetConfig(packages, nugetDependencyFile));
}
// case of csproj file
} else {
NugetCsprojPackages csprojPackages = persister.read(NugetCsprojPackages.class, xml);
NugetPackages packages = getNugetPackagesFromCsproj(csprojPackages);
if (!getDependenciesFromReferenceTag) {
dependencies.addAll(collectDependenciesFromNugetConfig(packages, nugetDependencyFile));
}
dependencies.addAll(getDependenciesFromReferencesTag(csprojPackages));
}
dependencies.stream().forEach(dependencyInfo -> dependencyInfo.setSystemPath(this.xml.getPath()));
} catch (Exception e) {
logger.warn("Unable to parse suspected Nuget package configuration file {}", xml, e.getMessage());
}
return dependencies;
}
|
[
"public",
"Set",
"<",
"DependencyInfo",
">",
"parsePackagesConfigFile",
"(",
"boolean",
"getDependenciesFromReferenceTag",
",",
"String",
"nugetDependencyFile",
")",
"{",
"Persister",
"persister",
"=",
"new",
"Persister",
"(",
")",
";",
"Set",
"<",
"DependencyInfo",
">",
"dependencies",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"try",
"{",
"// case of packages.config file",
"if",
"(",
"this",
".",
"nugetConfigFileType",
"==",
"NugetConfigFileType",
".",
"CONFIG_FILE_TYPE",
")",
"{",
"NugetPackages",
"packages",
"=",
"persister",
".",
"read",
"(",
"NugetPackages",
".",
"class",
",",
"xml",
")",
";",
"if",
"(",
"!",
"getDependenciesFromReferenceTag",
")",
"{",
"dependencies",
".",
"addAll",
"(",
"collectDependenciesFromNugetConfig",
"(",
"packages",
",",
"nugetDependencyFile",
")",
")",
";",
"}",
"// case of csproj file",
"}",
"else",
"{",
"NugetCsprojPackages",
"csprojPackages",
"=",
"persister",
".",
"read",
"(",
"NugetCsprojPackages",
".",
"class",
",",
"xml",
")",
";",
"NugetPackages",
"packages",
"=",
"getNugetPackagesFromCsproj",
"(",
"csprojPackages",
")",
";",
"if",
"(",
"!",
"getDependenciesFromReferenceTag",
")",
"{",
"dependencies",
".",
"addAll",
"(",
"collectDependenciesFromNugetConfig",
"(",
"packages",
",",
"nugetDependencyFile",
")",
")",
";",
"}",
"dependencies",
".",
"addAll",
"(",
"getDependenciesFromReferencesTag",
"(",
"csprojPackages",
")",
")",
";",
"}",
"dependencies",
".",
"stream",
"(",
")",
".",
"forEach",
"(",
"dependencyInfo",
"->",
"dependencyInfo",
".",
"setSystemPath",
"(",
"this",
".",
"xml",
".",
"getPath",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Unable to parse suspected Nuget package configuration file {}\"",
",",
"xml",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"dependencies",
";",
"}"
] |
Parse packages.config or csproj file
@param getDependenciesFromReferenceTag - flag to indicate weather to get dependencies form reference tag or not
@return Set of DependencyInfos
|
[
"Parse",
"packages",
".",
"config",
"or",
"csproj",
"file"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/nuget/packagesConfig/NugetPackagesConfigXmlParser.java#L65-L89
|
3,962 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/ruby/RubyDependencyResolver.java
|
RubyDependencyResolver.findPathToGems
|
private String findPathToGems() throws FileNotFoundException {
String[] commandParams = cli.getCommandParams(GEM, ENVIRONMENT);
List<String> lines = cli.runCmd(rootDirectory, commandParams);
String path = null;
if (!lines.isEmpty()) {
path = lines.get(0) + fileSeparator + CACHE;
if (new File(path).isDirectory() == false) {
throw new FileNotFoundException();
}
}
return path;
}
|
java
|
private String findPathToGems() throws FileNotFoundException {
String[] commandParams = cli.getCommandParams(GEM, ENVIRONMENT);
List<String> lines = cli.runCmd(rootDirectory, commandParams);
String path = null;
if (!lines.isEmpty()) {
path = lines.get(0) + fileSeparator + CACHE;
if (new File(path).isDirectory() == false) {
throw new FileNotFoundException();
}
}
return path;
}
|
[
"private",
"String",
"findPathToGems",
"(",
")",
"throws",
"FileNotFoundException",
"{",
"String",
"[",
"]",
"commandParams",
"=",
"cli",
".",
"getCommandParams",
"(",
"GEM",
",",
"ENVIRONMENT",
")",
";",
"List",
"<",
"String",
">",
"lines",
"=",
"cli",
".",
"runCmd",
"(",
"rootDirectory",
",",
"commandParams",
")",
";",
"String",
"path",
"=",
"null",
";",
"if",
"(",
"!",
"lines",
".",
"isEmpty",
"(",
")",
")",
"{",
"path",
"=",
"lines",
".",
"get",
"(",
"0",
")",
"+",
"fileSeparator",
"+",
"CACHE",
";",
"if",
"(",
"new",
"File",
"(",
"path",
")",
".",
"isDirectory",
"(",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
")",
";",
"}",
"}",
"return",
"path",
";",
"}"
] |
Ruby's cache is inside the installation folder. path can be found by running command 'gem environment gemdir'
|
[
"Ruby",
"s",
"cache",
"is",
"inside",
"the",
"installation",
"folder",
".",
"path",
"can",
"be",
"found",
"by",
"running",
"command",
"gem",
"environment",
"gemdir"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/ruby/RubyDependencyResolver.java#L547-L558
|
3,963 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/ruby/RubyDependencyResolver.java
|
RubyDependencyResolver.findGemVersion
|
private String findGemVersion(String gemName, String pathToGems) {
String version = null;
File maxVersionFile = findMaxVersionFile(gemName, pathToGems);
if (maxVersionFile != null) {
String fileName = maxVersionFile.getName();
version = getVersionFromFileName(fileName, gemName);
}
return version;
}
|
java
|
private String findGemVersion(String gemName, String pathToGems) {
String version = null;
File maxVersionFile = findMaxVersionFile(gemName, pathToGems);
if (maxVersionFile != null) {
String fileName = maxVersionFile.getName();
version = getVersionFromFileName(fileName, gemName);
}
return version;
}
|
[
"private",
"String",
"findGemVersion",
"(",
"String",
"gemName",
",",
"String",
"pathToGems",
")",
"{",
"String",
"version",
"=",
"null",
";",
"File",
"maxVersionFile",
"=",
"findMaxVersionFile",
"(",
"gemName",
",",
"pathToGems",
")",
";",
"if",
"(",
"maxVersionFile",
"!=",
"null",
")",
"{",
"String",
"fileName",
"=",
"maxVersionFile",
".",
"getName",
"(",
")",
";",
"version",
"=",
"getVersionFromFileName",
"(",
"fileName",
",",
"gemName",
")",
";",
"}",
"return",
"version",
";",
"}"
] |
in such cases, look for the relevant gem file in the cache with the highest version
|
[
"in",
"such",
"cases",
"look",
"for",
"the",
"relevant",
"gem",
"file",
"in",
"the",
"cache",
"with",
"the",
"highest",
"version"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/ruby/RubyDependencyResolver.java#L617-L625
|
3,964 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoardCallback.java
|
NotificationBoardCallback.makeRowView
|
public View makeRowView(NotificationBoard board, NotificationEntry entry, LayoutInflater inflater) {
return inflater.inflate(R.layout.notification_board_row, null, false);
}
|
java
|
public View makeRowView(NotificationBoard board, NotificationEntry entry, LayoutInflater inflater) {
return inflater.inflate(R.layout.notification_board_row, null, false);
}
|
[
"public",
"View",
"makeRowView",
"(",
"NotificationBoard",
"board",
",",
"NotificationEntry",
"entry",
",",
"LayoutInflater",
"inflater",
")",
"{",
"return",
"inflater",
".",
"inflate",
"(",
"R",
".",
"layout",
".",
"notification_board_row",
",",
"null",
",",
"false",
")",
";",
"}"
] |
Called to instantiate a view being placed in the row view,
which is the user interface for the incoming notification.
@param board
@param entry
@param inflater
@return View
|
[
"Called",
"to",
"instantiate",
"a",
"view",
"being",
"placed",
"in",
"the",
"row",
"view",
"which",
"is",
"the",
"user",
"interface",
"for",
"the",
"incoming",
"notification",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoardCallback.java#L101-L104
|
3,965 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoardCallback.java
|
NotificationBoardCallback.onRowViewAdded
|
public void onRowViewAdded(NotificationBoard board, RowView rowView, NotificationEntry entry) {
if (DBG) Log.v(TAG, "onRowViewAdded - " + entry.ID);
if (entry.hasActions()) {
ArrayList<Action> actions = entry.getActions();
ViewGroup vg = (ViewGroup) rowView.findViewById(R.id.actions);
vg.setVisibility(View.VISIBLE);
vg = (ViewGroup) vg.getChildAt(0);
final View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
Action act = (Action) view.getTag();
onClickActionView(act.entry, act, view);
act.execute(view.getContext());
}
};
for (int i = 0, count = actions.size(); i < count; i++) {
Action act = actions.get(i);
Button actionBtn = (Button) vg.getChildAt(i);
actionBtn.setVisibility(View.VISIBLE);
actionBtn.setTag(act);
actionBtn.setText(act.title);
actionBtn.setOnClickListener(onClickListener);
actionBtn.setCompoundDrawablesWithIntrinsicBounds(act.icon, 0, 0, 0);
}
}
}
|
java
|
public void onRowViewAdded(NotificationBoard board, RowView rowView, NotificationEntry entry) {
if (DBG) Log.v(TAG, "onRowViewAdded - " + entry.ID);
if (entry.hasActions()) {
ArrayList<Action> actions = entry.getActions();
ViewGroup vg = (ViewGroup) rowView.findViewById(R.id.actions);
vg.setVisibility(View.VISIBLE);
vg = (ViewGroup) vg.getChildAt(0);
final View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
Action act = (Action) view.getTag();
onClickActionView(act.entry, act, view);
act.execute(view.getContext());
}
};
for (int i = 0, count = actions.size(); i < count; i++) {
Action act = actions.get(i);
Button actionBtn = (Button) vg.getChildAt(i);
actionBtn.setVisibility(View.VISIBLE);
actionBtn.setTag(act);
actionBtn.setText(act.title);
actionBtn.setOnClickListener(onClickListener);
actionBtn.setCompoundDrawablesWithIntrinsicBounds(act.icon, 0, 0, 0);
}
}
}
|
[
"public",
"void",
"onRowViewAdded",
"(",
"NotificationBoard",
"board",
",",
"RowView",
"rowView",
",",
"NotificationEntry",
"entry",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"onRowViewAdded - \"",
"+",
"entry",
".",
"ID",
")",
";",
"if",
"(",
"entry",
".",
"hasActions",
"(",
")",
")",
"{",
"ArrayList",
"<",
"Action",
">",
"actions",
"=",
"entry",
".",
"getActions",
"(",
")",
";",
"ViewGroup",
"vg",
"=",
"(",
"ViewGroup",
")",
"rowView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"actions",
")",
";",
"vg",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"vg",
"=",
"(",
"ViewGroup",
")",
"vg",
".",
"getChildAt",
"(",
"0",
")",
";",
"final",
"View",
".",
"OnClickListener",
"onClickListener",
"=",
"new",
"View",
".",
"OnClickListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onClick",
"(",
"View",
"view",
")",
"{",
"Action",
"act",
"=",
"(",
"Action",
")",
"view",
".",
"getTag",
"(",
")",
";",
"onClickActionView",
"(",
"act",
".",
"entry",
",",
"act",
",",
"view",
")",
";",
"act",
".",
"execute",
"(",
"view",
".",
"getContext",
"(",
")",
")",
";",
"}",
"}",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"count",
"=",
"actions",
".",
"size",
"(",
")",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"Action",
"act",
"=",
"actions",
".",
"get",
"(",
"i",
")",
";",
"Button",
"actionBtn",
"=",
"(",
"Button",
")",
"vg",
".",
"getChildAt",
"(",
"i",
")",
";",
"actionBtn",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"actionBtn",
".",
"setTag",
"(",
"act",
")",
";",
"actionBtn",
".",
"setText",
"(",
"act",
".",
"title",
")",
";",
"actionBtn",
".",
"setOnClickListener",
"(",
"onClickListener",
")",
";",
"actionBtn",
".",
"setCompoundDrawablesWithIntrinsicBounds",
"(",
"act",
".",
"icon",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"}",
"}",
"}"
] |
Called when a row view is added to the board.
@param board
@param rowView
@param entry
|
[
"Called",
"when",
"a",
"row",
"view",
"is",
"added",
"to",
"the",
"board",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoardCallback.java#L113-L142
|
3,966 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoardCallback.java
|
NotificationBoardCallback.onRowViewUpdate
|
public void onRowViewUpdate(NotificationBoard board, RowView rowView, NotificationEntry entry) {
if (DBG) Log.v(TAG, "onRowViewUpdate - " + entry.ID);
ImageView iconView = (ImageView) rowView.findViewById(R.id.icon);
TextView titleView = (TextView) rowView.findViewById(R.id.title);
TextView textView = (TextView) rowView.findViewById(R.id.text);
TextView whenView = (TextView) rowView.findViewById(R.id.when);
ProgressBar bar = (ProgressBar) rowView.findViewById(R.id.progress);
if (entry.iconDrawable != null) {
iconView.setImageDrawable(entry.iconDrawable);
} else if (entry.smallIconRes != 0) {
iconView.setImageResource(entry.smallIconRes);
} else if (entry.largeIconBitmap != null) {
iconView.setImageBitmap(entry.largeIconBitmap);
}
titleView.setText(entry.title);
textView.setText(entry.text);
if (entry.showWhen) {
whenView.setText(entry.whenFormatted);
}
if (entry.progressMax != 0 || entry.progressIndeterminate) {
bar.setVisibility(View.VISIBLE);
bar.setIndeterminate(entry.progressIndeterminate);
if (!entry.progressIndeterminate) {
bar.setMax(entry.progressMax);
bar.setProgress(entry.progress);
}
} else {
bar.setVisibility(View.GONE);
}
}
|
java
|
public void onRowViewUpdate(NotificationBoard board, RowView rowView, NotificationEntry entry) {
if (DBG) Log.v(TAG, "onRowViewUpdate - " + entry.ID);
ImageView iconView = (ImageView) rowView.findViewById(R.id.icon);
TextView titleView = (TextView) rowView.findViewById(R.id.title);
TextView textView = (TextView) rowView.findViewById(R.id.text);
TextView whenView = (TextView) rowView.findViewById(R.id.when);
ProgressBar bar = (ProgressBar) rowView.findViewById(R.id.progress);
if (entry.iconDrawable != null) {
iconView.setImageDrawable(entry.iconDrawable);
} else if (entry.smallIconRes != 0) {
iconView.setImageResource(entry.smallIconRes);
} else if (entry.largeIconBitmap != null) {
iconView.setImageBitmap(entry.largeIconBitmap);
}
titleView.setText(entry.title);
textView.setText(entry.text);
if (entry.showWhen) {
whenView.setText(entry.whenFormatted);
}
if (entry.progressMax != 0 || entry.progressIndeterminate) {
bar.setVisibility(View.VISIBLE);
bar.setIndeterminate(entry.progressIndeterminate);
if (!entry.progressIndeterminate) {
bar.setMax(entry.progressMax);
bar.setProgress(entry.progress);
}
} else {
bar.setVisibility(View.GONE);
}
}
|
[
"public",
"void",
"onRowViewUpdate",
"(",
"NotificationBoard",
"board",
",",
"RowView",
"rowView",
",",
"NotificationEntry",
"entry",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"onRowViewUpdate - \"",
"+",
"entry",
".",
"ID",
")",
";",
"ImageView",
"iconView",
"=",
"(",
"ImageView",
")",
"rowView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"icon",
")",
";",
"TextView",
"titleView",
"=",
"(",
"TextView",
")",
"rowView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"title",
")",
";",
"TextView",
"textView",
"=",
"(",
"TextView",
")",
"rowView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"text",
")",
";",
"TextView",
"whenView",
"=",
"(",
"TextView",
")",
"rowView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"when",
")",
";",
"ProgressBar",
"bar",
"=",
"(",
"ProgressBar",
")",
"rowView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"progress",
")",
";",
"if",
"(",
"entry",
".",
"iconDrawable",
"!=",
"null",
")",
"{",
"iconView",
".",
"setImageDrawable",
"(",
"entry",
".",
"iconDrawable",
")",
";",
"}",
"else",
"if",
"(",
"entry",
".",
"smallIconRes",
"!=",
"0",
")",
"{",
"iconView",
".",
"setImageResource",
"(",
"entry",
".",
"smallIconRes",
")",
";",
"}",
"else",
"if",
"(",
"entry",
".",
"largeIconBitmap",
"!=",
"null",
")",
"{",
"iconView",
".",
"setImageBitmap",
"(",
"entry",
".",
"largeIconBitmap",
")",
";",
"}",
"titleView",
".",
"setText",
"(",
"entry",
".",
"title",
")",
";",
"textView",
".",
"setText",
"(",
"entry",
".",
"text",
")",
";",
"if",
"(",
"entry",
".",
"showWhen",
")",
"{",
"whenView",
".",
"setText",
"(",
"entry",
".",
"whenFormatted",
")",
";",
"}",
"if",
"(",
"entry",
".",
"progressMax",
"!=",
"0",
"||",
"entry",
".",
"progressIndeterminate",
")",
"{",
"bar",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"bar",
".",
"setIndeterminate",
"(",
"entry",
".",
"progressIndeterminate",
")",
";",
"if",
"(",
"!",
"entry",
".",
"progressIndeterminate",
")",
"{",
"bar",
".",
"setMax",
"(",
"entry",
".",
"progressMax",
")",
";",
"bar",
".",
"setProgress",
"(",
"entry",
".",
"progress",
")",
";",
"}",
"}",
"else",
"{",
"bar",
".",
"setVisibility",
"(",
"View",
".",
"GONE",
")",
";",
"}",
"}"
] |
Called when a row view is being updated.
@param board
@param rowView
@param entry
|
[
"Called",
"when",
"a",
"row",
"view",
"is",
"being",
"updated",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoardCallback.java#L162-L197
|
3,967 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoardCallback.java
|
NotificationBoardCallback.onClickRowView
|
public void onClickRowView(NotificationBoard board, RowView rowView, NotificationEntry entry) {
if (DBG) Log.v(TAG, "onClickRowView - " + entry.ID);
}
|
java
|
public void onClickRowView(NotificationBoard board, RowView rowView, NotificationEntry entry) {
if (DBG) Log.v(TAG, "onClickRowView - " + entry.ID);
}
|
[
"public",
"void",
"onClickRowView",
"(",
"NotificationBoard",
"board",
",",
"RowView",
"rowView",
",",
"NotificationEntry",
"entry",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"onClickRowView - \"",
"+",
"entry",
".",
"ID",
")",
";",
"}"
] |
Called when a row view has been clicked.
@param board
@param rowView
@param entry
|
[
"Called",
"when",
"a",
"row",
"view",
"has",
"been",
"clicked",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoardCallback.java#L206-L208
|
3,968 |
lamydev/Android-Notification
|
core/src/zemin/notification/Utils.java
|
Utils.getAlphaForOffset
|
public static float getAlphaForOffset(float alphaStart, float alphaEnd,
float posStart, float posEnd, float posOffset) {
return alphaStart + posOffset * (alphaEnd - alphaStart) / (posEnd - posStart);
}
|
java
|
public static float getAlphaForOffset(float alphaStart, float alphaEnd,
float posStart, float posEnd, float posOffset) {
return alphaStart + posOffset * (alphaEnd - alphaStart) / (posEnd - posStart);
}
|
[
"public",
"static",
"float",
"getAlphaForOffset",
"(",
"float",
"alphaStart",
",",
"float",
"alphaEnd",
",",
"float",
"posStart",
",",
"float",
"posEnd",
",",
"float",
"posOffset",
")",
"{",
"return",
"alphaStart",
"+",
"posOffset",
"*",
"(",
"alphaEnd",
"-",
"alphaStart",
")",
"/",
"(",
"posEnd",
"-",
"posStart",
")",
";",
"}"
] |
Calculate the alpha value for a position offset.
@param alphaStart
@param alphaEnd
@param posStart
@param posEnd
@param posOffset
|
[
"Calculate",
"the",
"alpha",
"value",
"for",
"a",
"position",
"offset",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/Utils.java#L33-L36
|
3,969 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/php/PhpDependencyResolver.java
|
PhpDependencyResolver.createDependencyInfos
|
private Collection<DependencyInfo> createDependencyInfos(Collection<PhpPackage> phpPackages, Collection<DependencyInfo> dependencyInfos, Collection<String> directDependencies) {
HashMap<DependencyInfo, Collection<String>> parentToChildMap = new HashMap<>();
HashMap<String, DependencyInfo> packageDependencyMap = new HashMap<>();
// collect packages data and create its dependencyInfo
for (PhpPackage phpPackage : phpPackages) {
DependencyInfo dependencyInfo = createDependencyInfo(phpPackage);
if (dependencyInfo != null) {
parentToChildMap.put(dependencyInfo, phpPackage.getPackageRequire().keySet());
packageDependencyMap.put(phpPackage.getName(), dependencyInfo);
} else {
logger.debug("Didn't succeed to create dependencyInfo for {}", phpPackage.getName());
}
}
if (!packageDependencyMap.isEmpty()) {
for (String directDependency : directDependencies) {
// create hierarchy tree
DependencyInfo dependencyInfo = packageDependencyMap.get(directDependency);
if (dependencyInfo != null) {
collectChildren(dependencyInfo, packageDependencyMap, parentToChildMap);
dependencyInfos.add(dependencyInfo);
} else {
logger.debug("Didn't found {} in map {}", directDependency, packageDependencyMap.getClass().getName());
}
}
} else {
logger.debug("The map {} is empty ", packageDependencyMap.getClass().getName());
}
return dependencyInfos;
}
|
java
|
private Collection<DependencyInfo> createDependencyInfos(Collection<PhpPackage> phpPackages, Collection<DependencyInfo> dependencyInfos, Collection<String> directDependencies) {
HashMap<DependencyInfo, Collection<String>> parentToChildMap = new HashMap<>();
HashMap<String, DependencyInfo> packageDependencyMap = new HashMap<>();
// collect packages data and create its dependencyInfo
for (PhpPackage phpPackage : phpPackages) {
DependencyInfo dependencyInfo = createDependencyInfo(phpPackage);
if (dependencyInfo != null) {
parentToChildMap.put(dependencyInfo, phpPackage.getPackageRequire().keySet());
packageDependencyMap.put(phpPackage.getName(), dependencyInfo);
} else {
logger.debug("Didn't succeed to create dependencyInfo for {}", phpPackage.getName());
}
}
if (!packageDependencyMap.isEmpty()) {
for (String directDependency : directDependencies) {
// create hierarchy tree
DependencyInfo dependencyInfo = packageDependencyMap.get(directDependency);
if (dependencyInfo != null) {
collectChildren(dependencyInfo, packageDependencyMap, parentToChildMap);
dependencyInfos.add(dependencyInfo);
} else {
logger.debug("Didn't found {} in map {}", directDependency, packageDependencyMap.getClass().getName());
}
}
} else {
logger.debug("The map {} is empty ", packageDependencyMap.getClass().getName());
}
return dependencyInfos;
}
|
[
"private",
"Collection",
"<",
"DependencyInfo",
">",
"createDependencyInfos",
"(",
"Collection",
"<",
"PhpPackage",
">",
"phpPackages",
",",
"Collection",
"<",
"DependencyInfo",
">",
"dependencyInfos",
",",
"Collection",
"<",
"String",
">",
"directDependencies",
")",
"{",
"HashMap",
"<",
"DependencyInfo",
",",
"Collection",
"<",
"String",
">",
">",
"parentToChildMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"HashMap",
"<",
"String",
",",
"DependencyInfo",
">",
"packageDependencyMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"// collect packages data and create its dependencyInfo",
"for",
"(",
"PhpPackage",
"phpPackage",
":",
"phpPackages",
")",
"{",
"DependencyInfo",
"dependencyInfo",
"=",
"createDependencyInfo",
"(",
"phpPackage",
")",
";",
"if",
"(",
"dependencyInfo",
"!=",
"null",
")",
"{",
"parentToChildMap",
".",
"put",
"(",
"dependencyInfo",
",",
"phpPackage",
".",
"getPackageRequire",
"(",
")",
".",
"keySet",
"(",
")",
")",
";",
"packageDependencyMap",
".",
"put",
"(",
"phpPackage",
".",
"getName",
"(",
")",
",",
"dependencyInfo",
")",
";",
"}",
"else",
"{",
"logger",
".",
"debug",
"(",
"\"Didn't succeed to create dependencyInfo for {}\"",
",",
"phpPackage",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"!",
"packageDependencyMap",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"String",
"directDependency",
":",
"directDependencies",
")",
"{",
"// create hierarchy tree",
"DependencyInfo",
"dependencyInfo",
"=",
"packageDependencyMap",
".",
"get",
"(",
"directDependency",
")",
";",
"if",
"(",
"dependencyInfo",
"!=",
"null",
")",
"{",
"collectChildren",
"(",
"dependencyInfo",
",",
"packageDependencyMap",
",",
"parentToChildMap",
")",
";",
"dependencyInfos",
".",
"add",
"(",
"dependencyInfo",
")",
";",
"}",
"else",
"{",
"logger",
".",
"debug",
"(",
"\"Didn't found {} in map {}\"",
",",
"directDependency",
",",
"packageDependencyMap",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"logger",
".",
"debug",
"(",
"\"The map {} is empty \"",
",",
"packageDependencyMap",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"dependencyInfos",
";",
"}"
] |
create dependencyInfo objects from each direct dependency
|
[
"create",
"dependencyInfo",
"objects",
"from",
"each",
"direct",
"dependency"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/php/PhpDependencyResolver.java#L168-L196
|
3,970 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/php/PhpDependencyResolver.java
|
PhpDependencyResolver.createDependencyInfo
|
private DependencyInfo createDependencyInfo(PhpPackage phpPackage) {
String groupId = getGroupIdFromName(phpPackage);
String artifactId = phpPackage.getName();
String version = phpPackage.getVersion();
String commit = phpPackage.getPackageSource().getReference();
if (StringUtils.isNotBlank(version) || StringUtils.isNotBlank(commit)) {
DependencyInfo dependencyInfo = new DependencyInfo(groupId, artifactId, version);
dependencyInfo.setCommit(commit);
dependencyInfo.setDependencyType(getDependencyType());
if (this.addSha1) {
String sha1 = null;
String sha1Source = StringUtils.isNotBlank(version) ? version : commit;
try {
sha1 = this.hashCalculator.calculateSha1ByNameVersionAndType(artifactId, sha1Source, DependencyType.PHP);
} catch (IOException e) {
logger.debug("Failed to calculate sha1 of: {}", artifactId);
}
if (sha1 != null) {
dependencyInfo.setSha1(sha1);
}
}
return dependencyInfo;
} else {
logger.debug("The parameters version and commit of {} are null", phpPackage.getName());
return null;
}
}
|
java
|
private DependencyInfo createDependencyInfo(PhpPackage phpPackage) {
String groupId = getGroupIdFromName(phpPackage);
String artifactId = phpPackage.getName();
String version = phpPackage.getVersion();
String commit = phpPackage.getPackageSource().getReference();
if (StringUtils.isNotBlank(version) || StringUtils.isNotBlank(commit)) {
DependencyInfo dependencyInfo = new DependencyInfo(groupId, artifactId, version);
dependencyInfo.setCommit(commit);
dependencyInfo.setDependencyType(getDependencyType());
if (this.addSha1) {
String sha1 = null;
String sha1Source = StringUtils.isNotBlank(version) ? version : commit;
try {
sha1 = this.hashCalculator.calculateSha1ByNameVersionAndType(artifactId, sha1Source, DependencyType.PHP);
} catch (IOException e) {
logger.debug("Failed to calculate sha1 of: {}", artifactId);
}
if (sha1 != null) {
dependencyInfo.setSha1(sha1);
}
}
return dependencyInfo;
} else {
logger.debug("The parameters version and commit of {} are null", phpPackage.getName());
return null;
}
}
|
[
"private",
"DependencyInfo",
"createDependencyInfo",
"(",
"PhpPackage",
"phpPackage",
")",
"{",
"String",
"groupId",
"=",
"getGroupIdFromName",
"(",
"phpPackage",
")",
";",
"String",
"artifactId",
"=",
"phpPackage",
".",
"getName",
"(",
")",
";",
"String",
"version",
"=",
"phpPackage",
".",
"getVersion",
"(",
")",
";",
"String",
"commit",
"=",
"phpPackage",
".",
"getPackageSource",
"(",
")",
".",
"getReference",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"version",
")",
"||",
"StringUtils",
".",
"isNotBlank",
"(",
"commit",
")",
")",
"{",
"DependencyInfo",
"dependencyInfo",
"=",
"new",
"DependencyInfo",
"(",
"groupId",
",",
"artifactId",
",",
"version",
")",
";",
"dependencyInfo",
".",
"setCommit",
"(",
"commit",
")",
";",
"dependencyInfo",
".",
"setDependencyType",
"(",
"getDependencyType",
"(",
")",
")",
";",
"if",
"(",
"this",
".",
"addSha1",
")",
"{",
"String",
"sha1",
"=",
"null",
";",
"String",
"sha1Source",
"=",
"StringUtils",
".",
"isNotBlank",
"(",
"version",
")",
"?",
"version",
":",
"commit",
";",
"try",
"{",
"sha1",
"=",
"this",
".",
"hashCalculator",
".",
"calculateSha1ByNameVersionAndType",
"(",
"artifactId",
",",
"sha1Source",
",",
"DependencyType",
".",
"PHP",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Failed to calculate sha1 of: {}\"",
",",
"artifactId",
")",
";",
"}",
"if",
"(",
"sha1",
"!=",
"null",
")",
"{",
"dependencyInfo",
".",
"setSha1",
"(",
"sha1",
")",
";",
"}",
"}",
"return",
"dependencyInfo",
";",
"}",
"else",
"{",
"logger",
".",
"debug",
"(",
"\"The parameters version and commit of {} are null\"",
",",
"phpPackage",
".",
"getName",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
convert phpPackage to dependencyInfo object
|
[
"convert",
"phpPackage",
"to",
"dependencyInfo",
"object"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/php/PhpDependencyResolver.java#L199-L225
|
3,971 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/php/PhpDependencyResolver.java
|
PhpDependencyResolver.collectChildren
|
private void collectChildren(DependencyInfo dependencyInfo, HashMap<String, DependencyInfo> packageDependencyMap,
HashMap<DependencyInfo, Collection<String>> requireDependenciesMap) {
Collection<String> requires = requireDependenciesMap.get(dependencyInfo);
// check if dependencyInfo object already have children's
if (dependencyInfo.getChildren().isEmpty()) {
for (String require : requires) {
DependencyInfo dependencyChild = packageDependencyMap.get(require);
if (dependencyChild != null) {
dependencyInfo.getChildren().add(dependencyChild);
collectChildren(dependencyChild, packageDependencyMap, requireDependenciesMap);
}
}
}
}
|
java
|
private void collectChildren(DependencyInfo dependencyInfo, HashMap<String, DependencyInfo> packageDependencyMap,
HashMap<DependencyInfo, Collection<String>> requireDependenciesMap) {
Collection<String> requires = requireDependenciesMap.get(dependencyInfo);
// check if dependencyInfo object already have children's
if (dependencyInfo.getChildren().isEmpty()) {
for (String require : requires) {
DependencyInfo dependencyChild = packageDependencyMap.get(require);
if (dependencyChild != null) {
dependencyInfo.getChildren().add(dependencyChild);
collectChildren(dependencyChild, packageDependencyMap, requireDependenciesMap);
}
}
}
}
|
[
"private",
"void",
"collectChildren",
"(",
"DependencyInfo",
"dependencyInfo",
",",
"HashMap",
"<",
"String",
",",
"DependencyInfo",
">",
"packageDependencyMap",
",",
"HashMap",
"<",
"DependencyInfo",
",",
"Collection",
"<",
"String",
">",
">",
"requireDependenciesMap",
")",
"{",
"Collection",
"<",
"String",
">",
"requires",
"=",
"requireDependenciesMap",
".",
"get",
"(",
"dependencyInfo",
")",
";",
"// check if dependencyInfo object already have children's",
"if",
"(",
"dependencyInfo",
".",
"getChildren",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"String",
"require",
":",
"requires",
")",
"{",
"DependencyInfo",
"dependencyChild",
"=",
"packageDependencyMap",
".",
"get",
"(",
"require",
")",
";",
"if",
"(",
"dependencyChild",
"!=",
"null",
")",
"{",
"dependencyInfo",
".",
"getChildren",
"(",
")",
".",
"add",
"(",
"dependencyChild",
")",
";",
"collectChildren",
"(",
"dependencyChild",
",",
"packageDependencyMap",
",",
"requireDependenciesMap",
")",
";",
"}",
"}",
"}",
"}"
] |
collect children's recursively for each dependencyInfo object
|
[
"collect",
"children",
"s",
"recursively",
"for",
"each",
"dependencyInfo",
"object"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/php/PhpDependencyResolver.java#L228-L241
|
3,972 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/php/PhpDependencyResolver.java
|
PhpDependencyResolver.getGroupIdFromName
|
private String getGroupIdFromName(PhpPackage phpPackage) {
String groupId = null;
if (StringUtils.isNotBlank(phpPackage.getName())) {
String packageName = phpPackage.getName();
String[] gavCoordinates = packageName.split(FORWARD_SLASH);
groupId = gavCoordinates[0];
}
return groupId;
}
|
java
|
private String getGroupIdFromName(PhpPackage phpPackage) {
String groupId = null;
if (StringUtils.isNotBlank(phpPackage.getName())) {
String packageName = phpPackage.getName();
String[] gavCoordinates = packageName.split(FORWARD_SLASH);
groupId = gavCoordinates[0];
}
return groupId;
}
|
[
"private",
"String",
"getGroupIdFromName",
"(",
"PhpPackage",
"phpPackage",
")",
"{",
"String",
"groupId",
"=",
"null",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"phpPackage",
".",
"getName",
"(",
")",
")",
")",
"{",
"String",
"packageName",
"=",
"phpPackage",
".",
"getName",
"(",
")",
";",
"String",
"[",
"]",
"gavCoordinates",
"=",
"packageName",
".",
"split",
"(",
"FORWARD_SLASH",
")",
";",
"groupId",
"=",
"gavCoordinates",
"[",
"0",
"]",
";",
"}",
"return",
"groupId",
";",
"}"
] |
get the groupId from the name of package
|
[
"get",
"the",
"groupId",
"from",
"the",
"name",
"of",
"package"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/php/PhpDependencyResolver.java#L244-L252
|
3,973 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/php/PhpDependencyResolver.java
|
PhpDependencyResolver.getArtifactIdFromName
|
private String getArtifactIdFromName(PhpPackage phpPackage) {
String artifactId = null;
if (StringUtils.isNotBlank(phpPackage.getName())) {
String packageName = phpPackage.getName();
String[] gavCoordinates = packageName.split(FORWARD_SLASH);
artifactId = gavCoordinates[1];
}
return artifactId;
}
|
java
|
private String getArtifactIdFromName(PhpPackage phpPackage) {
String artifactId = null;
if (StringUtils.isNotBlank(phpPackage.getName())) {
String packageName = phpPackage.getName();
String[] gavCoordinates = packageName.split(FORWARD_SLASH);
artifactId = gavCoordinates[1];
}
return artifactId;
}
|
[
"private",
"String",
"getArtifactIdFromName",
"(",
"PhpPackage",
"phpPackage",
")",
"{",
"String",
"artifactId",
"=",
"null",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"phpPackage",
".",
"getName",
"(",
")",
")",
")",
"{",
"String",
"packageName",
"=",
"phpPackage",
".",
"getName",
"(",
")",
";",
"String",
"[",
"]",
"gavCoordinates",
"=",
"packageName",
".",
"split",
"(",
"FORWARD_SLASH",
")",
";",
"artifactId",
"=",
"gavCoordinates",
"[",
"1",
"]",
";",
"}",
"return",
"artifactId",
";",
"}"
] |
get the artifactId from the name of package
|
[
"get",
"the",
"artifactId",
"from",
"the",
"name",
"of",
"package"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/php/PhpDependencyResolver.java#L255-L263
|
3,974 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/docker/remotedocker/azure/AzureRemoteDocker.java
|
AzureRemoteDocker.loginToRemoteRegistry
|
@Override
protected boolean loginToRemoteRegistry() {
Pair<Integer, InputStream> result;
try {
// Check if user already logged in to azure
isUserLoggedIn();
// If user isn't logged in, then login to azure via az cli.
if(!loggedInToAzure) {
Process process = Runtime.getRuntime().exec(azureCli.getLoginCommand(config.getAzureUserName(), config.getAzureUserPassword()));
int resultValue = process.waitFor();
if (resultValue == 0) {
logger.info("Log in to Azure account {} - Succeeded", config.getAzureUserName());
} else {
logger.info("Log in to Azure account {} - Failed", config.getAzureUserName());
String errorMessage = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8.name());
logger.error("Failed to log in to Azure account {} - {}", config.getAzureUserName(), errorMessage);
return false;
}
}
// Log in to registry via azure cli, Run azure command: "az acr login -n <RegistryName>"
// Once azure login command to registry succeeded - docker obtains authentication to pull images from registry.
for (String registryName : config.getAzureRegistryNames()) {
if (registryName != null && !registryName.trim().equals(Constants.EMPTY_STRING)) {
logger.info("Log in to Azure container registry {}", registryName);
result = executeCommand(azureCli.getLoginContainerRegistryCommand(registryName));
if (result.getKey() == 0) {
logger.info("Login to registry : {} - Succeeded", registryName);
loggedInRegistries.add(registryName);
} else {
logger.info("Login to registry {} - Failed", registryName);
logger.error("Failed to login registry {} - {}", registryName, IOUtils.toString(result.getValue(), StandardCharsets.UTF_8.name()));
}
}
}
return true;
} catch (InterruptedException interruptedException) {
logger.debug("Failed to login to Azure account, Exception: {}", interruptedException.getMessage());
} catch (IOException ioException) { // this exception occurred when parsing inputStream to String
logger.debug("Failed to parse command error result, Exception: {}", ioException.getMessage());
}
return false;
}
|
java
|
@Override
protected boolean loginToRemoteRegistry() {
Pair<Integer, InputStream> result;
try {
// Check if user already logged in to azure
isUserLoggedIn();
// If user isn't logged in, then login to azure via az cli.
if(!loggedInToAzure) {
Process process = Runtime.getRuntime().exec(azureCli.getLoginCommand(config.getAzureUserName(), config.getAzureUserPassword()));
int resultValue = process.waitFor();
if (resultValue == 0) {
logger.info("Log in to Azure account {} - Succeeded", config.getAzureUserName());
} else {
logger.info("Log in to Azure account {} - Failed", config.getAzureUserName());
String errorMessage = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8.name());
logger.error("Failed to log in to Azure account {} - {}", config.getAzureUserName(), errorMessage);
return false;
}
}
// Log in to registry via azure cli, Run azure command: "az acr login -n <RegistryName>"
// Once azure login command to registry succeeded - docker obtains authentication to pull images from registry.
for (String registryName : config.getAzureRegistryNames()) {
if (registryName != null && !registryName.trim().equals(Constants.EMPTY_STRING)) {
logger.info("Log in to Azure container registry {}", registryName);
result = executeCommand(azureCli.getLoginContainerRegistryCommand(registryName));
if (result.getKey() == 0) {
logger.info("Login to registry : {} - Succeeded", registryName);
loggedInRegistries.add(registryName);
} else {
logger.info("Login to registry {} - Failed", registryName);
logger.error("Failed to login registry {} - {}", registryName, IOUtils.toString(result.getValue(), StandardCharsets.UTF_8.name()));
}
}
}
return true;
} catch (InterruptedException interruptedException) {
logger.debug("Failed to login to Azure account, Exception: {}", interruptedException.getMessage());
} catch (IOException ioException) { // this exception occurred when parsing inputStream to String
logger.debug("Failed to parse command error result, Exception: {}", ioException.getMessage());
}
return false;
}
|
[
"@",
"Override",
"protected",
"boolean",
"loginToRemoteRegistry",
"(",
")",
"{",
"Pair",
"<",
"Integer",
",",
"InputStream",
">",
"result",
";",
"try",
"{",
"// Check if user already logged in to azure",
"isUserLoggedIn",
"(",
")",
";",
"// If user isn't logged in, then login to azure via az cli.",
"if",
"(",
"!",
"loggedInToAzure",
")",
"{",
"Process",
"process",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"exec",
"(",
"azureCli",
".",
"getLoginCommand",
"(",
"config",
".",
"getAzureUserName",
"(",
")",
",",
"config",
".",
"getAzureUserPassword",
"(",
")",
")",
")",
";",
"int",
"resultValue",
"=",
"process",
".",
"waitFor",
"(",
")",
";",
"if",
"(",
"resultValue",
"==",
"0",
")",
"{",
"logger",
".",
"info",
"(",
"\"Log in to Azure account {} - Succeeded\"",
",",
"config",
".",
"getAzureUserName",
"(",
")",
")",
";",
"}",
"else",
"{",
"logger",
".",
"info",
"(",
"\"Log in to Azure account {} - Failed\"",
",",
"config",
".",
"getAzureUserName",
"(",
")",
")",
";",
"String",
"errorMessage",
"=",
"IOUtils",
".",
"toString",
"(",
"process",
".",
"getInputStream",
"(",
")",
",",
"StandardCharsets",
".",
"UTF_8",
".",
"name",
"(",
")",
")",
";",
"logger",
".",
"error",
"(",
"\"Failed to log in to Azure account {} - {}\"",
",",
"config",
".",
"getAzureUserName",
"(",
")",
",",
"errorMessage",
")",
";",
"return",
"false",
";",
"}",
"}",
"// Log in to registry via azure cli, Run azure command: \"az acr login -n <RegistryName>\"",
"// Once azure login command to registry succeeded - docker obtains authentication to pull images from registry.",
"for",
"(",
"String",
"registryName",
":",
"config",
".",
"getAzureRegistryNames",
"(",
")",
")",
"{",
"if",
"(",
"registryName",
"!=",
"null",
"&&",
"!",
"registryName",
".",
"trim",
"(",
")",
".",
"equals",
"(",
"Constants",
".",
"EMPTY_STRING",
")",
")",
"{",
"logger",
".",
"info",
"(",
"\"Log in to Azure container registry {}\"",
",",
"registryName",
")",
";",
"result",
"=",
"executeCommand",
"(",
"azureCli",
".",
"getLoginContainerRegistryCommand",
"(",
"registryName",
")",
")",
";",
"if",
"(",
"result",
".",
"getKey",
"(",
")",
"==",
"0",
")",
"{",
"logger",
".",
"info",
"(",
"\"Login to registry : {} - Succeeded\"",
",",
"registryName",
")",
";",
"loggedInRegistries",
".",
"add",
"(",
"registryName",
")",
";",
"}",
"else",
"{",
"logger",
".",
"info",
"(",
"\"Login to registry {} - Failed\"",
",",
"registryName",
")",
";",
"logger",
".",
"error",
"(",
"\"Failed to login registry {} - {}\"",
",",
"registryName",
",",
"IOUtils",
".",
"toString",
"(",
"result",
".",
"getValue",
"(",
")",
",",
"StandardCharsets",
".",
"UTF_8",
".",
"name",
"(",
")",
")",
")",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}",
"catch",
"(",
"InterruptedException",
"interruptedException",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Failed to login to Azure account, Exception: {}\"",
",",
"interruptedException",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioException",
")",
"{",
"// this exception occurred when parsing inputStream to String",
"logger",
".",
"debug",
"(",
"\"Failed to parse command error result, Exception: {}\"",
",",
"ioException",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Log in to container registry in Azure cloud.
If login succeeded, docker obtains authentication to pull images from this registry.
@return
|
[
"Log",
"in",
"to",
"container",
"registry",
"in",
"Azure",
"cloud",
".",
"If",
"login",
"succeeded",
"docker",
"obtains",
"authentication",
"to",
"pull",
"images",
"from",
"this",
"registry",
"."
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/docker/remotedocker/azure/AzureRemoteDocker.java#L54-L100
|
3,975 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationEntry.java
|
NotificationEntry.setWhen
|
public void setWhen(CharSequence format, long when) {
if (format == null) format = DEFAULT_DATE_FORMAT;
this.whenFormatted = DateFormat.format(format, when);
}
|
java
|
public void setWhen(CharSequence format, long when) {
if (format == null) format = DEFAULT_DATE_FORMAT;
this.whenFormatted = DateFormat.format(format, when);
}
|
[
"public",
"void",
"setWhen",
"(",
"CharSequence",
"format",
",",
"long",
"when",
")",
"{",
"if",
"(",
"format",
"==",
"null",
")",
"format",
"=",
"DEFAULT_DATE_FORMAT",
";",
"this",
".",
"whenFormatted",
"=",
"DateFormat",
".",
"format",
"(",
"format",
",",
"when",
")",
";",
"}"
] |
Set a timestamp pertaining to this notification.
Only used for:
@see NotificationLocal
@see NotificationGlobal
@param format
@param when
|
[
"Set",
"a",
"timestamp",
"pertaining",
"to",
"this",
"notification",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationEntry.java#L309-L312
|
3,976 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationEntry.java
|
NotificationEntry.setProgress
|
public void setProgress(int max, int progress, boolean indeterminate) {
this.progressMax = max;
this.progress = progress;
this.progressIndeterminate = indeterminate;
}
|
java
|
public void setProgress(int max, int progress, boolean indeterminate) {
this.progressMax = max;
this.progress = progress;
this.progressIndeterminate = indeterminate;
}
|
[
"public",
"void",
"setProgress",
"(",
"int",
"max",
",",
"int",
"progress",
",",
"boolean",
"indeterminate",
")",
"{",
"this",
".",
"progressMax",
"=",
"max",
";",
"this",
".",
"progress",
"=",
"progress",
";",
"this",
".",
"progressIndeterminate",
"=",
"indeterminate",
";",
"}"
] |
Set the progress this notification represents.
@see android.app.Notification#setProgress(int, int, boolean)
@param max
@param progress
@param indeterminate
|
[
"Set",
"the",
"progress",
"this",
"notification",
"represents",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationEntry.java#L387-L391
|
3,977 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationEntry.java
|
NotificationEntry.setRingtone
|
public void setRingtone(Context context, int resId) {
if (resId > 0) {
this.ringtoneUri = Uri.parse("android.resource://" +
context.getPackageName() + "/" + resId);
}
}
|
java
|
public void setRingtone(Context context, int resId) {
if (resId > 0) {
this.ringtoneUri = Uri.parse("android.resource://" +
context.getPackageName() + "/" + resId);
}
}
|
[
"public",
"void",
"setRingtone",
"(",
"Context",
"context",
",",
"int",
"resId",
")",
"{",
"if",
"(",
"resId",
">",
"0",
")",
"{",
"this",
".",
"ringtoneUri",
"=",
"Uri",
".",
"parse",
"(",
"\"android.resource://\"",
"+",
"context",
".",
"getPackageName",
"(",
")",
"+",
"\"/\"",
"+",
"resId",
")",
";",
"}",
"}"
] |
Set ringtone resource.
@param context
@param resId
|
[
"Set",
"ringtone",
"resource",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationEntry.java#L618-L623
|
3,978 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationEntry.java
|
NotificationEntry.setRingtone
|
public void setRingtone(String filepath) {
if (filepath != null) {
File file = new File(filepath);
if (file.exists()) {
this.ringtoneUri = Uri.fromFile(file);
} else {
Log.e(TAG, "ringtone file not found.");
}
}
}
|
java
|
public void setRingtone(String filepath) {
if (filepath != null) {
File file = new File(filepath);
if (file.exists()) {
this.ringtoneUri = Uri.fromFile(file);
} else {
Log.e(TAG, "ringtone file not found.");
}
}
}
|
[
"public",
"void",
"setRingtone",
"(",
"String",
"filepath",
")",
"{",
"if",
"(",
"filepath",
"!=",
"null",
")",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"filepath",
")",
";",
"if",
"(",
"file",
".",
"exists",
"(",
")",
")",
"{",
"this",
".",
"ringtoneUri",
"=",
"Uri",
".",
"fromFile",
"(",
"file",
")",
";",
"}",
"else",
"{",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"ringtone file not found.\"",
")",
";",
"}",
"}",
"}"
] |
Set ringtone file path.
@param filepath
|
[
"Set",
"ringtone",
"file",
"path",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationEntry.java#L641-L650
|
3,979 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationRemote.java
|
NotificationRemote.getDeleteIntent
|
public PendingIntent getDeleteIntent(NotificationEntry entry) {
Intent intent = new Intent(ACTION_CANCEL);
intent.putExtra(KEY_ENTRY_ID, entry.ID);
return PendingIntent.getBroadcast(mContext, genIdForPendingIntent(), intent, 0);
}
|
java
|
public PendingIntent getDeleteIntent(NotificationEntry entry) {
Intent intent = new Intent(ACTION_CANCEL);
intent.putExtra(KEY_ENTRY_ID, entry.ID);
return PendingIntent.getBroadcast(mContext, genIdForPendingIntent(), intent, 0);
}
|
[
"public",
"PendingIntent",
"getDeleteIntent",
"(",
"NotificationEntry",
"entry",
")",
"{",
"Intent",
"intent",
"=",
"new",
"Intent",
"(",
"ACTION_CANCEL",
")",
";",
"intent",
".",
"putExtra",
"(",
"KEY_ENTRY_ID",
",",
"entry",
".",
"ID",
")",
";",
"return",
"PendingIntent",
".",
"getBroadcast",
"(",
"mContext",
",",
"genIdForPendingIntent",
"(",
")",
",",
"intent",
",",
"0",
")",
";",
"}"
] |
Create an PendingIntent to execute when the notification is explicitly dismissed by the user.
@see android.app.Notification#setDeleteIntent(PendingIntent)
@param entry
@return PendingIntent
|
[
"Create",
"an",
"PendingIntent",
"to",
"execute",
"when",
"the",
"notification",
"is",
"explicitly",
"dismissed",
"by",
"the",
"user",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationRemote.java#L129-L133
|
3,980 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationRemote.java
|
NotificationRemote.getContentIntent
|
public PendingIntent getContentIntent(NotificationEntry entry) {
Intent intent = new Intent(ACTION_CONTENT);
intent.putExtra(KEY_ENTRY_ID, entry.ID);
return PendingIntent.getBroadcast(mContext, genIdForPendingIntent(), intent, 0);
}
|
java
|
public PendingIntent getContentIntent(NotificationEntry entry) {
Intent intent = new Intent(ACTION_CONTENT);
intent.putExtra(KEY_ENTRY_ID, entry.ID);
return PendingIntent.getBroadcast(mContext, genIdForPendingIntent(), intent, 0);
}
|
[
"public",
"PendingIntent",
"getContentIntent",
"(",
"NotificationEntry",
"entry",
")",
"{",
"Intent",
"intent",
"=",
"new",
"Intent",
"(",
"ACTION_CONTENT",
")",
";",
"intent",
".",
"putExtra",
"(",
"KEY_ENTRY_ID",
",",
"entry",
".",
"ID",
")",
";",
"return",
"PendingIntent",
".",
"getBroadcast",
"(",
"mContext",
",",
"genIdForPendingIntent",
"(",
")",
",",
"intent",
",",
"0",
")",
";",
"}"
] |
Create an PendingIntent to execute when the notification is clicked by the user.
@see android.app.Notification#setContentIntent(PendingIntent)
@param entry
@return PedningIntent
|
[
"Create",
"an",
"PendingIntent",
"to",
"execute",
"when",
"the",
"notification",
"is",
"clicked",
"by",
"the",
"user",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationRemote.java#L143-L147
|
3,981 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationRemote.java
|
NotificationRemote.getActionIntent
|
public PendingIntent getActionIntent(NotificationEntry entry, NotificationEntry.Action act) {
Intent intent = new Intent(ACTION_ACTION);
intent.putExtra(KEY_ENTRY_ID, entry.ID);
intent.putExtra(KEY_ACTION_ID, entry.mActions.indexOf(act));
return PendingIntent.getBroadcast(mContext, genIdForPendingIntent(), intent, 0);
}
|
java
|
public PendingIntent getActionIntent(NotificationEntry entry, NotificationEntry.Action act) {
Intent intent = new Intent(ACTION_ACTION);
intent.putExtra(KEY_ENTRY_ID, entry.ID);
intent.putExtra(KEY_ACTION_ID, entry.mActions.indexOf(act));
return PendingIntent.getBroadcast(mContext, genIdForPendingIntent(), intent, 0);
}
|
[
"public",
"PendingIntent",
"getActionIntent",
"(",
"NotificationEntry",
"entry",
",",
"NotificationEntry",
".",
"Action",
"act",
")",
"{",
"Intent",
"intent",
"=",
"new",
"Intent",
"(",
"ACTION_ACTION",
")",
";",
"intent",
".",
"putExtra",
"(",
"KEY_ENTRY_ID",
",",
"entry",
".",
"ID",
")",
";",
"intent",
".",
"putExtra",
"(",
"KEY_ACTION_ID",
",",
"entry",
".",
"mActions",
".",
"indexOf",
"(",
"act",
")",
")",
";",
"return",
"PendingIntent",
".",
"getBroadcast",
"(",
"mContext",
",",
"genIdForPendingIntent",
"(",
")",
",",
"intent",
",",
"0",
")",
";",
"}"
] |
Create an PendingIntent to be fired when the notification action is invoked.
@see android.app.Notification#addAction(int, CharSequence, PendingIntent)
@param entry
@param act
@return PendingIntent
|
[
"Create",
"an",
"PendingIntent",
"to",
"be",
"fired",
"when",
"the",
"notification",
"action",
"is",
"invoked",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationRemote.java#L158-L163
|
3,982 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/go/GoDependencyResolver.java
|
GoDependencyResolver.collectDependenciesWithoutDefinedManager
|
private String collectDependenciesWithoutDefinedManager(String rootDirectory, List<DependencyInfo> dependencyInfos){
String error = null;
try {
collectDepDependencies(rootDirectory, dependencyInfos);
goDependencyManager = GoDependencyManager.DEP;
} catch (Exception e){
try {
collectGoDepDependencies(rootDirectory, dependencyInfos);
goDependencyManager = GoDependencyManager.GO_DEP;
} catch (Exception e1){
try {
collectVndrDependencies(rootDirectory, dependencyInfos);
goDependencyManager = GoDependencyManager.VNDR;
} catch (Exception e2) {
try {
collectGoGradleDependencies(rootDirectory, dependencyInfos);
goDependencyManager = GoDependencyManager.GO_GRADLE;
} catch (Exception e3) {
try {
collectGlideDependencies(rootDirectory, dependencyInfos);
goDependencyManager = GoDependencyManager.GLIDE;
} catch (Exception e4) {
try {
collectGoVendorDependencies(rootDirectory, dependencyInfos);
goDependencyManager = GoDependencyManager.GO_VENDOR;
} catch (Exception e5) {
try {
collectGoPMDependencies(rootDirectory, dependencyInfos);
goDependencyManager = GoDependencyManager.GOPM;
} catch (Exception e6) {
error = "Couldn't collect dependencies - no dependency manager is installed";
}
}
}
}
}
}
}
return error;
}
|
java
|
private String collectDependenciesWithoutDefinedManager(String rootDirectory, List<DependencyInfo> dependencyInfos){
String error = null;
try {
collectDepDependencies(rootDirectory, dependencyInfos);
goDependencyManager = GoDependencyManager.DEP;
} catch (Exception e){
try {
collectGoDepDependencies(rootDirectory, dependencyInfos);
goDependencyManager = GoDependencyManager.GO_DEP;
} catch (Exception e1){
try {
collectVndrDependencies(rootDirectory, dependencyInfos);
goDependencyManager = GoDependencyManager.VNDR;
} catch (Exception e2) {
try {
collectGoGradleDependencies(rootDirectory, dependencyInfos);
goDependencyManager = GoDependencyManager.GO_GRADLE;
} catch (Exception e3) {
try {
collectGlideDependencies(rootDirectory, dependencyInfos);
goDependencyManager = GoDependencyManager.GLIDE;
} catch (Exception e4) {
try {
collectGoVendorDependencies(rootDirectory, dependencyInfos);
goDependencyManager = GoDependencyManager.GO_VENDOR;
} catch (Exception e5) {
try {
collectGoPMDependencies(rootDirectory, dependencyInfos);
goDependencyManager = GoDependencyManager.GOPM;
} catch (Exception e6) {
error = "Couldn't collect dependencies - no dependency manager is installed";
}
}
}
}
}
}
}
return error;
}
|
[
"private",
"String",
"collectDependenciesWithoutDefinedManager",
"(",
"String",
"rootDirectory",
",",
"List",
"<",
"DependencyInfo",
">",
"dependencyInfos",
")",
"{",
"String",
"error",
"=",
"null",
";",
"try",
"{",
"collectDepDependencies",
"(",
"rootDirectory",
",",
"dependencyInfos",
")",
";",
"goDependencyManager",
"=",
"GoDependencyManager",
".",
"DEP",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"try",
"{",
"collectGoDepDependencies",
"(",
"rootDirectory",
",",
"dependencyInfos",
")",
";",
"goDependencyManager",
"=",
"GoDependencyManager",
".",
"GO_DEP",
";",
"}",
"catch",
"(",
"Exception",
"e1",
")",
"{",
"try",
"{",
"collectVndrDependencies",
"(",
"rootDirectory",
",",
"dependencyInfos",
")",
";",
"goDependencyManager",
"=",
"GoDependencyManager",
".",
"VNDR",
";",
"}",
"catch",
"(",
"Exception",
"e2",
")",
"{",
"try",
"{",
"collectGoGradleDependencies",
"(",
"rootDirectory",
",",
"dependencyInfos",
")",
";",
"goDependencyManager",
"=",
"GoDependencyManager",
".",
"GO_GRADLE",
";",
"}",
"catch",
"(",
"Exception",
"e3",
")",
"{",
"try",
"{",
"collectGlideDependencies",
"(",
"rootDirectory",
",",
"dependencyInfos",
")",
";",
"goDependencyManager",
"=",
"GoDependencyManager",
".",
"GLIDE",
";",
"}",
"catch",
"(",
"Exception",
"e4",
")",
"{",
"try",
"{",
"collectGoVendorDependencies",
"(",
"rootDirectory",
",",
"dependencyInfos",
")",
";",
"goDependencyManager",
"=",
"GoDependencyManager",
".",
"GO_VENDOR",
";",
"}",
"catch",
"(",
"Exception",
"e5",
")",
"{",
"try",
"{",
"collectGoPMDependencies",
"(",
"rootDirectory",
",",
"dependencyInfos",
")",
";",
"goDependencyManager",
"=",
"GoDependencyManager",
".",
"GOPM",
";",
"}",
"catch",
"(",
"Exception",
"e6",
")",
"{",
"error",
"=",
"\"Couldn't collect dependencies - no dependency manager is installed\"",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"}",
"return",
"error",
";",
"}"
] |
when no dependency manager is defined - trying to run one manager after the other, till one succeeds. if not - returning an error
|
[
"when",
"no",
"dependency",
"manager",
"is",
"defined",
"-",
"trying",
"to",
"run",
"one",
"manager",
"after",
"the",
"other",
"till",
"one",
"succeeds",
".",
"if",
"not",
"-",
"returning",
"an",
"error"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/go/GoDependencyResolver.java#L241-L280
|
3,983 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/utils/CommandLineProcess.java
|
CommandLineProcess.printErrors
|
private void printErrors(){
if (errorLog.isFile()){
FileReader fileReader;
try {
fileReader = new FileReader(errorLog);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String currLine;
while ((currLine = bufferedReader.readLine()) != null){
logger.debug(currLine);
}
fileReader.close();
} catch (Exception e) {
logger.warn("Error printing cmd command errors {} " , e.getMessage());
logger.debug("Error: {}", e.getStackTrace());
} finally {
try {
FileUtils.forceDelete(errorLog);
} catch (IOException e) {
logger.warn("Error closing cmd command errors file {} " , e.getMessage());
logger.debug("Error: {}", e.getStackTrace());
}
}
}
}
|
java
|
private void printErrors(){
if (errorLog.isFile()){
FileReader fileReader;
try {
fileReader = new FileReader(errorLog);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String currLine;
while ((currLine = bufferedReader.readLine()) != null){
logger.debug(currLine);
}
fileReader.close();
} catch (Exception e) {
logger.warn("Error printing cmd command errors {} " , e.getMessage());
logger.debug("Error: {}", e.getStackTrace());
} finally {
try {
FileUtils.forceDelete(errorLog);
} catch (IOException e) {
logger.warn("Error closing cmd command errors file {} " , e.getMessage());
logger.debug("Error: {}", e.getStackTrace());
}
}
}
}
|
[
"private",
"void",
"printErrors",
"(",
")",
"{",
"if",
"(",
"errorLog",
".",
"isFile",
"(",
")",
")",
"{",
"FileReader",
"fileReader",
";",
"try",
"{",
"fileReader",
"=",
"new",
"FileReader",
"(",
"errorLog",
")",
";",
"BufferedReader",
"bufferedReader",
"=",
"new",
"BufferedReader",
"(",
"fileReader",
")",
";",
"String",
"currLine",
";",
"while",
"(",
"(",
"currLine",
"=",
"bufferedReader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"logger",
".",
"debug",
"(",
"currLine",
")",
";",
"}",
"fileReader",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Error printing cmd command errors {} \"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Error: {}\"",
",",
"e",
".",
"getStackTrace",
"(",
")",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"FileUtils",
".",
"forceDelete",
"(",
"errorLog",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Error closing cmd command errors file {} \"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Error: {}\"",
",",
"e",
".",
"getStackTrace",
"(",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
if you find a better way - go ahead and replace it
|
[
"if",
"you",
"find",
"a",
"better",
"way",
"-",
"go",
"ahead",
"and",
"replace",
"it"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/utils/CommandLineProcess.java#L106-L129
|
3,984 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/utils/CommandLineProcess.java
|
CommandLineProcess.getShortPath
|
private String getShortPath(String rootPath) {
File file = new File(rootPath);
String lastPathAfterSeparator = null;
String shortPath = getWindowsShortPath(file.getAbsolutePath());
if (StringUtils.isNotEmpty(shortPath)) {
return getWindowsShortPath(file.getAbsolutePath());
} else {
while (StringUtils.isEmpty(getWindowsShortPath(file.getAbsolutePath()))) {
String filePath = file.getAbsolutePath();
if (StringUtils.isNotEmpty(lastPathAfterSeparator)) {
lastPathAfterSeparator = file.getAbsolutePath().substring(filePath.lastIndexOf(WINDOWS_SEPARATOR), filePath.length()) + lastPathAfterSeparator;
} else {
lastPathAfterSeparator = file.getAbsolutePath().substring(filePath.lastIndexOf(WINDOWS_SEPARATOR), filePath.length());
}
file = file.getParentFile();
}
return getWindowsShortPath(file.getAbsolutePath()) + lastPathAfterSeparator;
}
}
|
java
|
private String getShortPath(String rootPath) {
File file = new File(rootPath);
String lastPathAfterSeparator = null;
String shortPath = getWindowsShortPath(file.getAbsolutePath());
if (StringUtils.isNotEmpty(shortPath)) {
return getWindowsShortPath(file.getAbsolutePath());
} else {
while (StringUtils.isEmpty(getWindowsShortPath(file.getAbsolutePath()))) {
String filePath = file.getAbsolutePath();
if (StringUtils.isNotEmpty(lastPathAfterSeparator)) {
lastPathAfterSeparator = file.getAbsolutePath().substring(filePath.lastIndexOf(WINDOWS_SEPARATOR), filePath.length()) + lastPathAfterSeparator;
} else {
lastPathAfterSeparator = file.getAbsolutePath().substring(filePath.lastIndexOf(WINDOWS_SEPARATOR), filePath.length());
}
file = file.getParentFile();
}
return getWindowsShortPath(file.getAbsolutePath()) + lastPathAfterSeparator;
}
}
|
[
"private",
"String",
"getShortPath",
"(",
"String",
"rootPath",
")",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"rootPath",
")",
";",
"String",
"lastPathAfterSeparator",
"=",
"null",
";",
"String",
"shortPath",
"=",
"getWindowsShortPath",
"(",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"shortPath",
")",
")",
"{",
"return",
"getWindowsShortPath",
"(",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"else",
"{",
"while",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"getWindowsShortPath",
"(",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
")",
")",
"{",
"String",
"filePath",
"=",
"file",
".",
"getAbsolutePath",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"lastPathAfterSeparator",
")",
")",
"{",
"lastPathAfterSeparator",
"=",
"file",
".",
"getAbsolutePath",
"(",
")",
".",
"substring",
"(",
"filePath",
".",
"lastIndexOf",
"(",
"WINDOWS_SEPARATOR",
")",
",",
"filePath",
".",
"length",
"(",
")",
")",
"+",
"lastPathAfterSeparator",
";",
"}",
"else",
"{",
"lastPathAfterSeparator",
"=",
"file",
".",
"getAbsolutePath",
"(",
")",
".",
"substring",
"(",
"filePath",
".",
"lastIndexOf",
"(",
"WINDOWS_SEPARATOR",
")",
",",
"filePath",
".",
"length",
"(",
")",
")",
";",
"}",
"file",
"=",
"file",
".",
"getParentFile",
"(",
")",
";",
"}",
"return",
"getWindowsShortPath",
"(",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
"+",
"lastPathAfterSeparator",
";",
"}",
"}"
] |
get windows short path
|
[
"get",
"windows",
"short",
"path"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/utils/CommandLineProcess.java#L132-L150
|
3,985 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/npm/NpmDependencyResolver.java
|
NpmDependencyResolver.collectPackageJsonDependencies
|
private Collection<DependencyInfo> collectPackageJsonDependencies(Collection<BomFile> packageJsons) {
Collection<DependencyInfo> dependencies = new LinkedList<>();
ConcurrentHashMap<DependencyInfo, BomFile> dependencyPackageJsonMap = new ConcurrentHashMap<>();
ExecutorService executorService = Executors.newWorkStealingPool(NUM_THREADS);
Collection<EnrichDependency> threadsCollection = new LinkedList<>();
for (BomFile packageJson : packageJsons) {
if (packageJson != null && packageJson.isValid()) {
// do not add new dependencies if 'npm ls' already returned all
DependencyInfo dependency = new DependencyInfo();
dependencies.add(dependency);
threadsCollection.add(new EnrichDependency(packageJson, dependency, dependencyPackageJsonMap, npmAccessToken));
logger.debug("Collect package.json of the dependency in the file: {}", dependency.getFilename());
}
}
runThreadCollection(executorService, threadsCollection);
logger.debug("set hierarchy of the dependencies");
// remove duplicates dependencies
Map<String, DependencyInfo> existDependencies = new HashMap<>();
Map<DependencyInfo, BomFile> dependencyPackageJsonMapWithoutDuplicates = new HashMap<>();
for (Map.Entry<DependencyInfo, BomFile> entry : dependencyPackageJsonMap.entrySet()) {
DependencyInfo keyDep = entry.getKey();
String key = keyDep.getSha1() + keyDep.getVersion() + keyDep.getArtifactId();
if (!existDependencies.containsKey(key)) {
existDependencies.put(key, keyDep);
dependencyPackageJsonMapWithoutDuplicates.put(keyDep, entry.getValue());
}
}
setHierarchy(dependencyPackageJsonMapWithoutDuplicates, existDependencies);
return existDependencies.values();
}
|
java
|
private Collection<DependencyInfo> collectPackageJsonDependencies(Collection<BomFile> packageJsons) {
Collection<DependencyInfo> dependencies = new LinkedList<>();
ConcurrentHashMap<DependencyInfo, BomFile> dependencyPackageJsonMap = new ConcurrentHashMap<>();
ExecutorService executorService = Executors.newWorkStealingPool(NUM_THREADS);
Collection<EnrichDependency> threadsCollection = new LinkedList<>();
for (BomFile packageJson : packageJsons) {
if (packageJson != null && packageJson.isValid()) {
// do not add new dependencies if 'npm ls' already returned all
DependencyInfo dependency = new DependencyInfo();
dependencies.add(dependency);
threadsCollection.add(new EnrichDependency(packageJson, dependency, dependencyPackageJsonMap, npmAccessToken));
logger.debug("Collect package.json of the dependency in the file: {}", dependency.getFilename());
}
}
runThreadCollection(executorService, threadsCollection);
logger.debug("set hierarchy of the dependencies");
// remove duplicates dependencies
Map<String, DependencyInfo> existDependencies = new HashMap<>();
Map<DependencyInfo, BomFile> dependencyPackageJsonMapWithoutDuplicates = new HashMap<>();
for (Map.Entry<DependencyInfo, BomFile> entry : dependencyPackageJsonMap.entrySet()) {
DependencyInfo keyDep = entry.getKey();
String key = keyDep.getSha1() + keyDep.getVersion() + keyDep.getArtifactId();
if (!existDependencies.containsKey(key)) {
existDependencies.put(key, keyDep);
dependencyPackageJsonMapWithoutDuplicates.put(keyDep, entry.getValue());
}
}
setHierarchy(dependencyPackageJsonMapWithoutDuplicates, existDependencies);
return existDependencies.values();
}
|
[
"private",
"Collection",
"<",
"DependencyInfo",
">",
"collectPackageJsonDependencies",
"(",
"Collection",
"<",
"BomFile",
">",
"packageJsons",
")",
"{",
"Collection",
"<",
"DependencyInfo",
">",
"dependencies",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"ConcurrentHashMap",
"<",
"DependencyInfo",
",",
"BomFile",
">",
"dependencyPackageJsonMap",
"=",
"new",
"ConcurrentHashMap",
"<>",
"(",
")",
";",
"ExecutorService",
"executorService",
"=",
"Executors",
".",
"newWorkStealingPool",
"(",
"NUM_THREADS",
")",
";",
"Collection",
"<",
"EnrichDependency",
">",
"threadsCollection",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"for",
"(",
"BomFile",
"packageJson",
":",
"packageJsons",
")",
"{",
"if",
"(",
"packageJson",
"!=",
"null",
"&&",
"packageJson",
".",
"isValid",
"(",
")",
")",
"{",
"// do not add new dependencies if 'npm ls' already returned all",
"DependencyInfo",
"dependency",
"=",
"new",
"DependencyInfo",
"(",
")",
";",
"dependencies",
".",
"add",
"(",
"dependency",
")",
";",
"threadsCollection",
".",
"add",
"(",
"new",
"EnrichDependency",
"(",
"packageJson",
",",
"dependency",
",",
"dependencyPackageJsonMap",
",",
"npmAccessToken",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Collect package.json of the dependency in the file: {}\"",
",",
"dependency",
".",
"getFilename",
"(",
")",
")",
";",
"}",
"}",
"runThreadCollection",
"(",
"executorService",
",",
"threadsCollection",
")",
";",
"logger",
".",
"debug",
"(",
"\"set hierarchy of the dependencies\"",
")",
";",
"// remove duplicates dependencies",
"Map",
"<",
"String",
",",
"DependencyInfo",
">",
"existDependencies",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Map",
"<",
"DependencyInfo",
",",
"BomFile",
">",
"dependencyPackageJsonMapWithoutDuplicates",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"DependencyInfo",
",",
"BomFile",
">",
"entry",
":",
"dependencyPackageJsonMap",
".",
"entrySet",
"(",
")",
")",
"{",
"DependencyInfo",
"keyDep",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"String",
"key",
"=",
"keyDep",
".",
"getSha1",
"(",
")",
"+",
"keyDep",
".",
"getVersion",
"(",
")",
"+",
"keyDep",
".",
"getArtifactId",
"(",
")",
";",
"if",
"(",
"!",
"existDependencies",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"existDependencies",
".",
"put",
"(",
"key",
",",
"keyDep",
")",
";",
"dependencyPackageJsonMapWithoutDuplicates",
".",
"put",
"(",
"keyDep",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"setHierarchy",
"(",
"dependencyPackageJsonMapWithoutDuplicates",
",",
"existDependencies",
")",
";",
"return",
"existDependencies",
".",
"values",
"(",
")",
";",
"}"
] |
Collect dependencies from package.json files - without 'npm ls'
|
[
"Collect",
"dependencies",
"from",
"package",
".",
"json",
"files",
"-",
"without",
"npm",
"ls"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/npm/NpmDependencyResolver.java#L333-L362
|
3,986 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/npm/NpmDependencyResolver.java
|
NpmDependencyResolver.removeDependenciesWithoutSha1
|
private void removeDependenciesWithoutSha1(Collection<DependencyInfo> dependencies){
Collection<DependencyInfo> childDependencies = new ArrayList<>();
for (Iterator<DependencyInfo> iterator = dependencies.iterator(); iterator.hasNext();){
DependencyInfo dependencyInfo = iterator.next();
if (dependencyInfo.getSha1().isEmpty()){
childDependencies.addAll(dependencyInfo.getChildren());
iterator.remove();
}
}
dependencies.addAll(childDependencies);
}
|
java
|
private void removeDependenciesWithoutSha1(Collection<DependencyInfo> dependencies){
Collection<DependencyInfo> childDependencies = new ArrayList<>();
for (Iterator<DependencyInfo> iterator = dependencies.iterator(); iterator.hasNext();){
DependencyInfo dependencyInfo = iterator.next();
if (dependencyInfo.getSha1().isEmpty()){
childDependencies.addAll(dependencyInfo.getChildren());
iterator.remove();
}
}
dependencies.addAll(childDependencies);
}
|
[
"private",
"void",
"removeDependenciesWithoutSha1",
"(",
"Collection",
"<",
"DependencyInfo",
">",
"dependencies",
")",
"{",
"Collection",
"<",
"DependencyInfo",
">",
"childDependencies",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Iterator",
"<",
"DependencyInfo",
">",
"iterator",
"=",
"dependencies",
".",
"iterator",
"(",
")",
";",
"iterator",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"DependencyInfo",
"dependencyInfo",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"dependencyInfo",
".",
"getSha1",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"childDependencies",
".",
"addAll",
"(",
"dependencyInfo",
".",
"getChildren",
"(",
")",
")",
";",
"iterator",
".",
"remove",
"(",
")",
";",
"}",
"}",
"dependencies",
".",
"addAll",
"(",
"childDependencies",
")",
";",
"}"
] |
currently deprecated - not relevant
|
[
"currently",
"deprecated",
"-",
"not",
"relevant"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/npm/NpmDependencyResolver.java#L423-L433
|
3,987 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/docker/RpmParser.java
|
RpmParser.getPackageVersion
|
private String getPackageVersion(String packageInfoString) {
// packageInfoString for example - audit-libs-2.7.6-3.el7-x86_64
try {
String firstDotString = packageInfoString.substring(0, packageInfoString.indexOf(Constants.DOT));
int lastIndexOfHyphen = firstDotString.lastIndexOf(Constants.DASH);
int lastIndexOfDot = packageInfoString.lastIndexOf(Constants.DOT);
String packVersion = packageInfoString.substring(lastIndexOfHyphen + 1, lastIndexOfDot);
if (StringUtils.isNotBlank(packVersion)) {
return packVersion;
}
} catch (Exception e) {
logger.warn("Failed to create package version : {}", e.getMessage());
}
return null;
}
|
java
|
private String getPackageVersion(String packageInfoString) {
// packageInfoString for example - audit-libs-2.7.6-3.el7-x86_64
try {
String firstDotString = packageInfoString.substring(0, packageInfoString.indexOf(Constants.DOT));
int lastIndexOfHyphen = firstDotString.lastIndexOf(Constants.DASH);
int lastIndexOfDot = packageInfoString.lastIndexOf(Constants.DOT);
String packVersion = packageInfoString.substring(lastIndexOfHyphen + 1, lastIndexOfDot);
if (StringUtils.isNotBlank(packVersion)) {
return packVersion;
}
} catch (Exception e) {
logger.warn("Failed to create package version : {}", e.getMessage());
}
return null;
}
|
[
"private",
"String",
"getPackageVersion",
"(",
"String",
"packageInfoString",
")",
"{",
"// packageInfoString for example - audit-libs-2.7.6-3.el7-x86_64",
"try",
"{",
"String",
"firstDotString",
"=",
"packageInfoString",
".",
"substring",
"(",
"0",
",",
"packageInfoString",
".",
"indexOf",
"(",
"Constants",
".",
"DOT",
")",
")",
";",
"int",
"lastIndexOfHyphen",
"=",
"firstDotString",
".",
"lastIndexOf",
"(",
"Constants",
".",
"DASH",
")",
";",
"int",
"lastIndexOfDot",
"=",
"packageInfoString",
".",
"lastIndexOf",
"(",
"Constants",
".",
"DOT",
")",
";",
"String",
"packVersion",
"=",
"packageInfoString",
".",
"substring",
"(",
"lastIndexOfHyphen",
"+",
"1",
",",
"lastIndexOfDot",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"packVersion",
")",
")",
"{",
"return",
"packVersion",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Failed to create package version : {}\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
get rpm package version
|
[
"get",
"rpm",
"package",
"version"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/docker/RpmParser.java#L65-L79
|
3,988 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/docker/RpmParser.java
|
RpmParser.checkFolders
|
public File checkFolders(Collection<String> yumDbFolders, String yumDbFolderPath) {
if (!yumDbFolders.isEmpty()) {
for (String folderPath : yumDbFolders) {
File file = new File(folderPath);
if (file.listFiles().length > 0 && folderPath.contains(yumDbFolderPath)) {
return file;
}
}
}
return null;
}
|
java
|
public File checkFolders(Collection<String> yumDbFolders, String yumDbFolderPath) {
if (!yumDbFolders.isEmpty()) {
for (String folderPath : yumDbFolders) {
File file = new File(folderPath);
if (file.listFiles().length > 0 && folderPath.contains(yumDbFolderPath)) {
return file;
}
}
}
return null;
}
|
[
"public",
"File",
"checkFolders",
"(",
"Collection",
"<",
"String",
">",
"yumDbFolders",
",",
"String",
"yumDbFolderPath",
")",
"{",
"if",
"(",
"!",
"yumDbFolders",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"String",
"folderPath",
":",
"yumDbFolders",
")",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"folderPath",
")",
";",
"if",
"(",
"file",
".",
"listFiles",
"(",
")",
".",
"length",
">",
"0",
"&&",
"folderPath",
".",
"contains",
"(",
"yumDbFolderPath",
")",
")",
"{",
"return",
"file",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
find yumdb folder from collection
|
[
"find",
"yumdb",
"folder",
"from",
"collection"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/docker/RpmParser.java#L87-L97
|
3,989 |
whitesource/fs-agent
|
src/main/java/org/whitesource/fs/FSAConfiguration.java
|
FSAConfiguration.checkAppPathsForVia
|
private boolean checkAppPathsForVia(Set<String> keySet, List<String> errors) {
for (String key : keySet) {
if (!key.equals("defaultKey")) {
File file = new File(key);
if (!file.exists()) {
errors.add("Effective Usage Analysis will not run if the -appPath parameter references an invalid file path. Check that the -appPath parameter specifies a valid path");
return false;
} else if (!file.isFile()) {
errors.add("Effective Usage Analysis will not run if the -appPath parameter references an invalid file path. Check that the -appPath parameter specifies a valid path");
return false;
} else {
return true;
}
}
}
return false;
}
|
java
|
private boolean checkAppPathsForVia(Set<String> keySet, List<String> errors) {
for (String key : keySet) {
if (!key.equals("defaultKey")) {
File file = new File(key);
if (!file.exists()) {
errors.add("Effective Usage Analysis will not run if the -appPath parameter references an invalid file path. Check that the -appPath parameter specifies a valid path");
return false;
} else if (!file.isFile()) {
errors.add("Effective Usage Analysis will not run if the -appPath parameter references an invalid file path. Check that the -appPath parameter specifies a valid path");
return false;
} else {
return true;
}
}
}
return false;
}
|
[
"private",
"boolean",
"checkAppPathsForVia",
"(",
"Set",
"<",
"String",
">",
"keySet",
",",
"List",
"<",
"String",
">",
"errors",
")",
"{",
"for",
"(",
"String",
"key",
":",
"keySet",
")",
"{",
"if",
"(",
"!",
"key",
".",
"equals",
"(",
"\"defaultKey\"",
")",
")",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"key",
")",
";",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"errors",
".",
"add",
"(",
"\"Effective Usage Analysis will not run if the -appPath parameter references an invalid file path. Check that the -appPath parameter specifies a valid path\"",
")",
";",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"!",
"file",
".",
"isFile",
"(",
")",
")",
"{",
"errors",
".",
"add",
"(",
"\"Effective Usage Analysis will not run if the -appPath parameter references an invalid file path. Check that the -appPath parameter specifies a valid path\"",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
check validation for appPath property, first check if the path is exist and then if this path is not a directory
|
[
"check",
"validation",
"for",
"appPath",
"property",
"first",
"check",
"if",
"the",
"path",
"is",
"exist",
"and",
"then",
"if",
"this",
"path",
"is",
"not",
"a",
"directory"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/fs/FSAConfiguration.java#L407-L423
|
3,990 |
whitesource/fs-agent
|
src/main/java/org/whitesource/fs/FSAConfiguration.java
|
FSAConfiguration.parseProxy
|
public static String[] parseProxy(String proxy, List<String> errors) {
String[] parsedProxyInfo = new String[4];
if (proxy != null) {
try {
URL proxyAsUrl = new URL(proxy);
parsedProxyInfo[0] = proxyAsUrl.getHost();
parsedProxyInfo[1] = String.valueOf(proxyAsUrl.getPort());
if (proxyAsUrl.getUserInfo() != null) {
String[] parsedCred = proxyAsUrl.getUserInfo().split(COLON);
parsedProxyInfo[2] = parsedCred[0];
if (parsedCred.length > 1) {
parsedProxyInfo[3] = parsedCred[1];
}
}
} catch (MalformedURLException e) {
errors.add("Malformed proxy url : {}" + e.getMessage());
}
}
return parsedProxyInfo;
}
|
java
|
public static String[] parseProxy(String proxy, List<String> errors) {
String[] parsedProxyInfo = new String[4];
if (proxy != null) {
try {
URL proxyAsUrl = new URL(proxy);
parsedProxyInfo[0] = proxyAsUrl.getHost();
parsedProxyInfo[1] = String.valueOf(proxyAsUrl.getPort());
if (proxyAsUrl.getUserInfo() != null) {
String[] parsedCred = proxyAsUrl.getUserInfo().split(COLON);
parsedProxyInfo[2] = parsedCred[0];
if (parsedCred.length > 1) {
parsedProxyInfo[3] = parsedCred[1];
}
}
} catch (MalformedURLException e) {
errors.add("Malformed proxy url : {}" + e.getMessage());
}
}
return parsedProxyInfo;
}
|
[
"public",
"static",
"String",
"[",
"]",
"parseProxy",
"(",
"String",
"proxy",
",",
"List",
"<",
"String",
">",
"errors",
")",
"{",
"String",
"[",
"]",
"parsedProxyInfo",
"=",
"new",
"String",
"[",
"4",
"]",
";",
"if",
"(",
"proxy",
"!=",
"null",
")",
"{",
"try",
"{",
"URL",
"proxyAsUrl",
"=",
"new",
"URL",
"(",
"proxy",
")",
";",
"parsedProxyInfo",
"[",
"0",
"]",
"=",
"proxyAsUrl",
".",
"getHost",
"(",
")",
";",
"parsedProxyInfo",
"[",
"1",
"]",
"=",
"String",
".",
"valueOf",
"(",
"proxyAsUrl",
".",
"getPort",
"(",
")",
")",
";",
"if",
"(",
"proxyAsUrl",
".",
"getUserInfo",
"(",
")",
"!=",
"null",
")",
"{",
"String",
"[",
"]",
"parsedCred",
"=",
"proxyAsUrl",
".",
"getUserInfo",
"(",
")",
".",
"split",
"(",
"COLON",
")",
";",
"parsedProxyInfo",
"[",
"2",
"]",
"=",
"parsedCred",
"[",
"0",
"]",
";",
"if",
"(",
"parsedCred",
".",
"length",
">",
"1",
")",
"{",
"parsedProxyInfo",
"[",
"3",
"]",
"=",
"parsedCred",
"[",
"1",
"]",
";",
"}",
"}",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"errors",
".",
"add",
"(",
"\"Malformed proxy url : {}\"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"return",
"parsedProxyInfo",
";",
"}"
] |
returns data of proxy url from command line parameter proxy
|
[
"returns",
"data",
"of",
"proxy",
"url",
"from",
"command",
"line",
"parameter",
"proxy"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/fs/FSAConfiguration.java#L1220-L1240
|
3,991 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/gradle/GradleLinesParser.java
|
GradleLinesParser.getSha1FromLocalRepo
|
private DependencyFile getSha1FromLocalRepo(DependencyInfo dependencyInfo) {
File localRepo = new File(gradleLocalRepositoryPath);
DependencyFile dependencyFile = null;
if (localRepo.exists() && localRepo.isDirectory()) {
String artifactId = dependencyInfo.getArtifactId();
String version = dependencyInfo.getVersion();
String dependencyName = artifactId + Constants.DASH + version;
logger.debug("Looking for " + dependencyName + " in {}", localRepo.getPath());
dependencyFile = findDependencySha1(dependencyName, gradleLocalRepositoryPath);
} else {
logger.warn("Could not find path {}", localRepo.getPath());
}
return dependencyFile;
}
|
java
|
private DependencyFile getSha1FromLocalRepo(DependencyInfo dependencyInfo) {
File localRepo = new File(gradleLocalRepositoryPath);
DependencyFile dependencyFile = null;
if (localRepo.exists() && localRepo.isDirectory()) {
String artifactId = dependencyInfo.getArtifactId();
String version = dependencyInfo.getVersion();
String dependencyName = artifactId + Constants.DASH + version;
logger.debug("Looking for " + dependencyName + " in {}", localRepo.getPath());
dependencyFile = findDependencySha1(dependencyName, gradleLocalRepositoryPath);
} else {
logger.warn("Could not find path {}", localRepo.getPath());
}
return dependencyFile;
}
|
[
"private",
"DependencyFile",
"getSha1FromLocalRepo",
"(",
"DependencyInfo",
"dependencyInfo",
")",
"{",
"File",
"localRepo",
"=",
"new",
"File",
"(",
"gradleLocalRepositoryPath",
")",
";",
"DependencyFile",
"dependencyFile",
"=",
"null",
";",
"if",
"(",
"localRepo",
".",
"exists",
"(",
")",
"&&",
"localRepo",
".",
"isDirectory",
"(",
")",
")",
"{",
"String",
"artifactId",
"=",
"dependencyInfo",
".",
"getArtifactId",
"(",
")",
";",
"String",
"version",
"=",
"dependencyInfo",
".",
"getVersion",
"(",
")",
";",
"String",
"dependencyName",
"=",
"artifactId",
"+",
"Constants",
".",
"DASH",
"+",
"version",
";",
"logger",
".",
"debug",
"(",
"\"Looking for \"",
"+",
"dependencyName",
"+",
"\" in {}\"",
",",
"localRepo",
".",
"getPath",
"(",
")",
")",
";",
"dependencyFile",
"=",
"findDependencySha1",
"(",
"dependencyName",
",",
"gradleLocalRepositoryPath",
")",
";",
"}",
"else",
"{",
"logger",
".",
"warn",
"(",
"\"Could not find path {}\"",
",",
"localRepo",
".",
"getPath",
"(",
")",
")",
";",
"}",
"return",
"dependencyFile",
";",
"}"
] |
get sha1 form local repository
|
[
"get",
"sha1",
"form",
"local",
"repository"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/gradle/GradleLinesParser.java#L280-L293
|
3,992 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationRemoteCallback.java
|
NotificationRemoteCallback.onClickRemote
|
public void onClickRemote(NotificationRemote remote, NotificationEntry entry) {
if (DBG) Log.v(TAG, "onClickRemote - " + entry.ID);
}
|
java
|
public void onClickRemote(NotificationRemote remote, NotificationEntry entry) {
if (DBG) Log.v(TAG, "onClickRemote - " + entry.ID);
}
|
[
"public",
"void",
"onClickRemote",
"(",
"NotificationRemote",
"remote",
",",
"NotificationEntry",
"entry",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"onClickRemote - \"",
"+",
"entry",
".",
"ID",
")",
";",
"}"
] |
Called when notification is clicked.
@param remote
@param entry
|
[
"Called",
"when",
"notification",
"is",
"clicked",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationRemoteCallback.java#L135-L137
|
3,993 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationRemoteCallback.java
|
NotificationRemoteCallback.onClickRemoteAction
|
public void onClickRemoteAction(NotificationRemote remote, NotificationEntry entry,
NotificationEntry.Action act) {
if (DBG) Log.v(TAG, "onClickRemoteAction - " + entry.ID + ", " + act);
}
|
java
|
public void onClickRemoteAction(NotificationRemote remote, NotificationEntry entry,
NotificationEntry.Action act) {
if (DBG) Log.v(TAG, "onClickRemoteAction - " + entry.ID + ", " + act);
}
|
[
"public",
"void",
"onClickRemoteAction",
"(",
"NotificationRemote",
"remote",
",",
"NotificationEntry",
"entry",
",",
"NotificationEntry",
".",
"Action",
"act",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"onClickRemoteAction - \"",
"+",
"entry",
".",
"ID",
"+",
"\", \"",
"+",
"act",
")",
";",
"}"
] |
Called when notification action view is clicked.
@param remote
@param entry
@param act
|
[
"Called",
"when",
"notification",
"action",
"view",
"is",
"clicked",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationRemoteCallback.java#L156-L159
|
3,994 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationRemoteCallback.java
|
NotificationRemoteCallback.onReceive
|
public void onReceive(NotificationRemote remote, NotificationEntry entry,
Intent intent, String intentAction) {
if (DBG) Log.d(TAG, "onReceive - " + entry.ID + ", " + intentAction);
}
|
java
|
public void onReceive(NotificationRemote remote, NotificationEntry entry,
Intent intent, String intentAction) {
if (DBG) Log.d(TAG, "onReceive - " + entry.ID + ", " + intentAction);
}
|
[
"public",
"void",
"onReceive",
"(",
"NotificationRemote",
"remote",
",",
"NotificationEntry",
"entry",
",",
"Intent",
"intent",
",",
"String",
"intentAction",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"d",
"(",
"TAG",
",",
"\"onReceive - \"",
"+",
"entry",
".",
"ID",
"+",
"\", \"",
"+",
"intentAction",
")",
";",
"}"
] |
Called when receiving a broadcast.
@param remote
@param entry
@param intent
@param intentAction
|
[
"Called",
"when",
"receiving",
"a",
"broadcast",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationRemoteCallback.java#L169-L172
|
3,995 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/docker/DockerResolver.java
|
DockerResolver.filterDockerImagesToScan
|
private Collection<DockerImage> filterDockerImagesToScan(Collection<DockerImage> dockerImages, String[] dockerImageIncludes, String[] dockerImageExcludes) {
logger.info("Filtering docker images list by includes and excludes lists");
Collection<DockerImage> dockerImagesToScan = new LinkedList<>();
Collection<String> imageIncludesList = Arrays.asList(dockerImageIncludes);
Collection<String> imageExcludesList = Arrays.asList(dockerImageExcludes);
for (DockerImage dockerImage : dockerImages) {
String dockerImageString = dockerImage.getRepository() + Constants.WHITESPACE + dockerImage.getTag() + Constants.WHITESPACE + dockerImage.getId();
// add images to scan according to dockerIncludes pattern
if (isMatchingPattern(dockerImageString, imageIncludesList)) {
dockerImagesToScan.add(dockerImage);
}
// remove images from scan according to dockerExcludes pattern
if (isMatchingPattern(dockerImageString, imageExcludesList)) {
dockerImagesToScan.remove(dockerImage);
}
}
return dockerImagesToScan;
}
|
java
|
private Collection<DockerImage> filterDockerImagesToScan(Collection<DockerImage> dockerImages, String[] dockerImageIncludes, String[] dockerImageExcludes) {
logger.info("Filtering docker images list by includes and excludes lists");
Collection<DockerImage> dockerImagesToScan = new LinkedList<>();
Collection<String> imageIncludesList = Arrays.asList(dockerImageIncludes);
Collection<String> imageExcludesList = Arrays.asList(dockerImageExcludes);
for (DockerImage dockerImage : dockerImages) {
String dockerImageString = dockerImage.getRepository() + Constants.WHITESPACE + dockerImage.getTag() + Constants.WHITESPACE + dockerImage.getId();
// add images to scan according to dockerIncludes pattern
if (isMatchingPattern(dockerImageString, imageIncludesList)) {
dockerImagesToScan.add(dockerImage);
}
// remove images from scan according to dockerExcludes pattern
if (isMatchingPattern(dockerImageString, imageExcludesList)) {
dockerImagesToScan.remove(dockerImage);
}
}
return dockerImagesToScan;
}
|
[
"private",
"Collection",
"<",
"DockerImage",
">",
"filterDockerImagesToScan",
"(",
"Collection",
"<",
"DockerImage",
">",
"dockerImages",
",",
"String",
"[",
"]",
"dockerImageIncludes",
",",
"String",
"[",
"]",
"dockerImageExcludes",
")",
"{",
"logger",
".",
"info",
"(",
"\"Filtering docker images list by includes and excludes lists\"",
")",
";",
"Collection",
"<",
"DockerImage",
">",
"dockerImagesToScan",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"Collection",
"<",
"String",
">",
"imageIncludesList",
"=",
"Arrays",
".",
"asList",
"(",
"dockerImageIncludes",
")",
";",
"Collection",
"<",
"String",
">",
"imageExcludesList",
"=",
"Arrays",
".",
"asList",
"(",
"dockerImageExcludes",
")",
";",
"for",
"(",
"DockerImage",
"dockerImage",
":",
"dockerImages",
")",
"{",
"String",
"dockerImageString",
"=",
"dockerImage",
".",
"getRepository",
"(",
")",
"+",
"Constants",
".",
"WHITESPACE",
"+",
"dockerImage",
".",
"getTag",
"(",
")",
"+",
"Constants",
".",
"WHITESPACE",
"+",
"dockerImage",
".",
"getId",
"(",
")",
";",
"// add images to scan according to dockerIncludes pattern",
"if",
"(",
"isMatchingPattern",
"(",
"dockerImageString",
",",
"imageIncludesList",
")",
")",
"{",
"dockerImagesToScan",
".",
"add",
"(",
"dockerImage",
")",
";",
"}",
"// remove images from scan according to dockerExcludes pattern",
"if",
"(",
"isMatchingPattern",
"(",
"dockerImageString",
",",
"imageExcludesList",
")",
")",
"{",
"dockerImagesToScan",
".",
"remove",
"(",
"dockerImage",
")",
";",
"}",
"}",
"return",
"dockerImagesToScan",
";",
"}"
] |
Filter the images using includes and excludes lists
|
[
"Filter",
"the",
"images",
"using",
"includes",
"and",
"excludes",
"lists"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/docker/DockerResolver.java#L166-L183
|
3,996 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/docker/DockerResolver.java
|
DockerResolver.saveDockerImages
|
private void saveDockerImages(Collection<DockerImage> dockerImages, Collection<AgentProjectInfo> projects) throws IOException {
logger.info("Saving {} docker images", dockerImages.size());
int counter = 1;
int imagesCount = dockerImages.size();
for (DockerImage dockerImage : dockerImages) {
logger.info("Image {} of {} Images", counter, imagesCount);
//saveDockerImage(dockerImage, projects);
manageDockerImage(dockerImage, projects);
counter++;
}
}
|
java
|
private void saveDockerImages(Collection<DockerImage> dockerImages, Collection<AgentProjectInfo> projects) throws IOException {
logger.info("Saving {} docker images", dockerImages.size());
int counter = 1;
int imagesCount = dockerImages.size();
for (DockerImage dockerImage : dockerImages) {
logger.info("Image {} of {} Images", counter, imagesCount);
//saveDockerImage(dockerImage, projects);
manageDockerImage(dockerImage, projects);
counter++;
}
}
|
[
"private",
"void",
"saveDockerImages",
"(",
"Collection",
"<",
"DockerImage",
">",
"dockerImages",
",",
"Collection",
"<",
"AgentProjectInfo",
">",
"projects",
")",
"throws",
"IOException",
"{",
"logger",
".",
"info",
"(",
"\"Saving {} docker images\"",
",",
"dockerImages",
".",
"size",
"(",
")",
")",
";",
"int",
"counter",
"=",
"1",
";",
"int",
"imagesCount",
"=",
"dockerImages",
".",
"size",
"(",
")",
";",
"for",
"(",
"DockerImage",
"dockerImage",
":",
"dockerImages",
")",
"{",
"logger",
".",
"info",
"(",
"\"Image {} of {} Images\"",
",",
"counter",
",",
"imagesCount",
")",
";",
"//saveDockerImage(dockerImage, projects);",
"manageDockerImage",
"(",
"dockerImage",
",",
"projects",
")",
";",
"counter",
"++",
";",
"}",
"}"
] |
Save docker images and scan files
|
[
"Save",
"docker",
"images",
"and",
"scan",
"files"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/docker/DockerResolver.java#L220-L230
|
3,997 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationHandler.java
|
NotificationHandler.cancel
|
public void cancel(int entryId) {
NotificationEntry entry = mCenter.getEntry(ID, entryId);
if (entry != null) {
cancel(entry);
}
}
|
java
|
public void cancel(int entryId) {
NotificationEntry entry = mCenter.getEntry(ID, entryId);
if (entry != null) {
cancel(entry);
}
}
|
[
"public",
"void",
"cancel",
"(",
"int",
"entryId",
")",
"{",
"NotificationEntry",
"entry",
"=",
"mCenter",
".",
"getEntry",
"(",
"ID",
",",
"entryId",
")",
";",
"if",
"(",
"entry",
"!=",
"null",
")",
"{",
"cancel",
"(",
"entry",
")",
";",
"}",
"}"
] |
Cancel notification by its id.
@param entryId
|
[
"Cancel",
"notification",
"by",
"its",
"id",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationHandler.java#L231-L236
|
3,998 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationHandler.java
|
NotificationHandler.cancel
|
public void cancel(String tag) {
List<NotificationEntry> entries = mCenter.getEntries(ID, tag);
if (entries != null && !entries.isEmpty()) {
for (NotificationEntry entry : entries) {
cancel(entry);
}
}
}
|
java
|
public void cancel(String tag) {
List<NotificationEntry> entries = mCenter.getEntries(ID, tag);
if (entries != null && !entries.isEmpty()) {
for (NotificationEntry entry : entries) {
cancel(entry);
}
}
}
|
[
"public",
"void",
"cancel",
"(",
"String",
"tag",
")",
"{",
"List",
"<",
"NotificationEntry",
">",
"entries",
"=",
"mCenter",
".",
"getEntries",
"(",
"ID",
",",
"tag",
")",
";",
"if",
"(",
"entries",
"!=",
"null",
"&&",
"!",
"entries",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"NotificationEntry",
"entry",
":",
"entries",
")",
"{",
"cancel",
"(",
"entry",
")",
";",
"}",
"}",
"}"
] |
Cancel notifications by its tag.
@param tag
|
[
"Cancel",
"notifications",
"by",
"its",
"tag",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationHandler.java#L243-L250
|
3,999 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationHandler.java
|
NotificationHandler.cancelAll
|
public void cancelAll() {
if (DBG) Log.v(TAG, "prepare to cancel all");
cancelSchedule(ARRIVE);
schedule(CANCEL_ALL, 0, 0, null, 0);
}
|
java
|
public void cancelAll() {
if (DBG) Log.v(TAG, "prepare to cancel all");
cancelSchedule(ARRIVE);
schedule(CANCEL_ALL, 0, 0, null, 0);
}
|
[
"public",
"void",
"cancelAll",
"(",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"prepare to cancel all\"",
")",
";",
"cancelSchedule",
"(",
"ARRIVE",
")",
";",
"schedule",
"(",
"CANCEL_ALL",
",",
"0",
",",
"0",
",",
"null",
",",
"0",
")",
";",
"}"
] |
Cancel all notifications.
|
[
"Cancel",
"all",
"notifications",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationHandler.java#L269-L273
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.