Revision 45315
Added by Claudio Atzori almost 7 years ago
modules/dnet-openaire-blacklist/trunk/deploy.info | ||
---|---|---|
1 |
{"type_source": "SVN", "goal": "package -U source:jar", |
|
2 |
"url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-openaire-blacklist/trunk/", |
|
3 |
"deploy_repository": "dnet4-snapshots", "version": "4", "mail": "alessia.bardi@isti.cnr.it", |
|
4 |
"deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "dnet-openaire-blacklist"} |
modules/dnet-openaire-blacklist/trunk/src/test/java/eu/dnetlib/openaire/blacklist/OpenaireIdResolverTest.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.blacklist; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
6 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
7 |
import junit.framework.Assert; |
|
8 |
import org.apache.commons.logging.Log; |
|
9 |
import org.apache.commons.logging.LogFactory; |
|
10 |
import org.junit.Before; |
|
11 |
import org.junit.Ignore; |
|
12 |
import org.junit.Test; |
|
13 |
import org.junit.runner.RunWith; |
|
14 |
import org.mockito.Mock; |
|
15 |
import org.mockito.Mockito; |
|
16 |
import org.mockito.runners.MockitoJUnitRunner; |
|
17 |
|
|
18 |
@RunWith(MockitoJUnitRunner.class) |
|
19 |
public class OpenaireIdResolverTest { |
|
20 |
|
|
21 |
private static final Log log = LogFactory.getLog(OpenaireIdResolverTest.class); |
|
22 |
private final String id = "dedup_wf_001::00066fdc65f1e21677c69d976a8e852d"; |
|
23 |
private OpenaireIdResolver resolver; |
|
24 |
@Mock |
|
25 |
private ISLookUpService isLookupService; |
|
26 |
@Mock |
|
27 |
private UniqueServiceLocator serviceLocator; |
|
28 |
|
|
29 |
@Before |
|
30 |
public void setUp() throws Exception { |
|
31 |
resolver = new OpenaireIdResolver(); |
|
32 |
Mockito.when(serviceLocator.getService(ISLookUpService.class)).thenReturn(isLookupService); |
|
33 |
Mockito.when( |
|
34 |
isLookupService.getResourceProfileByQuery(Mockito.startsWith("for $x in collection('/db/DRIVER/ServiceResources/IndexServiceResourceType')"))) |
|
35 |
.thenReturn("beta.solr.openaire.eu:9983"); |
|
36 |
Mockito.when( |
|
37 |
isLookupService.getResourceProfileByQuery(Mockito.startsWith("for $x in collection('/db/DRIVER/ServiceResources/SearchServiceResourceType')"))) |
|
38 |
.thenReturn("DMF"); |
|
39 |
resolver.setServiceLocator(serviceLocator); |
|
40 |
|
|
41 |
} |
|
42 |
|
|
43 |
@Ignore |
|
44 |
@Test |
|
45 |
public void testFindOriginalIds() throws Exception { |
|
46 |
log.debug("Testing for " + id); |
|
47 |
List<String> originals = resolver.findOriginalIds(id); |
|
48 |
Assert.assertTrue(originals.contains("od_______165::deb6d865011c09f228af41a30e0ff1a4")); |
|
49 |
Assert.assertTrue(originals.contains("od_______165::00066fdc65f1e21677c69d976a8e852d")); |
|
50 |
Assert.assertTrue(originals.size() == 2); |
|
51 |
|
|
52 |
} |
|
53 |
} |
modules/dnet-openaire-blacklist/trunk/src/test/java/eu/dnetlib/openaire/blacklist/BlacklistManagerTest.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.blacklist; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import com.google.common.collect.Lists; |
|
6 |
import org.apache.commons.lang.StringUtils; |
|
7 |
import org.junit.Before; |
|
8 |
import org.junit.Test; |
|
9 |
|
|
10 |
public class BlacklistManagerTest { |
|
11 |
|
|
12 |
private List<String> input = Lists.newArrayList(); |
|
13 |
private BlacklistManager blManager; |
|
14 |
|
|
15 |
@Before |
|
16 |
public void setUp() throws Exception { |
|
17 |
input.add( |
|
18 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ROW><FIELD name=\"iis_module\">iis::document_referencedProjects</FIELD><FIELD name=\"ticket_id\">1245</FIELD><FIELD name=\"last_update_time\">2015-09-18 12:39:11.781532</FIELD><FIELD name=\"status\">accepted</FIELD><FIELD name=\"userid\">unknown</FIELD><FIELD name=\"iis_module_profile\" isNull=\"true\"/><FIELD name=\"original_target_objects\" isNull=\"true\"/><FIELD name=\"relationship\">resultProject_outcome_isProducedBy</FIELD><FIELD name=\"id\">1</FIELD><FIELD name=\"provenance\">iis</FIELD><FIELD name=\"iis_status\">unsolved</FIELD><FIELD name=\"original_source_objects\" isNull=\"true\"/><FIELD name=\"creation_time\">2015-09-18 12:39:11.781532</FIELD><FIELD name=\"target_object\">corda_______::fda6a1c19dac47508b6fb619518328c7</FIELD><FIELD name=\"note\" isNull=\"true\"/><FIELD name=\"source_object\">od_______908::a47e1c3ede9a21ee5278a2e5c338d69b</FIELD><FIELD name=\"source_type\">result</FIELD><FIELD name=\"target_type\">project</FIELD></ROW>"); |
|
19 |
input.add( |
|
20 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ROW><FIELD name=\"iis_module\">iis::document_referencedProjects</FIELD><FIELD name=\"ticket_id\">1245</FIELD><FIELD name=\"last_update_time\">2015-09-18 12:39:11.789433</FIELD><FIELD name=\"status\">accepted</FIELD><FIELD name=\"userid\">unknown</FIELD><FIELD name=\"iis_module_profile\" isNull=\"true\"/><FIELD name=\"original_target_objects\" isNull=\"true\"/><FIELD name=\"relationship\">resultProject_outcome_isProducedBy</FIELD><FIELD name=\"id\">2</FIELD><FIELD name=\"provenance\">iis</FIELD><FIELD name=\"iis_status\">unsolved</FIELD><FIELD name=\"original_source_objects\" isNull=\"true\"/><FIELD name=\"creation_time\">2015-09-18 12:39:11.789433</FIELD><FIELD name=\"target_object\">corda_______::189ff31d637eaaeaf4d3584dc490b1cf</FIELD><FIELD name=\"note\" isNull=\"true\"/><FIELD name=\"source_object\">od_______908::a47e1c3ede9a21ee5278a2e5c338d69b</FIELD><FIELD name=\"source_type\">result</FIELD><FIELD name=\"target_type\">project</FIELD></ROW>"); |
|
21 |
input.add( |
|
22 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ROW><FIELD name=\"iis_module\">iis::document_referencedProjects</FIELD><FIELD name=\"ticket_id\">1297</FIELD><FIELD name=\"last_update_time\">2015-09-18 12:39:11.854513</FIELD><FIELD name=\"status\">accepted</FIELD><FIELD name=\"userid\">unknown</FIELD><FIELD name=\"iis_module_profile\" isNull=\"true\"/><FIELD name=\"original_target_objects\" isNull=\"true\"/><FIELD name=\"relationship\">resultProject_outcome_isProducedBy</FIELD><FIELD name=\"id\">12</FIELD><FIELD name=\"provenance\">iis</FIELD><FIELD name=\"iis_status\">unsolved</FIELD><FIELD name=\"original_source_objects\" isNull=\"true\"/><FIELD name=\"creation_time\">2015-09-18 12:39:11.854513</FIELD><FIELD name=\"target_object\">corda_______::35695c955c51f0bb39482ce5477047c7</FIELD><FIELD name=\"note\" isNull=\"true\"/><FIELD name=\"source_object\">webcrawl____::ae0ae3ea5641ac24fa148ac38397dfcd</FIELD><FIELD name=\"source_type\">result</FIELD><FIELD name=\"target_type\">project</FIELD></ROW>"); |
|
23 |
input.add( |
|
24 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ROW><FIELD name=\"iis_module\">iis::document_referencedProjects</FIELD><FIELD name=\"ticket_id\">1297</FIELD><FIELD name=\"last_update_time\">2015-09-18 12:39:11.895653</FIELD><FIELD name=\"status\">accepted</FIELD><FIELD name=\"userid\">unknown</FIELD><FIELD name=\"iis_module_profile\" isNull=\"true\"/><FIELD name=\"original_target_objects\" isNull=\"true\"/><FIELD name=\"relationship\">resultProject_outcome_isProducedBy</FIELD><FIELD name=\"id\">17</FIELD><FIELD name=\"provenance\">iis</FIELD><FIELD name=\"iis_status\">unsolved</FIELD><FIELD name=\"original_source_objects\" isNull=\"true\"/><FIELD name=\"creation_time\">2015-09-18 12:39:11.895653</FIELD><FIELD name=\"target_object\">corda_______::35695c955c51f0bb39482ce5477047c7</FIELD><FIELD name=\"note\" isNull=\"true\"/><FIELD name=\"source_object\">webcrawl____::6ce2789da52c6036501533ed5613d71a</FIELD><FIELD name=\"source_type\">result</FIELD><FIELD name=\"target_type\">project</FIELD></ROW>"); |
|
25 |
input.add( |
|
26 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ROW><FIELD name=\"iis_module\">iis::document_referencedProjects</FIELD><FIELD name=\"ticket_id\">1360</FIELD><FIELD name=\"last_update_time\">2015-09-18 12:39:11.955417</FIELD><FIELD name=\"status\">accepted</FIELD><FIELD name=\"userid\">unknown</FIELD><FIELD name=\"iis_module_profile\" isNull=\"true\"/><FIELD name=\"original_target_objects\" isNull=\"true\"/><FIELD name=\"relationship\">resultProject_outcome_isProducedBy</FIELD><FIELD name=\"id\">23</FIELD><FIELD name=\"provenance\">iis</FIELD><FIELD name=\"iis_status\">unsolved</FIELD><FIELD name=\"original_source_objects\" isNull=\"true\"/><FIELD name=\"creation_time\">2015-09-18 12:39:11.955417</FIELD><FIELD name=\"target_object\">corda_______::800e636c0a24ac3767701a789a96ba89</FIELD><FIELD name=\"note\" isNull=\"true\"/><FIELD name=\"source_object\">od______2367::eb76f733498920166d4ce77ec37d487c</FIELD><FIELD name=\"source_type\">result</FIELD><FIELD name=\"target_type\">project</FIELD></ROW>"); |
|
27 |
|
|
28 |
blManager = new BlacklistManager(); |
|
29 |
} |
|
30 |
|
|
31 |
@Test |
|
32 |
public void testGetBlacklistIterator() { |
|
33 |
Iterable<BlacklistEntry> entries = this.blManager.getBlacklistIterable(input); |
|
34 |
for (BlacklistEntry e : entries) |
|
35 |
System.out.println(e); |
|
36 |
} |
|
37 |
|
|
38 |
@Test |
|
39 |
public void testFormat() { |
|
40 |
System.out.println(String.format("INSERT INTO blacklist(id, entitytype, pippo) VALUES('%2$s', '%1$s', '%2$s')", "the entity type", "the id")); |
|
41 |
} |
|
42 |
|
|
43 |
@Test |
|
44 |
public void testJoinForSQLArray() { |
|
45 |
List<String> list = Lists.newArrayList("one", "two", "three"); |
|
46 |
System.out.println("{\"" + StringUtils.join(list, "\",\"") + "\"}"); |
|
47 |
} |
|
48 |
} |
modules/dnet-openaire-blacklist/trunk/src/test/resources/log4j.properties | ||
---|---|---|
1 |
### Root Level ### |
|
2 |
log4j.rootLogger=WARN, CONSOLE |
|
3 |
|
|
4 |
|
|
5 |
### Configuration for the CONSOLE appender ### |
|
6 |
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender |
|
7 |
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout |
|
8 |
log4j.appender.CONSOLE.layout.ConversionPattern=[%-5p] %d %c - %m%n |
|
9 |
|
|
10 |
org.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger |
|
11 |
|
|
12 |
### Application Level ### |
|
13 |
log4j.logger.eu.dnetlib=INFO |
|
14 |
log4j.logger.eu.dnetlib.openaire.blacklist=DEBUG |
|
15 |
|
|
16 |
|
modules/dnet-openaire-blacklist/trunk/src/main/java/eu/dnetlib/msro/workflows/blacklist/ApplyBlacklistJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.blacklist; |
|
2 |
|
|
3 |
import java.io.StringReader; |
|
4 |
import java.util.List; |
|
5 |
import java.util.Map; |
|
6 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
7 |
|
|
8 |
import com.google.common.collect.Lists; |
|
9 |
import com.google.common.collect.Maps; |
|
10 |
import com.googlecode.sarasvati.Arc; |
|
11 |
import com.googlecode.sarasvati.NodeToken; |
|
12 |
import eu.dnetlib.data.hadoop.rmi.HadoopService; |
|
13 |
import eu.dnetlib.data.hadoop.rmi.HadoopServiceException; |
|
14 |
import eu.dnetlib.data.hadoop.rmi.hbase.Column; |
|
15 |
import eu.dnetlib.data.hadoop.rmi.hbase.HBaseRowDescriptor; |
|
16 |
import eu.dnetlib.data.mapreduce.util.OafRowKeyDecoder; |
|
17 |
import eu.dnetlib.data.transform.xml.AbstractDNetXsltFunctions; |
|
18 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
19 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
20 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
21 |
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory; |
|
22 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
23 |
import eu.dnetlib.openaire.blacklist.BlacklistManager; |
|
24 |
import org.apache.commons.lang.StringUtils; |
|
25 |
import org.apache.commons.logging.Log; |
|
26 |
import org.apache.commons.logging.LogFactory; |
|
27 |
import org.dom4j.Document; |
|
28 |
import org.dom4j.io.SAXReader; |
|
29 |
import org.springframework.beans.factory.annotation.Autowired; |
|
30 |
|
|
31 |
/** |
|
32 |
* Created by alessia on 23/10/15. |
|
33 |
*/ |
|
34 |
public class ApplyBlacklistJobNode extends SimpleJobNode { |
|
35 |
|
|
36 |
private static final Log log = LogFactory.getLog(ApplyBlacklistJobNode.class); |
|
37 |
|
|
38 |
@Autowired |
|
39 |
private BlacklistManager blacklistManager; |
|
40 |
|
|
41 |
@Autowired |
|
42 |
private UniqueServiceLocator serviceLocator; |
|
43 |
|
|
44 |
@Autowired |
|
45 |
private ResultSetClientFactory resultSetClientFactory; |
|
46 |
|
|
47 |
private String clusterName; |
|
48 |
|
|
49 |
private String tableName; |
|
50 |
|
|
51 |
@Override |
|
52 |
protected String execute(NodeToken token) throws Exception { |
|
53 |
final W3CEndpointReference epr = this.blacklistManager.getAcceptedBlacklistEntries(); |
|
54 |
final HadoopService hadoopService = serviceLocator.getService(HadoopService.class); |
|
55 |
|
|
56 |
final SAXReader r = new SAXReader(); |
|
57 |
|
|
58 |
final Map<String, String> relCache = Maps.newHashMap(); |
|
59 |
int count = 0; |
|
60 |
|
|
61 |
for(String s : resultSetClientFactory.getClient(epr)) { |
|
62 |
final Document doc = r.read(new StringReader(s)); |
|
63 |
|
|
64 |
if (log.isDebugEnabled()) { |
|
65 |
log.debug(doc.asXML()); |
|
66 |
} |
|
67 |
|
|
68 |
final ResolvedBlacklistEntry rbeRoot = new ResolvedBlacklistEntry(); |
|
69 |
|
|
70 |
final String source = fullId(doc.valueOf("//FIELD[./@name='source_type']"), doc.valueOf("//FIELD[./@name='source']")); |
|
71 |
rbeRoot.setSource(getResolvedId(source, hadoopService.describeHBaseColumn(getClusterName(), getTableName(), source).getColumns())); |
|
72 |
|
|
73 |
final String target = fullId(doc.valueOf("//FIELD[./@name='target_type']"), doc.valueOf("//FIELD[./@name='target']")); |
|
74 |
rbeRoot.setTarget(getResolvedId(target, hadoopService.describeHBaseColumn(getClusterName(), getTableName(), target).getColumns())); |
|
75 |
|
|
76 |
final String relType = doc.valueOf("//FIELD[./@name='relationship']"); |
|
77 |
rbeRoot.setRelType(relType); |
|
78 |
|
|
79 |
final ResolvedBlacklistEntry rbeNative = new ResolvedBlacklistEntry(source, target, relType); |
|
80 |
|
|
81 |
applyBlackListEntry(hadoopService, relCache, rbeRoot); |
|
82 |
applyBlackListEntry(hadoopService, relCache, rbeNative); |
|
83 |
|
|
84 |
count++; |
|
85 |
} |
|
86 |
|
|
87 |
log.info("blacklist size: " + count); |
|
88 |
token.getEnv().setAttribute("blacklistSize", count); |
|
89 |
|
|
90 |
return Arc.DEFAULT_ARC; |
|
91 |
} |
|
92 |
|
|
93 |
private void applyBlackListEntry(final HadoopService hadoopService, final Map<String, String> relCache, final ResolvedBlacklistEntry rbe) |
|
94 |
throws ISLookUpException, HadoopServiceException { |
|
95 |
if (!relCache.containsKey(rbe.getRelType())) { |
|
96 |
relCache.put(rbe.getRelType(), fetchInverse(rbe.getRelType())); |
|
97 |
} |
|
98 |
|
|
99 |
hadoopService.deleteHBaseColumn(getClusterName(), getTableName(), getHBaseRowDescriptor(rbe.getSource(), rbe.getTarget(), rbe.getRelType())); |
|
100 |
|
|
101 |
hadoopService.deleteHBaseColumn(getClusterName(), getTableName(), getHBaseRowDescriptor(rbe.getTarget(), rbe.getSource(), relCache.get( |
|
102 |
rbe.getRelType()))); |
|
103 |
} |
|
104 |
|
|
105 |
private HBaseRowDescriptor getHBaseRowDescriptor(final String source, final String target, final String relType) { |
|
106 |
|
|
107 |
final List<Column> cols = Lists.newArrayList(new Column(relType, Lists.newArrayList(target))); |
|
108 |
return new HBaseRowDescriptor(source, cols); |
|
109 |
} |
|
110 |
|
|
111 |
private String fetchInverse(final String relType) throws ISLookUpException { |
|
112 |
final String xquery = "let $x:= /RESOURCE_PROFILE[" |
|
113 |
+ " .//RESOURCE_TYPE/@value = 'OntologyDSResourceType' and " |
|
114 |
+ " .//TERM/@encoding='"+relType+"']" |
|
115 |
+ "let $y:= $x//TERM[./@encoding='"+relType+"']//RELATION[./@type='inverseOf']/@code/string() " |
|
116 |
+ "return $x//TERM[./@code = $y]/@encoding/string()"; |
|
117 |
return serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xquery); |
|
118 |
} |
|
119 |
|
|
120 |
private String fullId(final String type, final String id) { |
|
121 |
final String fullId = AbstractDNetXsltFunctions.oafSimpleId(type, id); |
|
122 |
|
|
123 |
return OafRowKeyDecoder.decode(fullId).getKey(); |
|
124 |
} |
|
125 |
|
|
126 |
private String getResolvedId(String originalId, List<Column> columns) { |
|
127 |
if (StringUtils.isBlank(originalId)) { |
|
128 |
throw new IllegalArgumentException("cannot resolve an empty id"); |
|
129 |
} |
|
130 |
|
|
131 |
for (Column c : columns) { |
|
132 |
if (c.getFamily().contains("isMergedIn")) { |
|
133 |
|
|
134 |
for (String s : c.getQualifier()) { |
|
135 |
if (StringUtils.isNotBlank(s)) return s; |
|
136 |
} |
|
137 |
} |
|
138 |
} |
|
139 |
return originalId; |
|
140 |
} |
|
141 |
|
|
142 |
public String getClusterName() { |
|
143 |
return clusterName; |
|
144 |
} |
|
145 |
|
|
146 |
public void setClusterName(final String clusterName) { |
|
147 |
this.clusterName = clusterName; |
|
148 |
} |
|
149 |
|
|
150 |
public String getTableName() { |
|
151 |
return tableName; |
|
152 |
} |
|
153 |
|
|
154 |
public void setTableName(final String tableName) { |
|
155 |
this.tableName = tableName; |
|
156 |
} |
|
157 |
|
|
158 |
} |
modules/dnet-openaire-blacklist/trunk/src/main/java/eu/dnetlib/msro/workflows/blacklist/ResolvedBlacklistEntry.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.blacklist; |
|
2 |
|
|
3 |
import com.google.common.base.Objects; |
|
4 |
import com.google.gson.Gson; |
|
5 |
|
|
6 |
/** |
|
7 |
* Created by alessia on 26/10/15. |
|
8 |
*/ |
|
9 |
public class ResolvedBlacklistEntry { |
|
10 |
|
|
11 |
private String source; |
|
12 |
|
|
13 |
private String target; |
|
14 |
|
|
15 |
private String relType; |
|
16 |
|
|
17 |
public ResolvedBlacklistEntry() { |
|
18 |
} |
|
19 |
|
|
20 |
public ResolvedBlacklistEntry(final String source, final String target, final String relType) { |
|
21 |
this.source = source; |
|
22 |
this.target = target; |
|
23 |
this.relType = relType; |
|
24 |
} |
|
25 |
|
|
26 |
public static ResolvedBlacklistEntry fromJson(String json) { |
|
27 |
return new Gson().fromJson(json, ResolvedBlacklistEntry.class); |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
public String toString() { |
|
32 |
return new Gson().toJson(this); |
|
33 |
} |
|
34 |
|
|
35 |
public String getSource() { |
|
36 |
return source; |
|
37 |
} |
|
38 |
|
|
39 |
public void setSource(String source) { |
|
40 |
this.source = source; |
|
41 |
} |
|
42 |
|
|
43 |
public String getTarget() { |
|
44 |
return target; |
|
45 |
} |
|
46 |
|
|
47 |
public void setTarget(String target) { |
|
48 |
this.target = target; |
|
49 |
} |
|
50 |
|
|
51 |
public String getRelType() { |
|
52 |
return relType; |
|
53 |
} |
|
54 |
|
|
55 |
public void setRelType(String relType) { |
|
56 |
this.relType = relType; |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public boolean equals(Object another) { |
|
61 |
if (!(another instanceof ResolvedBlacklistEntry)) return false; |
|
62 |
final ResolvedBlacklistEntry rbe = (ResolvedBlacklistEntry) another; |
|
63 |
return Objects.equal(getSource(), rbe.getSource()) && Objects.equal(getTarget(), rbe.getTarget()) && Objects.equal(getRelType(), rbe.getRelType()); |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
public int hashCode() { |
|
68 |
return Objects.hashCode(getSource(), getTarget(), getRelType()); |
|
69 |
} |
|
70 |
|
|
71 |
} |
modules/dnet-openaire-blacklist/trunk/src/main/java/eu/dnetlib/openaire/blacklist/OpenaireIdResolver.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.blacklist; |
|
2 |
|
|
3 |
import java.io.StringReader; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.apache.commons.lang.StringUtils; |
|
7 |
import org.apache.commons.logging.Log; |
|
8 |
import org.apache.commons.logging.LogFactory; |
|
9 |
import org.apache.solr.client.solrj.SolrQuery; |
|
10 |
import org.apache.solr.client.solrj.impl.CloudSolrServer; |
|
11 |
import org.apache.solr.client.solrj.response.QueryResponse; |
|
12 |
import org.apache.solr.common.SolrDocument; |
|
13 |
import org.apache.solr.common.SolrDocumentList; |
|
14 |
import org.dom4j.Attribute; |
|
15 |
import org.dom4j.Document; |
|
16 |
import org.dom4j.DocumentException; |
|
17 |
import org.dom4j.io.SAXReader; |
|
18 |
import org.springframework.beans.factory.annotation.Autowired; |
|
19 |
|
|
20 |
import com.google.common.base.Function; |
|
21 |
import com.google.common.collect.Iterables; |
|
22 |
import com.google.common.collect.Lists; |
|
23 |
|
|
24 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
25 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
26 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
27 |
|
|
28 |
/** |
|
29 |
* The goal of this task is to return the original identifiers of objects merged in a representative object by deduplication. Created by |
|
30 |
* alessia on 09/02/16. |
|
31 |
*/ |
|
32 |
public class OpenaireIdResolver { |
|
33 |
|
|
34 |
public final static String SOLR_COLLECTION_POSTFIX = "-index-openaire"; |
|
35 |
private static final Log log = LogFactory.getLog(OpenaireIdResolver.class); |
|
36 |
private final static String RESULT_FIELD = "__result"; |
|
37 |
private final static String XPATH_TO_MERGED = "//*[local-name()='entity']/*//children/result/@objidentifier"; |
|
38 |
private final SAXReader saxReader = new SAXReader(); |
|
39 |
@Autowired |
|
40 |
private UniqueServiceLocator serviceLocator; |
|
41 |
|
|
42 |
public List<String> resolveIdentifier(final String id) { |
|
43 |
if (StringUtils.isBlank(id)) return Lists.newArrayList(); |
|
44 |
else { |
|
45 |
return findOriginalIds(id); |
|
46 |
} |
|
47 |
} |
|
48 |
|
|
49 |
protected List<String> findOriginalIds(final String id) { |
|
50 |
CloudSolrServer solrCore = null; |
|
51 |
final SolrQuery q = new SolrQuery("objidentifier:\"" + id + "\""); |
|
52 |
QueryResponse response = null; |
|
53 |
try { |
|
54 |
solrCore = new CloudSolrServer(getIndexEndpoint()); |
|
55 |
solrCore.setDefaultCollection(getPublicIndexCollection() + SOLR_COLLECTION_POSTFIX); |
|
56 |
response = solrCore.query(q); |
|
57 |
final SolrDocumentList results = response.getResults(); |
|
58 |
if (results.isEmpty()) { |
|
59 |
log.debug("Query " + q + " returned 0 documents"); |
|
60 |
return Lists.newArrayList(); |
|
61 |
} |
|
62 |
// my results contain the document with the given identifier |
|
63 |
final SolrDocument solrDoc = results.get(0); |
|
64 |
return extractMergedIdentifiers(solrDoc); |
|
65 |
} catch (final Exception e) { |
|
66 |
log.error("Can't get original ids for " + id + "\n ", e); |
|
67 |
throw new RuntimeException("Can't get original ids for " + id + "\n " + e); |
|
68 |
} finally { |
|
69 |
solrCore.shutdown(); |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
@SuppressWarnings("unchecked") |
|
74 |
protected List<String> extractMergedIdentifiers(final SolrDocument doc) throws DocumentException { |
|
75 |
final String xmlRecord = (String) doc.getFirstValue(RESULT_FIELD); |
|
76 |
final Document xmlDoc = this.saxReader.read(new StringReader(xmlRecord)); |
|
77 |
return Lists.newArrayList(Iterables.transform(xmlDoc.selectNodes(XPATH_TO_MERGED), new Function<Attribute, String>() { |
|
78 |
|
|
79 |
@Override |
|
80 |
public String apply(final Attribute a) { |
|
81 |
return a.getStringValue(); |
|
82 |
} |
|
83 |
})); |
|
84 |
} |
|
85 |
|
|
86 |
protected String getIndexEndpoint() throws ISLookUpException { |
|
87 |
return this.serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery( |
|
88 |
"for $x in collection('/db/DRIVER/ServiceResources/IndexServiceResourceType') return $x//PROTOCOL[./@name='solr']/@address/string()"); |
|
89 |
} |
|
90 |
|
|
91 |
protected String getPublicIndexCollection() throws ISLookUpException { |
|
92 |
return this.serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery( |
|
93 |
"for $x in collection('/db/DRIVER/ServiceResources/SearchServiceResourceType') return $x[.//PROPERTY[@key='infrastructure']/@value='public']//PROPERTY[@key='mdformat']/@value/string()"); |
|
94 |
} |
|
95 |
|
|
96 |
public UniqueServiceLocator getServiceLocator() { |
|
97 |
return serviceLocator; |
|
98 |
} |
|
99 |
|
|
100 |
public void setServiceLocator(final UniqueServiceLocator serviceLocator) { |
|
101 |
this.serviceLocator = serviceLocator; |
|
102 |
} |
|
103 |
|
|
104 |
} |
modules/dnet-openaire-blacklist/trunk/src/main/java/eu/dnetlib/openaire/blacklist/BlacklistManager.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.blacklist; |
|
2 |
|
|
3 |
import java.io.StringReader; |
|
4 |
import java.util.Collection; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Set; |
|
7 |
|
|
8 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
9 |
|
|
10 |
import org.apache.commons.lang.StringUtils; |
|
11 |
import org.apache.commons.logging.Log; |
|
12 |
import org.apache.commons.logging.LogFactory; |
|
13 |
import org.dom4j.Document; |
|
14 |
import org.dom4j.DocumentException; |
|
15 |
import org.dom4j.Element; |
|
16 |
import org.dom4j.io.SAXReader; |
|
17 |
import org.springframework.beans.factory.annotation.Autowired; |
|
18 |
import org.springframework.beans.factory.annotation.Value; |
|
19 |
|
|
20 |
import com.google.common.collect.Lists; |
|
21 |
|
|
22 |
import eu.dnetlib.enabling.database.rmi.DatabaseException; |
|
23 |
import eu.dnetlib.enabling.database.rmi.DatabaseService; |
|
24 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
25 |
import eu.dnetlib.enabling.resultset.client.IterableResultSetClient; |
|
26 |
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory; |
|
27 |
import eu.dnetlib.miscutils.collections.MappedCollection; |
|
28 |
import eu.dnetlib.miscutils.functional.UnaryFunction; |
|
29 |
import eu.dnetlib.openaire.hadoop.utils.HBaseTableUtils; |
|
30 |
|
|
31 |
public class BlacklistManager { |
|
32 |
|
|
33 |
private static final Log log = LogFactory.getLog(BlacklistManager.class); // NOPMD by marko on 11/24/08 5:02 PM |
|
34 |
@Value("${dnet.openaire.blacklist.db.name}") |
|
35 |
private String blacklistDatabaseName; |
|
36 |
@Autowired |
|
37 |
private UniqueServiceLocator serviceLocator; |
|
38 |
@Autowired |
|
39 |
private ResultSetClientFactory resultSetClientFactory; |
|
40 |
@Autowired |
|
41 |
private OpenaireIdResolver openaireIdResolver; |
|
42 |
|
|
43 |
private List<String> getOriginalIds(final String id, final String entityType) { |
|
44 |
List<String> originalIds = Lists.newArrayList(); |
|
45 |
// We need to find original ids only for entities that are deduplicated: result, organization, person. |
|
46 |
if (entityType.equals("result") || entityType.equals("organization") || entityType.equals("person")) { |
|
47 |
originalIds = openaireIdResolver.resolveIdentifier(id); |
|
48 |
} |
|
49 |
return originalIds; |
|
50 |
} |
|
51 |
|
|
52 |
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); |
|
57 |
|
|
58 |
final DatabaseService dbService = serviceLocator.getService(DatabaseService.class); |
|
59 |
final String addQuery = String.format( |
|
60 |
"INSERT INTO blacklist(userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, " |
|
61 |
+ "ticket_id, original_source_objects, original_target_objects, note) " |
|
62 |
+ " VALUES(%1$s, %2$s, %3$s, %4$s, %5$s, %6$s, %7$s, %8$s, %9$s, %10$s, %11$s, %12$s, %13$s, %14$s)", |
|
63 |
asSqlParam(entry.getUser()), |
|
64 |
asSqlParam(entry.getRelationship()), |
|
65 |
asSqlParam(entry.getProvenance()), |
|
66 |
asSqlParam(entry.getIisModule()), |
|
67 |
asSqlParam(entry.getIisStatus()), |
|
68 |
asSqlParam(entry.getStatus()), |
|
69 |
asSqlParam(entry.getSourceObject()), |
|
70 |
asSqlParam(entry.getSourceType()), |
|
71 |
asSqlParam(entry.getTargetObject()), |
|
72 |
asSqlParam(entry.getTargetType()), |
|
73 |
asSqlParam(entry.getTicketId()), |
|
74 |
asSqlParam(joinCollectionForSQL(sourceIds.isEmpty() ? Lists.newArrayList(entry.getSourceObject()) : sourceIds)), |
|
75 |
asSqlParam(joinCollectionForSQL(targetIds.isEmpty() ? Lists.newArrayList(entry.getTargetObject()) : targetIds)), |
|
76 |
asSqlParam(entry.getNote())); |
|
77 |
log.debug("Adding new blacklist entry"); |
|
78 |
this.safeUpdateSql(dbService, blacklistDatabaseName, addQuery); |
|
79 |
} |
|
80 |
|
|
81 |
private String joinCollectionForSQL(final Collection<String> coll) { |
|
82 |
return "{\"" + StringUtils.join(coll, "\",\"") + "\"}"; |
|
83 |
} |
|
84 |
|
|
85 |
public void editBlacklistEntry(final BlacklistEntry entry) throws DatabaseException { |
|
86 |
|
|
87 |
final DatabaseService dbService = serviceLocator.getService(DatabaseService.class); |
|
88 |
final String editQuery = String.format( |
|
89 |
"UPDATE blacklist SET userid=%s, relationship=%s, provenance=%s, iis_module=%s, iis_status=%s, status=%s, source_type=%s, " |
|
90 |
+ "target_type=%s, ticket_id=%s, note=%s WHERE id=%s", |
|
91 |
asSqlParam(entry.getUser()), |
|
92 |
asSqlParam(entry.getRelationship()), |
|
93 |
asSqlParam(entry.getProvenance()), |
|
94 |
asSqlParam(entry.getIisModule()), |
|
95 |
asSqlParam(entry.getIisStatus()), |
|
96 |
asSqlParam(entry.getStatus()), |
|
97 |
asSqlParam(entry.getSourceType()), |
|
98 |
asSqlParam(entry.getTargetType()), |
|
99 |
asSqlParam(entry.getTicketId()), |
|
100 |
asSqlParam(entry.getNote()), |
|
101 |
asSqlParam(entry.getId())); |
|
102 |
log.debug("Editing blacklist entry: " + entry.getId()); |
|
103 |
this.safeUpdateSql(dbService, blacklistDatabaseName, editQuery); |
|
104 |
} |
|
105 |
|
|
106 |
private String asSqlParam(final Object o) { |
|
107 |
if (o == null) { |
|
108 |
return "NULL"; |
|
109 |
} else if ((o instanceof Number) || (o instanceof Boolean)) { |
|
110 |
return o.toString(); |
|
111 |
} else { |
|
112 |
return "'" + o.toString() + "'"; |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
public void deleteFromBlacklist(final int entryId) throws DatabaseException { |
|
117 |
final DatabaseService dbService = serviceLocator.getService(DatabaseService.class); |
|
118 |
log.debug("Deleting entry " + entryId + " from blacklist"); |
|
119 |
this.safeUpdateSql(dbService, blacklistDatabaseName, String.format("DELETE FROM blacklist WHERE id='%s' ", entryId)); |
|
120 |
} |
|
121 |
|
|
122 |
public Iterable<BlacklistEntry> getBlacklist() throws DatabaseException { |
|
123 |
final String sqlQuery = "SELECT * from blacklist order by ticket_id"; |
|
124 |
final W3CEndpointReference epr = serviceLocator.getService(DatabaseService.class).searchSQL(blacklistDatabaseName, sqlQuery); |
|
125 |
final IterableResultSetClient iter = resultSetClientFactory.getClient(epr); |
|
126 |
return this.getBlacklistIterable(iter); |
|
127 |
} |
|
128 |
|
|
129 |
public W3CEndpointReference getAcceptedBlacklistEntries() throws DatabaseException { |
|
130 |
final String sqlQuery = |
|
131 |
"SELECT source_type, unnest(original_source_objects) as source, target_type, unnest(original_target_objects) as target, relationship FROM blacklist WHERE status = 'ACCEPTED'"; |
|
132 |
return serviceLocator.getService(DatabaseService.class).searchSQL(blacklistDatabaseName, sqlQuery); |
|
133 |
} |
|
134 |
|
|
135 |
private void safeUpdateSql(final DatabaseService dbService, final String dbName, final String sql) throws DatabaseException { |
|
136 |
log.info(sql); |
|
137 |
dbService.updateSQL(dbName, sql); |
|
138 |
} |
|
139 |
|
|
140 |
public Iterable<BlacklistEntry> getBlacklistIterable(final Iterable<String> xmlEntries) { |
|
141 |
return new MappedCollection<BlacklistEntry, String>(xmlEntries, new UnaryFunction<BlacklistEntry, String>() { |
|
142 |
|
|
143 |
@Override |
|
144 |
public BlacklistEntry evaluate(final String dbEntry) { |
|
145 |
final SAXReader saxReader = new SAXReader(); |
|
146 |
final BlacklistEntry be = new BlacklistEntry(); |
|
147 |
Document doc; |
|
148 |
try { |
|
149 |
doc = saxReader.read(new StringReader(dbEntry)); |
|
150 |
be.setId(Integer.parseInt(doc.selectSingleNode("//FIELD[./@name='id']").getText())); |
|
151 |
be.setCreationDate(doc.selectSingleNode("//FIELD[./@name='creation_time']").getText()); |
|
152 |
be.setLastUpdateDate(doc.selectSingleNode("//FIELD[./@name='last_update_time']").getText()); |
|
153 |
be.setNote(doc.selectSingleNode("//FIELD[./@name='note']").getText()); |
|
154 |
be.setRelationship(doc.selectSingleNode(".//FIELD[./@name='relationship']").getText()); |
|
155 |
be.setStatus(STATUS.valueOf(StringUtils.upperCase(doc.selectSingleNode("//FIELD[./@name='status']").getText()))); |
|
156 |
be.setTicketId(doc.selectSingleNode("//FIELD[./@name='ticket_id']").getText()); |
|
157 |
be.setUser(doc.selectSingleNode("//FIELD[./@name='userid']").getText()); |
|
158 |
be.setSourceObject(doc.selectSingleNode("//FIELD[./@name='source_object']").getText()); |
|
159 |
be.setSourceType(doc.selectSingleNode("//FIELD[./@name='source_type']").getText()); |
|
160 |
be.setTargetObject(doc.selectSingleNode("//FIELD[./@name='target_object']").getText()); |
|
161 |
be.setTargetType(doc.selectSingleNode("//FIELD[./@name='target_type']").getText()); |
|
162 |
final String provenance = doc.selectSingleNode("//FIELD[./@name='provenance']").getText(); |
|
163 |
be.setProvenance(provenance); |
|
164 |
if (provenance.equalsIgnoreCase("iis")) { |
|
165 |
be.setIisModule(doc.selectSingleNode("//FIELD[./@name='iis_module']").getText()); |
|
166 |
be.setIisStatus(IIS_STATUS.valueOf(StringUtils.upperCase(doc.selectSingleNode("//FIELD[./@name='iis_status']").getText()))); |
|
167 |
} |
|
168 |
// get the array of original identifiers |
|
169 |
final List<Element> sources = doc.selectNodes("//FIELD[./@name='original_source_objects']/ITEM"); |
|
170 |
if ((sources != null) && !sources.isEmpty()) { |
|
171 |
for (final Element e : sources) { |
|
172 |
be.getOriginalSourceObjects().add(e.getText()); |
|
173 |
} |
|
174 |
} |
|
175 |
|
|
176 |
final List<Element> targets = doc.selectNodes("//FIELD[./@name='original_target_objects']/ITEM"); |
|
177 |
if ((targets != null) && !targets.isEmpty()) { |
|
178 |
for (final Element e : targets) { |
|
179 |
be.getOriginalTargetObjects().add(e.getText()); |
|
180 |
} |
|
181 |
} |
|
182 |
} catch (final DocumentException e) { |
|
183 |
log.error(e); |
|
184 |
throw new RuntimeException(e); |
|
185 |
} |
|
186 |
return be; |
|
187 |
} |
|
188 |
}); |
|
189 |
} |
|
190 |
|
|
191 |
public Set<String> getListOfRelationships() { |
|
192 |
return HBaseTableUtils.listRelationships(); |
|
193 |
} |
|
194 |
|
|
195 |
public enum IIS_STATUS { |
|
196 |
UNSOLVED, SOLVED |
|
197 |
} |
|
198 |
|
|
199 |
public enum STATUS { |
|
200 |
PENDING, ACCEPTED, REFUSED, DELETED |
|
201 |
} |
|
202 |
|
|
203 |
} |
modules/dnet-openaire-blacklist/trunk/src/main/java/eu/dnetlib/openaire/blacklist/BlacklistEntry.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.blacklist; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import com.google.common.collect.Lists; |
|
6 |
import com.google.gson.Gson; |
|
7 |
import eu.dnetlib.openaire.blacklist.BlacklistManager.IIS_STATUS; |
|
8 |
import eu.dnetlib.openaire.blacklist.BlacklistManager.STATUS; |
|
9 |
|
|
10 |
public class BlacklistEntry { |
|
11 |
|
|
12 |
|
|
13 |
private int id; |
|
14 |
/** |
|
15 |
* The user who reported the wrong link |
|
16 |
**/ |
|
17 |
private String user = "unknown"; |
|
18 |
/** |
|
19 |
* A note regarding the reported 'wrong' relationship |
|
20 |
**/ |
|
21 |
private String note = ""; |
|
22 |
/** |
|
23 |
* The id of the ticket associated to this entry |
|
24 |
**/ |
|
25 |
private String ticketId = "unknown"; |
|
26 |
/** |
|
27 |
* Provenance of the relationship. 'iis' when the relationship is inferred. 'crosswalk' if it is aggregated. 'claim' if it is a claim. |
|
28 |
**/ |
|
29 |
private String provenance; |
|
30 |
/** |
|
31 |
* Relationship label: 'resultProject_outcome_isProducedBy' for result-project relationships. |
|
32 |
*/ |
|
33 |
private String relationship; |
|
34 |
|
|
35 |
/** |
|
36 |
* The inference module that generated the relationship. 'iis::document_referencedProjects' for result-project relationships. Blank if provenance is not 'iis'. |
|
37 |
**/ |
|
38 |
private String iisModule = ""; |
|
39 |
|
|
40 |
/** |
|
41 |
* Status of the report |
|
42 |
**/ |
|
43 |
private STATUS status = STATUS.PENDING; |
|
44 |
/** |
|
45 |
* Status of the issue from the pov of IIS. Blank if provenance is not 'iis'. |
|
46 |
**/ |
|
47 |
private IIS_STATUS iisStatus = null; |
|
48 |
|
|
49 |
private String creationDate, lastUpdateDate; |
|
50 |
|
|
51 |
/** |
|
52 |
* OpenAIRE ids of the objects linked by the 'wrong' relationship |
|
53 |
**/ |
|
54 |
private String sourceObject, targetObject; |
|
55 |
/** |
|
56 |
* Type of the source and target objects. |
|
57 |
**/ |
|
58 |
private String sourceType, targetType; |
|
59 |
/** |
|
60 |
* If the source or the target are representatives, then the following strings are not empty and contain the json strings with the ids of the merged objects |
|
61 |
**/ |
|
62 |
private List<String> originalSourceObjects = Lists.newArrayList(), originalTargetObjects = Lists.newArrayList(); |
|
63 |
|
|
64 |
@Override |
|
65 |
public String toString() { |
|
66 |
Gson gson = new Gson(); |
|
67 |
return gson.toJson(this); |
|
68 |
} |
|
69 |
|
|
70 |
public String getRelationship() { |
|
71 |
return relationship; |
|
72 |
} |
|
73 |
|
|
74 |
public void setRelationship(final String relationship) { |
|
75 |
this.relationship = relationship; |
|
76 |
} |
|
77 |
|
|
78 |
public String getSourceType() { |
|
79 |
return sourceType; |
|
80 |
} |
|
81 |
|
|
82 |
public void setSourceType(final String sourceType) { |
|
83 |
this.sourceType = sourceType; |
|
84 |
} |
|
85 |
|
|
86 |
public String getTargetType() { |
|
87 |
return targetType; |
|
88 |
} |
|
89 |
|
|
90 |
public void setTargetType(final String targetType) { |
|
91 |
this.targetType = targetType; |
|
92 |
} |
|
93 |
|
|
94 |
public int getId() { |
|
95 |
return id; |
|
96 |
} |
|
97 |
|
|
98 |
public void setId(int id) { |
|
99 |
this.id = id; |
|
100 |
} |
|
101 |
|
|
102 |
public String getUser() { |
|
103 |
return user; |
|
104 |
} |
|
105 |
|
|
106 |
public void setUser(final String user) { |
|
107 |
this.user = user; |
|
108 |
} |
|
109 |
|
|
110 |
public String getNote() { |
|
111 |
return note; |
|
112 |
} |
|
113 |
|
|
114 |
public void setNote(final String note) { |
|
115 |
this.note = note; |
|
116 |
} |
|
117 |
|
|
118 |
public String getTicketId() { |
|
119 |
return ticketId; |
|
120 |
} |
|
121 |
|
|
122 |
public void setTicketId(final String ticketId) { |
|
123 |
this.ticketId = ticketId; |
|
124 |
} |
|
125 |
|
|
126 |
public String getProvenance() { |
|
127 |
return provenance; |
|
128 |
} |
|
129 |
|
|
130 |
public void setProvenance(final String provenance) { |
|
131 |
this.provenance = provenance; |
|
132 |
} |
|
133 |
|
|
134 |
public String getIisModule() { |
|
135 |
return iisModule; |
|
136 |
} |
|
137 |
|
|
138 |
public void setIisModule(final String iisModule) { |
|
139 |
this.iisModule = iisModule; |
|
140 |
} |
|
141 |
|
|
142 |
public STATUS getStatus() { |
|
143 |
return status; |
|
144 |
} |
|
145 |
|
|
146 |
public void setStatus(final STATUS status) { |
|
147 |
this.status = status; |
|
148 |
} |
|
149 |
|
|
150 |
public IIS_STATUS getIisStatus() { |
|
151 |
return iisStatus; |
|
152 |
} |
|
153 |
|
|
154 |
public void setIisStatus(final IIS_STATUS iisStatus) { |
|
155 |
this.iisStatus = iisStatus; |
|
156 |
} |
|
157 |
|
|
158 |
public String getCreationDate() { |
|
159 |
return creationDate; |
|
160 |
} |
|
161 |
|
|
162 |
public void setCreationDate(final String creationDate) { |
|
163 |
this.creationDate = creationDate; |
|
164 |
} |
|
165 |
|
|
166 |
public String getLastUpdateDate() { |
|
167 |
return lastUpdateDate; |
|
168 |
} |
|
169 |
|
|
170 |
public void setLastUpdateDate(final String lastUpdateDate) { |
|
171 |
this.lastUpdateDate = lastUpdateDate; |
|
172 |
} |
|
173 |
|
|
174 |
public String getSourceObject() { |
|
175 |
return sourceObject; |
|
176 |
} |
|
177 |
|
|
178 |
public void setSourceObject(final String sourceObject) { |
|
179 |
this.sourceObject = sourceObject; |
|
180 |
} |
|
181 |
|
|
182 |
public String getTargetObject() { |
|
183 |
return targetObject; |
|
184 |
} |
|
185 |
|
|
186 |
public void setTargetObject(final String targetObject) { |
|
187 |
this.targetObject = targetObject; |
|
188 |
} |
|
189 |
|
|
190 |
public List<String> getOriginalSourceObjects() { |
|
191 |
return originalSourceObjects; |
|
192 |
} |
|
193 |
|
|
194 |
public void setOriginalSourceObjects(final List<String> originalSourceObjects) { |
|
195 |
this.originalSourceObjects = originalSourceObjects; |
|
196 |
} |
|
197 |
|
|
198 |
public List<String> getOriginalTargetObjects() { |
|
199 |
return originalTargetObjects; |
|
200 |
} |
|
201 |
|
|
202 |
public void setOriginalTargetObjects(final List<String> originalTargetObjects) { |
|
203 |
this.originalTargetObjects = originalTargetObjects; |
|
204 |
} |
|
205 |
|
|
206 |
} |
modules/dnet-openaire-blacklist/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/blacklist/BlacklistEntryPointController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.blacklist; |
|
2 |
|
|
3 |
import javax.servlet.http.HttpServletRequest; |
|
4 |
import javax.servlet.http.HttpServletResponse; |
|
5 |
|
|
6 |
import org.springframework.ui.ModelMap; |
|
7 |
|
|
8 |
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint; |
|
9 |
|
|
10 |
/** |
|
11 |
* Created by alessia on 18/09/15. |
|
12 |
*/ |
|
13 |
public class BlacklistEntryPointController extends ModuleEntryPoint { |
|
14 |
|
|
15 |
@Override |
|
16 |
protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {} |
|
17 |
|
|
18 |
} |
modules/dnet-openaire-blacklist/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/blacklist/BlacklistInternalController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.blacklist; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.Set; |
|
5 |
import javax.annotation.Resource; |
|
6 |
|
|
7 |
import com.google.common.collect.Lists; |
|
8 |
import eu.dnetlib.enabling.database.rmi.DatabaseException; |
|
9 |
import eu.dnetlib.functionality.modular.ui.AbstractAjaxController; |
|
10 |
import eu.dnetlib.openaire.blacklist.BlacklistEntry; |
|
11 |
import eu.dnetlib.openaire.blacklist.BlacklistManager; |
|
12 |
import org.apache.commons.logging.Log; |
|
13 |
import org.apache.commons.logging.LogFactory; |
|
14 |
import org.springframework.stereotype.Controller; |
|
15 |
import org.springframework.web.bind.annotation.RequestBody; |
|
16 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
17 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
18 |
|
|
19 |
/** |
|
20 |
* Created by alessia on 18/09/15. |
|
21 |
*/ |
|
22 |
@Controller |
|
23 |
public class BlacklistInternalController extends AbstractAjaxController { |
|
24 |
|
|
25 |
private static final Log log = LogFactory.getLog(BlacklistInternalController.class); // NOPMD by marko on 11/24/08 5:02 PM |
|
26 |
|
|
27 |
@Resource |
|
28 |
private BlacklistManager blacklistManager; |
|
29 |
|
|
30 |
@ResponseBody |
|
31 |
@RequestMapping(value = "/ui/blacklist/getBlacklist.do") |
|
32 |
public List<BlacklistEntry> getBlacklist() throws DatabaseException { |
|
33 |
log.debug("getBlacklist"); |
|
34 |
return Lists.newArrayList(this.blacklistManager.getBlacklist()); |
|
35 |
} |
|
36 |
|
|
37 |
@ResponseBody |
|
38 |
@RequestMapping(value = "/ui/blacklist/addToBlacklist.do") |
|
39 |
public void addToBlacklist(@RequestBody(required = true) final BlacklistEntry entry) throws DatabaseException { |
|
40 |
log.debug("addToBlacklist"); |
|
41 |
this.blacklistManager.addToBlacklist(entry); |
|
42 |
} |
|
43 |
|
|
44 |
@ResponseBody |
|
45 |
@RequestMapping(value = "/ui/blacklist/editBlacklistEntry.do") |
|
46 |
public void editBlacklistEntry(@RequestBody(required = true) final BlacklistEntry entry) throws DatabaseException { |
|
47 |
log.debug("editing blacklist entry " + entry.getId()); |
|
48 |
this.blacklistManager.editBlacklistEntry(entry); |
|
49 |
} |
|
50 |
|
|
51 |
@ResponseBody |
|
52 |
@RequestMapping(value = "/ui/blacklist/deleteFromBlacklist.do") |
|
53 |
public void deleteFromBlacklist(@RequestBody(required = true) final int entryId) throws DatabaseException { |
|
54 |
log.debug("deleting blacklist entry " + entryId); |
|
55 |
this.blacklistManager.deleteFromBlacklist(entryId); |
|
56 |
} |
|
57 |
|
|
58 |
@ResponseBody |
|
59 |
@RequestMapping(value = "/ui/blacklist/getListOfRelationships.do") |
|
60 |
public Set<String> getListOfRelationships() throws DatabaseException { |
|
61 |
return this.blacklistManager.getListOfRelationships(); |
|
62 |
} |
|
63 |
|
|
64 |
} |
modules/dnet-openaire-blacklist/trunk/src/main/resources/eu/dnetlib/applicationContext-dnet-openaire-blacklist.properties | ||
---|---|---|
1 |
dnet.openaire.blacklist.db.name=dnet_openaire_blacklist |
modules/dnet-openaire-blacklist/trunk/src/main/resources/eu/dnetlib/openaire/blacklist/db/dnet_blacklists_data.sql | ||
---|---|---|
1 |
CREATE TYPE IIS_STATUS AS ENUM ('UNSOLVED', 'SOLVED'); |
|
2 |
CREATE TYPE STATUS AS ENUM ('PENDING', 'ACCEPTED', 'REFUSED', 'DELETED'); |
|
3 |
|
|
4 |
CREATE TABLE blacklist ( |
|
5 |
id SERIAL, |
|
6 |
source_object CHARACTER VARYING(255) NOT NULL, |
|
7 |
target_object CHARACTER VARYING(255) NOT NULL, |
|
8 |
|
|
9 |
source_type CHARACTER VARYING(255) NOT NULL, |
|
10 |
target_type CHARACTER VARYING(255) NOT NULL, |
|
11 |
|
|
12 |
relationship CHARACTER VARYING(255) NOT NULL, |
|
13 |
|
|
14 |
provenance CHARACTER VARYING(255) NOT NULL, |
|
15 |
iis_module CHARACTER VARYING(255), |
|
16 |
iis_module_profile CHARACTER VARYING(255), |
|
17 |
|
|
18 |
iis_status IIS_STATUS, |
|
19 |
status STATUS NOT NULL, |
|
20 |
|
|
21 |
original_source_objects CHARACTER VARYING(255) ARRAY, |
|
22 |
original_target_objects CHARACTER VARYING(255) ARRAY, |
|
23 |
|
|
24 |
creation_time TIMESTAMP DEFAULT now(), |
|
25 |
last_update_time TIMESTAMP DEFAULT now(), |
|
26 |
|
|
27 |
note TEXT, |
|
28 |
ticket_id CHARACTER VARYING(255), |
|
29 |
userid CHARACTER VARYING(255) NOT NULL, |
|
30 |
|
|
31 |
PRIMARY KEY (source_object, target_object, relationship) |
|
32 |
|
|
33 |
); |
|
34 |
|
|
35 |
CREATE INDEX ON blacklist (source_object); |
|
36 |
CREATE INDEX ON blacklist (target_object); |
|
37 |
CREATE INDEX ON blacklist (ticket_id, original_source_objects, original_target_objects); |
|
38 |
CREATE INDEX ON blacklist (iis_status); |
|
39 |
CREATE INDEX ON blacklist (status); |
|
40 |
|
|
41 |
--TRIGGER TO UPDATE THE last_update_time on UPDATES |
|
42 |
CREATE OR REPLACE FUNCTION update_modified_column() |
|
43 |
RETURNS TRIGGER AS $$ |
|
44 |
BEGIN |
|
45 |
NEW.last_update_time = now(); |
|
46 |
RETURN NEW; |
|
47 |
END; |
|
48 |
$$ LANGUAGE 'plpgsql'; |
|
49 |
|
|
50 |
CREATE TRIGGER update_blacklist_modtime BEFORE UPDATE ON blacklist FOR EACH ROW EXECUTE PROCEDURE update_modified_column(); |
|
51 |
|
|
52 |
-- Just for test |
|
53 |
|
|
54 |
-- INSERT INTO blacklist (userid, relationship, provenance, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
55 |
-- VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'crosswalk', |
|
56 |
-- 'ACCEPTED', 'od________18::xxxxxxxxxxxxxxxxxx', 'result', |
|
57 |
-- 'corda_______::9826e8aba3e8f3a2a46545cf341838a8', 'project', '1'); |
|
58 |
-- INSERT INTO blacklist (userid, relationship, provenance, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
59 |
-- VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'crosswalk', |
|
60 |
-- 'PENDING', 'od________18::yyyyyyyyyyyyyyyyyyyy', 'result', |
|
61 |
-- 'corda_______::9826e8aba3e8f3a2a46545cf341838a8', 'project', '1'); |
|
62 |
-- INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
63 |
-- VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
64 |
-- 'iis::document_referencedProjects', |
|
65 |
-- 'UNSOLVED', 'ACCEPTED', 'od______2367::eb76f733498920166d4ce77ec37d4X', 'result', |
|
66 |
-- 'corda_______::800e636c0a24ac3767701a789a96baX', 'project', '1360', '{"idsource::origi1", "idsource:orig2"}', |
|
67 |
-- '{"idtarget::origi1", "idtarget:orig2","idtarget:orig3"}'); |
|
68 |
|
|
69 |
-- https://issue.openaire.research-infrastructures.eu/issues/1245 |
|
70 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
71 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
72 |
'iis::document_referencedProjects', 'UNSOLVED', 'ACCEPTED', 'od_______908::a47e1c3ede9a21ee5278a2e5c338d69b', 'result', |
|
73 |
'corda_______::fda6a1c19dac47508b6fb619518328c7', 'project', '1245', '{"od_______908::a47e1c3ede9a21ee5278a2e5c338d69b"}', '{"corda_______::fda6a1c19dac47508b6fb619518328c7"}'); |
|
74 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
75 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
76 |
'iis::document_referencedProjects', 'UNSOLVED', 'ACCEPTED', 'od_______908::a47e1c3ede9a21ee5278a2e5c338d69b', 'result', |
|
77 |
'corda_______::189ff31d637eaaeaf4d3584dc490b1cf', 'project', '1245', '{"od_______908::a47e1c3ede9a21ee5278a2e5c338d69b"}', '{"corda_______::189ff31d637eaaeaf4d3584dc490b1cf"}'); |
|
78 |
|
|
79 |
-- https://issue.openaire.research-infrastructures.eu/issues/1360 |
|
80 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
81 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
82 |
'iis::document_referencedProjects', 'UNSOLVED', 'ACCEPTED', 'od________18::a727cc288016db7132ef9a799aa83350', 'result', |
|
83 |
'corda_______::9826e8aba3e8f3a2a46545cf341838a8', 'project', '1360', '{"od________18::a727cc288016db7132ef9a799aa83350"}', '{"corda_______::9826e8aba3e8f3a2a46545cf341838a8"}'); |
|
84 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
85 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
86 |
'iis::document_referencedProjects', 'UNSOLVED', 'ACCEPTED', 'od________18::062cf091d5c7a7d730001c34177042e3', 'result', |
|
87 |
'corda_______::9826e8aba3e8f3a2a46545cf341838a8', 'project', '1360', '{"od________18::062cf091d5c7a7d730001c34177042e3"}', |
|
88 |
'{"corda_______::9826e8aba3e8f3a2a46545cf341838a8"}'); |
|
89 |
|
|
90 |
-- https://issue.openaire.research-infrastructures.eu/issues/1254 |
|
91 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
92 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
93 |
'iis::document_referencedProjects', 'SOLVED', |
|
94 |
'ACCEPTED', 'webcrawl____::68c191d9b972b47a235d311804c7f6f5', 'result', 'corda_______::c3d0b21615b129cd7395e24f9cf6bb64', 'project', |
|
95 |
'1254', '{"webcrawl____::68c191d9b972b47a235d311804c7f6f5"}', '{"corda_______::c3d0b21615b129cd7395e24f9cf6bb64"}'); |
|
96 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
97 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
98 |
'iis::document_referencedProjects', |
|
99 |
'UNSOLVED', 'ACCEPTED', 'od_______908::1b172ab34639e7935e2357119cf20830', 'result', |
|
100 |
'corda_______::c3d0b21615b129cd7395e24f9cf6bb64', 'project', '1254', '{"od_______908::1b172ab34639e7935e2357119cf20830"}', |
|
101 |
'{"corda_______::c3d0b21615b129cd7395e24f9cf6bb64"}'); |
|
102 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
103 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
104 |
'iis::document_referencedProjects', |
|
105 |
'UNSOLVED', 'ACCEPTED', 'doajarticles::cb234c66327d29ba5f13c0db7a4cf423', 'result', |
|
106 |
'corda_______::c3d0b21615b129cd7395e24f9cf6bb64', 'project', '1254', '{"doajarticles::cb234c66327d29ba5f13c0db7a4cf423"}', |
|
107 |
'{"corda_______::c3d0b21615b129cd7395e24f9cf6bb64"}'); |
|
108 |
|
|
109 |
-- https://issue.openaire.research-infrastructures.eu/issues/1297 |
|
110 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
111 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
112 |
'iis::document_referencedProjects', 'UNSOLVED', |
|
113 |
'ACCEPTED', 'od______1146::e2fafaba636a14e408f02c6ea26acb0e', 'result', 'corda_______::35695c955c51f0bb39482ce5477047c7', 'project', |
|
114 |
'1297', '{"od______1146::e2fafaba636a14e408f02c6ea26acb0e"}', '{"corda_______::35695c955c51f0bb39482ce5477047c7"}'); |
|
115 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
116 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
117 |
'iis::document_referencedProjects', |
|
118 |
'UNSOLVED', 'ACCEPTED', 'od_______908::b8e86ed982ff331764456e1f0759ed9c', 'result', |
|
119 |
'corda_______::35695c955c51f0bb39482ce5477047c7', 'project', '1297', '{"od_______908::b8e86ed982ff331764456e1f0759ed9c"}', |
|
120 |
'{"corda_______::35695c955c51f0bb39482ce5477047c7"}'); |
|
121 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
122 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
123 |
'iis::document_referencedProjects', |
|
124 |
'UNSOLVED', 'ACCEPTED', 'webcrawl____::c472bf5944ce0495844d505d43d1c021', 'result', |
|
125 |
'corda_______::35695c955c51f0bb39482ce5477047c7', 'project', '1297', '{"webcrawl____::c472bf5944ce0495844d505d43d1c021"}', |
|
126 |
'{"corda_______::35695c955c51f0bb39482ce5477047c7"}'); |
|
127 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
128 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
129 |
'iis::document_referencedProjects', |
|
130 |
'UNSOLVED', 'ACCEPTED', 'od_______908::bbe86580e44dbefa401d435259baddf1', 'result', |
|
131 |
'corda_______::35695c955c51f0bb39482ce5477047c7', 'project', '1297', '{"od_______908::bbe86580e44dbefa401d435259baddf1"}', |
|
132 |
'{"corda_______::35695c955c51f0bb39482ce5477047c7"}'); |
|
133 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
134 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
135 |
'iis::document_referencedProjects', |
|
136 |
'UNSOLVED', 'ACCEPTED', 'webcrawl____::ae0ae3ea5641ac24fa148ac38397dfcd', 'result', |
|
137 |
'corda_______::35695c955c51f0bb39482ce5477047c7', 'project', '1297', '{"webcrawl____::ae0ae3ea5641ac24fa148ac38397dfcd"}', |
|
138 |
'{"corda_______::35695c955c51f0bb39482ce5477047c7"}'); |
|
139 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
140 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
141 |
'iis::document_referencedProjects', |
|
142 |
'UNSOLVED', 'ACCEPTED', 'webcrawl____::5f46a8c6420f5b5eaf30d7212b0ada5b', 'result', |
|
143 |
'corda_______::35695c955c51f0bb39482ce5477047c7', 'project', '1297', '{"webcrawl____::5f46a8c6420f5b5eaf30d7212b0ada5b"}', |
|
144 |
'{"corda_______::35695c955c51f0bb39482ce5477047c7"}'); |
|
145 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
146 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
147 |
'iis::document_referencedProjects', |
|
148 |
'UNSOLVED', 'ACCEPTED', 'od_______908::49d9b3df9cf7e9c991e09e53677e40e3', 'result', |
|
149 |
'corda_______::35695c955c51f0bb39482ce5477047c7', 'project', '1297', '{"od_______908::49d9b3df9cf7e9c991e09e53677e40e3"}', |
|
150 |
'{"corda_______::35695c955c51f0bb39482ce5477047c7"}'); |
|
151 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
152 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
153 |
'iis::document_referencedProjects', |
|
154 |
'UNSOLVED', 'ACCEPTED', 'od_______330::aa2edd06a6121a1a1db63be83cd7b7c7', 'result', |
|
155 |
'corda_______::35695c955c51f0bb39482ce5477047c7', 'project', '1297', '{"od_______330::aa2edd06a6121a1a1db63be83cd7b7c7"}', |
|
156 |
'{"corda_______::35695c955c51f0bb39482ce5477047c7"}'); |
|
157 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
158 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
159 |
'iis::document_referencedProjects', |
|
160 |
'UNSOLVED', 'ACCEPTED', 'od_______908::45f342e6f10d5543631a757b417388d7', 'result', |
|
161 |
'corda_______::35695c955c51f0bb39482ce5477047c7', 'project', '1297', '{"od_______908::45f342e6f10d5543631a757b417388d7"}', |
|
162 |
'{"corda_______::35695c955c51f0bb39482ce5477047c7"}'); |
|
163 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
164 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
165 |
'iis::document_referencedProjects', |
|
166 |
'UNSOLVED', 'ACCEPTED', 'webcrawl____::6ce2789da52c6036501533ed5613d71a', 'result', |
|
167 |
'corda_______::35695c955c51f0bb39482ce5477047c7', 'project', '1297', '{"webcrawl____::6ce2789da52c6036501533ed5613d71a"}', |
|
168 |
'{"corda_______::35695c955c51f0bb39482ce5477047c7"}'); |
|
169 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
170 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
171 |
'iis::document_referencedProjects', |
|
172 |
'UNSOLVED', 'ACCEPTED', 'webcrawl____::f887afc3d7a8e8c708b9b773d26cdd9d', 'result', |
|
173 |
'corda_______::35695c955c51f0bb39482ce5477047c7', 'project', '1297', '{"webcrawl____::f887afc3d7a8e8c708b9b773d26cdd9d"}', |
|
174 |
'{"corda_______::35695c955c51f0bb39482ce5477047c7"}'); |
|
175 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
176 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
177 |
'iis::document_referencedProjects', |
|
178 |
'UNSOLVED', 'ACCEPTED', 'webcrawl____::161ee67349e268750701ee437188340b', 'result', |
|
179 |
'corda_______::35695c955c51f0bb39482ce5477047c7', 'project', '1297', '{"webcrawl____::161ee67349e268750701ee437188340b"}', |
|
180 |
'{"corda_______::35695c955c51f0bb39482ce5477047c7"}'); |
|
181 |
|
|
182 |
-- https://issue.openaire.research-infrastructures.eu/issues/1412 |
|
183 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
184 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
185 |
'iis::document_referencedProjects', |
|
186 |
'UNSOLVED', 'ACCEPTED', 'od______2367::eb76f733498920166d4ce77ec37d487c', 'result', |
|
187 |
'corda_______::800e636c0a24ac3767701a789a96ba89', 'project', '1360', '{"od______2367::eb76f733498920166d4ce77ec37d487c"}', |
|
188 |
'{"corda_______::800e636c0a24ac3767701a789a96ba89"}'); |
|
189 |
|
|
190 |
-- https://issue.openaire.research-infrastructures.eu/issues/1530 |
|
191 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
192 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
193 |
'iis::document_referencedProjects', |
|
194 |
'UNSOLVED', 'ACCEPTED', 'dedup_wf_001::67d425112b2858ac59c44589496260b6', 'result', |
|
195 |
'corda__h2020::c4093823864f0ceb5747977245d1ad57', 'project', '1360', |
|
196 |
'{"doajarticles::67d425112b2858ac59c44589496260b6", "issn20484194::e8fe2f03154ed785e968ab72f54707e1"}', |
|
197 |
'{"corda__h2020::c4093823864f0ceb5747977245d1ad57"}'); |
|
198 |
|
|
199 |
INSERT INTO blacklist (userid, relationship, provenance, iis_module, iis_status, status, source_object, source_type, target_object, target_type, ticket_id, original_source_objects, original_target_objects) |
|
200 |
VALUES ('unknown', 'resultProject_outcome_isProducedBy', 'iis', |
|
201 |
'iis::document_referencedProjects', |
|
202 |
'UNSOLVED', 'ACCEPTED', 'dedup_wf_001::42baa97c7d0a4316f72bc61c373b6d2c', 'result', |
|
203 |
'corda__h2020::bc993a53736173ace2f6dd2ddc459dd5', 'project', '1360', |
|
204 |
'{"erc_________::42baa97c7d0a4316f72bc61c373b6d2c", "webcrawl____::488517651c5e126d97b45ad0416dd8a8", "od_______908::80a1640c67870bc5d4673a8d1ad0534a", "od_______610::9a1a5461cd13d2192950497bbe0b52ed"}', |
|
205 |
'{"corda__h2020::bc993a53736173ace2f6dd2ddc459dd5"}'); |
|
206 |
|
|
207 |
|
|
208 |
|
modules/dnet-openaire-blacklist/trunk/src/main/resources/eu/dnetlib/applicationContext-dnet-openaire-blacklist.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
3 |
xmlns="http://www.springframework.org/schema/beans" |
|
4 |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> |
|
5 |
|
|
6 |
<bean id="blacklistManager" class="eu.dnetlib.openaire.blacklist.BlacklistManager" /> |
|
7 |
|
|
8 |
<bean id="openaireIdResolver" class="eu.dnetlib.openaire.blacklist.OpenaireIdResolver"/> |
|
9 |
|
|
10 |
<bean id="wfNodeApplyBlacklistJob" class="eu.dnetlib.msro.workflows.blacklist.ApplyBlacklistJobNode" |
|
11 |
scope="prototype" /> |
|
12 |
|
|
13 |
</beans> |
modules/dnet-openaire-blacklist/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/webContext-modular-ui-blacklist.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<beans xmlns="http://www.springframework.org/schema/beans" |
|
3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" |
|
4 |
xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing" |
|
5 |
xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration" |
|
6 |
xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template" |
|
7 |
xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context" |
|
8 |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd |
|
9 |
http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd |
|
10 |
http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd |
|
11 |
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd |
|
12 |
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd |
|
13 |
http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd |
|
14 |
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd |
|
15 |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> |
|
16 |
|
|
17 |
|
|
18 |
<bean name="/ui/blacklist.do" |
|
19 |
class="eu.dnetlib.functionality.modular.ui.blacklist.BlacklistEntryPointController" |
|
20 |
p:menu="Blacklist Manager" |
|
21 |
p:title="Blacklist Manager" |
|
22 |
p:description="Manager for the Blacklist of links" |
|
23 |
p:group="Tools"> |
|
24 |
<property name="permissionLevels"> |
|
25 |
<set> |
|
26 |
<value>IS_ADMIN</value> |
|
27 |
</set> |
|
28 |
</property> |
|
29 |
</bean> |
|
30 |
|
|
31 |
</beans> |
modules/dnet-openaire-blacklist/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/blacklist.st | ||
---|---|---|
1 |
$common/master( header={ |
|
2 |
<script type="text/javascript" src="../resources/js/angular.min.js" ></script> |
|
3 |
<script type="text/javascript" src="../resources/js/angular-route.min.js"></script> |
|
4 |
<script type="text/javascript" src="../resources/js/ui-bootstrap.min.js"></script> |
|
5 |
<script type="text/javascript" src="../resources/js/jquery-ui-1.10.4.min.js"></script> |
|
6 |
|
|
7 |
<script type="text/javascript" src="../resources/js/blacklist.js"></script> |
|
8 |
<script type="text/javascript" src="../resources/js/blacklist_controllers.js"></script> |
|
9 |
|
|
10 |
<link rel="stylesheet" type="text/css" href="../resources/css/jquery-ui-1.10.4.min.css" /> |
|
11 |
|
|
12 |
}, body={ |
|
13 |
<div ng-app="blacklist"> |
|
14 |
<div ng-view></div> |
|
15 |
</div> |
|
16 |
} )$ |
modules/dnet-openaire-blacklist/trunk/src/main/resources/eu/dnetlib/web/resources/html/blacklist/blacklistEntryForm.html | ||
---|---|---|
1 |
<div class="modal fade"> |
|
2 |
<div class="modal-dialog modal-lg"> |
|
3 |
<div class="modal-content"> |
|
4 |
<div class="modal-header"> |
|
5 |
<button type="button" class="close" data-dismiss="modal"> |
|
6 |
<span aria-hidden="true">×</span> |
|
7 |
</button> |
|
8 |
<h4 class="modal-title" ng-if="mode == 'ADD'">Add new blacklist entry</h4> |
|
9 |
<h4 class="modal-title" ng-if="mode == 'UPDATE'">Edit blacklist entry</h4> |
|
10 |
</div> |
|
11 |
<div class="modal-body"> |
|
12 |
<form class="form-horizontal" name="formBlacklist"> |
|
13 |
|
|
14 |
<div class="form-group"> |
|
15 |
<label class="col-xs-3 control-label">Ticket ID</label> |
|
16 |
<div class="col-xs-2"> |
|
17 |
<div bs-has-error> |
|
18 |
<input class="form-control" ng-model="entry.ticketId" type="text" ng-pattern="/^\d+$/" placeholder="ID..." /> |
|
19 |
<span class="form-control-feedback glyphicon"></span> |
|
20 |
</div> |
|
21 |
</div> |
|
22 |
</div> |
|
23 |
|
|
24 |
<div class="form-group"> |
|
25 |
<label class="col-xs-3 control-label">Relationship</label> |
|
26 |
<div class="col-xs-9"> |
|
27 |
<div bs-has-error> |
|
28 |
<select class="form-control" ng-model="entry.relationship" required="required"> |
|
29 |
<option value="" disabled="disabled" style="display: none;">- Please Choose -</option> |
|
30 |
<option value="{{item}}" ng-repeat="item in relationTypes">{{item}}</option> |
|
31 |
</select> |
|
32 |
<span class="form-control-feedback glyphicon"></span> |
|
33 |
</div> |
|
34 |
</div> |
|
35 |
</div> |
|
36 |
|
|
37 |
<div class="form-group"> |
|
38 |
<label class="col-xs-3 control-label">Source</label> |
|
39 |
<div class="col-xs-3"> |
|
40 |
<div bs-has-error> |
|
41 |
<select class="form-control" ng-model="entry.sourceType" required="required"> |
|
42 |
<option value="" disabled="disabled" style="display: none;">- Choose Type... -</option> |
|
43 |
<option value="{{item}}" ng-repeat="item in entityTypes">{{item}}</option> |
|
44 |
</select> |
|
45 |
<span class="form-control-feedback glyphicon"></span> |
|
46 |
</div> |
|
47 |
</div> |
|
48 |
<div class="col-xs-6"> |
|
49 |
<div bs-has-error> |
|
50 |
<input class="form-control" ng-model="entry.sourceObject" type="text" required="required" ng-pattern="/^\S{12}::\S{32}$/" placeholder="Source ID..." ng-disabled="mode == 'UPDATE'"/> |
|
51 |
<span class="form-control-feedback glyphicon"></span> |
|
52 |
</div> |
|
53 |
</div> |
|
54 |
</div> |
|
55 |
|
|
56 |
<div class="form-group"> |
|
57 |
<label class="col-xs-3 control-label">Target</label> |
|
58 |
<div class="col-xs-3"> |
|
59 |
<div bs-has-error> |
|
60 |
<select class="form-control" ng-model="entry.targetType" required="required"> |
|
61 |
<option value="" disabled="disabled" style="display: none;">- Choose Type... -</option> |
|
62 |
<option value="{{item}}" ng-repeat="item in entityTypes">{{item}}</option> |
|
63 |
</select> |
|
64 |
<span class="form-control-feedback glyphicon"></span> |
|
65 |
</div> |
|
66 |
</div> |
|
67 |
<div class="col-xs-6"> |
|
68 |
<div bs-has-error> |
|
69 |
<input class="form-control" ng-model="entry.targetObject" type="text" required="required" ng-pattern="/^\S{12}::\S{32}$/" placeholder="Target ID..." ng-disabled="mode == 'UPDATE'" /> |
|
70 |
<span class="form-control-feedback glyphicon"></span> |
|
71 |
</div> |
|
72 |
</div> |
|
73 |
</div> |
|
74 |
|
|
75 |
<div class="form-group"> |
|
76 |
<label class="col-xs-3 control-label">Status</label> |
|
77 |
<div class="col-xs-3"> |
|
78 |
<div bs-has-error> |
|
79 |
<select class="form-control" ng-model="entry.status" required="required"> |
|
80 |
<option value="" disabled="disabled" style="display: none;">- Please Choose -</option> |
|
81 |
<option value="PENDING">PENDING</option> |
|
82 |
<option value="ACCEPTED">ACCEPTED</option> |
|
83 |
<option value="REFUSED">REFUSED</option> |
|
84 |
<option value="DELETED">DELETED</option> |
|
85 |
</select> |
|
86 |
<span class="form-control-feedback glyphicon"></span> |
|
87 |
</div> |
|
88 |
</div> |
|
89 |
</div> |
|
90 |
|
|
91 |
<div class="form-group"> |
|
92 |
<label class="col-xs-3 control-label">Provenance</label> |
|
93 |
<div class="col-xs-3"> |
|
94 |
<div bs-has-error> |
|
95 |
<select class="form-control" ng-model="entry.provenance" required="required" ng-change="resetIisInfo()"> |
|
96 |
<option value="" disabled="disabled" style="display: none;">- Please Choose -</option> |
|
97 |
<option value="iis">iis</option> |
|
98 |
<option value="crosswalk">crosswalk</option> |
|
99 |
<option value="claim">claim</option> |
|
100 |
<option value="unknown">unknown</option> |
|
101 |
</select> |
|
102 |
<span class="form-control-feedback glyphicon"></span> |
|
103 |
</div> |
|
104 |
</div> |
|
105 |
</div> |
|
106 |
|
|
107 |
<div class="form-group" ng-show="entry.provenance == 'iis'"> |
|
108 |
<label class="col-xs-3 control-label">IIS module</label> |
|
109 |
<div class="col-xs-6"> |
|
110 |
<div bs-has-error> |
|
111 |
<input class="form-control" ng-model="entry.iisModule" type="text" placeholder="E.g. iis::document_referencedProjects" ng-required="entry.provenance == 'iis'" /> |
|
112 |
<span class="form-control-feedback glyphicon"></span> |
|
113 |
</div> |
|
114 |
</div> |
|
115 |
<div class="col-xs-3"> |
|
116 |
<div bs-has-error> |
|
117 |
<select ng-model="entry.iisStatus" class="form-control" ng-required="entry.provenance == 'iis'"> |
|
118 |
<option value="" disabled="disabled" style="display: none;">- Please Choose -</option> |
|
119 |
<option value="UNSOLVED">UNSOLVED</option> |
|
120 |
<option value="SOLVED">SOLVED</option> |
|
121 |
</select> |
|
122 |
<span class="form-control-feedback glyphicon"></span> |
|
123 |
</div> |
|
124 |
</div> |
|
125 |
</div> |
|
126 |
|
|
127 |
<div class="form-group"> |
|
128 |
<label class="col-xs-3 control-label">Note</label> |
|
129 |
<div class="col-xs-9"> |
|
130 |
<div bs-has-error> |
|
131 |
<textarea class="form-control" rows="5" ng-model="entry.note" placeholder="Note..."></textarea> |
|
132 |
<span class="form-control-feedback glyphicon"></span> |
|
133 |
</div> |
|
134 |
</div> |
|
135 |
</div> |
|
136 |
|
|
137 |
</form> |
|
138 |
</div> |
|
139 |
<div class="modal-footer"> |
|
140 |
<button class="btn btn-default" data-dismiss="modal">Close</button> |
|
141 |
<button class="btn btn-primary" data-dismiss="modal" ng-click="saveEntry()" ng-disabled="formBlacklist.$invalid">Save changes</button> |
|
142 |
</div> |
|
143 |
</div> |
|
144 |
</div> |
|
145 |
</div> |
modules/dnet-openaire-blacklist/trunk/src/main/resources/eu/dnetlib/web/resources/html/blacklist/blacklist.html | ||
---|---|---|
1 |
<ng-blacklist-form entry="entryToEdit" |
|
2 |
visible="showBlacklistForm" |
|
3 |
add-function="addBlacklistEntry(entryToEdit)" |
|
4 |
update-function="editBlacklistEntry(entryToEdit)" |
|
5 |
mode="modeBlacklistForm"> |
|
6 |
</ng-blacklist-form> |
|
7 |
|
|
8 |
<div class="row"> |
|
9 |
<div class="col-xs-3"> |
|
10 |
<button class="btn btn-sm btn-primary" ng-click="prepareNewEntry()">Add blacklist entry</button> |
|
11 |
</div> |
|
12 |
<div class="col-xs-9"> |
|
13 |
<form role="form" class="form-inline pull-right"> |
|
14 |
<input type="text" placeholder="Filter..." ng-model="blacklistFilter" class="form-control input-sm"> |
|
15 |
<button type="button" class="btn btn-default btn btn-sm" ng-click="getBlacklist()"><span class="glyphicon glyphicon-refresh"></span></button> |
|
16 |
</form> |
|
17 |
</div> |
|
18 |
</div> |
|
19 |
|
|
20 |
<table class="table table-hover" style="font-size: 12px; margin-top: 30px;"> |
|
21 |
<thead> |
|
22 |
<tr> |
|
23 |
<th class="text-right"> |
|
24 |
<a href="javascript:void(0)" ng-click="order('ticketId')"> |
|
25 |
Ticket |
|
26 |
<span class="glyphicon" ng-class="{ |
|
27 |
'glyphicon-sort' : predicate != 'ticketId', |
|
28 |
'glyphicon-chevron-up' : predicate == 'ticketId' && reverse, |
|
29 |
'glyphicon-chevron-down' : predicate == 'ticketId' && !reverse |
|
30 |
}"></span> |
|
31 |
</a> |
|
32 |
</th> |
|
33 |
<th class="text-center"> |
|
34 |
<a href="javascript:void(0)" ng-click="order('sourceObject')"> |
|
35 |
Source Object |
|
36 |
<span class="glyphicon" ng-class="{ |
|
37 |
'glyphicon-sort' : predicate != 'sourceObject', |
|
38 |
'glyphicon-chevron-up' : predicate == 'sourceObject' && reverse, |
|
39 |
'glyphicon-chevron-down' : predicate == 'sourceObject' && !reverse |
|
40 |
}"></span> |
|
41 |
</a> |
|
42 |
</th> |
|
43 |
<th class="text-center"> |
|
44 |
<a href="javascript:void(0)" ng-click="order('relationship')"> |
|
45 |
Relationship |
|
46 |
<span class="glyphicon" ng-class="{ |
|
47 |
'glyphicon-sort' : predicate != 'relationship', |
|
48 |
'glyphicon-chevron-up' : predicate == 'relationship' && reverse, |
|
49 |
'glyphicon-chevron-down' : predicate == 'relationship' && !reverse |
Also available in: Unified diff
codebase used to migrate to java8 the production system