Project

General

Profile

« Previous | Next » 

Revision 531fc7bc

Added by Andreas Müller almost 8 years ago

Remove generics from Reference in cdmlib (except for cdmlib-model) #5830

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx/TaxonXModsImport.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
46 46
	public TaxonXModsImport(){
47 47
		super();
48 48
	}
49
	
50
	public boolean doCheck(TaxonXImportState state){
49

  
50
	@Override
51
    public boolean doCheck(TaxonXImportState state){
51 52
		boolean result = true;
52 53
		logger.warn("Checking for TaxonXMods not yet implemented");
53 54
		//result &= checkArticlesWithoutJournal(bmiConfig);
54
		
55

  
55 56
		return result;
56 57
	}
57 58

  
58
	public void doInvoke(TaxonXImportState state){		
59
	@Override
60
    public void doInvoke(TaxonXImportState state){
59 61
		logger.info("start make mods reference ...");
60 62
		TaxonXImportConfigurator config = state.getConfig();
61 63
		Element root = config.getSourceRoot();
62 64
		Namespace nsTaxonx = root.getNamespace();
63 65
		Namespace nsMods = Namespace.getNamespace("mods", "http://www.loc.gov/mods/v3");
64
		
66

  
65 67
		state.setModsReference(null);  //delete old reference
66 68
		Element elTaxonHeader = root.getChild("taxonxHeader", nsTaxonx);
67 69
		if (elTaxonHeader != null){
68 70
			Element elMods = elTaxonHeader.getChild("mods", nsMods);
69 71
			if (elMods != null){
70
				Reference<?> ref = ReferenceFactory.newGeneric();
72
				Reference ref = ReferenceFactory.newGeneric();
71 73
				//TitleInfo
72 74
				Element elTitleInfo = elMods.getChild("titleInfo", nsMods);
73 75
				if (elTitleInfo != null){
......
81 83
				//origin info
82 84
				Element elOriginInfo = elMods.getChild("originInfo", nsMods);
83 85
				makeOriginInfo(elOriginInfo, ref);
84
				
86

  
85 87
				//publish
86 88
				if (state.getConfig().isPublishReferences()){
87 89
					boolean publish = false;
88 90
					ref.addMarker(Marker.NewInstance(MarkerType.IN_BIBLIOGRAPHY(), publish));
89 91
				}
90
				
92

  
91 93
				//save
92 94
				state.setModsReference(ref);
93
				
95

  
94 96
			}
95 97
		}
96 98

  
97 99
		logger.info("end make mods reference ...");
98 100
		return;
99 101
	}
100
	
102

  
101 103

  
102 104
	/**
103 105
	 * @param contentList
......
114 116
		}
115 117
		contentList.removeAll(removeList);
116 118
	}
117
	
119

  
118 120
	/**
119 121
	 * @param elModsName
120 122
	 * @param ref
121 123
	 */
122
	private void makeOriginInfo(Element elOriginInfo, Reference<?> ref) {
124
	private void makeOriginInfo(Element elOriginInfo, Reference ref) {
123 125
		Namespace nsMods = elOriginInfo.getNamespace();
124 126
		List<Content> contentList = elOriginInfo.getContent();
125
		
127

  
126 128
		//dateIssued
127 129
		Element elDateIssued = elOriginInfo.getChild("dateIssued", nsMods);
128 130
		if (elDateIssued != null){
129 131
			String dateIssued = elDateIssued.getTextNormalize();
130 132
			contentList.remove(elDateIssued);
131
			
133

  
132 134
			TimePeriod datePublished = TimePeriodParser.parseString(dateIssued);
133 135
			if (ref.getType().isPublication()){
134 136
				((IPublicationBase)ref).setDatePublished(datePublished );
......
136 138
				logger.warn("Reference has issue date but is not of type publication base. Date was not set");
137 139
			}
138 140
		}
139
		
141

  
140 142
		//dateIssued
141 143
		Element elPublisher = elOriginInfo.getChild("publisher", nsMods);
142 144
		if (elPublisher != null){
143 145
			String publisher = elPublisher.getTextNormalize();
144 146
			contentList.remove(elPublisher);
145
			
147

  
146 148
			if (ref.getType().isPublication()){
147 149
				((IPublicationBase)ref).setPublisher(publisher);
148 150
			}else{
149 151
				logger.warn("Reference has publisher but is not of type publication base. Publisher was not set");
150 152
			}
151 153
		}
152
		
154

  
153 155
		removeEmptyContent(contentList);
154 156
		for (Content o: contentList){
155 157
			logger.warn(o + " (in mods:originInfo) not yet implemented for mods import");
......
166 168
	//THIS implementation is against the mods semantics but supports the current
167 169
	//format for palmae taxonX files
168 170
	//The later has to be changed and this part has to be adapted
169
	private void makeModsName(Element elModsName, Reference<?> ref) {
171
	private void makeModsName(Element elModsName, Reference ref) {
170 172
		int UNPARSED = 0;
171 173
		int PARSED = 1;
172 174
		Namespace nsMods = elModsName.getNamespace();
173 175
		List<Content> contentList = elModsName.getContent();
174 176
		Team authorship = Team.NewInstance();
175
		
177

  
176 178
		//name
177 179
		List<Element> elNameParts = elModsName.getChildren("namePart", nsMods);
178 180
		int mode = UNPARSED;
......
181 183
				mode = PARSED;
182 184
			}
183 185
		}
184
		
186

  
185 187
		if (mode == 0){
186
			Element elNamePart = elNameParts.get(0); 
188
			Element elNamePart = elNameParts.get(0);
187 189
			if (elNamePart != null){
188 190
				String namePart = elNamePart.getTextNormalize();
189 191
				contentList.remove(elNamePart);
......
193 195
				logger.warn("Multiple nameparts of unexpected type");
194 196
			}
195 197
		}else{
196
			
198

  
197 199
			Person lastTeamMember = Person.NewInstance();
198 200
			List<Element> tmpNamePartList = new ArrayList<Element>();
199 201
			tmpNamePartList.addAll(elNameParts);
......
211 213
			}
212 214
		}
213 215
		ref.setAuthorship(authorship);
214
		
216

  
215 217
		removeEmptyContent(contentList);
216 218
		for (Content o: contentList){
217 219
			logger.warn(o + " (in mods:name) not yet implemented for mods import");
......
223 225
	 * @param elTitleInfo
224 226
	 * @param ref
225 227
	 */
226
	private void makeTitleInfo(Element elTitleInfo, Reference<?> ref) {
228
	private void makeTitleInfo(Element elTitleInfo, Reference ref) {
227 229
		Namespace nsMods = elTitleInfo.getNamespace();
228 230
		List<Content> contentList = elTitleInfo.getContent();
229
		
231

  
230 232
		//title
231 233
		Element elTitle = elTitleInfo.getChild("title", nsMods);
232 234
		if (elTitle != null){
......
240 242
		}
241 243
		return;
242 244
	}
243
	
245

  
244 246
	/* (non-Javadoc)
245 247
	 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator)
246 248
	 */
247
	protected boolean isIgnore(TaxonXImportState state){
249
	@Override
250
    protected boolean isIgnore(TaxonXImportState state){
248 251
		return ! state.getConfig().isDoMods();
249 252
	}
250
	
253

  
251 254
}

Also available in: Unified diff