Search in sources :

Example 1 with ContactPartyRoleEntity

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

the class ActivityEntityToModelMapper method mapRoles.

private void mapRoles(ContactParty target, Set<ContactPartyRoleEntity> contactPartyRoleEntities) {
    List<CodeType> codeTypeList = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(contactPartyRoleEntities)) {
        for (ContactPartyRoleEntity source : contactPartyRoleEntities) {
            CodeType codeType = new CodeType();
            codeType.setValue(source.getRoleCode());
            codeType.setListID(source.getRoleCodeListId());
            codeTypeList.add(codeType);
        }
    }
    target.setRoleCodes(codeTypeList);
}
Also used : ArrayList(java.util.ArrayList) CodeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.CodeType) ContactPartyRoleEntity(eu.europa.ec.fisheries.ers.fa.entities.ContactPartyRoleEntity)

Example 2 with ContactPartyRoleEntity

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

the class ActivityDataUtil method getContactPartyRole.

public static Set<ContactPartyRoleEntity> getContactPartyRole(String roleCode, String roleID, ContactPartyEntity contPartEntity) {
    Set<ContactPartyRoleEntity> rolesList = new HashSet<>();
    ContactPartyRoleEntity entity_1 = new ContactPartyRoleEntity();
    entity_1.setContactParty(contPartEntity);
    entity_1.setRoleCode(roleCode);
    entity_1.setRoleCodeListId(roleID);
    rolesList.add(entity_1);
    return rolesList;
}
Also used : ContactPartyRoleEntity(eu.europa.ec.fisheries.ers.fa.entities.ContactPartyRoleEntity) HashSet(java.util.HashSet)

Example 3 with ContactPartyRoleEntity

use of eu.europa.ec.fisheries.ers.fa.entities.ContactPartyRoleEntity 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 4 with ContactPartyRoleEntity

use of eu.europa.ec.fisheries.ers.fa.entities.ContactPartyRoleEntity 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)

Example 5 with ContactPartyRoleEntity

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

the class MapperUtil method getFishingTripEntityWithContactParties.

public static FishingTripEntity getFishingTripEntityWithContactParties() {
    FishingTripEntity fishingTripEntity = getFishingTripEntity();
    Set<VesselTransportMeansEntity> vesselTransportEntityList = fishingTripEntity.getFishingActivity().getFaReportDocument().getVesselTransportMeans();
    Set<ContactPartyEntity> contactParties = new HashSet<>();
    ContactPartyEntity contPartEntity_1 = ActivityDataUtil.getContactPartyEntity("title1", "givenName1", "middleName1", "familyName1", "familyNamePrefix1", "nameSuffix1", "gender1", "alias1");
    ContactPartyEntity contPartEntity_2 = ActivityDataUtil.getContactPartyEntity("title2", "givenName2", "middleName2", "familyName2", "familyNamePrefix2", "nameSuffix2", "gender2", "alias2");
    Set<ContactPartyRoleEntity> roleList_1 = ActivityDataUtil.getContactPartyRole("SOMEROLE", "ROLE_CODE1", contPartEntity_1);
    Set<ContactPartyRoleEntity> roleList_2 = ActivityDataUtil.getContactPartyRole("MASTER", "ROLE_CODE2", contPartEntity_2);
    contPartEntity_1.setContactPartyRole(roleList_1);
    contPartEntity_2.setContactPartyRole(roleList_2);
    contactParties.addAll(Arrays.asList(contPartEntity_1, contPartEntity_2));
    for (VesselTransportMeansEntity vesselTransportMeansEntity : vesselTransportEntityList) {
        vesselTransportMeansEntity.setContactParty(contactParties);
    }
    return fishingTripEntity;
}
Also used : FishingTripEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity) VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) ContactPartyRoleEntity(eu.europa.ec.fisheries.ers.fa.entities.ContactPartyRoleEntity) ContactPartyEntity(eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity) HashSet(java.util.HashSet)

Aggregations

ContactPartyRoleEntity (eu.europa.ec.fisheries.ers.fa.entities.ContactPartyRoleEntity)6 ContactPartyEntity (eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity)3 HashSet (java.util.HashSet)3 StructuredAddressEntity (eu.europa.ec.fisheries.ers.fa.entities.StructuredAddressEntity)2 Test (org.junit.Test)2 CodeType (un.unece.uncefact.data.standard.unqualifieddatatype._20.CodeType)2 ContactPersonEntity (eu.europa.ec.fisheries.ers.fa.entities.ContactPersonEntity)1 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)1 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)1 ArrayList (java.util.ArrayList)1 ContactParty (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.ContactParty)1