All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.tno.bim.mapping.controller.IfcToNlsfbController Maven / Gradle / Ivy

package nl.tno.bim.mapping.controller;


import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
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 io.swagger.annotations.ApiOperation;
import nl.tno.bim.mapping.domain.IfcToNlsfb;
import nl.tno.bim.mapping.services.IfcToNlsfbService;

@CrossOrigin()
@RestController()
@RequestMapping(value = "/api")
public class IfcToNlsfbController {
    private final static Logger logger = LoggerFactory.getLogger(IfcToNlsfbController.class);


    private IfcToNlsfbService ifcToNlsfbService;

    @Autowired
    public void setIfcToNlsfbService(IfcToNlsfbService ifcToNlsfbService) {
        this.ifcToNlsfbService = ifcToNlsfbService;
    }
    @ApiOperation(value = "Persist new ifc to nlsfb")
    @RequestMapping(method = RequestMethod.POST, value = "/ifctonlsfb")
    public ResponseEntity> addIfcToNlsfbMap(@RequestBody List ifcToNlsfbs) {
        if (logger.isDebugEnabled()) {
            logger.debug("triggering method addIfcToNlsfbMap ");
        }
        List cwds = ifcToNlsfbService.persistIfcToNlsfbs(ifcToNlsfbs);
        if (cwds == null) {
            if (logger.isDebugEnabled()) {
                logger.debug("IfcToNlsfb: returning internal server error due to backend service problem ");
            }
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
        }
        if (logger.isDebugEnabled()) {
            logger.debug("returning persisted data ");
        }
        return ResponseEntity.status(HttpStatus.OK).body(cwds);
    }
    @ApiOperation(value = "Get ifc to nlsfb by id")
    @RequestMapping(method = RequestMethod.GET, value = "/ifctonlsfb/{id}")
    public ResponseEntity getIfcToNlsfbById(@PathVariable Long id) {
        if (logger.isDebugEnabled()) {
            logger.debug("triggering method getIfcToNlsfbById ");
        }
        IfcToNlsfb ms = ifcToNlsfbService.retrieveIfcToNlsfbById(id);
        if (ms == null) {
            if (logger.isDebugEnabled()) {
                logger.debug("getIfcToNlsfbById: returning 404 no data found ");
            }
            return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
        }
        if (logger.isDebugEnabled()) {
            logger.debug("returning IfcToNlsfb 200 object");
        }
        return ResponseEntity.status(HttpStatus.OK).body(ms);

    }
    @ApiOperation(value = "Get All ifc to nlsfb by or use query parameter 'q' to filter")
    @RequestMapping(method = RequestMethod.GET, value = "/ifctonlsfb")
    public ResponseEntity> searchIfcToNlsfb(@RequestParam(required = false) String q) {
        if (logger.isDebugEnabled()) {
            logger.debug("searchMapping: triggering method searchIfcToNlsfb");
        }
        List ms = ifcToNlsfbService.findIfcToNlsfb(q);
        if (ms == null) {
            if (logger.isDebugEnabled()) {
                logger.debug("searchIfcToNlsfb: returning 404 no data found ");
            }
            return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
        }
        if (logger.isDebugEnabled()) {
            logger.debug("returning IfcToNlsfb List 200 object");
        }
        return ResponseEntity.status(HttpStatus.OK).body(ms);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy