Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

complited project openpm #3

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified codeFormatter.xml
100755 → 100644
Empty file.
Empty file added pm/spy.log
Empty file.
5 changes: 3 additions & 2 deletions pm/src/main/java/com/jedlab/pm/dao/TaskDao.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.jedlab.pm.dao;

import org.springframework.data.repository.CrudRepository;


import com.jedlab.framework.spring.dao.AbstractCrudDAO;
import com.jedlab.pm.model.Task;

public interface TaskDao extends CrudRepository<Task, Long>
public interface TaskDao extends AbstractCrudDAO<Task>
{

}
2 changes: 2 additions & 0 deletions pm/src/main/java/com/jedlab/pm/model/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.jedlab.framework.report.ReportField;
import com.jedlab.framework.spring.dao.PO;

@Entity
Expand All @@ -19,6 +20,7 @@ public class Task extends PO
private Project project;

@Column(name = "name")
@ReportField(msg="Task_Name")
private String name;

public String getName()
Expand Down
3 changes: 2 additions & 1 deletion pm/src/main/java/com/jedlab/pm/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
import org.springframework.security.core.authority.SimpleGrantedAuthority;

import com.jedlab.framework.spring.security.SecurityUser;
import com.jedlab.framework.spring.security.SecurityUserContext;

@Entity
@Table(name = "users", schema = "public", uniqueConstraints = { @UniqueConstraint(columnNames = { "user_name", "email" }) })
public class User extends SecurityUser
public class User extends SecurityUser implements SecurityUserContext
{

private String email;
Expand Down
33 changes: 31 additions & 2 deletions pm/src/main/java/com/jedlab/pm/service/TaskService.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
package com.jedlab.pm.service;
import java.util.Locale;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jedlab.framework.exceptions.ServiceException;
import com.jedlab.framework.spring.dao.AbstractDAO;
import com.jedlab.framework.spring.service.AbstractCrudService;
import com.jedlab.pm.dao.TaskDao;
import com.jedlab.pm.model.Task;


@Service
public class TaskService
@Transactional
public class TaskService extends AbstractCrudService<Task>
{

@Autowired
Expand All @@ -17,10 +24,32 @@ public class TaskService
@Autowired
ProjectService projectService;

@Transactional
@Autowired
MessageSource messageSource;

/*
public void persist(Task instance)
{
taskDao.save(instance);
}
*/

@Override
public AbstractDAO<Task> getDao()
{

return taskDao;
}

@Override
protected void beforeInsert(Task entity) {
if(entity.getProject()== null)
throw new ServiceException(messageSource.getMessage("No Project", null, Locale.getDefault()));
}

@Override
protected void afterInsert(Task entity) {

}

}
6 changes: 3 additions & 3 deletions pm/src/main/resources/mail.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mail.host=mailtrap.io
mail.host=smtp.mailtrap.io
mail.port=2525
mail.username=5c2004fb6d747b
mail.password=c2cfab3fb3d9c0
mail.username=4ce150bbd4bef8
mail.password=f560fdc048dfdd
18 changes: 10 additions & 8 deletions pm/src/test/java/com/jedlab/pm/TaskTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;

import com.jedlab.pm.model.Project;
import com.jedlab.pm.model.Task;
Expand All @@ -25,14 +27,14 @@ public class TaskTest
@Test
public void taskInsertProject()
{
Project project = projectService.findAll().iterator().next();
for (int i = 0; i < 10; i++)
{
Task t = new Task();
t.setProject(project);
t.setName("task " + i);
taskService.persist(t);
}
for (int i = 4; i < 30; i++)
{
Task task=new Task();
task.setProject(projectService.findAll().iterator().next());
task.setName("task "+i);
taskService.insert(task);

}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<pageflow:Pageflow xmlns:pageflow="http://www.sybase.com/suade/pageflow" id="pf15218742415930" configfile="/webapp/src/main/webapp/WEB-INF/faces-config.xml"/>
8 changes: 8 additions & 0 deletions webapp/profiles/dev/WEB-INF/faces-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
version="2.2">

</faces-config>
2 changes: 1 addition & 1 deletion webapp/src/main/java/com/jedlab/pm/controller/register.vm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>

<br/>
<a href="http://localhost:8080/webapp/app/users/activate?c=${code}">فعالسازی</a>
<a href="http://localhost:8081/webapp/app/users/activate?c=${code}">فعالسازی</a>
<br/>

</body>
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/main/java/com/jedlab/pm/rest/ResourceQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public Response search(@Context HttpServletRequest request,@QueryParam("start")
GenericEntity<List<T>> entityWrapperList = new GenericEntity<List<T>>(projectList, responseType);
return Response.ok(entityWrapperList).build();
}
return Response.noContent().build();
return Response.ok("no result").build();
//return Response.noContent().build();
}

protected Restriction getRestriction()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.jedlab.pm.rest;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;


import com.jedlab.pm.model.Task;

@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class TaskEntityResourceQuery extends EntityResourceQuery<Task>
{

}
61 changes: 61 additions & 0 deletions webapp/src/main/java/com/jedlab/pm/rest/TaskResourceQuery.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.jedlab.pm.rest;

import javax.ws.rs.Path;

import org.hibernate.criterion.Restrictions;
import org.hibernate.sql.JoinType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.jedlab.framework.db.QueryMapper;
import com.jedlab.framework.spring.security.AuthenticationUtil;
import com.jedlab.framework.spring.service.AbstractCrudService;
import com.jedlab.framework.spring.service.Restriction;
import com.jedlab.pm.model.Task;
import com.jedlab.pm.service.TaskService;

@Component
@Path("/task")
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class TaskResourceQuery extends ResourceQuery<Task>
{

@Autowired
TaskService taskService;

@Autowired
TaskEntityResourceQuery subResourceLocator;



@Override
protected AbstractCrudService<Task> getService()
{

return taskService;
}

@Override
public EntityResourceQuery<Task> getEntityResourceQuery()
{

return subResourceLocator;
}

@Override
protected Restriction getRestriction()
{

return criteria -> {

criteria.createCriteria("project", "p", JoinType.LEFT_OUTER_JOIN);
criteria.createCriteria("p.owner", "o", JoinType.LEFT_OUTER_JOIN);
if(AuthenticationUtil.getUserId() != null)
criteria.add(Restrictions.eq("o.id", AuthenticationUtil.getUserId()));

};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public void resetSearch()
this.filter = new ProjectFilter();
}


@Override
protected ReportHeader getFormReportHeader()
{
String message=SpringUtil.getMessage("Project_List", null);
return new DefaultReportHeader(message);
}

}
92 changes: 92 additions & 0 deletions webapp/src/main/java/com/jedlab/pm/webflow/TaskHomeWebFlow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.jedlab.pm.webflow;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import org.primefaces.event.SelectEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;

import com.google.common.collect.Lists;
import com.jedlab.framework.spring.service.AbstractCrudService;
import com.jedlab.framework.web.AbstractHomeActionBean;
import com.jedlab.pm.model.Project;
import com.jedlab.pm.model.Task;
import com.jedlab.pm.service.ProjectService;
import com.jedlab.pm.service.TaskService;

public class TaskHomeWebFlow extends AbstractHomeActionBean<Task>
{

@Autowired
transient TaskService taskService;

@Autowired
transient ProjectService projectService;



public Long getTaskId()
{
return (Long) getId();
}

public void setTaskId(Long taskId)
{
setId(taskId);
}

@Override
public AbstractCrudService<Task> getService()
{

return taskService;
}

public void onItemSelect(SelectEvent event)
{
Project p=new Project();
p.setId((Long) event.getObject());

getInstance().setProject(p);


}


public List<Project> completeProject(String pname)
{
List<Project> projects=new ArrayList<Project>();

Iterable<Project> findAll = projectService.findAll(new ProjectSpecification(pname));
projects.addAll(Lists.newArrayList(findAll));
return projects;
}


public static class ProjectSpecification implements Specification<Project>
{

private String projectName;


public ProjectSpecification(String projectName)
{
this.projectName = projectName;
}


@Override
public Predicate toPredicate(Root<Project> root, CriteriaQuery<?> query, CriteriaBuilder cb)
{

return cb.like(root.get("name"),"%"+projectName+"%" );
}

}
}
Loading