Project

General

Profile

Revision 18d660e0

ID18d660e0749416ac1884e497da3537d0a1db2e77
Parent 3dfcbfee
Child 70e986c5

Added by Katja Luther about 3 years ago

fix specimen fact export

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/outputmodel/OutputModelClassificationExport.java
13 13
import java.util.HashSet;
14 14
import java.util.Iterator;
15 15
import java.util.List;
16
import java.util.Map;
16 17
import java.util.Set;
17 18
import java.util.UUID;
18 19

  
......
28 29
import eu.etaxonomy.cdm.model.agent.Person;
29 30
import eu.etaxonomy.cdm.model.agent.Team;
30 31
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
32
import eu.etaxonomy.cdm.model.common.Annotation;
33
import eu.etaxonomy.cdm.model.common.AnnotationType;
31 34
import eu.etaxonomy.cdm.model.common.CdmBase;
32 35
import eu.etaxonomy.cdm.model.common.DefinedTerm;
33 36
import eu.etaxonomy.cdm.model.common.ICdmBase;
......
293 296
        String[] csvLine = new String[table.getSize()];
294 297

  
295 298
        for (DescriptionElementBase element: specimenFacts){
299
            csvLine = new String[table.getSize()];
296 300
            if (element instanceof IndividualsAssociation){
297
                csvLine = new String[table.getSize()];
301

  
298 302
                IndividualsAssociation indAssociation = (IndividualsAssociation)element;
299 303
                csvLine[table.getIndex(OutputModelTable.FACT_ID)] = getId(state, element);
300 304
                handleSource(state, element, table);
......
306 310
                        handleSpecimen(state, derivedUnit);
307 311
                        csvLine[table.getIndex(OutputModelTable.TAXON_FK)] = getId(state, taxon);
308 312
                        csvLine[table.getIndex(OutputModelTable.SPECIMEN_FK)] = getId(state, indAssociation.getAssociatedSpecimenOrObservation());
309
                        state.getProcessor().put(table, indAssociation, csvLine, state);
313

  
310 314
                    }else{
311 315
                        state.getResult().addError("The associated Specimen of taxon " + taxon.getUuid() + " is not an DerivedUnit. Could not be exported.");
312 316
                    }
313 317

  
314 318
                }
319
                csvLine[table.getIndex(OutputModelTable.SPECIMEN_NOTES)] = createAnnotationsString(indAssociation.getAnnotations());
320
                state.getProcessor().put(table, indAssociation, csvLine, state);
321

  
322
            } else if (element instanceof TextData){
323
                TextData textData = HibernateProxyHelper.deproxy(element, TextData.class);
324
                csvLine[table.getIndex(OutputModelTable.FACT_ID)] = getId(state, textData);
325
                handleSource(state, textData, table);
326
                csvLine[table.getIndex(OutputModelTable.SPECIMEN_NOTES)] = createAnnotationsString(textData.getAnnotations());
327

  
328
                csvLine[table.getIndex(OutputModelTable.SPECIMEN_DESCRIPTION)] = createMultilanguageString(textData.getMultilanguageText());
329
                state.getProcessor().put(table, element, csvLine, state);
330
              //  state.getResult().addError("The specimen description for the taxon " + taxon.getUuid() + " is not of type individual association. Could not be exported. UUID of the description element: " + element.getUuid());
331
            }
315 332

  
316
            } else{
317
                state.getResult().addError("The specimen description for the taxon " + taxon.getUuid() + " is not of type individual association. Could not be exported. UUID of the description element: " + element.getUuid());
333

  
334
        }
335
    }
336

  
337
    /**
338
     * @param multilanguageText
339
     * @return
340
     */
341
    private String createMultilanguageString(Map<Language, LanguageString> multilanguageText) {
342
       String text = "";
343
       int index = multilanguageText.size();
344
       for(LanguageString langString: multilanguageText.values()){
345
           text += langString.getText();
346
           if (index > 1){
347
               text += "; ";
348
           }
349
           index --;
350
       }
351

  
352
        return text;
353
    }
