Project

General

Profile

« Previous | Next » 

Revision 37bb08e2

Added by Andreas Müller over 5 years ago

cleanup

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelFactsImport.java
110 110
	    getVocabularyService().save(newVoc);
111 111

  
112 112
	    return newVoc;
113

  
114
//	    try {
115
//			//TODO work around until service method works
116
//			TermVocabulary<Feature> featureVocabulary =  BerlinModelTransformer.factCategory2Feature(1).getVocabulary();
117
//			//TermVocabulary<Feature> vocabulary = getTermService().getVocabulary(vocabularyUuid);
118
//			return featureVocabulary;
119
//		} catch (UnknownCdmTypeException e) {
120
//			logger.error("Feature vocabulary not available. New vocabulary created");
121
//			return TermVocabulary.NewInstance(TermType.Feature, "User Defined Feature Vocabulary", "User Defined Feature Vocabulary", null, null);
122
//		}
123 113
	}
124 114

  
125 115
	private Map<Integer, Feature>  invokeFactCategories(BerlinModelImportState state){
......
320 310
	}
321 311

  
322 312
	@Override
323
	public boolean doPartition(ResultSetPartitioner partitioner, BerlinModelImportState state) {
313
	public boolean doPartition(@SuppressWarnings("rawtypes") ResultSetPartitioner partitioner, BerlinModelImportState state) {
324 314
		boolean success = true ;
325
		BerlinModelImportConfigurator config = state.getConfig();
326
		Set<TaxonBase> taxaToSave = new HashSet<TaxonBase>();
315
		Set<TaxonBase> taxaToSave = new HashSet<>();
327 316
		Map<String, TaxonBase> taxonMap = partitioner.getObjectMap(BerlinModelTaxonImport.NAMESPACE);
328 317
		Map<String, Reference> refMap = partitioner.getObjectMap(BerlinModelReferenceImport.REFERENCE_NAMESPACE);
329 318

  
......
392 381
						}
393 382
						if(newTextData == true)	{
394 383
							textData = TextData.NewInstance();
384
						}else if (textData == null){
385
						    throw new RuntimeException("Textdata must not be null");  //does not happen, only to avoid potential NPE warnings
395 386
						}
396 387

  
397 388

  
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelOccurrenceImport.java
60 60
    private static final Logger logger = Logger.getLogger(BerlinModelOccurrenceImport.class);
61 61

  
62 62
	public static final String NAMESPACE = "Occurrence";
63
	private static final String EM_AREA_NAMESPACE = "emArea";
64 63

  
65 64
	private static int modCount = 5000;
66 65
	private static final String pluralString = "occurrences";
......
81 80

  
82 81
	@Override
83 82
	protected String getRecordQuery(BerlinModelImportConfigurator config) {
84
			String emCode = config.isIncludesAreaEmCode()? ", emArea.EMCode" : "";
83
			String emCode = config.isIncludesAreaEmCode()? ", ar.EMCode" : "";
85 84
			String strQuery =   //DISTINCT because otherwise emOccurrenceSource creates multiple records for a single distribution
86
            " SELECT DISTINCT PTaxon.RIdentifier AS taxonId, emOccurrence.OccurrenceId, emOccurrence.Native, emOccurrence.Introduced, " +
87
            		" emOccurrence.Cultivated, emOccurrence.Notes occNotes, " +
88
            		" emOccurSumCat.emOccurSumCatId, emOccurSumCat.Short, emOccurSumCat.Description, " +
89
                	" emOccurSumCat.OutputCode, emArea.AreaId, emArea.TDWGCode " + emCode +
90
                " FROM emOccurrence INNER JOIN " +
91
                	" emArea ON emOccurrence.AreaFk = emArea.AreaId INNER JOIN " +
92
                	" PTaxon ON emOccurrence.PTNameFk = PTaxon.PTNameFk AND emOccurrence.PTRefFk = PTaxon.PTRefFk LEFT OUTER JOIN " +
93
                	" emOccurSumCat ON emOccurrence.SummaryStatus = emOccurSumCat.emOccurSumCatId LEFT OUTER JOIN " +
94
                	" emOccurrenceSource ON emOccurrence.OccurrenceId = emOccurrenceSource.OccurrenceFk " +
95
            " WHERE (emOccurrence.OccurrenceId IN (" + ID_LIST_TOKEN + ")  )" +
85
                " SELECT DISTINCT pt.RIdentifier AS taxonId, occ.OccurrenceId, occ.Native, occ.Introduced, " +
86
            		" occ.Cultivated, occ.Notes occNotes, " +
87
            		" sumcat.emOccurSumCatId, sumcat.Short, sumcat.Description, " +
88
                	" sumcat.OutputCode, ar.AreaId, ar.TDWGCode " + emCode +
89
                " FROM emOccurrence occ " +
90
                	" INNER JOIN emArea ar ON occ.AreaFk = ar.AreaId " +
91
                	" INNER JOIN PTaxon pt ON occ.PTNameFk = pt.PTNameFk AND occ.PTRefFk = pt.PTRefFk " +
92
                	" LEFT OUTER JOIN emOccurSumCat sumcat ON occ.SummaryStatus = sumcat.emOccurSumCatId " +
93
                	" LEFT OUTER JOIN emOccurrenceSource ocs ON occ.OccurrenceId = ocs.OccurrenceFk " +
94
                " WHERE (occ.OccurrenceId IN (" + ID_LIST_TOKEN + ")  )" +
96 95
                " ORDER BY PTaxon.RIdentifier";
97 96
		return strQuery;
98 97
	}
99 98

  
100
//	private Map<Integer, NamedArea> euroMedAreas = new HashMap<>();
101

  
102 99

  
103 100
	@Override
104 101
	public void doInvoke(BerlinModelImportState state) {
105
//		if (state.getConfig().isUseEmAreaVocabulary()){
106
//			try {
107
//				createEuroMedAreas(state);
108
//			} catch (Exception e) {
109
//				logger.error("Exception occurred when trying to create euroMed Areas");
110
//				e.printStackTrace();
111
//				state.setSuccess(false);
112
//			}
113
//		}
114 102
		super.doInvoke(state);
115
		//reset
116
//		euroMedAreas = new HashMap<>();
117 103
	}
118 104

  
119
    /**
120
     * @param emCode
121
     * @return
122
     */
123 105
    private NamedArea getAreaByAreaId(int areaId) {
124 106
        NamedArea result = null;
125 107
        String areaIdStr = String.valueOf(areaId);
......
156 138
	}
157 139

  
158 140
	@Override
159
	public boolean doPartition(ResultSetPartitioner partitioner, BerlinModelImportState state) {
141
	public boolean doPartition(@SuppressWarnings("rawtypes") ResultSetPartitioner partitioner, BerlinModelImportState state) {
160 142
		boolean success = true;
161
		Set<TaxonBase> taxaToSave = new HashSet<>();
143
		@SuppressWarnings("rawtypes")
144
        Set<TaxonBase> taxaToSave = new HashSet<>();
162 145

  
163
		Map<String, TaxonBase<?>> taxonMap = partitioner.getObjectMap(BerlinModelTaxonImport.NAMESPACE);
146
		@SuppressWarnings("unchecked")
147
        Map<String, TaxonBase<?>> taxonMap = partitioner.getObjectMap(BerlinModelTaxonImport.NAMESPACE);
164 148

  
165 149
		ResultSet rs = partitioner.getResultSet();
166 150

  
......
267 251
	 * @throws SQLException
268 252
	 */
269 253
	//Create area list
270
	private List<NamedArea> makeAreaList(BerlinModelImportState state, ResultSetPartitioner partitioner, ResultSet rs, int occurrenceId) throws SQLException {
254
	private List<NamedArea> makeAreaList(BerlinModelImportState state,
255
	        @SuppressWarnings("rawtypes") ResultSetPartitioner partitioner,
256
	        ResultSet rs, int occurrenceId) throws SQLException {
271 257

  
272 258
	    List<NamedArea> areas = new ArrayList<>();
273 259

  
......
329 315
			String nameSpace = BerlinModelTaxonImport.NAMESPACE;
330 316
			Class<?> cdmClass = TaxonBase.class;
331 317
			Set<String> idSet = taxonIdSet;
332
			Map<String, ? extends CdmBase> objectMap = (Map<String, TaxonBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
318
			@SuppressWarnings("unchecked")
319
            Map<String, ? extends CdmBase> objectMap = (Map<String, TaxonBase<?>>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
333 320
			result.put(nameSpace, objectMap);
334 321

  
335 322
			return result;

Also available in: Unified diff