Search in sources :

Example 1 with PollStatus

use of eu.europa.ec.fisheries.schema.exchange.v1.PollStatus 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 2 with PollStatus

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

the class ExchangeLogModelBean method setPollStatus.

@Override
public ExchangeLogType setPollStatus(PollStatus pollStatus, String username) throws ExchangeModelException {
    ExchangeLogType log = null;
    if (pollStatus == null || pollStatus.getPollGuid() == null) {
        throw new InputArgumentException("No poll id to update status");
    }
    try {
        List<ExchangeLog> exchangeLogByTypesRefAndGuid = logDao.getExchangeLogByTypesRefAndGuid(pollStatus.getPollGuid(), Collections.singletonList(TypeRefType.POLL));
        if (CollectionUtils.isNotEmpty(exchangeLogByTypesRefAndGuid)) {
            List<ExchangeLogStatus> statusList = exchangeLogByTypesRefAndGuid.get(0).getStatusHistory();
            statusList.add(LogMapper.toNewStatusEntity(exchangeLogByTypesRefAndGuid.get(0), pollStatus.getStatus(), username));
            exchangeLogByTypesRefAndGuid.get(0).setStatus(pollStatus.getStatus());
            ExchangeLog retEntity = logDao.updateLog(exchangeLogByTypesRefAndGuid.get(0));
            log = LogMapper.toModel(retEntity);
        }
    } catch (ExchangeDaoException ex) {
        LOG.error("[ Error when set poll status {} {}] {}", pollStatus, username, ex.getMessage());
        throw new ExchangeModelException("Error when update status of Exchange log ");
    }
    return log;
}
Also used : InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog) ExchangeLogStatus(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)

Example 3 with PollStatus

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

the class ExchangeEventIncomingServiceBean method handleSetPollStatusAcknowledge.

private void handleSetPollStatusAcknowledge(ExchangePluginMethod method, String serviceClassName, AcknowledgeType ack) {
    log.debug(method + " was acknowledged in " + serviceClassName);
    try {
        PollStatus updatedLog = exchangeLog.setPollStatus(ack.getMessageId(), ack.getPollStatus().getPollId(), ack.getPollStatus().getStatus(), serviceClassName);
        // Long polling
        pollEvent.fire(new NotificationMessage("guid", updatedLog.getPollGuid()));
    } catch (ExchangeLogException e) {
        log.error(e.getMessage());
    }
}
Also used : PollStatus(eu.europa.ec.fisheries.schema.exchange.v1.PollStatus) NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)

Example 4 with PollStatus

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

the class ExchangeLogServiceBean method setPollStatus.

@Override
public PollStatus setPollStatus(String jmsCorrelationId, String pollId, ExchangeLogStatusTypeType logStatus, String username) throws ExchangeLogException {
    try {
        // Remove the message from cache, because legancy implementation
        logCache.acknowledged(jmsCorrelationId);
        PollStatus pollStatus = new PollStatus();
        pollStatus.setPollGuid(pollId);
        pollStatus.setStatus(logStatus);
        ExchangeLogType exchangeLogType = exchangeLogModel.setPollStatus(pollStatus, username);
        pollStatus.setExchangeLogGuid(exchangeLogType.getGuid());
        sendAuditLogMessageForUpdatePollStatus(pollId, username);
        // For long polling
        exchangeLogEvent.fire(new NotificationMessage("guid", pollStatus.getExchangeLogGuid()));
        return pollStatus;
    } catch (ExchangeModelMapperException e) {
        throw new ExchangeLogException("Couldn't update status of exchange log");
    } catch (ExchangeModelException e) {
        throw new ExchangeLogException("Couldn't update status of exchange log");
    }
}
Also used : PollStatus(eu.europa.ec.fisheries.schema.exchange.v1.PollStatus) ExchangeModelMapperException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException) NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)

Aggregations

ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)3 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)3 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)2 PollStatus (eu.europa.ec.fisheries.schema.exchange.v1.PollStatus)2 NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)2 ExchangeHistoryListQuery (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeHistoryListQuery)1 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)1 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)1 TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)1 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)1 ExchangeLogStatus (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)1 ExchangeDaoException (eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException)1 ExchangeModelMapperException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException)1 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException)1 ArrayList (java.util.ArrayList)1