Java tutorial
/*Copyright (c) 2016-2017 wavemaker.com All Rights Reserved. This software is the confidential and proprietary information of wavemaker.com You shall not disclose such Confidential Information and shall use it only in accordance with the terms of the source code license agreement you entered into with wavemaker.com*/ package com.testing26thjuly_.db123testing.controller; /*This is a Studio Managed File. DO NOT EDIT THIS FILE. Your changes may be reverted by Studio.*/ import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.hibernate.TypeMismatchException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.wavemaker.runtime.data.exception.EntityNotFoundException; import com.wavemaker.runtime.data.export.ExportType; import com.wavemaker.runtime.data.expression.QueryFilter; import com.wavemaker.runtime.file.model.Downloadable; import com.wavemaker.runtime.util.WMMultipartUtils; import com.wavemaker.runtime.util.WMRuntimeUtils; import com.wordnik.swagger.annotations.Api; import com.wordnik.swagger.annotations.ApiOperation; import com.testing26thjuly_.db123testing.V1; import com.testing26thjuly_.db123testing.V1Id; import com.testing26thjuly_.db123testing.service.V1Service; import com.wordnik.swagger.annotations.*; import com.wavemaker.tools.api.core.annotations.WMAccessVisibility; import com.wavemaker.tools.api.core.models.AccessSpecifier; /** * Controller object for domain model class V1. * @see V1 */ @RestController("DB123Testing.V1Controller") @RequestMapping("/DB123Testing/V1") @Api(description = "Exposes APIs to work with V1 resource.", value = "V1Controller") public class V1Controller { private static final Logger LOGGER = LoggerFactory.getLogger(V1Controller.class); @Autowired @Qualifier("DB123Testing.V1Service") private V1Service v1Service; @RequestMapping(value = "/composite-id", method = RequestMethod.GET) @ApiOperation(value = "Returns the V1 instance associated with the given composite-id.") public V1 getV1(@RequestParam("id") int id, @RequestParam("byteCol") Byte byteCol, @RequestParam("shortCol") Short shortCol, @RequestParam("intCol") Integer intCol, @RequestParam("longCol") BigInteger longCol, @RequestParam("bigIntCol") BigInteger bigIntCol, @RequestParam("floatCol") Float floatCol, @RequestParam("doubleCol") Double doubleCol, @RequestParam("bigDecCol") BigDecimal bigDecCol, @RequestParam("charCol") Character charCol, @RequestParam("stringCol") String stringCol, @RequestParam("textCol") String textCol, @RequestParam("booleanCol") Boolean booleanCol, @RequestParam("blobCol") byte[] blobCol, @RequestParam("timestampCol") Date timestampCol, @RequestParam("dateCol") Date dateCol, @RequestParam("timeCol") Date timeCol, @RequestParam("datetimeCol") Date datetimeCol) throws EntityNotFoundException { V1Id v1Id = new V1Id(); v1Id.setId(id); v1Id.setByteCol(byteCol); v1Id.setShortCol(shortCol); v1Id.setIntCol(intCol); v1Id.setLongCol(longCol); v1Id.setBigIntCol(bigIntCol); v1Id.setFloatCol(floatCol); v1Id.setDoubleCol(doubleCol); v1Id.setBigDecCol(bigDecCol); v1Id.setCharCol(charCol); v1Id.setStringCol(stringCol); v1Id.setTextCol(textCol); v1Id.setBooleanCol(booleanCol); v1Id.setBlobCol(blobCol); v1Id.setTimestampCol(timestampCol); v1Id.setDateCol(dateCol); v1Id.setTimeCol(timeCol); v1Id.setDatetimeCol(datetimeCol); LOGGER.debug("Getting V1 with id: {}", v1Id); V1 v1 = v1Service.getById(v1Id); LOGGER.debug("V1 details with id: {}", v1); return v1; } @RequestMapping(value = "/composite-id/content/{fieldName}", method = RequestMethod.GET) @ApiOperation(value = "Retrieves content for the given BLOB field in V1 instance associated with the given composite-id.") public void getV1BLOBContent(@RequestParam("id") int id, @RequestParam("byteCol") Byte byteCol, @RequestParam("shortCol") Short shortCol, @RequestParam("intCol") Integer intCol, @RequestParam("longCol") BigInteger longCol, @RequestParam("bigIntCol") BigInteger bigIntCol, @RequestParam("floatCol") Float floatCol, @RequestParam("doubleCol") Double doubleCol, @RequestParam("bigDecCol") BigDecimal bigDecCol, @RequestParam("charCol") Character charCol, @RequestParam("stringCol") String stringCol, @RequestParam("textCol") String textCol, @RequestParam("booleanCol") Boolean booleanCol, @RequestParam("blobCol") byte[] blobCol, @RequestParam("timestampCol") Date timestampCol, @RequestParam("dateCol") Date dateCol, @RequestParam("timeCol") Date timeCol, @RequestParam("datetimeCol") Date datetimeCol, @PathVariable("fieldName") String fieldName, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws EntityNotFoundException { LOGGER.debug("Retrieves content for the given BLOB field {} in V1 instance", fieldName); if (!WMRuntimeUtils.isLob(V1.class, fieldName)) { throw new TypeMismatchException("Given field " + fieldName + " is not a valid BLOB type"); } V1Id v1Id = new V1Id(); v1Id.setId(id); v1Id.setByteCol(byteCol); v1Id.setShortCol(shortCol); v1Id.setIntCol(intCol); v1Id.setLongCol(longCol); v1Id.setBigIntCol(bigIntCol); v1Id.setFloatCol(floatCol); v1Id.setDoubleCol(doubleCol); v1Id.setBigDecCol(bigDecCol); v1Id.setCharCol(charCol); v1Id.setStringCol(stringCol); v1Id.setTextCol(textCol); v1Id.setBooleanCol(booleanCol); v1Id.setBlobCol(blobCol); v1Id.setTimestampCol(timestampCol); v1Id.setDateCol(dateCol); v1Id.setTimeCol(timeCol); v1Id.setDatetimeCol(datetimeCol); V1 v1 = v1Service.getById(v1Id); WMMultipartUtils.buildHttpResponseForBlob(v1, fieldName, httpServletRequest, httpServletResponse); } /** * @deprecated Use {@link #findV1s(String)} instead. */ @Deprecated @RequestMapping(value = "/search", method = RequestMethod.POST) @ApiOperation(value = "Returns the list of V1 instances matching the search criteria.") public Page<V1> findV1s(Pageable pageable, @RequestBody QueryFilter[] queryFilters) { LOGGER.debug("Rendering V1s list"); return v1Service.findAll(queryFilters, pageable); } @RequestMapping(method = RequestMethod.GET) @ApiOperation(value = "Returns the list of V1 instances matching the search criteria.") public Page<V1> findV1s(@RequestParam(value = "q", required = false) String query, Pageable pageable) { LOGGER.debug("Rendering V1s list"); return v1Service.findAll(query, pageable); } @RequestMapping(value = "/export/{exportType}", method = RequestMethod.GET, produces = "application/octet-stream") @ApiOperation(value = "Returns downloadable file for the data.") public Downloadable exportV1s(@PathVariable("exportType") ExportType exportType, @RequestParam(value = "q", required = false) String query, Pageable pageable) { return v1Service.export(exportType, query, pageable); } /** * This setter method should only be used by unit tests * * @param service V1Service instance */ protected void setV1Service(V1Service service) { this.v1Service = service; } @RequestMapping(value = "/count", method = RequestMethod.GET) @WMAccessVisibility(value = AccessSpecifier.APP_ONLY) @ApiOperation(value = "Returns the total count of V1 instances.") public Long countV1s(@RequestParam(value = "q", required = false) String query) { LOGGER.debug("counting V1s"); return v1Service.count(query); } }