Search in sources :

Example 1 with DateTimeType

use of un.unece.uncefact.data.standard.unqualifieddatatype._100.DateTimeType in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEntityToModelMapper method mapAcceptanceDateTime.

private void mapAcceptanceDateTime(FAReportDocument target, Date source) {
    if (ObjectUtils.allNotNull(target, source)) {
        DateTimeType dateTimeType = new DateTimeType();
        dateTimeType.setDateTime(DateUtils.dateToXmlGregorian(source));
        target.setAcceptanceDateTime(dateTimeType);
    }
}
Also used : DateTimeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.DateTimeType)

Example 2 with DateTimeType

use of un.unece.uncefact.data.standard.unqualifieddatatype._100.DateTimeType in project UVMS-ActivityModule-APP by UnionVMS.

the class FaQueryFactory method createFaQueryForTrip.

public static FAQuery createFaQueryForTrip(String tripId, String sendTo, boolean consolidated) {
    FAQuery faq = new FAQuery();
    faq.setID(new IDType(UUID.randomUUID().toString(), "UUID", null, null, null, null, null, null));
    faq.setTypeCode(new CodeType("TRIP", "FA_QUERY_TYPE", null, null, null, null, null, null, null, null));
    try {
        final XMLGregorianCalendar currentDate = DateUtils.getCurrentDate();
        faq.setSubmittedDateTime(new DateTimeType(currentDate, null));
    } catch (DatatypeConfigurationException e) {
        log.error("[ERROR] Error while trying to create XMLGregorianCalendar () DateUtils.getCurrentDate()! Going to retry", e);
        return null;
    }
    faq.setSubmitterFLUXParty(new FLUXParty(Collections.singletonList(new IDType(sendTo, "FLUX_GP_PARTY", null, null, null, null, null, null)), null));
    faq.setSimpleFAQueryParameters(Arrays.asList(new FAQueryParameter(new CodeType("TRIPID", "FA_QUERY_PARAMETER", null, null, null, null, null, null, null, null), null, null, new IDType(tripId, "EU_TRIP_ID", null, null, null, null, null, null)), new FAQueryParameter(new CodeType("CONSOLIDATED", "FA_QUERY_PARAMETER", null, null, null, null, null, null, null, null), new CodeType(consolidated ? "Y" : "N", "BOOLEAN_VALUE", null, null, null, null, null, null, null, null), null, null)));
    return faq;
}
Also used : FAQueryParameter(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAQueryParameter) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) DateTimeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.DateTimeType) FAQuery(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAQuery) CodeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.CodeType) IDType(un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType) FLUXParty(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FLUXParty)

Example 3 with DateTimeType

use of un.unece.uncefact.data.standard.unqualifieddatatype._100.DateTimeType in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityToSubscriptionMapperTest method before.

@Before
@SneakyThrows
public void before() {
    IDType idType = new IDType();
    idType.setSchemeID("FLUX_GP_PARTY");
    idType.setValue("BEL");
    FLUXParty fluxParty = new FLUXParty();
    fluxParty.setIDS(Collections.singletonList(idType));
    DelimitedPeriod delimitedPeriod = new DelimitedPeriod();
    DateTimeType startDateTime = new DateTimeType();
    GregorianCalendar cal = new GregorianCalendar();
    DateTime dateTime = DateUtils.XML_FORMATTER.parseDateTime("2016-07-01T02:00:00.000+02:00");
    cal.setTime(dateTime.toDate());
    XMLGregorianCalendar xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
    startDateTime.setDateTime(xmlDate);
    delimitedPeriod.setStartDateTime(startDateTime);
    DateTimeType endDateTime = new DateTimeType();
    GregorianCalendar cal2 = new GregorianCalendar();
    DateTime dateTime2 = DateUtils.XML_FORMATTER.parseDateTime("2017-07-01T02:00:00.000+02:00");
    cal2.setTime(dateTime2.toDate());
    XMLGregorianCalendar xmlDate2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal2);
    endDateTime.setDateTime(xmlDate2);
    delimitedPeriod.setEndDateTime(endDateTime);
    FAQueryParameter faQueryParameter = new FAQueryParameter();
    CodeType codeType = new CodeType();
    codeType.setValue(SubCriteriaType.VESSELID.value());
    faQueryParameter.setTypeCode(codeType);
    IDType idType0 = new IDType();
    idType0.setValue("PD2438");
    idType0.setSchemeID("IRCS");
    faQueryParameter.setValueID(idType0);
    FAQueryParameter faQueryParameter2 = new FAQueryParameter();
    CodeType codeType2 = new CodeType();
    codeType2.setValue(SubCriteriaType.VESSELID.value());
    faQueryParameter2.setTypeCode(codeType2);
    IDType idType2 = new IDType();
    idType2.setValue("SVN123456789");
    idType2.setSchemeID("CFR");
    faQueryParameter2.setValueID(idType2);
    FAQueryParameter faQueryParameter3 = new FAQueryParameter();
    CodeType codeType3 = new CodeType();
    codeType3.setValue(SubCriteriaType.TRIPID.value());
    faQueryParameter3.setTypeCode(codeType3);
    IDType idType3 = new IDType();
    idType3.setValue("FRA-TRP-2016122102030");
    idType3.setSchemeID("EU_TRIP_ID");
    faQueryParameter3.setValueID(idType3);
    FAQueryParameter faQueryParameter4 = new FAQueryParameter();
    CodeType codeType4 = new CodeType();
    codeType4.setValue("CONSOLIDATED");
    CodeType valueCode = new CodeType();
    valueCode.setListID("BOOLEAN_VALUE");
    valueCode.setValue("Y");
    faQueryParameter4.setTypeCode(codeType4);
    faQueryParameter4.setValueCode(valueCode);
    List<FAQueryParameter> faQueryParameters = new ArrayList<>();
    faQueryParameters.add(faQueryParameter);
    faQueryParameters.add(faQueryParameter2);
    faQueryParameters.add(faQueryParameter3);
    faQueryParameters.add(faQueryParameter4);
    FAQuery faQuery = new FAQuery();
    faQuery.setSpecifiedDelimitedPeriod(delimitedPeriod);
    faQuery.setSimpleFAQueryParameters(faQueryParameters);
    faQuery.setSubmitterFLUXParty(fluxParty);
    fluxfaQueryMessage.setFAQuery(faQuery);
}
Also used : FAQueryParameter(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAQueryParameter) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DateTimeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.DateTimeType) DelimitedPeriod(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.DelimitedPeriod) FAQuery(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAQuery) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ArrayList(java.util.ArrayList) CodeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.CodeType) IDType(un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType) FLUXParty(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FLUXParty) DateTime(org.joda.time.DateTime) Before(org.junit.Before) SneakyThrows(lombok.SneakyThrows)

