use of massbank.JobInfo in project MassBank-web by MassBank.
the class MassBankAPI method getJobResult.
/**
* 指定したジョブIDの結果を取得します
*/
public ResultSet[] getJobResult(String jobId) throws AxisFault {
ResultSet[] rsets = null;
JobManager jobMgr = new JobManager();
JobInfo info = null;
try {
info = jobMgr.getJobInfo(jobId);
} catch (SQLException ex) {
throw new AxisFault("System error! [code=120]");
}
jobMgr.end();
if (info != null) {
ResultSet rset = null;
ArrayList<ResultSet> rsetList = new ArrayList<ResultSet>();
String res = info.getResult();
String[] lines = res.split("\n");
int cntLine = 0;
String hit = "";
for (int l = 0; l < lines.length; l++) {
String line = lines[l];
if (!line.equals("")) {
switch(cntLine) {
case 0:
rset = new ResultSet();
rset.setQueryName(line);
break;
case 1:
hit = line;
if (hit.equals("-1")) {
Result rs = new Result();
rset.addInfo(rs);
rset.setNumResults(-1);
}
break;
case 2:
break;
default:
String[] items = line.split("\t");
Result rs = new Result();
rs.setId(items[0]);
rs.setTitle(items[1]);
rs.setFormula(items[2]);
rs.setExactMass(items[3]);
rs.setScore(items[4]);
rset.addInfo(rs);
}
cntLine++;
} else {
if (cntLine > 0) {
rsetList.add(rset);
cntLine = 0;
}
}
}
if (cntLine > 0) {
rsetList.add(rset);
}
rsets = (ResultSet[]) rsetList.toArray(new ResultSet[] {});
} else {
// 対象ジョブがない場合
throw new AxisFault("Job Not found");
}
return rsets;
}
use of massbank.JobInfo in project MassBank-web by MassBank.
the class MassBankAPI method getJobStatus.
/**
* 指定したジョブIDの情報を取得する
*/
public JobStatus getJobStatus(String jobId) throws AxisFault {
JobStatus jobStatus = new JobStatus();
JobManager jobMgr = new JobManager();
JobInfo info = null;
try {
info = jobMgr.getJobInfo(jobId);
} catch (SQLException ex) {
throw new AxisFault("System error! [code=110]");
}
jobMgr.end();
if (info != null) {
jobStatus.setStatus(info.getStatus());
jobStatus.setRequestDate(info.getTimeStamp());
} else {
// 対象ジョブがない場合
throw new AxisFault("Job Not found");
}
return jobStatus;
}
use of massbank.JobInfo in project MassBank-web by MassBank.
the class MassBankAPI method execBatchJob.
/**
* バッチ処理を行う
*/
public String execBatchJob(String type, String mailAddress, String[] queryStrings, String[] instrumentTypes, String ionMode) throws AxisFault {
String jobId = "";
// クエリをテンポラリファイルに書き出す
String tempFileName = "";
try {
tempFileName = queryStrsToTempFile(queryStrings);
} catch (AxisFault ex) {
throw ex;
}
// ---------------------------------------
// パラメータチェック
// ---------------------------------------
HashMap<String, Object> mapParam = new HashMap<String, Object>();
// massTypes は強制的にallを指定
String[] keys = { "instrumentTypes", "massTypes", "ionMode" };
Object[] vals = { instrumentTypes, new String[] { "all" }, ionMode };
for (int i = 0; i < keys.length; i++) {
mapParam.put(keys[i], vals[i]);
}
ApiParameter apiParam = new ApiParameter("execBatchJob", mapParam);
if (!apiParam.check()) {
// パラメータ不正の場合、SOAPFault を返す
String errDetail = apiParam.getErrorDetail();
throw new AxisFault("Invalid parameter : " + errDetail);
}
String param = apiParam.getCgiParam();
if (param.charAt(0) == '&') {
param = param.substring(1);
}
// ジョブ情報をセットする
MessageContext context = MessageContext.getCurrentMessageContext();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String time = sdf.format(new Date());
JobInfo jobInfo = new JobInfo();
jobInfo.setSessionId("");
jobInfo.setIpAddr((String) context.getProperty(MessageContext.REMOTE_ADDR));
jobInfo.setMailAddr(mailAddress);
jobInfo.setTimeStamp(time);
jobInfo.setQueryFileName("");
jobInfo.setQueryFileSize("");
jobInfo.setSearchParam(param);
jobInfo.setTempName(tempFileName);
JobManager jobMgr = new JobManager();
try {
jobId = jobMgr.addJobInfo(jobInfo);
jobMgr.end();
} catch (SQLException ex) {
throw new AxisFault("System error! [code=100]");
}
return jobId;
}
Aggregations