Projects >> resthub-spring-stack >>9c054f586711fb294d432d437929e721289faf2a

Chunk
Conflicting content
	List findAll();
<<<<<<< HEAD:resthub-core/src/main/java/org/resthub/core/service/GenericService.java
package org.resthub.core.service;

import java.io.Serializable;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

/**
 * Generic Service interface.
 * 
 * @param 
 *            Domain model class managed, must be an Entity
 * @param 
 *            Primary key class of T
 */
public interface GenericService {

	/**
	 * Create new resource.
	 * 
	 * @param resource
	 *            Resource to create
	 * @return new resource
	 */
	T create(T resource);

	/**
	 * Update existing resource.
	 * 
	 * @param resource
	 *            Resource to update
	 * @return resource updated
	 */
	T update(T resource);

	/**
	 * Delete existing resource.
	 * 
	 * @param resource
	 *            Resource to delete
	 */
	void delete(T resource);

	/**
	 * Delete existing resource.
	 * 
	 * @param id
	 *            Resource id
	 */
	void delete(ID id);

	/**
	 * Delete all existing resource. Do not use cascade remove (not a choice ->
	 * JPA specs)
	 */
	void deleteAll();

	/**
	 * Delete all existing resource, including linked entities with cascade
	 * delete
	 */
	void deleteAllWithCascade();

	/**
	 * Find resource by id.
	 * 
	 * @param id
	 *            Resource id
	 * @return resource
	 */
	T findById(ID id);

	/**
	 * Find all resources.
	 * 
	 * @return a list of all resources.
	 */

	/**
	 * Find all resources (pageable).
	 * 
	 * @param pageRequest
	 *            page request
	 * @return resources
	 */
	Page findAll(Pageable pageRequest);

	/**
	 * Count all resources.
	 * 
	 * @return number of resources
	 */
	Long count();
}
=======
package org.resthub.core.service;

import java.io.Serializable;
import java.util.List;

import org.synyx.hades.domain.Page;
     */
import org.synyx.hades.domain.Pageable;

/**
 * Generic Service interface.
 * 
 * @param 
 *            Domain model class managed, must be an Entity
 * @param 
 *            Primary key class of T
 */
public interface GenericService {

    /**
     * Create new resource.
     * 
     * @param resource
     *            Resource to create
     * @return new resource
     */
    T create(T resource);

    /**
     * Update existing resource.
     * 
     * @param resource
     *            Resource to update
     * @return resource updated
     */
    T update(T resource);

    /**
     * Delete existing resource.
     * 
     * @param resource
     *            Resource to delete
     */
    void delete(T resource);

    /**
     * Delete existing resource.
     * 
     * @param id
     *            Resource id
     */
    void delete(ID id);

    /**
     * Delete all existing resource. Do not use cascade remove (not a choice ->
     * JPA specs)
     */
    void deleteAll();

    /**
     * Delete all existing resource, including linked entities with cascade
     * delete
     */
    void deleteAllWithCascade();

    /**
     * Find resource by id.
     * 
     * @param id
     *            Resource id
     * @return resource
     */
    T findById(ID id);

    /**
     * Find all resources.
     * 
     * @param offset
     *            offset (default 0)
     * @param limit
     *            limit (default 100)
     * @return resources.
     */
    List findAll(Integer offset, Integer limit);

    /**
     * Find all resources.
     * 
     * @return a list of all resources.
     */
    List findAll();

    /**
     * Find all resources (pageable).
     * 
     * @param pageRequest
     *            page request
     * @return resources
     */
    Page findAll(Pageable pageRequest);

    /**
     * Count all resources.
     * 
     * @return number of resources
    Long count();

}
>>>>>>> cced174f5ded0640f16abdf78478e9ef4221c256:resthub-contract/src/main/java/org/resthub/core/service/GenericService.java
Solution content
	 * @param id
package org.resthub.core.service;

import java.io.Serializable;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

/**
 * Generic Service interface.
 * 
 * @param 
 *            Domain model class managed, must be an Entity
 * @param 
 *            Primary key class of T
 */
public interface GenericService {

