Commit 37852d8d authored by Noel Alonso's avatar Noel Alonso
Browse files

Cambia referencia a utilidad de geojson

parent 23a3a5ca
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.vividsolutions.jts.geom.Point;

import es.redmic.brokerlib.avro.geodata.common.FeatureDTO;
import es.redmic.brokerlib.avro.geodata.common.GeoJSONFeatureType;
import es.redmic.brokerlib.avro.geodata.utils.GeoJSONFeatureType;

public class VesselTrackingDTO extends FeatureDTO<VesselTrackingPropertiesDTO, Point> {

+152 −0
Original line number Diff line number Diff line
package es.redmic.vesselsview.controller.vesseltracking;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.annotation.KafkaHandler;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import es.redmic.exception.common.ExceptionType;
import es.redmic.models.es.common.dto.EventApplicationResult;
import es.redmic.models.es.common.query.dto.DataQueryDTO;
import es.redmic.vesselslib.dto.tracking.VesselTrackingDTO;
import es.redmic.vesselslib.events.vesseltracking.VesselTrackingEventFactory;
import es.redmic.vesselslib.events.vesseltracking.VesselTrackingEventTypes;
import es.redmic.vesselslib.events.vesseltracking.create.CreateVesselTrackingEvent;
import es.redmic.vesselslib.events.vesseltracking.delete.DeleteVesselTrackingEvent;
import es.redmic.vesselslib.events.vesseltracking.partialupdate.vessel.UpdateVesselInVesselTrackingEvent;
import es.redmic.vesselslib.events.vesseltracking.update.UpdateVesselTrackingEvent;
import es.redmic.vesselsview.model.vessel.Vessel;
import es.redmic.vesselsview.model.vesseltracking.VesselTracking;
import es.redmic.vesselsview.service.vesseltracking.VesselTrackingESService;
import es.redmic.viewlib.config.MapperScanBeanItfc;
import es.redmic.viewlib.geodata.controller.GeoDataController;

@Controller
@RequestMapping(value = "${controller.mapping.vesseltracking}")
@KafkaListener(topics = "${broker.topic.vessel-tracking}")
public class VesselTrackingController extends GeoDataController<VesselTracking, VesselTrackingDTO, DataQueryDTO> {

	private static Logger logger = LogManager.getLogger();

	@Value("${broker.topic.vessel-tracking}")
	private String vesseltracking_topic;

	@Autowired
	MapperScanBeanItfc mapper;

	VesselTrackingESService service;

	@Autowired
	public VesselTrackingController(VesselTrackingESService service) {
		super(service);
		this.service = service;
	}

	@KafkaHandler
	public void listen(CreateVesselTrackingEvent event) {

		logger.info("Crear vesselTracking");

		EventApplicationResult result = null;

		try {
			result = service.save(mapper.getMapperFacade().map(event.getVesselTracking(), VesselTracking.class));
		} catch (Exception e) {
			logger.error("Error al procesar CreateVesselTrackingEvent para vesselTracking " + event.getAggregateId()
					+ " " + e.getMessage());
			publishFailedEvent(VesselTrackingEventFactory.getEvent(event, VesselTrackingEventTypes.CREATE_FAILED,
					ExceptionType.INTERNAL_EXCEPTION.name(), null), vesseltracking_topic);
		}

		if (result.isSuccess()) {
			logger.info("VesselTracking creado en la vista");
			publishConfirmedEvent(VesselTrackingEventFactory.getEvent(event, VesselTrackingEventTypes.CREATE_CONFIRMED),
					vesseltracking_topic);
		} else {
			publishFailedEvent(VesselTrackingEventFactory.getEvent(event, VesselTrackingEventTypes.CREATE_FAILED,
					result.getExeptionType(), result.getExceptionArguments()), vesseltracking_topic);
		}
	}

	@KafkaHandler
	public void listen(UpdateVesselTrackingEvent event) {

		logger.info("Modificar vesselTracking");

		EventApplicationResult result = null;

		try {
			result = service.update(mapper.getMapperFacade().map(event.getVesselTracking(), VesselTracking.class));
		} catch (Exception e) {
			publishFailedEvent(VesselTrackingEventFactory.getEvent(event, VesselTrackingEventTypes.UPDATE_FAILED,
					ExceptionType.INTERNAL_EXCEPTION.name(), null), vesseltracking_topic);
		}

		if (result.isSuccess()) {
			logger.info("VesselTracking modificado en la vista");
			publishConfirmedEvent(VesselTrackingEventFactory.getEvent(event, VesselTrackingEventTypes.UPDATE_CONFIRMED),
					vesseltracking_topic);
		} else {
			publishFailedEvent(VesselTrackingEventFactory.getEvent(event, VesselTrackingEventTypes.UPDATE_FAILED,
					result.getExeptionType(), result.getExceptionArguments()), vesseltracking_topic);
		}
	}

	@KafkaHandler
	public void listen(UpdateVesselInVesselTrackingEvent event) {

		logger.info("Modificar vessel en vesseltracking");

		EventApplicationResult result = null;

		try {
			result = service.updateVesselInVesselTracking(event.getAggregateId(),
					mapper.getMapperFacade().map(event.getVessel(), Vessel.class));
		} catch (Exception e) {
			publishFailedEvent(VesselTrackingEventFactory.getEvent(event, VesselTrackingEventTypes.UPDATE_FAILED,
					ExceptionType.INTERNAL_EXCEPTION.name(), null), vesseltracking_topic);
		}

		if (result.isSuccess()) {
			logger.info("VesselTracking modificado en la vista");
			publishConfirmedEvent(VesselTrackingEventFactory.getEvent(event, VesselTrackingEventTypes.UPDATE_CONFIRMED),
					vesseltracking_topic);
		} else {
			publishFailedEvent(VesselTrackingEventFactory.getEvent(event, VesselTrackingEventTypes.UPDATE_FAILED,
					result.getExeptionType(), result.getExceptionArguments()), vesseltracking_topic);
		}
	}

	@KafkaHandler
	public void listen(DeleteVesselTrackingEvent event) {

		logger.info("Eliminar vesselTracking");

		EventApplicationResult result = null;

		try {
			result = service.delete(event.getAggregateId());
		} catch (Exception e) {
			publishFailedEvent(VesselTrackingEventFactory.getEvent(event, VesselTrackingEventTypes.DELETE_FAILED,
					ExceptionType.INTERNAL_EXCEPTION.name(), null), vesseltracking_topic);
		}

		if (result.isSuccess()) {

			logger.info("VesselTracking eliminado de la vista");
			publishConfirmedEvent(VesselTrackingEventFactory.getEvent(event, VesselTrackingEventTypes.DELETE_CONFIRMED),
					vesseltracking_topic);
		} else {
			publishFailedEvent(VesselTrackingEventFactory.getEvent(event, VesselTrackingEventTypes.DELETE_FAILED,
					result.getExeptionType(), result.getExceptionArguments()), vesseltracking_topic);
		}
	}

	@KafkaHandler(isDefault = true)
	public void listenDefualt(Object event) {
	}
}
+8 −0
Original line number Diff line number Diff line
@@ -2,8 +2,11 @@ server.port=8092
server.servlet.context-path=/api
server.servlet.path=/vessels/view

vesseltracking-activity-id=999

documentation.VESSEL_HOST=redmic.es${server.servlet.context-path}${server.servlet.path}
documentation.VESSELTYPE_HOST=${documentation.VESSEL_HOST}${controller.mapping.vesseltype}
documentation.VESSELTRACKING_HOST=${documentation.VESSEL_HOST}${controller.mapping.vesseltracking}
spring.profiles.active=@spring.profiles.active@

info.vessels-view.name=@project.name@
@@ -54,6 +57,8 @@ redmic.elasticsearch.MAX_QUERY_SIZE=3000
#mapping
controller.mapping.vesseltype=/vesseltype

controller.mapping.vesseltracking=/activities/{activityId}/vesseltracking

controller.mapping.FILTER_SCHEMA=/_search/_schema

#topic del broker para enviar/recibir eventos de barcos
@@ -62,5 +67,8 @@ broker.topic.vessel=vessel
#topic del broker para enviar/recibir eventos de tipos de barcos
broker.topic.vessel-type=vessel-type

#topic del broker para enviar/recibir eventos de tracking de barcos
broker.topic.vessel-tracking=vessel-tracking

#Exclude from autoconfigure
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration, org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration, org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration, org.springframework.boot.autoconfigure.aop.AopAutoConfiguration, org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration, org.springframework.boot.autoconfigure.cloud.CloudAutoConfiguration, org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration, org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration, org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.ldap.LdapDataAutoConfiguration, org.springframework.boot.autoconfigure.data.ldap.LdapRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration, org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration, org.springframework.boot.autoconfigure.data.solr.SolrRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.elasticsearch.jest.JestAutoConfiguration, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration, org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration, org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration, org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration, org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration, org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration, org.springframework.boot.autoconfigure.hazelcast.HazelcastJpaDependencyAutoConfiguration, org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration, org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.XADataSourceAutoConfiguration, org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration, org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration, org.springframework.boot.autoconfigure.jms.JndiConnectionFactoryAutoConfiguration, org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration, org.springframework.boot.autoconfigure.jms.artemis.ArtemisAutoConfiguration, org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration,org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration, org.springframework.boot.autoconfigure.ldap.embedded.EmbeddedLdapAutoConfiguration, org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration, org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration, org.springframework.boot.autoconfigure.mail.MailSenderValidatorAutoConfiguration, org.springframework.boot.autoconfigure.mobile.DeviceDelegatingViewResolverAutoConfiguration, org.springframework.boot.autoconfigure.mobile.DeviceResolverAutoConfiguration, org.springframework.boot.autoconfigure.mobile.SitePreferenceAutoConfiguration, org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration, org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration, org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration, org.springframework.boot.autoconfigure.reactor.ReactorAutoConfiguration, org.springframework.boot.autoconfigure.security.FallbackWebSecurityAutoConfiguration, org.springframework.boot.autoconfigure.sendgrid.SendGridAutoConfiguration, org.springframework.boot.autoconfigure.session.SessionAutoConfiguration, org.springframework.boot.autoconfigure.social.FacebookAutoConfiguration, org.springframework.boot.autoconfigure.social.LinkedInAutoConfiguration, org.springframework.boot.autoconfigure.social.SocialWebAutoConfiguration, org.springframework.boot.autoconfigure.social.TwitterAutoConfiguration, org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration, org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration, org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration
 No newline at end of file