Project

General

Profile

« Previous | Next » 

Revision b4b7ae12

Added by Patrick Plitzner about 8 years ago

Import ex authors

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportAuthor.java
85 85
                String authorName = rs.getString(columnName);
86 86
                TeamOrPersonBase teamOrPerson = null;
87 87
                if(!CdmUtils.isBlank(authorName)){
88
                    //check if it is a team
89
                    if(authorName.contains("&")){
90
                        teamOrPerson = Team.NewInstance();
91
                        String[] split = authorName.split("&");
92
                        for (int i = 0; i < split.length; i++) {
93
                            ((Team) teamOrPerson).addTeamMember(Person.NewTitledInstance(split[i].trim()));
94
                        }
95
                    }
96
                    else{
97
                        teamOrPerson = Person.NewTitledInstance(authorName);
98
                    }
99
                    getAgentService().saveOrUpdate(teamOrPerson);
100
                    state.getAuthorMap().put(authorName, teamOrPerson.getUuid());
88
                    makePerson(state, authorName);
101 89
                }
102 90
            }
103 91
        } catch (SQLException e) {
......
105 93
        }
106 94
    }
107 95

  
96
    private void makePerson(RedListGefaesspflanzenImportState state, String authorName) {
97
        TeamOrPersonBase teamOrPerson;
98
        //check if there are ex authors
99
        if(authorName.contains(" ex ")){
100
            String[] split = authorName.split(" ex ");
101
            for (int i = 0; i < split.length; i++) {
102
                makePerson(state, split[i].trim());
103
            }
104
        }
105
        //check if it is a team
106
        if(authorName.contains("&")){
107
            teamOrPerson = Team.NewInstance();
108
            String[] split = authorName.split("&");
109
            for (int i = 0; i < split.length; i++) {
110
                ((Team) teamOrPerson).addTeamMember(Person.NewTitledInstance(split[i].trim()));
111
            }
112
        }
113
        else{
114
            teamOrPerson = Person.NewTitledInstance(authorName);
115
        }
116
        getAgentService().saveOrUpdate(teamOrPerson);
117
        state.getAuthorMap().put(authorName, teamOrPerson.getUuid());
118
    }
119

  
120

  
108 121
    @Override
109 122
    public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs,
110 123
            RedListGefaesspflanzenImportState state) {
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportNames.java
42 42
@Component
43 43
@SuppressWarnings("serial")
44 44
public class RedListGefaesspflanzenImportNames extends DbImportBase<RedListGefaesspflanzenImportState, RedListGefaesspflanzenImportConfigurator> {
45
    /**
46
     *
47
     */
48
    private static final String EX = " ex ";
49

  
45 50
    private static final Logger logger = Logger.getLogger(RedListGefaesspflanzenImportNames.class);
46 51

  
47 52
    private static final String tableName = "Rote Liste Gefäßpflanzen";
......
120 125
            name.setGenusOrUninomial(ep1String);
121 126
        }
122 127

  
123
        //add author
124
        TeamOrPersonBase authorKomb = HibernateProxyHelper.deproxy(getAgentService().load(state.getAuthorMap().get(authorKombString)), TeamOrPersonBase.class);
125
        name.setCombinationAuthorship(authorKomb);
126
        TeamOrPersonBase authorBasi = HibernateProxyHelper.deproxy(getAgentService().load(state.getAuthorMap().get(authorBasiString)), TeamOrPersonBase.class);
127
        name.setBasionymAuthorship(authorBasi);
128
        //--- AUTHORS ---
129
        //combination author
130
        if(authorKombString.contains(EX)){
131
            //TODO: what happens with multiple ex authors??
132
            String[] kombSplit = authorKombString.split(EX);
133
            for (int i = 0; i < kombSplit.length; i++) {
134
                if(i==0){
135
                    //first author is ex author
136
                    TeamOrPersonBase authorKomb = HibernateProxyHelper.deproxy(getAgentService().load(state.getAuthorMap().get(kombSplit[i])), TeamOrPersonBase.class);
137
                    name.setExCombinationAuthorship(authorKomb);
138
                }
139
                else{
140
                    TeamOrPersonBase authorKomb = HibernateProxyHelper.deproxy(getAgentService().load(state.getAuthorMap().get(kombSplit[i])), TeamOrPersonBase.class);
141
                    name.setCombinationAuthorship(authorKomb);
142
                }
143
            }
144
        }
145
        else if(!CdmUtils.isBlank(authorKombString)){
146
            TeamOrPersonBase authorKomb = HibernateProxyHelper.deproxy(getAgentService().load(state.getAuthorMap().get(authorKombString)), TeamOrPersonBase.class);
147
            name.setCombinationAuthorship(authorKomb);
148
        }
149
        //basionym author
150
        if(authorBasiString.contains(EX)){
151
            String[] basiSplit = authorBasiString.split(EX);
152
            for (int i = 0; i < basiSplit.length; i++) {
153
                if(i==0){
154
                    TeamOrPersonBase authorBasi = HibernateProxyHelper.deproxy(getAgentService().load(state.getAuthorMap().get(basiSplit[i])), TeamOrPersonBase.class);
155
                    name.setExBasionymAuthorship(authorBasi);
156
                }
157
                else{
158
                    TeamOrPersonBase authorBasi = HibernateProxyHelper.deproxy(getAgentService().load(state.getAuthorMap().get(basiSplit[i])), TeamOrPersonBase.class);
159
                    name.setBasionymAuthorship(authorBasi);
160
                }
161
            }
162
        }
163
        else if(!CdmUtils.isBlank(authorBasiString)){
164
            TeamOrPersonBase authorBasi = HibernateProxyHelper.deproxy(getAgentService().load(state.getAuthorMap().get(authorBasiString)), TeamOrPersonBase.class);
165
            name.setBasionymAuthorship(authorBasi);
166
        }
128 167

  
129 168
        //check authorship consistency
130 169
        String authorString = rs.getString("AUTOR");
131
        if(!authorString.equals(name.getAuthorshipCache())){
132
            logger.warn("Authorship inconsisten! Name-AuthorhshipCache: +"+name.getAuthorshipCache()+" Column AUTOR: "+authorString);
170
        String authorshipCache = name.getAuthorshipCache();
171

  
172
        if(!CdmUtils.isBlank(zusatzString)){
173
            authorString = authorString.replace(", "+zusatzString, "");
174
        }
175
        if(CdmUtils.isBlank(authorKombString) && !CdmUtils.isBlank(authorBasiString)){
176
            authorString = "("+authorString+")";
177
        }
178
        if(!authorString.equals(authorshipCache)){
179
            logger.warn("NAMNR: "+id+" Authorship inconsistent! name.authorhshipCache <-> Column AUTOR: "+authorshipCache+" <-> "+authorString);
133 180
        }
134 181

  
135 182
        //id

Also available in: Unified diff