Search in sources :

Example 1 with ContactPartyEntity

use of eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityDataUtil method getContactPartyEntity.

public static ContactPartyEntity getContactPartyEntity(String title, String givenName, String middleName, String familyName, String familyNamePrefix, String nameSuffix, String gender, String alias) {
    ContactPartyEntity contPartEntity = new ContactPartyEntity();
    ContactPersonEntity contactPersonEntity = new ContactPersonEntity();
    contactPersonEntity.setTitle(title);
    contactPersonEntity.setGivenName(givenName);
    contactPersonEntity.setMiddleName(middleName);
    contactPersonEntity.setFamilyName(familyName);
    contactPersonEntity.setFamilyNamePrefix(familyNamePrefix);
    contactPersonEntity.setNameSuffix(nameSuffix);
    contactPersonEntity.setGender(gender);
    contactPersonEntity.setAlias(alias);
    contPartEntity.setContactPerson(contactPersonEntity);
    return contPartEntity;
}
Also used : ContactPersonEntity(eu.europa.ec.fisheries.ers.fa.entities.ContactPersonEntity) ContactPartyEntity(eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity)

Example 2 with ContactPartyEntity

use of eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class ContactPartyMapperTest method testContactPartyMapper.

@Test
public void testContactPartyMapper() {
    ContactParty contactParty = MapperUtil.getContactParty();
    ContactPartyEntity contactPartyEntity = ContactPartyMapper.INSTANCE.mapToContactPartyEntity(contactParty, null);
    ContactPartyRoleEntity entity = contactPartyEntity.getContactPartyRole().iterator().next();
    assertEquals(contactParty.getRoleCodes().get(0).getValue(), entity.getRoleCode());
    assertEquals(contactParty.getRoleCodes().get(0).getListID(), entity.getRoleCodeListId());
    assertNotNull(contactPartyEntity.getContactPerson());
    entity = contactPartyEntity.getContactPerson().getContactParty().getContactPartyRole().iterator().next();
    assertEquals(contactParty.getRoleCodes().get(0).getValue(), entity.getRoleCode());
    assertEquals(contactParty.getRoleCodes().get(0).getListID(), entity.getRoleCodeListId());
    assertNotNull(contactPartyEntity.getStructuredAddresses());
    StructuredAddressEntity structuredAddressEntity = contactPartyEntity.getStructuredAddresses().iterator().next();
    assertNotNull(structuredAddressEntity);
    entity = structuredAddressEntity.getContactParty().getContactPartyRole().iterator().next();
    assertEquals(contactParty.getRoleCodes().get(0).getValue(), entity.getRoleCode());
    assertEquals(contactParty.getRoleCodes().get(0).getListID(), entity.getRoleCodeListId());
}
Also used : StructuredAddressEntity(eu.europa.ec.fisheries.ers.fa.entities.StructuredAddressEntity) ContactPartyRoleEntity(eu.europa.ec.fisheries.ers.fa.entities.ContactPartyRoleEntity) ContactParty(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.ContactParty) ContactPartyEntity(eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity) Test(org.junit.Test)

Example 3 with ContactPartyEntity

use of eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEntityToModelMapper method mapSpecifiedContactParties.

private void mapSpecifiedContactParties(VesselTransportMeans target, Set<ContactPartyEntity> contactPartyEntities) {
    ArrayList<ContactParty> contactParties = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(contactPartyEntities)) {
        for (ContactPartyEntity source : contactPartyEntities) {
            ContactParty contactParty = new ContactParty();
            ContactPerson contactPerson = ContactPersonMapper.INSTANCE.mapToContactPerson(source.getContactPerson());
            if (contactPerson != null) {
                // TODO @Greg mapstruct add non-iterable type
                contactParty.setSpecifiedContactPersons(Collections.singletonList(contactPerson));
            }
            mapRoles(contactParty, source.getContactPartyRole());
            contactParty.setSpecifiedStructuredAddresses(StructuredAddressMapper.INSTANCE.mapToStructuredAddressList(source.getStructuredAddresses()));
            contactParties.add(contactParty);
        }
    }
    target.setSpecifiedContactParties(contactParties);
}
Also used : ArrayList(java.util.ArrayList) ContactParty(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.ContactParty) ContactPartyEntity(eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity) ContactPerson(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.ContactPerson)

