Revision aae87424
Added by Andreas Müller over 1 year ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/cdm2cdm/Cdm2CdmImportBase.java | ||
---|---|---|
714 | 714 |
protected User handlePersistedUser(User user, Cdm2CdmImportState state) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { |
715 | 715 |
User result = (User)handlePersistedCdmBase(user, state); |
716 | 716 |
if (result.getUsername().equals("admin")){ |
717 |
//TODO why only admin, is this not a problem for all duplicated usernames? Was this a preliminary decision? |
|
717 | 718 |
result = getUserService().listByUsername("admin", MatchMode.EXACT, null, null, null, null, null).iterator().next(); |
718 | 719 |
state.putPermanent(user.getUuid(), result); |
719 | 720 |
cache(result, state); //necessary? |
... | ... | |
776 | 777 |
protected <T extends CdmBase> T handlePersistedCdmBase(CdmBase cdmBase, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException { |
777 | 778 |
T result = (T)getTarget(cdmBase, state); |
778 | 779 |
//complete |
779 |
cdmBase.setCreatedBy(detach(cdmBase.getCreatedBy(), state));
|
|
780 |
cdmBase.setCreatedBy(makeCreatedUpdatedBy(cdmBase.getCreatedBy(), state, false));
|
|
780 | 781 |
return result; |
781 | 782 |
} |
782 | 783 |
|
783 | 784 |
protected <T extends VersionableEntity> T handlePersisted(VersionableEntity entity, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException { |
784 | 785 |
T result = (T)handlePersistedCdmBase((CdmBase)entity, state); |
785 | 786 |
//complete |
786 |
entity.setUpdatedBy(detach(entity.getUpdatedBy(), state));
|
|
787 |
entity.setUpdatedBy(makeCreatedUpdatedBy(entity.getUpdatedBy(), state, true));
|
|
787 | 788 |
return result; |
788 | 789 |
} |
789 | 790 |
|
... | ... | |
1020 | 1021 |
return result; |
1021 | 1022 |
} |
1022 | 1023 |
|
1024 |
// ****************************** USER HANDLING |
|
1025 |
|
|
1026 |
private User makeCreatedUpdatedBy(User createdByOriginal, Cdm2CdmImportState state, boolean isUpdatedBy) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException { |
|
1027 |
UserImportMode mode = isUpdatedBy? state.getConfig().getUpdatedByMode() : state.getConfig().getCreatedByMode(); |
|
1028 |
|
|
1029 |
switch (mode) { |
|
1030 |
case NONE: |
|
1031 |
return null; |
|
1032 |
case ORIGINAL: |
|
1033 |
return detach(createdByOriginal, state); |
|
1034 |
default: |
|
1035 |
logger.warn("Mode not yet supported: " + mode); |
|
1036 |
return null; |
|
1037 |
} |
|
1038 |
} |
|
1039 |
|
|
1040 |
|
|
1023 | 1041 |
// ****************************** INVISIBLE **************************************/ |
1024 | 1042 |
|
1025 | 1043 |
protected void setInvisible(Object holder, String fieldName, Object value) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { |
Also available in: Unified diff
ref #9771 improvements to Cdm2CdmImportBase including a first (not ready) version for VocabularyFilter