use of com.autentia.tnt.businessobject.Position in project TNTConcept by autentia.
the class PositionManager method trackEntityChanges.
/* Position - generated by stajanov (do not edit/delete) */
/**
* Mira los campos de la entidad a ver si se han producido cambios
*
* @return true si se produjo algun cambio
*/
private boolean trackEntityChanges(Position position) {
int previousHistorySize = position.getHistory().size();
int finalHistorySize = previousHistorySize;
final Position changes = position.getChanges();
// TODO ¿podría ser por reflexion para obtener los atributos persistentes?
if (changes != null) {
if (changes.getName() != null && !changes.getName().equals(position.getName())) {
position.getHistory().add(getChange(position, FIELD_NAME, changes.getName(), position.getName()));
this.trackContactChanges(position);
}
position.getHistory().add(getChange(position, FIELD_DESCRIPTION, changes.getDescription(), position.getDescription()));
position.getHistory().add(getChange(position, FIELD_EMAIL, changes.getEmail(), position.getEmail()));
position.getHistory().add(getChange(position, FIELD_PHONE, changes.getPhone(), position.getPhone()));
position.getHistory().add(getChange(position, FIELD_FAX, changes.getFax(), position.getFax()));
position.getHistory().add(getChange(position, FIELD_COUNTRY, changes.getCountry(), position.getCountry()));
position.getHistory().add(getChange(position, FIELD_POSTALCODE, changes.getPostalCode(), position.getPostalCode()));
position.getHistory().add(getChange(position, FIELD_ADDRESS, changes.getAddress(), position.getAddress()));
position.getHistory().add(getChange(position, FIELD_CITY, changes.getCity(), position.getCity()));
position.getHistory().add(getProvinceChange(position));
position.getHistory().addAll(getPositionTagChanges(position));
finalHistorySize = position.getHistory().size();
}
// if has changes previousHistorySize != finalHistorySize
return previousHistorySize != finalHistorySize;
}
use of com.autentia.tnt.businessobject.Position in project TNTConcept by autentia.
the class PositionManager method getProvinceChange.
private PositionChange getProvinceChange(Position position) {
String previous = "";
String now = "";
Position changes = position.getChanges();
// no está de más reflejarlo
if (changes.getProvince() != null) {
previous = StringUtils.defaultIfEmpty(changes.getProvince().getName(), "");
}
if (position.getProvince() != null) {
now = StringUtils.defaultIfEmpty(position.getProvince().getName(), "");
}
return getChange(position, FIELD_PROVINCE, previous, now);
}
use of com.autentia.tnt.businessobject.Position in project TNTConcept by autentia.
the class ContactPositionManagerTest method testDoAdvancedSearchHistorical.
/**
* Buscar por en historico y en activo
*/
@Test
public void testDoAdvancedSearchHistorical() {
final PositionDAO positionDAO = (PositionDAO) SpringUtilsForTesting.getSpringBean("daoPosition");
final ContactDAO contactDAO = (ContactDAO) SpringUtilsForTesting.getSpringBean("daoContact");
final EntityChangeDAO entityChangeDAO = (EntityChangeDAO) SpringUtilsForTesting.getSpringBean("daoEntityChange");
final ContactPositionManager contactPositionManager = new ContactPositionManager(contactDAO, positionDAO);
this.insertInitialData();
this.insertContactData();
// añadimos que Pilar Sancho fue becaria
final EntityChange changePosition = new EntityChange();
changePosition.setField(Contact.FIELD_POSITION);
changePosition.setNewValue("");
changePosition.setOldValue("becario");
changePosition.setEntityId(pilarSancho.getId());
changePosition.setEntityName("com.autentia.tnt.businessobject.Contact");
entityChangeDAO.insert(changePosition);
final AdvancedSearchContactSearch advancedSearch = new AdvancedSearchContactSearch();
final List<Position> positions = new ArrayList<Position>();
positions.add(becario);
advancedSearch.setPositions(positions);
final List<ContactPosition> contactPositions = contactPositionManager.doAdvancedSearch(advancedSearch, ACTIVE_AND_HISTORICAL);
// debe salir dos resultados, ya que hay uno que es becario actualmente y otro que lo fue
if (contactPositions.size() != 2) {
fail("Deberian haber salido 2 resultados, pero han salido " + contactPositions.size());
}
}
use of com.autentia.tnt.businessobject.Position in project TNTConcept by autentia.
the class ContactBean method getAllPositionsOfDepartment.
public List<SelectItem> getAllPositionsOfDepartment() {
final PositionSearch positionSearch = new PositionSearch();
positionSearch.setDepartmentId(this.getSelectedDepartment().getId());
positionSearch.setDeleted(false);
final List<Position> refs = PositionManager.getDefault().getAllEntities(positionSearch, new SortCriteria("name"));
final List<SelectItem> ret = new ArrayList<SelectItem>();
ret.add(new SelectItem(null, FacesUtils.getMessage("contact.selectOnePosition")));
for (Position ref : refs) {
ret.add(new SelectItem(ref, ref.getName()));
}
return ret;
}
use of com.autentia.tnt.businessobject.Position in project TNTConcept by autentia.
the class TagBean method createPositionTags.
/**
* Create a new empty instance of the one-to-many field
*
* @return forward to the same page
*/
public String createPositionTags() {
Position item = new Position();
if (tag.getPositionTags() == null) {
tag.setPositionTags(new HashSet());
}
tag.getPositionTags().add(item);
return null;
}
Aggregations