Conflicts:
	src/main/java/haflow/dto/entity/Flow.java
	src/main/java/haflow/service/FlowService.java
	src/main/java/haflow/ui/controller/FlowController.java
	src/main/java/haflow/ui/controller/HomeController.java
	src/main/java/haflow/ui/helper/FlowHelper.java
	src/main/resources/hibernate.cfg.xml
	src/main/webapp/WEB-INF/views/logon.jsp
	src/main/webapp/WEB-INF/views/main.jsp
	src/main/webapp/style/haflow.main.css
This commit is contained in:
keyeqing 2013-10-09 15:08:29 +08:00
commit c3ffff9891
30 changed files with 2143 additions and 32 deletions

View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

View File

@ -8,6 +8,8 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@ -18,6 +20,7 @@ public class Flow {
private String name;
private Set<Node> nodes;
private Set<Edge> edges;
private MainUser user;
private Set<FlowRunHistory> exeHistory;
@Id
@ -66,5 +69,13 @@ public class Flow {
this.exeHistory = exeHistory;
}
@ManyToOne
@JoinColumn(name="mainuser_id",referencedColumnName="id")
public MainUser getUser() {
return user;
}
public void setUser(MainUser user) {
this.user = user;
}
}

View File

@ -0,0 +1,121 @@
package haflow.dto.entity;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "mainuser")
public class MainUser {
private int id;
private String name;
private String password;
private String email;
private int role;
private String path;
private double space;
private double usedspace;
private String realname;
private Set<Flow> flows;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name = "name", unique = true, nullable = false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "password", nullable = false)
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Column(name = "email", unique = true, nullable = false)
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Column(name = "role", nullable = false)
public int getRole() {
return role;
}
public void setRole(int role) {
this.role = role;
}
@Column(name = "path", nullable = false)
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
@Column(name = "space", nullable = false)
public double getSpace() {
return space;
}
public void setSpace(double space2) {
this.space = space2;
}
@Column(name = "usedspace")
public double getUsedspace() {
return usedspace;
}
public void setUsedspace(double d) {
this.usedspace = d;
}
@Column(name = "realname")
public String getRealname() {
return realname;
}
public void setRealname(String realname) {
this.realname = realname;
}
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
public Set<Flow> getFlows() {
return flows;
}
public void setFlows(Set<Flow> flows) {
this.flows = flows;
}
}

View File

@ -0,0 +1,37 @@
package haflow.module.util;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class Md5Util {
public static String getMd5Hex(String password){
MessageDigest md=null;
try {
md = MessageDigest.getInstance("MD5");
md.reset();
md.update(password.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
System.out.println("NoSuchAlgorithmException caught!");
System.exit(-1);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
byte[] rs=md.digest();
StringBuffer sb=new StringBuffer();
for(int i=0;i<rs.length;i++){
String tmp=Integer.toHexString(rs[i]&0xff);
if(tmp.length()==1)
sb.append("0");
sb.append(tmp);
}
return sb.toString();
}
}

View File

@ -1,7 +1,9 @@
package haflow.service;
import haflow.dto.entity.Edge;
import haflow.dto.entity.Flow;
import haflow.dto.entity.MainUser;
import haflow.dto.entity.Node;
import haflow.util.SessionHelper;
@ -30,10 +32,11 @@ public class FlowService {
}
public boolean saveFlow(UUID flowId, String name, Set<Node> nodes,
Set<Edge> edges) {
Set<Edge> edges, int userid) {
Session session = this.getSessionHelper().openSession();
Transaction transaction = session.beginTransaction();
try {
MainUser user = (MainUser) session.get(MainUser.class, userid);
Flow flow = (Flow) session.get(Flow.class, flowId);
if (flow == null) {
flow = new Flow();
@ -41,13 +44,14 @@ public class FlowService {
flow.setName(name);
flow.setNodes(new HashSet<Node>());
flow.setEdges(new HashSet<Edge>());
session.merge(flow);
flow.setUser(user);
}
flow.setName(name);
flow.getNodes().clear();
flow.getEdges().clear();
for (Node node : nodes) {
node.setFlow(flow);
session.merge(node);
@ -71,31 +75,50 @@ public class FlowService {
}
flow.getEdges().add(edge);
}
session.merge(flow);
transaction.commit();
session.close();
return true;
} catch (Exception e) {
e.printStackTrace();
transaction.rollback();
session.close();
return false;
} finally {
if (session != null)
session.close();
}
}
public boolean removeFlow(UUID flowId) {
public boolean removeFlow(UUID flowId,int userid) {
Session session = this.getSessionHelper().openSession();
Transaction transaction = session.beginTransaction();
Flow flow = (Flow) session.get(Flow.class, flowId);
if (flow == null) {
return false;
}
MainUser user=(MainUser) session.get(MainUser.class, userid);
try {
session.delete(flow);
for(Flow f:user.getFlows()){
if(f.getId().equals(flowId)){
user.getFlows().remove(f);
f.setUser(null);
session.delete(f);
transaction.commit();
session.close();
return true;
}
}
return false;
//Flow flow = (Flow) session.get(Flow.class, flowId);
// if (flow == null) {
// return false;
// }
// try {
// System.out.println("remove flow before");
// session.delete(flow);
// transaction.commit();
// session.close();
// return true;
} catch (Exception e) {
e.printStackTrace();
transaction.rollback();
@ -105,10 +128,10 @@ public class FlowService {
}
@SuppressWarnings("unchecked")
public List<Flow> getFlowList() {
public List<Flow> getFlowList(int userid) {
Session session = this.getSessionHelper().openSession();
try {
Query query = session.createQuery("from Flow flow");
Query query = session.createQuery("select f from Flow f join f.user u where u.id= "+userid);
List<Flow> flows = (List<Flow>) query.list();
session.close();
return flows;
@ -119,16 +142,27 @@ public class FlowService {
}
}
public Flow getFlow(UUID flowId) {
public Flow getFlow(UUID flowId,int userid) {
Session session = this.getSessionHelper().openSession();
try {
Flow flow = (Flow) session.get(Flow.class, flowId);
session.close();
MainUser user = (MainUser) session.get(MainUser.class, userid);
Set<Flow> flows = (Set<Flow>) user.getFlows();
for (Flow flow : flows) {
if (flow.getId().equals(flowId)) {
return flow;
}
}
return null;
//Flow flow = (Flow) session.get(Flow.class, flowId);
} catch (Exception e) {
e.printStackTrace();
session.close();
return null;
}finally{
if(session!=null)
session.close();
}
}
}

View File

@ -0,0 +1,251 @@
package haflow.service;
import java.util.List;
import haflow.dto.entity.Flow;
import haflow.dto.entity.MainUser;
import haflow.util.SessionHelper;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hsqldb.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class UserService {
private SessionHelper sessionHelper;
private SessionHelper getSessionHelper() {
return sessionHelper;
}
@Autowired
private void setSessionHelper(SessionHelper sessionHelper) {
this.sessionHelper = sessionHelper;
}
public boolean updateUserEmail(int userid,String email){
Session session=this.getSessionHelper().openSession();
Transaction transaction = session.beginTransaction();
MainUser user=(MainUser) session.get(MainUser.class, userid);
if (user == null)
return false;
try {
String oldemail=user.getEmail();
if(!email.equals(oldemail)){
org.hibernate.Query query=session.createQuery("from MainUser as u where u.email=?");
query.setString(0,email);
List<MainUser> list=query.list();
if(list!=null){
return false;
}
else{
user.setEmail(email);
}
session.merge(user);
transaction.commit();
}
return true;
} catch (HibernateException e) {
// TODO Auto-generated catch block
transaction.rollback();
e.printStackTrace();
return false;
}finally{
if(session!=null)
session.close();
}
}
public boolean updateUser(int userid,String password,int role,double space,double usedspace,String realname){
Session session=this.getSessionHelper().openSession();
Transaction transaction = session.beginTransaction();
MainUser user=(MainUser) session.get(MainUser.class, userid);
if (user == null)
return false;
try {
if(role>1)
role=user.getRole();
if(usedspace>space)
return false;
user.setPassword(password);
user.setRole(role);
user.setSpace(space);
user.setUsedspace(usedspace);
user.setRealname(realname);
session.merge(user);
transaction.commit();
return true;
} catch (HibernateException e) {
// TODO Auto-generated catch block
transaction.rollback();
e.printStackTrace();
return false;
}finally{
if(session!=null)
session.close();
}
}
public boolean deleteUser(int userid){
Session session = this.getSessionHelper().openSession();
Transaction transaction = session.beginTransaction();
MainUser user=(MainUser) session.get(MainUser.class, userid);
if (user == null)
return false;
try {
session.delete(user);
transaction.commit();
return true;
} catch (HibernateException e) {
// TODO Auto-generated catch block
transaction.rollback();
e.printStackTrace();
return false;
}finally{
if(session!=null)
session.close();
}
}
public List<MainUser> getAllUser(){
Session session=this.getSessionHelper().openSession();
try {
Query query=session.createQuery("from MainUser as mainUser where role=0");
List<MainUser> list=query.list();
session.close();
return list;
} catch (Exception e) {
System.out.println("error!!!!!!!");
// TODO Auto-generated catch block
session.close();
e.printStackTrace();
return null;
}
}
public MainUser getUser(int userid){
Session session = this.getSessionHelper().openSession();
Transaction transaction = session.beginTransaction();
try {
MainUser user=(MainUser) session.get(MainUser.class, userid);
if (user == null)
return null;
else
return user;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}finally{
if(session!=null)
session.close();
}
}
public boolean saveUser(String username, String password,String email, String mora){
int role=-1;
double space=0.0;
if(mora.equals("main")){
role=0;
space=5.0;
}
if(mora.equals("admin")){
role=1;
space=10.0;
}
if(role==-1)
return false;
Session session=this.getSessionHelper().openSession();
Transaction tran=session.beginTransaction();
try{
org.hibernate.Query query=session.createQuery("from MainUser as u where u.name=?");
query.setString(0,username);
List<MainUser> list=query.list();
org.hibernate.Query query1=session.createQuery("from MainUser as u where u.email=?");
query1.setString(0, email);
List<MainUser> list1=query1.list();
if(list.size()==0 && list1.size()==0){
System.out.println("success!");
MainUser user=new MainUser();
user.setName(username);
user.setPassword(password);
user.setEmail(email);
user.setRole(role);
user.setSpace(space);
user.setUsedspace(0.0);
user.setPath("/"+username);
session.save(user);
tran.commit();
session.close();
return true;
}
else{
System.out.println(list.get(0));
return false;
}
}catch(Exception e){
e.printStackTrace();
tran.rollback();
session.close();
return false;
}
}
public int validate(String username, String password, String mora) {
int role=-1;
if(mora=="admin")
role=1;
if(mora=="main")
role=0;
Session session = this.getSessionHelper().openSession();
try{
org.hibernate.Query query=session.createQuery("from MainUser as u where u.name=? and password=?" );
//" and role=?");
query.setString(0, username);
query.setString(1,password);
//query.setInteger(2, role);
List<MainUser> list=query.list();
session.close();
if(list.size()==1){
int realrol=list.get(0).getRole();
if(realrol>=role){
return list.get(0).getId();
}
else
return -1;
}
else
return -1;
}catch (Exception e){
//e.printStackTrace();
session.close();
return -1;
}
}
}

View File

@ -0,0 +1,85 @@
package haflow.ui.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import haflow.dto.entity.MainUser;
import haflow.module.util.Md5Util;
import haflow.ui.helper.UserHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
@Controller
public class AdminLogonController {
private UserHelper userHelper;
private UserHelper getUserHelper() {
return userHelper;
}
@Autowired
private void setLogonHelper(UserHelper logonHelper) {
this.userHelper = logonHelper;
}
@RequestMapping(value="/admin")
public ModelAndView admin(HttpServletRequest request){
if(UserHelper.isUserLogon(request,1))
return new ModelAndView("admin");
else
return new ModelAndView("logon");
}
@RequestMapping(value="/adminusermana")
public ModelAndView adminmana(HttpServletRequest request){
if(UserHelper.isUserLogon(request,1)){
List<MainUser> list=this.getUserHelper().getAllUser();
request.setAttribute("list", list);
return new ModelAndView("adminusermana");
}
else
return new ModelAndView("logon");
}
@RequestMapping(value="/adminhome")
public ModelAndView aminhome(HttpServletRequest request){
if(UserHelper.isUserLogon(request,1))
return new ModelAndView("adminhome");
else
return new ModelAndView("logon");
}
@RequestMapping(value="/adminlogon", method = RequestMethod.POST)
public String post(RedirectAttributes redirectAttributes,HttpServletRequest request,@RequestParam("username") String username,@RequestParam("password") String password) {
System.out.println("admin logon enter!!!");
System.out.println(username);
System.out.println(password);
if(username==""||password==""){
redirectAttributes.addFlashAttribute("message", "请填写用户名密码");
return "redirect:/";
}
password=Md5Util.getMd5Hex(password);
int userid=this.getUserHelper().validate(username, password, "admin");
if(userid!=-1){
System.out.println("admin logon");
request.getSession().setAttribute("username", username);
request.getSession().setAttribute("userid", userid);
request.getSession().setAttribute("scope", 1);
return "redirect:/adminhome";
}
else{
redirectAttributes.addFlashAttribute("message","用户名密码错误");
return "redirect:/";
}
}
}

View File

@ -1,3 +1,4 @@
<<<<<<< HEAD
package haflow.ui.controller;
import haflow.ui.helper.FlowHelper;
@ -66,3 +67,76 @@ public class FlowController {
}
}
=======
package haflow.ui.controller;
import haflow.ui.helper.FlowHelper;
import haflow.ui.helper.UserHelper;
import haflow.ui.model.SaveFlowModel;
import haflow.ui.model.FlowListModel;
import haflow.ui.model.FlowModel;
import haflow.ui.model.SaveFlowResultModel;
import haflow.ui.model.RemoveFlowModel;
import haflow.ui.model.RemoveFlowResultModel;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/flow")
public class FlowController {
private FlowHelper flowHelper;
private FlowHelper getFlowHelper() {
return flowHelper;
}
@Autowired
private void setFlowHelper(FlowHelper flowHelper) {
this.flowHelper = flowHelper;
}
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public FlowListModel get(HttpServletRequest request) {
return this.getFlowHelper().getFlowList((Integer)request.getSession().getAttribute("userid"));
}
@RequestMapping(value = "/{flowId}", method = RequestMethod.GET)
@ResponseBody
public FlowModel get(@PathVariable UUID flowId,HttpServletRequest request) {
return this.getFlowHelper().getFlow(flowId,(Integer)request.getSession().getAttribute("userid"));
}
@RequestMapping(value = "/{flowId}", method = RequestMethod.POST)
@ResponseBody
public SaveFlowResultModel post(@PathVariable UUID flowId,
@RequestBody SaveFlowModel model,HttpServletRequest request) {
return this.getFlowHelper().saveFlow(flowId, model,(Integer)request.getSession().getAttribute("userid"));
}
@RequestMapping(value = "/{flowId}", method = RequestMethod.PUT)
@ResponseBody
public SaveFlowResultModel put(@PathVariable UUID flowId,
@RequestBody SaveFlowModel model,HttpServletRequest request) {
return this.getFlowHelper().saveFlow(flowId, model,(Integer)request.getSession().getAttribute("userid"));
}
@RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE)
@ResponseBody
public RemoveFlowResultModel delete(@PathVariable UUID flowId,
@RequestBody RemoveFlowModel model,HttpServletRequest request) {
return this.getFlowHelper().removeFlow(flowId, model,(Integer)request.getSession().getAttribute("userid"));
}
}
>>>>>>> branch 'master' of https://github.com/justinliucs/haflow.git

View File

@ -1,3 +1,4 @@
<<<<<<< HEAD
package haflow.ui.controller;
import org.springframework.stereotype.Controller;
@ -27,3 +28,39 @@ public class HomeController {
return new ModelAndView("oozie");
}
}
=======
package haflow.ui.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class HomeController {
@RequestMapping("/")
public ModelAndView logon() {
return new ModelAndView("logon");
}
// @RequestMapping("/main")
// public ModelAndView main() {
// return new ModelAndView("main");
// }
//
// @RequestMapping("/admin")
// public ModelAndView admin() {
// return new ModelAndView("admin");
// }
@RequestMapping({ "/oozie" })
public ModelAndView oozie() {
return new ModelAndView("oozie");
}
}
>>>>>>> branch 'master' of https://github.com/justinliucs/haflow.git

View File

@ -0,0 +1,103 @@
package haflow.ui.controller;
import javax.servlet.http.HttpServletRequest;
import haflow.module.util.Md5Util;
import haflow.ui.helper.UserHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
@Controller
public class MainLogonController {
private UserHelper userHelper;
private UserHelper getUserHelper() {
return userHelper;
}
@Autowired
private void setLogonHelper(UserHelper userHelper) {
this.userHelper = userHelper;
}
@RequestMapping("registration")
public ModelAndView toRegister() {
return new ModelAndView("registration");
}
@RequestMapping(value = "/regiscommit", method = RequestMethod.POST)
public String register(RedirectAttributes redirectAttributes,
@RequestParam("username") String username,
@RequestParam("password") String password,
@RequestParam("email") String email,@RequestParam("mora") String mora) {
password=Md5Util.getMd5Hex(password);
if (this.getUserHelper().saveUser(username, password,email, mora)) {
//System.out.println("successful return main");
redirectAttributes.addFlashAttribute("message", "注册成功");
return "redirect:/";
} else {
redirectAttributes.addFlashAttribute("message", "用户名或邮箱已存在");
return "redirect:/registration";
}
}
@RequestMapping(value="/quit")
public String quit(RedirectAttributes redirectAttributes,HttpServletRequest request){
request.getSession().setAttribute("username",null);
request.getSession().setAttribute("userid",null);
request.getSession().setAttribute("scope", null);
return "redirect:/";
}
@RequestMapping(value = "/logon", method = RequestMethod.POST)
public String login(RedirectAttributes redirectAttributes,
HttpServletRequest request,
@RequestParam("username") String username,
@RequestParam("password") String password) {
if (username == "" || password == "") {
redirectAttributes.addFlashAttribute("message", "请填写用户名密码");
return "redirect:/";
}
password=Md5Util.getMd5Hex(password);
int userid=this.getUserHelper().validate(username, password, "main");
if (userid!=-1) {
//System.out.println("logon enter!!!!!!");
request.getSession().setAttribute("userid", userid);
request.getSession().setAttribute("username", username);
request.getSession().setAttribute("scope", 0);
return "redirect:/main";
} else {
//System.out.println("logon failed!!!!!!");
redirectAttributes.addFlashAttribute("message","用户名密码错误");
return "redirect:/";
}
}
@RequestMapping(value = "/main")
public ModelAndView post(HttpServletRequest request) {
//System.out.println("main enter!!!!!");
boolean flag = UserHelper.isUserLogon(request,0);
if(flag){
ModelAndView main=new ModelAndView("main");
main.addObject("username", request.getSession().getAttribute("username"));
return main;
}
else{
ModelAndView mav=new ModelAndView("logon");
mav.addObject("message","请填写用户名和密码!");
return mav;
}
}
}

View File

@ -2,6 +2,8 @@ package haflow.ui.controller;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import haflow.ui.helper.RunHelper;
import haflow.ui.model.RunFlowModel;
import haflow.ui.model.RunFlowResultModel;
@ -31,7 +33,7 @@ public class RunController {
@RequestMapping(value = "/{flowId}", method = RequestMethod.POST)
@ResponseBody
public RunFlowResultModel post(@PathVariable UUID flowId,
@RequestBody RunFlowModel model) {
return this.getRunHelper().runFlow(flowId, model);
@RequestBody RunFlowModel model,HttpServletRequest request) {
return this.getRunHelper().runFlow(flowId, model,(Integer)request.getSession().getAttribute("userid"));
}
}

View File

@ -0,0 +1,82 @@
package haflow.ui.controller;
import javax.servlet.http.HttpServletRequest;
import haflow.ui.helper.UserHelper;
import haflow.ui.model.SaveUserResultModel;
import haflow.ui.model.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
@Controller
@RequestMapping("/user")
public class UserController {
private UserHelper userHelper;
public UserHelper getUserHelper() {
return userHelper;
}
@Autowired
public void setUserHelper(UserHelper userHelper) {
this.userHelper = userHelper;
}
@RequestMapping(value = "/get/{userid}", method = RequestMethod.GET)
@ResponseBody
public UserModel get(@PathVariable int userid,HttpServletRequest request){
boolean flag=UserHelper.isUserLogon(request, 0);
if(flag){
return this.getUserHelper().getUser(userid);
}
return null;
}
@RequestMapping(value = "/update/{userid}", method = RequestMethod.POST)
@ResponseBody
public SaveUserResultModel post(@PathVariable int userid,@RequestBody UserModel user,HttpServletRequest request){
System.out.println(userid);
System.out.println("!!!!!!!!!!!success update");
boolean flag=UserHelper.isUserLogon(request, 0);
if(flag){
return this.getUserHelper().updateUser(userid,user);
}
return null;
}
@RequestMapping(value = "/remove/{userid}", method = RequestMethod.GET)
public String delete(@PathVariable int userid,HttpServletRequest request,RedirectAttributes redirectAttributes){
boolean flag=UserHelper.isUserLogon(request, 1);
if(flag){
if(this.getUserHelper().deleteUser(userid)){
redirectAttributes.addFlashAttribute("message", "success removed a user!");
return "redirect:/adminhome";
// mav.addObject("message", "success!");
// return mav;
}
}
redirectAttributes.addFlashAttribute("message", "failed removed a user!");
return "redirect:/adminhome";
// mav.addObject("message", "failed!");
// return mav;
}
}

View File

@ -1,3 +1,4 @@
<<<<<<< HEAD
package haflow.ui.helper;
import java.util.ArrayList;
@ -213,3 +214,220 @@ public class FlowHelper {
return result;
}
}
=======
package haflow.ui.helper;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import haflow.dto.entity.Edge;
import haflow.dto.entity.Flow;
import haflow.dto.entity.Node;
import haflow.dto.profile.NodeAppearance;
import haflow.dto.profile.NodeConfiguration;
import haflow.service.FlowService;
import haflow.service.NodeAppearanceService;
import haflow.service.NodeConfigurationService;
import haflow.ui.model.ConfigurationItemModel;
import haflow.ui.model.EdgeModel;
import haflow.ui.model.FlowBriefModel;
import haflow.ui.model.FlowListModel;
import haflow.ui.model.FlowModel;
import haflow.ui.model.SaveFlowModel;
import haflow.ui.model.SaveFlowResultModel;
import haflow.ui.model.NodeModel;
import haflow.ui.model.PositionModel;
import haflow.ui.model.RemoveFlowModel;
import haflow.ui.model.RemoveFlowResultModel;
@Component
public class FlowHelper {
private FlowService flowService;
private NodeAppearanceService nodeAppearanceService;
private NodeConfigurationService nodeConfigurationProfileService;
private FlowService getFlowService() {
return flowService;
}
@Autowired
private void setFlowService(FlowService flowService) {
this.flowService = flowService;
}
private NodeAppearanceService getNodeAppearanceService() {
return nodeAppearanceService;
}
@Autowired
private void setNodeAppearanceService(
NodeAppearanceService nodeAppearanceService) {
this.nodeAppearanceService = nodeAppearanceService;
}
private NodeConfigurationService getNodeConfigurationProfileService() {
return nodeConfigurationProfileService;
}
@Autowired
private void setNodeConfigurationProfileService(
NodeConfigurationService nodeConfigurationProfileService) {
this.nodeConfigurationProfileService = nodeConfigurationProfileService;
}
public FlowListModel getFlowList(int userid) {
List<Flow> flowList = this.getFlowService().getFlowList(userid);
FlowListModel flowListModel = new FlowListModel();
flowListModel.setFlows(new ArrayList<FlowBriefModel>());
for (Flow flow : flowList) {
FlowBriefModel flowBriefModel = new FlowBriefModel();
flowBriefModel.setId(flow.getId());
flowBriefModel.setName(flow.getName());
flowListModel.getFlows().add(flowBriefModel);
}
return flowListModel;
}
public FlowModel getFlow(UUID flowId,int userid) {
Flow flow = this.getFlowService().getFlow(flowId,userid);
if (flow == null) {
return null;
}
FlowModel flowModel = new FlowModel();
flowModel.setId(flow.getId());
flowModel.setName(flow.getName());
flowModel.setNodes(new HashSet<NodeModel>());
for (Node node : flow.getNodes()) {
NodeModel nodeModel = new NodeModel();
NodeAppearance nodeAppearanceProfile = this
.getNodeAppearanceService().getNodeAppearance(
node.getId());
List<NodeConfiguration> nodeConfigurationProfiles = this
.getNodeConfigurationProfileService()
.getNodeConfiguration(node.getId());
nodeModel.setFlowId(node.getFlow().getId());
nodeModel.setId(node.getId());
nodeModel.setModuleId(node.getModuleId());
nodeModel.setName(node.getName());
nodeModel.setPosition(new PositionModel());
nodeModel.getPosition().setLeft(
nodeAppearanceProfile.getPositionLeft());
nodeModel.getPosition().setTop(
nodeAppearanceProfile.getPositionTop());
nodeModel.setConfigurations(new HashSet<ConfigurationItemModel>());
for (NodeConfiguration profile : nodeConfigurationProfiles) {
ConfigurationItemModel model = new ConfigurationItemModel();
model.setKey(profile.getKey());
model.setValue(profile.getValue());
nodeModel.getConfigurations().add(model);
}
flowModel.getNodes().add(nodeModel);
}
flowModel.setEdges(new HashSet<EdgeModel>());
for (Edge edge : flow.getEdges()) {
EdgeModel edgeModel = new EdgeModel();
edgeModel.setFlowId(edge.getFlow().getId());
edgeModel.setId(edge.getId());
edgeModel.setSourceNodeId(edge.getSourceNode().getId());
edgeModel.setSourceEndpoint(edge.getSourceEndpoint());
edgeModel.setTargetNodeId(edge.getTargetNode().getId());
edgeModel.setTargetEndpoint(edge.getTargetEndpoint());
flowModel.getEdges().add(edgeModel);
}
return flowModel;
}
public SaveFlowResultModel saveFlow(UUID flowId, SaveFlowModel model,int userid) {
boolean success = this.doSaveFlow(flowId, model,userid);
SaveFlowResultModel result = new SaveFlowResultModel();
result.setFlowId(flowId);
result.setSuccess(success);
if (success) {
result.setMessage("success");
} else {
result.setMessage("fail");
}
return result;
}
public boolean doSaveFlow(UUID flowId, SaveFlowModel model,int userid) {
Set<Node> nodes = new HashSet<Node>();
Set<Edge> edges = new HashSet<Edge>();
for (NodeModel nodeModel : model.getNodes()) {
if (!nodeModel.getFlowId().equals(flowId)) {
return false;
}
Node node = new Node();
node.setFlow(null);
node.setId(nodeModel.getId());
node.setModuleId(nodeModel.getModuleId());
node.setName(nodeModel.getName());
this.getNodeAppearanceService().mergeNodeAppearance(
nodeModel.getId(), nodeModel.getPosition().getLeft(),
nodeModel.getPosition().getTop());
if (nodeModel.getConfigurations() != null) {
for (ConfigurationItemModel configurationItemModel : nodeModel
.getConfigurations()) {
this.getNodeConfigurationProfileService()
.mergeNodeConfiguration(nodeModel.getId(),
configurationItemModel.getKey(),
configurationItemModel.getValue());
}
}
nodes.add(node);
}
for (EdgeModel edgeModel : model.getEdges()) {
if (!edgeModel.getFlowId().equals(flowId)) {
return false;
}
Edge edge = new Edge();
edge.setFlow(null);
edge.setId(edgeModel.getId());
edge.setSourceNode(new Node());
edge.getSourceNode().setId(edgeModel.getSourceNodeId());
edge.setSourceEndpoint(edgeModel.getSourceEndpoint());
edge.setTargetNode(new Node());
edge.getTargetNode().setId(edgeModel.getTargetNodeId());
edge.setTargetEndpoint(edgeModel.getTargetEndpoint());
edges.add(edge);
}
boolean result = true;
result = result
&& this.getFlowService().saveFlow(flowId, model.getName(),
nodes, edges,userid);
result = result
&& this.getNodeAppearanceService()
.cleanUpOrphanNodeAppearance();
result = result
&& this.getNodeConfigurationProfileService()
.cleanUpOrphanNodeConfiguration();
return result;
}
public RemoveFlowResultModel removeFlow(UUID flowId, RemoveFlowModel model,int userid) {
boolean success = this.getFlowService().removeFlow(flowId,userid);
success = success
&& this.getNodeAppearanceService()
.cleanUpOrphanNodeAppearance();
success = success
&& this.getNodeConfigurationProfileService()
.cleanUpOrphanNodeConfiguration();
RemoveFlowResultModel result = new RemoveFlowResultModel();
result.setFlowId(flowId);
result.setSuccess(success);
if (success) {
result.setMessage("success");
} else {
result.setMessage("fail");
}
return result;
}
}
>>>>>>> branch 'master' of https://github.com/justinliucs/haflow.git

View File

@ -22,9 +22,9 @@ public class RunHelper {
this.flowExecuteService = flowExecuteService;
}
public RunFlowResultModel runFlow(UUID flowId, RunFlowModel model) {
public RunFlowResultModel runFlow(UUID flowId, RunFlowModel model,int userid) {
RunFlowResultModel result = this.getFlowExecuteService()
.runFlow(flowId);
.runFlow(flowId,userid);
return result;
}

View File

@ -0,0 +1,88 @@
package haflow.ui.helper;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import haflow.service.UserService;
import haflow.ui.model.SaveUserResultModel;
import haflow.ui.model.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import haflow.dto.entity.MainUser;
@Component
public class UserHelper {
private UserService userService;
private UserService getUserService() {
return userService;
}
@Autowired
private void setUserService(UserService userService) {
this.userService = userService;
}
public UserModel getUser(int userid){
MainUser user=this.getUserService().getUser(userid);
if(user==null)
return null;
UserModel userModel=new UserModel();
userModel.setId(user.getId());
userModel.setPassword(user.getPassword());
userModel.setEmail(user.getEmail());
userModel.setName(user.getName());
userModel.setRealname(user.getRealname());
userModel.setRole(user.getRole());
userModel.setSpace(user.getSpace());
userModel.setUsedspace(user.getUsedspace());
return userModel;
}
public SaveUserResultModel updateUser(int userid,UserModel user){
boolean success=true;
String email=user.getEmail();
success=this.getUserService().updateUserEmail(userid, email);
success=success&&this.getUserService().updateUser(userid, user.getPassword(), user.getRole(), user.getSpace(), user.getUsedspace(), user.getRealname());
SaveUserResultModel result=new SaveUserResultModel();
result.setSuccess(success);
result.setUserid(userid);
if(success){
result.setMessage("success");
}
else
result.setMessage("failed");
return result;
}
public boolean updateUserEmail(int userid,String email){
return this.getUserService().updateUserEmail(userid, email);
}
public boolean deleteUser(int userid){
return this.getUserService().deleteUser(userid);
}
public int validate(String username,String password,String mora){
return this.getUserService().validate(username,password,mora);
}
public boolean saveUser(String username,String password,String email,String mora){
return this.getUserService().saveUser(username,password,email,mora);
}
public List<MainUser> getAllUser(){
return this.getUserService().getAllUser();
}
public static boolean isUserLogon(HttpServletRequest request,int authscope) {
String username = (String) request.getSession()
.getAttribute("username");
Integer scope = (Integer) request.getSession()
.getAttribute("scope");
if (username != null&&scope!=null)
if(scope>=authscope)
return true;
return false;
}
}

View File

@ -0,0 +1,34 @@
package haflow.ui.model;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="saveUserResult")
public class SaveUserResultModel {
private boolean success;
private int userid;
private String message;
@XmlElement
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
@XmlElement
public int getUserid() {
return userid;
}
public void setUserid(int userid) {
this.userid = userid;
}
@XmlElement
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View File

@ -0,0 +1,92 @@
package haflow.ui.model;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "mainuser")
public class UserModel {
private int id;
private String name;
private String password;
private String email;
private int role;
//private String path;
private double space;
private double usedspace;
private String realname;
//private Set<FlowModel> flows;
@XmlElement
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@XmlElement
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlElement
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@XmlElement
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@XmlElement
public int getRole() {
return role;
}
public void setRole(int role) {
this.role = role;
}
/*@XmlElement
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}*/
@XmlElement
public double getSpace() {
return space;
}
public void setSpace(double space) {
this.space = space;
}
@XmlElement
public double getUsedspace() {
return usedspace;
}
public void setUsedspace(double usedspace) {
this.usedspace = usedspace;
}
@XmlElement
public String getRealname() {
return realname;
}
public void setRealname(String realname) {
this.realname = realname;
}
// @XmlElementWrapper(name = "flows")
// @XmlElement(name = "flow")
// public Set<FlowModel> getFlows() {
// return flows;
// }
// public void setFlows(Set<FlowModel> flows) {
// this.flows = flows;
// }
}

View File

@ -1,3 +1,4 @@
<<<<<<< HEAD
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
@ -23,4 +24,33 @@
<mapping class="haflow.dto.profile.NodeAppearance" />
<mapping class="haflow.dto.profile.NodeConfiguration" />
</session-factory>
=======
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver </property>
<property name="hibernate.connection.url"> jdbc:mysql://localhost:3306/haflow
</property>
<property name="hibernate.connection.username">root </property>
<property name="hibernate.connection.password">123456 </property>
<property name="hibernate.connection.pool.size">20 </property>
<property name="hibernate.show_sql">false </property>
<property name="format_sql">false</property>
<property name="Connection.useUnicode">true </property>
<property name="connection.characterEncoding">utf-8 </property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect </property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping class="haflow.dto.entity.Edge" />
<mapping class="haflow.dto.entity.Flow" />
<mapping class="haflow.dto.entity.Node" />
<mapping class="haflow.dto.entity.MainUser"/>
<mapping class="haflow.dto.entity.FlowRunHistory" />
<mapping class="haflow.dto.profile.NodeAppearance" />
<mapping class="haflow.dto.profile.NodeConfiguration" />
</session-factory>
>>>>>>> branch 'master' of https://github.com/justinliucs/haflow.git
</hibernate-configuration>

29
src/main/webapp/1.jsp Normal file
View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html >
<head>
<link rel="stylesheet" href="http://dojotoolkit.org/reference-guide/1.9/_static/js/dojo/../dijit/themes/claro/claro.css">
<script>dojoConfig = {parseOnLoad: true}</script>
<script src='http://dojotoolkit.org/reference-guide/1.9/_static/js/dojo/dojo.js'></script>
<script>
require(["dojo/parser", "dijit/layout/TabContainer", "dijit/layout/ContentPane"]);
</script>
</head>
<body class="claro">
<div style="width: 350px; height: 300px">
<div data-dojo-type="dijit/layout/TabContainer" style="width: 100%; height: 100%;">
<div data-dojo-type="dijit/layout/ContentPane" title="My first tab" data-dojo-props="selected:true">
Lorem ipsum and all around...
</div>
<div data-dojo-type="dijit/layout/ContentPane" title="My second tab">
Lorem ipsum and all around - second...
</div>
<div data-dojo-type="dijit/layout/ContentPane" title="My last tab" data-dojo-props="closable:true">
Lorem ipsum and all around - last...
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,79 @@
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
String username=request.getSession().getAttribute("username").toString();
boolean flag;
Object message=request.getAttribute("message");
if(request.getAttribute("message")!=null){
flag=true;
}
else{
System.out.println("fa");
flag=false;
}
%>
<html >
<head>
<link rel="stylesheet"
href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.0/dijit/themes/claro/claro.css">
<style type="text/css">
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow:hidden;
}
#borderContainer {
width: 100%;
height: 100%;
}
</style>
<script>dojoConfig = {parseOnLoad: true}</script>
<script src='http://dojotoolkit.org/reference-guide/1.9/_static/js/dojo/dojo.js'></script>
<script>
require(["dojo/parser", "dijit/layout/TabContainer", "dijit/layout/ContentPane","dijit/MenuBar","dijit/layout/BorderContainer"]);
var flag=<%=flag%>
if(flag){
var message="<%=message%>"
alert(message);
}
</script>
</head>
<body class="claro">
<div data-dojo-type="dijit/layout/BorderContainer"
data-dojo-props="design:'sidebar', gutters:true, liveSplitters:true"
id="borderContainer">
<div data-dojo-type="dijit/MenuBar"
data-dojo-props="region:'top', splitter:false">
<div data-dojo-type="dijit/layout/ContentPane" style="float: left">
<h2>Haflow Background</h2>
</div>
<div data-dojo-type="dijit/layout/ContentPane" style="float: right">
<h5>
hello<font color=red><%=username %></font> | <a href="quit">quit</a>
</h5>
</div>
</div>
<div data-dojo-type="dijit/layout/TabContainer"
data-dojo-props="region:'center', tabStrip:false">
<div data-dojo-type="dijit/layout/ContentPane" title="Module List"
href="admin"></div>
<div data-dojo-type="dijit/layout/ContentPane" title="User List"
href="adminusermana"></div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,70 @@
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
String username=request.getSession().getAttribute("username").toString();
%>
<html >
<head>
<link rel="stylesheet"
href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.0/dijit/themes/claro/claro.css">
<style type="text/css">
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow:hidden;
}
#borderContainer {
width: 100%;
height: 100%;
}
</style>
<script>dojoConfig = {parseOnLoad: true}</script>
<script src='http://dojotoolkit.org/reference-guide/1.9/_static/js/dojo/dojo.js'></script>
<script>
require(["dojo/parser", "dijit/layout/TabContainer", "dijit/layout/ContentPane","dijit/layout/BorderContainer"]);
</script>
</head>
<body class="claro">
<div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'sidebar', gutters:true, liveSplitters:true" id="borderContainer">
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="splitter:true, region:'leading'" style="width: 100px;">
<h2>Haflow</h2>
<h2>Background</h2>
<h5>hello <%=username %></h5>
</div>
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="splitter:true, region:'center'">
<div data-dojo-type="dijit/layout/TabContainer" style="width: 100%; height: 100%;">
<div data-dojo-type="dijit/layout/ContentPane" title="Module List" href="admin">
</div>
<div data-dojo-type="dijit/layout/ContentPane" title="User List" href="adminusermana">
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,109 @@
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
String username=request.getSession().getAttribute("username").toString();
%>
<html >
<head>
<link rel="stylesheet"
href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.0/dijit/themes/claro/claro.css">
<style type="text/css">
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow:hidden;
}
#borderContainer {
width: 100%;
height: 100%;
}
</style>
<script>dojoConfig = {parseOnLoad: true}</script>
<script src='http://dojotoolkit.org/reference-guide/1.9/_static/js/dojo/dojo.js'></script>
<script>
require(["dojo/parser", "dijit/layout/TabContainer", "dijit/layout/ContentPane","dijit/MenuBar","dijit/layout/BorderContainer"]);
</script>
</head>
<body class="claro">
<div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'sidebar', gutters:true, liveSplitters:true" id="borderContainer">
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top', splitter:false">
<h2>Haflow Background</h2>
<h5>hello <%=username %></h5>
</div>
<div data-dojo-type="dijit/layout/TabContainer" data-dojo-props="region:'center', tabStrip:false">
<div data-dojo-type="dijit/layout/ContentPane" title="Module List" href="admin">
</div>
<div data-dojo-type="dijit/layout/ContentPane" title="User List" href="adminusermana">
</div>
</div>
</div>
<div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'sidebar', gutters:true, liveSplitters:true" id="borderContainer">
<div data-dojo-type="dijit/MenuBar" data-dojo-props="region:'top', splitter:false">
<div data-dojo-type="dijit/layout/ContentPane" style="float:left"><h2>Haflow Background</h2></div>
<div data-dojo-type="dijit/layout/ContentPane" style="float:right"><h5>hello<font color=red><%=username %></font> | <a href="quit">quit</a></h5>
</div>
</div>
</div>
<div data-dojo-type="dijit/layout/TabContainer" data-dojo-props="region:'center', tabStrip:false">
<div data-dojo-type="dijit/layout/ContentPane" title="Module List" href="admin">
</div>
<div data-dojo-type="dijit/layout/ContentPane" title="User List" href="adminusermana">
</div>
</div>
<%-- <div data-dojo-type="dijit/MenuBar" data-dojo-props="region:'top'" style="width: 100px;">
<div data-dojo-type="dijit/layout/ContentPane" style="float:left">Haflow Background</div>
<div data-dojo-type="dijit/layout/ContentPane" >hello <%=username %></div>
</div>
<div data-dojo-type="dijit/layout/TabContainer" style="width: 100%;">
<div data-dojo-type="dijit/layout/ContentPane" title="Module List" href="admin">
</div>
<div data-dojo-type="dijit/layout/ContentPane" title="User List" href="adminusermana">
</div>
</div> --%>
</body>
</html>

View File

@ -0,0 +1,63 @@
<%@page import="haflow.dto.entity.MainUser"%>
<%@page import="haflow.ui.helper.UserHelper"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>HA Flow UserManagement</title>
<link rel="stylesheet" href="<%=basePath%>/style/site.css">
<script type="text/javascript" src="<%=basePath%>script/adminusermana.js"></script>
<body>
<h1>Haflow Administration</h1>
<h2>User List</h2>
<table id="userList">
<tr>
<th>User Id</th>
<th>Name</th>
<th>Role</th>
<th>Space</th>
<th>UsedSpace</th>
<th>Operation</th>
<th>Operation</th>
</tr>
<% if(request.getAttribute("list")!=null){
java.util.List<MainUser> list=(java.util.List<MainUser>)request.getAttribute("list");
if(list!=null){
for(MainUser user:list){
%><tr>
<td id="id"><%=user.getId()%></td>
<td><%=user.getName()%></td>
<td><% System.out.print(user.getRole());
if(user.getRole()==0) out.print("user");
if(user.getRole()==1) out.print("admin");
%></td>
<td><%=user.getSpace() %></td>
<td><%=user.getUsedspace() %></td>
<td><a
href="user/remove/<%=user.getId()%>" onclick="return confirm('确认删除')">Remove</a></td>
<td><a
href="javascript:void(0)" onclick="return openEdit(this);" style="color:blue">Edit</a></td>
</tr>
<%
}
}
}
%>
</table>
</body>
</html>