Example 4 with ContactPartyEntity

use of eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingTripServiceBean method getFishingActivitySummaryList.

/**
 * This method creates FishingActivitySummary object from FishingActivityEntity object retrieved from database.
 *
 * @param uniqueActivityIdList      This method helps parent function to collect FishingActivities for all the fishingTrips. In order to avoid duplicate fishing Activities, we need to maintain uniqueActivityIdList
 * @param fishingActivityEntityList
 * @return
 */
public List<FishingActivitySummary> getFishingActivitySummaryList(List<FishingActivityEntity> fishingActivityEntityList, List<Integer> uniqueActivityIdList) {
    List<FishingActivitySummary> fishingActivitySummaryList = new ArrayList<>();
    if (CollectionUtils.isEmpty(uniqueActivityIdList)) {
        uniqueActivityIdList = new ArrayList<>();
    }
    for (FishingActivityEntity fishingActivityEntity : fishingActivityEntityList) {
        if (fishingActivityEntity != null && uniqueActivityIdList.add(fishingActivityEntity.getId())) {
            FishingActivitySummary fishingActivitySummary = FishingActivityMapper.INSTANCE.mapToFishingActivitySummary(fishingActivityEntity);
            ContactPartyEntity contactParty = getContactParty(fishingActivityEntity);
            if (contactParty != null) {
                VesselContactPartyType vesselContactParty = FishingActivityMapper.INSTANCE.mapToVesselContactParty(contactParty);
                fishingActivitySummary.setVesselContactParty(vesselContactParty);
            }
            if (fishingActivitySummary != null) {
                fishingActivitySummaryList.add(fishingActivitySummary);
            }
        }
    }
    return fishingActivitySummaryList;
}
Also used : FishingActivitySummary(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingActivitySummary) ArrayList(java.util.ArrayList) VesselContactPartyType(eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselContactPartyType) ContactPartyEntity(eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 5 with ContactPartyEntity

use of eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class ContactPartyMapperTest method testContactPartyMapperNullReturns.

@Test
public void testContactPartyMapperNullReturns() {
    Set<ContactPartyRoleEntity> contactPartyRoles = ContactPartyMapper.INSTANCE.getContactPartyRoles(null, new ContactPartyEntity());
    assertTrue(contactPartyRoles.size() == 0);
    ContactPersonEntity contactPersonEntity = ContactPartyMapper.INSTANCE.getContactPersonEntity(null, new ContactPartyEntity());
    assertNull(contactPersonEntity);
    Set<StructuredAddressEntity> structuredAddressEntity = ContactPartyMapper.INSTANCE.getStructuredAddressEntity(null, new ContactPartyEntity());
    assertTrue(structuredAddressEntity.size() == 0);
}
Also used : ContactPersonEntity(eu.europa.ec.fisheries.ers.fa.entities.ContactPersonEntity) StructuredAddressEntity(eu.europa.ec.fisheries.ers.fa.entities.StructuredAddressEntity) ContactPartyRoleEntity(eu.europa.ec.fisheries.ers.fa.entities.ContactPartyRoleEntity) ContactPartyEntity(eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity) Test(org.junit.Test)

Aggregations

ContactPartyEntity (eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity)9 ContactPartyRoleEntity (eu.europa.ec.fisheries.ers.fa.entities.ContactPartyRoleEntity)3 StructuredAddressEntity (eu.europa.ec.fisheries.ers.fa.entities.StructuredAddressEntity)3 Test (org.junit.Test)3 ContactParty (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.ContactParty)3 ContactPersonEntity (eu.europa.ec.fisheries.ers.fa.entities.ContactPersonEntity)2 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)2 FishingActivitySummary (eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingActivitySummary)2 VesselContactPartyType (eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselContactPartyType)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)1 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)1 StructuredAddressTypeEnum (eu.europa.ec.fisheries.ers.fa.utils.StructuredAddressTypeEnum)1 ContactPerson (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.ContactPerson)1 StructuredAddress (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.StructuredAddress)1