354

  
355
    /**
356
     * @param annotations
357
     * @return
358
     */
359
    private String createAnnotationsString(Set<Annotation> annotations) {
360
        StringBuffer strBuff = new StringBuffer();
361
        for (Annotation ann:annotations){
362
            if (ann.getAnnotationType() == null ||!ann.getAnnotationType().equals(AnnotationType.TECHNICAL())){
363
                strBuff.append(ann.getText());
364
                strBuff.append("; ");
318 365
            }
319 366
        }
367
        return strBuff.toString();
320 368
    }
321 369

  
322 370
    /**
......
1078 1126
    private String createShortCitation(Reference reference) {
1079 1127
        TeamOrPersonBase authorship = reference.getAuthorship();
1080 1128
        String shortCitation = "";
1129
        if (authorship == null) {
1130
            return null;
1131
        }
1132
        authorship = HibernateProxyHelper.deproxy(authorship);
1081 1133
        if (authorship instanceof Person){ shortCitation = ((Person)authorship).getLastname();}
1082
        else{
1134
        else if (authorship instanceof Team){
1135

  
1083 1136
            Team authorTeam = HibernateProxyHelper.deproxy(authorship, Team.class);
1084 1137
            int index = 0;
1138

  
1085 1139
            for (Person teamMember : authorTeam.getTeamMembers()){
1086 1140
                index++;
1087 1141
                String concat = concatString(authorTeam, authorTeam.getTeamMembers(), index);
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/outputmodel/OutputModelTable.java
49 49
    protected static final String REFERENCE_ID = "Reference_ID";
50 50
    protected static final String BIBLIO_SHORT_CITATION = "BibliographicShortCitation";
51 51
    protected static final String REF_TITLE = "Title";
52
    protected static final String ABBREV_REF_TITLE = "Abbrev. Title";
52 53
    protected static final String DATE_PUBLISHED = "DatePublished";
53 54
    protected static final String EDITION = "Edition";
54 55
    protected static final String EDITOR= "Editor";
......
178 179
    protected static final String FACT_CATEGORY = "FactCategory";
179 180

  
180 181
    // Specimen Facts
182
    protected static final String SPECIMEN_NOTES = "Specimen Notes";
183
    protected static final String SPECIMEN_DESCRIPTION = "Specimen Description";
184

  
181 185

  
182 186
    //Geographic Area Facts
183 187
    protected static final String AREA_LABEL = "AreaLabel";
......
202 206
    }
203 207

  
204 208
    final static String[] specimenFactsColumns() {
205
        return new String[]{FACT_ID, TAXON_FK, SPECIMEN_FK};
209
        return new String[]{FACT_ID, TAXON_FK, SPECIMEN_FK, SPECIMEN_DESCRIPTION, SPECIMEN_NOTES};
206 210
    }
207 211

  
208 212
    final static String[] commonNameFactsColumns() {
......
251 255
        return new String[]{SYNONYM_ID, TAXON_FK, NAME_FK, SEC_REFERENCE_FK, SEC_REFERENCE};
252 256
    }
253 257
    final static String[] referenceColumns(){
254
        return new String[]{REFERENCE_ID, BIBLIO_SHORT_CITATION, REF_TITLE, DATE_PUBLISHED, EDITION, EDITOR, ISBN,ISSN, ORGANISATION, PAGES, PLACE_PUBLISHED, PUBLISHER,
258
        return new String[]{REFERENCE_ID, BIBLIO_SHORT_CITATION, REF_TITLE,ABBREV_REF_TITLE, DATE_PUBLISHED, EDITION, EDITOR, ISBN,ISSN, ORGANISATION, PAGES, PLACE_PUBLISHED, PUBLISHER,
255 259
                REF_ABSTRACT, SERIES_PART, VOLUME, YEAR, AUTHORSHIP_TITLE, AUTHOR_FK, IN_REFERENCE, INSTITUTION, LSID, SCHOOL, REF_TYPE, URI};
256 260
    }
257 261

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)