Loading src/main/java/es/redmic/commandslib/config/GenerateJsonSchemaScanBean.java +4 −3 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.kjetland.jackson.jsonSchema.JsonSchemaGenerator; import com.kjetland.jackson.jsonSchema.JsonSchemaResources; import es.redmic.commandslib.controller.CommandController; import es.redmic.commandslib.controller.CommandBaseController; import es.redmic.exception.mediastorage.MSFileUploadException; public class GenerateJsonSchemaScanBean implements ApplicationContextAware { Loading Loading @@ -64,9 +64,10 @@ public class GenerateJsonSchemaScanBean implements ApplicationContextAware { * CommandController */ @SuppressWarnings("rawtypes") final Map<String, CommandController> controllers = applicationContext.getBeansOfType(CommandController.class); final Map<String, CommandBaseController> controllers = applicationContext .getBeansOfType(CommandBaseController.class); for (@SuppressWarnings("rawtypes") final CommandController controller : controllers.values()) { final CommandBaseController controller : controllers.values()) { try { Class<?> typeOfTDTO = (Class<?>) ((ParameterizedType) controller.getClass().getGenericSuperclass()) Loading src/main/java/es/redmic/commandslib/controller/CommandController.java +1 −23 Original line number Diff line number Diff line package es.redmic.commandslib.controller; import java.lang.reflect.ParameterizedType; import java.util.HashMap; import javax.validation.Valid; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; Loading @@ -20,7 +15,6 @@ import org.springframework.web.bind.annotation.ResponseBody; import es.redmic.brokerlib.avro.common.CommonDTO; import es.redmic.commandslib.service.CommandServiceItfc; import es.redmic.commandslib.service.JsonSchemaService; import es.redmic.exception.data.ItemAlreadyExistException; import es.redmic.exception.databinding.DTONotValidException; import es.redmic.models.es.common.dto.BodyItemDTO; Loading @@ -30,19 +24,11 @@ public abstract class CommandController<TDTO extends CommonDTO> extends CommandB protected static Logger logger = LogManager.getLogger(); protected Class<TDTO> typeOfTDTO; @Autowired JsonSchemaService jsonSchemaService; CommandServiceItfc<TDTO> service; @SuppressWarnings("unchecked") public CommandController(CommandServiceItfc<TDTO> service) { super(); this.service = service; this.typeOfTDTO = (Class<TDTO>) (((ParameterizedType) getClass().getGenericSuperclass()) .getActualTypeArguments()[0]); } @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) Loading Loading @@ -76,12 +62,4 @@ public abstract class CommandController<TDTO extends CommonDTO> extends CommandB service.delete(id); return new SuperDTO(true); } @Override @GetMapping(value = "${controller.mapping.EDIT_SCHEMA}") @ResponseBody public HashMap<String, Object> getJsonSchema() { return jsonSchemaService.getJsonSchema(typeOfTDTO.getName()); } } Loading
src/main/java/es/redmic/commandslib/config/GenerateJsonSchemaScanBean.java +4 −3 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.kjetland.jackson.jsonSchema.JsonSchemaGenerator; import com.kjetland.jackson.jsonSchema.JsonSchemaResources; import es.redmic.commandslib.controller.CommandController; import es.redmic.commandslib.controller.CommandBaseController; import es.redmic.exception.mediastorage.MSFileUploadException; public class GenerateJsonSchemaScanBean implements ApplicationContextAware { Loading Loading @@ -64,9 +64,10 @@ public class GenerateJsonSchemaScanBean implements ApplicationContextAware { * CommandController */ @SuppressWarnings("rawtypes") final Map<String, CommandController> controllers = applicationContext.getBeansOfType(CommandController.class); final Map<String, CommandBaseController> controllers = applicationContext .getBeansOfType(CommandBaseController.class); for (@SuppressWarnings("rawtypes") final CommandController controller : controllers.values()) { final CommandBaseController controller : controllers.values()) { try { Class<?> typeOfTDTO = (Class<?>) ((ParameterizedType) controller.getClass().getGenericSuperclass()) Loading
src/main/java/es/redmic/commandslib/controller/CommandController.java +1 −23 Original line number Diff line number Diff line package es.redmic.commandslib.controller; import java.lang.reflect.ParameterizedType; import java.util.HashMap; import javax.validation.Valid; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; Loading @@ -20,7 +15,6 @@ import org.springframework.web.bind.annotation.ResponseBody; import es.redmic.brokerlib.avro.common.CommonDTO; import es.redmic.commandslib.service.CommandServiceItfc; import es.redmic.commandslib.service.JsonSchemaService; import es.redmic.exception.data.ItemAlreadyExistException; import es.redmic.exception.databinding.DTONotValidException; import es.redmic.models.es.common.dto.BodyItemDTO; Loading @@ -30,19 +24,11 @@ public abstract class CommandController<TDTO extends CommonDTO> extends CommandB protected static Logger logger = LogManager.getLogger(); protected Class<TDTO> typeOfTDTO; @Autowired JsonSchemaService jsonSchemaService; CommandServiceItfc<TDTO> service; @SuppressWarnings("unchecked") public CommandController(CommandServiceItfc<TDTO> service) { super(); this.service = service; this.typeOfTDTO = (Class<TDTO>) (((ParameterizedType) getClass().getGenericSuperclass()) .getActualTypeArguments()[0]); } @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) Loading Loading @@ -76,12 +62,4 @@ public abstract class CommandController<TDTO extends CommonDTO> extends CommandB service.delete(id); return new SuperDTO(true); } @Override @GetMapping(value = "${controller.mapping.EDIT_SCHEMA}") @ResponseBody public HashMap<String, Object> getJsonSchema() { return jsonSchemaService.getJsonSchema(typeOfTDTO.getName()); } }