View File

@ -1,3 +1,4 @@
<<<<<<< HEAD
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%
@ -41,3 +42,60 @@
</div>
</body>
</html>
=======
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="<%=basePath%>script/logon.js"></script>
<link rel="stylesheet" href="<%=basePath%>/style/index.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Haflow Logon</title>
</head>
<body>
<div class="wrapper">
<div class="title">
<h1>大数据分析服务平台</h1>
</div>
<div class="content">
<div class="left">
<img src="<%=basePath%>/images/logon.png" />
</div>
<div class="right">
<!-- <h2>登录</h2> -->
<form id="form1" name="form1" action="" method="post">
<div class="field">
<span style="float: left; width: 80px;">用户名:</span><input type="text" id="username" name="username" />
<span id="error_username"></span>
</div><br/>
<div class="field">
<span style="float: left; width: 80px;">密码:</span><input type="password" id="password" name="password" />
<span id="error_password"></span>
</div><br/>
<div><span id="errorSpan"><%if(request.getAttribute("message")!=null) out.println(request.getAttribute("message")); %></span></div>
<div>
<button style="width: 70px;height: 35px; font-family:Arial;font-size:14px;font-weight:bold;color:#333333;" type="submit" name="main-log" onclick="fun()">登录</button>
&nbsp;&nbsp;
<button style="width: 120px;height: 35px; font-family:Arial;font-size:14px;font-weight:normal;color:#333333;" type="button" name="admin-log" onclick="fun1();">管理员登录</button>
</div>
<div class="field">
<span style="float: left; width: 120px;">还没有账户?</span><a href="registration">立即注册</a>
</div>
</form>
</div>
<div class="clear"></div>
</div>
</div>
</body>
</html>
>>>>>>> branch 'master' of https://github.com/justinliucs/haflow.git

