Project

General

Profile

« Previous | Next » 

Revision 7c429b09

Added by Andreas Müller almost 7 years ago

ref #6541 adapt pesi to ImportResult

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiFinalUpdateExport.java
1 1
/**
2 2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
28 28
 */
29 29
@Component
30 30
public class PesiFinalUpdateExport extends PesiExportBase {
31
	private static final Logger logger = Logger.getLogger(PesiFinalUpdateExport.class);
32
	private static final Class<? extends CdmBase> standardMethodParameter = TaxonBase.class;
31

  
32
    private static final long serialVersionUID = 6190569804410237104L;
33
    private static final Logger logger = Logger.getLogger(PesiFinalUpdateExport.class);
34

  
35
    private static final Class<? extends CdmBase> standardMethodParameter = TaxonBase.class;
33 36

  
34 37
	private static final String pluralString = "taxa";
35 38

  
......
37 40
		super();
38 41
	}
39 42

  
40
	/* (non-Javadoc)
41
	 * @see eu.etaxonomy.cdm.io.common.DbExportBase#getStandardMethodParameter()
42
	 */
43 43
	@Override
44 44
	public Class<? extends CdmBase> getStandardMethodParameter() {
45 45
		return standardMethodParameter;
46 46
	}
47 47

  
48
	/* (non-Javadoc)
49
	 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IoStateBase)
50
	 */
51 48
	@Override
52 49
	protected boolean doCheck(PesiExportState state) {
53 50
		boolean result = true;
54 51
		return result;
55 52
	}
56
	
57
	
58
	/* (non-Javadoc)
59
	 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#doInvoke(eu.etaxonomy.cdm.io.common.IoStateBase)
60
	 */
53

  
54

  
61 55
	@Override
62 56
	protected void doInvoke(PesiExportState state) {
63 57
		try {
......
65 59

  
66 60
			// Stores whether this invoke was successful or not.
67 61
			boolean success = true;
68
	
62

  
69 63
			//updates to TaxonStatus and others
70 64
			success &= doPhaseUpdates(state);
71 65

  
72
			
66

  
73 67
			logger.info("*** Finished Making " + pluralString + " ..." + getSuccessString(success));
74 68

  
75 69
			if (!success){
76
				state.setUnsuccessfull();
70
				state.getResult().addError("An unknown error occurred in PesiFinalUpdateExport.invoke");
77 71
			}
78 72
			return;
79 73
		} catch (Exception e) {
80 74
			e.printStackTrace();
81 75
			logger.error(e.getMessage());
82
			state.setUnsuccessfull();
76
			state.getResult().addException(e, e.getMessage());
83 77
			return;
84 78
		}
85 79
	}
86 80

  
87
	
