Project

General

Profile

1
package eu.dnetlib.openaire.hadoop.utils;
2

    
3
import java.util.Arrays;
4
import java.util.Set;
5
import java.util.stream.Collectors;
6
import java.util.stream.Stream;
7

    
8
import com.google.common.collect.Sets;
9
import eu.dnetlib.data.proto.DatasourceOrganizationProtos.DatasourceOrganization.Provision;
10
import eu.dnetlib.data.proto.DedupProtos.Dedup;
11
import eu.dnetlib.data.proto.DedupSimilarityProtos.DedupSimilarity;
12
import eu.dnetlib.data.proto.ProjectOrganizationProtos.ProjectOrganization.Participation;
13
import eu.dnetlib.data.proto.RelTypeProtos.RelType;
14
import eu.dnetlib.data.proto.RelTypeProtos.SubRelType;
15
import eu.dnetlib.data.proto.ResultOrganizationProtos.ResultOrganization.Affiliation;
16
import eu.dnetlib.data.proto.ResultProjectProtos.ResultProject.Outcome;
17
import eu.dnetlib.data.proto.ResultResultProtos.ResultResult.*;
18
import eu.dnetlib.data.proto.TypeProtos.Type;
19

    
20
/**
21
 * Common static utility methods to manage the hbase tables
22
 *
23
 * @author claudio
24
 */
25
public class HBaseTableUtils {
26

    
27
	private static final String SEPARATOR = "_";
28

    
29
	public static Set<String> listAllColumns() {
30
		final Set<String> union = Sets.union(listEntities(), listRelationships());
31
		return Sets.union(union, listDedupRelationships());
32
	}
33

    
34
	public static Set<String> listDedupRelationships() {
35
		final Set<String> cfs = Sets.newHashSet();
36
		cfs.add(RelType.organizationOrganization + SEPARATOR + SubRelType.dedup + SEPARATOR + Dedup.RelName.merges);
37
		cfs.add(RelType.organizationOrganization + SEPARATOR + SubRelType.dedup + SEPARATOR + Dedup.RelName.isMergedIn);
38
		cfs.add(RelType.organizationOrganization + SEPARATOR + SubRelType.dedupSimilarity + SEPARATOR + DedupSimilarity.RelName.isSimilarTo);
39

    
40
		cfs.add(RelType.resultResult + SEPARATOR + SubRelType.dedup + SEPARATOR + Dedup.RelName.merges);
41
		cfs.add(RelType.resultResult + SEPARATOR + SubRelType.dedup + SEPARATOR + Dedup.RelName.isMergedIn);
42
		cfs.add(RelType.resultResult + SEPARATOR + SubRelType.dedupSimilarity + SEPARATOR + DedupSimilarity.RelName.isSimilarTo);
43

    
44
		return cfs;
45
	}
46

    
47
	private static Stream<String> types() {
48
		return Arrays.stream(Type.values())
49
				.map(Enum::toString);
50
	}
51

    
52
	public static Set<String> listEntities() {
53
		return types()
54
				.collect(Collectors.toSet());
55
	}
56

    
57
	public static Set<String> listRelationships() {
58
		final Set<String> cfs = Sets.newHashSet();
59
		cfs.add(RelType.datasourceOrganization + SEPARATOR + SubRelType.provision + SEPARATOR + Provision.RelName.isProvidedBy);
60
		cfs.add(RelType.datasourceOrganization + SEPARATOR + SubRelType.provision + SEPARATOR + Provision.RelName.provides);
61

    
62
		cfs.add(RelType.projectOrganization + SEPARATOR + SubRelType.participation + SEPARATOR + Participation.RelName.hasParticipant);
63
		cfs.add(RelType.projectOrganization + SEPARATOR + SubRelType.participation + SEPARATOR + Participation.RelName.isParticipant);
64

    
65
		cfs.add(RelType.resultProject + SEPARATOR + SubRelType.outcome + SEPARATOR + Outcome.RelName.isProducedBy);
66
		cfs.add(RelType.resultProject + SEPARATOR + SubRelType.outcome + SEPARATOR + Outcome.RelName.produces);
67

    
68
		cfs.add(RelType.resultResult + SEPARATOR + SubRelType.similarity + SEPARATOR + Similarity.RelName.hasAmongTopNSimilarDocuments);
69
		cfs.add(RelType.resultResult + SEPARATOR + SubRelType.similarity + SEPARATOR + Similarity.RelName.isAmongTopNSimilarDocuments);
70

    
71
		cfs.add(RelType.resultResult + SEPARATOR + SubRelType.supplement + SEPARATOR + Supplement.RelName.isSupplementedBy);
72
		cfs.add(RelType.resultResult + SEPARATOR + SubRelType.supplement + SEPARATOR + Supplement.RelName.isSupplementTo);
73
		cfs.add(RelType.resultResult + SEPARATOR + SubRelType.part + SEPARATOR + Part.RelName.isPartOf);
74
		cfs.add(RelType.resultResult + SEPARATOR + SubRelType.part + SEPARATOR + Part.RelName.hasPart);
75

    
76
		cfs.add(RelType.resultResult + SEPARATOR + SubRelType.publicationDataset + SEPARATOR + PublicationDataset.RelName.isRelatedTo);
77

    
78
		cfs.add(RelType.resultOrganization + SEPARATOR + SubRelType.affiliation + SEPARATOR + Affiliation.RelName.isAuthorInstitutionOf);
79
		cfs.add(RelType.resultOrganization + SEPARATOR + SubRelType.affiliation + SEPARATOR + Affiliation.RelName.hasAuthorInstitution);
80

    
81
		cfs.add(RelType.resultResult + SEPARATOR + SubRelType.version + SEPARATOR + SoftwareSoftware.RelName.isVersionOf);
82
		cfs.add(RelType.resultResult + SEPARATOR + SubRelType.relationship + SEPARATOR + Relationship.RelName.isRelatedTo);
83

    
84
		return cfs;
85
	}
86

    
87
}
    (1-1/1)