View File

@ -1,3 +1,4 @@
<<<<<<< HEAD
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
@ -36,4 +37,56 @@
<body class="claro">
<input type="hidden" value="<%=basePath%>" id="basePath" />
</body>
=======
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
String username=request.getSession().getAttribute("username").toString();
Object userid=request.getSession().getAttribute("userid");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Haflow - a big data analysis service platform!</title>
<link rel="stylesheet"
href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.0/dijit/themes/claro/claro.css">
<link rel="stylesheet"
href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.0/dojox/layout/resources/ScrollPane.css">
<link rel="stylesheet" href="<%=basePath%>/style/haflow.css">
<link rel="stylesheet" href="<%=basePath%>/style/haflow.ui.css">
<link rel="stylesheet" href="<%=basePath%>/style/haflow.main.css">
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script type="text/javascript"
src="script/jsPlumb/jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript"
src="script/jsPlumb/jquery.jsPlumb-1.4.1-all.js"></script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/dojo/1.9.0/dojo/dojo.js"></script>
<script type="text/javascript" src="<%=basePath%>/script/haflow.js"></script>
<script type="text/javascript" src="<%=basePath%>/script/haflow.ui.js"></script>
<script type="text/javascript" src="<%=basePath%>/script/haflow.main.js"></script>
</head>
<body class="claro">
<script type="text/javascript">
var username="<%=username%>";
var userid=<%=userid%>;
</script>
<input type="hidden" value="<%=basePath%>" id="basePath" />
</body>
>>>>>>> branch 'master' of https://github.com/justinliucs/haflow.git
</html>