	/**
	 * Create new resource.
	 * 
	 * @param resource
	 *            Resource to create
	 * @return new resource
	 */
	T create(T resource);

	/**
	 * Update existing resource.
	 * 
	 * @param resource
	 *            Resource to update
	 * @return resource updated
	 */
	T update(T resource);

	/**
	 * Delete existing resource.
	 * 
	 * @param resource
	 *            Resource to delete
	 */
	void delete(T resource);

	/**
	 * Delete existing resource.
	 * 
	 *            Resource id
	 */
	void delete(ID id);

	/**
	 * Delete all existing resource. Do not use cascade remove (not a choice ->
	 * JPA specs)
	 */
	void deleteAll();

	/**
	 * Delete all existing resource, including linked entities with cascade
	 * delete
	 */
	void deleteAllWithCascade();

	/**
	 * Find resource by id.
	 * 
	 * @param id
	 *            Resource id
	 * @return resource
	 */
	T findById(ID id);

	/**
	 * Find all resources.
	 * 
	 * @return a list of all resources.
	 */
	List findAll();

	/**
	 * Find all resources (pageable).
	 * 
	 * @param pageRequest
	 *            page request
	 * @return resources
	 */
	Page findAll(Pageable pageRequest);

	/**
	 * Count all resources.
	 * 
	 * @return number of resources
	 */
	Long count();
}
File
GenericService.java
Developer's decision
Version 1
Kind of conflict
Comment
Import
Interface declaration
Package declaration
Chunk
Conflicting content
    private EntityManager em;
    
<<<<<<< HEAD
=======
    @PersistenceContext
    public void setEntityManager(EntityManager em) {
        this.em = em;
    }

>>>>>>> cced174f5ded0640f16abdf78478e9ef4221c256
    /**
     * Injection of Service
     * @param service the service to set
Solution content
    private EntityManager em;
    
    @PersistenceContext
    public void setEntityManager(EntityManager em) {
        this.em = em;
    }

    /**
     * Injection of Service
     * @param service the service to set
File
AbstractServiceTest.java
Developer's decision
Version 2
Kind of conflict
Annotation
Method declaration
Chunk
Conflicting content
@Named("groupService")
public class GroupServiceImpl extends AbstractTraceableServiceImpl implements GroupService {

<<<<<<< HEAD
	/**
	 * The userRepository
* This class need it in order to be able to deal with users */ protected UserRepository userRepository; protected RoleService roleService; ======= /** * The userDao
* This class need it in order to be able to deal with users */ protected UserDao userDao; protected RoleService roleService; @Inject @Named("userDao") protected void setUserDao(UserDao userDao) { this.userDao = userDao; } >>>>>>> cced174f5ded0640f16abdf78478e9ef4221c256 @Inject @Named("groupRepository")
Solution content
@Named("groupService")
public class GroupServiceImpl extends AbstractTraceableServiceImpl implements GroupService {

