Project

General

Profile

« Previous | Next » 

Revision c03af146

Added by Andreas Müller over 6 years ago

ref #5713 fix #5713 (partly or fully)

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/GbifDistributionCsv2CdmConverter.java
114 114

  
115 115
	private NamedArea getAreaByLocationId(StreamItem item, String locationId) {
116 116
		String namespace = TermUri.DWC_LOCATION_ID.toString();
117
		if (locationId == null){
118
		    return null;
119
		}
117 120
		List<NamedArea> result = state.get(namespace, locationId, NamedArea.class);
118 121
		if (result.isEmpty()){
119 122
			//try to find in cdm
120
			NamedArea newArea = TdwgAreaProvider.getAreaByTdwgAbbreviation(locationId);
123
			NamedArea newArea = getTdwgArea(locationId);
121 124
			if (newArea == null){
122
//				state.getCurrentIO().getTermService().findByAreaCode
125
			    //TODO could be idInVocabulary (with not voc given), abbrevTitle of any representation, ...
126
//				state.getCurrentIO().getTermService().listByCode
123 127
			}
124 128
			if (newArea == null){
125 129
				newArea = NamedArea.NewInstance(locationId, locationId, locationId);
126 130
			}
127 131

  
132
			state.putMapping(namespace, locationId, newArea);
128 133
			return newArea;
129 134
		}
130 135
		if (result.size() > 1){
......
134 139
		return result.iterator().next();
135 140
	}
136 141

  
142
    /**
143
     * @param locationId
144
     * @return
145
     */
146
    protected NamedArea getTdwgArea(String locationId) {
147
        if (locationId == null){
148
            return null;
149
        }else if (locationId.startsWith("TDWG:")){
150
            locationId = locationId.substring("TDWG:".length()); //CoL case
151
        }
152
        return TdwgAreaProvider.getAreaByTdwgAbbreviation(locationId);
153
    }
154

  
137 155
	@Override
138 156
	public String getSourceId(StreamItem item) {
139 157
		String id = item.get(CORE_ID);

Also available in: Unified diff