1
|
package eu.dnetlib.data.claims.migration;
|
2
|
|
3
|
import eu.dnetlib.data.claims.migration.handler.DMFContextHandler;
|
4
|
import eu.dnetlib.data.claims.migration.handler.DMFResultHandler;
|
5
|
import eu.dnetlib.data.claims.migration.handler.ProjectHandler;
|
6
|
import eu.dnetlib.data.claims.migration.handler.RelationHandler;
|
7
|
import eu.dnetlib.data.claimsDemo.ClaimBuilder;
|
8
|
import eu.dnetlib.data.claimsDemo.ClaimUtils;
|
9
|
import org.springframework.context.ApplicationContext;
|
10
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
11
|
|
12
|
import java.util.List;
|
13
|
|
14
|
/**
|
15
|
* Created by kiatrop on 4/2/2016.
|
16
|
*/
|
17
|
|
18
|
public class Migration {
|
19
|
|
20
|
//private SqlDAO sqlDAO = null;
|
21
|
ClaimBuilder claimBuilder = null;
|
22
|
QueryBuilder queryBuilder = null;
|
23
|
|
24
|
Migration() {
|
25
|
ApplicationContext context = new ClassPathXmlApplicationContext("eu/dnetlib/data/claims/migration/springContext-claimsDemo.xml");
|
26
|
claimBuilder = context.getBean(ClaimBuilder.class);
|
27
|
queryBuilder = context.getBean(QueryBuilder.class);
|
28
|
|
29
|
}
|
30
|
|
31
|
|
32
|
//TODO
|
33
|
private void createClaim() throws Exception {
|
34
|
RelationHandler relationHandler = new RelationHandler();
|
35
|
ProjectHandler projectHandler = new ProjectHandler();
|
36
|
DMFContextHandler dmfContextHandler = new DMFContextHandler();
|
37
|
DMFResultHandler dmfResultHandler = new DMFResultHandler();
|
38
|
|
39
|
List<Relation> relations = relationHandler.fetchAllRelations();
|
40
|
for(Relation relation:relations) {
|
41
|
if (relation.getSourceType().equals(ClaimUtils.PROJECT)) {
|
42
|
Project project = projectHandler.fetchProjectByID(relation.getSourceId());
|
43
|
|
44
|
} else if (relation.getSourceType().equals(ClaimUtils.CONTEXT)) {
|
45
|
Context context = dmfContextHandler.fetchContextById(relation.getSourceId());
|
46
|
|
47
|
} else if (relation.getSourceType().equals(ClaimUtils.DATASET) || relation.getSourceType().equals(ClaimUtils.PUBLICATION)) {
|
48
|
//TODO: check if dmf exists
|
49
|
//TODO: if yes get collectedFrom
|
50
|
//TODO: different cases of collectedFrom
|
51
|
|
52
|
//TODO
|
53
|
//if(result == null) {
|
54
|
|
55
|
//
|
56
|
// }
|
57
|
}
|
58
|
}
|
59
|
|
60
|
|
61
|
|
62
|
}
|
63
|
|
64
|
public static void main(String[] args) {
|
65
|
|
66
|
new Migration();
|
67
|
}
|
68
|
}
|