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