public class PeriodicTableElementResource extends Object
Constructor and Description |
---|
PeriodicTableElementResource(Long id)
Constructs this PeriodicTableElementResource from the supplied id.
|
Modifier and Type | Method and Description |
---|---|
javax.ws.rs.core.Response |
createElementFromFormParameters(javax.ws.rs.core.UriInfo uriInfo,
Long id,
String symbol,
String name,
String weight,
String group,
String period,
String block,
String electronConfiguration)
Creates a new Element or updates an existing Element from form parameters.
|
javax.ws.rs.core.Response |
createOrUpdateElement(javax.ws.rs.core.UriInfo uriInfo,
Element element)
Creates a new Element or updates an existing Element.
|
javax.ws.rs.core.Response |
createOrUpdateElementFromJasonOrXML(javax.ws.rs.core.UriInfo uriInfo,
Element element)
Creates a new Element or updates an existing Element from either JASON or XML.
|
void |
deleteElement()
Deletes the Element with the id that was supplied at construction time.
|
String |
getElementAsHtml()
Gets the Element with the id that was supplied at construction time, in HTML format.
|
Element |
getElementAsJasonOrXml()
Gets the Element with the id that was supplied at construction time.
|
public PeriodicTableElementResource(Long id)
id
- ID of the Element.@GET @Produces(value={"application/json","application/xml"}) public Element getElementAsJasonOrXml()
curl --header Accept:application/json --get http://localhost:8080/josef-demo-rest-ws/resources/elements/119
curl --header Accept:application/xml --get http://localhost:8080/josef-demo-rest-ws/resources/elements/119
javax.ws.rs.InternalServerErrorException
- When the element could not be fetched from the database.@GET @Produces(value="text/html;q=0.7") public String getElementAsHtml()
curl --header Accept:text/html --get http://localhost:8080/josef-demo-rest-ws/resources/elements/119
javax.ws.rs.InternalServerErrorException
- When the element could not be fetched from the database.@PUT @Consumes(value={"application/json","application/xml"}) public javax.ws.rs.core.Response createOrUpdateElementFromJasonOrXML(@Context javax.ws.rs.core.UriInfo uriInfo, Element element)
curl -H "Content-Type: application/json" -T create.json
http://localhost:8080/josef-demo-rest-ws/resources/elements/119
{
"id":"119",
"name":"Element 119",
"symbol":"Zz",
"weight":"119.0",
"group":"2",
"period":"3",
"block":"s",
"electronConfiguration":"1s1"
}
{
"id":"119",
"name":"Element 119",
"symbol":"Zz",
"weight":"119.0",
"group":"2",
"period":"3",
"block":"s",
"electronConfiguration":"1s1"
}
uriInfo
- The URI Info to create links.element
- The Element.@PUT @Consumes(value="application/x-www-form-urlencoded") @Produces(value="text/plain") public javax.ws.rs.core.Response createElementFromFormParameters(@Context javax.ws.rs.core.UriInfo uriInfo, @FormParam(value="id") Long id, @FormParam(value="idSymbol") String symbol, @FormParam(value="idName") String name, @FormParam(value="idWeight") String weight, @FormParam(value="idGroup") String group, @FormParam(value="idPeriod") String period, @FormParam(value="idBlock") String block, @FormParam(value="idElectronConfiguration") String electronConfiguration)
uriInfo
- The URI Info to create links.id
- The id (atomic number).symbol
- The symbol.name
- The name.weight
- The atomic weight.group
- The group number.period
- The period number.block
- The block.electronConfiguration
- The electron configuration.public javax.ws.rs.core.Response createOrUpdateElement(@Context javax.ws.rs.core.UriInfo uriInfo, Element element)
uriInfo
- The URI Info Object.element
- The element to create or update.@DELETE public void deleteElement()
javax.ws.rs.NotFoundException
- When no element with the id that was supplied at construction time exists.Copyright © 2008–2018. All rights reserved.