Revision 57130
Added by Michele Artini over 4 years ago
DatabaseUtils.java | ||
---|---|---|
16 | 16 |
import eu.dnetlib.organizations.model.Organization; |
17 | 17 |
import eu.dnetlib.organizations.model.OtherIdentifier; |
18 | 18 |
import eu.dnetlib.organizations.model.OtherName; |
19 |
import eu.dnetlib.organizations.model.Relationship; |
|
19 | 20 |
import eu.dnetlib.organizations.model.Type; |
20 | 21 |
import eu.dnetlib.organizations.model.Url; |
21 | 22 |
import eu.dnetlib.organizations.model.view.OrganizationView; |
... | ... | |
23 | 24 |
import eu.dnetlib.organizations.repository.OrganizationRepository; |
24 | 25 |
import eu.dnetlib.organizations.repository.OtherIdentifierRepository; |
25 | 26 |
import eu.dnetlib.organizations.repository.OtherNameRepository; |
27 |
import eu.dnetlib.organizations.repository.RelationshipRepository; |
|
26 | 28 |
import eu.dnetlib.organizations.repository.TypeRepository; |
27 | 29 |
import eu.dnetlib.organizations.repository.UrlRepository; |
28 | 30 |
|
... | ... | |
41 | 43 |
private TypeRepository typeRepository; |
42 | 44 |
@Autowired |
43 | 45 |
private UrlRepository urlRepository; |
46 |
@Autowired |
|
47 |
private RelationshipRepository relationshipRepository; |
|
44 | 48 |
|
45 | 49 |
@Autowired |
46 | 50 |
private JdbcTemplate jdbcTemplate; |
... | ... | |
85 | 89 |
return jdbcTemplate.queryForList("select val from " + table, String.class); |
86 | 90 |
} |
87 | 91 |
|
92 |
@Transactional |
|
93 |
public void addRelation(final String from, final String to, final RelationType type) { |
|
94 |
final Relationship r1 = new Relationship(from, to, type.toString()); |
|
95 |
final Relationship r2 = new Relationship(to, from, type.getInverse().toString()); |
|
96 |
relationshipRepository.save(r1); |
|
97 |
relationshipRepository.save(r2); |
|
98 |
} |
|
99 |
|
|
100 |
@Transactional |
|
101 |
public void deleteRelation(final String from, final String to, final RelationType type) { |
|
102 |
final Relationship r1 = new Relationship(from, to, type.toString()); |
|
103 |
final Relationship r2 = new Relationship(to, from, type.getInverse().toString()); |
|
104 |
relationshipRepository.delete(r1); |
|
105 |
relationshipRepository.delete(r2); |
|
106 |
} |
|
107 |
|
|
88 | 108 |
} |
Also available in: Unified diff