Project

General

Profile

« Previous | Next » 

Revision 55a9b086

Added by Andreas Müller about 11 years ago

Remove not public classes in merge and match strategies

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/match/DefaultMatchStrategy.java
13 13
import java.lang.annotation.Annotation;
14 14
import java.lang.reflect.Field;
15 15
import java.lang.reflect.GenericDeclaration;
16
import java.lang.reflect.ParameterizedType;
16 17
import java.lang.reflect.Type;
18
import java.lang.reflect.TypeVariable;
17 19
import java.net.URI;
18 20
import java.util.ArrayList;
19 21
import java.util.Collection;
......
25 27

  
26 28
import org.apache.log4j.Logger;
27 29

  
28
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
29
import sun.reflect.generics.reflectiveObjects.TypeVariableImpl;
30 30
import eu.etaxonomy.cdm.common.CdmUtils;
31 31
import eu.etaxonomy.cdm.common.DoubleResult;
32 32
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
......
367 367
	}
368 368
	
369 369
	private Class getTypeOfSet(Field field) throws MatchException{
370
		Type genericType = (ParameterizedTypeImpl)field.getGenericType();
371
		if (genericType instanceof ParameterizedTypeImpl){
372
			ParameterizedTypeImpl paraType = (ParameterizedTypeImpl)genericType;
370
		Type genericType = (ParameterizedType)field.getGenericType();
371
		if (genericType instanceof ParameterizedType/*Impl*/){
372
			ParameterizedType paraType = (ParameterizedType)genericType;
373 373
			paraType.getRawType();
374 374
			Type[] arguments = paraType.getActualTypeArguments();
375 375
			if (arguments.length == 1){
......
377 377
				try {
378 378
					if (arguments[0] instanceof Class){
379 379
						return (Class)arguments[0];
380
					}else if(arguments[0] instanceof TypeVariableImpl){
381
						TypeVariableImpl typeVariable = (TypeVariableImpl)arguments[0];
380
					}else if(arguments[0] instanceof TypeVariable/*Impl*/){
381
						TypeVariable typeVariable = (TypeVariable)arguments[0];
382 382
						GenericDeclaration genericDeclaration = typeVariable.getGenericDeclaration();
383 383
						return (Class)genericDeclaration;
384 384
					}else{
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/merge/DefaultMergeStrategy.java
14 14
import java.lang.reflect.Field;
15 15
import java.lang.reflect.GenericDeclaration;
16 16
import java.lang.reflect.Method;
17
import java.lang.reflect.ParameterizedType;
17 18
import java.lang.reflect.Type;
19
import java.lang.reflect.TypeVariable;
18 20
import java.util.ArrayList;
19 21
import java.util.Collection;
20 22
import java.util.HashMap;
......
26 28

  
27 29
import org.apache.log4j.Logger;
28 30

  
29
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
30
import sun.reflect.generics.reflectiveObjects.TypeVariableImpl;
31 31
import eu.etaxonomy.cdm.common.CdmUtils;
32 32
import eu.etaxonomy.cdm.model.common.CdmBase;
33 33
import eu.etaxonomy.cdm.model.common.ICdmBase;
......
493 493

  
494 494
	
495 495
	private static Class getCollectionType(Field field) throws MergeException{
496
		Type genericType = (ParameterizedTypeImpl)field.getGenericType();
497
		if (genericType instanceof ParameterizedTypeImpl){
498
			ParameterizedTypeImpl paraType = (ParameterizedTypeImpl)genericType;
499
			Class<?> rawType = paraType.getRawType();
496
		Type genericType = (ParameterizedType)field.getGenericType();
497
		if (genericType instanceof ParameterizedType/*Impl*/){
498
			ParameterizedType paraType = (ParameterizedType)genericType;
499
			Type rawType = paraType.getRawType();
500 500
			Type[] arguments = paraType.getActualTypeArguments();
501 501

  
502 502
			if (arguments.length == 1){
503 503
				Class collectionClass;
504 504
				if (arguments[0] instanceof Class){
505 505
					collectionClass = (Class)arguments[0];
506
				}else if(arguments[0] instanceof TypeVariableImpl){
507
					TypeVariableImpl typeVariable = (TypeVariableImpl)arguments[0];
506
				}else if(arguments[0] instanceof TypeVariable/*Impl*/){
507
					TypeVariable typeVariable = (TypeVariable)arguments[0];
508 508
					GenericDeclaration genericDeclaration = typeVariable.getGenericDeclaration();
509 509
					collectionClass = (Class)genericDeclaration;
510 510
				}else{
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/match/DefaultMatchStrategyTest.java
71 71
	private TimePeriod datePublished2 = TimePeriod.NewInstance(2002);
72 72
	private int hasProblem2 = 1;
73 73
	private LSID lsid2;
74
	ReferenceFactory refFactory;
75 74
	
76 75
	private IBook book3;
77 76
	
......
96 95
	 */
97 96
	@Before
98 97
	public void setUp() throws Exception {
99
		refFactory = ReferenceFactory.newInstance();
100 98
		team1 = Team.NewInstance();
101 99
		team1.setTitleCache("Team1",true);
102 100
		team2 = Team.NewInstance();
103 101
		team2.setTitleCache("Team2",true);
104
		printSeries1 = refFactory.newPrintSeries("Series1");
102
		printSeries1 = ReferenceFactory.newPrintSeries("Series1");
105 103
		printSeries1.setTitle("print series");
106
		printSeries2 = refFactory.newPrintSeries("Series2");
104
		printSeries2 = ReferenceFactory.newPrintSeries("Series2");
107 105
		annotation1 = Annotation.NewInstance("Annotation1", null);
108 106
		annotationString2 = "Annotation2";
109 107
		annotation2 = Annotation.NewInstance(annotationString2, null);
110 108
		
111
		book1 = refFactory.newBook();
109
		book1 = ReferenceFactory.newBook();
112 110
		book1.setAuthorTeam(team1);
113 111
		book1.setTitle(title1);
114 112
		book1.setEdition(editionString1);
......
121 119
		book1.setLsid(lsid1);
122 120
		((Reference) book1).setNomenclaturallyRelevant(false);
123 121
		
124
		book2 = refFactory.newBook();
122
		book2 = ReferenceFactory.newBook();
125 123
		book2.setAuthorTeam(team2);
126 124
		book2.setTitle(title2);
127 125
		book2.setEdition(editionString2);
......
264 262
		bookClone.setInSeries(printSeries1);
265 263
		Assert.assertTrue("Original printSeries should match", matchStrategy.invoke(book1, bookClone));
266 264
		
267
		IBook bookTitle1 = refFactory.newBook();
268
		IBook bookTitle2 = refFactory.newBook();
265
		IBook bookTitle1 = ReferenceFactory.newBook();
266
		IBook bookTitle2 = ReferenceFactory.newBook();
269 267
		Assert.assertFalse("Books without title should not match", matchStrategy.invoke(bookTitle1, bookTitle2));
270 268
		String title = "Any title";
271 269
		bookTitle1.setTitle(title);
......
288 286
		Assert.assertTrue("Books with same publication dates should match", matchStrategy.invoke(bookTitle1, bookTitle2));
289 287

  
290 288
		//BookSection
291
		IBookSection section1 = refFactory.newBookSection();
289
		IBookSection section1 = ReferenceFactory.newBookSection();
292 290
		section1.setInBook(bookTitle1);
293 291
		section1.setTitle("SecTitle");
294 292
		section1.setPages("22-33");
295
		IBookSection section2 = refFactory.newBookSection();
293
		IBookSection section2 = ReferenceFactory.newBookSection();
296 294
		section2.setInBook(bookTitle1);
297 295
		section2.setTitle("SecTitle");
298 296
		section2.setPages("22-33");
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/merge/DefaultMergeStrategyTest.java
21 21
import org.junit.Assert;
22 22
import org.junit.Before;
23 23
import org.junit.BeforeClass;
24
import org.junit.Ignore;
25 24
import org.junit.Test;
26 25

  
27 26
import eu.etaxonomy.cdm.model.agent.Address;
......
46 45
import eu.etaxonomy.cdm.model.occurrence.Specimen;
47 46
import eu.etaxonomy.cdm.model.reference.Reference;
48 47
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
49
//import eu.etaxonomy.cdm.model.reference.PrintSeries;
50
//import eu.etaxonomy.cdm.model.reference.Thesis;
51 48
import eu.etaxonomy.cdm.model.taxon.Taxon;
52 49
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
53 50
import eu.etaxonomy.cdm.strategy.cache.reference.INomenclaturalReferenceCacheStrategy;
......
62 59
	private static final Logger logger = Logger.getLogger(DefaultMergeStrategyTest.class);
63 60

  
64 61
	private DefaultMergeStrategy bookMergeStrategy;
65
	private Reference book1;
62
	private Reference<?> book1;
66 63
	private String editionString1 ="Ed.1";
67 64
	private String volumeString1 ="Vol.1";
68 65
	private Team team1;
69
	private Reference printSeries1;
66
	private Reference<?> printSeries1;
70 67
	private Annotation annotation1;
71 68
	private String title1 = "Title1";
72 69
	private TimePeriod datePublished1 = TimePeriod.NewInstance(2000);
73 70
	private int hasProblem1 = 1;
74 71
	private LSID lsid1;
75 72
	
76
	private Reference book2;
73
	private Reference<?> book2;
77 74
	private String editionString2 ="Ed.2";
78 75
	private String volumeString2 ="Vol.2";
79 76
	private Team team2;
80
	private Reference printSeries2;
77
	private Reference<?> printSeries2;
81 78
	private Annotation annotation2;
82 79
	private String annotationString2;
83 80
	private String title2 = "Title2";
......
85 82
	private TimePeriod datePublished2 = TimePeriod.NewInstance(2002);
86 83
	private int hasProblem2 = 1;
87 84
	private LSID lsid2;
88
	private ReferenceFactory refFactory;
89 85
	
90 86
	
91
	private Reference book3;
87
	private Reference<?> book3;
92 88
	
93 89
	/**
94 90
	 * @throws java.lang.Exception
......
111 107
	 */
112 108
	@Before
113 109
	public void setUp() throws Exception {
114
		refFactory = ReferenceFactory.newInstance();
115 110
		bookMergeStrategy = DefaultMergeStrategy.NewInstance(Reference.class);
116 111
		team1 = Team.NewInstance();
117 112
		team1.setTitleCache("Team1", true);
118 113
		team2 = Team.NewInstance();
119 114
		team2.setTitleCache("Team2", true);
120
		printSeries1 = refFactory.newPrintSeries("Series1");
121
		printSeries2 = refFactory.newPrintSeries("Series2");
115
		printSeries1 = ReferenceFactory.newPrintSeries("Series1");
116
		printSeries2 = ReferenceFactory.newPrintSeries("Series2");
122 117
		annotation1 = Annotation.NewInstance("Annotation1", null);
123 118
		annotationString2 = "Annotation2";
124 119
		annotation2 = Annotation.NewInstance(annotationString2, null);
125 120
		
126
		book1 = refFactory.newBook();
121
		book1 = ReferenceFactory.newBook();
127 122
		book1.setAuthorTeam(team1);
128 123
		book1.setTitle(title1);
129 124
		book1.setEdition(editionString1);
......
136 131
		book1.setLsid(lsid1);
137 132
		book1.setNomenclaturallyRelevant(false);
138 133
		
139
		book2 = refFactory.newBook();
134
		book2 = ReferenceFactory.newBook();
140 135
		book2.setAuthorTeam(team2);
141 136
		book2.setTitle(title2);
142 137
		book2.setEdition(editionString2);
......
302 297
		Institution school1 = Institution.NewInstance();
303 298
		Institution school2 = Institution.NewInstance();
304 299
		
305
		Reference thesis1 = refFactory.newThesis();
300
		Reference<?> thesis1 = ReferenceFactory.newThesis();
306 301
		thesis1.setSchool(school1);
307 302
		//Thesis thesis1 = Thesis.NewInstance(school1);
308
		Reference thesis2 = refFactory.newThesis();
303
		Reference<?> thesis2 = ReferenceFactory.newThesis();
309 304
		thesis2.setSchool(school2);
310 305
		DefaultMergeStrategy thesisStrategy = DefaultMergeStrategy.NewInstance(Reference.class);
311 306
		
......
354 349
		botName2.setCombinationAuthorTeam(team2);
355 350
		
356 351
		//taxa
357
		TaxonBase taxon1= Taxon.NewInstance(botName1, book1);
358
		TaxonBase taxon2= Taxon.NewInstance(botName2, book2);
352
		TaxonBase<?> taxon1= Taxon.NewInstance(botName1, book1);
353
		TaxonBase<?> taxon2= Taxon.NewInstance(botName2, book2);
359 354
		
360 355
		try {
361 356
			botNameMergeStrategy.setMergeMode("combinationAuthorTeam", MergeMode.SECOND);

Also available in: Unified diff