* 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;
import java.io.BufferedWriter;
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
/**
- * <p>
- * ExportHandler class.
- * </p>
*
* @author n.hoffmann
* @created Sep 11, 2009
- * @version 1.0
*/
-public class ExportManager extends AbstractIOManager<IExportConfigurator> implements IPostMoniteredOperationEnabled {
-
- private final String successMessage = "The export was successful";
+public class ExportManager
+ extends AbstractIOManager<IExportConfigurator>
+ implements IPostMoniteredOperationEnabled {
private static final Logger logger = Logger.getLogger(ExportManager.class);
/** Constant <code>DATE_FORMAT_NOW="yyyyMMddHHmm"</code> */
public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm";
- /**
- *
- * @param applicationConfiguration
- */
+
+ private final String successMessage = "The export was successful";
+
private ExportManager(ICdmRepository applicationConfiguration) {
super(applicationConfiguration);
}
- /**
- * <p>
- * NewInstance
- * </p>
- *
- * @param applicationConfiguration
- * a
- * {@link eu.etaxonomy.cdm.api.application.CdmApplicationController}
- * object.
- * @return a {@link eu.etaxonomy.taxeditor.io.ExportManager} object.
- */
public static ExportManager NewInstance(
ICdmRepository applicationConfiguration) {
return new ExportManager(applicationConfiguration);
}
- /**
- * <p>
- * createIOJob
- * </p>
- *
- * @param configurator
- * a {@link eu.etaxonomy.cdm.io.common.IExportConfigurator}
- * object.
- * @return a {@link org.eclipse.core.runtime.jobs.Job} object.
- */
@Override
protected Job createIOJob(final IExportConfigurator configurator) {
// monitor.worked(10);
- CdmDefaultExport<IExportConfigurator> exporter = new CdmDefaultExport<IExportConfigurator>();
+ CdmDefaultExport<IExportConfigurator> exporter = new CdmDefaultExport<>();
configurator.setProgressMonitor(CdmProgressMonitorAdapter
.CreateSubMonitor(monitor, 80));
exporter.setCdmAppController(applicationConfiguration);
+ "Please check error log for details.", e);
}
- display.asyncExec(new Runnable() {
-
- @Override
- public void run() {
- Object activePart = EventUtility.getActivePart();
- if (activePart instanceof IConversationEnabled) {
- // terminate any open transactions
- IConversationEnabled conversationEnabled = (IConversationEnabled) activePart;
- // restarting transaction and committing it to
- // trigger
- // change listener
- // TODO verify correct behaviour
-
- try{
- conversationEnabled.getConversationHolder()
- .startTransaction();
-
- conversationEnabled.getConversationHolder()
- .commit();
- }catch(RuntimeException e){
- MessagingUtils.messageDialog("Error starting conversation handling", this, "" +
- "Conversation Error: "+ e);
- }
+ display.asyncExec(()-> {
+ Object activePart = EventUtility.getActivePart();
+ if (activePart instanceof IConversationEnabled) {
+ // terminate any open transactions
+ IConversationEnabled conversationEnabled = (IConversationEnabled) activePart;
+ // restarting transaction and committing it to
+ // trigger
+ // change listener
+ // TODO verify correct behaviour
+
+ try{
+ conversationEnabled.getConversationHolder()
+ .startTransaction();
+
+ conversationEnabled.getConversationHolder()
+ .commit();
+ }catch(RuntimeException e){
+ MessagingUtils.messageDialog("Error starting conversation handling", this, "" +
+ "Conversation Error: "+ e);
}
}
});
return Status.OK_STATUS;
}
-
-
};
return job;
IIOService ioService = CdmApplicationState.getIOService();
UUID uuid = ioService.monitExportData(configurator);
IRemotingProgressMonitor remotingMonitor;
- List<IFeedbackGenerator> feedBackGeneratorList = new ArrayList<IFeedbackGenerator>();
+ List<IFeedbackGenerator> feedBackGeneratorList = new ArrayList<>();
try {
remotingMonitor = CdmStore.getProgressMonitorClientManager().pollMonitor("Export Data",
uuid,
subMonitor);
} catch (Exception ex) {
- return new Status(Status.ERROR, TaxeditorStorePlugin.PLUGIN_ID, "Operation Interrupted", ex);
+ return new Status(IStatus.ERROR, TaxeditorStorePlugin.PLUGIN_ID, "Operation Interrupted", ex);
}
ExportResult result = (ExportResult)remotingMonitor.getResult();
- ExportDataWrapper data = result.getExportData();
+ ExportDataWrapper<?> data = result.getExportData();
try{
if (result.getExportData().getType().equals(ExportResultType.BYTE_ARRAY) || result.getExportData().getType().equals(ExportResultType.LIST_BYTE_ARRAY)){
if (data.getExportData() instanceof byte[]){
}
}else if (data.getExportData() instanceof List<?>){
//TODO:This needs to be improved
- List<byte[]> exportData = (List<byte[]>)data.getExportData();
+ @SuppressWarnings("unchecked")
+ List<byte[]> exportData = (List<byte[]>)data.getExportData();
if(exportData != null){
FileOutputStream stream = new FileOutputStream(exportFile);
Writer out = new BufferedWriter(new OutputStreamWriter(
}
} else if (result.getExportData().getType().equals(ExportResultType.MAP_BYTE_ARRAY)){
+ @SuppressWarnings("unchecked")
Map<String, byte[]> resultMap = (Map<String, byte[]>)data.getExportData();
Set<String> keySet = resultMap.keySet();
- SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
- Calendar cal = Calendar.getInstance();
String fileEnding = ".zip";
if (configurator instanceof DwcaTaxExportConfigurator){
DwcaTaxExportConfigurator dwcaConfig = (DwcaTaxExportConfigurator)configurator;
};
return job;
}
- /**
- * @param jaxb
- * @return
- */
+
private IIoConfigurator getConfigurator(TYPE type) {
Assert.isNotNull(type, "Type should not be null");
}
}
- /**
- * <p>
- * JaxbConfigurator
- * </p>
- *
- * @return a {@link eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator} object.
- */
public final JaxbExportConfigurator JaxbConfigurator() {
return (JaxbExportConfigurator) getConfigurator(TYPE.Jaxb);
}
- /**
- * <p>
- * SddConfigurator
- * </p>
- *
- * @return a {@link eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator}
- * object.
- */
public final SDDExportConfigurator SddConfigurator() {
return (SDDExportConfigurator) getConfigurator(TYPE.Sdd);
}
- /**
- * @param configurator
- * @param urlString
- * @return
- */
public Job createIOServiceJob(CdmLightExportConfigurator configurator, String urlString) {
Assert.isNotNull(configurator, "Configuration may not be null");
final Display display = Display.getDefault();
configurator.setProgressMonitor(CdmProgressMonitorAdapter
.CreateSubMonitor(monitor, 80));
ExportResult result = ioService.export(configurator);
- ExportDataWrapper data = result.getExportData();
+ ExportDataWrapper<?> data = result.getExportData();
try{
if (result.getExportData().getType().equals(ExportResultType.BYTE_ARRAY) || result.getExportData().getType().equals(ExportResultType.LIST_BYTE_ARRAY)){
byte[] exportData = (byte[])data.getExportData();
stream.close();
}
} else if (result.getExportData().getType().equals(ExportResultType.MAP_BYTE_ARRAY)){
- Map<String, byte[]> resultMap = (Map<String, byte[]>)data.getExportData();
+ @SuppressWarnings("unchecked")
+ Map<String, byte[]> resultMap = (Map<String, byte[]>)data.getExportData();
Set<String> keySet = resultMap.keySet();
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
Calendar cal = Calendar.getInstance();
null,
urlString,
isZip);
-
}
});
-
}
@Override
public void postOperation(IRemotingProgressMonitor monitor) {
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- CdmStore.getContextManager().notifyContextRefresh();
- }
- });
-
+ Display.getDefault().asyncExec(()-> {
+ CdmStore.getContextManager().notifyContextRefresh();
+ });
}
-
-}
+}
\ No newline at end of file