use of com.autentia.tnt.businessobject.Contact in project TNTConcept by autentia.
the class ContactPositionManager method recoverChangesFromContact.
/**
* TODO
*/
private List<ContactPosition> recoverChangesFromContact(final AdvancedSearchContactSearch advancedSearch) {
final List<EntityChange> changes = contactDAO.contactAdvancedSearchChanges(advancedSearch);
final List<Contact> contacts = new ArrayList<Contact>(changes.size());
final List<ContactPosition> contactPositions = new ArrayList<ContactPosition>(contacts.size());
String changeValueDescription;
for (EntityChange entityChange : changes) {
final ContactPosition contactPosition = new ContactPosition();
final Contact contact = contactDAO.loadById(entityChange.getEntityId());
contactPosition.setName(contact.getName());
// recovers the text to show in the description of the change
if (!(entityChange.getNewValue() == null || entityChange.getNewValue().equals(""))) {
changeValueDescription = entityChange.getOldValue() + " [" + entityChange.getNewValue() + "]";
} else {
changeValueDescription = entityChange.getOldValue();
}
// add the description by field
if (entityChange.getField().equals(Contact.FIELD_POSITION)) {
contactPosition.setPosition(changeValueDescription);
} else if (entityChange.getField().equals(Contact.FIELD_ORGANIZATION)) {
contactPosition.setOrganization(changeValueDescription);
} else if (entityChange.getField().equals(Contact.FIELD_NAME)) {
contactPosition.setName(changeValueDescription);
} else if (entityChange.getField().equals(Contact.FIELD_DEPARTMENT)) {
contactPosition.setDepartment(changeValueDescription);
} else if (entityChange.getField().equals(Contact.FIELD_EMAIL)) {
contactPosition.setEmail(changeValueDescription);
} else if (entityChange.getField().equals(Contact.FIELD_PHONE)) {
contactPosition.setPhone(changeValueDescription);
} else if (entityChange.getField().equals(Contact.FIELD_FAX)) {
contactPosition.setFax(changeValueDescription);
} else if (entityChange.getField().equals(Contact.FIELD_COUNTRY)) {
contactPosition.setCountry(changeValueDescription);
} else if (entityChange.getField().equals(Contact.FIELD_PROVINCE)) {
contactPosition.setProvince(changeValueDescription);
} else if (entityChange.getField().equals(Contact.FIELD_CITY)) {
contactPosition.setCity(changeValueDescription);
} else if (entityChange.getField().equals(Contact.FIELD_POSTALCODE)) {
contactPosition.setPostalCode(changeValueDescription);
} else if (entityChange.getField().equals(Contact.FIELD_ADDRESS)) {
contactPosition.setAddress(changeValueDescription);
}
contactPositions.add(contactPosition);
}
return contactPositions;
}
use of com.autentia.tnt.businessobject.Contact in project TNTConcept by autentia.
the class OrganizationManager method trackContactChanges.
private void trackContactChanges(Organization organization) {
if (!organization.getName().equals(organization.getChanges().getName())) {
final List<Contact> contacts = organizationDAO.getContactsForOrganization(organization);
for (Contact contact : contacts) {
contact.addEntityChange(Contact.FIELD_ORGANIZATION, organization.getChanges().getName(), organization.getName(), organization.getId().toString());
contactDAO.update(contact);
}
}
}
use of com.autentia.tnt.businessobject.Contact in project TNTConcept by autentia.
the class PositionManager method trackContactChanges.
private void trackContactChanges(Position position) {
if (!position.getName().equals(position.getChanges().getName())) {
final List<Contact> contacts = positionDAO.getContactsForPosition(position);
for (Contact contact : contacts) {
contact.addEntityChange(Contact.FIELD_POSITION, position.getChanges().getName(), position.getName(), position.getId().toString());
contactDAO.update(contact);
}
}
}
use of com.autentia.tnt.businessobject.Contact in project TNTConcept by autentia.
the class TagManager method trackContactChanges.
private void trackContactChanges(Tag tag) {
// tracking associated Contacts
for (Contact contact : tag.getContactTags()) {
final Contact contactBD = ContactManager.getDefault().getEntityById(contact.getId());
if (!contactBD.getTags().contains(tag)) {
// FIXME aqui debería bastar con añadir el cambio o el tag al contacto y salvar el contacto
// para que se actualizase con los listener de hibernate. Por algún motivo, sólo cuando se da de alta
// una nueva clave y se asocia a un contacto antes de guardar no funciona correctamente.
EntityChange entityChange = contactBD.getEntityChange(Contact.FIELD_TAGS, "", tag.getName(), tag.getId().toString());
contactBD.addEntityChange(Contact.FIELD_TAGS, "", tag.getName(), tag.getId().toString());
if (entityChange != null) {
entityChangeDAO.insert(entityChange);
}
}
}
// tracking deassociated Contacts
if (tag.getId() != null) {
Tag tagDB = getEntityById(tag.getId());
for (Contact contactDB : tagDB.getContactTags()) {
if (!tag.getContactTags().contains(contactDB)) {
contactDB.addEntityChange(Contact.FIELD_TAGS, tag.getName(), "", tag.getId().toString());
contactDAO.update(contactDB);
}
}
}
}
use of com.autentia.tnt.businessobject.Contact in project TNTConcept by autentia.
the class DepartmentManager method trackContactChanges.
private void trackContactChanges(Department department) {
if (!department.getName().equals(department.getChanges().getName())) {
final List<Contact> contacts = departmentDAO.getContactsForDepartment(department);
for (Contact contact : contacts) {
contact.addEntityChange(Contact.FIELD_DEPARTMENT, department.getChanges().getName(), department.getName(), department.getId().toString());
contactDAO.update(contact);
}
}
}
Aggregations