Example 4 with DateTimeType

use of un.unece.uncefact.data.standard.unqualifieddatatype._100.DateTimeType in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityMapper method getCalculatedStartTime.

protected DateTimeType getCalculatedStartTime(FishingActivity fishingActivity) {
    if (fishingActivity == null)
        return null;
    DateTimeType dateTimeType = null;
    if (fishingActivity.getOccurrenceDateTime() != null)
        return fishingActivity.getOccurrenceDateTime();
    if (CollectionUtils.isNotEmpty(fishingActivity.getSpecifiedDelimitedPeriods())) {
        List<DelimitedPeriod> delimitedPeriodEntities = fishingActivity.getSpecifiedDelimitedPeriods();
        dateTimeType = delimitedPeriodEntities.iterator().next().getStartDateTime();
        if (dateTimeType != null) {
            return dateTimeType;
        }
    }
    // We reached till this point of code means FishingActivity has neither occurrence date or startDate for DelimitedPeriod.
    // In such cases, we need to check if its subactivities have date mentioned.
    // If yes, then take the first subactivity occurrence date and consider it as start date for parent fishing activity
    List<FishingActivity> relatedFishingActivities = fishingActivity.getRelatedFishingActivities();
    if (CollectionUtils.isNotEmpty(relatedFishingActivities)) {
        for (FishingActivity subFishingActivity : relatedFishingActivities) {
            if (subFishingActivity.getOccurrenceDateTime() != null || (CollectionUtils.isNotEmpty(fishingActivity.getSpecifiedDelimitedPeriods()) && fishingActivity.getSpecifiedDelimitedPeriods().iterator().next().getStartDateTime() != null)) {
                dateTimeType = subFishingActivity.getOccurrenceDateTime();
                if (dateTimeType == null) {
                    dateTimeType = fishingActivity.getSpecifiedDelimitedPeriods().iterator().next().getStartDateTime();
                }
                return dateTimeType;
            }
        }
    }
    return null;
}
Also used : FishingActivity(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity) DateTimeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.DateTimeType) DelimitedPeriod(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.DelimitedPeriod)

Example 5 with DateTimeType

use of un.unece.uncefact.data.standard.unqualifieddatatype._100.DateTimeType in project UVMS-ActivityModule-APP by UnionVMS.

the class MapperUtil method getRegistrationEvent.

public static RegistrationEvent getRegistrationEvent() {
    List<TextType> descriptions = Arrays.asList(getTextType("This is test Text"));
    DateTimeType occurrenceDateTime = getDateTimeType("2016-07-01 11:15:00");
    RegistrationLocation relatedRegistrationLocation = getRegistrationLocation();
    RegistrationEvent registrationEvent = new RegistrationEvent(descriptions, occurrenceDateTime, relatedRegistrationLocation);
    return registrationEvent;
}
Also used : RegistrationLocation(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.RegistrationLocation) DateTimeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.DateTimeType) RegistrationEvent(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.RegistrationEvent) TextType(un.unece.uncefact.data.standard.unqualifieddatatype._20.TextType)

Aggregations

DateTimeType (un.unece.uncefact.data.standard.unqualifieddatatype._20.DateTimeType)17 CodeType (un.unece.uncefact.data.standard.unqualifieddatatype._20.CodeType)9 BigDecimal (java.math.BigDecimal)7 IDType (un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType)7 CGlobal (com.helger.commons.CGlobal)6 ValueEnforcer (com.helger.commons.ValueEnforcer)6 CollectionHelper (com.helger.commons.collection.CollectionHelper)6 EqualsHelper (com.helger.commons.equals.EqualsHelper)6 ErrorList (com.helger.commons.error.list.ErrorList)6 IErrorList (com.helger.commons.error.list.IErrorList)6 MathHelper (com.helger.commons.math.MathHelper)6 ETriState (com.helger.commons.state.ETriState)6 StringHelper (com.helger.commons.string.StringHelper)6 Serializable (java.io.Serializable)6 LocalDate (java.time.LocalDate)6 Consumer (java.util.function.Consumer)6 Nonnull (javax.annotation.Nonnull)6 Nullable (javax.annotation.Nullable)6 CrossIndustryInvoiceType (un.unece.uncefact.data.standard.crossindustryinvoice._100.CrossIndustryInvoiceType)6 FormattedDateTimeType (un.unece.uncefact.data.standard.qualifieddatatype._100.FormattedDateTimeType)6