Project

General

Profile

1
package eu.dnetlib.data.transform;
2

    
3
import java.util.Map;
4

    
5
import com.google.gson.Gson;
6
import eu.dnetlib.data.graph.utils.RelDescriptor;
7

    
8
/**
9
 * Created by claudio on 12/12/2016.
10
 */
11
public class Ontology {
12

    
13
	private String code;
14
	private String description;
15

    
16
	private Map<String, OntologyTerm> terms;
17

    
18
	public String getCode() {
19
		return code;
20
	}
21

    
22
	public Ontology setCode(final String code) {
23
		this.code = code;
24
		return this;
25
	}
26

    
27
    public String getDescription() {
28
        return description;
29
    }
30

    
31
	public Ontology setDescription(final String description) {
32
		this.description = description;
33
		return this;
34
	}
35

    
36
    public Map<String, OntologyTerm> getTerms() {
37
        return terms;
38
    }
39

    
40
	public Ontology setTerms(final Map<String, OntologyTerm> terms) {
41
		this.terms = terms;
42
		return this;
43
	}
44

    
45
    public String inverseOf(final String termCode) {
46
        if (getTerms() == null || !getTerms().containsKey(termCode)) {
47
            return null;
48
        }
49
        return getTerms().get(termCode).getInverseCode();
50
    }
51

    
52

    
53
    public String inverseOf(final RelDescriptor rd) {
54
        if (getTerms() == null || !getTerms().containsKey(rd.getTermCode())) {
55
            return null;
56
        }
57
        return getTerms().get(rd.getTermCode()).getInverseCode();
58
    }
59

    
60
	@Override
61
	public String toString() {
62
		return new Gson().toJson(this);
63
	}
64

    
65
}
(6-6/13)