Project

General

Profile

Revision 2fa45f7e

ID2fa45f7efd931caff73f34caa04201fbab2fd2e0
Parent 86244fd8
Child 19d67961

Added by Katja Luther about 3 years ago

fix gatheringAgent import in ABCD Import

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206DataHolder.java
30 30

  
31 31
    protected List<String> knownABCDelements = new ArrayList<String>();
32 32
    protected HashMap<String,String> allABCDelements = new HashMap<String,String>();
33
    public String gatheringAgents ="";
34

  
33
    public String gatheringAgentsText ="";
34
    public List<String> gatheringAgentsList=new ArrayList<String>();
35 35

  
36 36
    //per unit
37 37

  
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206Import.java
434 434

  
435 435
                unitsGatheringEvent.setGatheringDepth(state.getDataHolder().getGatheringDepthText(),state.getDataHolder().getGatheringDepthMin(), state.getDataHolder().getGatheringDepthMax(), state.getDataHolder().getGatheringDepthUnit());
436 436
                //unitsGatheringEvent.setHeight(heightText, heightMin, heightMax, heightUnit);
437
                unitsGatheringEvent.setCollector(state.getPersonStore().get(state.getDataHolder().gatheringAgents), config);
437
                if(state.getDataHolder().gatheringAgentsList.isEmpty()) {
438
                    unitsGatheringEvent.setCollector(state.getPersonStore().get(state.getDataHolder().gatheringAgentsText), config);
439
                }else{
440
                    unitsGatheringEvent.setCollector(state.getPersonStore().get(state.getDataHolder().gatheringAgentsList.toString()), config);
441
                }
438 442
                // count
439 443
                UnitsGatheringArea unitsGatheringArea = new UnitsGatheringArea();
440 444
                //  unitsGatheringArea.setConfig(state.getConfig(),getOccurrenceService(), getTermService());
......
1076 1080
    private void prepareCollectors(Abcd206ImportState state, NodeList unitsList, Abcd206XMLFieldGetter abcdFieldGetter) {
1077 1081

  
1078 1082
        TeamOrPersonBase<?> teamOrPerson = null;
1079

  
1083
        Team team = null;
1080 1084
        //ImportHelper.setOriginalSource(teamOrPerson, state.getConfig().getSourceReference(), collector, "Collector");
1081 1085
        for (int i = 0; i < unitsList.getLength(); i++) {
1082 1086
            this.getCollectorsFromXML((Element) unitsList.item(i), abcdFieldGetter, state);
1083
            if (!StringUtils.isBlank(state.getDataHolder().gatheringAgents)){
1084
                teamOrPerson = parseAuthorString(state.getDataHolder().gatheringAgents);
1085
                if (!state.getPersonStore().containsId(state.getDataHolder().gatheringAgents)) {
1086
                    state.getPersonStore().put(state.getDataHolder().gatheringAgents, teamOrPerson);
1087
                    if (logger.isDebugEnabled()) { logger.debug("Stored author " + state.getDataHolder().gatheringAgents  ); }
1088
                } else {
1089
                    logger.warn("Not imported author with duplicated aut_id " + state.getDataHolder().gatheringAgents  );
1087
            if (!(state.getDataHolder().gatheringAgentsList.isEmpty())){
1088
                if (state.getDataHolder().gatheringAgentsList.size() == 1){
1089
                    teamOrPerson = parseAuthorString(state.getDataHolder().gatheringAgentsList.get(0));
1090
                }else{
1091
                    team = new Team();
1092
                    for(String collector: state.getDataHolder().gatheringAgentsList){
1093
                        teamOrPerson = parseAuthorString(collector);
1094
                        if (teamOrPerson instanceof Person){
1095
                            team.addTeamMember((Person)teamOrPerson);
1096
                        }else{
1097
                            for (Person person: ((Team)teamOrPerson).getTeamMembers()){
1098
                                team.addTeamMember(person);
1099
                            }
1100
                        }
1101
                    }
1090 1102
                }
1103
                if (!state.getPersonStore().containsId(state.getDataHolder().gatheringAgentsList.toString())) {
1104
                    state.getPersonStore().put(state.getDataHolder().gatheringAgentsList.toString(), teamOrPerson);
1105
                    if (logger.isDebugEnabled()) { logger.debug("Stored author " + state.getDataHolder().gatheringAgentsList.toString());}
1106
                    logger.warn("Not imported author with duplicated aut_id " + state.getDataHolder().gatheringAgentsList.toString() );
1107
                }
1108
            }
1109
            if (!StringUtils.isBlank(state.getDataHolder().gatheringAgentsText) && state.getDataHolder().gatheringAgentsList.isEmpty()){
1110
                teamOrPerson = parseAuthorString(state.getDataHolder().gatheringAgentsText);
1091 1111
            }
1092 1112

  
1093 1113
        }
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206XMLFieldGetter.java
1066 1066
     */
1067 1067
    protected void getGatheringPeople(Element root) {
1068 1068
        try {
1069
            dataHolder.gatheringAgents = "";
1069
            dataHolder.gatheringAgentsText = "";
1070
            dataHolder.gatheringAgentsList = new ArrayList<String>();
1070 1071

  
1071 1072
            NodeList group = root.getElementsByTagName(prefix + "GatheringAgent");
1072 1073
            for (int i = 0; i < group.getLength(); i++) {
......
1082 1083
                                path = "";
1083 1084
                                if (!persons.item(k).getTextContent().trim().equalsIgnoreCase("none")) {
1084 1085

  
1085
                                    dataHolder.gatheringAgents += persons.item(k).getTextContent();
1086
                                    dataHolder.gatheringAgentsList.add(persons.item(k).getTextContent());
1086 1087
                                }
1087 1088
                            }
1088 1089
                        }
......
1104 1105
                                dataHolder.knownABCDelements.add(path);
1105 1106
                                path = "";
1106 1107
                                if (!persons.item(k).getTextContent().trim().equalsIgnoreCase("none")) {
1107
                                    dataHolder.gatheringAgents+=persons.item(k).getTextContent();
1108
                                    dataHolder.gatheringAgentsText=persons.item(k).getTextContent();
1108 1109
                                }
1109 1110
                            }
1110 1111
                        }
......
1114 1115
            }
1115 1116

  
1116 1117
        } catch (NullPointerException e) {
1117
            dataHolder.gatheringAgents = "";
1118
            dataHolder.gatheringAgentsText = "";
1119
            dataHolder.gatheringAgentsList = new ArrayList<String>();
1118 1120
        }
1119 1121

  
1120 1122
    }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)