Search in sources :

Example 1 with ExchangeLogStatusHistoryType

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

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

the class LogMapper method toStatusModel.

public static ExchangeLogStatusType toStatusModel(ExchangeLog exchangeLog) {
    ExchangeLogStatusType model = new ExchangeLogStatusType();
    if (exchangeLog.getType().equals(LogType.SEND_POLL)) {
        model.setIdentifier(exchangeLog.getRecipient());
    }
    model.setGuid(exchangeLog.getGuid());
    if (exchangeLog.getTypeRefType() != null) {
        LogRefType logRefType = new LogRefType();
        logRefType.setRefGuid(exchangeLog.getTypeRefGuid());
        logRefType.setType(exchangeLog.getTypeRefType());
        logRefType.setMessage(exchangeLog.getTypeRefMessage());
        model.setTypeRef(logRefType);
    }
    if (exchangeLog.getStatusHistory() != null) {
        List<ExchangeLogStatusHistoryType> historyModelList = new ArrayList<>();
        for (ExchangeLogStatus history : exchangeLog.getStatusHistory()) {
            ExchangeLogStatusHistoryType historyModel = new ExchangeLogStatusHistoryType();
            historyModel.setStatus(history.getStatus());
            historyModel.setTimestamp(history.getStatusTimestamp());
            historyModelList.add(historyModel);
        }
        model.getHistory().addAll(historyModelList);
    }
    return model;
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) ExchangeLogStatusHistoryType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType) ArrayList(java.util.ArrayList) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType) ExchangeLogStatus(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)

Example 3 with ExchangeLogStatusHistoryType

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

the class ExchangeLogModelBean method updateExchangeLogStatus.

@Override
public ExchangeLogType updateExchangeLogStatus(ExchangeLogStatusType status, String username) throws ExchangeModelException {
    if (status == null || status.getGuid() == null || status.getGuid().isEmpty()) {
        throw new InputArgumentException("No exchange log to update status");
    }
    if (status.getHistory() == null || status.getHistory().isEmpty() || status.getHistory().size() != 1) {
        throw new InputArgumentException("Non valid status to update to");
    }
    try {
        ExchangeLogStatusHistoryType updateStatus = status.getHistory().get(0);
        ExchangeLog exchangeLog = logDao.getExchangeLogByGuid(status.getGuid());
        List<ExchangeLogStatus> statusList = exchangeLog.getStatusHistory();
        statusList.add(LogMapper.toNewStatusEntity(exchangeLog, updateStatus.getStatus(), username));
        exchangeLog.setStatus(updateStatus.getStatus());
        ExchangeLog retEntity = logDao.updateLog(exchangeLog);
        ExchangeLogType retType = LogMapper.toModel(retEntity);
        return retType;
    } catch (ExchangeDaoException ex) {
        LOG.error("[ Error when update status of Exchange log {} {}] {}", status, username, ex.getMessage());
        throw new ExchangeModelException("Error when update status of Exchange log", ex);
    }
}
Also used : InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException) ExchangeLogStatusHistoryType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType) 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)

Aggregations

ExchangeLogStatusHistoryType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType)3 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)2 ExchangeLogStatus (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)2 ArrayList (java.util.ArrayList)2 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)1 LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)1 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)1 ExchangeDaoException (eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException)1 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)1 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException)1