2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.io
.berlinModel
.in
;
12 import java
.sql
.ResultSet
;
13 import java
.sql
.SQLException
;
14 import java
.sql
.Timestamp
;
17 import org
.apache
.logging
.log4j
.LogManager
;
18 import org
.apache
.logging
.log4j
.Logger
;
19 import org
.joda
.time
.DateTime
;
21 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
22 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
23 import eu
.etaxonomy
.cdm
.io
.berlinModel
.BerlinModelTransformer
;
24 import eu
.etaxonomy
.cdm
.io
.common
.DbImportBase
;
25 import eu
.etaxonomy
.cdm
.io
.common
.ICdmIO
;
26 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.EDITOR
;
27 import eu
.etaxonomy
.cdm
.io
.common
.IPartitionedIO
;
28 import eu
.etaxonomy
.cdm
.io
.common
.TdwgAreaProvider
;
29 import eu
.etaxonomy
.cdm
.model
.common
.AnnotatableEntity
;
30 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
31 import eu
.etaxonomy
.cdm
.model
.common
.AnnotationType
;
32 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
33 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
34 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
35 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
36 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
37 import eu
.etaxonomy
.cdm
.model
.common
.SourcedEntityBase
;
38 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
39 import eu
.etaxonomy
.cdm
.model
.location
.Country
;
40 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
41 import eu
.etaxonomy
.cdm
.model
.location
.NamedAreaType
;
42 import eu
.etaxonomy
.cdm
.model
.permission
.User
;
43 import eu
.etaxonomy
.cdm
.model
.reference
.ISourceable
;
44 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
45 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
46 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
47 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
48 import eu
.etaxonomy
.cdm
.model
.term
.TermType
;
49 import eu
.etaxonomy
.cdm
.model
.term
.TermVocabulary
;
50 import eu
.etaxonomy
.cdm
.persistence
.query
.MatchMode
;
56 public abstract class BerlinModelImportBase
57 extends DbImportBase
<BerlinModelImportState
, BerlinModelImportConfigurator
>
58 implements ICdmIO
<BerlinModelImportState
>, IPartitionedIO
<BerlinModelImportState
> {
60 private static final long serialVersionUID
= -4982506434258587864L;
61 private static final Logger logger
= LogManager
.getLogger();
63 public BerlinModelImportBase(String tableName
, String pluralString
) {
64 super(tableName
, pluralString
);
68 protected String
getIdQuery(BerlinModelImportState state
){
69 String result
= " SELECT " + getTableName() + "id FROM " + getTableName();
74 protected boolean doIdCreatedUpdatedNotes(BerlinModelImportState state
, DescriptionElementBase descriptionElement
, ResultSet rs
, String id
, String namespace
) throws SQLException
{
75 boolean success
= true;
77 success
&= doId(state
, descriptionElement
, id
, namespace
);
79 success
&= doCreatedUpdatedNotes(state
, descriptionElement
, rs
);
83 protected boolean doIdCreatedUpdatedNotes(BerlinModelImportState state
, IdentifiableEntity identifiableEntity
, ResultSet rs
, long id
, String namespace
, boolean excludeUpdated
, boolean excludeNotes
)
85 boolean success
= true;
87 success
&= doId(state
, identifiableEntity
, id
, namespace
);
89 success
&= doCreatedUpdatedNotes(state
, identifiableEntity
, rs
, excludeUpdated
, excludeNotes
);
94 protected boolean doIdCreatedUpdatedNotes(BerlinModelImportState state
, IdentifiableEntity identifiableEntity
, ResultSet rs
, long id
, String namespace
)
96 boolean excludeUpdated
= false;
97 return doIdCreatedUpdatedNotes(state
, identifiableEntity
, rs
, id
, namespace
, excludeUpdated
, false);
100 protected boolean doCreatedUpdatedNotes(BerlinModelImportState state
, AnnotatableEntity annotatableEntity
, ResultSet rs
)
102 boolean excludeUpdated
= false;
103 return doCreatedUpdatedNotes(state
, annotatableEntity
, rs
, excludeUpdated
, false);
106 protected boolean doCreatedUpdatedNotes(BerlinModelImportState state
, AnnotatableEntity annotatableEntity
,
107 ResultSet rs
, boolean excludeUpdated
, boolean excludeNotes
)
110 BerlinModelImportConfigurator config
= state
.getConfig();
111 Object createdWhen
= rs
.getObject("Created_When");
112 String createdWho
= rs
.getString("Created_Who");
113 createdWho
= normalizeUsername(state
, createdWho
);
114 Object updatedWhen
= null;
115 String updatedWho
= null;
116 if (excludeUpdated
== false){
118 updatedWhen
= rs
.getObject("Updated_When");
119 updatedWho
= rs
.getString("Updated_who");
120 updatedWho
= normalizeUsername(state
, updatedWho
);
121 } catch (SQLException e
) {
122 //Table "Name" has no updated when/who
126 boolean success
= true;
128 //Created When, Who, Updated When Who
129 if (config
.getEditor() == null || config
.getEditor().equals(EDITOR
.NO_EDITORS
)){
131 }else if (config
.getEditor().equals(EDITOR
.EDITOR_AS_ANNOTATION
)){
132 String createdAnnotationString
= "Berlin Model record was created By: " + String
.valueOf(createdWho
) + " (" + String
.valueOf(createdWhen
) + ") ";
133 if (updatedWhen
!= null && updatedWho
!= null){
134 createdAnnotationString
+= " and updated By: " + String
.valueOf(updatedWho
) + " (" + String
.valueOf(updatedWhen
) + ")";
136 Annotation annotation
= Annotation
.NewInstance(createdAnnotationString
, Language
.DEFAULT());
137 //TODO make transaction compatible, same as common sec reference
138 annotation
.setCommentator(config
.getCommentator());
139 annotation
.setAnnotationType(AnnotationType
.TECHNICAL());
140 annotatableEntity
.addAnnotation(annotation
);
141 }else if (config
.getEditor().equals(EDITOR
.EDITOR_AS_EDITOR
)){
143 boolean xmlSourceAdded
= addXmlSource(state
, rs
, annotatableEntity
, createdWho
, false);
145 creator
= getXmlImporter(state
);
147 creator
= getUser(state
, createdWho
);
149 annotatableEntity
.setCreatedBy(creator
);
152 xmlSourceAdded
= addXmlSource(state
, rs
, annotatableEntity
, updatedWho
, xmlSourceAdded
);
154 updator
= getXmlImporter(state
);
156 updator
= getUser(state
, updatedWho
);
158 annotatableEntity
.setUpdatedBy(updator
);
160 DateTime created
= getDateTime(createdWhen
);
161 DateTime updated
= getDateTime(updatedWhen
);
162 annotatableEntity
.setCreated(created
);
163 annotatableEntity
.setUpdated(updated
);
165 logger
.warn("Editor type not yet implemented: " + config
.getEditor());
171 String notes
= rs
.getString("notes");
172 doNotes(annotatableEntity
, notes
);
181 private User
getXmlImporter(BerlinModelImportState state
) {
182 return getUser(state
, "import to BM");
189 * @param annotatableEntity
190 * @param xmlSourceAdded
192 * @throws SQLException
194 private boolean addXmlSource(BerlinModelImportState state
, ResultSet rs
, AnnotatableEntity annotatableEntity
, String username
, boolean existsAlready
) throws SQLException
{
195 if (!state
.getConfig().isEuroMed()){
198 if (isXmlImport(username
) && existsAlready
){
201 String idInSource
= getIdInSource(state
, rs
);
203 boolean isXmlUser
= isXmlImport(username
);
204 Reference ref
= isXmlUser?
getXmlRef(state
, username
): null;
205 if (ref
!= null || isNotBlank(idInSource
)){
206 if (annotatableEntity
.isInstanceOf(SourcedEntityBase
.class)){
207 SourcedEntityBase
<?
> sourcedEntity
= CdmBase
.deproxy(annotatableEntity
, SourcedEntityBase
.class);
208 sourcedEntity
.addImportSource(idInSource
, null, ref
, null);
209 }else if (annotatableEntity
.isInstanceOf(DescriptionElementBase
.class)){
210 DescriptionElementBase descriptionElement
= CdmBase
.deproxy(annotatableEntity
, DescriptionElementBase
.class);
211 descriptionElement
.addImportSource(idInSource
, null, ref
, null);
220 protected String
getIdInSource(BerlinModelImportState state
, ResultSet rs
) throws SQLException
{
230 private Reference
getXmlRef(BerlinModelImportState state
, String username
) {
231 String namespace
= "IMPORT USER";
232 Reference ref
= state
.getRelatedObject(namespace
, username
, Reference
.class);
234 if (state
.getXmlImportRefUuid(username
)!= null){
235 ref
= getReferenceService().find(state
.getXmlImportRefUuid(username
));
238 Pager
<Reference
> pager
= getReferenceService().findByTitle(Reference
.class, username
, MatchMode
.EXACT
, null, null, null, null, null);
239 if (pager
.getCount()>0){
240 ref
= pager
.getRecords().get(0);
241 if (pager
.getCount()>1){
242 logger
.warn("More then 1 reference found for " + username
);
247 ref
= ReferenceFactory
.newDatabase();
248 ref
.setTitleCache(username
, true);
249 ref
.setTitle(username
);
250 ref
.addImportSource(null, this.getTableName(), state
.getTransactionalSourceReference(), null);
251 getReferenceService().save(ref
);
253 state
.addRelatedObject(namespace
, username
, ref
);
254 state
.putXmlImportRefUuid(username
, ref
.getUuid());
265 private boolean isXmlImport(String username
) {
266 if (username
== null){
269 return username
.matches(".*\\.xml")
270 ||username
.equals("MCL-Import, a.mueller")
271 ||username
.equals("pandora import (J.Li)")
272 ||username
.equals("Import from Kew Checklist 2010")
273 ||username
.equals("Import from ILDIS 2010")
274 ||username
.equals("s_em_ImportCastroviejoReferences")
275 ||username
.equals("s_em_ImportUotilaReferences")
276 ||username
.equals("s_em_ImportValdesReferences")
277 ||username
.equals("s_em_NewImportNomReferences")
278 ||username
.equals("Import from Anthos 2010");
282 private DateTime
getDateTime(Object timeString
){
283 if (timeString
== null){
286 DateTime dateTime
= null;
287 if (timeString
instanceof Timestamp
){
288 Timestamp timestamp
= (Timestamp
)timeString
;
289 dateTime
= new DateTime(timestamp
);
291 logger
.warn("time ("+timeString
+") is not a timestamp. Datetime set to current date. ");
292 dateTime
= new DateTime();
304 protected Taxon
getTaxon(BerlinModelImportState state
, int taxonId
, Map
<String
, TaxonBase
> taxonMap
, int factId
) {
305 TaxonBase
<?
> taxonBase
= taxonMap
.get(String
.valueOf(taxonId
));
308 // if (taxonBase == null && ! state.getConfig().isDoTaxa()){
309 // taxonBase = Taxon.NewInstance(TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES()), null);
313 if ( taxonBase
instanceof Taxon
) {
314 taxon
= (Taxon
) taxonBase
;
315 } else if (taxonBase
!= null) {
316 logger
.warn("TaxonBase (" + taxonId
+ ") for Fact(Specimen) with factId " + factId
+ " was not of type Taxon but: " + taxonBase
.getClass().getSimpleName());
319 logger
.warn("TaxonBase (" + taxonId
+ ") for Fact(Specimen) with factId " + factId
+ " is null.");
327 * Searches first in the detail maps then in the ref maps for a reference.
328 * Returns the reference as soon as it finds it in one of the map, according
329 * to the order of the map.
330 * If nomRefDetailFk is <code>null</code> no search on detail maps is performed.
331 * If one of the maps is <code>null</code> no search on the according map is
333 * You may define the order of search by the order you pass the maps but
334 * make sure to always pass the detail maps first.
335 * @param firstDetailMap
336 * @param secondDetailMap
338 * @param secondRefMap
339 * @param nomRefDetailFk
343 protected Reference
getReferenceFromMaps(
344 Map
<String
, Reference
> detailMap
,
345 Map
<String
, Reference
> refMap
,
346 String nomRefDetailFk
,
348 Reference ref
= null;
349 if (detailMap
!= null){
350 ref
= detailMap
.get(nomRefDetailFk
);
353 ref
= refMap
.get(nomRefFk
);
360 * Searches for a reference in the first detail map. If it does not exist it
361 * searches in the second detail map. Returns null if it does not exist in any map.
362 * A map may be <code>null</code> to avoid search on this map.
363 * @param secondDetailMap
364 * @param firstDetailMap
365 * @param nomRefDetailFk
368 private Reference
getReferenceDetailFromMaps(Map
<String
, Reference
> firstDetailMap
, Map
<String
, Reference
> secondDetailMap
, String nomRefDetailFk
) {
369 Reference result
= null;
370 if (nomRefDetailFk
!= null){
372 if (firstDetailMap
!= null){
373 result
= firstDetailMap
.get(nomRefDetailFk
);
375 if (result
== null && secondDetailMap
!= null){
376 result
= secondDetailMap
.get(nomRefDetailFk
);
382 protected NamedArea
getOtherAreas(BerlinModelImportState state
, String emCodeString
, String tdwgCodeString
) {
383 String em
= CdmUtils
.Nz(emCodeString
).trim();
384 String tdwg
= CdmUtils
.Nz(tdwgCodeString
).trim();
386 if ("EM".equals(em
)){
387 return getNamedArea(state
, BerlinModelTransformer
.euroMedUuid
, "Euro+Med", "Euro+Med area", "EM", null, null);
388 }else if("Rf".equals(em
)){
389 return Country
.RUSSIANFEDERATION();
391 }else if("KRY-OO;UKR-UK".equals(tdwg
)){
392 return Country
.UKRAINE();
394 }else if("TCS-AZ;TCS-NA".equals(tdwg
)){
395 return Country
.AZERBAIJANREPUBLICOF();
396 }else if("TCS-AB;TCS-AD;TCS-GR".equals(tdwg
)){
397 return Country
.GEORGIA();
399 }else if("Cc".equals(em
)){
400 return getNamedArea(state
, BerlinModelTransformer
.uuidCaucasia
, "Caucasia (Ab + Ar + Gg + Rf(CS))", "Euro+Med area 'Caucasia (Ab + Ar + Gg + Rf(CS))'", "Cc", null, null);
404 else if("EUR".equals(em
)){
405 return TdwgAreaProvider
.getAreaByTdwgAbbreviation("1");
406 }else if("14".equals(em
)){
407 return TdwgAreaProvider
.getAreaByTdwgAbbreviation("14");
408 }else if("21".equals(em
)){
409 return TdwgAreaProvider
.getAreaByTdwgAbbreviation("21"); // Macaronesia
410 }else if("33".equals(em
)){
411 return TdwgAreaProvider
.getAreaByTdwgAbbreviation("33");
413 }else if("SM".equals(em
)){
414 return getNamedArea(state
, BerlinModelTransformer
.uuidSerbiaMontenegro
, "Serbia & Montenegro", "Euro+Med area 'Serbia & Montenegro'", "SM", NamedAreaType
.ADMINISTRATION_AREA(), null);
415 }else if("Sr".equals(em
)){
416 return getNamedArea(state
, BerlinModelTransformer
.uuidSerbia
, "Serbia", "Euro+Med area 'Serbia' (including Kosovo and Vojvodina)", "Sr", NamedAreaType
.ADMINISTRATION_AREA(), null);
420 }else if("Rs".equals(em
)){
421 return getNamedArea(state
, BerlinModelTransformer
.uuidUssr
, "Former USSR", "Euro+Med area 'Former USSR'", "Rs", NamedAreaType
.ADMINISTRATION_AREA(), null);
422 }else if("Rs(N)".equals(em
)){
423 return getNamedArea(state
, BerlinModelTransformer
.uuidRussiaNorthern
, "Russia Northern", "Euro+Med area 'Russia Northern'", "Rs(N)", null, null);
424 }else if("Rs(B)".equals(em
)){
425 return getNamedArea(state
, BerlinModelTransformer
.uuidRussiaBaltic
, "Russia Baltic", "Euro+Med area 'Russia Baltic'", "Rs(B)", null, null);
426 }else if("Rs(C)".equals(em
)){
427 return getNamedArea(state
, BerlinModelTransformer
.uuidRussiaCentral
, "Russia Central", "Euro+Med area 'Russia Central'", "Rs(C)", null, null);
428 }else if("Rs(W)".equals(em
)){
429 return getNamedArea(state
, BerlinModelTransformer
.uuidRussiaSouthWest
, "Russia Southwest", "Euro+Med area 'Russia Southwest'", "Rs(W)", null, null);
430 }else if("Rs(E)".equals(em
)){
431 return getNamedArea(state
, BerlinModelTransformer
.uuidRussiaSouthEast
, "Russia Southeast", "Euro+Med area 'Russia Southeast'", "Rs(E)", null, null);
434 }else if("AE".equals(em
)){
435 return getNamedArea(state
, BerlinModelTransformer
.uuidEastAegeanIslands
, "East Aegean Islands", "Euro+Med area 'East Aegean Islands'", "AE", null, null);
436 }else if("AE(T)".equals(em
)){
437 return getNamedArea(state
, BerlinModelTransformer
.uuidTurkishEastAegeanIslands
, "Turkish East Aegean Islands", "Euro+Med area 'Turkish East Aegean Islands'", "AE(T)", null, null);
438 }else if("Tu".equals(em
)){
439 return getNamedArea(state
, BerlinModelTransformer
.uuidTurkey
, "Turkey", "Euro+Med area 'Turkey' (without AE(T))", "Tu", null, null);
441 //TODO Azores, Canary Is.
442 }else if("Md(D)".equals(em
)){
443 return getNamedArea(state
, BerlinModelTransformer
.uuidDesertas
, "Desertas", "Euro+Med area 'Desertas'", "Md(D)", null, null);
444 }else if("Md(M)".equals(em
)){
445 return getNamedArea(state
, BerlinModelTransformer
.uuidMadeira
, "Madeira", "Euro+Med area 'Madeira'", "Md(M)", null, null);
446 }else if("Md(P)".equals(em
)){
447 return getNamedArea(state
, BerlinModelTransformer
.uuidPortoSanto
, "Porto Santo", "Euro+Med area 'Porto Santo'", "Md(P)", null, null);
449 }else if("Az(L)".equals(em
)){
450 return getNamedArea(state
, BerlinModelTransformer
.uuidFlores
, "Flores", "Euro+Med area 'Flores'", "Az(L)", null, null);
451 }else if("Az(C)".equals(em
)){
452 return getNamedArea(state
, BerlinModelTransformer
.uuidCorvo
, "Corvo", "Euro+Med area 'Corvo'", "Az(C)", null, null);
453 }else if("Az(F)".equals(em
)){
454 return getNamedArea(state
, BerlinModelTransformer
.uuidFaial
, "Faial", "Euro+Med area 'Faial'", "Az(F)", null, null);
455 }else if("Az(G)".equals(em
)){
456 return getNamedArea(state
, BerlinModelTransformer
.uuidGraciosa
, "Graciosa", "Euro+Med area 'Graciosa'", "Az(G)", null, null);
457 }else if("Az(J)".equals(em
)){
458 return getNamedArea(state
, BerlinModelTransformer
.uuidSaoJorge
, "S\u00E3o Jorge", "Euro+Med area 'S\u00E3o Jorge'", "Az(J)", null, null);
459 }else if("Az(M)".equals(em
)){
460 return getNamedArea(state
, BerlinModelTransformer
.uuidSaoMiguel
, "S\u00E3o Miguel", "Euro+Med area 'S\u00E3o Miguel'", "Az(M)", null, null);
461 }else if("Az(P)".equals(em
)){
462 return getNamedArea(state
, BerlinModelTransformer
.uuidPico
, "Pico", "Euro+Med area 'Pico'", "Az(P)", null, null);
463 }else if("Az(S)".equals(em
)){
464 return getNamedArea(state
, BerlinModelTransformer
.uuidSantaMaria
, "Santa Maria", "Euro+Med area 'Santa Maria'", "Az(S)", null, null);
465 }else if("Az(T)".equals(em
)){
466 return getNamedArea(state
, BerlinModelTransformer
.uuidTerceira
, "Terceira", "Euro+Med area 'Terceira'", "Az(T)", null, null);
468 }else if("Ca(C)".equals(em
)){
469 return getNamedArea(state
, BerlinModelTransformer
.uuidGranCanaria
, "Gran Canaria", "Euro+Med area 'Gran Canaria'", "Ca(C)", null, null);
470 }else if("Ca(F)".equals(em
)){
471 return getNamedArea(state
, BerlinModelTransformer
.uuidFuerteventura
, "Fuerteventura with Lobos", "Euro+Med area 'Fuerteventura with Lobos'", "Ca(F)", null, null);
472 }else if("Ca(G)".equals(em
)){
473 return getNamedArea(state
, BerlinModelTransformer
.uuidGomera
, "Gomera", "Euro+Med area 'Gomera'", "Ca(G)", null, null);
474 }else if("Ca(H)".equals(em
)){
475 return getNamedArea(state
, BerlinModelTransformer
.uuidHierro
, "Hierro", "Euro+Med area 'Hierro'", "Ca(H)", null, null);
476 }else if("Ca(L)".equals(em
)){
477 return getNamedArea(state
, BerlinModelTransformer
.uuidLanzaroteWithGraciosa
, "Lanzarote with Graciosa", "Euro+Med area 'Lanzarote with Graciosa'", "Ca(L)", null, null);
478 }else if("Ca(P)".equals(em
)){
479 return getNamedArea(state
, BerlinModelTransformer
.uuidLaPalma
, "La Palma", "Euro+Med area 'La Palma'", "Ca(P)", null, null);
480 }else if("Ca(T)".equals(em
)){
481 return getNamedArea(state
, BerlinModelTransformer
.uuidTenerife
, "Tenerife", "Euro+Med area 'Tenerife'", "Ca(T)", null, null);
483 }else if("Bl(I)".equals(em
)){
484 return getNamedArea(state
, BerlinModelTransformer
.uuidIbizaWithFormentera
, "Ibiza with Formentera", "Euro+Med area 'Ibiza with Formentera'", "Bl(I)", null, null);
485 }else if("Bl(M)".equals(em
)){
486 return getNamedArea(state
, BerlinModelTransformer
.uuidTerceira
, "Mallorca", "Euro+Med area 'Mallorca'", "Bl(M)", null, null);
487 }else if("Bl(N)".equals(em
)){
488 return getNamedArea(state
, BerlinModelTransformer
.uuidTerceira
, "Menorca", "Euro+Med area 'Menorca'", "Bl(N)", null, null);
491 logger
.warn("Area(em: '" + em
+ "', tdwg: '" + tdwg
+"') could not be found");
500 protected TermVocabulary
<MarkerType
> getEuroMedMarkerTypeVoc(BerlinModelImportState state
) {
501 TermVocabulary
<MarkerType
> markerTypeVoc
= getVocabulary(state
, TermType
.MarkerType
, BerlinModelTransformer
.uuidVocEMMarkerType
,
502 "Euro+Med marker type vocabulary", "E+M marker types", null, null, false, MarkerType
.COMPLETE());
503 return markerTypeVoc
;
508 * @param sourceReference
511 protected Reference
getSourceReference(Reference sourceReference
) {
512 Reference persistentSourceReference
= getReferenceService().find(sourceReference
.getUuid()); //just to be sure
513 if (persistentSourceReference
!= null){
514 sourceReference
= persistentSourceReference
;
516 return sourceReference
;
519 protected static <T
extends IdentifiableSource
> boolean importSourceExists(ISourceable
<T
> sourceable
, String idInSource
,
520 String namespace
, Reference ref
) {
521 for (T source
: sourceable
.getSources()){
522 if (CdmUtils
.nullSafeEqual(namespace
, source
.getIdNamespace()) &&
523 CdmUtils
.nullSafeEqual(idInSource
, source
.getIdInSource()) &&
524 CdmUtils
.nullSafeEqual(ref
, source
.getCitation())){
536 protected String
normalizeUsername(BerlinModelImportState state
, String username
) {
537 if (username
== null){
540 username
= username
.trim();
541 if (state
.getConfig().isEuroMed()){
542 if (username
.matches("[A-Za-z]+[7-9][0-9]")){
543 username
= username
.substring(0, username
.length()-2);
544 }else if(username
.matches("(mariam[1-4]|palermo|palma|paltar)")){
546 }else if (username
.matches("a.mueller.*") || "AM".equals(username
)){
547 username
= "a.mueller";
548 }else if (username
.matches("sh,.*")){
550 }else if (username
.matches("J.Li.*pandora")){
551 username
= "pandora import (J.Li)";
552 }else if (username
.matches("euromed")){
555 if(username
.matches("kapet")){