View File

@ -0,0 +1,70 @@
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="<%=basePath%>/style/index.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Haflow Registration</title>
</head>
<body>
<div class="wrapper">
<div class="title">
<h1>大数据分析服务平台</h1>
</div>
<div class="content">
<div class="left">
<img src="<%=basePath%>/images/logon.png" />
</div>
<div class="right">
<!-- <h2>登录</h2> -->
<form id="form2" action="regiscommit" method="post">
<div class="field">
<span style="float: left; width: 80px;">用户名:</span><input type="text" name="username" onblur="" />
<span id="username_err" ></span>
</div><br/>
<div class="field">
<span style="float: left; width: 80px;">邮箱:</span><input type="text" name="email" />
<span id="email_err" ></span>
</div><br/>
<div class="field">
<span style="float: left; width: 80px;">输入密码:</span><input type="password" name="password" />
<span id="password_err" ></span>
</div><br/>
<div class="field">
<span style="float: left; width: 80px;">确认密码:</span><input type="password" name="password1" onblur="checkPass()"/>
<span id="password1_err" ></span>
</div><br/>
<div><span id="errorSpan"><%if(request.getAttribute("message")!=null) out.println(request.getAttribute("message")); %></span></div>
<div>
<button style="width: 120px;height: 35px; font-family:Arial;font-size:14px;font-weight:bold;color:#333333;" type="button" name="main-log" onclick="fun3()">立即注册</button>
&nbsp;&nbsp;
<button style="width: 120px;height: 35px; font-family:Arial;font-size:14px;font-weight:normal;color:#333333;" type="button" name="admin-log" onclick="fun4()">管理员注册</button>
</div>
<div class="field">
<span style="float: left; width: 220px;">已有账户?<a href="/haflow">立即登陆</a></span>
</div>
<input id="mora" type="hidden" name="mora" />
</form>
</div>
<div class="clear"></div>
</div>
</div>
</body>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script type="text/javascript" src="<%=basePath%>script/registration.js"></script>
</html>

