Project

General

Profile

« Previous | Next » 

Revision 5559e194

Added by Andreas Müller over 12 years ago

remove deprecated call for description.setAddSource

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelNameFactsImport.java
136 136
								description.addElement(protolog);
137 137
								taxonNameBase.addDescription(description);
138 138
								if (citation != null){
139
									description.addDescriptionSource(citation);
139
									description.addSource(null, null, citation, null);
140 140
									protolog.addSource(null, null, citation, nameFactRefDetail, null, null);
141 141
								}
142 142
							}//end NAME_FACT_PROTOLOGUE
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/sdd/in/SDDDataSetImport.java
416 416
			if (StringUtils.isNotBlank(ref)) {
417 417
				if (ve instanceof TaxonDescription) {
418 418
					TaxonDescription td = (TaxonDescription) ve;
419
					if (td.getDescriptionSources().size() > 0) {
420
						this.associateImageWithCdmBase(ref,(Reference) td.getDescriptionSources().toArray()[0]);
419
					if (td.getSources().size() > 0) {
420
						this.associateImageWithCdmBase(ref, td.getSources().iterator().next().getCitation());
421 421
					} else {
422
						Reference descriptionSource = ReferenceFactory.newGeneric();
422
						Reference<?> descriptionSource = ReferenceFactory.newGeneric();
423 423
						sources.add(descriptionSource);
424
						td.addDescriptionSource(descriptionSource);
424
						td.addSource(null, null, descriptionSource, null);
425 425
						this.associateImageWithCdmBase(ref,descriptionSource);
426 426
					}
427 427
				} else {
......
645 645
					location.setAnnotationType(annotationType);
646 646
					(publication).addAnnotation(location);
647 647
				}
648
				td.addDescriptionSource(publication);
648
				td.addSource(null, null, publication, null);
649 649
			}
650 650
		}
651 651
		logger.info("end makeTaxonDescriptions ...");
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/sdd/in/SDDImport.java
109 109
	private Map<String,String> locations = new HashMap<String,String>();
110 110
	private Map<String,List<CdmBase>> mediaObject_ListCdmBase = new HashMap<String,List<CdmBase>>();
111 111
	private Map<String,String> mediaObject_Role = new HashMap<String,String>();
112
	private Map<String,Reference> publications = new HashMap<String,Reference>();
112
	private Map<String,Reference<?>> publications = new HashMap<String,Reference<?>>();
113 113
	private Map<String,State> states = new HashMap<String,State>();
114 114
	private Map<String,TaxonDescription> taxonDescriptions = new HashMap<String,TaxonDescription>();
115
	private Map<String,NonViralName> taxonNameBases = new HashMap<String,NonViralName>();
115
	private Map<String,NonViralName<?>> taxonNameBases = new HashMap<String,NonViralName<?>>();
116 116
	private Map<String,MeasurementUnit> units = new HashMap<String,MeasurementUnit>();
117 117
	private Map<String,TaxonNode> taxonNodes = new HashMap<String,TaxonNode>();
118 118
	private Map<String,NamedArea> namedAreas = new HashMap<String,NamedArea>();
......
120 120
	private Map<String,Modifier> modifiers = new HashMap<String,Modifier>();
121 121
	
122 122
	private Set<MarkerType> markerTypes = new HashSet<MarkerType>();
123
	private Set<TermVocabulary> vocabularies = new HashSet<TermVocabulary>();
123
	private Set<TermVocabulary<?>> vocabularies = new HashSet<TermVocabulary<?>>();
124 124

  
125 125
	private Set<Feature> descriptiveConcepts = new HashSet<Feature>();
126 126
	private Set<AnnotationType> annotationTypes = new HashSet<AnnotationType>();
127 127
//	private Set<Feature> featureSet = new HashSet<Feature>();
128
	private Set<Reference> sources = new HashSet<Reference>();
129
	private Reference sec = ReferenceFactory.newDatabase();
130
	private Reference sourceReference = null;
