49 |
49 |
import eu.etaxonomy.cdm.model.common.LanguageString;
|
50 |
50 |
import eu.etaxonomy.cdm.model.common.OriginalSourceBase;
|
51 |
51 |
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
|
|
52 |
import eu.etaxonomy.cdm.model.common.TermType;
|
|
53 |
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
52 |
54 |
import eu.etaxonomy.cdm.model.location.NamedArea;
|
53 |
55 |
import eu.etaxonomy.cdm.model.media.Media;
|
54 |
56 |
import eu.etaxonomy.cdm.model.molecular.DnaSample;
|
... | ... | |
68 |
70 |
/**
|
69 |
71 |
* @author p.kelbert
|
70 |
72 |
* @author p.plitzner
|
|
73 |
* @author k.luther
|
71 |
74 |
* @since 20.10.2008
|
72 |
75 |
*/
|
73 |
76 |
@Component
|
... | ... | |
93 |
96 |
MapWrapper<TeamOrPersonBase<?>> authorStore = (MapWrapper<TeamOrPersonBase<?>>)stores.get(ICdmIO.TEAM_STORE);
|
94 |
97 |
state.setPersonStore(authorStore);
|
95 |
98 |
MapWrapper<Reference> referenceStore = (MapWrapper<Reference>)stores.get(ICdmIO.REFERENCE_STORE);
|
|
99 |
createKindOfUnitsMap(state);
|
96 |
100 |
URI sourceUri = config.getSourceUri();
|
97 |
101 |
try{
|
98 |
102 |
state.setTx(startTransaction());
|
... | ... | |
287 |
291 |
}
|
288 |
292 |
|
289 |
293 |
|
|
294 |
/**
|
|
295 |
*
|
|
296 |
*/
|
|
297 |
private void createKindOfUnitsMap(Abcd206ImportState state) {
|
|
298 |
|
|
299 |
ICdmRepository cdmRepository = state.getConfig().getCdmAppController();
|
|
300 |
if (cdmRepository == null){
|
|
301 |
cdmRepository = this;
|
|
302 |
}
|
|
303 |
|
|
304 |
List<DefinedTerm> terms = cdmRepository.getTermService().listByTermType(TermType.KindOfUnit, null, 0, null, null);
|
|
305 |
kindOfUnitsMap = new HashMap<>();
|
|
306 |
for (DefinedTerm kindOfUnit:terms) {
|
|
307 |
kindOfUnitsMap.put(kindOfUnit.getLabel().toLowerCase(), kindOfUnit);
|
|
308 |
}
|
|
309 |
}
|
|
310 |
|
|
311 |
|
290 |
312 |
/**
|
291 |
313 |
* @param state
|
292 |
314 |
* @param item
|
293 |
315 |
*/
|
294 |
316 |
private void getSiblings(Abcd206ImportState state, Object item, DerivedUnitFacade facade) {
|
295 |
317 |
String unitId = facade.getCatalogNumber();
|
|
318 |
if (unitId == null){
|
|
319 |
unitId = facade.getAccessionNumber();
|
|
320 |
}
|
296 |
321 |
|
297 |
322 |
UnitAssociationParser unitParser = new UnitAssociationParser(state.getPrefix(), state.getReport(), state.getCdmRepository());
|
298 |
323 |
UnitAssociationWrapper unitAssociationWrapper = null;
|
299 |
324 |
for (URI accessPoint: state.getActualAccesPoint()){
|
300 |
325 |
unitAssociationWrapper = unitParser.parseSiblings(unitId, accessPoint);
|
301 |
|
if (unitAssociationWrapper.getAssociatedUnits() != null){
|
|
326 |
if (unitAssociationWrapper != null && unitAssociationWrapper.getAssociatedUnits() != null){
|
302 |
327 |
break;
|
303 |
328 |
}
|
304 |
329 |
}
|
... | ... | |
1002 |
1027 |
}
|
1003 |
1028 |
|
1004 |
1029 |
if (NB((state.getDataHolder()).getKindOfUnit()) != null) {
|
1005 |
|
if (state.getDataHolder().getKindOfUnit().toLowerCase().indexOf("clone")>-1) {
|
1006 |
|
kindOfUnit = getKindOfUnit(state, null, "clone culture", "clone culture", "cc", null);
|
1007 |
|
}
|
1008 |
|
else if (state.getDataHolder().getKindOfUnit().toLowerCase().startsWith("live")) {
|
1009 |
|
kindOfUnit = getKindOfUnit(state, null, "live sample", "live sample", "ls", null);
|
1010 |
|
}
|
|
1030 |
kindOfUnit = getKindOfUnit(state, null, state.getDataHolder().getKindOfUnit().toLowerCase(), null, null, null);
|
|
1031 |
if (kindOfUnit == null){
|
|
1032 |
if (state.getDataHolder().getKindOfUnit().toLowerCase().indexOf("clone")>-1) {
|
|
1033 |
kindOfUnit = getKindOfUnit(state, null, "clone culture", "clone culture", "cc", null);
|
|
1034 |
}
|
|
1035 |
else if (state.getDataHolder().getKindOfUnit().toLowerCase().startsWith("live")) {
|
|
1036 |
kindOfUnit = getKindOfUnit(state, null, "live sample", "live sample", "ls", null);
|
|
1037 |
}
|
|
1038 |
else if (state.getDataHolder().getKindOfUnit().toLowerCase().startsWith("microscopic slide")) {
|
|
1039 |
kindOfUnit = getKindOfUnit(state, null, "microscopic slide", "microscopic slide", "ms", null);
|
|
1040 |
}
|
1011 |
1041 |
|
1012 |
1042 |
|
1013 |
|
if (kindOfUnit == null) {
|
1014 |
|
logger.info("The kind of unit does not seem to be known: " + state.getDataHolder().getKindOfUnit());
|
|
1043 |
if (kindOfUnit == null) {
|
|
1044 |
logger.info("The kind of unit does not seem to be known: " + state.getDataHolder().getKindOfUnit());
|
1015 |
1045 |
|
|
1046 |
}
|
1016 |
1047 |
}
|
1017 |
1048 |
} else {
|
1018 |
1049 |
logger.info("The kind of unit is null");
|
... | ... | |
1232 |
1263 |
return false;
|
1233 |
1264 |
}
|
1234 |
1265 |
|
|
1266 |
|
|
1267 |
@Override
|
|
1268 |
protected DefinedTerm getKindOfUnit(Abcd206ImportState state, UUID uuid, String label, String description, String labelAbbrev, TermVocabulary<DefinedTerm> voc){
|
|
1269 |
|
|
1270 |
DefinedTerm unit = null;
|
|
1271 |
|
|
1272 |
if (uuid == null){
|
|
1273 |
unit = this.kindOfUnitsMap.get(label.toLowerCase());
|
|
1274 |
}else{
|
|
1275 |
unit = state.getKindOfUnit(uuid);
|
|
1276 |
|
|
1277 |
}
|
|
1278 |
if (unit == null){
|
|
1279 |
unit = (DefinedTerm)getTermService().find(uuid);
|
|
1280 |
if (unit == null){
|
|
1281 |
if (uuid == null){
|
|
1282 |
uuid = UUID.randomUUID();
|
|
1283 |
}
|
|
1284 |
unit = DefinedTerm.NewKindOfUnitInstance(description, label, labelAbbrev);
|
|
1285 |
unit.setUuid(uuid);
|
|
1286 |
if (voc == null){
|
|
1287 |
boolean isOrdered = false;
|
|
1288 |
voc = getVocabulary(TermType.KindOfUnit, uuidUserDefinedKindOfUnitVocabulary, "User defined vocabulary for kind-of-units", "User Defined Measurement kind-of-units", null, null, isOrdered, unit);
|
|
1289 |
}
|
|
1290 |
voc.addTerm(unit);
|
|
1291 |
getTermService().save(unit);
|
|
1292 |
}
|
|
1293 |
state.putKindOfUnit(unit);
|
|
1294 |
kindOfUnitsMap.put(unit.getLabel().toLowerCase(), unit);
|
|
1295 |
}
|
|
1296 |
return unit;
|
|
1297 |
}
|
|
1298 |
|
|
1299 |
|
1235 |
1300 |
}
|
smaller changes in ABCD import