View File

@ -0,0 +1,15 @@
function openEdit(obj){
var row = obj.parentNode.parentNode;
var userId = document.getElementById("userList").rows[row.rowIndex]
.cells[0].innerHTML;
// window.open("user/get/"+scriptId,"_blank","width=400,height=300,toolbar=no,scrollbars");
}
function openDel(obj){
var row = obj.parentNode.parentNode;
var scriptId = document.getElementById("userList").rows[row.rowIndex]
.cells[0].innerHTML;
window.open("user/remove/"+scriptId,"_blank","width=400,height=300,toolbar=no,scrollbars");
}

View File

@ -0,0 +1,50 @@
function fun(){
if(checkField()==true)
userlogon();
}
function fun1(){
if(checkField()==true)
adminlogon();
}
function userlogon()
{
document.getElementById("form1").action="logon";
document.getElementById("form1").submit();
}
function adminlogon()
{
document.getElementById("form1").action="adminlogon";
document.getElementById("form1").submit();
}
function checkField(){
var usernameValue = document.getElementById("username").value;
var passwordValue = document.getElementById("password").value;
usernameValue = usernameValue.replace(/\s/gi,"");
passwordValue = passwordValue.replace(/\s/gi,"");
if(usernameValue !== "" && passwordValue !== ""){
return true;
}else if(usernameValue == "" && passwordValue == ""){
document.getElementById("errorSpan").innerHTML="";
document.getElementById("error_username").innerHTML = "用户名不能为空!";
document.getElementById("error_password").innerHTML = "密码不能为空!";
return false ;
}else if(usernameValue !== "" && passwordValue == ""){
document.getElementById("errorSpan").innerHTML="";
document.getElementById("password").focus() ;
document.getElementById("error_username").innerHTML = "";
document.getElementById("error_password").innerHTML = "密码不能为空!";
return false ;
}else if(passwordValue !== "" && usernameValue == ""){
document.getElementById("errorSpan").innerHTML="";
document.getElementById("username").focus() ;
document.getElementById("error_password").innerHTML = "";
document.getElementById("error_username").innerHTML = "用户名不能为空!";
return false ;
}
}

