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