Skip to content

Commit

Permalink
Create search elements on controller
Browse files Browse the repository at this point in the history
Create sckelet for Task and Document
TODO:
DOCUMENT MANIPULATION
DOCUMENT FILE MANIPULATION
TASK MANIPULATION
SHOW CONTEOLLED TASK FOR USER
SHOW USERS TASK
STOREHAUSE MANIPULATION
GOOD PRODUCTION AND SERVICE
  • Loading branch information
FairWindCo committed Oct 14, 2015
1 parent cfb520f commit 8aaa625
Show file tree
Hide file tree
Showing 17 changed files with 904 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ua.pp.fairwind.favorid.internalDB.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.security.access.annotation.Secured;
Expand All @@ -10,12 +11,14 @@
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import ua.pp.fairwind.favorid.internalDB.jgrid.JGridRowsResponse;
import ua.pp.fairwind.favorid.internalDB.jgrid.JSComboExpenseResp;
import ua.pp.fairwind.favorid.internalDB.model.directories.ContactType;
import ua.pp.fairwind.favorid.internalDB.repository.ContactTypeRepository;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


/**
Expand Down Expand Up @@ -125,4 +128,43 @@ public void editor(@RequestParam String oper,ContactType contactType,BindingResu
}
}

@Transactional(readOnly = true)
@RequestMapping(value = "/showList", method = RequestMethod.GET)
@ResponseBody
public Object simpleClientList(@RequestParam(required = false) Integer page_num, @RequestParam(required = false) Integer per_page,@RequestParam(value = "pkey_val[]",required = false) String pkey,@RequestParam(value = "q_word[]",required = false) String[] qword,@RequestParam long firmID) {
// Retrieve all persons by delegating the call to PersonService
//Sort sort= FormSort.formSortFromSortDescription(orderby);
Sort sort=new Sort(Sort.Direction.ASC,"surname");
PageRequest pager=null;
if(page_num!=null && per_page!=null) {
pager = new PageRequest(page_num - 1, per_page, sort);
}
if(pager!=null) {
Page<ContactType> page;
if (qword != null && qword.length > 0) {
page = repositoryContactType.findByNameContains(qword[0], pager);
} else {
page = repositoryContactType.findAll(pager);
}
return new JSComboExpenseResp<>(page);
} else {
if(pkey!=null && !pkey.isEmpty()){
Long key=Long.valueOf(pkey);
ContactType ft=null;
if(key!=null) {
ft = repositoryContactType.findOne(key);
}
return ft;
} else {
List<ContactType> page;
if (qword != null && qword.length > 0) {
page = repositoryContactType.findByNameContains(qword[0],sort);
} else {
page = repositoryContactType.findAll(sort);
}
return new JSComboExpenseResp<>(page);
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ua.pp.fairwind.favorid.internalDB.controllers;

/**
* Created by Ñåðãåé on 14.10.2015.
*/
public class DocumentController {
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ua.pp.fairwind.favorid.internalDB.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.security.access.annotation.Secured;
Expand All @@ -13,12 +14,14 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import ua.pp.fairwind.favorid.internalDB.jgrid.JGridRowsResponse;
import ua.pp.fairwind.favorid.internalDB.jgrid.JSComboExpenseResp;
import ua.pp.fairwind.favorid.internalDB.model.directories.DocumentType;
import ua.pp.fairwind.favorid.internalDB.repository.DocumentTypeRepository;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


/**
Expand Down Expand Up @@ -118,4 +121,43 @@ public void editor(@RequestParam String oper,DocumentType documentType,BindingRe
}
}

@Transactional(readOnly = true)
@RequestMapping(value = "/showList", method = RequestMethod.GET)
@ResponseBody
public Object simpleClientList(@RequestParam(required = false) Integer page_num, @RequestParam(required = false) Integer per_page,@RequestParam(value = "pkey_val[]",required = false) String pkey,@RequestParam(value = "q_word[]",required = false) String[] qword,@RequestParam long firmID) {
// Retrieve all persons by delegating the call to PersonService
//Sort sort= FormSort.formSortFromSortDescription(orderby);
Sort sort=new Sort(Sort.Direction.ASC,"surname");
PageRequest pager=null;
if(page_num!=null && per_page!=null) {
pager = new PageRequest(page_num - 1, per_page, sort);
}
if(pager!=null) {
Page<DocumentType> page;
if (qword != null && qword.length > 0) {
page = repositoryDocumentType.findByNameContains(qword[0], pager);
} else {
page = repositoryDocumentType.findAll(pager);
}
return new JSComboExpenseResp<>(page);
} else {
if(pkey!=null && !pkey.isEmpty()){
Long key=Long.valueOf(pkey);
DocumentType ft=null;
if(key!=null) {
ft = repositoryDocumentType.findOne(key);
}
return ft;
} else {
List<DocumentType> page;
if (qword != null && qword.length > 0) {
page = repositoryDocumentType.findByNameContains(qword[0],sort);
} else {
page = repositoryDocumentType.findAll(sort);
}
return new JSComboExpenseResp<>(page);
}
}
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ua.pp.fairwind.favorid.internalDB.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.security.access.annotation.Secured;
Expand All @@ -13,12 +14,14 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import ua.pp.fairwind.favorid.internalDB.jgrid.JGridRowsResponse;
import ua.pp.fairwind.favorid.internalDB.jgrid.JSComboExpenseResp;
import ua.pp.fairwind.favorid.internalDB.model.directories.Position;
import ua.pp.fairwind.favorid.internalDB.repository.PositionRepository;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


/**
Expand Down Expand Up @@ -117,4 +120,44 @@ public void editor(@RequestParam String oper,Position position,BindingResult res
}
}

@Transactional(readOnly = true)
@RequestMapping(value = "/showList", method = RequestMethod.GET)
@ResponseBody
public Object simpleClientList(@RequestParam(required = false) Integer page_num, @RequestParam(required = false) Integer per_page,@RequestParam(value = "pkey_val[]",required = false) String pkey,@RequestParam(value = "q_word[]",required = false) String[] qword,@RequestParam long firmID) {
// Retrieve all persons by delegating the call to PersonService
//Sort sort= FormSort.formSortFromSortDescription(orderby);
Sort sort=new Sort(Sort.Direction.ASC,"surname");
PageRequest pager=null;
if(page_num!=null && per_page!=null) {
pager = new PageRequest(page_num - 1, per_page, sort);
}
if(pager!=null) {
Page<Position> page;
if (qword != null && qword.length > 0) {
page = repositoryPosition.findByNameContains(qword[0], pager);
} else {
page = repositoryPosition.findAll(pager);
}
return new JSComboExpenseResp<>(page);
} else {
if(pkey!=null && !pkey.isEmpty()){
Long key=Long.valueOf(pkey);
Position ft=null;
if(key!=null) {
ft = repositoryPosition.findOne(key);
}
return ft;
} else {
List<Position> page;
if (qword != null && qword.length > 0) {
page = repositoryPosition.findByNameContains(qword[0],sort);
} else {
page = repositoryPosition.findAll(sort);
}
return new JSComboExpenseResp<>(page);
}
}
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ua.pp.fairwind.favorid.internalDB.controllers;

/**
* Created by Ñåðãåé on 14.10.2015.
*/
public class TaskController {
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ua.pp.fairwind.favorid.internalDB.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.security.access.annotation.Secured;
Expand All @@ -13,12 +14,15 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import ua.pp.fairwind.favorid.internalDB.jgrid.JGridRowsResponse;
import ua.pp.fairwind.favorid.internalDB.jgrid.JSComboExpenseResp;
import ua.pp.fairwind.favorid.internalDB.model.directories.Position;
import ua.pp.fairwind.favorid.internalDB.model.directories.TaskType;
import ua.pp.fairwind.favorid.internalDB.repository.TaskTypeRepository;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


/**
Expand Down Expand Up @@ -118,4 +122,43 @@ public void editor(@RequestParam String oper,TaskType taskType,BindingResult res
}
}

@Transactional(readOnly = true)
@RequestMapping(value = "/showList", method = RequestMethod.GET)
@ResponseBody
public Object simpleClientList(@RequestParam(required = false) Integer page_num, @RequestParam(required = false) Integer per_page,@RequestParam(value = "pkey_val[]",required = false) String pkey,@RequestParam(value = "q_word[]",required = false) String[] qword,@RequestParam long firmID) {
// Retrieve all persons by delegating the call to PersonService
//Sort sort= FormSort.formSortFromSortDescription(orderby);
Sort sort=new Sort(Sort.Direction.ASC,"surname");
PageRequest pager=null;
if(page_num!=null && per_page!=null) {
pager = new PageRequest(page_num - 1, per_page, sort);
}
if(pager!=null) {
Page<TaskType> page;
if (qword != null && qword.length > 0) {
page = repositoryTaskType.findByNameContains(qword[0], pager);
} else {
page = repositoryTaskType.findAll(pager);
}
return new JSComboExpenseResp<>(page);
} else {
if(pkey!=null && !pkey.isEmpty()){
Long key=Long.valueOf(pkey);
TaskType ft=null;
if(key!=null) {
ft = repositoryTaskType.findOne(key);
}
return ft;
} else {
List<TaskType> page;
if (qword != null && qword.length > 0) {
page = repositoryTaskType.findByNameContains(qword[0],sort);
} else {
page = repositoryTaskType.findAll(sort);
}
return new JSComboExpenseResp<>(page);
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package ua.pp.fairwind.internalDBSystem.datamodel.proxy;

/**
* Created by Сергей on 16.09.2015.
*/
public class DonutData {
final private long value;
final private String label;

public DonutData(long value, String label) {
this.value = value;
this.label = label;
}

public long getValue() {
return value;
}

public String getLabel() {
return label;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import ua.pp.fairwind.favorid.internalDB.model.directories.ContactType;

Expand All @@ -14,4 +15,5 @@
public interface ContactTypeRepository extends JpaRepository<ContactType,Long>{
Page<ContactType> findByNameContains(String name,Pageable pager);
List<ContactType> findByNameContains(String name);
List<ContactType> findByNameContains(String name,Sort sort);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
Expand All @@ -19,6 +20,7 @@
public interface CounterpartyRepository extends JpaRepository<Counterparty,Long>{
Page<Counterparty> findByShortNameContains(String shortName, Pageable pager);
List<Counterparty> findByShortNameContains(String ShortName);
List<Counterparty> findByShortNameContains(String ShortName,Sort sort);
//@Query("select r from User u join u.userRoles r where u.userID=:userID")
@Query("select a from Agreement a join a.counterparty c where c.id=:ID")
Page<Agreement> getAgreements(@Param("ID") long id, Pageable pager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import ua.pp.fairwind.favorid.internalDB.model.directories.DocumentType;

Expand All @@ -14,4 +15,5 @@
public interface DocumentTypeRepository extends JpaRepository<DocumentType,Long>{
Page<DocumentType> findByNameContains(String name, Pageable pager);
List<DocumentType> findByNameContains(String name);
List<DocumentType> findByNameContains(String name,Sort sort);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import ua.pp.fairwind.favorid.internalDB.model.directories.Position;

Expand All @@ -14,4 +15,5 @@
public interface PositionRepository extends JpaRepository<Position,Long>{
Page<Position> findByNameContains(String name, Pageable pager);
List<Position> findByNameContains(String name);
List<Position> findByNameContains(String name,Sort sort);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import ua.pp.fairwind.favorid.internalDB.model.directories.TaskType;

Expand All @@ -14,4 +15,5 @@
public interface TaskTypeRepository extends JpaRepository<TaskType,Long>{
Page<TaskType> findByNameContains(String name, Pageable pager);
List<TaskType> findByNameContains(String name);
List<TaskType> findByNameContains(String name,Sort sort);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
public interface UserRepository extends JpaRepository<User,Long>{
Page<User> findByUserNameContains(String name, Pageable pager);
List<User> findByUserNameContains(String name);
User findByUserName(String userName);
//@Query("select r from User u join u.userRoles r where u.userID=:userID")
@Query("select r from Role r,User u where u.userID=:userID and (r MEMBER u.userRoles)")
Page<Role> getUserRoles(@Param("userID")long userId, Pageable pager);
Expand Down
Loading

0 comments on commit 8aaa625

Please sign in to comment.