Example usage for com.vaadin.v7.data.util BeanItemContainer addAll

List of usage examples for com.vaadin.v7.data.util BeanItemContainer addAll

Introduction

In this page you can find the example usage for com.vaadin.v7.data.util BeanItemContainer addAll.

Prototype

@Override
public void addAll(Collection<? extends BEANTYPE> collection) 

Source Link

Document

Adds all the beans from a Collection in one go.

Usage

From source file:de.symeda.sormas.ui.caze.AbstractTableField.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from   w ww  . jav a 2 s.c  o m
protected void setValue(Collection newFieldValue, boolean repaintIsNotNeeded, boolean ignoreReadOnly)
        throws com.vaadin.v7.data.Property.ReadOnlyException, ConversionException, InvalidValueException {

    BeanItemContainer<E> container = getContainer();
    if (container == null) {
        return;
    }

    container.removeAllItems();
    container.addAll(newFieldValue);
    table.refreshRowCache();

    fireValueChange(repaintIsNotNeeded);
}

From source file:org.esn.esobase.data.DBService.java

@Transactional
public BeanItemContainer<Subtitle> getNpcSubtitles(Npc npc, BeanItemContainer<Subtitle> container,
        Set<TRANSLATE_STATUS> translateStatus, SysAccount translator, boolean noTranslations,
        boolean emptyTranslations, String searchString) {
    container.removeAllItems();/*from  ww w.  ja  v a 2  s .c  om*/
    List<Subtitle> list = subtitleRepository.findAll(new SubtitleSpecification(npc, translateStatus, translator,
            noTranslations, emptyTranslations, searchString));
    if (searchString != null && searchString.length() > 2) {
        container.addAll(list);
    } else {
        List<Subtitle> orderedSubtitles = new ArrayList<>();
        for (Subtitle s : list) {
            if (!orderedSubtitles.contains(s)) {
                orderedSubtitles.add(s);
                addAllPreviousSubtitles(orderedSubtitles, s);
                addAllNextSubtitles(orderedSubtitles, s);
            }
        }
        container.addAll(orderedSubtitles);
    }
    return container;
}

From source file:org.esn.esobase.data.DBService.java

@Transactional
public BeanItemContainer<Npc> getNpcs(BeanItemContainer<Npc> container, TRANSLATE_STATUS translateStatus,
        SysAccount translator, boolean noTranslations) {
    container.removeAllItems();//from   ww w .  ja  v  a2s .c om
    Session session = (Session) em.getDelegate();
    Criteria crit = session.createCriteria(Npc.class);
    crit.setFetchMode("location", FetchMode.JOIN);
    if (translateStatus != null && translator != null) {
        Query q = em.createNativeQuery(
                "select npc_id from (select t.npc_id from translatedtext tt join topic t on tt.npctopic_id=t.id where tt.status=:translateStatus and tt.author_id=:authorId\n"
                        + "union all select t.npc_id from translatedtext tt join topic t on tt.playertopic_id=t.id where tt.status=:translateStatus and tt.author_id=:authorId\n"
                        + "union all select t.npc_id from translatedtext tt join greeting t on tt.greeting_id=t.id where tt.status=:translateStatus and tt.author_id=:authorId\n"
                        + "union all select t.npc_id from translatedtext tt join subtitle t on tt.subtitle_id=t.id where tt.status=:translateStatus and tt.author_id=:authorId) as rr group by npc_id");
        q.setParameter("authorId", translator.getId());
        q.setParameter("translateStatus", translateStatus.name());
        List<BigInteger> resultList = q.getResultList();
        List<Long> longResultList = new ArrayList();
        for (BigInteger id : resultList) {
            longResultList.add(id.longValue());
        }
        if (longResultList.isEmpty()) {
            longResultList.add(0L);
        }
        crit.add(Restrictions.in("id", longResultList));
    } else if (translateStatus != null) {
        Query q = em.createNativeQuery(
                "select npc_id from (select t.npc_id from translatedtext tt join topic t on tt.npctopic_id=t.id where tt.status=:translateStatus\n"
                        + "union all select t.npc_id from translatedtext tt join topic t on tt.playertopic_id=t.id where tt.status=:translateStatus\n"
                        + "union all select t.npc_id from translatedtext tt join greeting t on tt.greeting_id=t.id where tt.status=:translateStatus\n"
                        + "union all select t.npc_id from translatedtext tt join subtitle t on tt.subtitle_id=t.id where tt.status=:translateStatus) as rr group by npc_id");
        q.setParameter("translateStatus", translateStatus.name());
        List<BigInteger> resultList = q.getResultList();
        List<Long> longResultList = new ArrayList();
        for (BigInteger id : resultList) {
            longResultList.add(id.longValue());
        }
        if (longResultList.isEmpty()) {
            longResultList.add(0L);
        }
        crit.add(Restrictions.in("id", longResultList));
    } else if (translator != null) {
        Query q = em.createNativeQuery(
                "select npc_id from (select t.npc_id from translatedtext tt join topic t on tt.npctopic_id=t.id where tt.author_id=:authorId\n"
                        + "union all select t.npc_id from translatedtext tt join topic t on tt.playertopic_id=t.id where tt.author_id=:authorId\n"
                        + "union all select t.npc_id from translatedtext tt join greeting t on tt.greeting_id=t.id where tt.author_id=:authorId\n"
                        + "union all select t.npc_id from translatedtext tt join subtitle t on tt.subtitle_id=t.id where tt.author_id=:authorId) as rr group by npc_id");
        q.setParameter("authorId", translator.getId());
        List<BigInteger> resultList = q.getResultList();
        List<Long> longResultList = new ArrayList();
        for (BigInteger id : resultList) {
            longResultList.add(id.longValue());
        }
        if (longResultList.isEmpty()) {
            longResultList.add(0L);
        }
        crit.add(Restrictions.in("id", longResultList));
    }
    if (noTranslations) {
        crit.add(Restrictions.lt("progress", BigDecimal.ONE));
    }
    crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
    List<Npc> list = crit.list();
    container.addAll(list);
    return container;
}

From source file:org.esn.esobase.data.DBService.java

@Transactional
public BeanItemContainer loadBeanItems(BeanItemContainer container) {
    container.removeAllItems();/*from w ww  .ja  v  a2  s  . co  m*/
    Session session = (Session) em.getDelegate();
    Criteria crit = session.createCriteria(container.getBeanType());
    container.addAll(crit.list());
    return container;
}