use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestJsonWorkflowJob method testProperties.
public void testProperties() {
WorkflowJobBean wf = createWorkflow();
assertEquals("a", wf.getAppPath());
assertEquals("b", wf.getAppName());
assertEquals("c", wf.getId());
assertEquals("cc", wf.getConf());
assertEquals(WorkflowJob.Status.PREP, wf.getStatus());
assertEquals(JsonUtils.parseDateRfc822(CREATED_TIME), wf.getCreatedTime());
assertEquals(JsonUtils.parseDateRfc822(START_TIME), wf.getStartTime());
assertEquals(JsonUtils.parseDateRfc822(END_TIME), wf.getEndTime());
assertEquals("d", wf.getUser());
assertEquals("e", wf.getGroup());
assertEquals(2, wf.getRun());
assertEquals("cu", wf.getConsoleUrl());
assertEquals(0, wf.getActions().size());
wf.setActions(Arrays.asList((WorkflowActionBean) TestJsonWorkflowAction.createNode()));
assertEquals(1, wf.getActions().size());
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class WorkflowActionQueryExecutor method getList.
@Override
public List<WorkflowActionBean> getList(WorkflowActionQuery namedQuery, Object... parameters) throws JPAExecutorException {
JPAService jpaService = Services.get().get(JPAService.class);
EntityManager em = jpaService.getEntityManager();
Query query = getSelectQuery(namedQuery, em, parameters);
List<?> retList = (List<?>) jpaService.executeGetList(namedQuery.name(), query, em);
List<WorkflowActionBean> beanList = new ArrayList<WorkflowActionBean>();
if (retList != null) {
for (Object ret : retList) {
beanList.add(constructBean(namedQuery, ret));
}
}
return beanList;
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class WorkflowActionQueryExecutor method constructBean.
private WorkflowActionBean constructBean(WorkflowActionQuery namedQuery, Object ret) throws JPAExecutorException {
WorkflowActionBean bean;
Object[] arr;
switch(namedQuery) {
case GET_ACTION:
bean = (WorkflowActionBean) ret;
break;
case GET_ACTION_ID_TYPE_LASTCHECK:
bean = new WorkflowActionBean();
arr = (Object[]) ret;
bean.setId((String) arr[0]);
bean.setType((String) arr[1]);
bean.setLastCheckTime(DateUtils.toDate((Timestamp) arr[2]));
break;
case GET_ACTION_FAIL:
bean = new WorkflowActionBean();
arr = (Object[]) ret;
bean.setId((String) arr[0]);
bean.setJobId((String) arr[1]);
bean.setName((String) arr[2]);
bean.setStatusStr((String) arr[3]);
bean.setPending((Integer) arr[4]);
bean.setType((String) arr[5]);
bean.setLogToken((String) arr[6]);
bean.setTransition((String) arr[7]);
bean.setErrorInfo((String) arr[8], (String) arr[9]);
break;
case GET_ACTION_SIGNAL:
bean = new WorkflowActionBean();
arr = (Object[]) ret;
bean.setId((String) arr[0]);
bean.setJobId((String) arr[1]);
bean.setName((String) arr[2]);
bean.setStatusStr((String) arr[3]);
bean.setPending((Integer) arr[4]);
bean.setPendingAge(DateUtils.toDate((Timestamp) arr[5]));
bean.setType((String) arr[6]);
bean.setLogToken((String) arr[7]);
bean.setTransition((String) arr[8]);
bean.setErrorInfo((String) arr[9], (String) arr[10]);
bean.setExecutionPath((String) arr[11]);
bean.setSignalValue((String) arr[12]);
bean.setSlaXmlBlob((StringBlob) arr[13]);
bean.setExternalId((String) arr[14]);
break;
case GET_ACTION_CHECK:
bean = new WorkflowActionBean();
arr = (Object[]) ret;
bean.setId((String) arr[0]);
bean.setJobId((String) arr[1]);
bean.setName((String) arr[2]);
bean.setStatusStr((String) arr[3]);
bean.setPending((Integer) arr[4]);
bean.setPendingAge(DateUtils.toDate((Timestamp) arr[5]));
bean.setType((String) arr[6]);
bean.setLogToken((String) arr[7]);
bean.setTransition((String) arr[8]);
bean.setRetries((Integer) arr[9]);
bean.setUserRetryCount((Integer) arr[10]);
bean.setUserRetryMax((Integer) arr[11]);
bean.setUserRetryInterval((Integer) arr[12]);
bean.setTrackerUri((String) arr[13]);
bean.setStartTime(DateUtils.toDate((Timestamp) arr[14]));
bean.setEndTime(DateUtils.toDate((Timestamp) arr[15]));
bean.setLastCheckTime(DateUtils.toDate((Timestamp) arr[16]));
bean.setErrorInfo((String) arr[17], (String) arr[18]);
bean.setExternalId((String) arr[19]);
bean.setExternalStatus((String) arr[20]);
bean.setExternalChildIDsBlob((StringBlob) arr[21]);
bean.setConfBlob((StringBlob) arr[22]);
break;
case GET_ACTION_END:
bean = new WorkflowActionBean();
arr = (Object[]) ret;
bean.setId((String) arr[0]);
bean.setJobId((String) arr[1]);
bean.setName((String) arr[2]);
bean.setStatusStr((String) arr[3]);
bean.setPending((Integer) arr[4]);
bean.setPendingAge(DateUtils.toDate((Timestamp) arr[5]));
bean.setType((String) arr[6]);
bean.setLogToken((String) arr[7]);
bean.setTransition((String) arr[8]);
bean.setRetries((Integer) arr[9]);
bean.setTrackerUri((String) arr[10]);
bean.setUserRetryCount((Integer) arr[11]);
bean.setUserRetryMax((Integer) arr[12]);
bean.setUserRetryInterval((Integer) arr[13]);
bean.setStartTime(DateUtils.toDate((Timestamp) arr[14]));
bean.setEndTime(DateUtils.toDate((Timestamp) arr[15]));
bean.setErrorInfo((String) arr[16], (String) arr[17]);
bean.setExternalId((String) arr[18]);
bean.setExternalStatus((String) arr[19]);
bean.setExternalChildIDsBlob((StringBlob) arr[20]);
bean.setConfBlob((StringBlob) arr[21]);
bean.setDataBlob((StringBlob) arr[22]);
bean.setStatsBlob((StringBlob) arr[23]);
break;
case GET_ACTION_COMPLETED:
bean = new WorkflowActionBean();
arr = (Object[]) ret;
bean.setId((String) arr[0]);
bean.setJobId((String) arr[1]);
bean.setStatusStr((String) arr[2]);
bean.setType((String) arr[3]);
bean.setLogToken((String) arr[4]);
break;
case GET_RUNNING_ACTIONS:
bean = new WorkflowActionBean();
bean.setId((String) ret);
break;
case GET_PENDING_ACTIONS:
bean = new WorkflowActionBean();
arr = (Object[]) ret;
bean.setId((String) arr[0]);
bean.setJobId((String) arr[1]);
bean.setStatusStr((String) arr[2]);
bean.setType((String) arr[3]);
bean.setPendingAge(DateUtils.toDate((Timestamp) arr[4]));
break;
case GET_ACTIONS_FOR_WORKFLOW_RERUN:
bean = new WorkflowActionBean();
arr = (Object[]) ret;
bean.setId((String) arr[0]);
bean.setName((String) arr[1]);
bean.setStatusStr((String) arr[2]);
bean.setEndTime(DateUtils.toDate((Timestamp) arr[3]));
bean.setType((String) arr[4]);
break;
case GET_ACTION_FOR_SLA:
bean = new WorkflowActionBean();
arr = (Object[]) ret;
bean.setId((String) arr[0]);
bean.setStatusStr((String) arr[1]);
bean.setStartTime(DateUtils.toDate((Timestamp) arr[2]));
bean.setEndTime(DateUtils.toDate((Timestamp) arr[3]));
break;
default:
throw new JPAExecutorException(ErrorCode.E0603, "QueryExecutor cannot construct action bean for " + namedQuery.name());
}
return bean;
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class WorkflowActionQueryExecutor method getIfExist.
@Override
public WorkflowActionBean getIfExist(WorkflowActionQuery namedQuery, Object... parameters) throws JPAExecutorException {
JPAService jpaService = Services.get().get(JPAService.class);
EntityManager em = jpaService.getEntityManager();
Query query = getSelectQuery(namedQuery, em, parameters);
Object ret = jpaService.executeGet(namedQuery.name(), query, em);
if (ret == null) {
return null;
}
WorkflowActionBean bean = constructBean(namedQuery, ret);
return bean;
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class WorkflowActionSubsetGetJPAExecutor method execute.
/* (non-Javadoc)
* @see org.apache.oozie.executor.jpa.JPAExecutor#execute(javax.persistence.EntityManager)
*/
@Override
@SuppressWarnings("unchecked")
public List<WorkflowActionBean> execute(EntityManager em) throws JPAExecutorException {
List<WorkflowActionBean> actions;
List<WorkflowActionBean> actionList = new ArrayList<WorkflowActionBean>();
try {
Query q = em.createNamedQuery("GET_ACTIONS_FOR_WORKFLOW");
OpenJPAPersistence.cast(q);
q.setParameter("wfId", wfId);
q.setFirstResult(start - 1);
q.setMaxResults(length);
actions = q.getResultList();
} catch (Exception e) {
throw new JPAExecutorException(ErrorCode.E0605, "null", e);
}
return actions;
}
Aggregations