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);
}
}
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.");
}
}
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;
}
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);
}
}
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);
}
}
Aggregations