128
	private Set<Reference<?>> sources = new HashSet<Reference<?>>();
129
	private Reference<?> sec = ReferenceFactory.newDatabase();
130
	private Reference<?> sourceReference = null;
131 131

  
132 132
	private Language datasetLanguage = null;
133 133
	private WorkingSet workingSet = null;
......
177 177
		// <TechnicalMetadata created="2006-04-20T10:00:00">
178 178
		importTechnicalMetadata(root, sddNamespace, sddConfig);
179 179
		List<Element> elDatasets = root.getChildren("Dataset",sddNamespace);
180
		int i = 0;
180
//		int i = 0;
181 181

  
182 182
		//for each Dataset
183 183
		logger.info("start Dataset ...");
......
389 389
			if (StringUtils.isNotBlank(ref)) {
390 390
				if (ve instanceof TaxonDescription) {
391 391
					TaxonDescription td = (TaxonDescription) ve;
392
					if (td.getDescriptionSources().size() > 0) {
393
						this.associateImageWithCdmBase(ref,(Reference) td.getDescriptionSources().toArray()[0]);
392
					if (td.getSources().size() > 0) {
393
						this.associateImageWithCdmBase(ref, td.getSources().iterator().next().getCitation());
394 394
					} else {
395
						Reference descriptionSource = ReferenceFactory.newGeneric();
395
						Reference<?> descriptionSource = ReferenceFactory.newGeneric();
396 396
						sources.add(descriptionSource);
397
						td.addDescriptionSource(descriptionSource);
397
						td.addSource(null, null, descriptionSource, null);
398 398
						this.associateImageWithCdmBase(ref,descriptionSource);
399 399
					}
400 400
				} else {
......
618 618
					location.setAnnotationType(annotationType);
619 619
					(publication).addAnnotation(location);
620 620
				}
621
				td.addDescriptionSource(publication);
621
				td.addSource(null, null,publication, null);
622 622
			}
623 623
		}
624 624
		logger.info("end makeTaxonDescriptions ...");
......
632 632
		}
633 633
		saveFeatures();
634 634
		
