Eclipseplugins
UserExitDelegateImpl.java
1 package com.proalpha.pds.paconnector.userexit;
2 
3 import java.io.File;
4 
5 import org.eclipse.core.resources.IFolder;
6 import org.eclipse.core.resources.IResource;
7 import org.eclipse.core.runtime.CoreException;
8 import org.eclipse.core.runtime.IStatus;
9 import org.eclipse.core.runtime.NullProgressMonitor;
10 import org.eclipse.core.runtime.Status;
11 
12 import com.proalpha.pds.exception.ProALPHANotAvailableException;
13 import com.proalpha.pds.paconnector.Activator;
14 import com.proalpha.pds.paconnector.PaProject;
15 import com.proalpha.pds.paconnector.RunCommonPaProgram;
16 import com.proalpha.pds.paconnector.parameter.StartparameterReader;
17 
18 class UserExitDelegateImpl extends RunCommonPaProgram implements UserExitDelegate {
19 
20  private final StartparameterReader startparameterReader;
21 
22  protected UserExitDelegateImpl(PaProject paProject, StartparameterReader startparameterReader)
23  throws ProALPHANotAvailableException {
24  super(paProject);
25  this.startparameterReader = startparameterReader;
26  }
27 
28  @Override
29  public File extractBalpFileToXMLFile(String balpFile) throws Exception {
30 
31  IFolder workingDirectory = startparameterReader.getWorkingDirectory();
32 
33  if (!workingDirectory.exists())
34  throw new Exception("WorkingDirectory " + workingDirectory.getName()
35  + " does not exist. Check setting in proALPHA Start Config.");
36 
37  String pathToXMLFile = runSupportProcedure("ds_oea26.p", balpFile);
38 
39  try {
40  workingDirectory.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
41  } catch (CoreException e) {
42  IStatus status = new Status(Status.WARNING, Activator.PLUGIN_ID, e.getMessage(), e);
43  Activator.getDefault().getLog().log(status);
44  }
45 
46  return new File(pathToXMLFile);
47  }
48 
49  @Override
50  public File extractUserExitToXMLFile(UserExitInclude userExitInclude) {
51  String pahtToXMLFile = runSupportProcedure("ds_oea25.p", userExitInclude.getName(),
52  userExitInclude.getIncludeType(), userExitInclude.getSourceFileName(), userExitInclude.getSortCase());
53  return new File(pahtToXMLFile);
54  }
55 
56  @Override
57  public UserExitInclude getEmptyUserExitInclude() {
58  return new UserExitIncludeImpl();
59  }
60 
61 }
String runSupportProcedure(String supportProcedure, String... parameters)