	/**
	 * The userRepository
* This class need it in order to be able to deal with users */ protected UserRepository userRepository; protected RoleService roleService; @Inject @Named("groupRepository")
File
GroupServiceImpl.java
Developer's decision
Version 1
Kind of conflict
Annotation
Attribute
Comment
Method declaration
Chunk
Conflicting content
     * 
	}
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public abstract class GenericControllerImpl> implements
<<<<<<< HEAD
		GenericController {

	protected S service;

	@PersistenceContext
	private EntityManager em;

	public GenericControllerImpl() {

	}

	public void setService(S service) {
		this.service = service;
	public S getService() {
		return this.service;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.resthub.web.controller.GenericController#create(T)
	 */
	@Override
	@POST
	public T create(T entity) {
		return this.service.create(entity);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.resthub.web.controller.GenericController#update(ID, T)
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	@PUT
	@Path("/{id}")
	public T update(@PathParam("id") ID id, T entity) {
		Assert.notNull(id, "id cannot be null");
		T retreivedEntity = this.service.findById(id);
		if (retreivedEntity == null) {
			throw new NotFoundException();
		}
		MetamodelUtils utils = new MetamodelUtils((Class) ClassUtils.getGenericTypeFromBean(this.service),
				em.getMetamodel());
		Serializable entityId = utils.getIdFromEntity(entity);
		if ((entityId != null) && !id.equals(this.getIdFromEntity(retreivedEntity))) {
			throw new WebApplicationException(Response.Status.CONFLICT);
		}
		if (null == entityId) {
			utils.setIdForEntity(entity, id);
		}
		return this.service.update(entity);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.resthub.web.controller.GenericController#getEntities()
	 */
	@Override
	@GET
	@Path("/all")
	public List findAll() {
		return this.service.findAll();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.resthub.web.controller.GenericController#findAll(java.lang.Integer, java.lang.Integer)
	 */
	@Override
	@GET
	public PageResponse findAll(@QueryParam("page") @DefaultValue("0") Integer page,
								   @QueryParam("size") @DefaultValue("5") Integer size) {
		return new PageResponse(this.service.findAll(new PageRequest(page, size)));
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.resthub.web.controller.GenericController#getResource(ID)
	 */
	@Override
	@GET
	@Path("/{id}")
	public T findById(@PathParam("id") ID id) {
		T entity = this.service.findById(id);
		if (entity == null) {
			throw new NotFoundException();
		}

		return entity;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.resthub.web.controller.GenericController#delete()
	 */
	@Override
	@DELETE
	@Path("/all")
	public void delete() {
		this.service.deleteAllWithCascade();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.resthub.web.controller.GenericController#delete(ID)
	 */
	@Override
	@DELETE
	@Path("/{id}")
	public void delete(@PathParam("id") ID id) {
		this.service.delete(id);
	}

	/**
	 * Automatically retrieve ID from entity instance.
	 * 
	 * @param obj
	 *            The object from whom we need primary key
	 * @return The corresponding primary key.
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	protected ID getIdFromEntity(T obj) {
		MetamodelUtils utils = new MetamodelUtils((Class) ClassUtils.getGenericTypeFromBean(this.service),
				em.getMetamodel());
		return (ID) utils.getIdFromEntity(obj);
	}
=======
        GenericController {

    protected S service;

    private EntityManager em;
    
    @PersistenceContext
    public void setEntityManager(EntityManager em) {
        this.em = em;
    }

    public GenericControllerImpl() {

    }

    public void setService(S service) {
        this.service = service;
    }

    public S getService() {
        return this.service;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.resthub.web.controller.GenericController#create(T)
     */
    @Override
    @POST
    public T create(T entity) {
        return this.service.create(entity);
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.resthub.web.controller.GenericController#update(ID, T)
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Override
    @PUT
    @Path("/{id}")
    public T update(@PathParam("id") ID id, T entity) {
        Assert.notNull(id, "id cannot be null");
        T retreivedEntity = this.service.findById(id);
        if (retreivedEntity == null) {
            throw new NotFoundException();
        }
        MetamodelUtils utils = new MetamodelUtils((Class) ClassUtils.getGenericTypeFromBean(this.service),
                em.getMetamodel());
        Serializable entityId = utils.getIdFromEntity(entity);
        if ((entityId != null) && !id.equals(this.getIdFromEntity(retreivedEntity))) {
            throw new WebApplicationException(Response.Status.CONFLICT);
        }
        if (null == entityId) {
            utils.setIdForEntity(entity, id);
        }
        return this.service.update(entity);
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.resthub.web.controller.GenericController#getEntities()
     */
    @Override
    @GET
    @Path("/all")
    public List findAll() {
        return this.service.findAll();
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * org.resthub.web.controller.GenericController#getEntities(java.lang.Integer
     * , java.lang.Integer)
     */
    @Override
    @GET
    public PageResponse findAll(@QueryParam("page") @DefaultValue("0") Integer page,
            @QueryParam("size") @DefaultValue("5") Integer size) {
        return new PageResponse(this.service.findAll(new PageRequest(page, size)));
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.resthub.web.controller.GenericController#getResource(ID)
     */
    @Override
    @GET
    @Path("/{id}")
    public T findById(@PathParam("id") ID id) {
        T entity = this.service.findById(id);
        if (entity == null) {
            throw new NotFoundException();
        }

        return entity;
    }

    /*
     * (non-Javadoc)
     * @see org.resthub.web.controller.GenericController#delete()
     */
    @Override
    @DELETE
    @Path("/all")
    public void delete() {
        this.service.deleteAllWithCascade();
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.resthub.web.controller.GenericController#delete(ID)
     */
    @Override
    @DELETE
    @Path("/{id}")
    public void delete(@PathParam("id") ID id) {
        this.service.delete(id);
    }

    /**
     * Automatically retrieve ID from entity instance.
     * 
     * @param obj
     *            The object from whom we need primary key
     * @return The corresponding primary key.
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    protected ID getIdFromEntity(T obj) {
        MetamodelUtils utils = new MetamodelUtils((Class) ClassUtils.getGenericTypeFromBean(this.service),
                em.getMetamodel());
        return (ID) utils.getIdFromEntity(obj);
    }

>>>>>>> cced174f5ded0640f16abdf78478e9ef4221c256
}
Solution content
     */
    @Override
    @GET
    @Path("/all")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public abstract class GenericControllerImpl> implements
        GenericController {

    protected S service;

    private EntityManager em;
    
    @PersistenceContext
    public void setEntityManager(EntityManager em) {
        this.em = em;
    }

    public GenericControllerImpl() {

    }

    public void setService(S service) {
        this.service = service;
    }

    public S getService() {
        return this.service;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.resthub.web.controller.GenericController#create(T)
     */
    @Override
    @POST
    public T create(T entity) {
        return this.service.create(entity);
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.resthub.web.controller.GenericController#update(ID, T)
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Override
    @PUT
    @Path("/{id}")
    public T update(@PathParam("id") ID id, T entity) {
        Assert.notNull(id, "id cannot be null");
        T retreivedEntity = this.service.findById(id);
        if (retreivedEntity == null) {
            throw new NotFoundException();
        }
        MetamodelUtils utils = new MetamodelUtils((Class) ClassUtils.getGenericTypeFromBean(this.service),
                em.getMetamodel());
        Serializable entityId = utils.getIdFromEntity(entity);
        if ((entityId != null) && !id.equals(this.getIdFromEntity(retreivedEntity))) {
            throw new WebApplicationException(Response.Status.CONFLICT);
        }
        if (null == entityId) {
            utils.setIdForEntity(entity, id);
        }
        return this.service.update(entity);
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.resthub.web.controller.GenericController#getEntities()
    public List findAll() {
        return this.service.findAll();
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.resthub.web.controller.GenericController#findAll(java.lang.Integer, java.lang.Integer)
     */
    @Override
    @GET
    public PageResponse findAll(@QueryParam("page") @DefaultValue("0") Integer page,
            @QueryParam("size") @DefaultValue("5") Integer size) {
        return new PageResponse(this.service.findAll(new PageRequest(page, size)));
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.resthub.web.controller.GenericController#getResource(ID)
     */
    @Override
    @GET
    @Path("/{id}")
    public T findById(@PathParam("id") ID id) {
        T entity = this.service.findById(id);
        if (entity == null) {
            throw new NotFoundException();
        }

        return entity;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.resthub.web.controller.GenericController#delete()
     */
    @Override
    @DELETE
    @Path("/all")
    public void delete() {
        this.service.deleteAllWithCascade();
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.resthub.web.controller.GenericController#delete(ID)
     */
    @Override
    @DELETE
    @Path("/{id}")
    public void delete(@PathParam("id") ID id) {
        this.service.delete(id);
    }

    /**
     * Automatically retrieve ID from entity instance.
     * 
     * @param obj
     *            The object from whom we need primary key
     * @return The corresponding primary key.
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    protected ID getIdFromEntity(T obj) {
        MetamodelUtils utils = new MetamodelUtils((Class) ClassUtils.getGenericTypeFromBean(this.service),
                em.getMetamodel());
        return (ID) utils.getIdFromEntity(obj);
    }

}
File
GenericControllerImpl.java
Developer's decision
Combination
Kind of conflict
Annotation
Attribute
Comment
Method declaration