Project

General

Profile

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
			return "result";
65
		default:
66
			return type;
67
		}
68
	}
69

    
70
	protected String getFullId(final String type, final String id) {
71
		final String fullId = AbstractDNetXsltFunctions.oafSimpleId(type, id);
72
		return OafRowKeyDecoder.decode(fullId).getKey();
73
	}
74

    
75
	protected static DataInfo getDataInfo() {
76
		return DataInfo.newBuilder().setTrust("0.91").setInferred(false)
77
				.setProvenanceaction(
78
						Qualifier.newBuilder()
79
								.setClassid("user:claim")
80
								.setClassname("user:claim")
81
								.setSchemeid("dnet:provenanceActions")
82
								.setSchemename("dnet:provenanceActions")).build();
83

    
84
	}
85

    
86
	public String getSql() {
87
		return sql;
88
	}
89

    
90
	public void setSql(final String sql) {
91
		this.sql = sql;
92
	}
93

    
94
	public String getCountQuery() {
95
		return countQuery;
96
	}
97

    
98
	public void setCountQuery(final String countQuery) {
99
		this.countQuery = countQuery;
100
	}
101

    
102
	public int getTotal() {
103
		return total;
104
	}
105

    
106
	public void setTotal(final int total) {
107
		this.total = total;
108
	}
109

    
110
	public int getProcessed() {
111
		return processed;
112
	}
113

    
114
	public void setProcessed(final int processed) {
115
		this.processed = processed;
116
	}
117

    
118
	public void incrementProcessed() {
119
		processed++;
120
	}
121

    
122
	public String getClusterName() {
123
		return clusterName;
124
	}
125

    
126
	public void setClusterName(final String clusterName) {
127
		this.clusterName = clusterName;
128
	}
129

    
130
	public String getTableName() {
131
		return tableName;
132
	}
133

    
134
	public void setTableName(final String tableName) {
135
		this.tableName = tableName;
136
	}
137

    
138
	public UniqueServiceLocator getServiceLocator() {
139
		return serviceLocator;
140
	}
141

    
142
	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
143
		this.serviceLocator = serviceLocator;
144
	}
145

    
146
	public ClaimDatabaseUtils getClaimDatabaseUtils() {
147
		return claimDatabaseUtils;
148
	}
149

    
150
	public void setClaimDatabaseUtils(final ClaimDatabaseUtils claimDatabaseUtils) {
151
		this.claimDatabaseUtils = claimDatabaseUtils;
152
	}
153
}
(1-1/6)