Project

General

Profile

Revision 64a50c81

ID64a50c812b5e3ba9f52b8ae14627b5697a95cc51
Parent 4e56a70e
Child 9e5c772a, af6418df

Added by Andreas Müller over 7 years ago

fix reset bug in flora imports

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/ImportStateBase.java
22 22
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
23 23
import eu.etaxonomy.cdm.model.common.AnnotationType;
24 24
import eu.etaxonomy.cdm.model.common.CdmBase;
25
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
25 26
import eu.etaxonomy.cdm.model.common.ExtensionType;
26 27
import eu.etaxonomy.cdm.model.common.Language;
27 28
import eu.etaxonomy.cdm.model.common.MarkerType;
......
105 106
//			}
106 107
			setTransformer(newTransformer);
107 108
		}
109
		
108 110
	}
109 111
	
112
	
113
	
114
	/**
115
	 * Resets (empties) all maps which map a uuid to a {@link DefinedTermBase term}.
116
	 * This is usually needed when a a new transaction is opened and user defined terms are reused.
117
	 */
118
	public void resetUuidTermMaps(){
119
		extensionTypeMap = new HashMap<UUID, ExtensionType>();
120
		markerTypeMap = new HashMap<UUID, MarkerType>();
121
		annotationTypeMap = new HashMap<UUID, AnnotationType>();
122
		
123
		namedAreaMap = new HashMap<UUID, NamedArea>();
124
		namedAreaLevelMap = new HashMap<UUID, NamedAreaLevel>();
125
		featureMap = new HashMap<UUID, Feature>();
126
		stateTermMap = new HashMap<UUID, State>();
127
		measurementUnitMap = new HashMap<UUID, MeasurementUnit>();
128
		statisticalMeasureMap = new HashMap<UUID, StatisticalMeasure>();
129
		modifierMap = new HashMap<UUID, Modifier>();
130
		
131
		presenceTermMap = new HashMap<UUID, PresenceTerm>();;
132
		languageMap = new HashMap<UUID, Language>();
133
		taxonRelationshipTypeMap = new HashMap<UUID, TaxonRelationshipType>();
134
		
135
		referenceSystemMap = new HashMap<UUID, ReferenceSystem>();
136
		rankMap = new HashMap<UUID, Rank>();
137
	}
138
	
139
	
110 140
	//different type of stores that are used by the known imports
111 141
	protected Map<String, MapWrapper<? extends CdmBase>> stores = new HashMap<String, MapWrapper<? extends CdmBase>>();
112 142
	
......
169 199
	}
170 200

  
171 201
	
172
	
173
	
174 202
	/**
175 203
	 * Adds a classification uuid to the classification uuid map,
176 204
	 * which maps a key for the classification to its UUID in the CDM
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/XmlImportState.java
17 17
/**
18 18
 * @author a.mueller
19 19
 * @created 11.05.2009
20
 * @version 1.0
21 20
 */
22 21
public class XmlImportState<CONFIG extends XmlImportConfiguratorBase, IO extends XmlImportBase> extends ImportStateBase<CONFIG, IO> {
23 22
	@SuppressWarnings("unused")
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupDocumentImport.java
76 76
	public void doInvoke(MarkupImportState state) { 
77 77
		fireProgressEvent("Start import markup document", "Before start of document");
78 78
		
79
		Queue<CdmBase> outputStream = new LinkedList<CdmBase>();
80

  
81 79
		TransactionStatus tx = startTransaction();
82 80
		// FIXME reset state
83 81
		doAllTheOldOtherStuff(state);
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupImportBase.java
245 245
	}
246 246
	
247 247

  
248

  
249 248
	//TODO move to service layer for all IdentifiableEntities	
250 249
	protected void save(CdmBase cdmBase, MarkupImportState state) {
251 250
		if (state.isCheck()){
......
269 268
			docImport.getOccurrenceService().saveOrUpdate((SpecimenOrObservationBase<?>)cdmBase);
270 269
		}else if (cdmBase.isInstanceOf(DescriptionElementBase.class)){
271 270
			docImport.getDescriptionService().saveDescriptionElement((DescriptionElementBase)cdmBase);
271
		}else if (cdmBase.isInstanceOf(Reference.class)){
272
			docImport.getReferenceService().saveOrUpdate((Reference<?>)cdmBase);
272 273
		}else{
273 274
			String message = "Unknown cdmBase type to save: " + cdmBase.getClass();
274 275
			fireWarningEvent(message, "Unknown location", 8);
......
954 955
		return StringUtils.isBlank(str);
955 956
	}
956 957

  
957
	public TaxonDescription getTaxonDescription(Taxon taxon, Reference<?> ref, boolean isImageGallery, boolean createNewIfNotExists) {
958
	protected TaxonDescription getTaxonDescription(Taxon taxon, Reference<?> ref, boolean isImageGallery, boolean createNewIfNotExists) {
958 959
		return docImport.getTaxonDescription(taxon, isImageGallery, createNewIfNotExists);	
959 960
	}	
960 961
	
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupImportConfigurator.java
107 107
		if (this.isReuseExistingState() == true){
108 108
			if (this.state == null){
109 109
				this.state = new MarkupImportState(this);
110
			}else{
111
				state.reset();
110 112
			}
111 113
			return this.state;
112 114
		}else{
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupImportState.java
108 108
		footnoteRefRegister = new HashMap<String, Set<AnnotatableEntity>>();
109 109
		figureRefRegister = new HashMap<String, Set<AnnotatableEntity>>();
110 110
		currentAreas = new HashSet<NamedArea>();
111
		
112
		this.resetUuidTermMaps();
111 113
	}
112 114
	
113 115
		

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)