Search in sources :

Example 1 with Tag

use of com.autentia.tnt.businessobject.Tag in project TNTConcept by autentia.

the class DepartmentBean method deleteTag.

public String deleteTag() {
    final UIData table = (UIData) FacesUtils.getComponent("department:tags");
    final Tag toDelete = (Tag) table.getRowData();
    department.getTags().remove(toDelete);
    return NavigationResults.EDIT;
}
Also used : Tag(com.autentia.tnt.businessobject.Tag) UIData(javax.faces.component.UIData)

Example 2 with Tag

use of com.autentia.tnt.businessobject.Tag 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);
            }
        }
    }
}
Also used : EntityChange(com.autentia.tnt.tracking.EntityChange) Tag(com.autentia.tnt.businessobject.Tag) Contact(com.autentia.tnt.businessobject.Contact)

Example 3 with Tag

use of com.autentia.tnt.businessobject.Tag in project TNTConcept by autentia.

the class ContactBean method getAllTags.

public List<SelectItem> getAllTags() {
    final List<Tag> refs = TagManager.getDefault().getAllEntities(null, new SortCriteria("id"));
    final List<SelectItem> ret = new ArrayList<SelectItem>();
    for (Tag ref : refs) {
        ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList) Tag(com.autentia.tnt.businessobject.Tag)

Example 4 with Tag

use of com.autentia.tnt.businessobject.Tag in project TNTConcept by autentia.

the class ContactBean method deleteTag.

// public void setTags(Set<Tag> tags) {
// contact.setTags(tags);
// }
public String deleteTag() {
    final UIData table = (UIData) FacesUtils.getComponent("contact:tags");
    final Tag toDelete = (Tag) table.getRowData();
    contact.removeTag(toDelete);
    return NavigationResults.EDIT;
}
Also used : Tag(com.autentia.tnt.businessobject.Tag) UIData(javax.faces.component.UIData)

Example 5 with Tag

use of com.autentia.tnt.businessobject.Tag in project TNTConcept by autentia.

the class PositionBean method deleteTag.

public String deleteTag() {
    final UIData table = (UIData) FacesUtils.getComponent("position:tags");
    final Tag toDelete = (Tag) table.getRowData();
    position.getTags().remove(toDelete);
    return NavigationResults.EDIT;
}
Also used : Tag(com.autentia.tnt.businessobject.Tag) UIData(javax.faces.component.UIData)

Aggregations

Tag (com.autentia.tnt.businessobject.Tag)8 SortCriteria (com.autentia.tnt.dao.SortCriteria)3 ArrayList (java.util.ArrayList)3 UIData (javax.faces.component.UIData)3 SelectItem (javax.faces.model.SelectItem)3 Contact (com.autentia.tnt.businessobject.Contact)1 EntityChange (com.autentia.tnt.tracking.EntityChange)1 Date (java.util.Date)1