1
|
package eu.dnetlib.msro.openaireplus.workflows.nodes.claims;
|
2
|
|
3
|
import eu.dnetlib.data.mapreduce.util.OafRowKeyDecoder;
|
4
|
import eu.dnetlib.data.proto.FieldTypeProtos.DataInfo;
|
5
|
import eu.dnetlib.data.proto.FieldTypeProtos.Qualifier;
|
6
|
import eu.dnetlib.data.transform.xml.AbstractDNetXsltFunctions;
|
7
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
8
|
import eu.dnetlib.msro.workflows.nodes.ProgressJobNode;
|
9
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
10
|
import eu.dnetlib.msro.workflows.util.ProgressProvider;
|
11
|
import org.apache.commons.logging.Log;
|
12
|
import org.apache.commons.logging.LogFactory;
|
13
|
import org.springframework.beans.factory.annotation.Autowired;
|
14
|
|
15
|
/**
|
16
|
* Created by Alessia Bardi on 28/06/2017.
|
17
|
*
|
18
|
* @author Alessia Bardi
|
19
|
*/
|
20
|
public abstract class AbstractClaimsToHBASE extends SimpleJobNode implements ProgressJobNode {
|
21
|
|
22
|
private static final Log log = LogFactory.getLog(AbstractClaimsToHBASE.class);
|
23
|
|
24
|
private String sql;
|
25
|
private String countQuery;
|
26
|
|
27
|
private int total = 0;
|
28
|
private int processed = 0;
|
29
|
|
30
|
private String clusterName;
|
31
|
private String tableName;
|
32
|
|
33
|
@Autowired
|
34
|
private UniqueServiceLocator serviceLocator;
|
35
|
|
36
|
@Autowired
|
37
|
private ClaimDatabaseUtils claimDatabaseUtils;
|
38
|
|
39
|
@Override
|
40
|
public ProgressProvider getProgressProvider() {
|
41
|
return new ProgressProvider() {
|
42
|
|
43
|
@Override
|
44
|
public boolean isInaccurate() {
|
45
|
return false;
|
46
|
}
|
47
|
|
48
|
@Override
|
49
|
public int getTotalValue() {
|
50
|
return total;
|
51
|
}
|
52
|
|
53
|
@Override
|
54
|
public int getCurrentValue() {
|
55
|
return processed;
|
56
|
}
|
57
|
};
|
58
|
}
|
59
|
|
60
|
protected String getOpenAIREType(final String type) {
|
61
|
switch (type) {
|
62
|
case "publication":
|
63
|
case "dataset":
|
64
|
case "software":
|
65
|
case "other":
|
66
|
return "result";
|
67
|
default:
|
68
|
return type;
|
69
|
}
|
70
|
}
|
71
|
|
72
|
protected String getFullId(final String type, final String id) {
|
73
|
final String fullId = AbstractDNetXsltFunctions.oafSimpleId(type, id);
|
74
|
return OafRowKeyDecoder.decode(fullId).getKey();
|
75
|
}
|
76
|
|
77
|
protected static DataInfo getDataInfo() {
|
78
|
return DataInfo.newBuilder().setTrust("0.91").setInferred(false)
|
79
|
.setProvenanceaction(
|
80
|
Qualifier.newBuilder()
|
81
|
.setClassid("user:claim")
|
82
|
.setClassname("user:claim")
|
83
|
.setSchemeid("dnet:provenanceActions")
|
84
|
.setSchemename("dnet:provenanceActions")).build();
|
85
|
|
86
|
}
|
87
|
|
88
|
public String getSql() {
|
89
|
return sql;
|
90
|
}
|
91
|
|
92
|
public void setSql(final String sql) {
|
93
|
this.sql = sql;
|
94
|
}
|
95
|
|
96
|
public String getCountQuery() {
|
97
|
return countQuery;
|
98
|
}
|
99
|
|
100
|
public void setCountQuery(final String countQuery) {
|
101
|
this.countQuery = countQuery;
|
102
|
}
|
103
|
|
104
|
public int getTotal() {
|
105
|
return total;
|
106
|
}
|
107
|
|
108
|
public void setTotal(final int total) {
|
109
|
this.total = total;
|
110
|
}
|
111
|
|
112
|
public int getProcessed() {
|
113
|
return processed;
|
114
|
}
|
115
|
|
116
|
public void setProcessed(final int processed) {
|
117
|
this.processed = processed;
|
118
|
}
|
119
|
|
120
|
public void incrementProcessed() {
|
121
|
processed++;
|
122
|
}
|
123
|
|
124
|
public String getClusterName() {
|
125
|
return clusterName;
|
126
|
}
|
127
|
|
128
|
public void setClusterName(final String clusterName) {
|
129
|
this.clusterName = clusterName;
|
130
|
}
|
131
|
|
132
|
public String getTableName() {
|
133
|
return tableName;
|
134
|
}
|
135
|
|
136
|
public void setTableName(final String tableName) {
|
137
|
this.tableName = tableName;
|
138
|
}
|
139
|
|
140
|
public UniqueServiceLocator getServiceLocator() {
|
141
|
return serviceLocator;
|
142
|
}
|
143
|
|
144
|
public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
|
145
|
this.serviceLocator = serviceLocator;
|
146
|
}
|
147
|
|
148
|
public ClaimDatabaseUtils getClaimDatabaseUtils() {
|
149
|
return claimDatabaseUtils;
|
150
|
}
|
151
|
|
152
|
public void setClaimDatabaseUtils(final ClaimDatabaseUtils claimDatabaseUtils) {
|
153
|
this.claimDatabaseUtils = claimDatabaseUtils;
|
154
|
}
|
155
|
}
|