throw new GwtException(e.getMessage());
}
}
@Override
public JobModel getUpstreamJob(String jobId) throws GwtException {
JobBean jobBean=permissionGroupManager.getUpstreamJobBean(jobId);
JobModel jobModel=new JobModel();
jobModel.setCronExpression(jobBean.getJobDescriptor().getCronExpression());
jobModel.setDependencies(jobBean.getJobDescriptor().getDependencies());
jobModel.setDesc(jobBean.getJobDescriptor().getDesc());
jobModel.setGroupId(jobBean.getJobDescriptor().getGroupId());
jobModel.setId(jobBean.getJobDescriptor().getId());
String jobRunType=null;
if(jobBean.getJobDescriptor().getJobType()==JobRunType.MapReduce){
jobRunType=JobModel.MapReduce;
}else if(jobBean.getJobDescriptor().getJobType()==JobRunType.Shell){
jobRunType=JobModel.SHELL;
}else if(jobBean.getJobDescriptor().getJobType()==JobRunType.Hive){
jobRunType=JobModel.HIVE;
}
jobModel.setJobRunType(jobRunType);
String jobScheduleType=null;
if(jobBean.getJobDescriptor().getScheduleType()==JobScheduleType.Dependent){
jobScheduleType=JobModel.DEPEND_JOB;
}else if(jobBean.getJobDescriptor().getScheduleType()==JobScheduleType.Independent){
jobScheduleType=JobModel.INDEPEN_JOB;
}
jobModel.setJobScheduleType(jobScheduleType);
jobModel.setLocalProperties(jobBean.getJobDescriptor().getProperties());
jobModel.setName(jobBean.getJobDescriptor().getName());
jobModel.setOwner(jobBean.getJobDescriptor().getOwner());
String ownerName=userManager.findByUid(jobModel.getOwner()).getName();
if(ownerName==null || "".equals(ownerName.trim()) || "null".equals(ownerName)){
ownerName=jobModel.getOwner();
}
jobModel.setOwnerName(ownerName);
jobModel.setLocalResources(jobBean.getJobDescriptor().getResources());
jobModel.setAllProperties(jobBean.getHierarchyProperties().getAllProperties());
jobModel.setAllResources(jobBean.getHierarchyResources());
jobModel.setAuto(jobBean.getJobDescriptor().getAuto());
jobModel.setScript(jobBean.getJobDescriptor().getScript());
List<String> preList=new ArrayList<String>();
if(!jobBean.getJobDescriptor().getPreProcessers().isEmpty()){
for(Processer p:jobBean.getJobDescriptor().getPreProcessers()){
JSONObject o=new JSONObject();
o.put("id", p.getId());
o.put("config", p.getConfig());
preList.add(o.toString());
}
}
jobModel.setPreProcessers(preList);
List<String> postList=new ArrayList<String>();
if(!jobBean.getJobDescriptor().getPostProcessers().isEmpty()){
for(Processer p:jobBean.getJobDescriptor().getPostProcessers()){
JSONObject o=new JSONObject();
o.put("id", p.getId());
o.put("config", p.getConfig());
postList.add(o.toString());
}
}
jobModel.setPostProcessers(postList);
jobModel.setAdmin(permissionGroupManager.hasJobPermission(LoginUser.getUser().getUid(), jobId));
List<ZeusFollow> follows=followManager.findJobFollowers(jobId);
if(follows!=null){
List<String> followNames=new ArrayList<String>();
for(ZeusFollow zf:follows){
String name=userManager.findByUid(zf.getUid()).getName();
if(name==null || "".equals(name.trim())){
name=zf.getUid();
}
followNames.add(name);
}
jobModel.setFollows(followNames);
}
List<String> ladmins=permissionManager.getJobAdmins(jobId);
List<String> admins=new ArrayList<String>();
for(String s:ladmins){
String name=userManager.findByUid(s).getName();
if(name==null || "".equals(name.trim()) || "null".equals(name)){
name=s;
}
admins.add(name);
}
jobModel.setAdmins(admins);
List<String> owners=new ArrayList<String>();
owners.add(jobBean.getJobDescriptor().getOwner());
GroupBean parent=jobBean.getGroupBean();
while(parent!=null){
if(!owners.contains(parent.getGroupDescriptor().getOwner())){
owners.add(parent.getGroupDescriptor().getOwner());
}
parent=parent.getParentGroupBean();