Skip to content

Commit

Permalink
MESSAGE MANIPULATION COMPLETE
Browse files Browse the repository at this point in the history
WORK ON TASK MANIPULATION
TODO:
REQUEST MANIPULATION
DOCUMENT MANIPULATION
DOCUMENT FILE MANIPULATION
SHOW CONTROLLED TASK FOR USER
SHOW USERS TASK
STOREHOUSE MANIPULATION
GOOD PRODUCTION AND SERVICE
REGISTER BAD PRODUCT
  • Loading branch information
FairWindCo committed Nov 3, 2015
1 parent cb44ad0 commit dd4a3fa
Show file tree
Hide file tree
Showing 29 changed files with 1,710 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public String index(Model model) {

@RequestMapping(value = "/notfound", method = RequestMethod.GET)
public String eror404(Model model) {
return "error404rror404";
return "error404";
}

@RequestMapping(value = "/error403", method = RequestMethod.GET)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public Object documentSubscriberList(@RequestParam(required = false) Integer pag
public Object userPersonsList(@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,HttpServletRequest request) {
// Retrieve all persons by delegating the call to PersonService
//Sort sort= FormSort.formSortFromSortDescription(orderby);
Sort sort=new Sort(Sort.Direction.ASC,"surname");
Sort sort=new Sort(Sort.Direction.ASC,"person.surname");
PageRequest pager=null;
if(page_num!=null && per_page!=null) {
page_num= page_num<1?1:page_num;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ 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) {
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) {
// Retrieve all persons by delegating the call to PersonService
//Sort sort= FormSort.formSortFromSortDescription(orderby);
Sort sort=new Sort(Sort.Direction.ASC,"surname");
Sort sort=new Sort(Sort.Direction.ASC,"name");
PageRequest pager=null;
if(page_num!=null && per_page!=null) {
page_num= page_num<1?1:page_num;
Expand Down
34 changes: 34 additions & 0 deletions src/main/java/ua/pp/fairwind/favorid/internalDB/jgrid/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import org.springframework.data.domain.Sort;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

Expand All @@ -25,6 +28,26 @@ public static Long getLongParameter(String name,HttpServletRequest request){
return val;
}

public static Date getDateParameter(String name,String format,HttpServletRequest request){
Date val=null;
String value=request.getParameter(name);
if(value!=null && !value.isEmpty()){
if("null".equals(value)||"undifined".equals(value))return null;
val=getDateFromString(value,format);
}
return val;
}

public static Date getDateParameter(String name,HttpServletRequest request){
Date val=null;
String value=request.getParameter(name);
if(value!=null && !value.isEmpty()){
if("null".equals(value)||"undifined".equals(value))return null;
val=getDateFromString(value,null);
}
return val;
}

public static Sort getJComboSortOrder(HttpServletRequest request){
Sort sort=null;
String order_string=request.getParameter("order_by");
Expand Down Expand Up @@ -169,6 +192,17 @@ public static Long getLongFromString(String str){
}
}

public static Date getDateFromString(String stringValue,String format){
if(stringValue==null || stringValue.isEmpty()) return null;
if(format==null || format.isEmpty())format="dd-MM-yyyy";
try {
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
return dateFormat.parse(stringValue);
} catch (ParseException e){
return null;
}
}

public static Set<Long> getIDsFromRequest(HttpServletRequest request,String paramName){
if(request==null || paramName==null) return null;
Set<Long> set=null;
Expand Down
43 changes: 23 additions & 20 deletions src/main/java/ua/pp/fairwind/favorid/internalDB/model/Task.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package ua.pp.fairwind.favorid.internalDB.model;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.LastModifiedDate;
import ua.pp.fairwind.favorid.internalDB.model.administrative.User;
import ua.pp.fairwind.favorid.internalDB.model.directories.TaskType;
import ua.pp.fairwind.favorid.internalDB.model.document.Document;
import ua.pp.fairwind.favorid.internalDB.model.proxy.MyDateSerializer;

import javax.persistence.*;
import java.util.Collections;
Expand All @@ -22,15 +24,12 @@ public class Task {
@Id
@GeneratedValue
Long id;
String name;
String description;
String result;
@ManyToOne
@JoinColumn(name = "task__type_id")
@JoinColumn(name = "task_type_id")
TaskType taskType;
@ManyToOne
@JoinColumn(name = "counterparty_id")
Counterparty counterparty;
@ManyToOne
@JsonManagedReference
@JoinColumn(name = "responsible_person_id")
Person responsible;
Expand All @@ -52,7 +51,7 @@ public class Task {
@CreatedBy
@JoinColumn(name = "create_user_id")
User creationUser;

Date endControlDate;
@Version
private long version;

Expand All @@ -64,12 +63,12 @@ public void setId(Long id) {
this.id = id;
}

public String getName() {
return name;
public String getResult() {
return result;
}

public void setName(String name) {
this.name = name;
public void setResult(String result) {
this.result = result;
}

public String getDescription() {
Expand All @@ -88,13 +87,6 @@ public void setTaskType(TaskType taskType) {
this.taskType = taskType;
}

public Counterparty getCounterparty() {
return counterparty;
}

public void setCounterparty(Counterparty counterparty) {
this.counterparty = counterparty;
}

public Person getResponsible() {
return responsible;
Expand All @@ -108,7 +100,7 @@ public Set<Person> getExecutors() {
return Collections.unmodifiableSet(executors);
}


@JsonSerialize(using=MyDateSerializer.class)
public Date getStartDate() {
return startDate;
}
Expand All @@ -117,22 +109,23 @@ public void setStartDate(Date startDate) {
this.startDate = startDate;
}

@JsonSerialize(using=MyDateSerializer.class)
public Date getDedLineDate() {
return dedLineDate;
}

public void setDedLineDate(Date dedLineDate) {
this.dedLineDate = dedLineDate;
}

@JsonSerialize(using=MyDateSerializer.class)
public Date getEndDate() {
return endDate;
}

public void setEndDate(Date endDate) {
this.endDate = endDate;
}

@JsonSerialize(using=MyDateSerializer.class)
public Date getCreationDate() {
return creationDate;
}
Expand All @@ -141,6 +134,7 @@ public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}

@JsonSerialize(using=MyDateSerializer.class)
public Date getModificationDate() {
return modificationDate;
}
Expand Down Expand Up @@ -185,4 +179,13 @@ public User getCreationUser() {
public void setCreationUser(User creationUser) {
this.creationUser = creationUser;
}

@JsonSerialize(using=MyDateSerializer.class)
public Date getEndControlDate() {
return endControlDate;
}

public void setEndControlDate(Date endControlDate) {
this.endControlDate = endControlDate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.Set;

/**
* Created by Ñåðãåé on 16.10.2015.
* Created by ������ on 16.10.2015.
*/
@Entity
@Table(name = "MESSAGES")
Expand Down Expand Up @@ -65,7 +65,7 @@ public boolean isCanValidate(){
}
for(MessageRecipient in:recipientSet){
if(in.getValidationDate()==null) {
if (userDetail.getUserPerson().equals(in.getRecipient())) {
if (userDetail.getUserPerson().equals(in.getRecipient())||userDetail.getUserPerson().getId().equals(in.getRecipient().getId())) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package ua.pp.fairwind.favorid.internalDB.model.messages;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import ua.pp.fairwind.favorid.internalDB.model.Person;
import ua.pp.fairwind.favorid.internalDB.model.proxy.MyDateSerializer;

import javax.persistence.*;
import java.util.Date;
Expand Down Expand Up @@ -54,7 +56,7 @@ public Person getRecipient() {
public void setRecipient(Person recipient) {
this.recipient = recipient;
}

@JsonSerialize(using=MyDateSerializer.class)
public Date getValidationDate() {
return validationDate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ public interface PersonRepository extends JpaRepository<Person,Long>{
List<PersonProxy> findMessageUsersProxy(@Param("messageid")long messageid,Sort sort);


@Query("Select distinct new ua.pp.fairwind.favorid.internalDB.model.proxy.PersonProxy(u.person.id,u.person.surname,u.person.firstName,u.person.middleName,u.person.date_of_birth) from User u where u.person not in (select p from Task t join t.executors p where t.id=:taskid) and u.person.surname like :surname ")
Page<PersonProxy> findTaskUsersProxyBySurname(@Param("surname")String surname,@Param("taskid")long taskid,Pageable pageRequest);
@Query("Select distinct new ua.pp.fairwind.favorid.internalDB.model.proxy.PersonProxy(u.person.id,u.person.surname,u.person.firstName,u.person.middleName,u.person.date_of_birth) from User u where u.person not in (select p from Task t join t.executors p where t.id=:taskid) and u.person.surname like :surname ")
List<PersonProxy> findTaskUsersProxyBySurname(@Param("surname")String fio,@Param("taskid")long taskid,Sort sort);
@Query("Select distinct new ua.pp.fairwind.favorid.internalDB.model.proxy.PersonProxy(u.person.id,u.person.surname,u.person.firstName,u.person.middleName,u.person.date_of_birth) from User u where u.person not in (select p from Task t join t.executors p where t.id=:taskid)")
Page<PersonProxy> findTaskUsersProxy(@Param("taskid")long taskid,Pageable pageRequest);
@Query("Select distinct new ua.pp.fairwind.favorid.internalDB.model.proxy.PersonProxy(u.person.id,u.person.surname,u.person.firstName,u.person.middleName,u.person.date_of_birth) from User u where u.person not in (select p from Task t join t.executors p where t.id=:taskid)")
List<PersonProxy> findTaskUsersProxy(@Param("taskid")long taskid,Sort sort);



@Query("select c from Contact c,Person p where p.id=:ID and c member of p.contacts")
Page<Contact> getContacts(@Param("ID") long id, Pageable pager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import ua.pp.fairwind.favorid.internalDB.model.Person;
import ua.pp.fairwind.favorid.internalDB.model.Task;
import ua.pp.fairwind.favorid.internalDB.model.administrative.User;
Expand All @@ -14,21 +16,26 @@
*/

public interface TaskRepository extends JpaRepository<Task,Long>{
Page<Task> findByNameContains(String name,Pageable pageRequest);
List<Task> findByNameContains(String name);
Page<Task> findByDescriptionContains(String name,Pageable pageRequest);
List<Task> findByDescriptionContains(String name);

Page<Task> findByNameContainsAndCreationUser(String name,User created,Pageable pageRequest);
List<Task> findByNameContainsAndCreationUser(String name,User created);
Page<Task> findByDescriptionContainsAndCreationUser(String name,User created,Pageable pageRequest);
List<Task> findByDescriptionContainsAndCreationUser(String name,User created);
Page<Task> findByCreationUser(User created,Pageable pageRequest);
List<Task> findByCreationUser(User created);

Page<Task> findByNameContainsAndResponsible(String name,Person responsible,Pageable pageRequest);
List<Task> findByNameContainsAndResponsible(String name,Person responsible);
Page<Task> findByDescriptionContainsAndResponsible(String name,Person responsible,Pageable pageRequest);
List<Task> findByDescriptionContainsAndResponsible(String name,Person responsible);
Page<Task> findByResponsible(Person responsible,Pageable pageRequest);
List<Task> findByResponsible(Person responsible);

Page<Task> findByNameContainsAndExecutors(String name,Person executor,Pageable pageRequest);
List<Task> findByNameContainsAndExecutors(String name,Person executor);
Page<Task> findByDescriptionContainsAndExecutors(String name,Person executor,Pageable pageRequest);
List<Task> findByDescriptionContainsAndExecutors(String name,Person executor);
Page<Task> findByExecutors(Person executor,Pageable pageRequest);
List<Task> findByExecutors(Person executor);

@Query("select p from Task t join t.executors p where t.id=:id")
Page<Person> getExecutors(@Param(value = "id")long id,Pageable pageRequest);
@Query("select p from Task t join t.executors p where t.id=:id")
List<Person> getExecutors(@Param(value = "id")long id);
}
13 changes: 11 additions & 2 deletions src/main/resources/label_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,19 @@ label.message.administrator=Administrate
label.message.for_me=Messages for Me
label.message.my=My Messages
label.message.actual_for_me=Actual Messages
label.messages.creationDate=Creation |Date
label.messages.creationDate=Creation Date
label.messages.actualDate=Date of actuality
label.messages.text=Message Text
label.messages.creationUser=From Person
label.message.recipient=Recipient
label.message.validationDate=Validation Date
label.message.recipients=List of mesage recipients
label.message.recipients=List of mesage recipients
label.tasktypes.list=Task Types
label.tasks.view=List of Tasks
label.tasks.type=Task Type
label.tasks.counterpart=Counterpart
label.tasks.responsible=Responsible
label.tasks.descriptions=Description
label.tasks.startDate=Start Date
label.tasks.dedLineDate=Plan End Date
label.tasks.creationDate=Creation Date
Loading

0 comments on commit dd4a3fa

Please sign in to comment.