Commit 2de8b559 authored by Noel Alonso's avatar Noel Alonso
Browse files

Adapta controladores a nuevo dto de consultas

parent a49d8502
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -26,10 +26,11 @@ import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
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.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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@@ -56,7 +57,7 @@ public class ActivityProjectController extends RBaseController<Activity, Activit
		this.service = service;
	}

	@RequestMapping(value = "/_search", method = RequestMethod.POST)
	@PostMapping(value = "/_search")
	@ResponseBody
	public SuperDTO findAll(@PathVariable("projectId") Long projectId,
			@Valid @RequestBody DataQueryDTO queryDTO, BindingResult bindingResult) {
@@ -68,7 +69,7 @@ public class ActivityProjectController extends RBaseController<Activity, Activit
		return new ElasticSearchDTO(service.find(queryDTO));
	}

	@RequestMapping(value = "/_suggest", method = RequestMethod.GET)
	@GetMapping(value = "/_suggest")
	@ResponseBody
	public SuperDTO _suggest(@PathVariable("projectId") Long projectId, @RequestParam("fields") String[] fields,
			@RequestParam("text") String text,
@@ -79,12 +80,12 @@ public class ActivityProjectController extends RBaseController<Activity, Activit
		processQuery((DataQueryDTO) queryDTO);
		queryDTO.addTerm("path.split", projectId);

		List<String> response = service.suggest(convertToQuery((DataQueryDTO)queryDTO));
		List<String> response = service.suggest(convertToDataQuery((DataQueryDTO)queryDTO));

		return new ElasticSearchDTO(response, response.size());
	}

	@RequestMapping(value = "/{id}", method = RequestMethod.GET)
	@GetMapping(value = "/{id}")
	@ResponseBody
	public SuperDTO findById(@PathVariable("projectId") String projectId, @PathVariable("id") String id) {

+5 −4
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ package es.redmic.api.administrative.controller;
 */

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -51,7 +52,7 @@ public class ContactController
		this.serviceES = serviceES;
	}

	@RequestMapping(value = "${contoller.mapping.FILTERED_ACTIVITIES}", method = RequestMethod.GET)
	@GetMapping(value = "${contoller.mapping.FILTERED_ACTIVITIES}")
	@ResponseBody
	public SuperDTO getActivities(@RequestParam(required = false, value = "fields") String[] fields,
			@RequestParam(required = false, value = "text") String text,
@@ -63,7 +64,7 @@ public class ContactController

		processQuery(queryDTO);

		JSONCollectionDTO response = serviceES.getActivities(convertToQuery(queryDTO), id);
		JSONCollectionDTO response = serviceES.getActivities(convertToDataQuery(queryDTO), id);
		return new ElasticSearchDTO(response);
	}
}
+5 −5
Original line number Diff line number Diff line
@@ -21,9 +21,9 @@ package es.redmic.api.administrative.controller;
 */

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@@ -50,7 +50,7 @@ public class DocumentController extends
		this.serviceES = serviceES;
	}

	@RequestMapping(value = "${contoller.mapping.FILTERED_ACTIVITIES}", method = RequestMethod.GET)
	@GetMapping(value = "${contoller.mapping.FILTERED_ACTIVITIES}")
	@ResponseBody
	public SuperDTO getActivities(@RequestParam(required = false, value = "fields") String[] fields,
			@RequestParam(required = false, value = "text") String text,
@@ -61,6 +61,6 @@ public class DocumentController extends
				ESService.createSimpleQueryDTOFromTextQueryParams(fields, text, from, size), MetadataQueryDTO.class);
		processQuery(queryDTO);

		return new ElasticSearchDTO(serviceES.getActivities(convertToQuery(queryDTO), id));
		return new ElasticSearchDTO(serviceES.getActivities(convertToDataQuery(queryDTO), id));
	}
}
+6 −6
Original line number Diff line number Diff line
@@ -21,9 +21,9 @@ package es.redmic.api.administrative.controller;
 */

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@@ -50,7 +50,7 @@ public class OrganisationController extends
		this.serviceES = serviceES;
	}

	@RequestMapping(value = "${contoller.mapping.FILTERED_ACTIVITIES}", method = RequestMethod.GET)
	@GetMapping(value = "${contoller.mapping.FILTERED_ACTIVITIES}")
	@ResponseBody
	public SuperDTO getActivities(@RequestParam(required = false, value = "fields") String[] fields,
			@RequestParam(required = false, value = "text") String text,
@@ -62,6 +62,6 @@ public class OrganisationController extends

		processQuery(queryDTO);

		return new ElasticSearchDTO(serviceES.getActivities(convertToQuery(queryDTO), id));
		return new ElasticSearchDTO(serviceES.getActivities(convertToDataQuery(queryDTO), id));
	}
}
+5 −5
Original line number Diff line number Diff line
@@ -21,9 +21,9 @@ package es.redmic.api.administrative.controller;
 */

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@@ -50,7 +50,7 @@ public class PlatformController extends
		this.serviceES = serviceES;
	}

	@RequestMapping(value = "${contoller.mapping.FILTERED_ACTIVITIES}", method = RequestMethod.GET)
	@GetMapping(value = "${contoller.mapping.FILTERED_ACTIVITIES}")
	@ResponseBody
	public SuperDTO getActivities(@RequestParam(required = false, value = "fields") String[] fields,
			@RequestParam(required = false, value = "text") String text,
@@ -61,6 +61,6 @@ public class PlatformController extends
				ESService.createSimpleQueryDTOFromTextQueryParams(fields, text, from, size), MetadataQueryDTO.class);
		processQuery(queryDTO);

		return new ElasticSearchDTO(serviceES.getActivities(convertToQuery(queryDTO), id));
		return new ElasticSearchDTO(serviceES.getActivities(convertToDataQuery(queryDTO), id));
	}
}
Loading