command.name.INSPECT_ACTIVE_SESSIONS = Inspect Active Session\r
viewCommandMapping.viewerName.CLASSIFICATION_WIZARD = Classification Wizard\r
viewCommandMapping.viewerName.TAXON_NODE_WIZARD = Taxon node Wizard\r
-command.label.CHANGE_PASSWORD = Change password
\ No newline at end of file
+command.label.CHANGE_PASSWORD = Change password\r
+wizard.name.22 = Output Model
\ No newline at end of file
command.name.INSPECT_ACTIVE_SESSIONS = Aktive Session untersuchen
viewCommandMapping.viewerName.CLASSIFICATION_WIZARD = Klassifikations-Wizard
viewCommandMapping.viewerName.TAXON_NODE_WIZARD = Taxonknoten-Wizard
-command.label.CHANGE_PASSWORD = Kennwort ändern
\ No newline at end of file
+command.label.CHANGE_PASSWORD = Kennwort ändern
+wizard.name.22 = Output Model
\ No newline at end of file
id="eu.etaxonomy.taxeditor.io.export.csv_print"
name="%wizard.name.20">
</wizard>
+ <wizard
+ category="eu.etaxonomy.taxeditor.export.category.cdm"
+ class="eu.etaxonomy.taxeditor.io.wizard.OutputModelExportWizard"
+ id="eu.etaxonomy.taxeditor.io.export.output_model"
+ name="%wizard.name.22">
+ </wizard>
</extension>
<extension
point="org.eclipse.ui.newWizards">
import java.io.File;
import java.io.FileOutputStream;
+import java.util.Map;
+import java.util.Set;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.Assert;
import eu.etaxonomy.cdm.io.common.CdmDefaultExport;
import eu.etaxonomy.cdm.io.common.ExportDataWrapper;
import eu.etaxonomy.cdm.io.common.ExportResult;
+import eu.etaxonomy.cdm.io.common.ExportResultType;
import eu.etaxonomy.cdm.io.common.IExportConfigurator;
import eu.etaxonomy.cdm.io.common.IIoConfigurator;
import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator;
+import eu.etaxonomy.cdm.io.outputmodel.OutputModelConfigurator;
import eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator;
import eu.etaxonomy.cdm.io.service.IIOService;
import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter;
ExportResult result = ioService.export(configurator);
ExportDataWrapper data = result.getExportData();
try{
- byte[] exportData = (byte[])data.getExportData();
- if(exportData != null){
- FileOutputStream stream = new FileOutputStream(exportFile);
- stream.write(exportData);
- stream.close();
- }
+ if (result.getExportData().getType().equals(ExportResultType.BYTE_ARRAY)){
+ byte[] exportData = (byte[])data.getExportData();
+ if(exportData != null){
+ FileOutputStream stream = new FileOutputStream(exportFile);
+ stream.write(exportData);
+ stream.close();
+ }
+// } else if (result.getExportData().getType().equals(ExportResultType.MAP_BYTE_ARRAY)){
+// Map<String, byte[]> resultMap = (Map<String, byte[]>)data.getExportData();
+// Set<String> keySet = resultMap.keySet();
+// for (String key: keySet){
+// byte[] fileData = resultMap.get(key);
+// File file = new File(urlString)
+// FileOutputStream stream = new FileOutputStream(key);
+// stream.write(fileData);
+// stream.close();
+// }
+
+ }else{
+ logger.error("This kind of result data is not supported yet." + result.getExportData().getType().toString());
+ }
} catch(Exception e){
logger.error(e.getStackTrace());
}
return (SDDExportConfigurator) getConfigurator(TYPE.Sdd);
}
+ /**
+ * @param configurator
+ * @param urlString
+ * @return
+ */
+ public Job createIOServiceJob(OutputModelConfigurator configurator, String urlString) {
+ Assert.isNotNull(configurator, "Configuration may not be null");
+
+ // final Display display = Display.getCurrent();
+
+ Job job = new Job("Export: " + configurator.getClass().getSimpleName()) { //$NON-NLS-1$
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask("Exporting database. This will take some time.", IProgressMonitor.UNKNOWN);
+ try {
+ IIOService ioService = CdmApplicationState.getIOService();
+
+ ExportResult result = ioService.export(configurator);
+ ExportDataWrapper data = result.getExportData();
+ try{
+ if (result.getExportData().getType().equals(ExportResultType.BYTE_ARRAY)){
+ byte[] exportData = (byte[])data.getExportData();
+ if(exportData != null){
+ File file = new File(urlString);
+ FileOutputStream stream = new FileOutputStream(file);
+ stream.write(exportData);
+ stream.close();
+ }
+ } else if (result.getExportData().getType().equals(ExportResultType.MAP_BYTE_ARRAY)){
+ Map<String, byte[]> resultMap = (Map<String, byte[]>)data.getExportData();
+ Set<String> keySet = resultMap.keySet();
+ for (String key: keySet){
+ byte[] fileData = resultMap.get(key);
+ String fileEnding ="";
+ if (configurator instanceof OutputModelConfigurator){
+ fileEnding = ".csv";
+ }
+ File file = new File(urlString+File.separator + key + fileEnding);
+ FileOutputStream stream = new FileOutputStream(file);
+ stream.write(fileData);
+ stream.close();
+ }
+
+ }else{
+ logger.error("This kind of result data is not supported yet." + result.getExportData().getType().toString());
+ }
+ } catch(Exception e){
+ logger.error(e.getStackTrace());
+ }
+
+
+
+
+ } catch (Exception e) {
+ MessagingUtils.errorDialog("Error exporting data",
+ this,
+ e.getMessage(),
+ TaxeditorStorePlugin.PLUGIN_ID,
+ e,
+ true);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ return job;
+ }
+
}
public static final String SDD_EXPORT = "SDD_EXPORT";
public static final String DWCA_EXPORT = "DWCA_EXPORT";
-
+ public static final String OUTPUT_MODEL_EXPORT = "OUTPUT_MODEL_EXPORT";
public static final String CSV_EXPORT = "CSV_EXPORT";
public static final String CSV_NAME_EXPORT = "CSV_NAME_EXPORT";
private static boolean csvPrintExport = false;
+ private static boolean outputModelExport = false;
+
private DirectoryDialog folderDialog;
private Text text_exportFileName;
ZIP);
}
+ /**
+ * @return
+ */
+ public static ExportToFileDestinationWizardPage OutputModel() {
+ outputModelExport = true;
+ return new ExportToFileDestinationWizardPage(
+ OUTPUT_MODEL_EXPORT,
+ "output model",
+ "Output Model Export",
+ "Export the contents of the currently selected database into the output model format.",
+ CSV);
+ }
/**
}
- if(csvExport || csvPrintExport){
+ if(csvExport || csvPrintExport || outputModelExport){
Label comboBoxLabel = new Label(composite, SWT.NONE);
comboBoxLabel.setText("Classification");
classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
true, false, 2, 1));
}
-
-
-
-
- Label fileLabel = new Label(composite, SWT.NONE);
- fileLabel.setText("File");
-
- text_exportFileName = new Text(composite, SWT.BORDER);
- text_exportFileName.setText(generateFilename());
- text_exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
- true, false, 2, 1));
+ if (!outputModelExport){
+ Label fileLabel = new Label(composite, SWT.NONE);
+ fileLabel.setText("File");
+ text_exportFileName = new Text(composite, SWT.BORDER);
+ text_exportFileName.setText(generateFilename());
+ text_exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
+ true, false, 2, 1));
+ }
Label folderLabel = new Label(composite, SWT.NONE);
folderLabel.setText("Folder");
--- /dev/null
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.io.wizard;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.List;
+import java.util.UUID;
+
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.progress.IProgressConstants;
+
+import eu.etaxonomy.cdm.io.outputmodel.OutputModelConfigurator;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author k.luther
+ * @date 21.03.2017
+ *
+ */
+public class OutputModelExportWizard extends
+ AbstractExportWizard<OutputModelConfigurator> {
+
+ private OutputModelConfigurator configurator;
+ private ExportToFileDestinationWizardPage page;
+
+ private final String description = "Export the contents of the currently selected database into Comma Separated Value format.";
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
+ * org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ configurator = new OutputModelConfigurator(null);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#getConfigurator()
+ */
+ @Override
+ public OutputModelConfigurator getConfigurator() {
+ return configurator;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ String urlString = page.getFolderText() + File.separator;
+ //+ page.getExportFileName();
+
+ final Combo combo = page.getCombo();
+ final List<Classification> listClassifications = CdmStore.getCurrentApplicationConfiguration().getClassificationService().listClassifications(null, null, null, null);
+ if(combo != null){
+ int selectionIndex = combo.getSelectionIndex();
+ HashSet<UUID> set = new HashSet<UUID>();
+ if(selectionIndex == -1){
+ for(Classification c:listClassifications){
+ set.add(c.getUuid());
+ }
+ }else{
+ for(Classification c:listClassifications){
+ if(c.getTitleCache().equalsIgnoreCase(combo.getItem(selectionIndex))){
+ set.add(c.getUuid());
+ }
+ }
+ configurator.setClassificationUuids(set);
+
+ }
+ }
+
+ // create job
+ Job job = CdmStore.getExportManager().createIOServiceJob(configurator, urlString);
+ // configure the job
+ job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
+ job.setUser(true);
+ // schedule job
+ job.schedule();
+
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#addPages()
+ */
+ @Override
+ public void addPages() {
+ //TODO create page with drop down menu for export for single classification.
+// super.addPages();
+
+
+ //standard page
+ page = ExportToFileDestinationWizardPage.OutputModel();
+
+ addPage(page);
+ }
+
+
+}
import eu.etaxonomy.cdm.api.service.ITermService;
import eu.etaxonomy.cdm.api.service.IUserService;
import eu.etaxonomy.cdm.api.service.IVocabularyService;
-import eu.etaxonomy.cdm.api.service.pager.Pager;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.agent.AgentBase;
import eu.etaxonomy.cdm.model.agent.Person;
}
@Test
- @Ignore
+@Ignore
public void addGrandChildPolytomousKeyNode() {
PolytomousKey pKey = CdmBase.deproxy(polytomousKeyService.find(polytomousKeyUuid),PolytomousKey.class);
}
}
termService.delete(updateTerms);
-
+
// if(termService.findByRepresentationText("UpdateTest", Feature.class, null, null) != null) {
// Pager<Feature> terms = termService.findByRepresentationText("UpdateTest", Feature.class, null, null);
// if (!terms.getRecords().isEmpty()){
vocNameFeature.addTerm(newTerm);
List<MergeResult<TermVocabulary>> mergeResults = vocabularyService.merge(vocs, true);
-
+
for(MergeResult<TermVocabulary> result : mergeResults){
TermVocabulary voc = result.getMergedEntity();
if(voc.getUuid().equals(vocNameFeatureUuid)) {