Revision 51171c9d
Added by Andreas Müller about 13 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/sdd/in/SDDDataSetImport.java | ||
---|---|---|
37 | 37 |
import eu.etaxonomy.cdm.io.common.CdmImportBase; |
38 | 38 |
import eu.etaxonomy.cdm.io.common.ICdmIO; |
39 | 39 |
import eu.etaxonomy.cdm.io.common.ICdmImport; |
40 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator; |
|
41 | 40 |
import eu.etaxonomy.cdm.io.common.ImportHelper; |
42 | 41 |
import eu.etaxonomy.cdm.io.sdd.SDDTransformer; |
43 | 42 |
import eu.etaxonomy.cdm.model.agent.Person; |
... | ... | |
189 | 188 |
// @Override |
190 | 189 |
// public boolean doInvoke(IImportConfigurator config, Map<String, MapWrapper<? extends CdmBase>> stores){ |
191 | 190 |
@Override |
192 |
public boolean doInvoke(SDDImportState state){ |
|
193 |
boolean success = true; |
|
191 |
public void doInvoke(SDDImportState state){ |
|
194 | 192 |
|
195 | 193 |
TransactionStatus ts = startTransaction(); |
196 | 194 |
SDDImportConfigurator sddConfig = state.getConfig(); |
... | ... | |
212 | 210 |
logger.info("start Dataset ..."); |
213 | 211 |
progressMonitor.beginTask("Importing SDD data", elDatasets.size()); |
214 | 212 |
for (Element elDataset : elDatasets){ |
215 |
success &= importDataset(elDataset, sddNamespace, state);
|
|
213 |
importDataset(elDataset, sddNamespace, state); |
|
216 | 214 |
// if ((++i % modCount) == 0){ logger.info("dataset(s) handled: " + i);} |
217 | 215 |
// logger.info(i + " dataset(s) handled"); |
218 | 216 |
progressMonitor.worked(1); |
... | ... | |
220 | 218 |
commitTransaction(ts); |
221 | 219 |
progressMonitor.done(); |
222 | 220 |
logger.info("End of transaction"); |
223 |
return success;
|
|
221 |
return; |
|
224 | 222 |
} |
225 | 223 |
|
226 | 224 |
/* (non-Javadoc) |
... | ... | |
298 | 296 |
} |
299 | 297 |
|
300 | 298 |
// imports the representation (label, detail, lang) of a particular SDD element |
301 |
protected void importRepresentation(Element parent, Namespace sddNamespace, VersionableEntity ve, String id, IImportConfigurator config){
|
|
299 |
protected void importRepresentation(Element parent, Namespace sddNamespace, VersionableEntity ve, String id, SDDImportState state){
|
|
302 | 300 |
Element elRepresentation = parent.getChild("Representation",sddNamespace); |
303 | 301 |
|
304 | 302 |
Map<Language,List<String>> langLabDet = new HashMap<Language,List<String>>(); |
... | ... | |
562 | 560 |
} |
563 | 561 |
|
564 | 562 |
// imports the complete dataset information |
565 |
protected boolean importDataset(Element elDataset, Namespace sddNamespace, SDDImportState state){ // <Dataset xml:lang="en-us"> |
|
566 |
boolean success = true; |
|
567 |
SDDImportConfigurator sddConfig = state.getConfig(); |
|
563 |
protected void importDataset(Element elDataset, Namespace sddNamespace, SDDImportState state){ // <Dataset xml:lang="en-us"> |
|
564 |
// SDDImportConfigurator sddConfig = state.getConfig(); |
|
568 | 565 |
|
569 | 566 |
workingSet = WorkingSet.NewInstance(); |
570 |
importDatasetLanguage(elDataset,sddConfig);
|
|
567 |
importDatasetLanguage(elDataset,state);
|
|
571 | 568 |
importDatasetRepresentation(elDataset, sddNamespace); |
572 | 569 |
importRevisionData(elDataset, sddNamespace); |
573 |
importIPRStatements(elDataset, sddNamespace, sddConfig);
|
|
574 |
importTaxonNames(elDataset, sddNamespace, sddConfig);
|
|
570 |
importIPRStatements(elDataset, sddNamespace, state);
|
|
571 |
importTaxonNames(elDataset, sddNamespace, state);
|
|
575 | 572 |
|
576 |
importDescriptiveConcepts(elDataset, sddNamespace, sddConfig);
|
|
577 |
success &= importCharacters(elDataset, sddNamespace, sddConfig);
|
|
578 |
importCharacterTrees(elDataset, sddNamespace, sddConfig, success);
|
|
573 |
importDescriptiveConcepts(elDataset, sddNamespace, state);
|
|
574 |
importCharacters(elDataset, sddNamespace, state);
|
|
575 |
importCharacterTrees(elDataset, sddNamespace, state);
|
|
579 | 576 |
|
580 | 577 |
MarkerType editorMarkerType = getMarkerType(state, SDDTransformer.uuidMarkerEditor, "editor", "Editor", "edt"); |
581 | 578 |
MarkerType geographicAreaMarkerType = getMarkerType(state, SDDTransformer.uuidMarkerSDDGeographicArea, "SDDGeographicArea", "SDDGeographicArea", "ga"); |
... | ... | |
595 | 592 |
saveStatisticalMeasure(); |
596 | 593 |
saveAnnotationType(); |
597 | 594 |
|
598 |
success &= importCodedDescriptions(elDataset, sddNamespace, sddConfig);
|
|
599 |
importAgents(elDataset, sddNamespace, sddConfig, success);
|
|
600 |
importPublications(elDataset, sddNamespace, sddConfig, success);
|
|
601 |
importMediaObjects(elDataset, sddNamespace, sddConfig, success);
|
|
602 |
importTaxonHierarchies(elDataset, sddNamespace, sddConfig, success);
|
|
603 |
importGeographicAreas(elDataset, sddNamespace, sddConfig);
|
|
604 |
importSpecimens(elDataset,sddNamespace, sddConfig);
|
|
595 |
importCodedDescriptions(elDataset, sddNamespace, state);
|
|
596 |
importAgents(elDataset, sddNamespace, state);
|
|
597 |
importPublications(elDataset, sddNamespace, state);
|
|
598 |
importMediaObjects(elDataset, sddNamespace, state);
|
|
599 |
importTaxonHierarchies(elDataset, sddNamespace, state);
|
|
600 |
importGeographicAreas(elDataset, sddNamespace, state);
|
|
601 |
importSpecimens(elDataset,sddNamespace, state);
|
|
605 | 602 |
|
606 | 603 |
|
607 | 604 |
if ((authors != null)||(editors != null)) { |
... | ... | |
682 | 679 |
} |
683 | 680 |
logger.info("end of persistence ..."); |
684 | 681 |
|
685 |
return success;
|
|
682 |
return; |
|
686 | 683 |
} |
687 | 684 |
|
688 | 685 |
/** |
... | ... | |
751 | 748 |
} |
752 | 749 |
|
753 | 750 |
// imports the default language of the dataset |
754 |
protected void importDatasetLanguage(Element elDataset, SDDImportConfigurator sddConfig){
|
|
751 |
protected void importDatasetLanguage(Element elDataset, SDDImportState state){
|
|
755 | 752 |
String nameLang = elDataset.getAttributeValue("lang",xmlNamespace); |
756 | 753 |
|
757 | 754 |
if (StringUtils.isNotBlank(nameLang)) { |
... | ... | |
766 | 763 |
} |
767 | 764 |
|
768 | 765 |
// imports the specimens |
769 |
protected void importSpecimens(Element elDataset, Namespace sddNamespace, SDDImportConfigurator sddConfig) {
|
|
766 |
protected void importSpecimens(Element elDataset, Namespace sddNamespace, SDDImportState cdmState) {
|
|
770 | 767 |
logger.info("start Specimens ..."); |
771 | 768 |
/* <Specimens> |
772 | 769 |
<Specimen id="sp1"> |
... | ... | |
786 | 783 |
if (!id.equals("")) { |
787 | 784 |
specimen = Specimen.NewInstance(); |
788 | 785 |
specimens.put(id,specimen); |
789 |
importRepresentation(elSpecimen, sddNamespace, specimen, id, sddConfig);
|
|
786 |
importRepresentation(elSpecimen, sddNamespace, specimen, id, cdmState);
|
|
790 | 787 |
} |
791 | 788 |
} |
792 | 789 |
|
... | ... | |
849 | 846 |
} |
850 | 847 |
|
851 | 848 |
// imports ipr statements associated with a dataset |
852 |
protected void importIPRStatements(Element elDataset, Namespace sddNamespace, SDDImportConfigurator sddConfig){
|
|
849 |
protected void importIPRStatements(Element elDataset, Namespace sddNamespace, SDDImportState state){
|
|
853 | 850 |
// <IPRStatements> |
854 | 851 |
logger.info("start IPRStatements ..."); |
855 | 852 |
Element elIPRStatements = elDataset.getChild("IPRStatements",sddNamespace); |
... | ... | |
897 | 894 |
} |
898 | 895 |
|
899 | 896 |
// imports the taxon names |
900 |
protected void importTaxonNames(Element elDataset, Namespace sddNamespace, SDDImportConfigurator sddConfig){
|
|
897 |
protected void importTaxonNames(Element elDataset, Namespace sddNamespace, SDDImportState cdmState){
|
|
901 | 898 |
// <TaxonNames> |
902 | 899 |
logger.info("start TaxonNames ..."); |
903 | 900 |
Element elTaxonNames = elDataset.getChild("TaxonNames",sddNamespace); |
... | ... | |
928 | 925 |
|
929 | 926 |
// <Representation> |
930 | 927 |
// <Label xml:lang="la">Viola hederacea Labill.</Label> |
931 |
importRepresentation(elTaxonName, sddNamespace, tnb, id, sddConfig);
|
|
928 |
importRepresentation(elTaxonName, sddNamespace, tnb, id, cdmState);
|
|
932 | 929 |
|
933 | 930 |
if ((++j % modCount) == 0){ logger.info("TaxonNames handled: " + j);} |
934 | 931 |
|
... | ... | |
937 | 934 |
} |
938 | 935 |
|
939 | 936 |
// imports the characters (categorical, quantitative and text ; sequence characters not supported) which correspond to CDM Features |
940 |
protected boolean importCharacters(Element elDataset, Namespace sddNamespace, SDDImportConfigurator sddConfig){ |
|
941 |
boolean success = true; |
|
937 |
protected void importCharacters(Element elDataset, Namespace sddNamespace, SDDImportState state){ |
|
942 | 938 |
// <Characters> |
943 | 939 |
logger.info("start Characters ..."); |
944 | 940 |
Element elCharacters = elDataset.getChild("Characters", sddNamespace); |
945 | 941 |
|
946 | 942 |
// <CategoricalCharacter id="c1"> |
947 | 943 |
if (elCharacters != null) { |
948 |
success &= handleCategoricalData(sddNamespace, sddConfig, elCharacters);
|
|
949 |
success &= handleQuantitativeData(sddNamespace, sddConfig, elCharacters);
|
|
950 |
success &= handleTextCharacters(sddNamespace, sddConfig, elCharacters);
|
|
944 |
handleCategoricalData(sddNamespace, state, elCharacters);
|
|
945 |
handleQuantitativeData(sddNamespace, state, elCharacters);
|
|
946 |
handleTextCharacters(sddNamespace, state, elCharacters);
|
|
951 | 947 |
} |
952 | 948 |
|
953 | 949 |
/*for (Iterator<Feature> f = features.values().iterator() ; f.hasNext() ;){ |
954 | 950 |
featureSet.add(f.next()); //XIM Why this line ? |
955 | 951 |
}*/ |
956 | 952 |
|
957 |
return success;
|
|
953 |
return; |
|
958 | 954 |
|
959 | 955 |
} |
960 | 956 |
|
961 | 957 |
/** |
962 | 958 |
* @param sddNamespace |
963 |
* @param sddConfig |
|
964 |
* @param success |
|
959 |
* @param cdmState |
|
965 | 960 |
* @param elCharacters |
966 | 961 |
* @return |
967 | 962 |
*/ |
968 |
private boolean handleCategoricalData(Namespace sddNamespace, SDDImportConfigurator sddConfig, Element elCharacters) { |
|
969 |
boolean success = true; |
|
963 |
private void handleCategoricalData(Namespace sddNamespace, SDDImportState cdmState, Element elCharacters) { |
|
970 | 964 |
List<Element> elCategoricalCharacters = elCharacters.getChildren("CategoricalCharacter", sddNamespace); |
971 | 965 |
int j = 0; |
972 | 966 |
for (Element elCategoricalCharacter : elCategoricalCharacters){ |
... | ... | |
975 | 969 |
String idCC = elCategoricalCharacter.getAttributeValue("id"); |
976 | 970 |
Feature categoricalCharacter = Feature.NewInstance(); |
977 | 971 |
categoricalCharacter.setKindOf(Feature.DESCRIPTION()); |
978 |
importRepresentation(elCategoricalCharacter, sddNamespace, categoricalCharacter, idCC, sddConfig);
|
|
972 |
importRepresentation(elCategoricalCharacter, sddNamespace, categoricalCharacter, idCC, cdmState);
|
|
979 | 973 |
categoricalCharacter.setSupportsCategoricalData(true); |
980 | 974 |
|
981 | 975 |
// <States> |
... | ... | |
1000 | 994 |
}else{ |
1001 | 995 |
logger.debug("State duplicate found"); |
1002 | 996 |
} |
1003 |
importRepresentation(elStateDefinition, sddNamespace, state, idS, sddConfig);
|
|
997 |
importRepresentation(elStateDefinition, sddNamespace, state, idS, cdmState);
|
|
1004 | 998 |
|
1005 | 999 |
termVocabularyState.addTerm(state); |
1006 | 1000 |
states.put(idS,state); |
... | ... | |
1010 | 1004 |
|
1011 | 1005 |
} catch (Exception e) { |
1012 | 1006 |
logger.warn("Import of CategoricalCharacter " + j + " failed."); |
1013 |
success = false;
|
|
1007 |
cdmState.setUnsuccessfull();
|
|
1014 | 1008 |
} |
1015 | 1009 |
|
1016 | 1010 |
if ((++j % modCount) == 0){ logger.info("CategoricalCharacters handled: " + j);} |
1017 | 1011 |
|
1018 | 1012 |
} |
1019 |
return success;
|
|
1013 |
return; |
|
1020 | 1014 |
} |
1021 | 1015 |
|
1022 | 1016 |
/** |
... | ... | |
1024 | 1018 |
* @param sddConfig |
1025 | 1019 |
* @param elCharacters |
1026 | 1020 |
*/ |
1027 |
private boolean handleQuantitativeData(Namespace sddNamespace, SDDImportConfigurator sddConfig, Element elCharacters) { |
|
1028 |
boolean success = true; |
|
1021 |
private void handleQuantitativeData(Namespace sddNamespace, SDDImportState cdmState, Element elCharacters) { |
|
1029 | 1022 |
int j; |
1030 | 1023 |
// <QuantitativeCharacter id="c2"> |
1031 | 1024 |
List<Element> elQuantitativeCharacters = elCharacters.getChildren("QuantitativeCharacter", sddNamespace); |
... | ... | |
1042 | 1035 |
// </Representation> |
1043 | 1036 |
Feature quantitativeCharacter = Feature.NewInstance(); |
1044 | 1037 |
quantitativeCharacter.setKindOf(Feature.DESCRIPTION()); |
1045 |
importRepresentation(elQuantitativeCharacter, sddNamespace, quantitativeCharacter, idQC, sddConfig);
|
|
1038 |
importRepresentation(elQuantitativeCharacter, sddNamespace, quantitativeCharacter, idQC, cdmState);
|
|
1046 | 1039 |
|
1047 | 1040 |
quantitativeCharacter.setSupportsQuantitativeData(true); |
1048 | 1041 |
|
... | ... | |
1089 | 1082 |
} catch (Exception e) { |
1090 | 1083 |
//FIXME |
1091 | 1084 |
logger.warn("Import of QuantitativeCharacter " + j + " failed."); |
1092 |
success = false;
|
|
1085 |
cdmState.setUnsuccessfull();
|
|
1093 | 1086 |
} |
1094 | 1087 |
|
1095 | 1088 |
if ((++j % modCount) == 0){ logger.info("QuantitativeCharacters handled: " + j);} |
1096 | 1089 |
|
1097 | 1090 |
} |
1098 |
return success;
|
|
1091 |
return; |
|
1099 | 1092 |
} |
1100 | 1093 |
|
1101 |
private boolean handleTextCharacters(Namespace sddNamespace, SDDImportConfigurator sddConfig, Element elCharacters) { |
|
1102 |
boolean success = true; |
|
1094 |
private void handleTextCharacters(Namespace sddNamespace, SDDImportState cdmState, Element elCharacters) { |
|
1103 | 1095 |
int j; |
1104 | 1096 |
// <TextCharacter id="c3"> |
1105 | 1097 |
List<Element> elTextCharacters = elCharacters.getChildren("TextCharacter", sddNamespace); |
... | ... | |
1116 | 1108 |
// </Representation> |
1117 | 1109 |
Feature textCharacter = Feature.NewInstance(); |
1118 | 1110 |
textCharacter.setKindOf(Feature.DESCRIPTION()); |
1119 |
importRepresentation(elTextCharacter, sddNamespace, textCharacter, idTC, sddConfig);
|
|
1111 |
importRepresentation(elTextCharacter, sddNamespace, textCharacter, idTC, cdmState);
|
|
1120 | 1112 |
|
1121 | 1113 |
textCharacter.setSupportsTextData(true); |
1122 | 1114 |
|
... | ... | |
1125 | 1117 |
} catch (Exception e) { |
1126 | 1118 |
//FIXME |
1127 | 1119 |
logger.warn("Import of TextCharacter " + j + " failed."); |
1128 |
success = false;
|
|
1120 |
cdmState.setUnsuccessfull();
|
|
1129 | 1121 |
} |
1130 | 1122 |
|
1131 | 1123 |
if ((++j % modCount) == 0){ logger.info("TextCharacters handled: " + j);} |
1132 | 1124 |
|
1133 | 1125 |
} |
1134 |
return success;
|
|
1126 |
return; |
|
1135 | 1127 |
} |
1136 | 1128 |
|
1137 | 1129 |
// imports the descriptions of taxa |
1138 |
protected boolean importCodedDescriptions(Element elDataset, Namespace sddNamespace, SDDImportConfigurator sddConfig){ |
|
1139 |
boolean success = true; |
|
1130 |
protected void importCodedDescriptions(Element elDataset, Namespace sddNamespace, SDDImportState cdmState){ |
|
1140 | 1131 |
|
1141 | 1132 |
// <CodedDescriptions> |
1142 | 1133 |
logger.info("start CodedDescriptions ..."); |
... | ... | |
1148 | 1139 |
int j = 0; |
1149 | 1140 |
//for each CodedDescription |
1150 | 1141 |
for (Element elCodedDescription : listCodedDescriptions){ |
1151 |
success &= handleCodedDescription(sddNamespace, sddConfig, elCodedDescription, j);
|
|
1142 |
handleCodedDescription(sddNamespace, cdmState, elCodedDescription, j);
|
|
1152 | 1143 |
if ((++j % modCount) == 0){ logger.info("CodedDescriptions handled: " + j);} |
1153 | 1144 |
} |
1154 | 1145 |
} |
1155 |
return success;
|
|
1146 |
return; |
|
1156 | 1147 |
} |
1157 | 1148 |
|
1158 | 1149 |
/** |
... | ... | |
1162 | 1153 |
* @param elCodedDescription |
1163 | 1154 |
* @return |
1164 | 1155 |
*/ |
1165 |
private boolean handleCodedDescription(Namespace sddNamespace, SDDImportConfigurator sddConfig, Element elCodedDescription, int j) { |
|
1166 |
boolean success = true ; |
|
1156 |
private void handleCodedDescription(Namespace sddNamespace, SDDImportState cdmState, Element elCodedDescription, int j) { |
|
1167 | 1157 |
try { |
1168 | 1158 |
|
1169 | 1159 |
String idCD = elCodedDescription.getAttributeValue("id"); |
... | ... | |
1176 | 1166 |
Annotation annotation = Annotation.NewInstance(generatorName, AnnotationType.TECHNICAL(),Language.DEFAULT()); |
1177 | 1167 |
taxonDescription.addAnnotation(annotation); |
1178 | 1168 |
} |
1179 |
importRepresentation(elCodedDescription, sddNamespace, taxonDescription, idCD, sddConfig);
|
|
1169 |
importRepresentation(elCodedDescription, sddNamespace, taxonDescription, idCD, cdmState);
|
|
1180 | 1170 |
|
1181 | 1171 |
// <Scope> |
1182 | 1172 |
// <TaxonName ref="t1"/> |
... | ... | |
1185 | 1175 |
Element elScope = elCodedDescription.getChild("Scope", sddNamespace); |
1186 | 1176 |
Taxon taxon; |
1187 | 1177 |
if (elScope != null) { |
1188 |
taxon = handleCDScope(sddNamespace, sddConfig, idCD, elScope);
|
|
1178 |
taxon = handleCDScope(sddNamespace, cdmState, idCD, elScope);
|
|
1189 | 1179 |
} else {//in case no taxon is linked to the description, a new one is created |
1190 |
taxon = handleCDNoScope(sddNamespace, sddConfig, elCodedDescription);
|
|
1180 |
taxon = handleCDNoScope(sddNamespace, cdmState, elCodedDescription);
|
|
1191 | 1181 |
} |
1192 | 1182 |
|
1193 | 1183 |
// <SummaryData> |
... | ... | |
1211 | 1201 |
} catch (Exception e) { |
1212 | 1202 |
//FIXME |
1213 | 1203 |
logger.warn("Import of CodedDescription " + j + " failed.", e); |
1214 |
success = false;
|
|
1204 |
cdmState.setUnsuccessfull();
|
|
1215 | 1205 |
} |
1216 |
return success;
|
|
1206 |
return; |
|
1217 | 1207 |
} |
1218 | 1208 |
|
1219 | 1209 |
/** |
... | ... | |
1224 | 1214 |
* @return |
1225 | 1215 |
*/ |
1226 | 1216 |
private Taxon handleCDNoScope(Namespace sddNamespace, |
1227 |
SDDImportConfigurator sddConfig, Element elCodedDescription ) {
|
|
1217 |
SDDImportState cdmState, Element elCodedDescription ) {
|
|
1228 | 1218 |
Taxon taxon = null; |
1229 | 1219 |
NonViralName nonViralName = NonViralName.NewInstance(null); |
1230 | 1220 |
String id = new String("" + taxonNamesCount); |
1231 | 1221 |
IdentifiableSource source = IdentifiableSource.NewInstance(id, "TaxonName"); |
1232 |
importRepresentation(elCodedDescription, sddNamespace, nonViralName, id, sddConfig);
|
|
1222 |
importRepresentation(elCodedDescription, sddNamespace, nonViralName, id, cdmState);
|
|
1233 | 1223 |
|
1234 |
if(sddConfig.isDoMatchTaxa()){
|
|
1224 |
if(cdmState.getConfig().isDoMatchTaxa()){
|
|
1235 | 1225 |
taxon = getTaxonService().findBestMatchingTaxon(nonViralName.getTitleCache()); |
1236 | 1226 |
} |
1237 | 1227 |
|
... | ... | |
1258 | 1248 |
* @param taxon |
1259 | 1249 |
* @return |
1260 | 1250 |
*/ |
1261 |
private Taxon handleCDScope(Namespace sddNamespace, SDDImportConfigurator sddConfig,
|
|
1251 |
private Taxon handleCDScope(Namespace sddNamespace, SDDImportState cdmState,
|
|
1262 | 1252 |
String idCD, Element elScope) { |
1263 | 1253 |
Taxon taxon = null; |
1264 | 1254 |
Element elTaxonName = elScope.getChild("TaxonName", sddNamespace); |
1265 | 1255 |
String ref = elTaxonName.getAttributeValue("ref"); |
1266 | 1256 |
NonViralName nonViralName = taxonNameBases.get(ref); |
1267 | 1257 |
|
1268 |
if(sddConfig.isDoMatchTaxa()){
|
|
1258 |
if(cdmState.getConfig().isDoMatchTaxa()){
|
|
1269 | 1259 |
taxon = getTaxonService().findBestMatchingTaxon(nonViralName.getTitleCache()); |
1270 | 1260 |
} |
1271 | 1261 |
|
... | ... | |
1446 | 1436 |
} |
1447 | 1437 |
|
1448 | 1438 |
// imports the persons associated with the dataset creation, modification, related publications |
1449 |
protected void importAgents(Element elDataset, Namespace sddNamespace, SDDImportConfigurator sddConfig, boolean success){
|
|
1439 |
protected void importAgents(Element elDataset, Namespace sddNamespace, SDDImportState cdmState){
|
|
1450 | 1440 |
// <Agents> |
1451 | 1441 |
logger.info("start Agents ..."); |
1452 | 1442 |
Element elAgents = elDataset.getChild("Agents",sddNamespace); |
... | ... | |
1466 | 1456 |
// <Detail role="Description">Ali Baba is also known as r.a.m.</Detail> |
1467 | 1457 |
// </Representation> |
1468 | 1458 |
Person person = Person.NewInstance(); |
1469 |
importRepresentation(elAgent, sddNamespace, person, idA, sddConfig);
|
|
1459 |
importRepresentation(elAgent, sddNamespace, person, idA, cdmState);
|
|
1470 | 1460 |
person.addSource(IdentifiableSource.NewInstance(idA, "Agent")); |
1471 | 1461 |
|
1472 | 1462 |
/*XIM <Links> |
... | ... | |
1513 | 1503 |
} catch (Exception e) { |
1514 | 1504 |
//FIXME |
1515 | 1505 |
logger.warn("Import of Agent " + j + " failed."); |
1516 |
success = false;
|
|
1506 |
cdmState.setUnsuccessfull();
|
|
1517 | 1507 |
} |
1518 | 1508 |
|
1519 | 1509 |
if ((++j % modCount) == 0){ logger.info("Agents handled: " + j);} |
... | ... | |
1523 | 1513 |
} |
1524 | 1514 |
|
1525 | 1515 |
// imports publications related with the data set |
1526 |
protected void importPublications(Element elDataset, Namespace sddNamespace, SDDImportConfigurator sddConfig, boolean success){
|
|
1516 |
protected void importPublications(Element elDataset, Namespace sddNamespace, SDDImportState cdmState){
|
|
1527 | 1517 |
/* <Publications> |
1528 | 1518 |
<Publication id="p112"> |
1529 | 1519 |
<Representation> |
... | ... | |
1547 | 1537 |
|
1548 | 1538 |
String idP = elPublication.getAttributeValue("id"); |
1549 | 1539 |
Reference publication = ReferenceFactory.newArticle(); |
1550 |
importRepresentation(elPublication, sddNamespace, publication, idP, sddConfig);
|
|
1540 |
importRepresentation(elPublication, sddNamespace, publication, idP, cdmState);
|
|
1551 | 1541 |
|
1552 | 1542 |
publications.put(idP,publication); |
1553 | 1543 |
|
1554 | 1544 |
} catch (Exception e) { |
1555 | 1545 |
logger.warn("Import of Publication " + j + " failed."); |
1556 |
success = false;
|
|
1546 |
cdmState.setUnsuccessfull();
|
|
1557 | 1547 |
} |
1558 | 1548 |
|
1559 | 1549 |
if ((++j % modCount) == 0){ logger.info("Publications handled: " + j);} |
... | ... | |
1563 | 1553 |
} |
1564 | 1554 |
|
1565 | 1555 |
// imports media objects such as images //FIXME check mediaobj |
1566 |
protected void importMediaObjects(Element elDataset, Namespace sddNamespace, SDDImportConfigurator sddConfig, boolean success){
|
|
1556 |
protected void importMediaObjects(Element elDataset, Namespace sddNamespace, SDDImportState cdmState){
|
|
1567 | 1557 |
// <MediaObjects> |
1568 | 1558 |
logger.info("start MediaObjects ..."); |
1569 | 1559 |
Element elMediaObjects = elDataset.getChild("MediaObjects",sddNamespace); |
... | ... | |
1584 | 1574 |
// <Label>Image description, e.g. to be used for alt-attribute in html.</Label> |
1585 | 1575 |
// </Representation> |
1586 | 1576 |
Media media = Media.NewInstance(); |
1587 |
importRepresentation(elMO, sddNamespace, media, idMO, sddConfig);
|
|
1577 |
importRepresentation(elMO, sddNamespace, media, idMO, cdmState);
|
|
1588 | 1578 |
|
1589 | 1579 |
// <Type>Image</Type> |
1590 | 1580 |
// <Source href="http://test.edu/test.jpg"/> |
... | ... | |
1606 | 1596 |
logger.error("Malformed URL", e); |
1607 | 1597 |
} |
1608 | 1598 |
} else { |
1609 |
String sns = sddConfig.getSourceNameString();
|
|
1599 |
String sns = cdmState.getConfig().getSourceNameString();
|
|
1610 | 1600 |
File f = new File(sns); |
1611 | 1601 |
File parent = f.getParentFile(); |
1612 | 1602 |
String fi = parent.toString() + File.separator + href; |
... | ... | |
1660 | 1650 |
} catch (Exception e) { |
1661 | 1651 |
//FIXME |
1662 | 1652 |
logger.warn("Could not attach MediaObject " + j + "(SDD: " + id + ") to several objects."); |
1663 |
success = false;
|
|
1653 |
cdmState.setUnsuccessfull();
|
|
1664 | 1654 |
} |
1665 | 1655 |
|
1666 | 1656 |
if ((++j % modCount) == 0){ logger.info("MediaObjects handled: " + j); |
... | ... | |
1672 | 1662 |
|
1673 | 1663 |
// imports the <DescriptiveConcepts> block ; DescriptiveConcepts are used as nodes in CharacterTrees and Characters as leaves |
1674 | 1664 |
// but since Modifiers can be linked to DescriptiveConcepts they are stored as features with a particular Marker |
1675 |
protected void importDescriptiveConcepts(Element elDataset, Namespace sddNamespace, SDDImportConfigurator sddConfig){
|
|
1665 |
protected void importDescriptiveConcepts(Element elDataset, Namespace sddNamespace, SDDImportState cdmState){
|
|
1676 | 1666 |
/* <DescriptiveConcepts> |
1677 | 1667 |
<DescriptiveConcept id="dc0"> |
1678 | 1668 |
<Representation> |
... | ... | |
1704 | 1694 |
if (!id.equals("")) { |
1705 | 1695 |
// <Representation> |
1706 | 1696 |
// <Label>Body</Label> |
1707 |
importRepresentation(elDescriptiveConcept, sddNamespace, feature, id, sddConfig);
|
|
1697 |
importRepresentation(elDescriptiveConcept, sddNamespace, feature, id, cdmState);
|
|
1708 | 1698 |
features.put(id, feature); |
1709 | 1699 |
getTermService().save(feature);//XIM |
1710 | 1700 |
descriptiveConcepts.add(feature); |
... | ... | |
1716 | 1706 |
for (Element elModifier : listModifiers) { |
1717 | 1707 |
Modifier modif = Modifier.NewInstance(); |
1718 | 1708 |
String idmod = elModifier.getAttributeValue("id"); |
1719 |
importRepresentation(elModifier, sddNamespace, modif, idmod, sddConfig);
|
|
1709 |
importRepresentation(elModifier, sddNamespace, modif, idmod, cdmState);
|
|
1720 | 1710 |
termVocabularyState.addTerm(modif); |
1721 | 1711 |
//termVocabularyStates.add(termVocabularyState); |
1722 | 1712 |
getVocabularyService().save(termVocabularyState);//XIM |
... | ... | |
1737 | 1727 |
} |
1738 | 1728 |
|
1739 | 1729 |
// imports the <CharacterTrees> block |
1740 |
protected void importCharacterTrees(Element elDataset, Namespace sddNamespace, SDDImportConfigurator sddConfig, boolean success){
|
|
1730 |
protected void importCharacterTrees(Element elDataset, Namespace sddNamespace, SDDImportState cdmState){
|
|
1741 | 1731 |
// <CharacterTrees> |
1742 | 1732 |
logger.info("start CharacterTrees ..."); |
1743 | 1733 |
Element elCharacterTrees = elDataset.getChild("CharacterTrees",sddNamespace); |
... | ... | |
1752 | 1742 |
//Element elDesignedFor = elCharacterTree.getChild("DesignedFor",sddNamespace);//TODO ? |
1753 | 1743 |
|
1754 | 1744 |
FeatureTree featureTree = FeatureTree.NewInstance(); |
1755 |
importRepresentation(elCharacterTree, sddNamespace, featureTree, "", sddConfig);
|
|
1745 |
importRepresentation(elCharacterTree, sddNamespace, featureTree, "", cdmState);
|
|
1756 | 1746 |
FeatureNode root = featureTree.getRoot(); |
1757 | 1747 |
List<Element> listeOfNodes = elCharacterTree.getChildren("Nodes", sddNamespace); |
1758 | 1748 |
|
... | ... | |
1771 | 1761 |
|
1772 | 1762 |
catch (Exception e) { |
1773 | 1763 |
logger.warn("Import of Character tree " + j + " failed."); |
1774 |
success = false;
|
|
1764 |
cdmState.setUnsuccessfull();
|
|
1775 | 1765 |
} |
1776 | 1766 |
if ((++j % modCount) == 0){ logger.info("CharacterTrees handled: " + j);} |
1777 | 1767 |
|
... | ... | |
1880 | 1870 |
} |
1881 | 1871 |
|
1882 | 1872 |
// imports the <TaxonHierarchies> block |
1883 |
protected void importTaxonHierarchies(Element elDataset, Namespace sddNamespace, SDDImportConfigurator sddConfig, boolean success){
|
|
1873 |
protected void importTaxonHierarchies(Element elDataset, Namespace sddNamespace, SDDImportState cdmState){
|
|
1884 | 1874 |
|
1885 | 1875 |
logger.info("start TaxonHierarchies ..."); |
1886 | 1876 |
Element elTaxonHierarchies = elDataset.getChild("TaxonHierarchies",sddNamespace); |
... | ... | |
1893 | 1883 |
Element elRepresentation = elTaxonHierarchy.getChild("Representation",sddNamespace); |
1894 | 1884 |
String label = (String)ImportHelper.getXmlInputValue(elRepresentation,"Label",sddNamespace); |
1895 | 1885 |
Classification classification = Classification.NewInstance(label); |
1896 |
importRepresentation(elTaxonHierarchy, sddNamespace, classification, "", sddConfig);
|
|
1886 |
importRepresentation(elTaxonHierarchy, sddNamespace, classification, "", cdmState);
|
|
1897 | 1887 |
|
1898 | 1888 |
Set<TaxonNode> root = classification.getChildNodes(); |
1899 | 1889 |
Element elNodes = elTaxonHierarchy.getChild("Nodes", sddNamespace); // There can be only one <Nodes> block for TaxonHierarchies |
... | ... | |
1929 | 1919 |
catch (Exception e) { |
1930 | 1920 |
//FIXME |
1931 | 1921 |
logger.warn("Import of Taxon Hierarchy " + j + " failed."); |
1932 |
success = false;
|
|
1922 |
cdmState.setUnsuccessfull();
|
|
1933 | 1923 |
} |
1934 | 1924 |
|
1935 | 1925 |
if ((++j % modCount) == 0){ logger.info("TaxonHierarchies handled: " + j);} |
... | ... | |
1941 | 1931 |
|
1942 | 1932 |
|
1943 | 1933 |
// imports the <GeographicAreas> block |
1944 |
protected void importGeographicAreas(Element elDataset, Namespace sddNamespace, SDDImportConfigurator sddConfig) {
|
|
1934 |
protected void importGeographicAreas(Element elDataset, Namespace sddNamespace, SDDImportState cdmState) {
|
|
1945 | 1935 |
Element elGeographicAreas = elDataset.getChild("GeographicAreas",sddNamespace); |
1946 | 1936 |
if (elGeographicAreas != null) { |
1947 | 1937 |
List<Element> listGeographicAreas = elGeographicAreas.getChildren("GeographicArea", sddNamespace); |
... | ... | |
1951 | 1941 |
|
1952 | 1942 |
String id = elGeographicArea.getAttributeValue("id"); |
1953 | 1943 |
NamedArea na = new NamedArea(); |
1954 |
importRepresentation(elGeographicArea, sddNamespace, na, id, sddConfig);
|
|
1944 |
importRepresentation(elGeographicArea, sddNamespace, na, id, cdmState);
|
|
1955 | 1945 |
namedAreas.put(id,na); |
1956 | 1946 |
} |
1957 | 1947 |
if ((++j % modCount) == 0){ logger.info("GeographicAreas handled: " + j);} |
Also available in: Unified diff
last updates for Taxon Excel Import and moving all success variables to state