Search in sources :

Example 1 with SampleReference

use of com.iggroup.oss.sample.domain.SampleReference in project RESTdoclet by IG-Group.

the class SampleController method getSampleByReference.

/**
	 * Find sample by unique lookup reference
	 * 
	 * @param reference the sample reference, a 5 digit text field
	 * @return the sample object corresponding to the lookup reference
	 */
@RequestMapping(value = "/samples/{reference}", method = { RequestMethod.GET })
@ResponseBody
public Sample getSampleByReference(/*
	 * @Valid @Pattern(regexp=
	 * "[0-9][0-9][0-9][0-9][0-9]")
	 */
@PathVariable String reference) {
    LOGGER.info("getSampleByReference " + reference);
    // since @Valid doesn't work properly until Spring 3.1
    // Note: could use SampleReference as a RequestParam but then the
    // interface is a little clunky
    validate(new SampleReference(reference));
    return service.getSampleByReference(reference);
}
Also used : SampleReference(com.iggroup.oss.sample.domain.SampleReference) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with SampleReference

use of com.iggroup.oss.sample.domain.SampleReference in project RESTdoclet by IG-Group.

the class AbstractSampleServiceTest method getAvailableRef.

/**
    * Find an available reference by adding 1 to the largest existing reference
    * number
    * 
    * @return unique reference
    */
private String getAvailableRef() {
    Long availRef = new Long(0);
    List<Sample> samples = service.findAllSamples();
    for (Sample s : samples) {
        Long ref = Long.valueOf(s.getReference());
        if (ref >= availRef) {
            availRef = ref + 1;
        }
    }
    return new SampleReference(availRef).toString();
}
Also used : SampleReference(com.iggroup.oss.sample.domain.SampleReference) Sample(com.iggroup.oss.sample.domain.Sample)

Example 3 with SampleReference

use of com.iggroup.oss.sample.domain.SampleReference in project RESTdoclet by IG-Group.

the class SampleController method deleteSample.

/**
	 * Delete the sample indicated by the reference
	 * 
	 * @param reference the sample's reference, a 5 digit text field
	 */
@RequestMapping(value = "/samples/{reference}", method = { RequestMethod.DELETE })
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteSample(@PathVariable String reference) {
    LOGGER.info("deleteSample " + reference);
    validate(new SampleReference(reference));
    service.deleteSample(reference);
}
Also used : SampleReference(com.iggroup.oss.sample.domain.SampleReference) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SampleReference (com.iggroup.oss.sample.domain.SampleReference)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Sample (com.iggroup.oss.sample.domain.Sample)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1