Project

General

Profile

« Previous | Next » 

Revision 7c778a7e

Added by Andreas Müller about 10 years ago

latest globis import changes and update for IPartionedIO signature for app-import

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisImportBase.java
19 19

  
20 20
import org.apache.commons.lang.StringUtils;
21 21
import org.apache.log4j.Logger;
22
import org.hibernate.NonUniqueObjectException;
22 23
import org.joda.time.DateTime;
23 24

  
24 25
import eu.etaxonomy.cdm.api.service.AgentServiceImpl;
......
169 170
				for (Person member :((Team) author).getTeamMembers()){
170 171
					Person existingPerson = state.getPerson(member.getTitleCache());
171 172
					if (existingPerson != null){
173
						try {
174
							getAgentService().update(existingPerson);
175
						} catch (NonUniqueObjectException nuoe){
176
							// person already exists in 
177
							existingPerson = CdmBase.deproxy(getAgentService().find(existingPerson.getUuid()), Person.class);
178
							state.putPerson(existingPerson.getTitleCache(), existingPerson);
179
						} catch (Exception e) {
180
							throw new RuntimeException (e);
181
						}
172 182
						newTeam.addTeamMember(existingPerson);
183
						
184
						logger.warn("newTeam " + newTeam.getId());
173 185
					}else{
174 186
						newTeam.addTeamMember(member);
175 187
					}	
......
186 198

  
187 199
	private TeamOrPersonBase<?> saveAndDecide(TeamOrPersonBase<?> existing, TeamOrPersonBase<?> author, String key, GlobisImportState state) {
188 200
		if (existing != null){
189
			getAgentService().update(existing);
201
			try {
202
				getAgentService().update(existing);
203
			} catch (NonUniqueObjectException nuoe){
204
				// person already exists in 
205
				existing = CdmBase.deproxy(getAgentService().find(existing.getUuid()), TeamOrPersonBase.class);
206
				putAgent(existing, key, state);
207
			} catch (Exception e) {
208
				throw new RuntimeException (e);
209
			}
190 210
			return existing;
191 211
		}else{
192 212
			getAgentService().save(author);
193
			if (author instanceof Team){
194
				state.putTeam(key, (Team)author);
195
			}else{
196
				state.putPerson(key, (Person)author);
197
			}
213
			putAgent(author, key, state);
198 214
			return author;
199 215
		}
200 216
	}
201 217

  
218
	/**
219
	 * @param author
220
	 * @param key
221
	 * @param state
222
	 */
223
	private void putAgent(TeamOrPersonBase<?> agent, String key, GlobisImportState state) {
224
		if (agent instanceof Team){
225
			state.putTeam(key, (Team)agent);
226
		}else{
227
			state.putPerson(key, (Person)agent);
228
		}
229
	}
230

  
202 231
	/**
203 232
	 * @param state
204 233
	 * @param countryStr

Also available in: Unified diff