Revision 45455
Added by Alessia Bardi over 7 years ago
MongoSetCollection.java | ||
---|---|---|
3 | 3 |
import java.text.Normalizer; |
4 | 4 |
import java.util.List; |
5 | 5 |
|
6 |
import org.apache.commons.lang3.StringEscapeUtils; |
|
7 |
import org.apache.commons.lang3.StringUtils; |
|
8 |
import org.bson.conversions.Bson; |
|
9 |
import org.springframework.beans.factory.annotation.Autowired; |
|
10 |
|
|
11 |
import com.google.common.base.Function; |
|
12 | 6 |
import com.google.common.collect.Iterables; |
13 | 7 |
import com.google.common.collect.Lists; |
14 | 8 |
import com.mongodb.BasicDBObject; |
... | ... | |
21 | 15 |
import com.mongodb.client.model.FindOneAndReplaceOptions; |
22 | 16 |
import com.mongodb.client.model.FindOneAndUpdateOptions; |
23 | 17 |
import com.mongodb.client.model.IndexOptions; |
24 |
|
|
25 | 18 |
import eu.dnetlib.oai.info.SetInfo; |
19 |
import org.apache.commons.lang3.StringEscapeUtils; |
|
20 |
import org.apache.commons.lang3.StringUtils; |
|
21 |
import org.bson.conversions.Bson; |
|
22 |
import org.springframework.beans.factory.annotation.Autowired; |
|
26 | 23 |
|
27 | 24 |
public class MongoSetCollection implements SetCollection { |
28 | 25 |
|
... | ... | |
40 | 37 |
|
41 | 38 |
@Override |
42 | 39 |
public List<SetInfo> getAllSets(final boolean enabledOnly, final String dbName) { |
43 |
FindIterable<DBObject> iter = null;
|
|
40 |
FindIterable<DBObject> iter; |
|
44 | 41 |
if (!enabledOnly) { |
45 | 42 |
iter = this.getSetsCollection(dbName).find(); |
46 | 43 |
} else { |
47 | 44 |
final Bson where = Filters.eq("enabled", true); |
48 | 45 |
iter = this.getSetsCollection(dbName).find(where); |
49 | 46 |
} |
50 |
return Lists.newArrayList(Iterables.transform(iter, new Function<DBObject, SetInfo>() {
|
|
47 |
return Lists.newArrayList(Iterables.transform(iter, dbObject -> getSetFromDBObject(dbObject)));
|
|
51 | 48 |
|
52 |
@Override |
|
53 |
public SetInfo apply(final DBObject dbObject) { |
|
54 |
return getSetFromDBObject(dbObject); |
|
55 |
} |
|
56 |
})); |
|
57 | 49 |
} |
58 | 50 |
|
59 | 51 |
@Override |
... | ... | |
138 | 130 |
this.getSetsCountCollection(dbName).deleteMany(query); |
139 | 131 |
} |
140 | 132 |
|
141 |
// public void dropConfigurationSets(final String dbName) {
|
|
142 |
// this.getSetsCollection(dbName).deleteMany(Filters.eq("fromConfiguration", true));
|
|
143 |
// }
|
|
133 |
public void dropConfigurationSets(final String dbName) { |
|
134 |
this.getSetsCollection(dbName).deleteMany(Filters.eq("fromConfiguration", true)); |
|
135 |
} |
|
144 | 136 |
|
145 | 137 |
protected List<SetInfo> findSets(final Bson query, final String dbName) { |
146 | 138 |
final FindIterable<DBObject> sets = this.getSetsCollection(dbName).find(query); |
Also available in: Unified diff
Included changes about the CQL translation as in most recent version of cnr-cql-utils of DNet40 + refactoring of OAI parameters