Revision 58672
Added by Alessia Bardi almost 4 years ago
BlacklistManager.java | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
9 | 9 |
|
10 |
import com.google.common.collect.Sets; |
|
10 | 11 |
import org.apache.commons.lang.StringUtils; |
11 | 12 |
import org.apache.commons.logging.Log; |
12 | 13 |
import org.apache.commons.logging.LogFactory; |
... | ... | |
40 | 41 |
@Autowired |
41 | 42 |
private OpenaireIdResolver openaireIdResolver; |
42 | 43 |
|
43 |
private List<String> getOriginalIds(final String id, final String entityType) {
|
|
44 |
List<String> originalIds = Lists.newArrayList();
|
|
44 |
private Set<String> getOriginalIds(final String id, final String entityType) {
|
|
45 |
Set<String> originalIds = Sets.newHashSet();
|
|
45 | 46 |
// We need to find original ids only for entities that are deduplicated: result, organization, person. |
46 | 47 |
if (entityType.equals("result") || entityType.equals("organization") || entityType.equals("person")) { |
47 | 48 |
originalIds = openaireIdResolver.resolveIdentifier(id); |
... | ... | |
50 | 51 |
} |
51 | 52 |
|
52 | 53 |
public void addToBlacklist(final BlacklistEntry entry) throws DatabaseException { |
53 |
final List<String> sourceIds = getOriginalIds(entry.getSourceObject(), entry.getSourceType());
|
|
54 |
final List<String> targetIds = getOriginalIds(entry.getTargetObject(), entry.getTargetType());
|
|
55 |
entry.setOriginalSourceObjects(sourceIds);
|
|
56 |
entry.setOriginalTargetObjects(targetIds);
|
|
54 |
final Set<String> sourceIds = getOriginalIds(entry.getSourceObject(), entry.getSourceType());
|
|
55 |
final Set<String> targetIds = getOriginalIds(entry.getTargetObject(), entry.getTargetType());
|
|
56 |
sourceIds.add(entry.getSourceObject());
|
|
57 |
targetIds.add(entry.getTargetObject());
|
|
57 | 58 |
|
58 | 59 |
final DatabaseService dbService = serviceLocator.getService(DatabaseService.class); |
59 | 60 |
final String addQuery = String.format( |
... | ... | |
71 | 72 |
asSqlParam(entry.getTargetObject()), |
72 | 73 |
asSqlParam(entry.getTargetType()), |
73 | 74 |
asSqlParam(entry.getTicketId()), |
74 |
asSqlParam(joinCollectionForSQL(sourceIds.isEmpty() ? Lists.newArrayList(entry.getSourceObject()) : sourceIds)),
|
|
75 |
asSqlParam(joinCollectionForSQL(targetIds.isEmpty() ? Lists.newArrayList(entry.getTargetObject()) : targetIds)),
|
|
75 |
asSqlParam(joinCollectionForSQL(sourceIds)), |
|
76 |
asSqlParam(joinCollectionForSQL(targetIds)), |
|
76 | 77 |
asSqlParam(entry.getNote())); |
77 | 78 |
log.debug("Adding new blacklist entry"); |
78 | 79 |
this.safeUpdateSql(dbService, blacklistDatabaseName, addQuery); |
Also available in: Unified diff
ensure we have the proper identifiers in the list of original source and target objects. They may, as it used to be, contain also representative identifiers. Asking for them should be enough to completely blacklist a relationship