View File

@ -0,0 +1,125 @@
function fun3(){
if(checkAll()&&RePass()){
document.getElementById("mora").value = "main";
document.getElementById("form2").submit();
}
}
function fun4(){
if(checkAll()&&RePass()){
document.getElementById("mora").value= "admin";
document.getElementById("form2").submit();
}
}
function checkAll(){
if(checkPass()){
if(form_validation('username')&form_validation('email')&form_validation('password'))
return true;
else
return false;
}
else
return false;
}
function RePass(){
var retype_pwd = document.getElementsByName('password1')[0].value;
var input_pwd = document.getElementsByName('password')[0].value;
if(retype_pwd==input_pwd){
return true;
}
else{
document.getElementById("password1_err").innerHTML="两次密码不一致!";
return false;
}
}
//check null
function checkPass() {
var null_flag=0;
var user_name = document.getElementsByName('username')[0].value;
var eml_msg=document.getElementsByName("email")[0].value;
var retype_pwd = document.getElementsByName('password1')[0].value;
var input_pwd = document.getElementsByName('password')[0].value;
if(user_name==""){
document.getElementById("username_err").innerHTML="用户名不能为空!";
document.getElementsByName('username')[0].value="";
document.getElementsByName('username')[0].style.border="1px solid red";
null_flag=1;}
if(eml_msg==""){
document.getElementById("email_err").innerHTML="邮箱不能为空!";
document.getElementsByName('email')[0].value="";
document.getElementsByName('email')[0].style.border="1px solid red";
null_flag=1;}
if(input_pwd==""){
document.getElementById("password_err").innerHTML="密码不能为空!";
document.getElementsByName('password')[0].value="";
document.getElementsByName('password')[0].style.border="1px solid red";
null_flag=1;}
if(retype_pwd==""){
document.getElementById("password1_err").innerHTML="密码不能为空!";
document.getElementsByName('password1')[0].value="";
document.getElementsByName('password1')[0].style.border="1px solid red";
null_flag=1;
}
if((null_flag==0)) return true;
else return false;
}
function clean() {
document.getElementsByName('username')[0].value="";
document.getElementsByName('password')[0].value="";
document.getElementsByName('email')[0].value="";
document.getElementsByName('password1')[0].value="";
}
//check form
function form_validation(name) {
var input_value = document.getElementsByName(name)[0].value;
var regx=null;
var err=null;
if(name=="username"){
regx=/^[a-z0-9_-]{3,8}$/;
err="3-8位数字或字母";
}
if(name=="password"){
regx=/^[a-z0-9_-]{4,18}$/;
err="4-18位数字或字母";
}
if (name == "email") {
regx = /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/;
err = "请填写有效的邮箱地址!";
}
if(!regx.test(input_value)){
var errmsg=name+"_err";
document.getElementById(errmsg).innerHTML = err;
document.getElementsByName(name)[0].value="";
document.getElementsByName(name)[0].style.border="1px solid red";
return false;
}
else
{
return true;
}
}

View File

@ -1,3 +1,4 @@
<<<<<<< HEAD
@CHARSET "UTF-8";
.node {
@ -77,4 +78,91 @@
path {
cursor: pointer;
=======
@CHARSET "UTF-8";
.dijitDisabled.dijitButtonDisabled .dijitButtonNode {
border: none;
background-color: transparent;
}
.node {
width: 8em;
padding: 1em;
position: absolute;
z-index: 4;
border-radius: 1em;
box-shadow: 2px 2px 19px #e0e0e0;
-o-box-shadow: 2px 2px 19px #e0e0e0;
-webkit-box-shadow: 2px 2px 19px #e0e0e0;
-moz-box-shadow: 2px 2px 19px #e0e0e0;
-moz-border-radius: 0.5em;
border-radius: 0.5em;
opacity: 0.8;
filter: alpha(opacity-80);
cursor: move;
border: 2px solid #346789;
}
.module {
margin-top: 10px;
margin-bottom: 10px;
margin-left: auto;
margin-right: auto;
width: 8em;
padding: 1em;
z-index: 4;
border-radius: 1em;
box-shadow: 2px 2px 19px #e0e0e0;
-o-box-shadow: 2px 2px 19px #e0e0e0;
-webkit-box-shadow: 2px 2px 19px #e0e0e0;
-moz-box-shadow: 2px 2px 19px #e0e0e0;
-moz-border-radius: 0.5em;
border-radius: 0.5em;
opacity: 0.8;
filter: alpha(opacity-80);
cursor: move;
border: 2px solid #346789;
}
.flowcontainer {
position: relative;
width: 2000px;
height: 1500px;
}
.configuration {
margin: 3px;
}
.configuration-content {
margin-bottom: 5px;
}
.center {
margin-left: auto;
margin-right: auto;
}
}
._jsPlumb_endpoint {
z-index: 9;
}
._jsPlumb_overlay {
z-index: 4;
}
._jsPlumb_endpoint_anchor_ {
z-index: 9;
}
.dragHover {
border: 1px dotted red;
}
path {
cursor: pointer;
>>>>>>> branch 'master' of https://github.com/justinliucs/haflow.git
}