Skip to content

Commit

Permalink
Remove generics from scan converter VSD.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender committed Jan 15, 2025
1 parent 6172426 commit bc57977
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
import org.eclipse.chemclipse.vsd.converter.core.IScanImportConverter;
import org.eclipse.chemclipse.vsd.converter.supplier.cml.io.ScanReader;
import org.eclipse.chemclipse.vsd.converter.supplier.cml.model.IVendorSpectrumVSD;
import org.eclipse.chemclipse.vsd.model.core.ISpectrumVSD;
import org.eclipse.core.runtime.IProgressMonitor;

@SuppressWarnings("rawtypes")
public class ScanImportConverter extends AbstractScanImportConverter implements IScanImportConverter {

@Override
public IProcessingInfo<IVendorSpectrumVSD> convert(File file, IProgressMonitor monitor) {
public IProcessingInfo<ISpectrumVSD> convert(File file, IProgressMonitor monitor) {

IProcessingInfo<IVendorSpectrumVSD> processingInfo = new ProcessingInfo<>();
IProcessingInfo<ISpectrumVSD> processingInfo = new ProcessingInfo<>();
IVendorSpectrumVSD vendorScan = null;
ScanReader scanReader = new ScanReader();
vendorScan = scanReader.read(file, monitor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
import org.eclipse.chemclipse.vsd.converter.core.IScanImportConverter;
import org.eclipse.chemclipse.vsd.converter.supplier.csv.io.ScanReader;
import org.eclipse.chemclipse.vsd.converter.supplier.csv.model.IVendorSpectrumVSD;
import org.eclipse.chemclipse.vsd.model.core.ISpectrumVSD;
import org.eclipse.core.runtime.IProgressMonitor;

@SuppressWarnings("rawtypes")
public class ScanImportConverter extends AbstractScanImportConverter implements IScanImportConverter {

private static final Logger logger = Logger.getLogger(ScanImportConverter.class);

@Override
public IProcessingInfo<?> convert(File file, IProgressMonitor monitor) {
public IProcessingInfo<ISpectrumVSD> convert(File file, IProgressMonitor monitor) {

IProcessingInfo<IVendorSpectrumVSD> processingInfo = new ProcessingInfo<>();
IProcessingInfo<ISpectrumVSD> processingInfo = new ProcessingInfo<>();
try {
ScanReader scanReader = new ScanReader();
IVendorSpectrumVSD vendorScan = scanReader.read(file, monitor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@

import org.eclipse.chemclipse.converter.core.AbstractImportConverter;

@SuppressWarnings("rawtypes")
public abstract class AbstractScanImportConverter extends AbstractImportConverter implements IScanImportConverter {
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

import org.eclipse.chemclipse.converter.core.IImportConverter;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.chemclipse.vsd.model.core.ISpectrumVSD;
import org.eclipse.core.runtime.IProgressMonitor;

public interface IScanImportConverter<T> extends IImportConverter {
public interface IScanImportConverter extends IImportConverter {

IProcessingInfo<T> convert(File file, IProgressMonitor monitor);
IProcessingInfo<ISpectrumVSD> convert(File file, IProgressMonitor monitor);
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static IProcessingInfo<ISpectrumVSD> convert(final File file, final Strin
* Do not use a safe runnable here, because an object must
* be returned or null.
*/
IScanImportConverter<ISpectrumVSD> importConverter = getScanImportConverter(converterId);
IScanImportConverter importConverter = getScanImportConverter(converterId);
if(importConverter != null) {
processingInfo = importConverter.convert(file, monitor);
} else {
Expand Down Expand Up @@ -87,7 +87,7 @@ private static IProcessingInfo<ISpectrumVSD> getScan(final File file, IProgressM
* Do not use a safe runnable here, because an object must
* be returned or null.
*/
IScanImportConverter<ISpectrumVSD> importConverter = getScanImportConverter(converterId);
IScanImportConverter importConverter = getScanImportConverter(converterId);
if(importConverter != null) {
processingInfo = importConverter.convert(file, monitor);
if(!processingInfo.hasErrorMessages()) {
Expand Down Expand Up @@ -117,15 +117,14 @@ public static IProcessingInfo<File> convert(final File file, final ISpectrumVSD
return processingInfo;
}

@SuppressWarnings("unchecked")
private static IScanImportConverter<ISpectrumVSD> getScanImportConverter(final String converterId) {
private static IScanImportConverter getScanImportConverter(final String converterId) {

IConfigurationElement element;
element = getConfigurationElement(converterId);
IScanImportConverter<ISpectrumVSD> instance = null;
IScanImportConverter instance = null;
if(element != null) {
try {
instance = (IScanImportConverter<ISpectrumVSD>)element.createExecutableExtension(Converter.IMPORT_CONVERTER);
instance = (IScanImportConverter)element.createExecutableExtension(Converter.IMPORT_CONVERTER);
} catch(CoreException e) {
logger.error(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
import org.eclipse.chemclipse.vsd.converter.core.IScanImportConverter;
import org.eclipse.chemclipse.vsd.converter.supplier.jcampdx.io.ScanReader;
import org.eclipse.chemclipse.vsd.converter.supplier.jcampdx.model.IVendorSpectrumVSD;
import org.eclipse.chemclipse.vsd.model.core.ISpectrumVSD;
import org.eclipse.core.runtime.IProgressMonitor;

@SuppressWarnings("rawtypes")
public class ScanImportConverter extends AbstractScanImportConverter implements IScanImportConverter {

private static final Logger logger = Logger.getLogger(ScanImportConverter.class);

@Override
public IProcessingInfo<IVendorSpectrumVSD> convert(File file, IProgressMonitor monitor) {
public IProcessingInfo<ISpectrumVSD> convert(File file, IProgressMonitor monitor) {

IProcessingInfo<IVendorSpectrumVSD> processingInfo = new ProcessingInfo<>();
IProcessingInfo<ISpectrumVSD> processingInfo = new ProcessingInfo<>();
try {
ScanReader scanReader = new ScanReader();
IVendorSpectrumVSD vendorScan = scanReader.read(file, monitor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,48 @@
import org.eclipse.chemclipse.vsd.converter.supplier.cml.PathResolver;
import org.eclipse.chemclipse.vsd.converter.supplier.cml.converter.ScanImportConverter;
import org.eclipse.chemclipse.vsd.converter.supplier.cml.model.IVendorSpectrumVSD;
import org.eclipse.chemclipse.vsd.model.core.ISpectrumVSD;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.junit.Test;

import junit.framework.TestCase;

public class But2_ITest extends TestCase {

private IVendorSpectrumVSD vendorSpectrum;
private ISpectrumVSD spectrumVSD;

@Override
protected void setUp() throws Exception {

super.setUp();
File file = new File(PathResolver.getAbsolutePath(TestPathHelper.BUT2));
ScanImportConverter importConverter = new ScanImportConverter();
IProcessingInfo<IVendorSpectrumVSD> processingInfo = importConverter.convert(file, new NullProgressMonitor());
vendorSpectrum = processingInfo.getProcessingResult();
IProcessingInfo<ISpectrumVSD> processingInfo = importConverter.convert(file, new NullProgressMonitor());
spectrumVSD = processingInfo.getProcessingResult();
}

@Override
protected void tearDown() throws Exception {

vendorSpectrum = null;
spectrumVSD = null;
super.tearDown();
}

@Test
public void testLoading() {

assertNotNull(vendorSpectrum);
assertEquals("2-Butanol", vendorSpectrum.getSampleName());
assertEquals("but2", vendorSpectrum.getDataName());
assertEquals("C 4 H 10 O 1", vendorSpectrum.getFormula());
assertEquals("78-92-2", vendorSpectrum.getCasNumber());
assertNotNull(spectrumVSD);
assertEquals("2-Butanol", spectrumVSD.getSampleName());
assertEquals("but2", spectrumVSD.getDataName());
if(spectrumVSD instanceof IVendorSpectrumVSD vendorSpectrumVSD) {
assertEquals("C 4 H 10 O 1", vendorSpectrumVSD.getFormula());
assertEquals("78-92-2", vendorSpectrumVSD.getCasNumber());
}
}

@Test
public void testSignals() {

assertEquals(224, vendorSpectrum.getScanVSD().getProcessedSignals().size());
assertEquals(224, spectrumVSD.getScanVSD().getProcessedSignals().size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,49 @@
import org.eclipse.chemclipse.vsd.converter.supplier.cml.PathResolver;
import org.eclipse.chemclipse.vsd.converter.supplier.cml.converter.ScanImportConverter;
import org.eclipse.chemclipse.vsd.converter.supplier.cml.model.IVendorSpectrumVSD;
import org.eclipse.chemclipse.vsd.model.core.ISpectrumVSD;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.junit.Test;

import junit.framework.TestCase;

public class PCLANIL_ITest extends TestCase {

private IVendorSpectrumVSD vendorSpectrum;
private ISpectrumVSD spectrumVSD;

@Override
protected void setUp() throws Exception {

super.setUp();
File file = new File(PathResolver.getAbsolutePath(TestPathHelper.PCLANIL));
ScanImportConverter importConverter = new ScanImportConverter();
IProcessingInfo<IVendorSpectrumVSD> processingInfo = importConverter.convert(file, new NullProgressMonitor());
vendorSpectrum = processingInfo.getProcessingResult();
IProcessingInfo<ISpectrumVSD> processingInfo = importConverter.convert(file, new NullProgressMonitor());
spectrumVSD = processingInfo.getProcessingResult();
}

@Override
protected void tearDown() throws Exception {

vendorSpectrum = null;
spectrumVSD = null;
super.tearDown();
}

@Test
public void testLoading() {

assertNotNull(vendorSpectrum);
assertEquals("para-chloroaniline", vendorSpectrum.getSampleName());
assertEquals("IR_para-chlor", vendorSpectrum.getDataName());
assertEquals("C6H6ClN", vendorSpectrum.getFormula());
assertEquals("106-47-8", vendorSpectrum.getCasNumber());
assertEquals("PERKIN-ELMER 1000 FT-IR", vendorSpectrum.getInstrument());
assertNotNull(spectrumVSD);
assertEquals("para-chloroaniline", spectrumVSD.getSampleName());
assertEquals("IR_para-chlor", spectrumVSD.getDataName());
assertEquals("PERKIN-ELMER 1000 FT-IR", spectrumVSD.getInstrument());
if(spectrumVSD instanceof IVendorSpectrumVSD vendorSpectrumVSD) {
assertEquals("C6H6ClN", vendorSpectrumVSD.getFormula());
assertEquals("106-47-8", vendorSpectrumVSD.getCasNumber());
}
}

@Test
public void testSignals() {

assertEquals(1801, vendorSpectrum.getScanVSD().getProcessedSignals().size());
assertEquals(1801, spectrumVSD.getScanVSD().getProcessedSignals().size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,42 @@

import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.chemclipse.vsd.converter.supplier.jcampdx.converter.ScanImportConverter;
import org.eclipse.chemclipse.vsd.converter.supplier.jcampdx.model.IVendorSpectrumVSD;
import org.eclipse.chemclipse.vsd.model.core.ISpectrumVSD;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.junit.Test;

import junit.framework.TestCase;

public class FixedDecrease1_ITest extends TestCase {

private IVendorSpectrumVSD vendorSpectrum;
private ISpectrumVSD spectrumVSD;

@Override
protected void setUp() throws Exception {

super.setUp();
File file = new File(PathResolver.getAbsolutePath(TestPathHelper.FIXDEC1));
ScanImportConverter importConverter = new ScanImportConverter();
IProcessingInfo<IVendorSpectrumVSD> processingInfo = importConverter.convert(file, new NullProgressMonitor());
vendorSpectrum = processingInfo.getProcessingResult();
IProcessingInfo<ISpectrumVSD> processingInfo = importConverter.convert(file, new NullProgressMonitor());
spectrumVSD = processingInfo.getProcessingResult();
}

@Override
protected void tearDown() throws Exception {

vendorSpectrum = null;
spectrumVSD = null;
super.tearDown();
}

@Test
public void testLoading() {

assertNotNull(vendorSpectrum);
assertNotNull(spectrumVSD);
}

@Test
public void testSignals() {

assertEquals(3951, vendorSpectrum.getScanVSD().getProcessedSignals().size());
assertEquals(3951, spectrumVSD.getScanVSD().getProcessedSignals().size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,42 @@

import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.chemclipse.vsd.converter.supplier.jcampdx.converter.ScanImportConverter;
import org.eclipse.chemclipse.vsd.converter.supplier.jcampdx.model.IVendorSpectrumVSD;
import org.eclipse.chemclipse.vsd.model.core.ISpectrumVSD;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.junit.Test;

import junit.framework.TestCase;

public class FixedIncrease1_ITest extends TestCase {

private IVendorSpectrumVSD vendorSpectrum;
private ISpectrumVSD spectrumVSD;

@Override
protected void setUp() throws Exception {

super.setUp();
File file = new File(PathResolver.getAbsolutePath(TestPathHelper.FIXINC1));
ScanImportConverter importConverter = new ScanImportConverter();
IProcessingInfo<IVendorSpectrumVSD> processingInfo = importConverter.convert(file, new NullProgressMonitor());
vendorSpectrum = processingInfo.getProcessingResult();
IProcessingInfo<ISpectrumVSD> processingInfo = importConverter.convert(file, new NullProgressMonitor());
spectrumVSD = processingInfo.getProcessingResult();
}

@Override
protected void tearDown() throws Exception {

vendorSpectrum = null;
spectrumVSD = null;
super.tearDown();
}

@Test
public void testLoading() {

assertNotNull(vendorSpectrum);
assertNotNull(spectrumVSD);
}

@Test
public void testSignals() {

assertEquals(3736, vendorSpectrum.getScanVSD().getProcessedSignals().size());
assertEquals(3736, spectrumVSD.getScanVSD().getProcessedSignals().size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,42 @@

import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.chemclipse.vsd.converter.supplier.jcampdx.converter.ScanImportConverter;
import org.eclipse.chemclipse.vsd.converter.supplier.jcampdx.model.IVendorSpectrumVSD;
import org.eclipse.chemclipse.vsd.model.core.ISpectrumVSD;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.junit.Test;

import junit.framework.TestCase;

public class FixedIncrease2_ITest extends TestCase {

private IVendorSpectrumVSD vendorSpectrum;
private ISpectrumVSD spectrumVSD;

@Override
protected void setUp() throws Exception {

super.setUp();
File file = new File(PathResolver.getAbsolutePath(TestPathHelper.FIXINC2));
ScanImportConverter importConverter = new ScanImportConverter();
IProcessingInfo<IVendorSpectrumVSD> processingInfo = importConverter.convert(file, new NullProgressMonitor());
vendorSpectrum = processingInfo.getProcessingResult();
IProcessingInfo<ISpectrumVSD> processingInfo = importConverter.convert(file, new NullProgressMonitor());
spectrumVSD = processingInfo.getProcessingResult();
}

@Override
protected void tearDown() throws Exception {

vendorSpectrum = null;
spectrumVSD = null;
super.tearDown();
}

@Test
public void testLoading() {

assertNotNull(vendorSpectrum);
assertNotNull(spectrumVSD);
}

@Test
public void testSignals() {

assertEquals(3601, vendorSpectrum.getScanVSD().getProcessedSignals().size());
assertEquals(3601, spectrumVSD.getScanVSD().getProcessedSignals().size());
}
}
Loading

0 comments on commit bc57977

Please sign in to comment.