Search in sources :

Example 1 with ExchangeLogStatusType

use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventIncomingServiceBean method logRefIdByTypeExists.

@Override
public void logRefIdByTypeExists(@Observes @LogRefIdByTypeExists ExchangeMessageEvent event) {
    try {
        LogRefIdByTypeExistsRequest request = unMarshallMessage(event.getJmsMessage().getText(), LogRefIdByTypeExistsRequest.class);
        String refGuid = request.getRefGuid();
        List<TypeRefType> refTypes = request.getRefTypes();
        List<ExchangeLogStatusType> exchangeStatusHistoryList = exchangeLogModel.getExchangeLogsStatusHistories(refGuid, refTypes);
        LogRefIdByTypeExistsResponse response = new LogRefIdByTypeExistsResponse();
        if (CollectionUtils.isNotEmpty(exchangeStatusHistoryList)) {
            response.setRefGuid(exchangeStatusHistoryList.get(0).getTypeRef().getRefGuid());
        }
        String responseAsString = JAXBUtils.marshallJaxBObjectToString(response);
        producer.sendModuleResponseMessage(event.getJmsMessage(), responseAsString);
    } catch (ExchangeModelException | JAXBException | JMSException e) {
        fireExchangeFault(event, "Could not un-marshall " + LogRefIdByTypeExistsRequest.class, e);
    }
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) LogRefIdByTypeExistsRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.LogRefIdByTypeExistsRequest) TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) LogRefIdByTypeExistsResponse(eu.europa.ec.fisheries.schema.exchange.module.v1.LogRefIdByTypeExistsResponse) JAXBException(javax.xml.bind.JAXBException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) JMSException(javax.jms.JMSException)

Example 2 with ExchangeLogStatusType

use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogServiceBean method getExchangeStatusHistoryList.

@Override
public List<ExchangeLogStatusType> getExchangeStatusHistoryList(ExchangeLogStatusTypeType status, TypeRefType type, Date from, Date to) throws ExchangeLogException {
    log.info("Get pollstatus list in service layer:{}", status);
    try {
        List<ExchangeLogStatusTypeType> statusList = new ArrayList<>();
        if (status != null) {
            statusList.add(status);
        }
        List<TypeRefType> typeList = new ArrayList<>();
        if (type != null) {
            typeList.add(type);
        }
        ExchangeHistoryListQuery query = new ExchangeHistoryListQuery();
        query.setTypeRefDateFrom(from);
        query.setTypeRefDateTo(to);
        query.getStatus().addAll(statusList);
        query.getType().addAll(typeList);
        List<ExchangeLogStatusType> pollStatusList = exchangeLogModel.getExchangeLogStatusHistoryByQuery(query);
        return pollStatusList;
    } catch (ExchangeModelException e) {
        throw new ExchangeLogException("Couldn't get exchange status history list.");
    }
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ArrayList(java.util.ArrayList) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) ExchangeHistoryListQuery(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeHistoryListQuery)

Example 3 with ExchangeLogStatusType

use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogServiceBean method createExchangeLogStatusType.

private ExchangeLogStatusType createExchangeLogStatusType(ExchangeLogStatusTypeType logStatus, String logGuid) {
    ExchangeLogStatusType exchangeLogStatusType = new ExchangeLogStatusType();
    exchangeLogStatusType.setGuid(logGuid);
    ArrayList statusHistoryList = new ArrayList();
    ExchangeLogStatusHistoryType statusHistory = new ExchangeLogStatusHistoryType();
    statusHistory.setStatus(logStatus);
    statusHistoryList.add(statusHistory);
    exchangeLogStatusType.getHistory().addAll(statusHistoryList);
    return exchangeLogStatusType;
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) ExchangeLogStatusHistoryType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType) ArrayList(java.util.ArrayList)

Example 4 with ExchangeLogStatusType

use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogRestResource method getPollStatus.

@POST
@Consumes(value = { MediaType.APPLICATION_JSON })
@Produces(value = { MediaType.APPLICATION_JSON })
@Path(value = "/poll")
@RequiresFeature(UnionVMSFeature.viewExchange)
public ResponseDto getPollStatus(PollQuery query) {
    try {
        log.info("Get ExchangeLog status for Poll in rest layer:{}", query);
        Date from = DateUtils.stringToDate(query.getStatusFromDate());
        Date to = DateUtils.stringToDate(query.getStatusToDate());
        List<ExchangeLogStatusType> response = serviceLayer.getExchangeStatusHistoryList(query.getStatus(), TypeRefType.POLL, from, to);
        return new ResponseDto(response, RestResponseCode.OK);
    } catch (Exception e) {
        log.error("[ Error when getting config search fields. {}] {}", query, e.getMessage());
        return ErrorHandler.getFault(e);
    }
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) ResponseDto(eu.europa.ec.fisheries.uvms.exchange.rest.dto.ResponseDto) Date(java.util.Date) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) RequiresFeature(eu.europa.ec.fisheries.uvms.rest.security.RequiresFeature)

Example 5 with ExchangeLogStatusType

use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogRestResource method getPollStatus.

@GET
@Consumes(value = { MediaType.APPLICATION_JSON })
@Produces(value = { MediaType.APPLICATION_JSON })
@Path(value = "/poll/{typeRefGuid}")
@RequiresFeature(UnionVMSFeature.viewExchange)
public ResponseDto getPollStatus(@PathParam("typeRefGuid") String typeRefGuid) {
    try {
        log.info("Get ExchangeLog status for Poll by typeRefGuid:{}", typeRefGuid);
        ExchangeLogStatusType response = serviceLayer.getExchangeStatusHistory(TypeRefType.POLL, typeRefGuid, request.getRemoteUser());
        return new ResponseDto(response, RestResponseCode.OK);
    } catch (Exception e) {
        log.error("[ Error when getting config search fields. {} ] {}", typeRefGuid, e.getMessage());
        return ErrorHandler.getFault(e);
    }
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) ResponseDto(eu.europa.ec.fisheries.uvms.exchange.rest.dto.ResponseDto) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) RequiresFeature(eu.europa.ec.fisheries.uvms.rest.security.RequiresFeature)

Aggregations

ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)9 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)5 ArrayList (java.util.ArrayList)4 ExchangeLogStatusHistoryType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType)3 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)3 TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)3 ExchangeLogStatus (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)3 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)2 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)2 ExchangeDaoException (eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException)2 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException)2 ResponseDto (eu.europa.ec.fisheries.uvms.exchange.rest.dto.ResponseDto)2 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)2 RequiresFeature (eu.europa.ec.fisheries.uvms.rest.security.RequiresFeature)2 Consumes (javax.ws.rs.Consumes)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 LogRefIdByTypeExistsRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.LogRefIdByTypeExistsRequest)1 LogRefIdByTypeExistsResponse (eu.europa.ec.fisheries.schema.exchange.module.v1.LogRefIdByTypeExistsResponse)1 ExchangeHistoryListQuery (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeHistoryListQuery)1