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
	public String getSql() {
86
		return sql;
87
	}
88

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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