0% found this document useful (0 votes)
68 views4 pages

WS Practical No.7

The document contains details of a student named Onkar Jagadale with roll number 8242/TYCS-A. It describes practical number 7 which involves creating an Index.html page with placeholder content and a College7FacadeREST.java file that implements RESTful web services to perform CRUD operations on a College7 entity. The Java file defines JAX-RS annotated methods to create, edit, delete, find by id, find all, find a range, and get the count of College7 records using the EntityManager.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views4 pages

WS Practical No.7

The document contains details of a student named Onkar Jagadale with roll number 8242/TYCS-A. It describes practical number 7 which involves creating an Index.html page with placeholder content and a College7FacadeREST.java file that implements RESTful web services to perform CRUD operations on a College7 entity. The Java file defines JAX-RS annotated methods to create, edit, delete, find by id, find all, find a range, and get the count of College7 records using the EntityManager.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Name: Onkar Jagadale

Roll No: 8242/ TYCS-A

Practical No.7

Index.html :

<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div>TODO write content</div>
</body>
</html>

college7facadeREST.java :

package service;

import com.abc.College7;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
*
* @author Administrator
*/
@Stateless
Name: Onkar Jagadale
Roll No: 8242/ TYCS-A

@Path("com.abc.college7")
public class College7FacadeREST extends AbstractFacade<College7> {

@PersistenceContext(unitName = "Rest_CRUDPU")
private EntityManager em;

public College7FacadeREST() {
super(College7.class);
}

@POST
@Override
@Consumes({MediaType.APPLICATION_XML,
MediaType.APPLICATION_JSON})
public void create(College7 entity) {
super.create(entity);
}

@PUT
@Path("{id}")
@Consumes({MediaType.APPLICATION_XML,
MediaType.APPLICATION_JSON})
public void edit(@PathParam("id") Integer id, College7 entity) {
super.edit(entity);
}

@DELETE
@Path("{id}")
public void remove(@PathParam("id") Integer id) {
super.remove(super.find(id));
}

@GET
@Path("{id}")
@Produces({MediaType.APPLICATION_XML,
MediaType.APPLICATION_JSON})
public College7 find(@PathParam("id") Integer id) {
return super.find(id);
}
Name: Onkar Jagadale
Roll No: 8242/ TYCS-A

@GET
@Override
@Produces({MediaType.APPLICATION_XML,
MediaType.APPLICATION_JSON})
public List<College7> findAll() {
return super.findAll();
}

@GET
@Path("{from}/{to}")
@Produces({MediaType.APPLICATION_XML,
MediaType.APPLICATION_JSON})
public List<College7> findRange(@PathParam("from") Integer from,
@PathParam("to") Integer to) {
return super.findRange(new int[]{from, to});
}

@GET
@Path("count")
@Produces(MediaType.TEXT_PLAIN)
public String countREST() {
return String.valueOf(super.count());
}

@Override
protected EntityManager getEntityManager() {
return em;
}

}
Name: Onkar Jagadale
Roll No: 8242/ TYCS-A

OUTPUT :

You might also like