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

nl.tno.bim.mapping.controller.IfcMaterialKeywordController 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.IfcMaterialKeyword;
import nl.tno.bim.mapping.services.IfcMaterialKeywordService;

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


    private IfcMaterialKeywordService ifcMaterialKeywordService;

    @Autowired
    public void setIfcMaterialKeywordService(IfcMaterialKeywordService ifcMaterialKeywordService) {
        this.ifcMaterialKeywordService = ifcMaterialKeywordService;
    }

    @ApiOperation(value = "Persist new ifc material keyword")
    @RequestMapping(method = RequestMethod.POST, value = "/ifcmaterialkeyword")
    public ResponseEntity> addIfcMaterialKeywords(@RequestBody List ifcMaterialKeywords) {
        if (logger.isDebugEnabled()) {
            logger.debug("triggering method addIfcMaterialKeywords ");
        }
        List Imks = ifcMaterialKeywordService.persistIfcMaterialKeyword(ifcMaterialKeywords);
        if (Imks == null) {
            if (logger.isDebugEnabled()) {
                logger.debug("IfcMaterialKeyword: 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(Imks);
    }
    @ApiOperation(value = "Get All ifc material keyword by id")
    @RequestMapping(method = RequestMethod.GET, value = "/ifcmaterialkeyword/{id}")
    public ResponseEntity getIfcMaterialKeywordById(@PathVariable Long id) {
        if (logger.isDebugEnabled()) {
            logger.debug("triggering method getIfcMaterialKeywordById ");
        }
        IfcMaterialKeyword ms = ifcMaterialKeywordService.retrieveIfcMaterialKeywordById(id);
        if (ms == null) {
            if (logger.isDebugEnabled()) {
                logger.debug("getIfcMaterialKeywordById: returning 404 no data found ");
            }
            return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
        }
        if (logger.isDebugEnabled()) {
            logger.debug("returning IfcMaterialKeyword 200 object");
        }
        return ResponseEntity.status(HttpStatus.OK).body(ms);

    }
    @ApiOperation(value = "Get All ifc material keyword or use Request parameter q to filter")
    @RequestMapping(method = RequestMethod.GET, value = "/ifcmaterialkeyword")
    public ResponseEntity> searchIfcMaterialKeyword(@RequestParam(required = false) String q) {
        if (logger.isDebugEnabled()) {
            logger.debug("searchMapping: triggering method searchIfcMaterialKeyword");
        }
        List ms = ifcMaterialKeywordService.findIfcMaterialKeyword(q);
        if (ms == null) {
            if (logger.isDebugEnabled()) {
                logger.debug("searchIfcMaterialKeyword: returning 404 no data found ");
            }
            return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
        }
        if (logger.isDebugEnabled()) {
            logger.debug("returning IfcMaterialKeyword List 200 object");
        }
        return ResponseEntity.status(HttpStatus.OK).body(ms);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy