Skip to content

Commit

Permalink
Merge pull request #1580 from Mailaender/process-builder-parameters
Browse files Browse the repository at this point in the history
Fix invalid parameters for process builder
  • Loading branch information
eselmeister authored Dec 11, 2023
2 parents 33bbed5 + fa71136 commit fbd4705
Show file tree
Hide file tree
Showing 27 changed files with 181 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.chromatogram.msd.peak.detector.supplier.amdis.runtime;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.eclipse.chemclipse.support.runtime.AbstractLinuxWineSupport;
Expand All @@ -21,9 +22,9 @@ public class LinuxWineSupport extends AbstractLinuxWineSupport implements IExten

private IAmdisSupport amdisSupport;

public LinuxWineSupport(String application, String parameter) throws FileNotFoundException {
public LinuxWineSupport(String application, List<String> parameters) throws FileNotFoundException {

super(application, parameter);
super(application, parameters);
amdisSupport = new AmdisSupport(this);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/*******************************************************************************
* Copyright (c) 2014, 2018 Lablicate GmbH.
* Copyright (c) 2014, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.chromatogram.msd.peak.detector.supplier.amdis.runtime;

import java.io.FileNotFoundException;
import java.util.List;

import org.eclipse.chemclipse.chromatogram.msd.peak.detector.supplier.amdis.preferences.PreferenceSupplier;
import org.eclipse.chemclipse.support.runtime.AbstractMacWineSupport;
Expand All @@ -20,8 +21,9 @@ public class MacWineSupport extends AbstractMacWineSupport implements IExtendedR

private IAmdisSupport amdisSupport;

public MacWineSupport(String application, String parameter) throws FileNotFoundException {
super(application, parameter, PreferenceSupplier.getMacWineBinary());
public MacWineSupport(String application, List<String> parameters) throws FileNotFoundException {

super(application, parameters, PreferenceSupplier.getMacWineBinary());
amdisSupport = new AmdisSupport(this);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
/*******************************************************************************
* Copyright (c) 2014, 2018 Lablicate GmbH.
* Copyright (c) 2014, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.chromatogram.msd.peak.detector.supplier.amdis.runtime;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.chemclipse.support.settings.OperatingSystemUtils;

Expand All @@ -20,16 +22,18 @@ public class RuntimeSupportFactory {
public static IExtendedRuntimeSupport getRuntimeSupport(String application, String chromatogram) throws FileNotFoundException {

IExtendedRuntimeSupport runtimeSupport;
String parameter = chromatogram + " " + IAmdisSupport.PARAMETER;
List<String> parameters = new ArrayList<>();
parameters.add(chromatogram);
parameters.add(IAmdisSupport.PARAMETER);
if(OperatingSystemUtils.isWindows()) {
runtimeSupport = new WindowsSupport(application, parameter);
runtimeSupport = new WindowsSupport(application, parameters);
} else if(OperatingSystemUtils.isMac()) {
runtimeSupport = new MacWineSupport(application, parameter);
runtimeSupport = new MacWineSupport(application, parameters);
} else {
/*
* wine AMDIS32\$.exe C:\\tmp\\C2.CDF /S
*/
runtimeSupport = new LinuxWineSupport(application, parameter);
runtimeSupport = new LinuxWineSupport(application, parameters);
}
return runtimeSupport;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.chromatogram.msd.peak.detector.supplier.amdis.runtime;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;

import org.eclipse.chemclipse.support.runtime.AbstractWindowsSupport;

public class WindowsSupport extends AbstractWindowsSupport implements IExtendedRuntimeSupport {

private IAmdisSupport amdisSupport;

public WindowsSupport(String application, String parameter) throws FileNotFoundException {
public WindowsSupport(String application, List<String> parameters) throws FileNotFoundException {

super(application, parameter);
super(application, parameters);
amdisSupport = new AmdisSupport(this);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
/*******************************************************************************
* Copyright (c) 2014, 2020 Lablicate GmbH.
* Copyright (c) 2014, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.msd.identifier.supplier.nist.runtime;

import java.util.List;

import org.eclipse.chemclipse.support.runtime.IRuntimeSupport;

public interface IExtendedRuntimeSupport extends IRuntimeSupport {
Expand All @@ -30,7 +32,7 @@ public interface IExtendedRuntimeSupport extends IRuntimeSupport {
*/
default boolean isBatchModus() {

String parameter = getParameter();
List<String> parameter = getParameters();
if(parameter != null) {
return parameter.contains(INistSupport.PAR2);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*******************************************************************************
* Copyright (c) 2008, 2022 Lablicate GmbH.
* Copyright (c) 2008, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.msd.identifier.supplier.nist.runtime;

Expand All @@ -27,8 +27,6 @@ public interface INistSupport {
*/
String PAR2 = "/PAR=2";
String INSTRUMENT = "/INSTRUMENT";
String PARAMETER_BACKGROUND = INSTRUMENT + " " + PAR2;
String PARAMETER_FOREGROUND = INSTRUMENT;
/*
* The path is NIST library specific.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
* Christoph Läubrich - using a path instead of a string
*******************************************************************************/
package org.eclipse.chemclipse.msd.identifier.supplier.nist.runtime;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.eclipse.chemclipse.msd.identifier.supplier.nist.preferences.PreferenceSupplier;
Expand All @@ -24,9 +25,9 @@ public class LinuxWineSupport extends AbstractLinuxWineSupport implements IExten

private final INistSupport nistSupport;

public LinuxWineSupport(File applicationFolder, String parameter) throws FileNotFoundException {
public LinuxWineSupport(File applicationFolder, List<String> parameters) throws FileNotFoundException {

super(PreferenceSupplier.getNistExecutable(applicationFolder).getAbsolutePath(), parameter);
super(PreferenceSupplier.getNistExecutable(applicationFolder).getAbsolutePath(), parameters);
nistSupport = new NistSupport(this);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
/*******************************************************************************
* Copyright (c) 2011, 2019 Lablicate GmbH.
* Copyright (c) 2011, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
* Christoph Läubrich - using a path instead of a string
*******************************************************************************/
package org.eclipse.chemclipse.msd.identifier.supplier.nist.runtime;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.List;

import org.eclipse.chemclipse.msd.identifier.supplier.nist.preferences.PreferenceSupplier;
import org.eclipse.chemclipse.support.runtime.AbstractMacWineSupport;
Expand All @@ -22,8 +23,9 @@ public class MacWineSupport extends AbstractMacWineSupport implements IExtendedR

private final INistSupport nistSupport;

public MacWineSupport(File applicationFolder, String parameter) throws FileNotFoundException {
super(PreferenceSupplier.getNistExecutable(applicationFolder).getAbsolutePath(), parameter, PreferenceSupplier.getMacWineBinary());
public MacWineSupport(File applicationFolder, List<String> parameters) throws FileNotFoundException {

super(PreferenceSupplier.getNistExecutable(applicationFolder).getAbsolutePath(), parameters, PreferenceSupplier.getMacWineBinary());
nistSupport = new NistSupport(this);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
/*******************************************************************************
* Copyright (c) 2012, 2020 Lablicate GmbH.
* Copyright (c) 2012, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
* Christoph Läubrich - using a path instead of a string
*******************************************************************************/
package org.eclipse.chemclipse.msd.identifier.supplier.nist.runtime;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.chemclipse.support.settings.OperatingSystemUtils;

Expand Down Expand Up @@ -43,14 +45,17 @@ public static IExtendedRuntimeSupport getRuntimeSupport(File applicationFolder)
public static IExtendedRuntimeSupport getRuntimeSupport(File applicationFolder, boolean batchModus) throws FileNotFoundException {

IExtendedRuntimeSupport runtimeSupport;
String parameter = batchModus ? INistSupport.PARAMETER_BACKGROUND : INistSupport.PARAMETER_FOREGROUND;
//
List<String> parameters = new ArrayList<>();
parameters.add(INistSupport.INSTRUMENT);
if(batchModus) {
parameters.add(INistSupport.PAR2);
}
if(OperatingSystemUtils.isWindows()) {
runtimeSupport = new WindowsSupport(applicationFolder, parameter);
runtimeSupport = new WindowsSupport(applicationFolder, parameters);
} else if(OperatingSystemUtils.isMac()) {
runtimeSupport = new MacWineSupport(applicationFolder, parameter);
runtimeSupport = new MacWineSupport(applicationFolder, parameters);
} else {
runtimeSupport = new LinuxWineSupport(applicationFolder, parameter);
runtimeSupport = new LinuxWineSupport(applicationFolder, parameters);
}
return runtimeSupport;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
* Christoph Läubrich - using a path instead of a string
*******************************************************************************/
package org.eclipse.chemclipse.msd.identifier.supplier.nist.runtime;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;

import org.eclipse.chemclipse.msd.identifier.supplier.nist.preferences.PreferenceSupplier;
import org.eclipse.chemclipse.support.runtime.AbstractWindowsSupport;
Expand All @@ -23,9 +24,9 @@ public class WindowsSupport extends AbstractWindowsSupport implements IExtendedR

private final INistSupport nistSupport;

public WindowsSupport(File applicationFolder, String parameter) throws FileNotFoundException {
public WindowsSupport(File applicationFolder, List<String> parameters) throws FileNotFoundException {

super(PreferenceSupplier.getNistExecutable(applicationFolder).getAbsolutePath(), parameter);
super(PreferenceSupplier.getNistExecutable(applicationFolder).getAbsolutePath(), parameters);
nistSupport = new NistSupport(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.support.runtime;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public abstract class AbstractLinuxWineSupport extends AbstractWineRuntimeSupport implements IWineRuntimeSupport {
Expand All @@ -24,7 +26,7 @@ public abstract class AbstractLinuxWineSupport extends AbstractWineRuntimeSuppor
* @param application
* @param parameter
*/
protected AbstractLinuxWineSupport(String application, String parameter) throws FileNotFoundException {
protected AbstractLinuxWineSupport(String application, List<String> parameter) throws FileNotFoundException {

super(application, parameter);
}
Expand All @@ -40,7 +42,12 @@ private ProcessBuilder getRunCommand() {
/*
* "env WINEPREFIX=/home/chemclipse/.wine wine start C:\\programme\\nist\\MSSEARCH\\nistms$.exe /INSTRUMENT /PAR=2"
*/
ProcessBuilder processBuilder = new ProcessBuilder("wine", "start", getWineApplication(), getParameter());
List<String> commands = new ArrayList<>();
commands.add("wine");
commands.add("start");
commands.add(getWineApplication());
commands.addAll(getParameters());
ProcessBuilder processBuilder = new ProcessBuilder(commands);
Map<String, String> environment = processBuilder.environment();
environment.put("WINEPREFIX", getWineEnvironment());
return processBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.support.runtime;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;

public abstract class AbstractMacWineSupport extends AbstractWineRuntimeSupport implements IWineRuntimeSupport {

Expand All @@ -27,9 +28,9 @@ public abstract class AbstractMacWineSupport extends AbstractWineRuntimeSupport
* @param macWineBinary
* (e.g. "/Applications/Wine.app")
*/
protected AbstractMacWineSupport(String application, String parameter, String macWineBinary) throws FileNotFoundException {
protected AbstractMacWineSupport(String application, List<String> parameters, String macWineBinary) throws FileNotFoundException {

super(application, parameter);
super(application, parameters);
this.macWineBinary = macWineBinary;
}

Expand Down
Loading

0 comments on commit fbd4705

Please sign in to comment.