81

  
88 82
	private boolean doPhaseUpdates(PesiExportState state) {
89
		
90
		
83

  
84

  
91 85
		String oldStatusFilter = " 7 ";  //"= '" + PesiTransformer.T_STATUS_STR_UNACCEPTED + "' ";
92 86
		String emStr = PesiTransformer.SOURCE_STR_EM;
93 87
		String feStr = PesiTransformer.SOURCE_STR_FE;
94 88
		String ifStr = PesiTransformer.SOURCE_STR_IF;
95
		
89

  
96 90
		//NOT ACCEPTED names
97 91
		String updateNotAccepted = " UPDATE Taxon SET TaxonStatusFk = %d, TaxonStatusCache = '%s' " +
98 92
				" WHERE OriginalDB = '%s' AND taxonstatusfk = 1 AND ParentTaxonFk = %s AND RankFk > 180 ";
99 93
		updateNotAccepted = String.format(updateNotAccepted, 8, "NOT ACCEPTED: TAXONOMICALLY VALUELESS LOCAL OR SINGULAR BIOTYPE", emStr, oldStatusFilter);
100 94
		int updated = state.getConfig().getDestination().update(updateNotAccepted);
101
		
95

  
102 96
		//alternative names
103
		String updateAlternativeName = "UPDATE Taxon SET TaxonStatusFk = 1, TaxonStatusCache = 'accepted' " + 
97
		String updateAlternativeName = "UPDATE Taxon SET TaxonStatusFk = 1, TaxonStatusCache = 'accepted' " +
104 98
				" FROM RelTaxon RIGHT OUTER JOIN Taxon ON RelTaxon.TaxonFk1 = Taxon.TaxonId " +
105 99
				" WHERE (RelTaxon.RelTaxonQualifierFk = 17) AND (Taxon.TaxonStatusFk = %s) ";
106 100
		updateAlternativeName = String.format(updateAlternativeName, oldStatusFilter);
107 101
		System.out.println(updateAlternativeName);
108 102
		updated = state.getConfig().getDestination().update(updateAlternativeName);
109
		
110
		String updateSynonyms = " UPDATE Taxon SET TaxonStatusFk = 2, TaxonStatusCache = 'synonym' " + 
111
					" FROM RelTaxon RIGHT OUTER JOIN Taxon ON RelTaxon.TaxonFk1 = Taxon.TaxonId " + 
103

  
104
		String updateSynonyms = " UPDATE Taxon SET TaxonStatusFk = 2, TaxonStatusCache = 'synonym' " +
105
					" FROM RelTaxon RIGHT OUTER JOIN Taxon ON RelTaxon.TaxonFk1 = Taxon.TaxonId " +
112 106
					" WHERE (RelTaxon.RelTaxonQualifierFk in (1, 3)) AND (Taxon.TaxonStatusFk = %s)";
113 107
		updateSynonyms = String.format(updateSynonyms, oldStatusFilter);
114 108
		System.out.println(updateSynonyms);
115 109
		updated = state.getConfig().getDestination().update(updateSynonyms);
116
		
110

  
117 111
		// cache citation  - check if this can't be done in getCacheCitation
118 112
		// cache citation - FE
119 113
//		String updateCacheCitationFE = " UPDATE Taxon " +
......
121 115
//				" WHERE OriginalDb = '%s'";
122 116
//		updateCacheCitationFE = String.format(updateCacheCitationFE, feStr);
123 117
//		updated = state.getConfig().getDestination().update(updateCacheCitationFE);
124
		
118

  
125 119
		// cache citation - EM
126 120
		String updateCacheCitationEM = " UPDATE Taxon " +
127 121
				" SET CacheCitation = SpeciesExpertName + ' ' + WebShowName + '. Accessed through: Euro+Med PlantBase at http://ww2.bgbm.org/euroPlusMed/PTaxonDetail.asp?UUID=' + GUID " +
128 122
				" WHERE OriginalDb = '%s'";
129 123
		updateCacheCitationEM = String.format(updateCacheCitationEM, emStr);
130 124
		updated = state.getConfig().getDestination().update(updateCacheCitationEM);
131
		
125

  
132 126
		// cache citation - IF
133 127
//		String updateCacheCitationIF = " UPDATE Taxon " +
134 128
//				" SET CacheCitation = IsNull(SpeciesExpertName + ' ', '') + WebShowName + '. Accessed through: Index Fungorum at http://www.indexfungorum.org/names/NamesRecord.asp?RecordID=' + cast(TempIF_Id as varchar) " +
135 129
//				" WHERE OriginalDb = '%s'";
136 130
//		updateCacheCitationIF = String.format(updateCacheCitationIF, ifStr);
137 131
//		updated = state.getConfig().getDestination().update(updateCacheCitationIF);
138
		
132

  
139 133
		return true;
140 134
	}
141 135

  
142
	/* (non-Javadoc)
143
	 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IoStateBase)
144
	 */
145 136
	@Override
146 137
	protected boolean isIgnore(PesiExportState state) {
147 138
		return ! state.getConfig().isDoTaxa();

Also available in: Unified diff