635
		for (Reference publication : publications.values()){
635
		for (Reference<?> publication : publications.values()){
636 636
			getReferenceService().save(publication); 
637 637
		}
638 638
		
639
		for (Reference source : sources){
639
		for (Reference<?> source : sources){
640 640
			getReferenceService().save(source); 
641 641
		}
642 642

  
......
659 659
	 * 
660 660
	 */
661 661
	private void saveVocabularies() {
662
		for (TermVocabulary vocabulary : vocabularies ){
662
		for (TermVocabulary<?> vocabulary : vocabularies ){
663 663
			getVocabularyService().save(vocabulary);
664 664
		}
665 665
		
......
749 749
		Element elSpecimens = elDataset.getChild("Specimens",sddNamespace);
750 750
		if (elSpecimens != null){
751 751
			List<Element> listSpecimens = elSpecimens.getChildren("Specimen", sddNamespace);
752
			int j = 0;
753 752
			for (Element elSpecimen : listSpecimens) {
754 753
				String id = elSpecimen.getAttributeValue("id");
755 754
				Specimen specimen = null;
......
881 880
				String id = elTaxonName.getAttributeValue("id");
882 881
				String uri = elTaxonName.getAttributeValue("uri");
883 882

  
884
				NonViralName tnb = null;
883
				NonViralName<?> tnb = null;
885 884
				if (!id.equals("")) {
886 885
					tnb = NonViralName.NewInstance(null);
887 886
					IdentifiableSource source = null;
......
1188 1187
	 */
1189 1188
	private Taxon handleCDNoScope(Namespace sddNamespace, SDDImportState cdmState, Element elCodedDescription	) {
1190 1189
		Taxon taxon = null;
1191
		NonViralName nonViralName = NonViralName.NewInstance(null);
1190
		NonViralName<?> nonViralName = NonViralName.NewInstance(null);
1192 1191
		String id = new String("" + taxonNamesCount);
1193 1192
		IdentifiableSource source = IdentifiableSource.NewInstance(id, "TaxonName");
1194 1193
		importRepresentation(elCodedDescription, sddNamespace, nonViralName, id, cdmState);
......
1225 1224
		Taxon taxon = null;
1226 1225
		Element elTaxonName = elScope.getChild("TaxonName", sddNamespace);
1227 1226
		String ref = elTaxonName.getAttributeValue("ref");
1228
		NonViralName nonViralName = taxonNameBases.get(ref);
1227
		NonViralName<?> nonViralName = taxonNameBases.get(ref);
1229 1228
		
1230 1229
		if(cdmState.getConfig().isDoMatchTaxa()){
1231 1230
			taxon = getTaxonService().findBestMatchingTaxon(nonViralName.getTitleCache());
......
1508 1507
				try {
1509 1508

  
1510 1509
					String idP = elPublication.getAttributeValue("id");
1511
					Reference publication = ReferenceFactory.newArticle();
1510
					Reference<?> publication = ReferenceFactory.newArticle();
1512 1511
					importRepresentation(elPublication, sddNamespace, publication, idP, cdmState);
1513 1512

  
1514 1513
					publications.put(idP,publication);
......
1585 1584
						if (lcb != null) {
1586 1585
							for (int k = 0; k < lcb.size(); k++) {
1587 1586
								if (lcb.get(k) instanceof DefinedTermBase) {
1588
									DefinedTermBase dtb = (DefinedTermBase) lcb.get(k);
1587
									DefinedTermBase<?> dtb = (DefinedTermBase<?>) lcb.get(k);
1589 1588
									// if (lcb.get(0) instanceof DefinedTermBase) {
1590 1589
									// DefinedTermBase dtb = (DefinedTermBase) lcb.get(0);
1591 1590
									//									if (dtb!=null) {
......
1598 1597
									//										}
1599 1598
									//									}
1600 1599
								} else if (lcb.get(k) instanceof Reference) {
1601
									Reference rb = (Reference) lcb.get(k);
1600
									Reference<?> rb = (Reference<?>) lcb.get(k);
1602 1601
									//} else if (lcb.get(0) instanceof Reference) {
1603 1602
									//Reference rb = (Reference) lcb.get(0);
1604 1603
									// rb.setTitleCache(label);
......
1859 1858
						Classification classification =  Classification.NewInstance(label);
1860 1859
						importRepresentation(elTaxonHierarchy, sddNamespace, classification, "", cdmState);
1861 1860
					
1862
						Set<TaxonNode> root = classification.getChildNodes();
1863 1861
						Element elNodes = elTaxonHierarchy.getChild("Nodes", sddNamespace); // There can be only one <Nodes> block for TaxonHierarchies
1864 1862
						List<Element> listNodes = elNodes.getChildren("Node", sddNamespace);
1865 1863
						
1866 1864
						for (Element elNode : listNodes){
1867 1865
							String idN = elNode.getAttributeValue("id");
1868
							TaxonNameBase tnb = null;
1866
							TaxonNameBase<?,?> tnb = null;
1869 1867
							if (!idN.equals("")) {
1870 1868
								Element elTaxonName = elNode.getChild("TaxonName", sddNamespace);
1871 1869
								String refTN = elTaxonName.getAttributeValue("ref");
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/sdd/out/SDDDocumentBuilder.java
15 15
import java.io.OutputStreamWriter;
16 16
import java.io.Writer;
17 17
import java.util.HashMap;
18
import java.util.HashSet;
18 19
import java.util.Iterator;
19 20
import java.util.List;
20 21
import java.util.Map;
......
98 99
	private SDDDataSet cdmSource;
99 100

  
100 101
	private final Map<Person, String> agents = new HashMap<Person, String>();
101
	private final Map<TaxonNameBase, String> taxonNames = new HashMap<TaxonNameBase, String>();
102
	private final Map<TaxonNameBase<?,?>, String> taxonNames = new HashMap<TaxonNameBase<?,?>, String>();
102 103
	private final Map<Feature, String> characters = new HashMap<Feature, String>();
103 104
	private final Map<FeatureNode, String> featureNodes = new HashMap<FeatureNode, String>();
104 105
	private final Map<Feature, String> descriptiveConcepts = new HashMap<Feature, String>();
105 106
	private final Map<TaxonDescription, String> codedDescriptions = new HashMap<TaxonDescription, String>();
106 107
	private final Map<Media, String> medias = new HashMap<Media, String>();
107 108
	private final Map<State, String> states = new HashMap<State, String>();
108
	private final Map<Reference, String> articles = new HashMap<Reference, String>();
109
	private final Map<Reference<?>, String> articles = new HashMap<Reference<?>, String>();
109 110
	private final Map<VersionableEntity, String> featuretrees = new HashMap<VersionableEntity, String>();
110 111
	private final Map<Modifier, String> modifiers = new HashMap<Modifier, String>();
111 112
	private final Map<TaxonNode, String> taxonNodes = new HashMap<TaxonNode, String>();
112 113
	private final Map<NamedArea, String> namedAreas = new HashMap<NamedArea, String>();
113 114
	private final Map<Specimen, String> specimens = new HashMap<Specimen, String>();
114
	private final ReferenceFactory refFactory = ReferenceFactory.newInstance();
115

  
115
	
116 116
	private final Map<VersionableEntity, String> features = new HashMap<VersionableEntity, String>();
117 117
	private int agentsCount = 0;
118 118
	private int articlesCount = 0;
......
269 269

  
270 270
		List<Reference> references = cdmSource.getReferences();
271 271
		Iterator<Reference> iterator = references.iterator();
272
		IDatabase d = refFactory.newDatabase();
272
		IDatabase d = ReferenceFactory.newDatabase();
273 273
		while (iterator.hasNext()) {
274 274
			Reference reference = iterator.next();
275 275
			if (reference.getType().equals(ReferenceType.Database)) {
......
295 295
		List<Reference> references = cdmSource.getReferences();
296 296
		Iterator<Reference> iterator = references.iterator();
297 297
		boolean database = false;
298
		IDatabase d = refFactory.newDatabase();
298
		IDatabase d = ReferenceFactory.newDatabase();
299 299
		while ((iterator.hasNext()) && (!database)) {
300
			Reference reference = iterator.next();
300
			Reference<?> reference = iterator.next();
301 301
			if (reference.getType().equals(ReferenceType.Database)) {
302 302
				d = reference;
303 303
			}
......
354 354
		buildLabel(representation, reference.getTitleCache());
355 355

  
356 356
		Set<Annotation> annotations = ((Reference) reference).getAnnotations();
357
		Iterator iterator = annotations.iterator();
357
		Iterator<Annotation> iterator = annotations.iterator();
358 358
		String detailText = null;
359 359
		if (iterator.hasNext()) {
360 360
			Annotation annotation = (Annotation) iterator.next();
......
830 830
			}
831 831
		}
832 832

  
833
		Set<Reference> descriptionSources = taxonDescription
834
				.getDescriptionSources();
835
		for (Iterator<Reference> rb = descriptionSources.iterator(); rb
836
				.hasNext();) {
833
		Set<Reference> descriptionSources = new HashSet<Reference>();
834
		for (IdentifiableSource source : taxonDescription.getSources()){
835
			descriptionSources.add(source.getCitation());
836
		}
837
		for (Iterator<Reference> rb = descriptionSources.iterator(); rb.hasNext();) {
837 838
			Reference descriptionSource = rb.next();
838 839
			if (descriptionSource.getType().equals(ReferenceType.Article)) {
839 840

  
......
841 842
				articlesCount = buildReference(descriptionSource, articles,
842 843
						REF, citation, "p", articlesCount);
843 844

  
844
				Set<Annotation> annotations = descriptionSource
845
						.getAnnotations();
846
				for (Iterator<Annotation> a = annotations.iterator(); a
847
						.hasNext();) {
845
				Set<Annotation> annotations = descriptionSource.getAnnotations();
846
				for (Iterator<Annotation> a = annotations.iterator(); a.hasNext();) {
848 847
					Annotation annotation = a.next();
849
					AnnotationType annotationType = annotation
850
							.getAnnotationType();
848
					AnnotationType annotationType = annotation.getAnnotationType();
851 849
					if (annotationType != null) {
852 850
						String type = annotationType.getLabel();
853 851
						if (type.equals("location")) {
854
							citation.setAttribute("location",
855
									annotation.getText());
852
							citation.setAttribute("location",annotation.getText());
856 853
						}
857 854
					}
858 855
				}
......
1369 1366
			for (int i = 0; i < cdmSource.getReferences().size(); i++) {
1370 1367
				ElementImpl elPublication = new ElementImpl(document,
1371 1368
						"Publication");
1372
				Reference publication = cdmSource.getReferences().get(i);
1369
				Reference<?> publication = cdmSource.getReferences().get(i);
1373 1370
				Set<Annotation> annotations = publication.getAnnotations();
1374 1371
				for (Iterator<Annotation> a = annotations.iterator(); a
1375 1372
						.hasNext();) {
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx/TaxonXDescriptionImport.java
111 111
		TaxonDescription description = TaxonDescription.NewInstance();
112 112
		description.setTitleCache(getDescriptionTitle(state), true);
113 113
		if (modsReference != null){
114
			description.addDescriptionSource(modsReference);
114
			description.addSource(null, null, modsReference, null);
115 115
		}
116 116
		
117 117
		Element elTaxonBody = root.getChild("taxonxBody", nsTaxonx);
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/tcsrdf/TcsRdfTaxonImport.java
179 179
				Taxon taxon = Taxon.NewInstance(taxonNameBase, sec);
180 180
				List<DescriptionElementBase> geoList = makeGeo(elTaxonConcept, geoNamespace, rdfNamespace);
181 181
				TaxonDescription description = TaxonDescription.NewInstance(taxon);
182
				description.addDescriptionSource(taxon.getSec());
182
				description.addSource(null, null, taxon.getSec(), null);
183 183
				for (DescriptionElementBase geo: geoList){
184 184
					description.addElement(geo);
185 185
					DescriptionElementSource source = DescriptionElementSource.NewInstance(null, null, taxon.getSec(), null);
cdmlib-io/src/test/java/eu/etaxonomy/cdm/io/sdd/in/SDDImportTest.java
12 12
import static org.junit.Assert.assertEquals;
13 13
import static org.junit.Assert.assertNotNull;
14 14

  
15
import java.net.MalformedURLException;
16
import java.net.URI;
15 17
import java.net.URISyntaxException;
16 18
import java.net.URL;
17 19

  
......
31 33
 * @version 1.0
32 34
 */
33 35

  
34
@Ignore // we ignore this test at the moment because it does not run with maven
36
//@Ignore // we ignore this test at the moment because it does not run with maven
35 37
public class SDDImportTest extends CdmTransactionalIntegrationTest {
36 38
	
37 39
	@SpringBeanByType
......
45 47
	@Before
46 48
	public void setUp() throws URISyntaxException {
47 49
		URL url = this.getClass().getResource("/eu/etaxonomy/cdm/io/sdd/SDDImportTest-input.xml");
50
//		URI uri = url.toURI();
51
		URI	uri = URI.create("file:///C:/localCopy/Data/xper/Cichorieae-DA2.sdd.xml");
48 52
		Assert.assertNotNull(url);
49
		configurator = SDDImportConfigurator.NewInstance(url.toURI(), null);
53
		configurator = SDDImportConfigurator.NewInstance(uri, null);
50 54
	}
51 55
	
52 56
	@Test

Also available in: Unified diff