Project

General

Profile

« Previous | Next » 

Revision 79de4982

Added by Andreas Müller about 7 years ago

ref #6519 adapt app-import to ExportResult

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/app/dwca/DwcaExportActivator.java
1 1
/**
2 2
* Copyright (C) 2007 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
*/
......
23 23
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
24 24
import eu.etaxonomy.cdm.database.ICdmDataSource;
25 25
import eu.etaxonomy.cdm.io.common.CdmDefaultExport;
26
import eu.etaxonomy.cdm.io.common.ExportResult;
26 27
import eu.etaxonomy.cdm.io.common.IExportConfigurator.CHECK;
27 28
import eu.etaxonomy.cdm.io.dwca.out.DwcaEmlRecord;
28 29
import eu.etaxonomy.cdm.io.dwca.out.DwcaTaxExportConfigurator;
......
49 50
	private static final ICdmDataSource cdmSource = CdmDestinations.cdm_cyprus_production();
50 51

  
51 52
	private IProgressMonitor monitor = DefaultProgressMonitor.NewInstance();
52
	
53

  
53 54
	private static DateTime dateTime = new DateTime();
54 55
	private static String date = dateTime.getYear() + "-" + dateTime.getMonthOfYear() + "-" + dateTime.getDayOfMonth();
55
	
56
	private static final String defaultBibliographicCitation = "ICN (Hand, R., Kilian, N. & Raab-Straube, E. von; general editors) 2009+ (continuously updated): International Cichorieae Network: Cichorieae Portal. Published on the Internet at http://wp6-cichorieae.e-taxonomy.eu/portal/; " + 
56

  
57
	private static final String defaultBibliographicCitation = "ICN (Hand, R., Kilian, N. & Raab-Straube, E. von; general editors) 2009+ (continuously updated): International Cichorieae Network: Cichorieae Portal. Published on the Internet at http://wp6-cichorieae.e-taxonomy.eu/portal/; " +
57 58
		"accessed ["+date+"].";
58 59

  
59 60
	private static final String taxonSourceDefault = "http://wp6-cichorieae.e-taxonomy.eu/portal/?q=cdm_dataportal/taxon/{id}";
60
	
61

  
61 62
	//check - import
62 63
	private static final CHECK check = CHECK.EXPORT_WITHOUT_CHECK;
63 64

  
......
69 70
			UUID.fromString("cbf12c6c-94e6-4724-9c48-0f6f10d83e1c"),   //Editor Brackets
70 71
			UUID.fromString("0508114d-4158-48b5-9100-369fa75120d3")     //inedited
71 72
	});
72
	
73
	
73

  
74

  
74 75
// ****************** ALL *****************************************
75
	
76

  
76 77
//	private boolean doTaxa = true;
77 78
//	private boolean doResourceRelation = true;
78 79
//	private boolean doTypesAndSpecimen = true;
......
85 86
//	private boolean doEml = true;
86 87

  
87 88
// ************************ NONE **************************************** //
88
	
89

  
89 90
	private boolean doTaxa = true;
90 91
	private boolean doResourceRelation = false;
91 92
	private boolean doTypesAndSpecimen = false;
......
96 97
	private boolean doImages = false;
97 98
	private boolean doMetaData = true;
98 99
	private boolean doEml = false;
99
	
100
	public boolean 	doExport(ICdmDataSource source){
100

  
101
	public ExportResult 	doExport(ICdmDataSource source){
101 102
		System.out.println("Start export to DWC-A ("+ fileDestination + ") ...");
102
		
103

  
103 104
//		CdmUpdater su = CdmUpdater.NewInstance();
104 105
//		IProgressMonitor monitor = DefaultProgressMonitor.NewInstance();
105
//		
106
//
106 107
//		try {
107 108
//			su.updateToCurrentVersion(source, monitor);
108 109
//		} catch (Exception e) {
......
111 112
//		if (true){
112 113
//			return true;
113 114
//		}
114
		
115

  
115 116
		//make file destination
116 117
		String destination = fileDestination;
117 118
		DwcaEmlRecord emlRecord = getEmlRecord();
118
		
119

  
119 120
		DwcaTaxExportConfigurator config = DwcaTaxExportConfigurator.NewInstance(source, new File(destination), emlRecord);
120
		
121

  
121 122
		config.setDoTaxa(doTaxa);
122 123
		config.setDoResourceRelation(doResourceRelation);
123 124
		config.setDoTypesAndSpecimen(doTypesAndSpecimen);
......
133 134
		config.setDefaultBibliographicCitation(defaultBibliographicCitation);
134 135
		config.setDefaultTaxonSource(taxonSourceDefault);
135 136
		monitor.beginTask("DwcA-Export", 10);
136
		
137

  
137 138
		config.setFeatureExclusions(featureExclusions);
138 139
		// invoke import
139 140
		CdmDefaultExport<DwcaTaxExportConfigurator> bmExport = new CdmDefaultExport<DwcaTaxExportConfigurator>();
140
		boolean result = bmExport.invoke(config);
141
		
142
		System.out.println("End export to DWC-A ("+ fileDestination + ")..." + (result? "(successful)":"(with errors)"));
141
		ExportResult result = bmExport.invoke(config);
142

  
143
		System.out.println("End export to DWC-A ("+ fileDestination + ")..." + "("+result.getState().toString()+")");
143 144
		return result;
144 145
	}
145 146

  
......
160 161
		emlRecord.setProjectTitle("Projekt tit");
161 162
		emlRecord.setProjectLead("Proj Lead");
162 163
		emlRecord.setProjectDescription("Proj Desc");
163
		
164

  
164 165
		Person person = Person.NewInstance();
165 166
		Institution institution = Institution.NewInstance();
166
		
167

  
167 168
		InstitutionalMembership m = person.addInstitutionalMembership(institution, null, null, null);
168 169
		emlRecord.setResourceCreator(m);
169
		
170

  
170 171
		return emlRecord;
171 172
	}
172 173

  
......
180 181

  
181 182
		ex.doExport(source);
182 183
	}
183
	
184
	
185
	
184

  
185

  
186

  
186 187

  
187 188
}

Also available in: Unified diff